1!function(){try{var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},e=(new t.Error).stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="9e2cc839-5bf8-4fa2-8069-cb093cb63b7c",t._sentryDebugIdIdentifier="sentry-dbid-9e2cc839-5bf8-4fa2-8069-cb093cb63b7c")}catch(t){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[36865],{38399:(t,e,i)=>{let r,s,n,o;i.r(e),i.d(e,{ActiveSelection:()=>n5,BaseBrush:()=>n_,BaseFabricObject:()=>i4,Canvas:()=>no,Canvas2dFilterBackend:()=>n3,CanvasDOMManager:()=>sU,Circle:()=>nS,CircleBrush:()=>nw,ClipPathLayout:()=>n0,Color:()=>eG,Control:()=>ro,Ellipse:()=>nE,FabricImage:()=>ot,FabricObject:()=>rj,FabricText:()=>n$,FitContentLayout:()=>sn,FixedLayout:()=>n1,Gradient:()=>ny,Group:()=>sh,IText:()=>nQ,Image:()=>ot,InteractiveFabricObject:()=>rE,Intersection:()=>i5,LayoutManager:()=>sa,LayoutStrategy:()=>ss,Line:()=>nD,Object:()=>rj,Observable:()=>ts,Path:()=>nx,Pattern:()=>nv,PatternBrush:()=>nO,PencilBrush:()=>nC,Point:()=>tl,Polygon:()=>nF,Polyline:()=>nj,Rect:()=>st,Shadow:()=>ih,SprayBrush:()=>nT,StaticCanvas:()=>ee,StaticCanvasDOMManager:()=>t5,Text:()=>n$,Textbox:()=>nZ,Triangle:()=>nM,WebGLFilterBackend:()=>n4,cache:()=>w,classRegistry:()=>ti,config:()=>d,controlsUtils:()=>s9,createCollectionMixin:()=>tu,filters:()=>oZ,getEnv:()=>x,getFabricDocument:()=>C,getFabricWindow:()=>b,getFilterBackend:()=>n6,iMatrix:()=>E,initFilterBackend:()=>n8,isPutImageFaster:()=>op,isWebGLPipelineState:()=>of,loadSVGFromString:()=>od,loadSVGFromURL:()=>og,parseSVGDocument:()=>ou,runningAnimations:()=>tr,setEnv:()=>_,setFilterBackend:()=>n9,util:()=>sH,version:()=>T});var a=Object.defineProperty,l=(t,e)=>{let i={};for(var r in t)a(i,r,{get:t[r],enumerable:!0});return e||a(i,Symbol.toStringTag,{value:"Module"}),i};function h(t){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function c(t,e,i){var r;return(r=function(t,e){if("object"!=h(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=h(r))return r;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(e,"string"),(e="symbol"==h(r)?r:r+"")in t)?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}var u=class{constructor(){c(this,"browserShadowBlurConstant",1),c(this,"DPI",96),c(this,"devicePixelRatio","u">typeof window?window.devicePixelRatio:1),c(this,"perfLimitSizeTotal",2097152),c(this,"maxCacheSideLimit",4096),c(this,"minCacheSideLimit",256),c(this,"disableStyleCopyPaste",!1),c(this,"enableGLFiltering",!0),c(this,"textureSize",4096),c(this,"forceGLPutImageData",!1),c(this,"cachesBoundsOfCurve",!1),c(this,"fontPaths",{}),c(this,"NUM_FRACTION_DIGITS",4)}};let d=new class extends u{constructor(t){super(),this.configure(t)}configure(t={}){Object.assign(this,t)}addFonts(t={}){this.fontPaths={...this.fontPaths,...t}}removeFonts(t=[]){t.forEach(t=>{delete this.fontPaths[t]})}clearFonts(){this.fontPaths={}}restoreDefaults(t){let e=new u,i=(null==t?void 0:t.reduce((t,i)=>(t[i]=e[i],t),{}))||e;this.configure(i)}},g=(t,...e)=>console[t]("fabric",...e);var f=class extends Error{constructor(t,e){super(`fabric: ${t}`,e)}},p=class extends f{constructor(t){super(`${t} 'options.signal' is in 'aborted' state`)}},m=class{},y=class extends m{testPrecision(t,e){let i=`precision ${e} float; 2void main(){}`,r=t.createShader(t.FRAGMENT_SHADER);return!!r&&(t.shaderSource(r,i),t.compileShader(r),!!t.getShaderParameter(r,t.COMPILE_STATUS))}queryWebGL(t){let e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(t=>this.testPrecision(e,t)),e.getExtension("WEBGL_lose_context").loseContext(),g("log",`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}};let v={},_=t=>{r=t},x=()=>r||(r={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new y,dispose(){}
2,copyPasteData:v}),C=()=>x().document,b=()=>x().window,S=()=>{var t;return Math.max(null==(t=d.devicePixelRatio)?b().devicePixelRatio:t,1)},w=new class{constructor(){c(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache({fontFamily:t,fontStyle:e,fontWeight:i}){t=t.toLowerCase();let r=this.charWidthsCache;r.has(t)||r.set(t,new Map);let s=r.get(t),n=`${e.toLowerCase()}_${(i+"").toLowerCase()}`;return s.has(n)||s.set(n,new Map),s.get(n)}clearFontCache(t){t?this.charWidthsCache.delete((t||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(t){let{perfLimitSizeTotal:e}=d,i=Math.sqrt(e*t);return[Math.floor(i),Math.floor(e/i)]}},T="7.3.1";function O(){}let k=Math.PI/2,D=Math.PI/4,M=2*Math.PI,P=Math.PI/180,E=Object.freeze([1,0,0,1,0,0]),A="center",j="left",F="bottom",L="right",B="none",I=/\r?\n/,R="moving",$="scaling",X="rotating",Y="rotate",W="skewing",V="resizing",G="modifyPoly",z="changed",H="scale",N="scaleX",U="scaleY",q="skewX",K="skewY",J="fill",Q="stroke",Z="modified",tt="normal",te="json",ti=new class{constructor(){this[te]=new Map,this.svg=new Map}has(t){return this[te].has(t)}getClass(t){let e=this[te].get(t);if(!e)throw new f(`No class registered for ${t}`);return e}setClass(t,e){e?this[te].set(e,t):(this[te].set(t.type,t),this[te].set(t.type.toLowerCase(),t))}getSVGClass(t){return this.svg.get(t)}setSVGClass(t,e){this.svg.set(null==e?t.type.toLowerCase():e,t)}},tr=new class extends Array{remove(t){let e=this.indexOf(t);e>-1&&this.splice(e,1)}cancelAll(){let t=this.splice(0);return t.forEach(t=>t.abort()),t}cancelByCanvas(t){if(!t)return[];let e=this.filter(e=>{var i;return e.target===t||"object"==typeof e.target&&(null==(i=e.target)?void 0:i.canvas)===t});return e.forEach(t=>t.abort()),e}cancelByTarget(t){if(!t)return[];let e=this.filter(e=>e.target===t);return e.forEach(t=>t.abort()),e}};var ts=class{constructor(){c(this,"__eventListeners",{})}on(t,e){return(this.__eventListeners||(this.__eventListeners={}),"object"==typeof t)?(Object.entries(t).forEach(([t,e])=>{this.on(t,e)}),()=>this.off(t)):e?(this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e),()=>this.off(t,e)):()=>!1}once(t,e){if("object"==typeof t){let e=[];return Object.entries(t).forEach(([t,i])=>{e.push(this.once(t,i))}),()=>e.forEach(t=>t())}if(e){let i=this.on(t,function(...t){e.call(this,...t),i()});return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){let i=this.__eventListeners[t],r=i.indexOf(e);r>-1&&i.splice(r,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(void 0===t)for(let t in this.__eventListeners)this._removeEventListener(t);else"object"==typeof t?Object.entries(t).forEach(([t,e])=>{this._removeEventListener(t,e)}):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;let r=null==(i=this.__eventListeners[t])?void 0:i.concat();if(r)for(let t=0;t<r.length;t++)r[t].call(this,e||{})}};let tn=(t,e)=>{let i=t.indexOf(e);return -1!==i&&t.splice(i,1),t},to=t=>{if(0===t)return 1;switch(Math.abs(t)/k){case 1:case 3:return 0;case 2:return -1}return Math.cos(t)},ta=t=>{if(0===t)return 0;let e=Math.sign(t);switch(t/k){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)};var tl=class t{constructor(t=0,e=0){"object"==typeof t?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(e){return new t(this.x+e.x,this.y+e.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(e){return new t(this.x+e,this.y+e)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(e){return new t(this.x-e.x,this.y-e.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(e){return new t(this.x-e,this.y-e)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(e){return new t(this.x*e.x,this.y*e.y)}scalarMultiply(e){return new t(this.x*e,this.y*e)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(e){return new t(this.x/e.x,this.y/e.y)}scalarDivide(e){return new t(this.x/e,this.y/e)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(e,i=.5){return i=Math.max(Math.min(1,i),0),new t(this.x+(e.x-this.x)*i,this.y+(e.y-this.y)*i)}distanceFrom(t){let e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(e){return new t(Math.min(this.x,e.x),Math.min(this.y,e.y))}max(e){return new t(Math.max(this.x,e.x),Math.max(this.y,e.y))}toString(){return`${this.x},${this.y}`}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){let e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new t(this.x,this.y)}rotate(e,i=th){let r=ta(e),s=to(e),n=this.subtract(i);return new t(n.x*s-n.y*r,n.x*r+n.y*s).add(i)}transform(e,i=!1){return new t(e[0]*this.x+e[2]*this.y+(i?0:e[4]),e[1]*this.x+e[3]*this.y+(i?0:e[5]))}};
vendor: 5,400 bytes, line 2
2let th=new tl(0,0),tc=t=>!!t&&Array.isArray(t._objects);function tu(t){class e extends t{constructor(...t){super(...t),c(this,"_objects",[])}_onObjectAdded(t){}_onObjectRemoved(t){}_onStackOrderChanged(t){}add(...t){let e=this._objects.push(...t);return t.forEach(t=>this._onObjectAdded(t)),e}insertAt(t,...e){return this._objects.splice(t,0,...e),e.forEach(t=>this._onObjectAdded(t)),this._objects.length}remove(...t){let e=this._objects,i=[];return t.forEach(t=>{let r=e.indexOf(t);-1!==r&&(e.splice(r,1),i.push(t),this._onObjectRemoved(t))}),i}forEachObject(t){this.getObjects().forEach((e,i,r)=>t(e,i,r))}getObjects(...t){return 0===t.length?[...this._objects]:this._objects.filter(e=>e.isType(...t))}item(t){return this._objects[t]}isEmpty(){return 0===this._objects.length}size(){return this._objects.length}contains(t,i){return!!this._objects.includes(t)||!!i&&this._objects.some(i=>i instanceof e&&i.contains(t,!0))}complexity(){return this._objects.reduce((t,e)=>t+=e.complexity?e.complexity():0,0)}sendObjectToBack(t){return!(!t||t===this._objects[0])&&(tn(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),!0)}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1])&&(tn(this._objects,t),this._objects.push(t),this._onStackOrderChanged(t),!0)}sendObjectBackwards(t,e){if(!t)return!1;let i=this._objects.indexOf(t);if(0!==i){let r=this.findNewLowerIndex(t,i,e);return tn(this._objects,t),this._objects.splice(r,0,t),this._onStackOrderChanged(t),!0}return!1}bringObjectForward(t,e){if(!t)return!1;let i=this._objects.indexOf(t);if(i!==this._objects.length-1){let r=this.findNewUpperIndex(t,i,e);return tn(this._objects,t),this._objects.splice(r,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(tn(this._objects,t),this._objects.splice(e,0,t),this._onStackOrderChanged(t),!0)}findNewLowerIndex(t,e,i){let r;if(i){r=e;for(let i=e-1;i>=0;--i)if(t.isOverlapping(this._objects[i])){r=i;break}}else r=e-1;return r}findNewUpperIndex(t,e,i){let r;if(i){r=e;for(let i=e+1;i<this._objects.length;++i)if(t.isOverlapping(this._objects[i])){r=i;break}}else r=e+1;return r}collectObjects({left:t,top:e,width:i,height:r},{includeIntersecting:s=!0}={}){let n=[],o=new tl(t,e),a=o.add(new tl(i,r));for(let t=this._objects.length-1;t>=0;t--){let e=this._objects[t];e.selectable&&e.visible&&(s&&e.intersectsWithRect(o,a)||e.isContainedWithinRect(o,a)||s&&e.containsPoint(o)||s&&e.containsPoint(a))&&n.push(e)}return n}}return e}var td=class extends ts{_setOptions(t={}){for(let e in t)this.set(e,t[e])}_setObject(t){for(let e in t)this._set(e,t[e])}set(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){let e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this}get(t){return this[t]}};function tg(t){return b().requestAnimationFrame(t)}function tf(t){return b().cancelAnimationFrame(t)}let tp=0,tm=()=>tp++,ty=()=>{let t=C().createElement("canvas");if(!t||void 0===t.getContext)throw new f("Failed to create `canvas` element");return t},tv=()=>C().createElement("img"),t_=t=>{var e;let i=tx(t);return null==(e=i.getContext("2d"))||e.drawImage(t,0,0),i},tx=t=>{let e=ty();return e.width=t.width,e.height=t.height,e},tC=(t,e,i)=>t.toDataURL(`image/${e}`,i),tb=(t,e,i)=>new Promise((r,s)=>{t.toBlob(r,`image/${e}`,i)}),tS=t=>t*P,tw=t=>t/P,tT=t=>t.every((t,e)=>t===E[e]),tO=(t,e,i)=>new tl(t).transform(e,i),tk=t=>{let e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0],0,0],{x:r,y:s}=new tl(t[4],t[5]).transform(i,!0);return i[4]=-r,i[5]=-s,i},tD=(t,e,i)=>[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]],tM=(t,e)=>t.reduceRight((t,i)=>i&&t?tD(i,t,e):i||t,void 0)||E.concat(),tP=([t,e])=>Math.atan2(e,t),tE=t=>{let e=tP(t),i=t[0]**2+t[1]**2,r=Math.sqrt(i),s=(t[0]*t[3]-t[2]*t[1])/r,n=Math.atan2(t[0]*t[2]+t[1]*t[3],i);return{angle:tw(e),scaleX:r,scaleY:s,skewX:tw(n),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},tA=(t,e=0)=>[1,0,0,1,t,e];function tj({angle:t=0}={},{x:e=0,y:i=0}={}){let r=tS(t),s=to(r),n=ta(r);return[s,n,-n,s,e?e-(s*e-n*i):0,i?i-(n*e+s*i):0]}let tF=(t,e=t)=>[t,0,0,e,0,0],tL=t=>Math.tan(tS(t)),tB=t=>[1,0,tL(t),1,0,0],tI=t=>[1,tL(t),0,1,0,0],tR=({scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:r=!1,skewX:s=0,skewY:n=0})=>{let o=tF(i?-t:t,r?-e:e);return s&&(o=tD(o,tB(s),!0)),n&&(o=tD(o,tI(n),!0)),o},t$=t=>{let{translateX:e=0,translateY:i=0,angle:r=0}=t,s=tA(e,i);r&&(s=tD(s,tj({angle:r})));let n=tR(t);return tT(n)||(s=tD(s,n)),s},tX=(t,{signal:e,crossOrigin:i=null}={})=>new Promise(function(r,s){if(e&&e.aborted)return s(new p("loadImage"));let n=tv(),o;e&&(o=function(t){n.src="",s(t)},e.addEventListener("abort",o,{once:!0}));let a=function(){n.onload=n.onerror=null,o&&(null==e||e.removeEventListener("abort",o)),r(n)};t?(n.onload=a,n.onerror=function(){o&&(null==e||e.removeEventListener("abort",o)),s(new f(`Error loading ${n.src}`))},i&&(n.crossOrigin=i),n.src=t):a()}),tY=(t,{signal:e,reviver:i=O}={})=>new Promise((r,s)=>{let n=[];e&&e.addEventListener("abort",s,{once:!0}),Promise.allSettled(t.map(t=>ti.getClass(t.type).fromObject(t,{signal:e}))).then(async e=>{for(let[r,s]of e.entries())if("fulfilled"===s.status&&(await i(t[r],s.value),n.push(s.value)),"rejected"===s.status){let e=await i(t[r],void 0,s.reason);e&&n.push(e)}r(n)}).catch(t=>
2{n.forEach(t=>{t.dispose&&t.dispose()}),s(t)}).finally(()=>{e&&e.removeEventListener("abort",s)})}),tW=(t,{signal:e}={})=>new Promise((i,r)=>{let s=[];e&&e.addEventListener("abort",r,{once:!0});let n=Object.values(t).map(t=>t&&t.type&&ti.has(t.type)?tY([t],{signal:e}).then(([t])=>(s.push(t),t)):t),o=Object.keys(t);Promise.all(n).then(t=>t.reduce((t,e,i)=>(t[o[i]]=e,t),{})).then(i).catch(t=>{s.forEach(t=>{t.dispose&&t.dispose()}),r(t)}).finally(()=>{e&&e.removeEventListener("abort",r)})}),tV=(t,e=[])=>e.reduce((e,i)=>(i in t&&(e[i]=t[i]),e),{}),tG=(t,e)=>Object.keys(t).reduce((i,r)=>(e(t[r],r,t)&&(i[r]=t[r]),i),{}),tz=(t,e)=>parseFloat(Number(t).toFixed(e)),tH=t=>"matrix("+t.map(t=>tz(t,d.NUM_FRACTION_DIGITS)).join(" ")+")",tN=t=>!!t&&void 0!==t.toLive,tU=t=>!!t&&"function"==typeof t.toObject,tq=t=>!!t&&void 0!==t.offsetX&&"source"in t,tK=t=>!!t&&"multiSelectionStacking"in t;function tJ(t){let e=t&&tQ(t),i=0,r=0;if(!t||!e)return{left:i,top:r};let s=t,n=e.documentElement,o=e.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&((s=s.parentNode||s.host)===e?(i=o.scrollLeft||n.scrollLeft||0,r=o.scrollTop||n.scrollTop||0):(i+=s.scrollLeft||0,r+=s.scrollTop||0),1!==s.nodeType||"fixed"!==s.style.position););return{left:i,top:r}}let tQ=t=>t.ownerDocument||null,tZ=t=>{var e;return(null==(e=t.ownerDocument)?void 0:e.defaultView)||null},t0=(t,e,{width:i,height:r},s=1)=>{t.width=i,t.height=r,s>1&&(t.setAttribute("width",(i*s).toString()),t.setAttribute("height",(r*s).toString()),e.scale(s,s))},t1=(t,{width:e,height:i})=>{e&&(t.style.width="number"==typeof e?`${e}px`:e),i&&(t.style.height="number"==typeof i?`${i}px`:i)};function t2(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=B,t}var t5=class{constructor(t){c(this,"_originalCanvasStyle",void 0),c(this,"lower",void 0);let e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){let e=t&&void 0!==t.getContext?t:t&&C().getElementById(t)||ty();if(e.hasAttribute("data-fabric"))throw new f("Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?");return this._originalCanvasStyle=e.style.cssText,e.setAttribute("data-fabric","main"),e.classList.add("lower-canvas"),e}cleanupDOM({width:t,height:e}){let{el:i}=this.lower;i.classList.remove("lower-canvas"),i.removeAttribute("data-fabric"),i.setAttribute("width",`${t}`),i.setAttribute("height",`${e}`),i.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){let{el:i,ctx:r}=this.lower;t0(i,r,t,e)}setCSSDimensions(t){t1(this.lower.el,t)}calcOffset(){return function(t){var e;let i=t&&tQ(t),r={left:0,top:0};if(!i)return r;let s=(null==(e=tZ(t))?void 0:e.getComputedStyle(t,null))||{};r.left+=parseInt(s.borderLeftWidth,10)||0,r.top+=parseInt(s.borderTopWidth,10)||0,r.left+=parseInt(s.paddingLeft,10)||0,r.top+=parseInt(s.paddingTop,10)||0;let n={left:0,top:0},o=i.documentElement;void 0!==t.getBoundingClientRect&&(n=t.getBoundingClientRect());let a=tJ(t);return{left:n.left+a.left-(o.clientLeft||0)+r.left,top:n.top+a.top-(o.clientTop||0)+r.top}}(this.lower.el)}dispose(){x().dispose(this.lower.el),delete this.lower}};let t3={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 t4=l({capitalize:()=>t8,escapeXml:()=>t6,graphemeSplit:()=>t9});let t8=(t,e=!1)=>`${t.charAt(0).toUpperCase()}${e?t.slice(1):t.slice(1).toLowerCase()}`,t6=t=>t.toString().replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),t9=t=>(s||s||(s="Intl"in b()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),s)?Array.from(s.segment(t)).map(({segment:t})=>t):t7(t),t7=t=>{let e=[];for(let i,r=0;r<t.length;r++)!1!==(i=et(t,r))&&e.push(i);return e},et=(t,e)=>{let i=t.charCodeAt(e);if(isNaN(i))return"";if(i<55296||i>57343)return t.charAt(e);if(55296<=i&&i<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";let i=t.charCodeAt(e+1);if(56320>i||i>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";let r=t.charCodeAt(e-1);if(55296>r||r>56319)throw"Low surrogate without preceding high surrogate";return!1};var ee=class t extends tu(td){get lowerCanvasEl(){var t;return null==(t=this.elements.lower)?void 0:t.el}get contextContainer(){var t;return null==(t=this.elements.lower)?void 0:t.ctx}static getDefaults(){return t.ownDefaults}constructor(t,e={}){super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}
vendor: 13,007 bytes, lines 2-21
2),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new t5(t)}add(...t){let e=super.add(...t);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),e}insertAt(t,...e){let i=super.insertAt(t,...e);return e.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),i}remove(...t){let e=super.remove(...t);return e.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),e}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(g("warn",`Canvas is trying to add an object that belongs to a different canvas. 3Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?S():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}_setDimensionsImpl(t,{cssOnly:e=!1,backstoreOnly:i=!1}={}){if(!e){let e={width:this.width,height:this.height,...t};this.elements.setDimensions(e,this.getRetinaScaling()),this.hasLostContext=!0,this.width=e.width,this.height=e.height}i||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){let i=[...this.viewportTransform],r=tO(t,tk(i));i[0]=e,i[3]=e;let s=tO(r,i);i[4]+=t.x-s.x,i[5]+=t.y-s.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new tl(0,0),t)}absolutePan(t){let e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new tl(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.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=tg(()=>this.renderAndReset()))}calcViewportBoundaries(){let t=this.width,e=this.height,i=tk(this.viewportTransform),r=tO({x:0,y:0},i),s=tO({x:t,y:e},i),n=r.min(s),o=r.max(s);return this.vptCoords={tl:n,tr:new tl(o.x,n.y),bl:new tl(n.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(tf(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;let i=this.viewportTransform,r=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality=this.patternQuality,this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),r&&(r._set("canvas",this),r.shouldCache(),r._transformDone=!0,r.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,r)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){let i=this.viewportTransform;t.save(),t.transform(...i),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let i=0,r=e.length;i<r;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){let i=this[`${e}Color`],r=this[`${e}Image`],s=this.viewportTransform,n=this[`${e}Vpt`];if(!i&&!r)return;let o=tN(i);if(i){if(t.save(),t.beginPath(),t.moveTo(0,0),t.lineTo(this.width,0),t.lineTo(this.width,this.height),t.lineTo(0,this.height),t.closePath(),t.fillStyle=o?i.toLive(t):i,n&&t.transform(...s),o){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);let e=i.gradientTransform||i.patternTransform;e&&t.transform(...e)}t.fill(),t.restore()}if(r){t.save();let{skipOffscreen:e}=this;this.skipOffscreen=n,n&&t.transform(...s),r.render(t),this.skipOffscreen=e,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenterPoint(){return new tl(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new tl(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new tl(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new tl(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new tl(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return tO(this.getCenterPoint(),tk(this.viewportTransform))}_centerObject(t,e){t.setXY(e,A,A),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){let i=this.clipPath,r=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return{version:T,...tV(this,e),objects:this._objects.filter(t=>!t.excludeFromExport).map(i=>this._toObject(i,t,e)),...this.__serializeBgOverlay(t,e),...r?{clipPath:r}:null}}_toObject(t,e,i){let r;this.includeDefaultValues||(r=t.includeDefaultValues,t.includeDefaultValues=!1);let s=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!r),s}__serializeBgOverlay(t,e){let i={},r=this.backgroundImage,s=this.overlayImage,n=this.backgroundColor,o=this.overlayColor;return tN(n)?n.excludeFromExport||(i.background=n.toObject(e)):n&&(i.background=n),tN(o)?o.excludeFromExport||(i.overlay=o.toObject(e)):o&&(i.overlay=o),r&&!r.excludeFromExport&&(i.backgroundImage=this._toObject(r,t,e)),s&&!s.excludeFromExport&&(i.overlayImage=this._toObject(s,t,e)),i}toSVG(t={},e){var i;t.reviver=e;let r=[];return this._setSVGPreamble(r,t),this._setSVGHeader(r,t),this.clipPath&&r.push(`<g clip-path="url(#${t6(null==(i=this.clipPath.clipPathId)?"":i)})" > 4`),this._setSVGBgOverlayColor(r,"background"),this._setSVGBgOverlayImage(r,"backgroundImage",e),this._setSVGObjects(r,e),this.clipPath&&r.push(`</g> 5`),this._setSVGBgOverlayColor(r,"overlay"),this._setSVGBgOverlayImage(r,"overlayImage",e),r.push("</svg>"),r.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",`" standalone="no" ?> 6`,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> 7`)}_setSVGHeader(t,e){let i=e.width||`${this.width}`,r=e.height||`${this.height}`,s=d.NUM_FRACTION_DIGITS,n=e.viewBox,o;if(n)o=`viewBox="${n.x} ${n.y} ${n.width} ${n.height}" `;else if(this.svgViewportTransformation){let t=this.viewportTransform;o=`viewBox="${tz(-t[4]/t[0],s)} ${tz(-t[5]/t[3],s)} ${tz(this.width/t[0],s)} ${tz(this.height/t[3],s)}" `}else o=`viewBox="0 0 ${this.width} ${this.height}" `;t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',r,'" ',o,`xml:space="preserve"> 8`,"<desc>Created with Fabric.js ",T,`</desc> 9`,`<defs> 10`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs> 11`)}createSVGClipPathMarkup(t){let e=this.clipPath;return e?(e.clipPathId=`CLIPPATH_${tm()}`,`<clipPath id="${e.clipPathId}" > 12${e.toClipPathSVG(t.reviver)}</clipPath> 13`):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{let e=this[`${t}Color`];if(tN(e)){let i=this[`${t}Vpt`],r=this.viewportTransform,s={isType:()=>!1,width:this.width/(i?r[0]:1),height:this.height/(i?r[3]:1)};return e.toSVG(s,{additionalTransform:i?tH(r):""})}}).join("")}createSVGFontFacesMarkup(){let t=[],e={},i=d.fontPaths;this._objects.forEach(function e(i){t.push(i),tc(i)&&i._objects.forEach(e)}),t.forEach(t=>{if(!t||"function"!=typeof t._renderText)return;let{styles:r,fontFamily:s}=t;!e[s]&&i[s]&&(e[s]=!0,r&&Object.values(r).forEach(t=>{Object.values(t).forEach(({fontFamily:t=""})=>{!e[t]&&i[t]&&(e[t]=!0)})}))});let r=Object.keys(e).map(t=>` @font-face { 14 font-family: '${t}'; 15 src: url('${i[t]}'); 16 } 17`).join("");return r?` <style type="text/css"><![CDATA[ 18${r}]]></style> 19`:""}_setSVGObjects(t,e){this.forEachObject(i=>{i.excludeFromExport||this._setSVGObject(t,i,e)})}_setSVGObject(t,e,i){t.push(e.toSVG(i))}_setSVGBgOverlayImage(t,e,i){let r=this[e];r&&!r.excludeFromExport&&r.toSVG&&t.push(r.toSVG(i))}_setSVGBgOverlayColor(t,e){let i=this[`${e}Color`];if(i)if(tN(i)){let r=i.repeat||"",s=this.width,n=this.height,o=this[`${e}Vpt`]?tH(tk(this.viewportTransform)):"";t.push(`<rect transform="${o} translate(${s/2},${n/2})" x="${i.offsetX-s/2}" y="${i.offsetY-n/2}" width="${("repeat-y"===r||"no-repeat"===r)&&tq(i)?i.source.width:s}" height="${("repeat-x"===r||"no-repeat"===r)&&tq(i)?i.source.height:n}" fill="url(#SVGID_${i.id})"></rect> 20`)}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect> 21`)}loadFromJSON(t,e,{signal:i}={}){if(!t)return Promise.reject(new f("`json` is undefined"));let{objects:r=[],...s}="string"==typeof t?JSON.parse(t):t,{backgroundImage:n,background:o,overlayImage:a,overlay:l,clipPath:h}=s,c=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([tY(r,{reviver:e,signal:i}),tW({backgroundImage:n,backgroundColor:o,overlayImage:a,overlayColor:l,clipPath:h},{signal:i})]).then(([t,e])=>(this.clear(),this.add(...t),this.set(s),this.set(e),this.renderOnAddRemove=c,this))}clone(t){let e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){let t=tx(this);return new this.constructor(t)}toDataURL(t={}){let{format:e="png",quality:i=1,multiplier:r=1,enableRetinaScaling:s=!1}=t,n=r*(s?this.getRetinaScaling():1);return tC(this.toCanvasElement(n,t),e,i)}toBlob(t={}){let{format:e="png",quality:i=1,multiplier:r=1,enableRetinaScaling:s=!1}=t,n=r*(s?this.getRetinaScaling():1);return tb(this.toCanvasElement(n,t),e,i)}toCanvasElement(t=1,{width:e,height:i,left:r,top:s,filter:n}={}){let o=(e||this.width)*t,a=(i||this.height)*t,l=this.getZoom(),h=this.width,c=this.height,u=this.skipControlsDrawing,d=l*t,g=this.viewportTransform,f=[d,0,0,d,(g[4]-(r||0))*t,(g[5]-(s||0))*t],p=this.enableRetinaScaling,m=tx({width:o,height:a}),y=n?this._objects.filter(t=>n(t)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=o,this.height=a,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),y),this.viewportTransform=g,this.width=h,this.height=c,this.calcViewportBoundaries(),this.enableRetinaScaling=p,this.skipControlsDrawing=u,m}dispose(){return this.disposed||this.elements.cleanupDOM({width:this.width,height:this.height}),tr.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{let i=()=>{this.destroy(),t(!0)};i.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=i:i()})}destroy(){this.destroyed=!0,this.cancelRequestedRender(),this.forEachObject(t=>t.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} }>`}};c(ee,"ownDefaults",t3);let ei=["touchstart","touchmove","touchend"],er=t=>{let e=tJ(t.target),i=function(t){let e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new tl(i.clientX+e.left,i.clientY+e.top)},es=t=>ei.includes(t.type)||"touch"===t.pointerType,en=t=>{t.preventDefault(),t.stopPropagation()},eo=t=>{let e=0,i=0,r=0,s=0;for(let n=0,o=t.length;n<o;n++){let{x:o,y:a}=t[n];(o>r||!n)&&(r=o),(o<e||!n)&&(e=o),(a>s||!n)&&(s=a),(a<i||!n)&&(i=a)}return{left:e,top:i,width:r-e,height:s-i}},ea=(t,e)=>{eh(t,tD(tk(e),t.calcOwnMatrix()))},el=(t,e)=>eh(t,tD(e,t.calcOwnMatrix())),eh=(t,e)=>{let{translateX:i,translateY:r,scaleX:s,scaleY:n,...o}
21=tE(e),a=new tl(i,r);t.flipX=!1,t.flipY=!1,Object.assign(t,o),t.set({scaleX:s,scaleY:n}),t.setPositionByOrigin(a,A,A)},ec=t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},eu=t=>({scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}),ed=(t,e,i)=>{let r=t/2,s=e/2,n=eo([new tl(-r,-s),new tl(r,-s),new tl(-r,s),new tl(r,s)].map(t=>t.transform(i)));return new tl(n.width,n.height)},eg=(t=E,e=E)=>tD(tk(e),t),ef=(t,e=E,i=E)=>t.transform(eg(e,i)),ep=(t,e=E,i=E)=>t.transform(eg(e,i),!0),em=(t,e,i)=>{let r=eg(e,i);return eh(t,tD(r,t.calcOwnMatrix())),r},ey={left:-.5,top:-.5,center:0,bottom:.5,right:.5},ev=t=>"string"==typeof t?ey[t]:t-.5,e_=new tl(1,0),ex=new tl,eC=(t,e)=>t.rotate(e),eb=(t,e)=>new tl(e).subtract(t),eS=t=>t.distanceFrom(ex),ew=(t,e)=>Math.atan2(eD(t,e),eM(t,e)),eT=t=>ew(e_,t),eO=t=>t.eq(ex)?t:t.scalarDivide(eS(t)),ek=(t,e=!0)=>eO(new tl(-t.y,t.x).scalarMultiply(e?1:-1)),eD=(t,e)=>t.x*e.y-t.y*e.x,eM=(t,e)=>t.x*e.x+t.y*e.y,eP=(t,e,i)=>{if(t.eq(e)||t.eq(i))return!0;let r=eD(e,i),s=eD(e,t),n=eD(i,t);return r>=0?s>=0&&n<=0:!(s<=0&&n>=0)},eE="not-allowed";function eA(t){return ev(t.originX)===ev("center")&&ev(t.originY)===ev("center")}let ej=(t,e)=>t[e],eF=(t,e,i,r)=>({e:t,transform:e,pointer:new tl(i,r)});function eL(t,e,i){return Math.round((eT(eb(ef(t.getCenterPoint(),t.canvas.viewportTransform,void 0),i))+M)%M/D)}function eB({target:t,corner:e},i,r,s,n){var o,a;let l,h,c=t.controls[e],u=(null==(o=t.canvas)?void 0:o.getZoom())||1,d=t.padding/u,g=(a=new tl(s,n),l=t.getRelativeCenterPoint(),h=void 0!==i&&void 0!==r?t.translateToGivenOrigin(l,A,A,i,r):new tl(t.left,t.top),(t.angle?a.rotate(-tS(t.angle),l):a).subtract(h));return g.x>=d&&(g.x-=d),g.x<=-d&&(g.x+=d),g.y>=d&&(g.y-=d),g.y<=d&&(g.y+=d),g.x-=c.offsetX,g.y-=c.offsetY,g}let eI=t=>t.replace(/\s+/g," "),eR={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"},e$=(t,e,i)=>(i<0&&(i+=1),i>1&&--i,i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t),eX=(t,e,
21i,r)=>{t/=255;let s=Math.max(t,e/=255,i/=255),n=Math.min(t,e,i),o,a,l=(s+n)/2;if(s===n)o=a=0;else{let r=s-n;switch(a=l>.5?r/(2-s-n):r/(s+n),s){case t:o=(e-i)/r+6*(e<i);break;case e:o=(i-t)/r+2;break;case i:o=(t-e)/r+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),r]},eY=(t="1")=>parseFloat(t)/(t.endsWith("%")?100:1),eW=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),eV=([t,e,i,r=1])=>{let s=Math.round(.3*t+.59*e+.11*i);return[s,s,s,r]};var eG=class t{constructor(e){if(c(this,"isUnrecognised",!1),e)if(e instanceof t)this.setSource([...e._source]);else if(Array.isArray(e)){let[t,i,r,s=1]=e;this.setSource([t,i,r,s])}else this.setSource(this._tryParsingColor(e));else this.setSource([0,0,0,1])}_tryParsingColor(e){return(e=e.toLowerCase())in eR&&(e=eR[e]),"transparent"===e?[255,255,255,0]:t.sourceFromHex(e)||t.sourceFromRgb(e)||t.sourceFromHsl(e)||(this.isUnrecognised=!0,[0,0,0,1])}getSource(){return this._source}setSource(t){this._source=t}toRgb(){let[t,e,i]=this.getSource();return`rgb(${t},${e},${i})`}toRgba(){return`rgba(${this.getSource().join(",")})`}toHsl(){let[t,e,i]=eX(...this.getSource());return`hsl(${t},${e}%,${i}%)`}toHsla(){let[t,e,i,r]=eX(...this.getSource());return`hsla(${t},${e}%,${i}%,${r})`}toHex(){return this.toHexa().slice(0,6)}toHexa(){let[t,e,i,r]=this.getSource();return`${eW(t)}${eW(e)}${eW(i)}${eW(Math.round(255*r))}`}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(eV(this.getSource())),this}toBlackWhite(t){let[e,,,i]=eV(this.getSource()),r=e<(t||127)?0:255;return this.setSource([r,r,r,i]),this}overlayWith(e){e instanceof t||(e=new t(e));let i=this.getSource(),r=e.getSource(),[s,n,o]=i.map((t,e)=>Math.round(.5*t+.5*r[e]));return this.setSource([s,n,o,i[3]]),this}static fromRgb(e){return t.fromRgba(e)}static fromRgba(e){return new t(t.sourceFromRgb(e))}static sourceFromRgb(t){let e=eI(t).match(/^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);if(e){let[t,i,r]=e.slice(1,4).map(t=>{let e=parseFloat(t);return t.endsWith("%")?Math.round(2.55*e):e});return[t,i,r,eY(e[4])]}}static fromHsl(e){return t.fromHsla(e)}static fromHsla(e){return new t(t.sourceFromHsl(e))}static sourceFromHsl(e){let i=eI(e).match(/^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);if(!i)return;let r=(t.parseAngletoDegrees(i[1])%360+360)%360/360,s=parseFloat(i[2])/100,n=parseFloat(i[3])/100,o,a,l;if(0===s)o=a=l=n;else{let t=n<=.5?n*(s+1):n+s-n*s,e=2*n-t;o=e$(e,t,r+1/3),a=e$(e,t,r),l=e$(e,t,r-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),eY(i[4])]}static fromHex(e){return new t(t.sourceFromHex(e))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){let e=t.slice(t.indexOf("#")+1),[i,r,s,n=255]=(e.length<=4?e.split("").map(t=>t+t):e.match(/.{2}/g)).map(t=>parseInt(t,16));return[i,r,s,n/255]}}static parseAngletoDegrees(t){let e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?tw(i):e.includes("turn")?360*i:i}};let ez=t=>{let e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":return e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);case"radialGradient":return e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);case"stop":return e.concat(["offset","stop-color","stop-opacity"])}return e},eH=(t,e=16)=>{let i=/\D{0,2}$/.exec(t),r=parseFloat(t),s=d.DPI;switch(null==i?void 0:i[0]){case"mm":return r*s/25.4;case"cm":return r*s/2.54;case"in":return r*s;case"pt":return r*s/72;case"pc":return r*s/72*12;case"em":return r*e;default:return r}},eN=t=>{let[e,i]=t.trim().split(" "),[r,s]=e&&"none"!==e?[e.slice(1,4),e.slice(5,8)]:"none"===e?[e,e]:["Mid","Mid"];return{meetOrSlice:i||"meet",alignX:r,alignY:s}},eU=(t,e,i=!0)=>{let r,s;if(e)if(e.toLive)r=`url(#SVGID_${t6(e.id)})`;else{let t=new eG(e),i=t.getAlpha();r=t.toRgb(),1!==i&&(s=i.toString())}else r="none";return i?`${t}: ${r}; ${s?`${t}-opacity: ${s}; `:""}`:`${t}="${r}" ${s?`${t}-opacity="${s}" `:""}`};var eq=class{getSvgStyles(t){let e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",r=this.strokeDashArray?this.strokeDashArray.join(" "):B,s=this.strokeDashOffset?this.strokeDashOffset:"0",n=this.strokeLineCap?this.strokeLineCap:"butt",o=this.strokeLineJoin?this.strokeLineJoin:"miter",a=this.strokeMiterLimit?this.strokeMiterLimit:"4",l=void 0===this.opacity?"1":this.opacity,h=this.visible?"":" visibility: hidden;",c=t?"":this.getSvgFilter(),u=eU(J,this.fill);return[eU(Q,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",r,"; ","stroke-linecap: ",n,"; ","stroke-dashoffset: ",s,"; ","stroke-linejoin: ",o,"; ","stroke-miterlimit: ",a,"; ",u,"fill-rule: ",e,"; ","opacity: ",l,";",c,h].map(t=>t6(t)).join("")}getSvgFilter(){return this.shadow?`filter: url(#SVGID_${t6(this.shadow.id)});`:""}
vendor: 6,217 bytes, lines 21-37
21getSvgCommons(){return[this.id?`id="${t6(String(this.id))}" `:"",this.clipPath?`clip-path="url(#${this.clipPath.clipPathId})" `:""].join("")}getSvgTransform(t,e=""){return`transform="${tH(t?this.calcTransformMatrix():this.calcOwnMatrix())}${e}" `}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return` `+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t,{reviver:e,additionalTransform:i=""}={}){let r=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=r,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t,{noStyle:e,reviver:i,withShadow:r,additionalTransform:s}={}){let n=e?"":`style="${this.getSvgStyles()}" `,o=r?`style="${this.getSvgFilter()}" `:"",a=this.clipPath,l=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=a&&a.absolutePositioned,c=this.stroke,u=this.fill,d=this.shadow,g=[],f=t.indexOf("COMMON_PARTS"),p;return a&&(a.clipPathId=`CLIPPATH_${tm()}`,p=`<clipPath id="${a.clipPathId}" > 22${a.toClipPathSVG(i)}</clipPath> 23`),h&&g.push("<g ",o,this.getSvgCommons(),` > 24`),g.push("<g ",this.getSvgTransform(!1),h?"":o+this.getSvgCommons(),` > 25`),t[f]=[n,l,e?"":this.addPaintOrder()," ",s?`transform="${s}" `:""].join(""),tN(u)&&g.push(u.toSVG(this)),tN(c)&&g.push(c.toSVG(this)),d&&g.push(d.toSVG(this)),a&&g.push(p),g.push(t.join("")),g.push(`</g> 26`),h&&g.push(`</g> 27`),i?i(g.join("")):g.join("")}addPaintOrder(){return"fill"===this.paintFirst?"":` paint-order="${t6(this.paintFirst)}" `}};function eK(t){return RegExp("^("+t.join("|")+")\\b","i")}let eJ="textDecorationThickness",eQ="textDecorationColor",eZ=["fontSize","fontWeight","fontFamily","fontStyle"],e0=["underline","overline","linethrough"],e1=[...eZ,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],e2=[...e1,...e0,"textBackgroundColor","direction",eJ,eQ],e5=[...eZ,...e0,Q,"strokeWidth",J,"deltaY","textBackgroundColor",eJ,eQ],e3="justify",e4=String.raw`[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?`,e8=String.raw`(?:\s*,?\s+|\s*,\s*)`,e6="http://www.w3.org/2000/svg",e9=RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+e4+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+e4+"))?\\s+(.*)"),e7={cx:j,x:j,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":eJ,"text-decoration-color":eQ},it="font-size",ie="clip-path",ii=eK(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),ir=eK(["symbol","image","marker","pattern","view","svg"]),is=eK(["symbol","g","a","svg","clipPath","defs"]),io=new RegExp(String.raw`^\s*(${e4})${e8}(${e4})${e8}(${e4})${e8}(${e4})\s*$`),ia="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",il=RegExp("(?:\\s|^)"+ia+ia+"("+e4+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");var ih=class t{constructor(e={}){let i="string"==typeof e?t.parseShadow(e):e;Object.assign(this,t.ownDefaults,i),this.id=tm()}static parseShadow(t){let e=t.trim(),[,i=0,r=0,s=0]=(il.exec(e)||[]).map(t=>parseFloat(t)||0);return{color:(e.replace(il,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:r,blur:s}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){let e=eC(new tl(this.offsetX,this.offsetY),tS(-t.angle)),i=d.NUM_FRACTION_DIGITS,r=new eG(this.color),s=40,n=40;return t.width&&t.height&&(s=100*tz((Math.abs(e.x)+this.blur)/t.width,i)+20,n=100*tz((Math.abs(e.y)+this.blur)/t.height,i)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),`<filter id="SVGID_${t6(this.id)}" y="-${n}%" height="${100+2*n}%" x="-${s}%" width="${100+2*s}%" > 28 <feGaussianBlur in="SourceAlpha" stdDeviation="${tz(this.blur?this.blur/2:0,i)}"></feGaussianBlur> 29 <feOffset dx="${tz(e.x,i)}" dy="${tz(e.y,i)}" result="oBlur" ></feOffset> 30 <feFlood flood-color="${r.toRgb()}" flood-opacity="${r.getAlpha()}"/> 31 <feComposite in2="oBlur" operator="in" /> 32 <feMerge> 33 <feMergeNode></feMergeNode> 34 <feMergeNode in="SourceGraphic"></feMergeNode> 35 </feMerge> 36</filter> 37`}toObject(){let e={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},i=t.ownDefaults;return this.includeDefaultValues?e:tG(e,(t,e)=>t!==i[e])}static async fromObject(t){return new this(t)}};c(ih,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),c(ih,"type","shadow"),ti.setClass(ih,"shadow");let ic=(t,e,i)=>Math.max(t,Math.min(e,i)),iu=["top",j,N,U,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",q,K],id=[J,Q,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"];var ig=l({defaultEasing:()=>iy,easeInBack:()=>i$,easeInBounce:()=>iV,easeInCirc:()=>ij,easeInCubic:()=>iv,easeInElastic:()=>iB,easeInExpo:()=>iP,easeInOutBack:()=>iY,easeInOutBounce:()=>iG,easeInOutCirc:()=>iL,easeInOutCubic:()=>ix,easeInOutElastic:()=>iR,easeInOutExpo:()=>iA,easeInOutQuad:()=>iN,easeInOutQuart:()=>iS,easeInOutQuint:()=>iO,easeInOutSine:()=>iM,easeInQuad:()=>iz,easeInQuart:()=>iC,easeInQuint:()=>iw,easeInSine:()=>ik,easeOutBack:()=>iX,easeOutBounce:()=>iW,easeOutCirc:()=>iF,easeOutCubic:()=>i_,easeOutElastic:()=>iI,easeOutExpo:()=>iE,easeOutQuad:()=>iH,easeOutQuart:()=>ib,easeOutQuint:()=>iT,easeOutSine:()=>iD});let ip=(t,e,i,r)=>
37(t<Math.abs(e)?(t=e,r=i/4):r=0===e&&0===t?i/M*Math.asin(1):i/M*Math.asin(e/t),{a:t,c:e,p:i,s:r}),im=(t,e,i,r,s)=>t*2**(10*--r)*Math.sin((r*s-e)*M/i),iy=(t,e,i,r)=>-i*Math.cos(t/r*k)+i+e,iv=(t,e,i,r)=>i*(t/r)**3+e,i_=(t,e,i,r)=>i*((t/r-1)**3+1)+e,ix=(t,e,i,r)=>(t/=r/2)<1?i/2*t**3+e:i/2*((t-2)**3+2)+e,iC=(t,e,i,r)=>i*(t/=r)*t**3+e,ib=(t,e,i,r)=>-i*((t=t/r-1)*t**3-1)+e,iS=(t,e,i,r)=>(t/=r/2)<1?i/2*t**4+e:-i/2*((t-=2)*t**3-2)+e,iw=(t,e,i,r)=>i*(t/r)**5+e,iT=(t,e,i,r)=>i*((t/r-1)**5+1)+e,iO=(t,e,i,r)=>(t/=r/2)<1?i/2*t**5+e:i/2*((t-2)**5+2)+e,ik=(t,e,i,r)=>-i*Math.cos(t/r*k)+i+e,iD=(t,e,i,r)=>i*Math.sin(t/r*k)+e,iM=(t,e,i,r)=>-i/2*(Math.cos(Math.PI*t/r)-1)+e,iP=(t,e,i,r)=>0===t?e:i*2**(10*(t/r-1))+e,iE=(t,e,i,r)=>t===r?e+i:-(i*(2**(-10*t/r)+1))+e,iA=(t,e,i,r)=>0===t?e:t===r?e+i:(t/=r/2)<1?i/2*2**(10*(t-1))+e:-(i/2*(2**(-10*--t)+2))+e,ij=(t,e,i,r)=>-i*(Math.sqrt(1-(t/=r)*t)-1)+e,iF=(t,e,i,r)=>i*Math.sqrt(1-(t=t/r-1)*t)+e,iL=(t,e,i,r)=>(t/=r/2)<1?-i/2*(Math.sqrt(1-t**2)-1)+e:i/2*(Math.sqrt(1-(t-=2)*t)+1)+e,iB=(t,e,i,r)=>{let s=0;if(0===t)return e;if(1==(t/=r))return e+i;s||(s=.3*r);let{a:n,s:o,p:a}=ip(i,i,s,1.70158);return-im(n,o,a,t,r)+e},iI=(t,e,i,r)=>{let s=0;if(0===t)return e;if(1==(t/=r))return e+i;s||(s=.3*r);let{a:n,s:o,p:a,c:l}=ip(i,i,s,1.70158);return n*2**(-10*t)*Math.sin((t*r-o)*M/a)+l+e},iR=(t,e,i,r)=>{let s=0;if(0===t)return e;if(2==(t/=r/2))return e+i;s||(s=.3*1.5*r);let{a:n,s:o,p:a,c:l}=ip(i,i,s,1.70158);return t<1?-.5*im(n,o,a,t,r)+e:n*2**(-10*--t)*Math.sin((t*r-o)*M/a)*.5+l+e},i$=(t,e,i,r,s=1.70158)=>i*(t/=r)*t*((s+1)*t-s)+e,iX=(t,e,i,r,s=1.70158)=>i*((t=t/r-1)*t*((s+1)*t+s)+1)+e,iY=(t,e,i,r,s=1.70158)=>(t/=r/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e,iW=(t,e,i,r)=>(t/=r)<1/2.75?7.5625*t*t*i+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,iV=(t,e,i,r)=>i-iW(r-t,0,i,r)+e,iG=(t,e,i,r)=>t<r/2?.5*iV(2*t,0,i,r)+e:.5*iW(2*t-r,0,i,r)+.5*i+e,iz=(t,e,i,r)=>i*(t/=r)*t+e,iH=(t,e,i,r)=>-i*(t/=r)*(t-2)+e,iN=(t,e,i,r)=>(t/=r/2)<1?i/2*t**2+e:-i/2*(--t*(t-2)-1)+e,iU=()=>!1;var iq=class{constructor({startValue:t,byValue:e,duration:i=500,delay:r=0,easing:s=iy,onStart:n=O,onChange:o=O,onComplete:a=O,abort:l=iU,target:h}){c(this,"_state","pending"),c(this,"durationProgress",0),c(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=i,this.delay=r,this.easing=s,this._onStart=n,this._onChange=o,this._onComplete=a,this._abort=l,this.target=h,this.startValue=t,this.byValue=e,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return"aborted"===this._state||"completed"===this._state}start(){let t=t=>{"pending"===this._state&&(this.startTime=t||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?this.timeout=b().setTimeout(()=>tg(t),this.delay):tg(t)}tick(t){let e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;let{value:r,valueProgress:s}=this.calculate(i);this.value=Object.freeze(r),this.valueProgress=s,"aborted"!==this._state&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=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),tg(this.tick)))}register(){tr.push(this)}unregister(){tr.remove(this)}abort(){this._state="aborted",this.unregister(),this.timeout&&b().clearTimeout(this.timeout)}},iK=class extends iq{constructor({startValue:t=0,endValue:e=100,...i}){super({...i,startValue:t,byValue:e-t})}calculate(t){let e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}},iJ=class extends iq{constructor({startValue:t=[0],endValue:e=[100],...i}){super({...i,startValue:t,byValue:e.map((e,i)=>e-t[i])})}calculate(t){let e=this.startValue.map((e,i)=>this.easing(t,e,this.byValue[i],this.duration,i));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}};let iQ=(t,e,i,r)=>e+i*(1-Math.cos(t/r*k)),iZ=t=>t&&((e,i,r)=>t(new eG(e).toRgba(),i,r));var i0=class extends iq{constructor({startValue:t,endValue:e,easing:i=iQ,onChange:r,onComplete:s,abort:n,...o}){let a=new eG(t).getSource();super({...o,startValue:a,byValue:new eG(e).getSource().map((t,e)=>t-a[e]),easing:i,onChange:iZ(r),onComplete:iZ(s),abort:iZ(n)})}calculate(t){let[e,i,r,s]=this.startValue.map((e,i)=>this.easing(t,e,this.byValue[i],this.duration,i)),n=[...[e,i,r].map(Math.round),ic(0,s,1)];return{value:n,valueProgress:n.map((t,e)=>0===this.byValue[e]?0:Math.abs((t-this.startValue[e])/this.byValue[e])).find(t=>0!==t)||0}}};function i1(t){let e=Array.isArray(t.startValue)||Array.isArray(t.endValue)?new iJ(t):new iK(t);return e.start(),e}function i2(t){let e=new i0(t);return e.start(),e}var i5=class t{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some(e=>e.eq(t))}append(...t){return this.points=this.points.concat(t.filter(t=>!this.includes(t))),this}static isPointContained(t,e,i,r=!1){if(e.eq(i))return t.eq(e);
37if(e.x===i.x)return t.x===e.x&&(r||t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y));if(e.y===i.y)return t.y===e.y&&(r||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{let s=eb(e,i),n=eb(e,t).divide(s);return r?Math.abs(n.x)===Math.abs(n.y):n.x===n.y&&n.x>=0&&n.x<=1}}static isPointInPolygon(t,e){let i=new tl(t).setX(Math.min(t.x-1,...e.map(t=>t.x))),r=0;for(let s=0;s<e.length;s++){let n=this.intersectSegmentSegment(e[s],e[(s+1)%e.length],t,i);if(n.includes(t))return!0;r+=Number("Intersection"===n.status)}return r%2==1}static intersectLineLine(e,i,r,s,n=!0,o=!0){let a=i.x-e.x,l=i.y-e.y,h=s.x-r.x,c=s.y-r.y,u=e.x-r.x,d=e.y-r.y,g=h*d-c*u,f=a*d-l*u,p=c*a-h*l;if(0!==p){let i=g/p,r=f/p;return(n||0<=i&&i<=1)&&(o||0<=r&&r<=1)?new t("Intersection").append(new tl(e.x+i*a,e.y+i*l)):new t}return new t(0===g||0===f?n||o||t.isPointContained(e,r,s)||t.isPointContained(i,r,s)||t.isPointContained(r,e,i)||t.isPointContained(s,e,i)?"Coincident":void 0:"Parallel")}static intersectSegmentLine(e,i,r,s){return t.intersectLineLine(e,i,r,s,!1,!0)}static intersectSegmentSegment(e,i,r,s){return t.intersectLineLine(e,i,r,s,!1,!1)}static intersectLinePolygon(e,i,r,s=!0){let n=new t,o=r.length;for(let a,l,h,c=0;c<o;c++){if(a=r[c],l=r[(c+1)%o],"Coincident"===(h=t.intersectLineLine(e,i,a,l,s,!1)).status)return h;n.append(...h.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(e,i,r){return t.intersectLinePolygon(e,i,r,!1)}static intersectPolygonPolygon(e,i){let r=new t,s=e.length,n=[];for(let o=0;o<s;o++){let a=e[o],l=e[(o+1)%s],h=t.intersectSegmentPolygon(a,l,i);"Coincident"===h.status?(n.push(h),r.append(a,l)):r.append(...h.points)}return n.length>0&&n.length===e.length?new t("Coincident"):(r.points.length>0&&(r.status="Intersection"),r)}static intersectPolygonRectangle(e,i,r){let s=i.min(r),n=i.max(r),o=new tl(n.x,s.y),a=new tl(s.x,n.y);return t.intersectPolygonPolygon(e,[s,o,n,a])}},i3=class extends td{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){let t=this.getRelativeXY();return this.group?tO(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=tO(t,tk(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new tl(this.left,this.top)}setRelativeXY(t,e=this.originX,i=this.originY){this.setPositionByOrigin(t,e,i)}isStrokeAccountedForInDimensions(){return!1}getCoords(){let{tl:t,tr:e,br:i,bl:r}=this.aCoords||(this.aCoords=this.calcACoords()),s=[t,e,i,r];if(this.group){let t=this.group.calcTransformMatrix();return s.map(e=>tO(e,t))}return s}intersectsWithRect(t,e){return"Intersection"===i5.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){let e=i5.intersectPolygonPolygon(this.getCoords(),t.getCoords());return"Intersection"===e.status||"Coincident"===e.status||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){let{left:i,top:r,width:s,height:n}=this.getBoundingRect();return i>=t.x&&i+s<=e.x&&r>=t.y&&r+n<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return i5.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;let{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(i=>i.x<=e.x&&i.x>=t.x&&i.y<=e.y&&i.y>=t.y)||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;let{tl:t,br:e}=this.canvas.vptCoords;return!!this.intersectsWithRect(t,e)||this.getCoords().every(i=>(i.x>=e.x||i.x<=t.x)&&(i.y>=e.y||i.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return eo(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(N,t),this._set(U,t),this.setCoords()}
37scaleToWidth(t){let e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){let e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return(null==(t=this.canvas)?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?tw(tP(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null==(t=this.canvas)?void 0:t.viewportTransform)||E.concat()}calcACoords(){let t=tj({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),r=tD(tA(e,i),t),s=this._getTransformedDimensions(),n=s.x/2,o=s.y/2;return{tl:tO({x:-n,y:-o},r),tr:tO({x:n,y:-o},r),bl:tO({x:-n,y:o},r),br:tO({x:n,y:o},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(t=!1){let e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.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,ev(this.originX),ev(this.originY)),e}calcTransformMatrix(t=!1){let e=this.calcOwnMatrix();if(t||!this.group)return e;let i=this.transformMatrixKey(t),r=this.matrixCache;return r&&r.key.every((t,e)=>t===i[e])?r.value:(this.group&&(e=tD(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:i,value:e},e)}calcOwnMatrix(){let t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key.every((e,i)=>e===t[i]))return e.value;let i=this.getRelativeCenterPoint(),r=t$({angle:this.angle,translateX:i.x,translateY:i.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY});return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new tl(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(t={}){let e={scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth,...t},i=e.strokeWidth,r=i,s=0;this.strokeUniform&&(r=0,s=i);let n=e.width+r,o=e.height+r;return(0===e.skewX&&0===e.skewY?new tl(n*e.scaleX,o*e.scaleY):ed(n,o,tR(e))).scalarAdd(s)}translateToGivenOrigin(t,e,i,r,s){let n=t.x,o=t.y,a=ev(r)-ev(e),l=ev(s)-ev(i);if(a||l){let t=this._getTransformedDimensions();n+=a*t.x,o+=l*t.y}return new tl(n,o)}translateToCenterPoint(t,e,i){if("center"===e&&"center"===i)return t;let r=this.translateToGivenOrigin(t,e,i,A,A);return this.angle?r.rotate(tS(this.angle),t):r}translateToOriginPoint(t,e,i){let r=this.translateToGivenOrigin(t,A,A,e,i);return this.angle?r.rotate(tS(this.angle),t):r}getCenterPoint(){let t=this.getRelativeCenterPoint();return this.group?tO(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new tl(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.getPositionByOrigin(t,e)}getPositionByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){let r=this.translateToCenterPoint(t,e,i),s=this.translateToOriginPoint(r,this.originX,this.originY);this.set({left:s.x,top:s.y})}_getLeftTopCoords(){return this.getPositionByOrigin(j,"top")}positionByLeftTop(t){return this.setPositionByOrigin(t,j,"top")}},i4=class t extends i3{static getDefaults(){return t.ownDefaults}get type(){let t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){g("warn","Setting type has no effect",t)}constructor(e){super(),c(this,"_cacheContext",null),Object.assign(this,t.ownDefaults),this.setOptions(e)}_createCacheCanvas(){this._cacheCanvas=ty(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){let e=t.width,i=t.height,r=d.maxCacheSideLimit,s=d.minCacheSideLimit;if(e<=r&&i<=r&&e*i<=d.perfLimitSizeTotal)return e<s&&(t.width=s),i<s&&(t.height=s),t;let[n,o]=w.limitDimsByArea(e/i),a=ic(s,n,r),l=ic(s,o,r);return e>a&&(t.zoomX/=e/a,t.width=a,t.capped=!0),i>l&&(t.zoomY/=i/l,t.height=l,t.capped=!0),t}_getCacheCanvasDimensions(){let t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),i=e.x*t.x/this.scaleX,r=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(r+2),zoomX:t.x,zoomY:t.y,x:i,y:r}}_updateCacheCanvas(){let t=this._cacheCanvas,e=this._cacheContext,{width:i,height:r,zoomX:s,zoomY:n,x:o,y:a}=this._limitCacheSize(this._getCacheCanvasDimensions()),l=i!==t.width||r!==t.height,h=this.zoomX!==s||this.zoomY!==n;if(!t||!e)return!1;if(l||h){i!==t.width||r!==t.height?(t.width=i,t.height=r):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));let l=o/2,h=a/2;return this.cacheTranslationX=Math.round(t.width/2-l)+l,this.cacheTranslationY=Math.round(t.height/2-h)+h,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(s,n),this.zoomX=s,this.zoomY=n,!0}return!1}setOptions(t={}){this._setOptions(t)}transform(t){let e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new tl(Math.abs(this.scaleX),Math.abs(this.scaleY));let t=tE(this.calcTransformMatrix());return new tl(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){let t=this.getObjectScaling();if(this.canvas){let e=this.canvas.getZoom(),i=this.getCanvasRetinaScaling();return t.scalarMultiply(e*i)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:0===t?1e-4:t}_set(t,e){"scaleX"!==t&&"scaleY"!==t||(e=this._constrainScale(e)),"scaleX"===t&&e<0?(this.flipX=!this.flipX,e*=-1):"scaleY"===t&&e<0?(this.flipY=!this.flipY,e*=-1):"shadow"!==t||!e||e instanceof ih||(e=new ih(e));let i=this[t]!==e;return this[t]=e,i&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||i&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackgroun
37d(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){let{zoomX:e,zoomY:i,cacheTranslationX:r,cacheTranslationY:s}=this,{width:n,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:r,cacheTranslationY:s,width:n,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return!!this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth}hasFill(){return!!this.fill&&"transparent"!==this.fill}needsItsOwnCache(){return!!("stroke"===this.paintFirst&&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&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)}drawClipPathOnCache(t,e,i){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(i,0,0),t.restore()}drawObject(t,e,i){let r=this.fill,s=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this.fire("before:render",{ctx:t}),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=r,this.stroke=s}createClipPathLayer(t,e){let i=tx(e),r=i.getContext("2d");if(r.translate(e.cacheTranslationX,e.cacheTranslationY),r.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach(t=>{t.transform(r)}),e.parentClipPaths.push(t),t.absolutePositioned){let t=tk(this.calcTransformMatrix());r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return t.transform(r),t.drawObject(r,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;let r=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,r)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(t=!1){if(this.isNotVisible())return!1;let e=this._cacheCanvas,i=this._cacheContext;return!(!e||!i||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&i&&!t&&(i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,e.width,e.height),i.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;let e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){let i=e.stroke;i&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,tN(i)?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?this._applyPatternForTransformedGradient(t,i):(t.strokeStyle=i.toLive(t),this._applyPatternGradientTransform(t,i)):t.strokeStyle=e.stroke)}_setFillStyles(t,{fill:e}){e&&(tN(e)?(t.fillStyle=e.toLive(t),this._applyPatternGradientTransform(t,e)):t.fillStyle=e)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&0!==e.length&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;let e=this.shadow,i=this.canvas,r=this.getCanvasRetinaScaling(),[s,,,n]=(null==i?void 0:i.viewportTransform)||E,o=s*r,a=n*r,l=e.nonScaling?new tl(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*d.browserShadowBlurConstant*(o+a)*(l.x+l.y)/4,t.shadowOffsetX=e.offsetX*o*l.x,t.shadowOffsetY=e.offsetY*a*l.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!tN(e))return{offsetX:0,offsetY:0};let i=e.gradientTransform||e.patternTransform,r=-this.width/2+e.offsetX||0,s=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,r,s):t.transform(1,0,0,1,r,s),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:r,offsetY:s}}_renderPaintInOrder(t){"stroke"===this.paintFirst?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore(
vendor: 9,051 bytes, line 37
37))}_renderStroke(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){let e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;let r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=this.getCanvasRetinaScaling(),n=r.x/this.scaleX/s,o=r.y/this.scaleY/s,a=tx({width:Math.ceil(n),height:Math.ceil(o)}),l=a.getContext("2d");l&&(l.beginPath(),l.moveTo(0,0),l.lineTo(n,0),l.lineTo(n,o),l.lineTo(0,o),l.closePath(),l.translate(n/2,o/2),l.scale(r.zoomX/this.scaleX/s,r.zoomY/this.scaleY/s),this._applyPatternGradientTransform(l,e),l.fillStyle=e.toLive(t),l.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(s*this.scaleX/r.zoomX,s*this.scaleY/r.zoomY),t.strokeStyle=null==(i=l.createPattern(a,"no-repeat"))?"":i)}_findCenterFromElement(){return new tl(this.left+this.width/2,this.top+this.height/2)}clone(t){let e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){let e=this.toCanvasElement(t);return new(ti.getClass("image"))(e)}toCanvasElement(t={}){let e=eu(this),i=this.group,r=this.shadow,s=Math.abs,n=t.enableRetinaScaling?S():1,o=(t.multiplier||1)*n,a=t.canvasProvider||(t=>new ee(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&ec(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&em(this,this.getViewportTransform()),this.setCoords();let l=ty(),h=this.getBoundingRect(),c=this.shadow,u=new tl;if(c){let t=c.blur,e=c.nonScaling?new tl(1,1):this.getObjectScaling();u.x=2*Math.round(s(c.offsetX)+t)*s(e.x),u.y=2*Math.round(s(c.offsetY)+t)*s(e.y)}let d=h.width+u.x,g=h.height+u.y;l.width=Math.ceil(d),l.height=Math.ceil(g);let f=a(l);"jpeg"===t.format&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new tl(f.width/2,f.height/2),A,A);let p=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();let m=f.toCanvasElement(o||1,t);return this.set("canvas",p),this.shadow=r,i&&(this.group=i),this.set(e),this.setCoords(),f._objects=[],f.destroy(),m}toDataURL(t={}){return tC(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(t={}){return tb(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(...t){return t.includes(this.constructor.type)||t.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){let{centeredRotation:e,originX:i,originY:r}=this;if(e){let{x:t,y:e}=this.getRelativeCenterPoint();this.originX=A,this.originY=A,this.left=t,this.top=e}if(this.set("angle",t),e){let{x:t,y:e}=this.getPositionByOrigin(i,r);this.left=t,this.top=e,this.originX=i,this.originY=r}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){tr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&x().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((t,[i,r])=>(t[i]=this._animate(i,r,e),t),{})}_animate(t,e,i={}){let r=t.split("."),s=this.constructor.colorProperties.includes(r[r.length-1]),{abort:n,startValue:o,onChange:a,onComplete:l}=i,h={...i,target:this,startValue:null==o?r.reduce((t,e)=>t[e],this):o,endValue:e,abort:null==n?void 0:n.bind(this),onChange:(t,e,i)=>{r.reduce((e,i,s)=>(s===r.length-1&&(e[i]=t),e[i]),this),a&&a(t,e,i)},onComplete:(t,e,i)=>{this.setCoords(),l&&l(t,e,i)}};return s?i2(h):i1(h)}isDescendantOf(t){let{parent:e,group:i}=this;return e===t||i===t||!!e&&e.isDescendantOf(t)||!!i&&i!==e&&i.isDescendantOf(t)}getAncestors(){let t=[],e=this;do(e=e.parent)&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};let e=this.getAncestors(),i=t.getAncestors();if(0===e.length&&i.length>0&&this===i[i.length-1])return{fork:[],otherFork:[t,...i.slice(0,i.length-1)],common:[this]};for(let r,s=0;s<e.length;s++){if((r=e[s])===t)return{fork:[this,...e.slice(0,s)],otherFork:[],common:e.slice(s)};for(let n=0;n<i.length;n++){if(this===i[n])return{fork:[],otherFork:[t,...i.slice(0,n)],common:[this,...e]};if(r===i[n])return{fork:[this,...e.slice(0,s)],otherFork:[t,...i.slice(0,n)],common:e.slice(s)}}}return{fork:[this,...e],otherFork:[t,...i],common:[]}}hasCommonAncestors(t){let e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;let e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;let i=e.common[0]||this.canvas;if(!i)return;let r=e.fork.pop(),s=e.otherFork.pop(),n=i._objects.indexOf(r),o=i._objects.indexOf(s);return n>-1&&n>o}toObject(e=[]){let i=e.concat(t.customProperties,this.constructor.customProperties||[]),r,s=d.NUM_FRACTION_DIGITS,{clipPath:n,fill:o,stroke:a,shadow:l,strokeDashArray:h,left:c,top:u,originX:g,originY:f,width:p,height:m,strokeWidth:y,strokeLineCap:v,strokeDashOffset:_,strokeLineJoin:x,strokeUniform:C,strokeMiterLimit:b,scaleX:S,scaleY:w,angle:O,flipX:k,flipY:D,opacity:M,visible:P,backgroundColor:E,fillRule:A,paintFirst:j,globalCompositeOperation:F,skewX:L,skewY:B}=this;n&&!n.excludeFromExport&&(r=n.toObject(i.concat("inverted","absolutePositioned")));let I=t=>tz(t,s),R={...tV(this,i),type:this.constructor.type,version:T,originX:g,originY:f,left:I(c),top:I(u),width:I(p),height:I(m),fill:tU(o)?o.toObject():o,stroke:tU(a)?a.toObject():a,strokeWidth:I(y),strokeDashArray:h&&h.concat(),strokeLineCap:v,strokeDashOffset:_,strokeLineJoin:x,strokeUniform:C,strokeMiterLimit:I(b),scaleX:I(S),scaleY:I(w),angle:I(O),flipX:k,flipY:D,opacity:I(M),shadow:l&&l.toObject(),visible:P,backgroundColor:E,fillRule:A,paintFirst:j,globalCompositeOperation:F,skewX:I(L),skewY:I(B),...r?{clipPath:r}:null};return this.includeDefaultValues?R:this._removeDefaultValues(R)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){let e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return tG(t,(t,e)=>{if("left"===e||"top"===e||"type"===e)return!0;let r=i[e];return t!==r&&!(Array.isArray(t)&&Array.isArray(r)&&0===t.length&&0===r.length)})}toString(){return`#<${this.constructor.type}>`}static _fromObject({type:t,...e},{extraParam:i,...r}={}){return tW(e,r).then(t=>i?(delete t[i],new this(e[i],t)):new this(t))}static fromObject(t,e){return this._fromObject(t,e)}};c(i4,"stateProperties",iu),c(i4,"cacheProperties",id),c(i4,"ownDefaults",{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:A,originY:A,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}),c(i4,"type","FabricObject"),c(i4,"colorProperties",[J,Q,"backgroundColor"]),c(i4,"customProperties",[]),ti.setClass(i4),ti.setClass(i4,"object");let i8=(t,e)=>{var i;let{transform:{target:r}}=e;null==(i=r.canvas)||i.fire(`object:${t}`,{...e,target:r}),r.fire(t,e)},i6=(t,e,i)=>(r,s,n,o)=>{let a=e(r,s,n,o);return a&&i8(t,{...eF(r,s,n,o),...i}),a};function i9(t){return(e,i,r,s)=>{let{target:n,originX:o,originY:a}=i,l=n.getPositionByOrigin(o,a),h=t(e,i,r,s);return n.setPositionByOrigin(l,i.originX,i.originY),h}}let i7=(t,e,i,r)=>(s,n,o,a)=>{let l=eB(n,n.originX,n.originY,o,a)[i],h=ev(n[e]);if(0===h||h>0&&l<0||h<0&&l>0){let{target:e}=n,i=e.strokeWidth/(e.strokeUniform?e[r]:1),s=eA(n)?2:1,o=e[t],a=Math.abs(l*s/e[r])-i;return e.set(t,Math.max(a,1)),o!==e[t]}return!1},rt=i7("width","originX","x","scaleX"),re=i7("height","originY","y","scaleY"),ri=i6(V,i9(rt)),rr=i6(V,i9(re));function rs(t,e,i,r,s){t.save();let{stroke:n,xSize:o,ySize:a,opName:l}=this.commonRenderProps(t,e,i,s,r),h=o;o>a?t.scale(1,a/o):a>o&&(h=a,t.scale(o/a,1)),t.beginPath(),t.arc(0,0,h/2,0,M,!1),t[l](),n&&t.stroke(),t.restore()}function rn(t,e,i,r,s){t.save();let{stroke:n,xSize:o,ySize:a,opName:l}=this.commonRenderProps(t,e,i,s,r),h=o/2,c=a/2;t[`${l}Rect`](-h,-c,o,a),n&&t.strokeRect(-h,-c,o,a),t.restore()}var ro=class{constructor(t){c(this,"visible",!0),c(this,"actionName",H),c(this,"angle",0),c(this,"x",0),c(this,"y",0),c(this,"offsetX",0),c(this,"offsetY",0),c(this,"sizeX",0),c(this,"sizeY",0),c(this,"touchSizeX",0),c(this,"touchSizeY",0),c(this,"cursorStyle","crosshair"),c(this,"withConnection",!1),Object.assign(this,t)}getTransformAnchorPoint(){var t;return null==(t=this.transformAnchorPoint)?new tl(.5-this.x,.5-this.y):t}shouldActivate(t,e,i,{tl:r,tr:s,br:n,bl:o}){var a;return(null==(a=e.canvas)?void 0:a.getActiveObject())===e&&e.isControlVisible(t)&&i5.isPointInPolygon(i,[r,s,n,o]
37)}getActionHandler(t,e,i){return this.actionHandler}getMouseDownHandler(t,e,i){return this.mouseDownHandler}getMouseUpHandler(t,e,i){return this.mouseUpHandler}cursorStyleHandler(t,e,i,r){return e.cursorStyle}getActionName(t,e,i){return e.actionName}getVisibility(t,e){var i,r;return null==(i=null==(r=t._controlsVisibility)?void 0:r[e])?this.visible:i}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,r){return new tl(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,r,s,n){let o=tM([tA(i,r),tj({angle:t}),tF((s?this.touchSizeX:this.sizeX)||e,(s?this.touchSizeY:this.sizeY)||e)]);return{tl:new tl(-.5,-.5).transform(o),tr:new tl(.5,-.5).transform(o),br:new tl(.5,.5).transform(o),bl:new tl(-.5,.5).transform(o)}}commonRenderProps(t,e,i,r,s={}){let{cornerSize:n,cornerColor:o,transparentCorners:a,cornerStrokeColor:l}=s,h=n||r.cornerSize,c=this.sizeX||h,u=this.sizeY||h,d=void 0===a?r.transparentCorners:a,g=d?Q:J,f=l||r.cornerStrokeColor;return t.fillStyle=o||r.cornerColor||"",t.strokeStyle=f||"",t.translate(e,i),t.rotate(tS(r.getTotalAngle())),{stroke:!d&&!!f,xSize:c,ySize:u,transparentCorners:d,opName:g}}render(t,e,i,r,s){"circle"===((r=r||{}).cornerStyle||s.cornerStyle)?rs.call(this,t,e,i,r,s):rn.call(this,t,e,i,r,s)}};let ra=(t,e,i)=>i.lockRotation?eE:e.cursorStyle,rl=i6(X,i9((t,{target:e,ex:i,ey:r,theta:s,originX:n,originY:o},a,l)=>{let h=e.getPositionByOrigin(n,o);if(ej(e,"lockRotation"))return!1;let c=Math.atan2(r-h.y,i-h.x),u=tw(Math.atan2(l-h.y,a-h.x)-c+s);if(e.snapAngle&&e.snapAngle>0){let t=e.snapAngle,i=e.snapThreshold||t,r=Math.ceil(u/t)*t,s=Math.floor(u/t)*t;Math.abs(u-s)<i?u=s:Math.abs(u-r)<i&&(u=r)}u<0&&(u=360+u),u%=360;let d=e.angle!==u;return e.angle=u,d}));function rh(t,e){let i=e.canvas,r=t[i.uniScaleKey];return i.uniformScaling&&!r||!i.uniformScaling&&r}function rc(t,e,i){let r=ej(t,"lockScalingX"),s=ej(t,"lockScalingY");if(r&&s||!e&&(r||s)&&i||r&&"x"===e||s&&"y"===e)return!0;let{width:n,height:o,strokeWidth:a}=t;return 0===n&&0===a&&"y"!==e||0===o&&0===a&&"x"!==e}let ru=["e","se","s","sw","w","nw","n","ne","e"],rd=(t,e,i,r)=>{let s=rh(t,i);return rc(i,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",s)?eE:`${ru[eL(i,0,r)]}-resize`};function rg(t,e,i,r,s={}){let n=e.target,o=s.by,a=rh(t,n),l,h,c,u,d,g;if(rc(n,o,a))return!1;if(e.gestureScale)h=e.scaleX*e.gestureScale,c=e.scaleY*e.gestureScale;else{if(l=eB(e,e.originX,e.originY,i,r),d="y"===o?1:Math.sign(l.x||e.signX||1),g="x"===o?1:Math.sign(l.y||e.signY||1),e.signX||(e.signX=d),e.signY||(e.signY=g),ej(n,"lockScalingFlip")&&(e.signX!==d||e.signY!==g))return!1;if(u=n._getTransformedDimensions(),a&&!o){let t=Math.abs(l.x)+Math.abs(l.y),{original:i}=e,r=t/(Math.abs(u.x*i.scaleX/n.scaleX)+Math.abs(u.y*i.scaleY/n.scaleY));h=i.scaleX*r,c=i.scaleY*r}else h=Math.abs(l.x*n.scaleX/u.x),c=Math.abs(l.y*n.scaleY/u.y);eA(e)&&(h*=2,c*=2),e.signX!==d&&"y"!==o&&(e.originX=.5-ev(e.originX),h*=-1,e.signX=d),e.signY!==g&&"x"!==o&&(e.originY=.5-ev(e.originY),c*=-1,e.signY=g)}let f=n.scaleX,p=n.scaleY;return o?("x"===o&&n.set("scaleX",h),"y"===o&&n.set("scaleY",c)):(ej(n,"lockScalingX")||n.set("scaleX",h),ej(n,"lockScalingY")||n.set("scaleY",c)),f!==n.scaleX||p!==n.scaleY}let rf=i6($,i9((t,e,i,r)=>rg(t,e,i,r))),rp=i6($,i9((t,e,i,r)=>rg(t,e,i,r,{by:"x"}))),rm=i6($,i9((t,e,i,r)=>rg(t,e,i,r,{by:"y"}))),ry={x:{counterAxis:"y",scale:N,skew:q,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:U,skew:K,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},rv=["ns","nesw","ew","nwse"],r_=(t,e,i,r)=>0!==e.x&&ej(i,"lockSkewingY")||0!==e.y&&ej(i,"lockSkewingX")?eE:`${rv[eL(i,0,r)%4]}-resize`;function rx(t,e,i,r,s){let{target:n}=i,{counterAxis:o,origin:a,lockSkewing:l,skew:h,flip:c}=ry[t];if(ej(n,l))return!1;let{origin:u,flip:d}=ry[o],g=-Math.sign(ev(i[u])*(n[d]?-1:1))*(n[c]?-1:1),f=-(0===n[h]&&eB(i,"center","center",r,s)[t]>0||n[h]>0?1:-1)*g*.5+.5;return i6(W,i9((e,i,r,s)=>(function(t,{target:e,ex:i,ey:r,skewingSide:s,...n},o){let{skew:a}=ry[t],l=o.subtract(new tl(i,r)).divide(new tl(e.scaleX,e.scaleY))[t],h=e[a],c=Math.tan(tS(n[a])),u=tw(Math.atan(2*l*s/Math.max("y"===t?e._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:e._getTransformedDimensions({scaleX:1,scaleY:1}
37).y,1)+c));e.set(a,u);let d=h!==e[a];if(d&&"y"===t){let{skewX:t,scaleX:i}=e,r=e._getTransformedDimensions({skewY:h}),s=e._getTransformedDimensions(),n=0===t?1:r.x/s.x;1!==n&&e.set("scaleX",n*i)}return d})(t,i,new tl(r,s))))(e,{...i,[a]:f,skewingSide:g},r,s)}let rC=(t,e,i,r)=>rx("x",t,e,i,r),rb=(t,e,i,r)=>rx("y",t,e,i,r);function rS(t,e){return t[e.canvas.altActionKey]}let rw=(t,e,i)=>{let r=rS(t,i);return 0===e.x?r?q:U:0===e.y?r?K:N:""},rT=(t,e,i,r)=>rS(t,i)?r_(0,e,i,r):rd(t,e,i,r),rO=(t,e,i,r)=>rS(t,e.target)?rb(t,e,i,r):rp(t,e,i,r),rk=(t,e,i,r)=>rS(t,e.target)?rC(t,e,i,r):rm(t,e,i,r),rD=()=>({ml:new ro({x:-.5,y:0,cursorStyleHandler:rT,actionHandler:rO,getActionName:rw}),mr:new ro({x:.5,y:0,cursorStyleHandler:rT,actionHandler:rO,getActionName:rw}),mb:new ro({x:0,y:.5,cursorStyleHandler:rT,actionHandler:rk,getActionName:rw}),mt:new ro({x:0,y:-.5,cursorStyleHandler:rT,actionHandler:rk,getActionName:rw}),tl:new ro({x:-.5,y:-.5,cursorStyleHandler:rd,actionHandler:rf}),tr:new ro({x:.5,y:-.5,cursorStyleHandler:rd,actionHandler:rf}),bl:new ro({x:-.5,y:.5,cursorStyleHandler:rd,actionHandler:rf}),br:new ro({x:.5,y:.5,cursorStyleHandler:rd,actionHandler:rf}),mtr:new ro({x:0,y:-.5,actionHandler:rl,cursorStyleHandler:ra,offsetY:-40,withConnection:!0,actionName:Y})}),rM=()=>({mr:new ro({x:.5,y:0,actionHandler:ri,cursorStyleHandler:rT,actionName:V}),ml:new ro({x:-.5,y:0,actionHandler:ri,cursorStyleHandler:rT,actionName:V})}),rP=()=>({...rD(),...rM()});var rE=class t extends i4{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e){super(),Object.assign(this,this.constructor.createControls(),t.ownDefaults),this.setOptions(e)}static createControls(){return{controls:rD()}}_updateCacheCanvas(){let t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){let e=t._currentTransform,i=e.target,r=e.action;if(this===i&&r&&r.startsWith("scale"))return!1}return super._updateCacheCanvas()}getActiveControl(){let t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t,e=!1){if(!this.hasControls||!this.canvas)return;this.__corner=void 0;let i=Object.entries(this.oCoords);for(let r=i.length-1;r>=0;r--){let[s,n]=i[r],o=this.controls[s];if(o.shouldActivate(s,this,t,e?n.touchCorner:n.corner))return this.__corner=s,{key:s,control:o,coord:this.oCoords[s]}}}calcOCoords(){let t=this.getViewportTransform(),e=this.getCenterPoint(),i=tD(tD(t,tD(tA(e.x,e.y),tj({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}))),[1/t[0],0,0,1/t[3],0,0]),r=this.group?tE(this.calcTransformMatrix()):void 0;r&&(r.scaleX=Math.abs(r.scaleX),r.scaleY=Math.abs(r.scaleY));let s=this._calculateCurrentDimensions(r),n={};return this.forEachControl((t,e)=>{let r=t.positionHandler(s,i,this,t);n[e]=Object.assign(r,this._calcCornerCoords(t,r))}),n}_calcCornerCoords(t,e){let i=this.getTotalAngle();return{corner:t.calcCornerCoords(i,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(i,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(let e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();let e=this.getRelativeCenterPoint(),i=this._calculateCurrentDimensions(),r=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/r[0],1/r[3]),t.rotate(tS(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-i.x/2,-i.y/2,i.x,i.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e,i={}){let r={hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray,...i};t.save(),t.strokeStyle=r.borderColor,this._setLineDash(t,r.borderDashArray),this.strokeBorders(t,e),r.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t,e={}){let{hasBorders:i,hasControls:r}=this,s={hasBorders:i,hasControls:r,...e},n=this.getViewportTransform(),o=s.hasBorders,a=s.hasControls,l=tE(tD(n,this.calcTransformMatrix()));t.save(),t.translate(l.translateX,l.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(l.angle-=180),t.rotate(tS(this.group?l.angle:this.angle)),o&&this.drawBorders(t,l,e),a&&this.drawControls(t,e),t.restore(
vendor: 8,523 bytes, line 37
37)}drawBorders(t,e,i){let r;if(i&&i.forActiveSelection||this.group){let t=ed(this.width,this.height,tR(e)),i=this.isStrokeAccountedForInDimensions()?th:(this.strokeUniform?new tl().scalarAdd(this.canvas?this.canvas.getZoom():1):new tl(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);r=t.add(i).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else r=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,r,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl((r,s)=>{r.withConnection&&r.getVisibility(this,s)&&(i=!0,t.moveTo(r.x*e.x,r.y*e.y),t.lineTo(r.x*e.x+r.offsetX,r.y*e.y+r.offsetY))}),i&&t.stroke()}drawControls(t,e={}){t.save();let i=this.getCanvasRetinaScaling(),{cornerStrokeColor:r,cornerDashArray:s,cornerColor:n}=this,o={cornerStrokeColor:r,cornerDashArray:s,cornerColor:n,...e};t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=o.cornerColor,this.transparentCorners||(t.strokeStyle=o.cornerStrokeColor),this._setLineDash(t,o.cornerDashArray),this.forEachControl((e,i)=>{if(e.getVisibility(this,i)){let r=this.oCoords[i];e.render(t,r.x,r.y,o,this)}}),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(t={}){Object.entries(t).forEach(([t,e])=>this.setControlVisible(t,e))}clearContextTop(t){if(!this.canvas)return;let e=this.canvas.contextTop;if(!e)return;let i=this.canvas.viewportTransform;e.save(),e.transform(i[0],i[1],i[2],i[3],i[4],i[5]),this.transform(e);let r=this.width+4,s=this.height+4;return e.clearRect(-r/2,-s/2,r,s),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}};function rA(t,e){return e.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{"constructor"!==i&&Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))})}),t}c(rE,"ownDefaults",{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 rj=class extends rE{};rA(rj,[eq]),ti.setClass(rj),ti.setClass(rj,"object");let rF=(t,e,i,r)=>{let s=2*(r=Math.round(r))+1,{data:n}=t.getImageData(e-r,i-r,s,s);for(let t=3;t<n.length;t+=4)if(n[t]>0)return!1;return!0};var rL=class{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new tl(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new tl(1/this.options.scaleX,1/this.options.scaleY):new tl(1,1)}createSideVector(t,e){let i=eb(t,e);return this.options.strokeUniform?i.multiply(this.scale):i}projectOrthogonally(t,e,i){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,i)))}isSkewed(){return 0!==this.options.skewX||0!==this.options.skewY}applySkew(t){let e=new tl(t);return e.y+=e.x*Math.tan(tS(this.options.skewY)),e.x+=e.y*Math.tan(tS(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}};let rB=new tl;var rI=class t extends rL{static getOrthogonalRotationFactor(t,e){return Math.abs(e?ew(t,e):eT(t))<k?-1:1}constructor(t,e,i,r){super(r),c(this,"AB",void 0),c(this,"AC",void 0),c(this,"alpha",void 0),c(this,"bisector",void 0),this.A=new tl(t),this.B=new tl(e),this.C=new tl(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=ew(this.AB,this.AC),this.bisector=eO(eC(this.AB.eq(rB)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(e,i,r=this.strokeProjectionMagnitude){let s=ek(this.createSideVector(e,i)),n=t.getOrthogonalRotationFactor(s,this.bisector);return this.scaleUnitVector(s,r*n)}projectBevel(){let t=[];return(this.alpha%M==0?[this.B]:[this.B,this.C]).forEach(e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))}),t}projectMiter(){let t=[],e=1/Math.sin(Math.abs(this.alpha)/2),i=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*e),r=this.options.strokeUniform?eS(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return eS(i)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(e,i){let r=[],s=new tl(t.getOrthogonalRotationFactor(this.bisector),t.getOrthogonalRotationFactor(new tl(this.bisector.y,this.bisector.x)));return[new tl(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new tl(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(t=>{eP(t,e,i)&&r.push(this.A.add(t))}),r}projectRoundWithSkew(t,e){let i=[],{skewX:r,skewY:s,scaleX:n,scaleY:o,strokeUniform:a}=this.options,l=new tl(Math.tan(tS(r)),Math.tan(tS(s))),h=this.strokeProjectionMagnitude,c=a?h/o/Math.sqrt(1/o**2+1/n**2*l.y**2):h/Math.sqrt(1+l.y**2),u=new tl(Math.sqrt(Math.max(h**2-c**2,0)),c),d=a?h/Math.sqrt(1+l.x**2*(1/o)**2/(1/n+1/n*l.x*l.y)**2):h/Math.sqrt(1+l.x**2/(1+l.x*l.y)**2),g=new tl(d,Math.sqrt(Math.max(h**2-d**2,0)));return[g,g.scalarMultiply(-1),u,u.scalarMultiply(-1)].map(t=>this.applySkew(a?t.multiply(this.strokeUniformScalar):t)).forEach(r=>{eP(r,t,e)&&i.push(this.applySkew(this.A).add(r))}),i}projectRound(){let t=[];t.push(...this.projectBevel());let e=this.alpha%M==0,i=this.applySkew(this.A),r=t[2*!e].subtract(i),s=t[+!!e].subtract(i),n=eD(r,e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)))>0,o=n?r:s,a=n?s:r;return this.isSkewed()?t.push(...this.projectRoundWithSkew(o,a)):t.push(...this.projectRoundNoSkew(o,a)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}},rR=class extends rL{constructor(t,e,i){super(i),this.A=new tl(t),this.T=new tl(e)}calcOrthogonalProjection(t,e,i=this.strokeProjectionMagnitude){let r=this.createSideVector(t,e);return this.scaleUnitVector(ek(r),i)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){let t=[];if(!this.isSkewed()&&this.A.eq(this.T)){let e=new tl(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new rI(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){let t=[];if(this.A.eq(this.T)){let e=new tl(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{let e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(eO(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),r=this.A.add(i);t.push(r.add(e),r.subtract(e))}return t.map(t=>this.applySkew(t))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}};let r$=(t,e,i=!1)=>{let r=[];if(0===t.length)return r;let s=t.reduce((t,e)=>(t[t.length-1].eq(e)||t.push(new tl(e)),t),[new tl(t[0])]);if(1===s.length)i=!0;else if(!i){let t=s[0],e=((t,e)=>{for(let i=t.length-1;i>=0;i--)if(e(t[i],i,t))return i;return -1})(s,e=>!e.eq(t));s.splice(e+1)}return s.forEach((t,s,n)=>{let o,a;0===s?(a=n[1],o=i?t:n[n.length-1]):s===n.length-1?(o=n[s-1],a=i?t:n[0]):(o=n[s-1],a=n[s+1]),i&&1===n.length?r.push(...new rR(t,t,e).project()):i&&(0===s||s===n.length-1)?r.pu
37sh(...new rR(t,0===s?a:o,e).project()):r.push(...new rI(t,o,a,e).project())}),r},rX=t=>{let e={};return Object.keys(t).forEach(i=>{e[i]={},Object.keys(t[i]).forEach(r=>{e[i][r]={...t[i][r]}})}),e},rY=(t,e,i=!1)=>t.fill!==e.fill||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth||t.fontSize!==e.fontSize||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.textDecorationThickness!==e.textDecorationThickness||t.textDecorationColor!==e.textDecorationColor||t.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||i&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough),rW=(t,e)=>{let i=e.split(` 38`),r=[],s=-1,n={};t=rX(t);for(let e=0;e<i.length;e++){let o=t9(i[e]);if(t[e])for(let i=0;i<o.length;i++){s++;let o=t[e][i];o&&Object.keys(o).length>0&&(rY(n,o,!0)?r.push({start:s,end:s+1,style:o}):r[r.length-1].end++),n=o||{}}else s+=o.length,n={}}return r},rV=(t,e)=>{if(!Array.isArray(t))return rX(t);let i=e.split(I),r={},s=-1,n=0;for(let e=0;e<i.length;e++){let o=t9(i[e]);for(let i=0;i<o.length;i++)s++,t[n]&&t[n].start<=s&&s<t[n].end&&(r[e]=r[e]||{},r[e][i]={...t[n].style},s===t[n].end-1&&n++)}return r},rG=["display","transform",J,"fill-opacity","fill-rule","opacity",Q,"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 rz(t,e){let i=t.nodeName,r=t.getAttribute("class"),s=t.getAttribute("id"),n="(?![a-zA-Z\\-]+)",o;if(o=RegExp("^"+i,"i"),e=e.replace(o,""),s&&e.length&&(o=RegExp("#"+s+n,"i"),e=e.replace(o,"")),r&&e.length){let t=r.split(" ");for(let i=t.length;i--;)o=RegExp("\\."+t[i]+n,"i"),e=e.replace(o,"")}return 0===e.length}let rH=t=>{var e;return null==(e=e7[t])?t:e},rN=RegExp(`(${e4})`,"gi"),rU=`(${e4})`,rq=String.raw`(skewX)\(${rU}\)`,rK=String.raw`(skewY)\(${rU}\)`,rJ=String.raw`(rotate)\(${rU}(?: ${rU} ${rU})?\)`,rQ=String.raw`(scale)\(${rU}(?: ${rU})?\)`,rZ=String.raw`(translate)\(${rU}(?: ${rU})?\)`,r0=`(?:${String.raw`(matrix)\(${rU} ${rU} ${rU} ${rU} ${rU} ${rU}\)`}|${rZ}|${rJ}|${rQ}|${rq}|${rK})`,r1=`(?:${r0}*)`,r2=new RegExp(String.raw`^\s*(?:${r1}?)\s*$`),r5=new RegExp(r0),r3=RegExp(r0,"g");function r4(t){let e=[];
38if(!(t=eI(t.replace(rN," $1 ").replace(/,/gi," ")).replace(/\s*([()])\s*/gi,"$1"))||t&&!r2.test(t))return[...E];for(let i of t.matchAll(r3)){let t=r5.exec(i[0]);if(!t)continue;let r=E,[,s,...n]=t.filter(t=>!!t),[o,a,l,h,c,u]=n.map(t=>parseFloat(t));switch(s){case"translate":r=tA(o,a);break;case Y:r=tj({angle:o},{x:a,y:l});break;case H:r=tF(o,a);break;case q:r=tB(o);break;case K:r=tI(o);break;case"matrix":r=[o,a,l,h,c,u]}e.push(r)}return tM(e)}function r8(t,e){t.replace(/;\s*$/,"").split(";").forEach(t=>{if(!t)return;let[i,r]=t.split(":");e[i.trim().toLowerCase()]=r.trim()})}let r6={stroke:"strokeOpacity",fill:"fillOpacity"};function r9(t,e,i){let r,s,n;if(!t)return{};let o,a={},l=16;t.parentNode&&is.test(t.parentNode.nodeName)&&(a=r9(t.parentElement,e,i)).fontSize&&(o=l=eH(a.fontSize));let h={...e.reduce((e,i)=>{let r=t.getAttribute(i);return r&&(e[i]=r),e},{}),...function(t,e={}){let i={};for(let r in e)(function(t,e){let i=!0,r=rz(t,e.pop());return r&&e.length&&(i=function(t,e){let i,r=!0;for(;t.parentElement&&1===t.parentElement.nodeType&&e.length;)r&&(i=e.pop()),r=rz(t=t.parentElement,i);return 0===e.length}(t,e)),r&&i&&0===e.length})(t,r.split(" "))&&(i={...i,...e[r]});return i}(t,i),...(r={},(s=t.getAttribute("style"))&&("string"==typeof s?r8(s,r):function(t,e){Object.entries(t).forEach(([t,i])=>{void 0!==i&&(e[t.toLowerCase()]=i)})}(s,r)),r)};h["clip-path"]&&t.setAttribute(ie,h[ie]),h["font-size"]&&(o=eH(h[it],l),h[it]=`${o}`);let c={};for(let t in h){let e=rH(t);c[e]=function(t,e,i,r){let s=Array.isArray(e),n,o=e;if("fill"!==t&&"stroke"!==t||"none"!==e){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)o="none"===e?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)o=i&&i.transformMatrix?tD(i.transformMatrix,r4(e)):r4(e);else if("visible"===t)o="none"!==e&&"hidden"!==e,i&&!1===i.visible&&(o=!1);else if("opacity"===t)o=parseFloat(e),i&&void 0!==i.opacity&&(o*=i.opacity);else if("textAnchor"===t)o="start"===e?j:"end"===e?L:A;else if("charSpacing"===t||"textDecorationThickness"===t)n=eH(e,r)/r*1e3;else if("paintFirst"===t){let t=e.indexOf(J),i=e.indexOf(Q);o=J,(t>-1&&i>-1&&i<t||-1===t&&i>-1)&&(o=Q)}else{if("href"===t||"xlink:href"===t||"font"===t||"id"===t)return e;if("imageSmoothing"===t)return"optimizeQuality"===e;n=s?e.map(eH):eH(e,r)}}else o="";return!s&&isNaN(n)?o:n}(e,h[t],a,o)}c&&c.font&&function(t,e){let i=t.match(e9);if(!i)return;let r=i[1],s=i[3],n=i[4],o=i[5],a=i[6];r&&(e.fontStyle=r),s&&(e.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),n&&(e.fontSize=eH(n)),a&&(e.fontFamily=a),o&&(e.lineHeight="normal"===o?1:o)}(c.font,c);let u={...a,...c};return is.test(t.nodeName)||(n=rj.getDefaults(),Object.entries(r6).forEach(([t,e])=>{if(void 0===u[e]||""===u[t])return;if(void 0===u[t]){if(!n[t])return;u[t]=n[t]}if(0===u[t].indexOf("url("))return;let i=new eG(u[t]);u[t]=i.setAlpha(tz(i.getAlpha()*u[e],2)).toRgba()})),u}let r7=["rx","ry"];var st=class t extends rj{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e){super(),Object.assign(this,t.ownDefaults),this.setOptions(e),this._initRxRy()}_initRxRy(){let{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){let{width:e,height:i}=this,r=-e/2,s=-i/2,n=this.rx?Math.min(this.rx,e/2):0,o=this.ry?Math.min(this.ry,i/2):0,a=0!==n||0!==o;t.beginPath(),t.moveTo(r+n,s),t.lineTo(r+e-n,s),a&&t.bezierCurveTo(r+e-.4477152502*n,s,r+e,s+.4477152502*o,r+e,s+o),t.lineTo(r+e,s+i-o),a&&t.bezierCurveTo(r+e,s+i-.4477152502*o,r+e-.4477152502*n,s+i,r+e-n,s+i),t.lineTo(r+n,s+i),a&&t.bezierCurveTo(r+.4477152502*n,s+i,r,s+i-.4477152502*o,r,s+i-o),t.lineTo(r,s+o),a&&t.bezierCurveTo(r,s+.4477152502*o,r+.4477152502*n,s,r+n,s),t.closePath(),this._renderPaintInOrder(t)}toObject(t=[]){return super.toObject([...r7,...t])}_toSVG(){let{width:t,height:e,rx:i,ry:r}=this;return["<rect ","COMMON_PARTS",`x="${-t/2}" y="${-e/2}" rx="${t6(i)}" ry="${t6(r)}" width="${t6(t)}" height="${t6(e)}" /> 39`]}static async fromElement(t,e,i){let{left:r=0,top:s=0,width:n=0,height:o=0,visible:a=!0,...l}=r9(t,this.ATTRIBUTE_NAMES,i);return new this({...e,...l,left:r,top:s,width:n,height:o,visible:!!(a&&n&&o)})}};c(st,"type","Rect"),c(st,"cacheProperties",[...id,...r7]),c(st,"ownDefaults",{rx:0,ry:0}),c(st,"ATTRIBUTE_NAMES",[...rG,"x","y","rx","ry","width","height"]),ti.setClass(st),ti.setSVGClass(st);let se="initialization",si="added",sr=(t,e)=>{let{strokeUniform:i,strokeWidth:r,width:s,height:n,group:o}=e,a=o&&o!==t?eg(o.calcTransformMatrix(),t.calcTransformMatrix()):null,l=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),h=!e.isStrokeAccountedForInDimensions(),c=i&&h?ep(new tl(r,r),void 0,t.calcTransformMatrix()):th,u=!i&&h?r:0,d=ed(s+u,n+u,tM([a,e.calcOwnMatrix()],!0)).add(c).scalarDivide(2);return[l.subtract(d),l.add(d)]};var ss=class{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout({type:t,prevStrategy:e,strategy:i}
39){return"initialization"===t||"imperative"===t||!!e&&i!==e}shouldLayoutClipPath({type:t,target:{clipPath:e}}){return"initialization"!==t&&e&&!e.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){let{type:i,target:r}=e;if("imperative"===i&&e.overrides)return e.overrides;if(0===t.length)return;let{left:s,top:n,width:o,height:a}=eo(t.map(t=>sr(r,t)).reduce((t,e)=>t.concat(e),[])),l=new tl(o,a),h=new tl(s,n).add(l.scalarDivide(2));if("initialization"===i){let t=this.getInitialSize(e,{size:l,center:h});return{center:h,relativeCorrection:new tl(0,0),size:t}}return{center:h.transform(r.calcOwnMatrix()),size:l}}};c(ss,"type","strategy");var sn=class extends ss{shouldPerformLayout(t){return!0}};c(sn,"type","fit-content"),ti.setClass(sn);let so="layoutManager";var sa=class{constructor(t=new sn){c(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){let e={bubbles:!0,strategy:this.strategy,...t,prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}};this.onBeforeLayout(e);let i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){let{target:i}=e;return[Z,R,V,X,$,W,z,G,"modifyPath"].map(e=>t.on(e,t=>this.performLayout("modified"===e?{type:"object_modified",trigger:e,e:t,target:i}:{type:"object_modifying",trigger:e,e:t,target:i})))}subscribe(t,e){this.unsubscribe(t,e);let i=this.attachHandlers(t,e);this._subscriptions.set(t,i)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(t=>t()),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach(e=>this.unsubscribe(e,t))}subscribeTargets(t){t.targets.forEach(e=>this.subscribe(e,t))}onBeforeLayout(t){let{target:e,type:i}=t,{canvas:r}=e;if("initialization"===i||"added"===i?this.subscribeTargets(t):"removed"===i&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),r&&r.fire("object:layout:before",{target:e,context:t}),"imperative"===i&&t.deep){let{strategy:i,...r}=t;e.forEachObject(t=>t.layoutManager&&t.layoutManager.performLayout({...r,bubbles:!1,target:t}))}}getLayoutResult(t){let{target:e,strategy:i,type:r}=t,s=i.calcLayoutResult(t,e.getObjects());if(!s)return;let n="initialization"===r?new tl:e.getRelativeCenterPoint(),{center:o,correction:a=new tl,relativeCorrection:l=new tl}=s;return{result:s,prevCenter:n,nextCenter:o,offset:n.subtract(o).add(a).transform("initialization"===r?E:tk(e.calcOwnMatrix()),!0).add(l)}}commitLayout(t,e){var i,r;let{target:s}=t,{result:{size:n},nextCenter:o}=e;s.set({width:n.x,height:n.y}),this.layoutObjects(t,e),"initialization"===t.type?s.set({left:null==(i=t.x)?o.x+n.x*ev(s.originX):i,top:null==(r=t.y)?o.y+n.y*ev(s.originY):r}):(s.setPositionByOrigin(o,A,A),s.setCoords(),s.set("dirty",!0))}layoutObjects(t,e){let{target:i}=t;i.forEachObject(r=>{r.group===i&&this.layoutObject(t,e,r)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,{offset:e},i){i.set({left:i.left+e.x,top:i.top+e.y})}onAfterLayout(t,e){let{target:i,strategy:r,bubbles:s,prevStrategy:n,...o}=t,{canvas:a}=i;i.fire("layout:after",{context:t,result:e}),a&&a.fire("object:layout:after",{context:t,result:e,target:i});let l=i.parent;s&&null!=l&&l.layoutManager&&((o.path||(o.path=[])).push(i),l.layoutManager.performLayout({...o,target:l})),i.set("dirty",!0)}dispose(){let{_subscriptions:t}=this;t.forEach(t=>t.forEach(t=>t())),t.clear()}toObject(){return{type:so,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}};ti.setClass(sa,so);var sl=class extends sa{performLayout(){}},sh=class t extends tu(rj){static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e=[],i={}){super(),c(this,"_activeObjects",[]),c(this,"__objectSelectionTracker",void 0),c(this,"__objectSelectionDisposer",void 0),Object.assign(this,t.ownDefaults),this.setOptions(i),this.groupInit(e,i)}groupInit(t,e){var i;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(t=>{this.enterGroup(t,!1)}),this.layoutManager=null==(i=e.layoutManager)?new sa:i,this.layoutManager.performLayout({type:se,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(g("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(g("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((t,e,i)=>this.canEnterGroup(t)&&i.indexOf(t)===e)}add(...t){let e=this._filterObjectsBeforeEnteringGroup(t),i=super.add(...e);return this._onAfterObjectsChange(si,e),i}insertAt(t,...e){let i=this._filterObjectsBeforeEnteringGroup(e),r=super.insertAt(t,...i);return this._onAfterObjectsChange(si,i),r}remove(...t){let e=super.remove(...t);return this._onAfterObjectsChange("removed",e),e}_onObjectAdded(t){this.enterGroup(t,!0),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t,e){this.exitGroup(t,e),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onAfterObjectsChange(t,e){this.layoutManager.performLayout({type:t,targets:e,target:this})}_onStackOrderChanged(){this._set("dirty",!0)}_set(t,e){let i=this[t];return super._set(t,e),"canvas"===t&&i!==e&&(this._objects||[]).forEac
vendor: 5,641 bytes, lines 39-41
39h(i=>{i._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,{target:e}){let i=this._activeObjects;if(t)i.push(e),this._set("dirty",!0);else if(i.length>0){let t=i.indexOf(e);t>-1&&(i.splice(t,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&eh(t,tD(tk(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);let i=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();i&&(i===t||t.isDescendantOf(i))&&this._activeObjects.push(t)}exitGroup(t,e){this._exitGroup(t,e),t._set("parent",void 0),t._set("canvas",void 0)}_exitGroup(t,e){t._set("group",void 0),e||(eh(t,tD(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);let i=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;i>-1&&this._activeObjects.splice(i,1)}shouldCache(){let t=rj.prototype.shouldCache.call(this);if(t){for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,i){this._renderBackground(t);for(let e=0;e<this._objects.length;e++){var r;let i=this._objects[e];null!=(r=this.canvas)&&r.preserveObjectStacking&&i.group!==this?(t.save(),t.transform(...tk(this.calcTransformMatrix())),i.render(t),t.restore()):i.group===this&&i.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(t={}){this.layoutManager.performLayout({target:this,type:"imperative",...t})}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){let i=this.includeDefaultValues;return this._objects.filter(function(t){return!t.excludeFromExport}).map(function(r){let s=r.includeDefaultValues;r.includeDefaultValues=i;let n=r[t||"toObject"](e);return r.includeDefaultValues=s,n})}toObject(t=[]){let e=this.layoutManager.toObject();return{...super.toObject(["subTargetCheck","interactive",...t]),..."fit-content"!==e.strategy||this.includeDefaultValues?{layoutManager:e}:{},objects:this.__serializeObjects("toObject",t)}}toString(){return`#<Group: (${this.complexity()})>`}dispose(){this.layoutManager.unsubscribeTargets({targets:this.getObjects(),target:this}),this._activeObjects=[],this.forEachObject(t=>{this._watchObject(!1,t),t.dispose()}),super.dispose()}_createSVGBgRect(t){if(!this.backgroundColor)return"";let e=st.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';let r=e.join("");return t?t(r):r}_toSVG(t){let e=["<g ","COMMON_PARTS",` > 40`],i=this._createSVGBgRect(t);i&&e.push(` `,i);for(let i=0;i<this._objects.length;i++)e.push(` `,this._objects[i].toSVG(t));return e.push(`</g> 41`),e}getSvgStyles(){let t=void 0!==this.opacity&&1!==this.opacity?`opacity: ${t6(this.opacity)};`:"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){let e=[],i=this._createSVGBgRect(t);i&&e.push(` `,i);for(let i=0;i<this._objects.length;i++)e.push(` `,this._objects[i].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject({type:t,objects:e=[],layoutManager:i,...r},s){return Promise.all([tY(e,s),tW(r,s)]).then(([t,e])=>{let s=new this(t,{...r,...e,layoutManager:new sl});return s.layoutManager=i?new(ti.getClass(i.type))(new(ti.getClass(i.strategy))):new sa,s.layoutManager.subscribeTargets({type:se,target:s,targets:s.getObjects()}),s.setCoords(),s})}};c(sh,"type","Group"),c(sh,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),ti.setClass(sh);let sc=(t,e)=>t&&1===t.length?t[0]:new sh(t,e),su=(t,e)=>Math.min(e.width/t.width,e.height/t.height),sd=(t,e)=>Math.max(e.width/t.width,e.height/t.height),sg="\\s*,?\\s*",sf=`${sg}(${e4})`,sp=`${sf}${sf}${sf}${sg}([01])${sg}([01])${sf}${sf}`,sm={m:"l",M:"L"},sy=(t,e,i,r,s,n,o,a,l,h,c)=>{let u=to(t),d=ta(t),g=to(e),f=ta(e),p=i*s*g-r*n*f+o,m=r*s*g+i*n*f+a;return["C",h+l*(-i*s*d-r*n*u),c+l*(-r*s*d+i*n*u),p+l*(i*s*f+r*n*g),m+l*(r*s*f-i*n*g),p,m]},sv=(t,e,i,r)=>{let s=Math.atan2(e,t),n=Math.atan2(r,i);return n>=s?n-s:2*Math.PI-(s-n)};function s_(t,e,i,r,s,n,o,a){let l;if(d.cachesBoundsOfCurve&&(l=[...arguments].join(),w.boundsOfCurveCache[l]))return w.boundsOfCurveCache[l];let h=Math.sqrt,c=Math.abs,u=[],g=[[0,0],[0,0]],f=6*t-12*i+6*s,p=-3*t+9*i-9*s+3*o,m=3*i-3*t;for(let t=0;t<2;++t){if(t>0&&(f=6*e-12*r+6*n,p=-3*e+9*r-9*n+3*a,m=3*r-3*e),1e-12>c(p)){if(1e-12>c(f))continue;let t=-m/f;0<t&&t<1&&u.push(t);continue}let i=f*f-4*m*p;if(i<0)continue;let s=h(i),o=(-f+s)/(2*p);0<o&&o<1&&u.push(o);let l=(-f-s)/(2*p);0<l&&l<1&&u.push(l)}let y=u.length,v=y,_=sS(t,e,i,r,s,n,o,a);for(;y--;){let{x:t,y:e}=_(u[y]);g[0][y]=t,g[1][y]=e}g[0][v]=t,g[1][v]=e,g[0][v+1]=o,g[1][v+1]=a;let x=[new tl(Math.min(...g[0]),Math.min(...g[1])),new tl(Math.max(...g[0]),Math.max(...g[1]))];return d.cachesBoundsOfCurve&&(w.boundsOfCurveCache[l]=x),x}let sx=(t,e,[i,r,s,n,o,a,l,h])=>
41{let c=((t,e,i,r,s,n,o)=>{if(0===i||0===r)return[];let a=0,l=0,h=0,c=Math.PI,u=o*P,d=ta(u),g=to(u),f=.5*(-g*t-d*e),p=.5*(-g*e+d*t),m=i**2,y=r**2,v=p**2,_=f**2,x=m*y-m*v-y*_,C=Math.abs(i),b=Math.abs(r);if(x<0){let t=Math.sqrt(1-x/(m*y));C*=t,b*=t}else h=(s===n?-1:1)*Math.sqrt(x/(m*v+y*_));let S=h*C*p/b,w=-h*b*f/C,T=g*S-d*w+.5*t,O=d*S+g*w+.5*e,k=sv(1,0,(f-S)/C,(p-w)/b),D=sv((f-S)/C,(p-w)/b,(-f-S)/C,(-p-w)/b);0===n&&D>0?D-=2*c:1===n&&D<0&&(D+=2*c);let M=Math.ceil(Math.abs(D/c*2)),E=[],A=D/M,j=8/3*Math.sin(A/4)*Math.sin(A/4)/Math.sin(A/2),F=k+A;for(let t=0;t<M;t++)E[t]=sy(k,F,g,d,C,b,T,O,j,a,l),a=E[t][5],l=E[t][6],k=F,F+=A;return E})(l-t,h-e,r,s,o,a,n);for(let i=0,r=c.length;i<r;i++)c[i][1]+=t,c[i][2]+=e,c[i][3]+=t,c[i][4]+=e,c[i][5]+=t,c[i][6]+=e;return c},sC=t=>{let e=0,i=0,r=0,s=0,n=[],o,a=0,l=0;for(let h of t){let t=[...h],c;switch(t[0]){case"l":t[1]+=e,t[2]+=i;case"L":c=["L",e=t[1],i=t[2]];break;case"h":t[1]+=e;case"H":c=["L",e=t[1],i];break;case"v":t[1]+=i;case"V":c=["L",e,i=t[1]];break;case"m":t[1]+=e,t[2]+=i;case"M":e=t[1],i=t[2],r=t[1],s=t[2],c=["M",e,i];break;case"c":t[1]+=e,t[2]+=i,t[3]+=e,t[4]+=i,t[5]+=e,t[6]+=i;case"C":a=t[3],l=t[4],e=t[5],i=t[6],c=["C",t[1],t[2],a,l,e,i];break;case"s":t[1]+=e,t[2]+=i,t[3]+=e,t[4]+=i;case"S":"C"===o?(a=2*e-a,l=2*i-l):(a=e,l=i),e=t[3],i=t[4],a=(c=["C",a,l,t[1],t[2],e,i])[3],l=c[4];break;case"q":t[1]+=e,t[2]+=i,t[3]+=e,t[4]+=i;case"Q":a=t[1],l=t[2],c=["Q",a,l,e=t[3],i=t[4]];break;case"t":t[1]+=e,t[2]+=i;case"T":"Q"===o?(a=2*e-a,l=2*i-l):(a=e,l=i),c=["Q",a,l,e=t[1],i=t[2]];break;case"a":t[6]+=e,t[7]+=i;case"A":sx(e,i,t).forEach(t=>n.push(t)),e=t[6],i=t[7];break;case"z":case"Z":e=r,i=s,c=["Z"]}c?(n.push(c),o=c[0]):o=""}return n},sb=(t,e,i,r)=>Math.sqrt((i-t)**2+(r-e)**2),sS=(t,e,i,r,s,n,o,a)=>l=>{let h=l**3,c=(t=>3*t**2*(1-t))(l),u=(t=>3*t*(1-t)**2)(l),d=(1-l)**3;return new tl(o*h+s*c+i*u+t*d,a*h+n*c+r*u+e*d)},sw=t=>t**2,sT=t=>2*t*(1-t),sO=t=>(1-t)**2,sk=(t,e,i,r,s,n,o,a)=>l=>{let h=sw(l),c=sT(l),u=sO(l);return Math.atan2(3*(u*(r-e)+c*(n-r)+h*(a-n)),3*(u*(i-t)+c*(s-i)+h*(o-s)))}
41,sD=(t,e,i,r,s,n)=>o=>{let a=sw(o),l=sT(o),h=sO(o);return new tl(s*a+i*l+t*h,n*a+r*l+e*h)},sM=(t,e,i,r,s,n)=>o=>{let a=1-o;return Math.atan2(2*(a*(r-e)+o*(n-r)),2*(a*(i-t)+o*(s-i)))},sP=(t,e,i)=>{let r=new tl(e,i),s=0;for(let e=1;e<=100;e+=1){let i=t(e/100);s+=sb(r.x,r.y,i.x,i.y),r=i}return s},sE=(t,e)=>{let i,r=0,s=0,n={x:t.x,y:t.y},o={...n},a=.01,l=0,h=t.iterator,c=t.angleFinder;for(;s<e&&a>1e-4;)o=h(r),l=r,(i=sb(n.x,n.y,o.x,o.y))+s>e?(r-=a,a/=2):(n=o,r+=a,s+=i);return{...o,angle:c(l)}},sA=t=>{let e,i,r=0,s=0,n=0,o=0,a=0,l=[];for(let h of t){let t={x:s,y:n,command:h[0],length:0};switch(h[0]){case"M":(i=t).x=o=s=h[1],i.y=a=n=h[2];break;case"L":(i=t).length=sb(s,n,h[1],h[2]),s=h[1],n=h[2];break;case"C":e=sS(s,n,h[1],h[2],h[3],h[4],h[5],h[6]),(i=t).iterator=e,i.angleFinder=sk(s,n,h[1],h[2],h[3],h[4],h[5],h[6]),i.length=sP(e,s,n),s=h[5],n=h[6];break;case"Q":e=sD(s,n,h[1],h[2],h[3],h[4]),(i=t).iterator=e,i.angleFinder=sM(s,n,h[1],h[2],h[3],h[4]),i.length=sP(e,s,n),s=h[3],n=h[4];break;case"Z":(i=t).destX=o,i.destY=a,i.length=sb(s,n,o,a),s=o,n=a}r+=i.length,l.push(i)}return l.push({length:r,x:s,y:n}),l},sj=(t,e,i=sA(t))=>{let r=0;for(;e-i[r].length>0&&r<i.length-2;)e-=i[r].length,r++;let s=i[r],n=e/s.length,o=t[r];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return{...new tl(s.x,s.y).lerp(new tl(s.destX,s.destY),n),angle:Math.atan2(s.destY-s.y,s.destX-s.x)};case"L":return{...new tl(s.x,s.y).lerp(new tl(o[1],o[2]),n),angle:Math.atan2(o[2]-s.y,o[1]-s.x)};case"C":case"Q":return sE(s,e)}},sF=RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),sL=RegExp(sp,"g"),sB=RegExp(e4,"gi"),sI={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},sR=t=>{var e;let i=[];for(let r of null==(e=t.match(sF))?[]:e){let t=r[0];if("z"===t||"Z"===t){i.push([t]);continue}let e=sI[t.toLowerCase()],s=[];if("a"===t||"A"===t){sL.lastIndex=0;for(let t=null;t=sL.exec(r);)s.push(...t.slice(1))}else s=r.match(sB)||[];for(let r=0;r<s.length;r+=e){let n=Array(e),o=sm[t];n[0]=r>0&&o?o:t;for(let t=0;t<e;t++)n[t+1]=parseFloat(s[r+t]);i.push(n)}}return i},s$=(t,e=0)=>{let i=new tl(t[0]),r=new tl(t[1]),s=1,n=0,o=[],a=t.length,l=a>2,h;for(l&&(s=t[2].x<r.x?-1:+(t[2].x!==r.x),n=t[2].y<r.y?-1:+(t[2].y!==r.y)),o.push(["M",i.x-s*e,i.y-n*e]),h=1;h<a;h++){if(!i.eq(r)){let t=i.midPointFrom(r);o.push(["Q",i.x,i.y,t.x,t.y])}i=t[h],h+1<t.length&&(r=t[h+1])}return l&&(s=i.x>t[h-2].x?1:i.x===t[h-2].x?0:-1,n=i.y>t[h-2].y?1:i.y===t[h-2].y?0:-1),o.push(["L",i.x+s*e,i.y+n*e]),o},sX=(t,e,i)=>(i&&(e=tD(e,[1,0,0,1,-i.x,-i.y])),t.map(t=>{let i=[...t];for(let r=1;r<t.length-1;r+=2){let{x:s,y:n}=tO({x:t[r],y:t[r+1]},e);i[r]=s,i[r+1]=n}return i})),sY=(t,e)=>{let i=2*Math.PI/t,r=-k;t%2==0&&(r+=i/2);let s=Array(t+1);for(let n=0;n<t;n++){let t=n*i+r,{x:o,y:a}=new tl(to(t),ta(t)).scalarMultiply(e);s[n]=[0===n?"M":"L",o,a]}return s[t]=["Z"],s},sW=(t,e)=>t.map(t=>t.map((t,i)=>0===i||void 0===e?t:tz(t,e)).join(" ")).join(" "),sV=(t,e)=>{var i;let r=t,s=e;r.inverted&&!s.inverted&&(r=e,s=t),em(s,null==(i=s.group)?void 0:i.calcTransformMatrix(),r.calcTransformMatrix());let n=r.inverted&&s.inverted;return n&&(r.inverted=s.inverted=!1),new sh([r],{clipPath:s,inverted:n})},sG=(t,e)=>Math.floor(Math.random()*(e-t+1))+t,sz=(t,e)=>{let i=t._findCenterFromElement();t.transformMatrix&&((t=>{if(t.transformMatrix){let{scaleX:e,scaleY:i,angle:r,skewX:s}=tE(t.transformMatrix);t.flipX=!1,t.flipY=!1,t.set(N,e),t.set(U,i),t.angle=r,t.skewX=s,t.skewY=0}})(t),i=i.transform(t.transformMatrix)),delete t.transformMatrix,e&&(t.scaleX*=e.scaleX,t.scaleY*=e.scaleY,t.cropX=e.cropX,t.cropY=e.cropY,i.x+=e.offsetLeft,i.y+=e.offsetTop,t.width=e.width,t.height=e.height),t.setPositionByOrigin(i,A,A)};var sH=l({addTransformToObject:()=>el,animate:()=>i1,animateColor:()=>i2,applyTransformToObject:()=>eh,calcAngleBetweenVectors:()=>ew,calcDimensionsMatrix:()=>tR,calcPlaneChangeMatrix:()=>eg,calcVectorRotation:()=>eT,cancelAnimFrame:()=>tf,capValue:()=>ic,composeMatrix:()=>t$,copyCanvasElement:()=>t_,cos:()=>to,createCanvasElement:()=>ty,createImage:()=>tv,createRotateMatrix:()=>tj,createScaleMatrix:()=>tF,createSkewXMatrix:()=>tB,createSkewYMatrix:()=>
vendor: 5,321 bytes, line 41
41tI,createTranslateMatrix:()=>tA,createVector:()=>eb,crossProduct:()=>eD,degreesToRadians:()=>tS,dotProduct:()=>eM,ease:()=>ig,enlivenObjectEnlivables:()=>tW,enlivenObjects:()=>tY,findScaleToCover:()=>sd,findScaleToFit:()=>su,getBoundsOfCurve:()=>s_,getOrthonormalVector:()=>ek,getPathSegmentsInfo:()=>sA,getPointOnPath:()=>sj,getPointer:()=>er,getRandomInt:()=>sG,getRegularPolygonPath:()=>sY,getSmoothPathFromPoints:()=>s$,getSvgAttributes:()=>ez,getUnitVector:()=>eO,groupSVGElements:()=>sc,hasStyleChanged:()=>rY,invertTransform:()=>tk,isBetweenVectors:()=>eP,isIdentityMatrix:()=>tT,isTouchEvent:()=>es,isTransparent:()=>rF,joinPath:()=>sW,loadImage:()=>tX,magnitude:()=>eS,makeBoundingBoxFromPoints:()=>eo,makePathSimpler:()=>sC,matrixToSVG:()=>tH,mergeClipPaths:()=>sV,multiplyTransformMatrices:()=>tD,multiplyTransformMatrixArray:()=>tM,parsePath:()=>sR,parsePreserveAspectRatioAttribute:()=>eN,parseUnit:()=>eH,pick:()=>tV,projectStrokeOnPoints:()=>r$,qrDecompose:()=>tE,radiansToDegrees:()=>tw,removeFromArray:()=>tn,removeTransformFromObject:()=>ea,removeTransformMatrixForSvgParsing:()=>sz,requestAnimFrame:()=>tg,resetObjectTransform:()=>ec,rotateVector:()=>eC,saveObjectTransform:()=>eu,sendObjectToPlane:()=>em,sendPointToPlane:()=>ef,sendVectorToPlane:()=>ep,sin:()=>ta,sizeAfterTransform:()=>ed,string:()=>t4,stylesFromArray:()=>rV,stylesToArray:()=>rW,toBlob:()=>tb,toDataURL:()=>tC,toFixed:()=>tz,transformPath:()=>sX,transformPoint:()=>tO});function sN(t,e){let i=t.style;i&&Object.entries(e).forEach(([t,e])=>i.setProperty(t,e))}var sU=class extends t5{constructor(t,{allowTouchScrolling:e=!1,containerClass:i=""}={}){super(t),c(this,"upper",void 0),c(this,"container",void 0);let{el:r}=this.lower,s=this.createUpperCanvas();this.upper={el:s,ctx:s.getContext("2d")},this.applyCanvasStyle(r,{allowTouchScrolling:e}),this.applyCanvasStyle(s,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});let n=this.createContainerElement();n.classList.add(i),r.parentNode&&r.parentNode.replaceChild(n,r),n.append(r,s),this.container=n}createUpperCanvas(){let{el:t}=this.lower,e=ty();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){let t=C().createElement("div");return t.setAttribute("data-fabric","wrapper"),sN(t,{position:"relative"}),t2(t),t}applyCanvasStyle(t,e){let{styles:i,allowTouchScrolling:r}=e;sN(t,{...i,"touch-action":r?"manipulation":B}),t2(t)}setDimensions(t,e){super.setDimensions(t,e);let{el:i,ctx:r}=this.upper;t0(i,r,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),t1(this.upper.el,t),t1(this.container,t)}cleanupDOM(t){let e=this.container,{el:i}=this.lower,{el:r}=this.upper;super.cleanupDOM(t),e.removeChild(r),e.removeChild(i),e.parentNode&&e.parentNode.replaceChild(i,e)}dispose(){super.dispose(),x().dispose(this.upper.el),delete this.upper,delete this.container}};let sq=(t,e,i,r)=>{let{target:s,offsetX:n,offsetY:o}=e,a=i-n,l=r-o,h=!ej(s,"lockMovementX")&&s.left!==a,c=!ej(s,"lockMovementY")&&s.top!==l;return h&&s.set("left",a),c&&s.set("top",l),(h||c)&&i8(R,eF(t,e,i,r)),h||c},sK=t=>function(e,i,r){let{points:s,pathOffset:n}=r;return new tl(s[t]).subtract(n).transform(tD(r.getViewportTransform(),r.calcTransformMatrix()))},sJ=(t,e,i,r)=>{let{target:s,pointIndex:n}=e,o=ef(new tl(i,r),void 0,s.calcOwnMatrix());return s.points[n]=o.add(s.pathOffset),s.setDimensions(),s.set("dirty",!0),!0},sQ=(t,e)=>function(i,r,s,n){let o=r.target,a=new tl(o.points[(t>0?t:o.points.length)-1]),l=a.subtract(o.pathOffset).transform(o.calcOwnMatrix()),h=e(i,{...r,pointIndex:t},s,n),c=a.subtract(o.pathOffset).transform(o.calcOwnMatrix()).subtract(l);return o.left-=c.x,o.top-=c.y,h},sZ=t=>i6(G,sQ(t,sJ));function s0(t,e={}){let i={};for(let r=0;r<("number"==typeof t?t:t.points.length);r++)i[`p${r}`]=new ro({actionName:G,positionHandler:sK(r),actionHandler:sZ(r),...e});return i}let s1=(t,e,i)=>{let{path:r,pathOffset:s}=t,n=r[e];return new tl(n[i]-s.x,n[i+1]-s.y).transform(tD(t.getViewportTransform(),t.calcTransformMatrix()))};function s2(t,e,i){let{commandIndex:r,pointIndex:s}=this;return s1(i,r,s)}function s5(t,e,i,r){let{target:s}=e,{commandIndex:n,pointIndex:o}=this,a=((t,e,i,r,s)=>{let{path:n,pathOffset:o}=t,a=n[(r>0?r:n.length)-1],l=new tl(a[s],a[s+1]),h=l.subtract(o).transform(t.calcOwnMatrix()),c=ef(new tl(e,i),void 0,t.calcOwnMatrix());n[r][s]=c.x+o.x,n[r][s+1]=c.y+o.y,t.setDimensions();let u=l.subtract(t.pathOffset).transform(t.calcOwnMatrix()).subtract(h);return t.left-=u.x,t.top-=u.y,t.set("dirty",!0),!0})(s,i,r,n,o);return a&&i8(this.actionName,{...eF(t,e,i,r),commandIndex:n,pointIndex:o}),a}var s3=class extends ro{constructor(t){super(t)}render(t,e,i,r,s){let n={...r,cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill};super.render(t,e,i,n,s)}},s4=class extends s3{constructor(t){super(t)}render(t,e,i,r,s){let{path:n}=s,{commandIndex:o,pointIndex:a,connectToCommandIndex:l,connectToPointIndex:h}=this;t.save(),t.strokeStyle=this.controlStroke,this.connectionDashArray&&t.setLineDash(this.connectionDashArray);let[c]=n[o],u=s1(s,l,h);if("Q"===c){let r=s1(s,o,a+2);t.moveTo(r.x,r.y),t.lineTo(e,i)}else t.moveTo(e,i);
41t.lineTo(u.x,u.y),t.stroke(),t.restore(),super.render(t,e,i,r,s)}};let s8=(t,e,i,r,s,n)=>new(i?s4:s3)({commandIndex:t,pointIndex:e,actionName:"modifyPath",positionHandler:s2,actionHandler:s5,connectToCommandIndex:s,connectToPointIndex:n,...r,...i?r.controlPointStyle:r.pointStyle});function s6(t,e={}){let i={},r="M";return t.path.forEach((t,s)=>{let n=t[0];switch("Z"!==n&&(i[`c_${s}_${n}`]=s8(s,t.length-2,!1,e)),n){case"C":let o;i[`c_${s}_C_CP_1`]=s8(s,1,!0,e,s-1,"C"===(o=r)?5:"Q"===o?3:1),i[`c_${s}_C_CP_2`]=s8(s,3,!0,e,s,5);break;case"Q":i[`c_${s}_Q_CP_1`]=s8(s,1,!0,e,s,3)}r=n}),i}var s9=l({changeHeight:()=>rr,changeObjectHeight:()=>re,changeObjectWidth:()=>rt,changeWidth:()=>ri,createObjectDefaultControls:()=>rD,createPathControls:()=>s6,createPolyActionHandler:()=>sZ,createPolyControls:()=>s0,createPolyPositionHandler:()=>sK,createResizeControls:()=>rM,createTextboxDefaultControls:()=>rP,dragHandler:()=>sq,factoryPolyActionHandler:()=>sQ,getLocalPoint:()=>eB,polyActionHandler:()=>sJ,renderCircleControl:()=>rs,renderSquareControl:()=>rn,rotationStyleHandler:()=>ra,rotationWithSnapping:()=>rl,scaleCursorStyleHandler:()=>rd,scaleOrSkewActionName:()=>rw,scaleSkewCursorStyleHandler:()=>rT,scalingEqually:()=>rf,scalingX:()=>rp,scalingXOrSkewingY:()=>rO,scalingY:()=>rm,scalingYOrSkewingX:()=>rk,skewCursorStyleHandler:()=>r_,skewHandlerX:()=>rC,skewHandlerY:()=>rb,wrapWithFireEvent:()=>i6,wrapWithFixedAnchor:()=>i9}),s7=class t extends ee{constructor(...t){super(...t),c(this,"_hoveredTargets",[]),c(this,"_currentTransform",null),c(this,"_groupSelector",null),c(this,"contextTopDirty",!1)}static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}get upperCanvasEl(){var t;return null==(t=this.elements.upper)?void 0:t.el}get contextTop(){var t;return null==(t=this.elements.upper)?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new sU(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){let t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter(e=>!e.group&&e!==t).concat(t):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(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){let t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;let e=this.getRetinaScaling(),i=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=i,this.pixelFindContext.scale(e,e)}
41isTargetTransparent(t,e,i){let r=this.targetFindTolerance,s=this.pixelFindContext;this.clearContext(s),s.save(),s.translate(-e+r,-i+r),s.transform(...this.viewportTransform);let n=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(s),t.selectionBackgroundColor=n,s.restore();let o=Math.round(r*this.getRetinaScaling());return rF(s,o,o,o)}_isSelectionKeyPressed(t){let e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(e=>!!e&&!0===t[e]):t[e])}_shouldClearSelection(t,e){let i=this.getActiveObjects(),r=this._activeObject;return!!(!e||e&&r&&i.length>1&&-1===i.indexOf(e)&&r!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&r&&r!==e)}_shouldCenterTransform(t,e,i){let r;if(t)return"scale"===e||"scaleX"===e||"scaleY"===e||"resizing"===e?r=this.centeredScaling||t.centeredScaling:"rotate"===e&&(r=this.centeredRotation||t.centeredRotation),r?!i:i}_getOriginFromCorner(t,e){let i=e?t.controls[e].getTransformAnchorPoint():{x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=L:["mr","tr","br"].includes(e)&&(i.x=j),["tl","mt","tr"].includes(e)?i.y=F:["bl","mb","br"].includes(e)&&(i.y="top")),i}_setupCurrentTransform(t,e,i){var r;let s=e.group?ef(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:n="",control:o}=e.getActiveControl()||{},a=i&&o?null==(r=o.getActionHandler(t,e,o))?void 0:r.bind(o):sq,l=((t,e,i,r)=>{if(!e||!t)return"drag";let s=r.controls[e];return s.getActionName(i,s,r)})(i,n,t,e),h=t[this.centeredKey],c=this._shouldCenterTransform(e,l,h)?{x:A,y:A}:this._getOriginFromCorner(e,n),{scaleX:u,scaleY:d,skewX:g,skewY:f,left:p,top:m,angle:y,width:v,height:_,cropX:x,cropY:C}=e,b={target:e,action:l,actionHandler:a,actionPerformed:!1,corner:n,scaleX:u,scaleY:d,skewX:g,skewY:f,offsetX:s.x-p,offsetY:s.y-m,originX:c.x,originY:c.y,ex:s.x,ey:s.y,lastX:s.x,lastY:s.y,theta:tS(y),width:v,height:_,shiftKey:t.shiftKey,altKey:h,original:{...eu(e),originX:c.x,originY:c.y,cropX:x,cropY:C}};this._currentTransform=b,this.fire("before:transform",{e:t,transform:b})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){let{x:e,y:i,deltaX:r,deltaY:s}=this._groupSelector,n=new tl(e,i).transform(this.viewportTransform),o=new tl(e+r,i+s).transform(this.viewportTransform),a=this.selectionLineWidth/2,l=Math.min(n.x,o.x),h=Math.min(n.y,o.y),c=Math.max(n.x,o.x),u=Math.max(n.y,o.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(l,h,c-l,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,l+=a,h+=a,c-=a,u-=a,rj.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(l,h,c-l,u-h))}findTarget(t){if(this._targetInfo)return this._targetInfo;if(this.skipTargetFind)return{subTargets:[],currentSubTargets:[]};let e=this.getScenePoint(t),i=this._activeObject,r=this.getActiveObjects(),s=this.searchPossibleTargets(this._objects,e),{subTargets:n,container:o,target:a}=s,l={...s,currentSubTargets:n,currentContainer:o,currentTarget:a};if(!i)return l;let h={...this.searchPossibleTargets([i],e),currentSubTargets:n,currentContainer:o,currentTarget:a};return i.findControl(this.getViewportPoint(t),es(t))?{...h,target:i}:h.target&&(r.length>1||!this.preserveObjectStacking||this.preserveObjectStacking&&t[this.altSelectionKey])?h:l}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords(),r=this.getZoom(),s=t.padding/r;if(s){let[t,e,r,n]=i,o=Math.atan2(e.y-t.y,e.x-t.x),a=to(o)*s,l=ta(o)*s,h=a+l,c=a-l;i=[new tl(t.x-c,t.y-h),new tl(e.x+h,e.y-c),new tl(r.x+c,r.y+h),new tl(n.x-h,n.y+c)]}return i5.isPointInPolygon(e,i)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,e)){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;{let i=e.transform(this.viewportTransform);
vendor: 4,763 bytes, line 41
41if(!this.isTargetTransparent(t,i.x,i.y))return!0}}return!1}_searchPossibleTargets(t,e,i){let r=t.length;for(;r--;){let s=t[r];if(this._checkTarget(s,e)){if(tc(s)&&s.subTargetCheck){let{target:t}=this._searchPossibleTargets(s._objects,e,i);t&&i.push(t)}return{target:s,subTargets:i}}}return{subTargets:[]}}searchPossibleTargets(t,e){let i=this._searchPossibleTargets(t,e,[]);i.container=i.target;let{container:r,subTargets:s}=i;if(r&&tc(r)&&r.interactive&&s[0]){for(let t=s.length-1;t>0;t--){let e=s[t];if(!tc(e)||!e.interactive)return i.target=e,i}return i.target=s[0],i}return i}getViewportPoint(t){return this._viewportPoint?this._viewportPoint:this._getPointerImpl(t,!0)}getScenePoint(t){return this._scenePoint?this._scenePoint:this._getPointerImpl(t)}_getPointerImpl(t,e=!1){let i=this.upperCanvasEl,r=i.getBoundingClientRect(),s=er(t),n=r.width||0,o=r.height||0;n&&o||("top"in r&&"bottom"in r&&(o=Math.abs(r.top-r.bottom)),"right"in r&&"left"in r&&(n=Math.abs(r.right-r.left))),this.calcOffset(),s.x-=this._offset.left,s.y-=this._offset.top,e||(s=ef(s,void 0,this.viewportTransform));let a=this.getRetinaScaling();1!==a&&(s.x/=a,s.y/=a);let l=0===n||0===o?new tl(1,1):new tl(i.width/n,i.height/o);return s.multiply(l)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=ty(),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 t=this._activeObject;return tK(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,r=!1,s=this.getActiveObjects(),n=[],o=[];t.forEach(t=>{s.includes(t)||(i=!0,t.fire("deselected",{e:e,target:t}),o.push(t))}),s.forEach(r=>{t.includes(r)||(i=!0,r.fire("selected",{e:e,target:r}),n.push(r))}),t.length>0&&s.length>0?(r=!0,i&&this.fire("selection:updated",{e:e,selected:n,deselected:o})):s.length>0?(r=!0,this.fire("selection:created",{e:e,selected:n})):t.length>0&&(r=!0,this.fire("selection:cleared",{e:e,deselected:o})),r&&(this._objectsToRender=void 0)}setActiveObject(t,e){let i=this.getActiveObjects(),r=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),r}_setActiveObject(t,e){let i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e:e})&&(this._activeObject=t,tK(t)&&i!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){let i=this._activeObject;return!!i&&!i.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===i&&this.endCurrentTransform(t),tK(i)&&i===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){let e=this.getActiveObjects(),i=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[i]});let r=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),r}endCurrentTransform(t){let e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){let e=this._currentTransform,i=e.target,r={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",r),i.fire(Z,r))}setViewportTransform(t){super.setViewportTransform(t);let e=this._activeObject;e&&e.setCoords()}destroy(){let t=this._activeObject;tK(t)&&(t.removeAll(),t.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(t){let e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,i){let r=this._realizeGroupTransformOnObject(t),s=super._toObject(t,e,i);return t.set(r),s}_realizeGroupTransformOnObject(t){let{group:e}=t;if(e&&tK(e)&&this._activeObject===e){let i=tV(t,["angle","flipX","flipY",j,N,U,q,K,"top"]);return el(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){let r=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(r)}};c(s7,"ownDefaults",{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,hoverCurs
41or:"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});var nt=class{constructor(t){c(this,"targets",[]),c(this,"__disposer",void 0);let e=()=>{let{hiddenTextarea:e}=t.getActiveObject()||{};e&&e.focus()},i=t.upperCanvasEl;i.addEventListener("click",e),this.__disposer=()=>i.removeEventListener("click",e)}exitTextEditing(){this.target=void 0,this.targets.forEach(t=>{t.isEditing&&t.exitEditing()})}add(t){this.targets.push(t)}remove(t){this.unregister(t),tn(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;null!=(e=this.target)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}};let ne={passive:!1},ni=(t,e)=>({viewportPoint:t.getViewportPoint(e),scenePoint:t.getScenePoint(e)}),nr=(t,...e)=>t.addEventListener(...e),ns=(t,...e)=>t.removeEventListener(...e),nn={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 no=class extends s7{constructor(t,e={}){super(t,e),c(this,"_isClick",void 0),c(this,"textEditingManager",new nt(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(t=>{this[t]=this[t].bind(this)}),this.addOrRemove(nr)}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e=!1){let i=this.upperCanvasEl,r=this._getEventPrefix();t(tZ(i),"resize",this._onResize),t(i,r+"down",this._onMouseDown),t(i,`${r}move`,this._onMouseMove,ne),t(i,`${r}out`,this._onMouseOut),t(i,`${r}enter`,this._onMouseEnter),t(i,"wheel",this._onMouseWheel,{passive:!1}),t(i,"contextmenu",this._onContextMenu),e||(t(i,"click",this._onClick),t(i,"dblclick",this._onClick)),t(i,"dragstart",this._onDragStart),t(i,"dragend",this._onDragEnd),t(i,"dragover",this._onDragOver),t(i,"dragenter",this._onDragEnter),t(i,"dragleave",this._onDragLeave),t(i,"drop",this._onDrop),this.enablePointerEvents||t(i,"touchstart",this._onTouchStart,ne)}removeListeners(){this.addOrRemove(ns);let t=this._getEventPrefix(),e=tQ(this.upperCanvasEl);ns(e,`${t}up`,this._onMouseUp),ns(e,"touchend",this._onTouchEnd,ne),ns(e,`${t}move`,this._onMouseMove,ne),ns(e,"touchmove",this._onMouseMove,ne),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_onMouseOut(t){let e=this._hoveredTarget,i={e:t,...ni(this,t)};this.fire("mouse:out",{...i,target:e}),this._hoveredTarget=void 0,e&&e.fire("mouseout",{...i}),this._hoveredTargets.forEach(t=>{this.fire("mouse:out",{...i,target:t}),t&&t.fire("mouseout",{...i})}),this._hoveredTargets=[]}_onMouseEnter(t){let{target:e}=this.findTarget(t);this._currentTransform||e||(this.fire("mouse:over",{e:t,...ni(this,t)}),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;let e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;let i={e:t,target:e};this.fire("dragstart",i),e.fire("dragstart",i),nr(this.upperCanvasEl,"drag",this._onDragProgress);return}en(t)}_renderDragEffects(t,e,i){let r=!1,s=this._dropTarget;s&&s!==e&&s!==i&&(s.clearContextTop(),r=!0),null==e||e.clearContextTop(),i!==e&&(null==i||i.clearContextTop());let n=this.contextTop;n.save(),n.transform(...this.viewportTransform),e&&(n.save(),e.transform(n),e.renderDragSourceEffect(t),n.restore(),r=!0),i&&(n.save(),i.transform(n),i.renderDropTargetEffect(t),n.restore(),r=!0),n.restore(),r&&(this.contextTopDirty=!0)}_onDragEnd(t){let{currentSubTargets:e}
41=this.findTarget(t),i=!!t.dataTransfer&&"none"!==t.dataTransfer.dropEffect,r=i?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:e,dragSource:this._dragSource,didDrop:i,dropTarget:r};ns(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",s),this._dragSource&&this._dragSource.fire("dragend",s),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){let e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}_onDragOver(t){let e="dragover",{currentContainer:i,currentSubTargets:r}=this.findTarget(t),s=this._dragSource,n={e:t,target:i,subTargets:r,dragSource:s,canDrop:!1,dropTarget:void 0},o;this.fire(e,n),this._fireEnterLeaveEvents(t,i,n),i&&(i.canDrop(t)&&(o=i),i.fire(e,n));for(let i=0;i<r.length;i++){let s=r[i];s.canDrop(t)&&(o=s),s.fire(e,n)}this._renderDragEffects(t,s,o),this._dropTarget=o}_onDragEnter(t){let{currentContainer:e,currentSubTargets:i}=this.findTarget(t),r={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",r),this._fireEnterLeaveEvents(t,e,r)}_onDragLeave(t){let{currentSubTargets:e}=this.findTarget(t),i={e:t,target:this._draggedoverTarget,subTargets:e,dragSource:this._dragSource};this.fire("dragleave",i),this._fireEnterLeaveEvents(t,void 0,i),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this._hoveredTargets=[]}_onDrop(t){let{currentContainer:e,currentSubTargets:i}=this.findTarget(t),r=this._basicEventHandler("drop:before",{e:t,target:e,subTargets:i,dragSource:this._dragSource,...ni(this,t)});r.didDrop=!1,r.dropTarget=void 0,this._basicEventHandler("drop",r),this.fire("drop:after",r)}_onContextMenu(t){let{target:e,subTargets:i}=this.findTarget(t),r=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&en(t),this._basicEventHandler("contextmenu",r),!1}_onClick(t){let e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),2==e&&"dblclick"===t.type&&this._handleEvent(t,"dblclick"),3==e&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}fireEventFromPointerEvent(t,e,i,r={}){this._cacheTransformEventData(t);let{target:s,subTargets:n}=this.findTarget(t),o={e:t,target:s,subTargets:n,...ni(this,t),transform:this._currentTransform,...r};this.fire(e,o),s&&s.fire(i,o);for(let t=0;t<n.length;t++)n[t]!==s&&n[t].fire(i,o);this._resetTransformEventData()}getPointerId(t){let e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){this._cacheTransformEventData(t);let e=!this.allowTouchScrolling,i=this._activeObject;void 0===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t);let{target:r}=this.findTarget(t);(this.isDrawingMode||i&&r===i)&&(e=!0),e&&t.preventDefault();let s=this.upperCanvasEl,n=this._getEventPrefix(),o=tQ(s);nr(o,"touchend",this._onTouchEnd,ne),e&&nr(o,"touchmove",this._onMouseMove,ne),ns(s,`${n}down`,this._onMouseDown),this._resetTransformEventData()}_onMouseDown(t){this._cacheTransformEventData(t),this.__onMouseDown(t);let e=this.upperCanvasEl,i=this._getEventPrefix();ns(e,`${i}move`,this._onMouseMove,ne);let r=tQ(e);nr(r,`${i}up`,this._onMouseUp),nr(r,`${i}move`,this._onMouseMove,ne),this._resetTransformEventData()}_onTouchEnd(t){if(t.touches.length>0)return;this._cacheTransformEventData(t),this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;let e=this._getEventPrefix(),i=tQ(this.upperCanvasEl);ns(i,"touchend",this._onTouchEnd,ne),ns(i,"touchmove",this._onMouseMove,ne),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{nr(this.upperCanvasEl,`${e}down`,this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this._cacheTransformEventData(t),this.__onMouseUp(t);let e=this.upperCanvasEl,i=this._getEventPrefix();if(this._isMainEvent(t)){let t=tQ(this.upperCanvasEl);ns(t,`${i}up`,this._onMouseUp),ns(t,`${i}move`,this._onMouseMove,ne),nr(e,`${i}move`,this._onMouseMove,ne)}this._resetTransformEventData()}_onMouseMove(t){this._cacheTransformEventData(t);let e=this.getActiveObject();this.allowTouchScrolling||e&&e.shouldStartDragging(t)||!t.preventDefault||t.preventDefault(),this.__onMouseMove(t),this._resetTransformEventData()}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){let e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._handleEvent(t,"up:before");
vendor: 5,368 bytes, line 41
41let i=this._currentTransform,r=this._isClick,{target:s}=this.findTarget(t),{button:n}=t;if(n)return void((this.fireMiddleClick&&1===n||this.fireRightClick&&2===n)&&this._handleEvent(t,"up"));if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let o,a,l=!1;if(i&&(this._finalizeCurrentTransform(t),l=i.actionPerformed),!r){let e=s===this._activeObject;this.handleSelection(t),l||(l=this._shouldRender(s)||!e&&s===this._activeObject)}if(s){let{key:e,control:r}=s.findControl(this.getViewportPoint(t),es(t))||{};if(a=e,s.selectable&&s!==this._activeObject&&"up"===s.activeOn)this.setActiveObject(s,t),l=!0;else if(r){let e=r.getMouseUpHandler(t,s,r);e&&(o=this.getScenePoint(t),e.call(r,t,i,o.x,o.y))}s.isMoving=!1}if(i&&(i.target!==s||i.corner!==a)){let e=i.target&&i.target.controls[i.corner],r=e&&e.getMouseUpHandler(t,i.target,e);o=o||this.getScenePoint(t),r&&r.call(e,t,i,o.x,o.y)}this._setCursorFromEvent(t,s),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,s&&(s.__corner=void 0),l?this.requestRenderAll():r||null!=(e=this._activeObject)&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){let{target:i,subTargets:r=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let s=0;s<r.length;s++)r[s]!==i&&r[s].fire(t,e);return e}_handleEvent(t,e,i){let{target:r,subTargets:s}=this.findTarget(t),n={e:t,target:r,subTargets:s,...ni(this,t),transform:this._currentTransform,..."down:before"===e||"down"===e?i:{}};"up:before"!==e&&"up"!==e||(n.isClick=this._isClick),this.fire(`mouse:${e}`,n),r&&r.fire(`mouse${e}`,n);for(let t=0;t<s.length;t++)s[t]!==r&&s[t].fire(`mouse${e}`,n)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());let e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){let e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){let e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._handleEvent(t,"down:before");let{target:e}=this.findTarget(t),i=!!e&&e===this._activeObject,{button:r}=t;if(r)return void((this.fireMiddleClick&&1===r||this.fireRightClick&&2===r)&&this._handleEvent(t,"down",{alreadySelected:i}));if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let s=this._shouldRender(e),n=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,n=!0,s=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){let e=this.getScenePoint(t);this._groupSelector={x:e.x,y:e.y,deltaY:0,deltaX:0}}if(i=!!e&&e===this._activeObject,e){e.selectable&&"down"===e.activeOn&&this.setActiveObject(e,t);let r=e.findControl(this.getViewportPoint(t),es(t));if(e===this._activeObject&&(r||!n)){this._setupCurrentTransform(t,e,i);let s=r?r.control:void 0,n=this.getScenePoint(t),o=s&&s.getMouseDownHandler(t,e,s);o&&o.call(s,t,this._currentTransform,n.x,n.y)}}s&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:i}),s&&this.requestRenderAll()}_resetTransformEventData(){this._targetInfo=this._viewportPoint=this._scenePoint=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._viewportPoint=this.getViewportPoint(t),this._scenePoint=ef(this._viewportPoint,void 0,this.viewportTransform),this._targetInfo=this.findTarget(t),this._currentTransform&&(this._targetInfo.target=this._currentTransform.target)}__onMouseMove(t){if(this._isClick=!1,this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;let e=this._groupSelector;if(e){let i=this.getScenePoint(t);e.deltaX=i.x-e.x,e.deltaY=i.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{let{target:e}=this.findTarget(t);this._setCursorFromEvent(t,e),this._fireOverOutEvents(t,e)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move")}_fireOverOutEvents(t,e){let{_hoveredTarget:i,_hoveredTargets:r}=this,{subTargets:s,currentTarget:n}=this.findTarget(t),o=Math.max(r.length,s.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,actualTarget:n,oldActualTarget:this._hoveredActualTarget,fireCanvas:!0});for(let n=0;n<o;n++)s[n]===e||r[n]&&r[n]===i||this.fireSyntheticInOutEvents("mouse",{e:t,target:s[n],oldTarget:r[n]});this._hoveredActualTarget=n,this._hoveredTarget=e,this._hoveredTargets=s}_fireEnterLeaveEvents(t,e,i){let r=this._draggedoverTarget,s=this._hoveredTargets,{subTargets:n}=this.findTarget(t),o=Math.max(s.length,n.length);this.fireSyntheticInOutEvents("drag",{...i,target:e,oldTarget:r,fireCanvas:!0});for(let t=0;t<o;t++)this.fireSyntheticInOutEvents("drag",{...i,target:n[t],oldTarget:s[t]});this._draggedoverTarget=e}fireSyntheticInOutEvents(t,{target:e,oldTarget:i,actualTarget:r,oldActualTarget:s,fireCanvas:n,e:o,...a}
41){let{targetIn:l,targetOut:h,canvasIn:c,canvasOut:u}=nn[t],d=i!==e,g=s!==r,f=e&&d,p=r&&g,m=i&&d,y=s&&g,v={...a,e:o,...ni(this,o)},_={...v,target:i,nextTarget:e,actualTarget:s,nextActualTarget:r};(m||y)&&n&&this.fire(u,_),m&&i.fire(h,_),y&&i!==s&&s.fire(h,_);let x={...v,target:e,previousTarget:i,actualTarget:r,previousActualTarget:s};(f||p)&&n&&this.fire(c,x),f&&e.fire(l,x),p&&r!==e&&r.fire(l,x)}_transformObject(t){let e=this.getScenePoint(t),i=this._currentTransform,r=i.target,s=r.group?ef(e,void 0,r.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,s),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){let{action:r,actionHandler:s,target:n}=e,o=!!s&&s(t,e,i.x,i.y);o&&n.setCoords(),"drag"===r&&o&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||o}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor,r=tK(this._activeObject)?this._activeObject:null,s=(!r||e.group!==r)&&e.findControl(this.getViewportPoint(t));if(s){let{control:i,coord:r}=s;this.setCursor(i.cursorStyleHandler(t,i,e,r))}else{if(e.subTargetCheck){let{subTargets:e}=this.findTarget(t);e.concat().reverse().forEach(t=>{i=t.hoverCursor||i})}this.setCursor(i)}}handleMultiSelection(t,e){let i=this._activeObject,r=tK(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||r)&&(r||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(r){let r=i.getObjects(),s=[];if(e===i){let i=this.getScenePoint(t),n=this.searchPossibleTargets(r,i);if(e=n.target?n.target:(n=this.searchPossibleTargets(this._objects,i)).target,s=n.subTargets,!e||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=s,1===i.size()&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=s),this._fireSelectionEvents(r,t)}else{i.isEditing&&i.exitEditing();let r=new(ti.getClass("ActiveSelection"))([],{canvas:this});r.multiSelectAdd(i,e),this._hoveredTarget=r,this._setActiveObject(r,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;let{x:e,y:i,deltaX:r,deltaY:s}=this._groupSelector,n=new tl(e,i),o=n.add(new tl(r,s)),a=n.min(o),l=n.max(o).subtract(a),h=this.collectObjects({left:a.x,top:a.y,width:l.x,height:l.y},{includeIntersecting:!this.selectionFullyContained}),c=n.eq(o)?h[0]?[h[0]]:[]:h.length>1?h.filter(e=>!e.onSelect({e:t})).reverse():h;if(1===c.length)this.setActiveObject(c[0],t);else if(c.length>1){let e=ti.getClass("ActiveSelection");this.setActiveObject(new e(c,{canvas:this}),t)}return this._groupSelector=null,!0}toCanvasElement(t=1,e){let{upper:i}=this.elements;i.ctx=void 0;let r=super.toCanvasElement(t,e);return i.ctx=i.el.getContext("2d"),r}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}};let na={x1:0,y1:0,x2:0,y2:0},nl={...na,r1:0,r2:0},nh=(t,e)=>isNaN(t)&&"number"==typeof e?e:t;function nc(t){return t&&/%$/.test(t)&&Number.isFinite(parseFloat(t))}function nu(t,e){return ic(0,nh("number"==typeof t?t:"string"==typeof t?parseFloat(t)/(nc(t)?100:1):NaN,e),1)}let nd=/\s*;\s*/,ng=/\s*:\s*/;function nf(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function np(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function nm(t,e){return t.getAttribute(e)}var ny=class{constructor(t){let{type:e="linear",gradientUnits:i="pixels",coords:r={},colorStops:s=[],offsetX:n=0,offsetY:o=0,gradientTransform:a,id:l}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:{..."radial"===e?nl:na,...r},colorStops:s,offsetX:n,offsetY:o,gradientTransform:a,id:l?`${l}_${tm()}`:tm()})}addColorStop(t){for(let e in t)this.colorStops.push({offset:parseFloat(e),color:t[e]});return this}
41toObject(t){return{...tV(this,t),type:this.type,coords:{...this.coords},colorStops:this.colorStops.map(t=>({...t})),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0}}toSVG(t,{additionalTransform:e}={}){let i=[],r=this.gradientTransform?this.gradientTransform.concat():E.concat(),s="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",n=this.colorStops.map(t=>({...t})).sort((t,e)=>t.offset-e.offset),o=-this.offsetX,a=-this.offsetY;"objectBoundingBox"===s?(o/=t.width,a/=t.height):(o+=t.width/2,a+=t.height/2),t&&"function"==typeof t._renderPathCommands&&"percentage"!==this.gradientUnits&&(o-=t.pathOffset.x,a-=t.pathOffset.y),r[4]-=o,r[5]-=a;let l=`id="SVGID_${t6(String(this.id))}" gradientUnits="${s}" gradientTransform="${e?e+" ":""}${tH(r)}" `,h=t=>parseFloat(String(t));if("linear"===this.type){let{x1:t,y1:e,x2:r,y2:s}=this.coords,n=h(t),o=h(e),a=h(r),c=h(s);i.push("<linearGradient ",l,' x1="',n,'" y1="',o,'" x2="',a,'" y2="',c,`"> 42`)}else if("radial"===this.type){let{x1:t,y1:e,x2:r,y2:s,r1:o,r2:a}=this.coords,c=h(t),u=h(e),d=h(r),g=h(s),f=h(o),p=h(a),m=f>p;i.push("<radialGradient ",l,' cx="',m?c:d,'" cy="',m?u:g,'" r="',m?f:p,'" fx="',m?d:c,'" fy="',m?g:u,`"> 43`),m&&(n.reverse(),n.forEach(t=>{t.offset=1-t.offset}));let y=Math.min(f,p);if(y>0){let t=y/Math.max(f,p);n.forEach(e=>{e.offset+=t*(1-e.offset)})}}return n.forEach(({color:t,offset:e})=>{i.push(`<stop offset="${100*e}%" style="stop-color:${t};"/> 44`)}),i.push("linear"===this.type?"</linearGradient>":"</radialGradient>",` 45`),i.join("")}toLive(t){let{x1:e,y1:i,x2:r,y2:s,r1:n,r2:o}=this.coords,a="linear"===this.type?t.createLinearGradient(e,i,r,s):t.createRadialGradient(e,i,n,r,s,o);return this.colorStops.forEach(({color:t,offset:e})=>{a.addColorStop(e,t)}),a}static async fromObject(t){let{colorStops:e,gradientTransform:i}=t;return new this({...t,colorStops:e?e.map(t=>({...t})):void 0,gradientTransform:i?[...i]:void 0})}static fromElement(t,e,i){var r;let s=np(t),n=e._findCenterFromElement();return new this({id:t.getAttribute("id")||void 0,type:nf(t),coords:(r={width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height},function(t,{width:e,height:i,gradientUnits:r}){let s;return Object.entries(t).reduce((t,[n,o])=>{if("Infinity"===o)s=1;else if("-Infinity"===o)s=0;else{let t="string"==typeof o;s=t?parseFloat(o):o,t&&nc(o)&&(s*=.01,"pixels"===r&&("x1"!==n&&"x2"!==n&&"r2"!==n||(s*=e),"y1"!==n&&"y2"!==n||(s*=i)))}return t[n]=s,t},{})}("linear"===nf(t)?{x1:nm(t,"x1")||0,y1:nm(t,"y1")||0,x2:nm(t,"x2")||"100%",y2:nm(t,"y2")||0}:{x1:nm(t,"fx")||nm(t,"cx")||"50%",y1:nm(t,"fy")||nm(t,"cy")||"50%",r1:0,x2:nm(t,"cx")||"50%",y2:nm(t,"cy")||"50%",r2:nm(t,"r")||"50%"},{...r,gradientUnits:np(t)})),colorStops:function(t,e){let i=[],r=t.getElementsByTagName("stop"),s=nu(e,1);for(let t=r.length;t--;)i.push(function(t,e){let i,r,s=t.getAttribute("style");if(s){let t=s.split(nd);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){let[s,n]=t[e].split(ng).map(t=>t.trim());"stop-color"===s?i=n:"stop-opacity"===s&&(r=n)}}i=i||t.getAttribute("stop-color")||"rgb(0,0,0)",r=nh(parseFloat(r||t.getAttribute("stop-opacity")||""),1);let n=new eG(i);return n.setAlpha(n.getAlpha()*r*e),{offset:nu(t.getAttribute("offset"),0),color:n.toRgba()}}(r[t],s));return i}(t,i.opacity),gradientUnits:s,gradientTransform:r4(t.getAttribute("gradientTransform")||""),..."pixels"===s?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}})}};c(ny,"type","Gradient"),ti.setClass(ny,"gradient"),ti.setClass(ny,"linear"),ti.setClass(ny,"radial");var nv=class{get type(){return"pattern"}set type(t){g("warn","Setting type has no effect",t)}constructor(t){c(this,"repeat","repeat"),c(this,"offsetX",0),c(this,"offsetY",0),c(this,"crossOrigin",""),this.id=tm(),Object.assign(this,t)}isImageSource(){return!!this.source&&"string"==typeof this.source.src}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&0!==this.source.naturalWi
45dth&&0!==this.source.naturalHeight)?t.createPattern(this.source,this.repeat):null}toObject(t=[]){let{repeat:e,crossOrigin:i}=this;return{...tV(this,t),type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:tz(this.offsetX,d.NUM_FRACTION_DIGITS),offsetY:tz(this.offsetY,d.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null}}toSVG({width:t,height:e}){let{source:i,repeat:r,id:s}=this,n=nh(this.offsetX/t,0),o=nh(this.offsetY/e,0),a="repeat-y"===r||"no-repeat"===r?1+Math.abs(n||0):nh(i.width/t,0),l="repeat-x"===r||"no-repeat"===r?1+Math.abs(o||0):nh(i.height/e,0);return[`<pattern id="SVGID_${t6(s)}" x="${n}" y="${o}" width="${a}" height="${l}">`,`<image x="0" y="0" width="${i.width}" height="${i.height}" xlink:href="${t6(this.sourceToString())}"></image>`,"</pattern>",""].join(` 46`)}static async fromObject({type:t,source:e,patternTransform:i,...r},s){let n=await tX(e,{...s,crossOrigin:r.crossOrigin});return new this({...r,patternTransform:i&&i.slice(0),source:n})}};c(nv,"type","Pattern"),ti.setClass(nv),ti.setClass(nv,"pattern");var n_=class{constructor(t){c(this,"color","rgb(0, 0, 0)"),c(this,"width",1),c(this,"shadow",null),c(this,"strokeLineCap","round"),c(this,"strokeLineJoin","round"),c(this,"strokeMiterLimit",10),c(this,"strokeDashArray",null),c(this,"limitedToCanvasSize",!1),this.canvas=t}_setBrushStyles(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])}_saveAndTransform(t){let e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}needsFullRender(){return 1>new eG(this.color).getAlpha()||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;let t=this.canvas,e=this.shadow,i=t.contextTop,r=t.getZoom()*t.getRetinaScaling();i.shadowColor=e.color,i.shadowBlur=e.blur*r,i.shadowOffsetX=e.offsetX*r,i.shadowOffsetY=e.offsetY*r}_resetShadow(){let t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}_isOutSideCanvas(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}},nx=class t extends rj{constructor(e,{path:i,left:r,top:s,...n}={}){super(),Object.assign(this,t.ownDefaults),this.setOptions(n),this._setPath(e||[],!0),"number"==typeof r&&this.set("left",r),"number"==typeof s&&this.set("top",s)}_setPath(t,e){this.path=sC(Array.isArray(t)?t:sR(t)),this.setBoundingBox(e)}_findCenterFromElement(){let t=this._calcBoundsFromPath();return new tl(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){let e=-this.pathOffset.x,i=-this.pathOffset.y;for(let r of(t.beginPath(),this.path))switch(r[0]){case"L":t.lineTo(r[1]+e,r[2]+i);break;case"M":t.moveTo(r[1]+e,r[2]+i);break;case"C":t.bezierCurveTo(r[1]+e,r[2]+i,r[3]+e,r[4]+i,r[5]+e,r[6]+i);break;case"Q":t.quadraticCurveTo(r[1]+e,r[2]+i,r[3]+e,r[4]+i);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return`#<Path (${this.complexity()}): { "top": ${this.top}, "left": ${this.left} }>`}toObject(t=[]){return{...super.toObject(t),path:this.path.map(t=>t.slice())}}toDatalessObject(t=[]){let e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){return["<path ","COMMON_PARTS",`d="${sW(this.path,d.NUM_FRACTION_DIGITS)}" stroke-linecap="round" /> 47`]}_getOffsetTransform(){let t=d.NUM_FRACTION_DIGITS;return` translate(${tz(-this.pathOffset.x,t)}, ${tz(-this.pathOffset.y,t)})`}toClipPathSVG(t){let e=this._getOffsetTransform();return` `+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){let e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){let{width:e,height:i,pathOffset:r}=this._calcDimensions();this.set({width:e,height:i,pathOffset:r}),t&&this.setPositionByOrigin(r,"center","center")}_calcBoundsFromPath(){let t=[],e=0,i=0,r=0,s=0;for(let n of this.path)switch(n[0]){case"L":r=n[1],s=n[2],t.push({x:e,y:i},{x:r,y:s});break;case"M":r=n[1],s=n[2],e=r,i=s;break;case"C":t.push(...s_(r,s,n[1],n[2],n[3],n[4],n[5],n[6])),r=n[5],s=n[6];break;
vendor: 12,251 bytes, lines 47-51
47case"Q":t.push(...s_(r,s,n[1],n[2],n[1],n[2],n[3],n[4])),r=n[3],s=n[4];break;case"Z":r=e,s=i}return eo(t)}_calcDimensions(){let t=this._calcBoundsFromPath();return{...t,pathOffset:new tl(t.left+t.width/2,t.top+t.height/2)}}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){let{d:r,...s}=r9(t,this.ATTRIBUTE_NAMES,i);return new this(r,{...s,...e,left:void 0,top:void 0})}};c(nx,"type","Path"),c(nx,"cacheProperties",[...id,"path","fillRule"]),c(nx,"ATTRIBUTE_NAMES",[...rG,"d"]),ti.setClass(nx),ti.setSVGClass(nx);var nC=class t extends n_{constructor(t){super(t),c(this,"decimate",.4),c(this,"drawStraightLine",!1),c(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(t,e,i){let r=e.midPointFrom(i);return t.quadraticCurveTo(e.x,e.y,r.x,r.y),r}onMouseDown(t,{e:e}){this.canvas._isMainEvent(e)&&(this.drawStraightLine=!!this.straightLineKey&&e[this.straightLineKey],this._prepareForDrawing(t),this._addPoint(t),this._render())}onMouseMove(e,{e:i}){if(this.canvas._isMainEvent(i)&&(this.drawStraightLine=!!this.straightLineKey&&i[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(e))&&this._addPoint(e)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{let e=this._points,i=e.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=t.drawSegment(r,e[i-2],e[i-1]),r.stroke(),r.restore()}}onMouseUp({e:t}){return!this.canvas._isMainEvent(t)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(t){this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)}_addPoint(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(e=this.canvas.contextTop){let i=this._points[0],r=this._points[1];if(this._saveAndTransform(e),e.beginPath(),2===this._points.length&&i.x===r.x&&i.y===r.y){let t=this.width/1e3;i.x-=t,r.x+=t}e.moveTo(i.x,i.y);for(let s=1;s<this._points.length;s++)t.drawSegment(e,i,r),i=this._points[s],r=this._points[s+1];e.lineTo(i.x,i.y),e.stroke(),e.restore()}convertPointsToSVGPath(t){return s$(t,this.width/1e3)}createPath(t){let e=new nx(t,{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,e.shadow=new ih(this.shadow)),e}decimatePoints(t,e){if(t.length<=2)return t;let i=t[0],r=(e/this.canvas.getZoom())**2,s=t.length-1,n=[i];for(let e=1;e<s-1;e++)(i.x-t[e].x)**2+(i.y-t[e].y)**2>=r&&n.push(i=t[e]);return n.push(t[s]),n}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));let t=this.convertPointsToSVGPath(this._points);if("M 0 0 Q 0 0 0 0 L 0 0"===sW(t))return void this.canvas.requestRenderAll();let e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}};let nb=["radius","startAngle","endAngle","counterClockwise"];var nS=class t extends rj{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e){super(),Object.assign(this,t.ownDefaults),this.setOptions(e)}_set(t,e){return super._set(t,e),"radius"===t&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,tS(this.startAngle),tS(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(N)}getRadiusY(){return this.get("radius")*this.get(U)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(t=[]){return super.toObject([...nb,...t])}_toSVG(){let{radius:t,startAngle:e,endAngle:i}=this,r=(i-e)%360;if(0===r)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',`${t6(t)}`,`" /> 48`];{let s=tS(e),n=tS(i),o=to(s)*t,a=ta(s)*t,l=to(n)*t,h=ta(n)*t;return[`<path d="M ${o} ${a} A ${t} ${t} 0 ${+(r>180)} ${+!this.counterClockwise} ${l} ${h}" `,"COMMON_PARTS",` /> 49`]}}static async fromElement(t,e,i){let{left:r=0,top:s=0,radius:n=0,...o}=r9(t,this.ATTRIBUTE_NAMES,i);return new this({...o,radius:n,left:r-n,top:s-n})}static fromObject(t){return super._fromObject(t)}};c(nS,"type","Circle"),c(nS,"cacheProperties",[...id,...nb]),c(nS,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),c(nS,"ATTRIBUTE_NAMES",["cx","cy","r",...rG]),ti.setClass(nS),ti.setSVGClass(nS);var nw=class extends n_{constructor(t){super(t),c(this,"width",10),this.points=[]}drawDot(t){let e=this.addPoint(t),i=this.canvas.contextTop;this._saveAndTransform(i),this.dot(i,e),i.restore()}dot(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()}onMouseDown(t){this.points=[],this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)}_render(){let t=this.canvas.contextTop,e=this.points;this._saveAndTransform(t);for(let i=0;i<e.length;i++)this.dot(t,e[i]);t.restore()}onMouseMove(t){!0===this.limitedToCanvasSize&&this._isOutSideCanvas(t)||(this.needsFullRender()?(this.canvas.clearContext(this.canvas.contextTop),this.addPoint(t),this._render()):this.drawDot(t))}onMouseUp(){let t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;let e=[];for(let t=0;t<this.points.length;t++){let i=this.points[t],r=new nS({radius:i.radius,left:i.x,top:i.y,originX:A,originY:A,fill:i.fill});this.shadow&&(r.shadow=new ih(this.shadow)),e.push(r)}let i=new sh(e,{canvas:this.canvas});this.canvas.fire("before:path:created",{path:i}),this.canvas.add(i),this.canvas.fire("path:created",{path:i}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=t,this.canvas.requestRenderAll()}addPoint({x:t,y:e}){let i={x:t,y:e,radius:sG(Math.max(0,this.width-20),this.width+20)/2,fill:new eG(this.color).setAlpha(sG(0,100)/100).toRgba()};return this.points.push(i),i}},nT=class extends n_{constructor(t){super(t),c(this,"width",10),c(this,"density",20),c(this,"dotWidth",1),c(this,"dotWidthVariance",1),c(this,"randomOpacity",!1),c(this,"optimizeOverlapping",!0),this.sprayChunks=[],this.sprayChunk=[]}onMouseDown(t){this.sprayChunks=[],this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.addSprayChunk(t),this.renderChunck(this.sprayChunk)}onMouseMove(t){!0===this.limitedToCanvasSize&&this._isOutSideCanvas(t)||(this.addSprayChunk(t),this.renderChunck(this.sprayChunk))}onMouseUp(){let t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=!1;let e=[];for(let t=0;t<this.sprayChunks.length;t++){let i=this.sprayChunks[t];for(let t=0;t<i.length;t++){let r=i[t],s=new st({width:r.width,height:r.width,left:r.x+1,top:r.y+1,originX:A,originY:A,fill:this.color});e.push(s)}}let i=new sh(this.optimizeOverlapping?function(t){let e={},i=[];for(let r,s=0;s<t.length;s++)e[r=`${t[s].left}${t[s].top}`]||(e[r]=!0,i.push(t[s]));return i}(e):e,{objectCaching:!0,subTargetCheck:!1,interactive:!1});this.shadow&&i.set("shadow",new ih(this.shadow)),this.canvas.fire("before:path:created",{path:i}),this.canvas.add(i),this.canvas.fire("path:created",{path:i}),this.canvas.clearContext(this.canvas.contextTop),this._resetShadow(),this.canvas.renderOnAddRemove=t,this.canvas.requestRenderAll()}renderChunck(t){let e=this.canvas.contextTop;e.fillStyle=this.color,this._saveAndTransform(e);for(let i=0;i<t.length;i++){let r=t[i];e.globalAlpha=r.opacity,e.fillRect(r.x,r.y,r.width,r.width)}e.restore()}_render(){let t=this.canvas.contextTop;t.fillStyle=this.color,this._saveAndTransform(t);for(let t=0;t<this.sprayChunks.length;t++)this.renderChunck(this.sprayChunks[t]);t.restore()}addSprayChunk(t){this.sprayChunk=[];let e=this.width/2;for(let i=0;i<this.density;i++)this.sprayChunk.push({x:sG(t.x-e,t.x+e),y:sG(t.y-e,t.y+e),width:this.dotWidthVariance?sG(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance):this.dotWidth,opacity:this.randomOpacity?sG(0,100)/100:1});this.sprayChunks.push(this.sprayChunk)}},nO=class extends nC{constructor(t){super(t)}getPatternSrc(){let t=ty(),e=t.getContext("2d");return t.width=t.height=25,e&&(e.fillStyle=this.color,e.beginPath(),e.arc(10,10,10,0,2*Math.PI,!1),e.closePath(),e.fill()),t}getPattern(t){return t.createPattern(this.source||this.getPatternSrc(),"repeat")}_setBrushStyles(t){super._setBrushStyles(t);let e=this.getPattern(t);e&&(t.strokeStyle=e)}createPath(t){let e=super.createPath(t),i=e._getLeftTopCoords().scalarAdd(e.strokeWidth/2);return e.stroke=new nv({source:this.source||this.getPatternSrc(),offsetX:-i.x,offsetY:-i.y}),e}};let nk=["x1","x2","y1","y2"];var nD=class t extends rj{constructor([e,i,r,s]=[0,0,0,0],n={}){super(),Object.assign(this,t.ownDefaults),this.setOptions(n),this.x1=e,this.x2=r,this.y1=i,this.y2=s,this._setWidthHeight();let{left:o,top:a}=n;"number"==typeof o&&this.set("left",o),"number"==typeof a&&this.set("top",a)}_setWidthHeight(){let{x1:t,y1:e,x2:i,y2:r}=this;this.width=Math.abs(i-t),this.height=Math.abs(r-e);let{left:s,top:n,width:o,height:a}=eo([{x:t,y:e},{x:i,y:r}]),l=new tl(s+o/2,n+a/2);this.setPositionByOrigin(l,A,A)}_set(t,e){return super._set(t,e),nk.includes(t)&&this._setWidthHeight(),this}_render(t){var e;t.beginPath();let i=this.calcLinePoints();t.moveTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineWidth=this.strokeWidth;let r=t.strokeStyle;tN(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=null==(e=this.stroke)?t.fillStyle:e,this.stroke&&this._renderStroke(t),t.strokeStyle=r}_findCenterFromElement(){return new tl((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(t=[]){return{...super.toObject(t),...this.calcLinePoints()}}_getNonTransformedDimensions(){let t=super._getNonTransformedDimensions();return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t}calcLinePoints(){let{x1:t,x2:e,y1:i,y2:r,width:s,height:n}=this,o=t<=e?-.5:.5,a=i<=r?-.5:.5;return{x1:o*s,x2:-(o*s),y1:a*n,y2:-(a*n)}}_toSVG(){let{x1:t,x2:e,y1:i,y2:r}=this.calcLinePoints();return["<line ","COMMON_PARTS",`x1="${t}" y1="${i}" x2="${e}" y2="${r}" /> 50`]}static async fromElement(t,e,i){let{x1:r=0,y1:s=0,x2:n=0,y2:o=0,...a}=r9(t,this.ATTRIBUTE_NAMES,i);return new this([r,s,n,o],a)}static fromObject({x1:t,y1:e,x2:i,y2:r,...s}){return this._fromObject({...s,points:[t,e,i,r]},{extraParam:"points"})}};c(nD,"type","Line"),c(nD,"cacheProperties",[...id,...nk]),c(nD,"ATTRIBUTE_NAMES",rG.concat(nk)),ti.setClass(nD),ti.setSVGClass(nD);var nM=class t extends rj{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e){super(),Object.assign(this,t.ownDefaults),this.setOptions(e)}_render(t){let e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,i),t.lineTo(0,-i),t.lineTo(e,i),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){let t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',`${-t} ${e},0 ${-e},${t} ${e}`,'" />']}};c(nM,"type","Triangle"),c(nM,"ownDefaults",{width:100,height:100}),ti.setClass(nM),ti.setSVGClass(nM);let nP=["rx","ry"];var nE=class t extends rj{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e){super(),Object.assign(this,t.ownDefaults),this.setOptions(e)}_set(t,e){switch(super._set(t,e),t){case"rx":this.rx=e,this.set("width",2*e);break;case"ry":this.ry=e,this.set("height",2*e)}return this}getRx(){return this.get("rx")*this.get(N)}getRy(){return this.get("ry")*this.get(U)}toObject(t=[]){return super.toObject([...nP,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",`cx="0" cy="0" rx="${t6(this.rx)}" ry="${t6(this.ry)}" /> 51`]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,M,!1),t.restore(
51),this._renderPaintInOrder(t)}static async fromElement(t,e,i){let r=r9(t,this.ATTRIBUTE_NAMES,i);return r.left=(r.left||0)-r.rx,r.top=(r.top||0)-r.ry,new this(r)}};c(nE,"type","Ellipse"),c(nE,"cacheProperties",[...id,...nP]),c(nE,"ownDefaults",{rx:0,ry:0}),c(nE,"ATTRIBUTE_NAMES",[...rG,"cx","cy","rx","ry"]),ti.setClass(nE),ti.setSVGClass(nE);let nA={exactBoundingBox:!1};var nj=class t extends rj{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e=[],i={}){super(),c(this,"strokeDiff",void 0),Object.assign(this,t.ownDefaults),this.setOptions(i),this.points=e;let{left:r,top:s}=i;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof r&&this.set("left",r),"number"==typeof s&&this.set("top",s)}isOpen(){return!0}_projectStrokeOnPoints(t){return r$(this.points,t,this.isOpen())}_calcDimensions(t){t={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,...t||{}};let e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(t=>t.projectedPoint):this.points;if(0===e.length)return{left:0,top:0,width:0,height:0,pathOffset:new tl,strokeOffset:new tl,strokeDiff:new tl};let i=eo(e),r=tR({...t,scaleX:1,scaleY:1}),s=eo(this.points.map(t=>tO(t,r,!0))),n=new tl(this.scaleX,this.scaleY),o=i.left+i.width/2,a=i.top+i.height/2;return this.exactBoundingBox&&(o-=a*Math.tan(tS(this.skewX)),a-=o*Math.tan(tS(this.skewY))),{...i,pathOffset:new tl(o,a),strokeOffset:new tl(s.left,s.top).subtract(new tl(i.left,i.top)).multiply(n),strokeDiff:new tl(i.width,i.height).subtract(new tl(s.width,s.height)).multiply(n)}}_findCenterFromElement(){let t=eo(this.points);return new tl(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){let{left:e,top:i,width:r,height:s,pathOffset:n,strokeOffset:o,strokeDiff:a}=this._calcDimensions();this.set({width:r,height:s,pathOffset:n,strokeOffset:o,strokeDiff:a}),t&&this.setPositionByOrigin(new tl(e+r/2,i+s/2),"center","center")}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new tl(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(t={}){if(this.exactBoundingBox){var e,i,r,s;let n;if(Object.keys(t).some(t=>this.strokeUniform||this.constructor.layoutProperties.includes(t))){let{width:r,height:s}=this._calcDimensions(t);n=new tl(null==(e=t.width)?r:e,null==(i=t.height)?s:i)}else n=new tl(null==(r=t.width)?this.width:r,null==(s=t.height)?this.height:s);return n.multiply(new tl(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){let i=this.initialized&&this[t]!==e,r=super._set(t,e);return this.exactBoundingBox&&i&&(("scaleX"===t||"scaleY"===t)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),r}toObject(t=[]){return{...super.toObject(t),points:this.points.map(({x:t,y:e})=>({x:t,y:e}))}}_toSVG(){let t=this.pathOffset.x,e=this.pathOffset.y,i=d.NUM_FRACTION_DIGITS,r=this.points.map(({x:r,y:s})=>`${tz(r-t,i)},${tz(s-e,i)}`).join(" ");return[`<${t6(this.constructor.type).toLowerCase()} `,"COMMON_PARTS",`points="${r}" /> 52`]}_render(t){let e=this.points.length,i=this.pathOffset.x,r=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-r);for(let s=0;s<e;s++){let e=this.points[s];t.lineTo(e.x-i,e.y-r)}this.isOpen()||t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){let r=function(t){if(!t)return[];let e=t.replace(/,/g," ").trim().split(/\s+/),i=[];for(let t=0;t<e.length;t+=2)i.push({x:parseFloat(e[t]),y:parseFloat(e[t+1])});return i}(t.getAttribute("points")),{left:s,top:n,...o}=r9(t,this.ATTRIBUTE_NAMES,i);return new this(r,{...o,...e})}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}};c(nj,"ownDefaults",nA),c(nj,"type","Polyline"),c(nj,"layoutProperties",[q,K,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),c(nj,"cac
52heProperties",[...id,"points"]),c(nj,"ATTRIBUTE_NAMES",[...rG]),ti.setClass(nj),ti.setSVGClass(nj);var nF=class extends nj{isOpen(){return!1}};c(nF,"ownDefaults",nA),c(nF,"type","Polygon"),ti.setClass(nF),ti.setSVGClass(nF);var nL=class extends rj{isEmptyStyles(t){if(!this.styles||void 0!==t&&!this.styles[t])return!0;let e=void 0===t?this.styles:{line:this.styles[t]};for(let t in e)for(let i in e[t])for(let r in e[t][i])return!1;return!0}styleHas(t,e){if(!this.styles||void 0!==e&&!this.styles[e])return!1;let i=void 0===e?this.styles:{0:this.styles[e]};for(let e in i)for(let r in i[e])if(void 0!==i[e][r][t])return!0;return!1}cleanStyle(t){if(!this.styles)return!1;let e=this.styles,i,r,s=0,n=!0,o=0;for(let o in e){for(let a in i=0,e[o]){let l=e[o][a]||{};s++,void 0===l[t]?n=!1:(r?l[t]!==r&&(n=!1):r=l[t],l[t]===this[t]&&delete l[t]),0===Object.keys(l).length?delete e[o][a]:i++}0===i&&delete e[o]}for(let t=0;t<this._textLines.length;t++)o+=this._textLines[t].length;n&&s===o&&(this[t]=r,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;let e=this.styles,i,r,s;for(r in e){for(s in i=e[r])delete i[s][t],0===Object.keys(i[s]).length&&delete i[s];0===Object.keys(i).length&&delete e[r]}}_extendStyles(t,e){let{lineIndex:i,charIndex:r}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);let s=tG({...this._getStyleDeclaration(i,r),...e},t=>void 0!==t);this._setStyleDeclaration(i,r,s)}getSelectionStyles(t,e,i){let r=[];for(let s=t;s<(e||t);s++)r.push(this.getStyleAtPosition(s,i));return r}getStyleAtPosition(t,e){let{lineIndex:i,charIndex:r}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,r):this._getStyleDeclaration(i,r)}setSelectionStyles(t,e,i){for(let r=e;r<(i||e);r++)this._extendStyles(r,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;let r=this.styles&&this.styles[t];return r&&null!=(i=r[e])?i:{}}getCompleteStyleDeclaration(t,e){return{...tV(this,this.constructor._styleProperties),...this._getStyleDeclaration(t,e)}}_setStyleDeclaration(t,e,i){this.styles[t][e]=i}_deleteStyleDeclaration(t,e){delete this.styles[t][e]}_getLineStyle(t){return!!this.styles[t]}_setLineStyle(t){this.styles[t]={}}_deleteLineStyle(t){delete this.styles[t]}};c(nL,"_styleProperties",e5);let nB=/ +/g,nI=/"/g;function nR(t,e,i,r,s){return` ${((t,{left:e,top:i,width:r,height:s},n=d.NUM_FRACTION_DIGITS)=>{let o=eU(J,t,!1),[a,l,h,c]=[e,i,r,s].map(t=>tz(t,n));return`<rect ${o} x="${a}" y="${l}" width="${h}" height="${c}"></rect>`})(t,{left:e,top:i,width:r,height:s})} 53`}var n$=class t extends nL{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e,i){super(),c(this,"__charBounds",[]),Object.assign(this,t.ownDefaults),this.setOptions(i),this.styles||(this.styles={}),this.text=e,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){let t=this.path;t&&(t.segmentsInfo=sA(t.path))}_splitText(){let t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}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 t,e,i,r,s,n,o;for(let a=0,l=this._textLines.length;a<l;a++)if(("justify"===this.textAlign||a!==l-1&&!this.isEndOfWrapping(a))&&(r=0,s=this._textLines[a],(e=this.getLineWidth(a))<this.width&&(o=this.textLines[a].match(this._reSpacesAndTabs)))){i=o.length,t=(this.width-e)/i;for(let e=0;e<=s.length;e++)n=this.__charBounds[a][e],this._reSpaceAndTab.test(s[e])?(n.width+=t,n.kernedWidth+=t,n.left+=r,r+=t):n.left+=r}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){let i=e?this._unwrappedTextLines:this._textLines,r;for(r=0;r<i.length;r++){if(t<=i[r].length)return{lineIndex:r,charIndex:t};t-=i[r].length+this.missingNewlineOffset(r,e)}return{lineIndex:r-1,charIndex:i[r-1].length<t?i[r-1].length:t}}toString(){return`#<Text (${this.complexity()}): { "text": "${this.text}", "fontFamily": "${this.fontFamily}" }>`}_getCacheCanvasDimensions(){let t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){let e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackgroun
53d(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){"stroke"===this.paintFirst?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,i){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case A:t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline=F}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){let i=this.getLineWidth(e);i>t&&(t=i)}return t}_renderTextLine(t,e,i,r,s,n){this._renderChars(t,e,i,r,s,n)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;let e=t.fillStyle,i=this._getLeftOffset(),r=this._getTopOffset();for(let e=0,s=this._textLines.length;e<s;e++){let s=this.getHeightOfLine(e);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",e)){r+=s;continue}let n=this._textLines[e].length,o=this._getLineLeftOffset(e),a,l,h=0,c=0,u=this.getValueOfPropertyAt(e,0,"textBackgroundColor"),d=this.getHeightOfLineImpl(e);for(let s=0;s<n;s++){let n=this.__charBounds[e][s];l=this.getValueOfPropertyAt(e,s,"textBackgroundColor"),this.path?(t.save(),t.translate(n.renderLeft,n.renderTop),t.rotate(n.angle),t.fillStyle=l,l&&t.fillRect(-n.width/2,-d*(1-this._fontSizeFraction),n.width,d),t.restore()):l===u?h+=n.kernedWidth:(a=i+o+c,"rtl"===this.direction&&(a=this.width-a-h),t.fillStyle=u,u&&t.fillRect(a,r,h,d),c=n.left,h=n.width,u=l)}l&&!this.path&&(a=i+o+c,"rtl"===this.direction&&(a=this.width-a-h),t.fillStyle=l,t.fillRect(a,r,h,d)),r+=s}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,r){let s=w.getFontCache(e),o=this._getFontDeclaration(e),a=i?i+t:t,l=i&&o===this._getFontDeclaration(r),h=e.fontSize/this.CACHE_FONT_SIZE,c,u,d,g;if(i&&s.has(i)&&(d=s.get(i)),s.has(t)&&(g=c=s.get(t)),l&&s.has(a)&&(g=(u=s.get(a))-d),void 0===c||void 0===d||void 0===u){let r=(n||(n=tx({width:0,height:0}).getContext("2d")),n);this._setTextStyles(r,e,!0),void 0===c&&(g=c=r.measureText(t).width,s.set(t,c)),void 0===d&&l&&i&&(d=r.measureText(i).width,s.set(i,d)),l&&void 0===u&&(u=r.measureText(a).width,s.set(a,u),g=u-d)}return{width:c*h,kernedWidth:g*h}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){let e=this._measureLine(t);return 0!==this.charSpacing&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,r=0,s=this.pathSide===L,n=this.path,o=this._textLines[t],a=o.length,l=Array(a);this.__charBounds[t]=l;for(let s=0;s<a;s++){let n=o[s];i=this._getGraphemeBox(n,t,s,e),l[s]=i,r+=i.kernedWidth,e=n}if(l[a]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},n&&n.segmentsInfo){let t=0,e=n.segmentsInfo[n.segmentsInfo.length-1].length;switch(this.textAlign){case j:t=s?e-r:0;break;case A:t=(e-r)/2;break;case L:t=s?0:e-r}t+=this.pathStartOffset*(s?-1:1);for(let r=s?a-1:0;s?r>=0:r<a;s?r--:r++)i=l[r],t>e?t%=e:t<0&&(t+=e),this._setGraphemeOnPath(t,i),t+=i.kernedWidth}return{width:r,numOfSpaces:0}}_setGraphemeOnPath(t,e){let i=t+e.kernedWidth/2,r=this.path,s=sj(r.path,i,r.segmentsInfo);e.renderLeft=s.x-r.pathOffset.x,e.renderTop=s.y-r.pathOffset.y,e.angle=s.angle+("right"===this.pathSide?Math.PI:0)}_getGraphemeBox(t,e,i,r,s){let n=this.getCompleteStyleDeclaration(e,i),o=r?this.getCompleteStyleDeclaration(e,i-1):{},a=this._measureChar(t,n,r,o),l,h=a.kernedWidth,c=a.width;0!==this.charSpacing&&(c+=l=this._getWidthOfCharSpacing(),h+=l);let u={width:c,left:0,height:n.fontSize,kernedWidth:h,deltaY:n.deltaY};if(i>0&&!s){let t=this.__charBounds[e][i-1];u.left=t.left+t.width+a.kernedWidth-a.width}return u}getHeightOfLineImpl(t){let e=this.__lineHeights;if(e[t])return e[t];let i=this.getHeightOfChar(t,0);for(let e=1,r=this._textLines[t].length;e<r;e++)i=Math.max(this.getHeightOfChar(t,e),i);return e[t]=i*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,i=this._textLines.length;e<i;e++)t+=e===i-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return"ltr"===this.direction?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let i=0,r=this._getLeftOffset(),s=this._getTopOffset();for(let n=0,o=this._textLines.length;n<o;n++)this._renderTextLine(e,t,this._textLines[n],r+this._getLineLeftOffset(n),s+i+this.getHeightOfLineImpl(n),n),i+=this.getHeightOfLine(n);
53t.restore()}_renderTextFill(t){(this.fill||this.styleHas("fill"))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&0!==this.strokeWidth||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,r,s,n){let o=this.textAlign.includes(e3),a=this.path,l=!o&&0===this.charSpacing&&this.isEmptyStyles(n)&&!a,h="ltr"===this.direction,c="ltr"===this.direction?1:-1,u=e.direction,d,g,f,p,m,y="",v=0;if(e.save(),u!==this.direction&&(e.canvas.setAttribute("dir",h?"ltr":"rtl"),e.direction=h?"ltr":"rtl",e.textAlign=h?j:L),s-=this.getHeightOfLineImpl(n)*this._fontSizeFraction,l)return this._renderChar(t,e,n,0,i.join(""),r,s),void e.restore();for(let l=0,h=i.length-1;l<=h;l++)p=l===h||this.charSpacing||a,y+=i[l],f=this.__charBounds[n][l],0===v?(r+=c*(f.kernedWidth-f.width),v+=f.width):v+=f.kernedWidth,o&&!p&&this._reSpaceAndTab.test(i[l])&&(p=!0),p||(p=rY(d=d||this.getCompleteStyleDeclaration(n,l),g=this.getCompleteStyleDeclaration(n,l+1),!1)),p&&(a?(e.save(),e.translate(f.renderLeft,f.renderTop),e.rotate(f.angle),this._renderChar(t,e,n,l,y,-v/2,0),e.restore()):(m=r,this._renderChar(t,e,n,l,y,m,s)),y="",d=g,r+=c*v,v=0);e.restore()}_applyPatternGradientTransformText(t){let e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,r=tx({width:e,height:i}),s=r.getContext("2d");return r.width=e,r.height=i,s.beginPath(),s.moveTo(0,0),s.lineTo(e,0),s.lineTo(e,i),s.lineTo(0,i),s.closePath(),s.translate(e/2,i/2),s.fillStyle=t.toLive(s),this._applyPatternGradientTransform(s,t),s.fill(),s.createPattern(r,"no-repeat")}handleFiller(t,e,i){let r,s;return tN(i)?"percentage"===i.gradientUnits||i.gradientTransform||i.patternTransform?(r=-this.width/2,s=-this.height/2,t.translate(r,s),t[e]=this._applyPatternGradientTransformText(i),{offsetX:r,offsetY:s}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,{stroke:e,strokeWidth:i}){return t.lineWidth=i,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",e)}_setFillStyles(t,{fill:e}){return this.handleFiller(t,"fillStyle",e)}_renderChar(t,e,i,r,s,n,o){let a=this._getStyleDeclaration(i,r),l=this.getCompleteStyleDeclaration(i,r),h="fillText"===t&&l.fill,c="strokeText"===t&&l.stroke&&l.strokeWidth;if(c||h){if(e.save(),e.font=this._getFontDeclaration(l),a.textBackgroundColor&&this._removeShadow(e),a.deltaY&&(o+=a.deltaY),h){let t=this._setFillStyles(e,l);e.fillText(s,n-t.offsetX,o-t.offsetY)}if(c){let t=this._setStrokeStyles(e,l);e.strokeText(s,n-t.offsetX,o-t.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){let r=this.get2DCursorLocation(t,!0),s=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,"fontSize"),n=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,"deltaY"),o={fontSize:s*i.size,deltaY:n+s*i.baseline};this.setSelectionStyles(o,t,e)}_getLineLeftOffset(t){let e=this.getLineWidth(t),i=this.width-e,r=this.textAlign,s=this.direction,n=this.isEndOfWrapping(t),o=0;return"justify"!==r&&("justify-center"!==r||n)&&("justify-right"!==r||n)&&("justify-left"!==r||n)?("center"===r&&(o=i/2),"right"===r&&(o=i),"justify-center"===r&&(o=i/2),"justify-right"===r&&(o=i),"rtl"===s&&("right"===r||"justify-right"===r?o=0:"left"===r||"justify-left"===r?o=-i:"center"!==r&&"justify-center"!==r||(o=-i/2)),o):0}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(void 0!==this.__lineWidths[t])return this.__lineWidths[t];let{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return 0===this.charSpacing?0:this.fontSize*this.charSpacing/1e3}getValueOfPropertyAt(t,e,i){var r;return null==(r=this._getStyleDeclaration(t,e)[i])?this[i]:r}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset(),r=this._getLeftOffset(),s=this.path,n=this._getWidthOfCharSpacing(),o="linethrough"===e?.5:+("overline"===e),a=this.offsets[e];for(let l=0,h=this._textLines.length;l<h;l++){let h=this.getHeightOfLine(l);if(!this[e]&&!this.styleHas(e,l)){i+=h;continue}let c=this._textLines[l],u=h/this.lineHeight,d=this._getLineLeftOffset(l),g=0,f=0,p=this.getValueOfPropertyAt(l,0,e),m=this.getValueOfPropertyAt(l,0,J),y=this.getValueOfPropertyAt(l,0,"textDecorationColor")||m,v=this.getValueOfPropertyAt(l,0,eJ),_=p,x=m,C=y,b=v,
53S=i+u*(1-this._fontSizeFraction),w=this.getHeightOfChar(l,0),T=this.getValueOfPropertyAt(l,0,"deltaY");for(let i=0,n=c.length;i<n;i++){let n=this.__charBounds[l][i];_=this.getValueOfPropertyAt(l,i,e),x=this.getValueOfPropertyAt(l,i,J),C=this.getValueOfPropertyAt(l,i,"textDecorationColor")||x,b=this.getValueOfPropertyAt(l,i,eJ);let h=this.getHeightOfChar(l,i),c=this.getValueOfPropertyAt(l,i,"deltaY");if(s&&_&&x){let e=this.fontSize*b/1e3;t.save(),t.fillStyle=C,t.translate(n.renderLeft,n.renderTop),t.rotate(n.angle),t.fillRect(-n.kernedWidth/2,a*h+c-o*e,n.kernedWidth,e),t.restore()}else if((_!==p||x!==m||C!==y||h!==w||b!==v||c!==T)&&f>0){let e=this.fontSize*v/1e3,i=r+d+g;"rtl"===this.direction&&(i=this.width-i-f),p&&y&&v&&(t.fillStyle=y,t.fillRect(i,S+a*w+T-o*e,f,e)),g=n.left,f=n.width,p=_,y=C,v=b,m=x,w=h,T=c}else f+=n.kernedWidth}let O=r+d+g;"rtl"===this.direction&&(O=this.width-O-f),t.fillStyle=C;let k=this.fontSize*b/1e3;_&&C&&b&&t.fillRect(O,S+a*w+T-o*k,f-n,k),i+=h}this._removeShadow(t)}_getFontDeclaration({fontFamily:e=this.fontFamily,fontStyle:i=this.fontStyle,fontWeight:r=this.fontWeight,fontSize:s=this.fontSize}={},n){let o=e.includes("'")||e.includes('"')||e.includes(",")||t.genericFonts.includes(e.toLowerCase())?e:`"${e}"`;return[i,r,`${n?this.CACHE_FONT_SIZE:s}px`,o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return t9(t)}_splitTextIntoLines(t){let e=t.split(this._reNewline),i=Array(e.length),r=[` 54`],s=[];for(let t=0;t<e.length;t++)i[t]=this.graphemeSplit(e[t]),s=s.concat(i[t],r);return s.pop(),{_unwrappedLines:i,lines:e,graphemeText:s,graphemeLines:i}}toObject(t=[]){return{...super.toObject([...e2,...t]),styles:rW(this.styles,this.text),...this.path?{path:this.path.toObject()}:{}}}set(t,e){let{textLayoutProperties:i}=this.constructor;super.set(t,e);let r=!1,s=!1;if("object"==typeof t)for(let e in t)"path"===e&&this.setPathInfo(),r=r||i.includes(e),s=s||"path"===e;else r=i.includes(t),s="path"===t;return s&&this.setPathInfo(),r&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(e,i,r){let s=r9(e,t.ATTRIBUTE_NAMES,r),{textAnchor:n=j,textDecoration:o="",dx:a=0,dy:l=0,top:h=0,left:c=0,fontSize:u=16,strokeWidth:d=1,...g}={...i,...s},f=new this(eI(e.textContent||"").trim(),{left:c+a,top:h+l,underline:o.includes("underline"),overline:o.includes("overline"),linethrough:o.includes("line-through"),strokeWidth:0,fontSize:u,...g}),p=f.getScaledHeight()/f.height,m=((f.height+f.strokeWidth)*f.lineHeight-f.height)*p,y=f.getScaledHeight()+m,v=0;return"center"===n&&(v=f.getScaledWidth()/2),"right"===n&&(v=f.getScaledWidth()),f.set({left:f.left-v,top:f.top-(y-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:d}),f}static fromObject(t){return this._fromObject({...t,styles:rV(t.styles||{},t.text)},{extraParam:"text"})}};c(n$,"textLayoutProperties",e1),c(n$,"cacheProperties",[...id,...e2]),c(n$,"ownDefaults",{_reNewline:I,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:tt,fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:j,fontStyle:tt,lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:j,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,[eJ]:66.667}),c(n$,"type","Text"),c(n$,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),c(n$,"ATTRIBUTE_NAMES",rG.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")),rA(n$,[class extends eq{_toSVG(){let t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(t){let e=this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0}
54),i=this.path;return i?e+i._createBaseSVGMarkup(i._toSVG(),{reviver:t,withShadow:!0,additionalTransform:tH(this.calcOwnMatrix())}):e}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg({textBgRects:t,textSpans:e}){let i=this.getSvgTextDecoration(this);return[t.join(""),` <text xml:space="preserve" `,`font-family="${t6(this.fontFamily.replace(nI,"'"))}" `,`font-size="${t6(this.fontSize)}" `,this.fontStyle?`font-style="${t6(this.fontStyle)}" `:"",this.fontWeight?`font-weight="${t6(this.fontWeight)}" `:"",i?`text-decoration="${i}" `:"","rtl"===this.direction?'direction="rtl" ':"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text> 55`]}_getSVGTextAndBg(t,e){let i=[],r=[],s,n=t;this.backgroundColor&&r.push(nR(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let t=0,o=this._textLines.length;t<o;t++)s=this._getLineLeftOffset(t),"rtl"===this.direction&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",t))&&this._setSVGTextLineBg(r,t,e+s,n),this._setSVGTextLineText(i,t,e+s,n),n+=this.getHeightOfLine(t);return{textSpans:i,textBgRects:r}}_createTextCharSpan(t,e,i,r,s){let n=d.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(e,t!==t.trim()||!!t.match(nB)),a=o?`style="${o}"`:"",l=e.deltaY,h=l?` dy="${tz(l,n)}" `:"",{angle:c,renderLeft:u,renderTop:g,width:f}=s,p="";if(void 0!==u){c&&(p=` rotate="${tz(tw(c),n)}"`);let t=tj({angle:tw(c)});t[4]=u,t[5]=g;let e=new tl(-(f/2),0).transform(t);i=e.x,r=e.y}return`<tspan x="${tz(i,n)}" y="${tz(r,n)}" ${h}${p}${a}>${t6(t)}</tspan>`}_setSVGTextLineText(t,e,i,r){let s=this.getHeightOfLine(e),n=this.textAlign.includes(e3),o=this._textLines[e],a,l,h,c,u,d="",g=0;r+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let s=0,f=o.length-1;s<=f;s++)u=s===f||this.charSpacing||this.path,d+=o[s],h=this.__charBounds[e][s],0===g?(i+=h.kernedWidth-h.width,g+=h.width):g+=h.kernedWidth,n&&!u&&this._reSpaceAndTab.test(o[s])&&(u=!0),u||(u=rY(a=a||this.getCompleteStyleDeclaration(e,s),l=this.getCompleteStyleDeclaration(e,s+1),!0)),u&&(c=this._getStyleDeclaration(e,s),t.push(this._createTextCharSpan(d,c,i,r,h)),d="",a=l,"rtl"===this.direction?i-=g:i+=g,g=0)}_setSVGTextLineBg(t,e,i,r){let s=this._textLines[e],n=this.getHeightOfLine(e)/this.lineHeight,o,a=0,l=0,h=this.getValueOfPropertyAt(e,0,"textBackgroundColor");for(let c=0;c<s.length;c++){let{left:s,width:u,kernedWidth:d}=this.__charBounds[e][c];(o=this.getValueOfPropertyAt(e,c,"textBackgroundColor"))===h?a+=d:(h&&t.push(nR(h,i+l,r,a,n)),l=s,a=u,h=o)}o&&t.push(nR(h,i+l,r,a,n))}getSvgStyles(t){let e=this.textDecorationColor?` text-decoration-color: ${t6(this[eQ])};`:"";return`${super.getSvgStyles(t)} text-decoration-thickness: ${tz(this.textDecorationThickness*this.getObjectScaling().y/10,d.NUM_FRACTION_DIGITS)}%;${e} white-space: pre;`}getSvgSpanStyles(t,e){let{fontFamily:i,strokeWidth:r,stroke:s,fill:n,fontSize:o,fontStyle:a,fontWeight:l,textDecorationThickness:h,textDecorationColor:c,linethrough:u,overline:g,underline:f}=t,p=this.getSvgTextDecoration({underline:null==f?this.underline:f,overline:null==g?this.overline:g,linethrough:null==u?this.linethrough:u}),m=h||this.textDecorationThickness,y=c||this.textDecorationColor;return[s?eU(Q,s):"",r?`stroke-width: ${t6(r)}; `:"",i?`font-family: ${i.includes("'")||i.includes('"')?t6(i):`'${t6(i)}'`}; `:"",o?`font-size: ${t6(o)}px; `:"",a?`font-style: ${t6(a)}; `:"",l?`font-weight: ${t6(l)}; `:"",p?`text-decoration: ${p}; text-decoration-thickness: ${tz(m*this.getObjectScaling().y/10,d.NUM_FRACTION_DIGITS)}%;${y?` text-decoration-color: ${t6(y)};`:""} `:"",n?eU(J,n):"",e?"white-space: pre; ":""].join("")}getSvgTextDecoration(t){return["overline","underline","line-through"].filter(e=>t[e.replace("-","")]).join(" ")}}]),ti.setClass(n$),ti.setSVGClass(n$);var nX=class{constructor(t){c(this,"target",void 0),c(this,"__mouseDownInPlace",!1),c(this,"__dragStartFired",!1),c(this,"__isDraggingOver",!1),c(this,"__dragStartSelection",void 0),c(this,"__dragImageDisposer",void 0),c(this,"_dispose",void 0),this.target=t;let e=[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=()=>{e.forEach(t=>t()),this._dispose=void 0}}isPointerOverSelection(t){let e=this.target,i=e.getSelectionStartFromPointer(t);return e.isEditing&&i>=e.selectionStart&&i<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){let e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,{selectionStart:e,selectionEnd:i}){var r;
55let s=this.target,n=s.canvas,o=new tl(s.flipX?-1:1,s.flipY?-1:1),a=s._getCursorBoundaries(e),l=new tl(a.left+a.leftOffset,a.top+a.topOffset).multiply(o).transform(s.calcTransformMatrix()),h=n.getScenePoint(t).subtract(l),c=s.getCanvasRetinaScaling(),u=s.getBoundingRect(),d=l.subtract(new tl(u.left,u.top)),g=n.viewportTransform,f=d.add(h).transform(g,!0),p=s.backgroundColor,m=rX(s.styles);s.backgroundColor="";let y={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};s.setSelectionStyles(y,0,e),s.setSelectionStyles(y,i,s.text.length),s.dirty=!0;let v=s.toCanvasElement({enableRetinaScaling:n.enableRetinaScaling,viewportTransform:!0});s.backgroundColor=p,s.styles=m,s.dirty=!0,sN(v,{position:"fixed",left:-v.width+"px",border:B,width:v.width/c+"px",height:v.height/c+"px"}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{v.remove()},tQ(t.target||this.target.hiddenTextarea).body.appendChild(v),null==(r=t.dataTransfer)||r.setDragImage(v,f.x,f.y)}onDragStart(t){this.__dragStartFired=!0;let e=this.target,i=this.isActive();if(i&&t.dataTransfer){let i=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},r=e._text.slice(i.selectionStart,i.selectionEnd).join(""),s={text:e.text,value:r,...i};t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,styles:e.getSelectionStyles(i.selectionStart,i.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,s)}return e.abortCursorAnimation(),i}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){let e=this.target.getSelectionStartFromPointer(t),i=this.__dragStartSelection;return e<i.selectionStart||e>i.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler({e:t}){let e=this.targetCanDrop(t);!this.__isDraggingOver&&e&&(this.__isDraggingOver=!0)}dragOverHandler(t){let{e:e}=t,i=this.targetCanDrop(e);!this.__isDraggingOver&&i?this.__isDraggingOver=!0:this.__isDraggingOver&&!i&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;let{e:i}=t,r=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let s=null==(e=i.dataTransfer)?void 0:e.getData("text/plain");if(s&&!r){let e=this.target,r=e.canvas,n=e.getSelectionStartFromPointer(i),{styles:o}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},a=s[Math.max(0,s.length-1)];if(this.__dragStartSelection){let t=this.__dragStartSelection.selectionStart,i=this.__dragStartSelection.selectionEnd;n>t&&n<=i?n=t:n>i&&(n-=i-t),e.removeChars(t,i),delete this.__dragStartSelection}e._reNewline.test(a)&&(e._reNewline.test(e._text[n])||n===e._text.length)&&(s=s.trimEnd()),t.didDrop=!0,t.dropTarget=e,e.insertChars(s,o,n),r.setActiveObject(e),e.enterEditing(i),e.selectionStart=Math.min(n+0,e._text.length),e.selectionEnd=Math.min(e.selectionStart+s.length,e._text.length),e.hiddenTextarea.value=e.text,e._updateTextarea(),e.hiddenTextarea.focus(),e.fire(z,{index:n+0,action:"drop"}),r.fire("text:changed",{target:e}),r.contextTopDirty=!0,r.requestRenderAll()}}dragEndHandler({e:t}){if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var e;let i=this.target,r=this.target.canvas,{selectionStart:s,selectionEnd:n}=this.__dragStartSelection,o=(null==(e=t.dataTransfer)?void 0:e.dropEffect)||"none";"none"===o?(i.selectionStart=s,i.selectionEnd=n,i._updateTextarea(),i.hiddenTextarea.focus()):(i.clearContextTop(),"move"===o&&(i.removeChars(s,n),i.selectionStart=i.selectionEnd=s,i.hiddenTextarea&&(i.hiddenTextarea.value=i.text),i._updateTextarea(),i.fire(z,{index:s,action:"dragend"}),r.fire("text:changed",{target:i}),r.requestRenderAll()),i.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}};
55let nY=/[ \n\.,;!\?\-]/;var nW=class extends n${constructor(...t){super(...t),c(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor({toValue:t,duration:e,delay:i,onComplete:r}){return i1({startValue:this._currentCursorOpacity,endValue:t,duration:e,delay:i,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:t=>{this._currentCursorOpacity=t,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;null==(t=this._currentTickCompleteState)||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.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(t){let e=0,i=t-1;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i--;for(;/\S/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findWordBoundaryRight(t){let e=0,i=t;if(this._reSpace.test(this._text[i]))for(;this._reSpace.test(this._text[i]);)e++,i++;for(;/\S/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}findLineBoundaryLeft(t){let e=0,i=t-1;for(;!/\n/.test(this._text[i])&&i>-1;)e++,i--;return t-e}findLineBoundaryRight(t){let e=0,i=t;for(;!/\n/.test(this._text[i])&&i<this._text.length;)e++,i++;return t+e}searchWordBoundary(t,e){let i=this._text,r=t>0&&this._reSpace.test(i[t])&&(-1===e||!I.test(i[t-1]))?t-1:t,s=i[r];for(;r>0&&r<i.length&&!nY.test(s);)r+=e,s=i[r];return -1===e&&nY.test(s)&&r++,r}selectWord(t){var e;t=null==(e=t)?this.selectionStart:e;let i=this.searchWordBoundary(t,-1),r=Math.max(i,this.searchWordBoundary(t,1));this.selectionStart=i,this.selectionEnd=r,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=null==(e=t)?this.selectionStart:e;let i=this.findLineBoundaryLeft(t),r=this.findLineBoundaryRight(t);this.selectionStart=i,this.selectionEnd=r,this._fireSelectionChanged(),this._updateTextarea()}enterEditing(t){!this.isEditing&&this.editable&&(this.enterEditingImpl(),this.fire("editing:entered",t?{e:t}:void 0),this._fireSelectionChanged(),this.canvas&&(this.canvas.fire("text:editing:entered",{target:this,e:t}),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(t){if(this.getActiveControl())return;let e=this.hiddenTextarea;tQ(e).activeElement!==e&&e.focus();let i=this.getSelectionStartFromPointer(t),r=this.selectionStart,s=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&r!==s||r!==i&&s!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===r&&this.selectionEnd===s||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}
vendor: 12,182 bytes, lines 55-56
55_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(t,e,i){let r=i.slice(0,t),s=this.graphemeSplit(r).length;if(t===e)return{selectionStart:s,selectionEnd:s};let n=i.slice(t,e);return{selectionStart:s,selectionEnd:s+this.graphemeSplit(n).length}}fromGraphemeToStringSelection(t,e,i){let r=i.slice(0,t).join("").length;return t===e?{selectionStart:r,selectionEnd:r}:{selectionStart:r,selectionEnd:r+i.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){let t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){let{hiddenTextarea:t,direction:e,textAlign:i,inCompositionMode:r}=this;if(!t)return;let s="justify"===i?"ltr"===e?j:L:i.replace("justify-",""),n=this.getPositionByOrigin(s,"top");this.cursorOffsetCache={},this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setPositionByOrigin(n,s,"top"),this.setCoords();let o=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=o.selectionEnd,r||(this.selectionStart=o.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){let t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};let t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),i=this.get2DCursorLocation(t),r=i.lineIndex,s=i.charIndex,n=this.getValueOfPropertyAt(r,s,"fontSize")*this.lineHeight,o=e.leftOffset,a=this.getCanvasRetinaScaling(),l=this.canvas.upperCanvasEl,h=l.width/a,c=l.height/a,u=h-n,d=c-n,g=new tl(e.left+o,e.top+e.topOffset+n).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new tl(l.clientWidth/h,l.clientHeight/c));return g.x<0&&(g.x=0),g.x>u&&(g.x=u),g.y<0&&(g.y=0),g.y>d&&(g.y=d),g.x+=this.canvas._offset.left,g.y+=this.canvas._offset.top,{left:`${g.x}px`,top:`${g.y}px`,fontSize:`${n}px`,charHeight:n}}_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 t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),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 t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire("modified"),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(let t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){let{lineIndex:i,charIndex:r}=this.get2DCursorLocation(t,!0),{lineIndex:s,charIndex:n}=this.get2DCursorLocation(e,!0);if(i!==s){if(this.styles[i])for(let t=r;t<this._unwrappedTextLines[i].length;t++)delete this.styles[i][t];if(this.styles[s])for(let t=n;t<this._unwrappedTextLines[s].length;t++){let e=this.styles[s][t];e&&(this.styles[i]||(this.styles[i]={}),this.styles[i][r+t-n]=e)}for(let t=i+1;t<=s;t++)delete this.styles[t];this.shiftLineStyles(s,i-s)}else if(this.styles[i]){let t=this.styles[i],e=n-r;for(let e=r;e<n;e++)delete t[e];for(let r in this.styles[i]){let i=parseInt(r,10);i>=n&&(t[i-e]=t[r],delete t[r])}}}shiftLineStyles(t,e){let i=Object.assign({},this.styles);for(let r in this.styles){let s=parseInt(r,10);s>t&&(this.styles[s+e]=i[s],i[s-e]||delete this.styles[s])}}insertNewlineStyleObject(t,e,i,r){let s={},n=this._unwrappedTextLines[t].length,o=n===e,a=!1;i||(i=1),this.shiftLineStyles(t,i);let l=this.styles[t]?this.styles[t][0===e?e:e-1]:void 0;for(let i in this.styles[t]){let r=parseInt(i,10);r>=e&&(a=!0,s[r-e]=this.styles[t][i],o&&0===e||delete this.styles[t][i])}let h=!1;for(a&&!o&&(this.styles[t+i]=s,h=!0),(h||n>e)&&i--;i>0;)r&&r[i-1]?this.styles[t+i]={0:{...r[i-1]}}:l?this.styles[t+i]={0:{...l}}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,r){this.styles||(this.styles={});let s=this.styles[t],n=s?{...s}:{};for(let t in i||(i=1),n){let r=parseInt(t,10);r>=e&&(s[r+i]=n[r],n[r-i]||delete s[r])}if(this._forceClearCache=!0,r){for(;i--;)Object.keys(r[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]={...r[i]});return}if(!s)return;let o=s[e?e-1:1];for(;o&&i--;)this.styles[t][e+i]={...o}}insertNewStyleBlock(t,e,i){let r=this.get2DCursorLocation(e,!0),s=[0],n,o=0;for(let e=0;e<t.length;e++)t[e]===` 56`?s[++o]=0:s[o]++;for(s[0]>0&&(this.insertCharStyleObject(r.lineIndex,r.charIndex,s[0],i),i=i&&i.slice(s[0]+1)),o&&this.insertNewlineStyleObject(r.lineIndex,r.charIndex+s[0],o),n=1;n<o;n++)s[n]>0?this.insertCharStyleObject(r.lineIndex+n,0,s[n],i):i&&this.styles[r.lineIndex+n]&&i[0]&&(this.styles[r.lineIndex+n][0]=i[0]),i=i&&i.slice(s[n]+1);s[n]>0&&this.insertCharStyleObject(r.lineIndex+n,0,s[n],i)}removeChars(t,e=t+1){this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i,r=i){r>i&&this.removeStyleFromTo(i,r);let s=this.graphemeSplit(t);this.insertNewStyleBlock(s,i,e),this._text=[...this._text.slice(0,i),...s,...this._text.slice(r)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,i){i<=t?(e===t?this._selectionDirection=j:"right"===this._selectionDirection&&(this._selectionDirection=j,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?"right"===this._selectionDirection?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=L:"left"===this._selectionDirection&&(this._selectionDirection=L,this.selectionStart=e),this.selectionEnd=i)}},nV=class extends nW{initHiddenTextarea(){let t=this.canvas&&tQ(this.canvas.getElement())||C(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map(([t,i])=>e.setAttribute(t,i));let{top:i,left:r,fontSize:s}=this._calcTextareaPosition();e.style.cssText=`position: absolute; top: ${i}; left: ${r}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${s};`,(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map(([t,i])=>e.addEventListener(t,this[i].bind(this))),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;let e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){let e=this.fromPaste,{value:i,selectionStart:r,selectionEnd:s}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;let n=()=>{this.updateFromTextArea(),this.fire(z),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void n();let o=this._splitTextIntoLines(i).graphemeText,a=this._text.length,l=o.length,h=this.selectionStart,c=this.selectionEnd,u=h!==c,g,f,p,m,y=l-a,v=this.fromStringToGraphemeSelection(r,s,i),_=h>v.selectionStart;u?(f=this._text.slice(h,c),y+=c-h):l<a&&(f=_?this._text.slice(c+y,c):this._text.slice(h,h-y));let C=o.slice(v.selectionEnd-y,v.selectionEnd);if(f&&f.length&&(C.length&&(g=this.getSelectionStyles(h,h+1,!1),g=C.map(()=>g[0])),u?(p=h,m=c):_?(p=c-f.length,m=c):(p=c,m=c+f.length),this.removeStyleFromTo(p,m)),C.length){let{copyPasteData:t}=x();e&&C.join("")===t.copiedText&&!d.disableStyleCopyPaste&&(g=t.copiedTextStyle),this.insertNewStyleBlock(C,h,g)}n()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate({target:t}){let{selectionStart:e,selectionEnd:i}=t;this.compositionStart=e,this.compositionEnd=i,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;let{copyPasteData:t}=x();t.copiedText=this.getSelectedText(),d.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let i,r=this._getLineLeftOffset(t);return e>0&&(r+=(i=this.__charBounds[t][e-1]).left+i.width),r}getDownCursorOffset(t,e){let i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),s=r.lineIndex;if(s===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-i;let n=r.charIndex,o=this._getWidthBeforeCursor(s,n),a=this._getIndexOnLine(s+1,o);return this._textLines[s].slice(n).length+a+1+this.missingNewlineOffset(s)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){let i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),s=r.lineIndex;if(0===s||t.metaKey||33===t.keyCode)return-i;let n=r.charIndex,o=this._getWidthBeforeCursor(s,n),a=this._getIndexOnLine(s-1,o),l=this._textLines[s].slice(0,n),h=this.missingNewlineOffset(s-1);return-this._textLines[s-1].length+a-l.length+(1-h)}_getIndexOnLine(t,e){let i=this._textLines[t],r,s,n=this._getLineLeftOffset(t),o=0;for(let a=0,l=i.length;a<l;a++)if((n+=r=this.__charBounds[t][a].width)>e){s=!0;let t=Math.abs(n-r-e);o=Math.abs(n-e)<t?a:a-1;break}return s||(o=i.length-1),o}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){let i=this[`get${t}CursorOffset`](e,this._selectionDirection===L);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),0!==i){let t=this.text.length;this.selectionStart=ic(0,this.selectionStart,t),this.selectionEnd=ic(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}
56moveCursorWithShift(t){let e="left"===this._selectionDirection?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t}moveCursorLeft(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let r;if(t.altKey)r=this[`findWordBoundary${i}`](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===i?-1:1,!0;r=this[`findLineBoundary${i}`](this[e])}return void 0!==r&&this[e]!==r&&(this[e]=r,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=j,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return"right"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0===this.selectionStart?void 0:(this._selectionDirection=j,this._moveLeft(t,"selectionStart"))}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){let i=`moveCursor${t}${e.shiftKey?"WithShift":"WithoutShift"}`;this._currentCursorOpacity=1,this[i](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return"left"===this._selectionDirection&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd===this._text.length?void 0:(this._selectionDirection=L,this._moveRight(t,"selectionEnd"))}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=L,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}};let nG=t=>!!t.button;var nz=class extends nV{constructor(...t){super(...t),c(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 nX(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}doubleClickHandler(t){this.isEditing&&(this.selectWord(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}tripleClickHandler(t){this.isEditing&&(this.selectLine(this.getSelectionStartFromPointer(t.e)),this.renderCursorOrSelection())}_mouseDownHandler({e:t,alreadySelected:e}){this.canvas&&this.editable&&!nG(t)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(t)||(this.canvas.textEditingManager.register(this),e&&(this.inCompositionMode=!1,this.setCursorByClick(t)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=e||this.isEditing)))}mouseUpHandler({e:t,transform:e}){let i=this.draggableTextDelegate.end(t);if(this.canvas){this.canvas.textEditingManager.unregister(this);let t=this.canvas._activeObject;if(t&&t!==this)return}!this.editable||this.group&&!this.group.interactive||e&&e.actionPerformed||nG(t)||i||this.selected&&!this.getActiveControl()&&(this.enterEditing(t),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){let e=this.getSelectionStartFromPointer(t),i=this.selectionStart,r=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,r,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){let e=this.canvas.getScenePoint(t).transform(tk(this.calcTransformMatrix())).add(new tl
56(-this._getLeftOffset(),-this._getTopOffset())),i=0,r=0,s=0;for(let t=0;t<this._textLines.length&&i<=e.y;t++)i+=this.getHeightOfLine(t),s=t,t>0&&(r+=this._textLines[t-1].length+this.missingNewlineOffset(t-1));let n=Math.abs(this._getLineLeftOffset(s)),o=this._textLines[s].length,a=this.__charBounds[s];for(let t=0;t<o;t++){let i=n+a[t].kernedWidth;if(e.x<=i){Math.abs(e.x-i)<=Math.abs(e.x-n)&&r++;break}n=i,r++}return Math.min(this.flipX?o-r:r,this._text.length)}};let nH="moveCursorUp",nN="moveCursorDown",nU="moveCursorLeft",nq="moveCursorRight",nK="exitEditing",nJ=(t,e)=>{let i=e.getRetinaScaling();t.setTransform(i,0,0,i,0,0);let r=e.viewportTransform;t.transform(r[0],r[1],r[2],r[3],r[4],r[5])};var nQ=class t extends nz{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}get type(){let t=super.type;return"itext"===t?"i-text":t}constructor(e,i){super(e,{...t.ownDefaults,...i}),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):("canvas"===t&&(this.canvas instanceof no&&this.canvas.textEditingManager.remove(this),e instanceof no&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),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(t=this.selectionStart||0,e=this.selectionEnd,i){return super.getSelectionStyles(t,e,i)}setSelectionStyles(t,e=this.selectionStart||0,i=this.selectionEnd){return super.setSelectionStyles(t,e,i)}get2DCursorLocation(t=this.selectionStart,e){return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){let e=this.isEditing;this.isEditing=!1;let i=super.toCanvasElement(t);return this.isEditing=e,i}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;let t=this.clearContextTop(!0);if(!t)return;let e=this._getCursorBoundaries(),i=this.findAncestorsWithClipPath(),r=i.length>0,s,n=t;if(r){nJ(n=(s=tx(t.canvas)).getContext("2d"),this.canvas);let e=this.calcTransformMatrix();n.transform(e[0],e[1],e[2],e[3],e[4],e[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(n,e):this.renderCursor(n,e),r)for(let e of i){let i=e.clipPath,r=tx(t.canvas),s=r.getContext("2d");if(nJ(s,this.canvas),!i.absolutePositioned){let t=e.calcTransformMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5])}i.transform(s),i.drawObject(s,!0,{}),this.drawClipPathOnCache(n,i,r)}r&&(t.setTransform(1,0,0,1,0,0),t.drawImage(s,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){let t=[],e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(t=this.selectionStart,e){let i=this._getLeftOffset(),r=this._getTopOffset(),s=this._getCursorBoundariesOffsets(t,e);return{left:i,top:r,leftOffset:s.left,topOffset:s.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,i=0,{charIndex:r,lineIndex:s}=this.get2DCursorLocation(t),{textAlign:n,direction:o}=this;for(let t=0;t<s;t++)e+=this.getHeightOfLine(t);let a=this._getLineLeftOffset(s),l=this.__charBounds[s][r];l&&(i=l.left),0!==this.charSpacing&&r===this._textLines[s].length&&(i-=this._getWidthOfCharSpacing());let h=a+(i>0?i:0);return"rtl"===o&&("right"===n||"justify"===n||"justify-right"===n?h*=-1:"left"===n||"justify-left"===n?h=a-(i>0?i:0):"center"!==n&&"justify-center"!==n||(h=a-(i>0?i:0))),{top:e,left:h}}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(t=this.selectionStart,e=this._getCursorBoundaries(t)){let i=this.get2DCursorLocation(t),r=i.lineIndex,s=i.charIndex>0?i.charIndex-1:0,n=this.getValueOfPropertyAt(r,s,"fontSize"),o=this.getObjectScaling().x*this.canvas.getZoom(),a=this.cursorWidth/o,l=this.getValueOfPropertyAt(r,s,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(r)/this.lineHeight-n*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(r,s,"fill"),op
56acity:this._currentCursorOpacity,left:e.left+e.leftOffset-a/2,top:h+e.top+l,width:a,height:n}}_renderCursor(t,e,i){let{color:r,opacity:s,left:n,top:o,width:a,height:l}=this.getCursorRenderingData(i,e);t.fillStyle=r,t.globalAlpha=s,t.fillRect(n,o,a,l)}renderSelection(t,e){let i={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,i,e)}renderDragSourceEffect(){let t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){let e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,i){let{textAlign:r,direction:s}=this,n=e.selectionStart,o=e.selectionEnd,a=r.includes(e3),l=this.get2DCursorLocation(n),h=this.get2DCursorLocation(o),c=l.lineIndex,u=h.lineIndex,d=l.charIndex<0?0:l.charIndex,g=h.charIndex<0?0:h.charIndex;for(let e=c;e<=u;e++){let n=this._getLineLeftOffset(e)||0,o=this.getHeightOfLine(e),l=0,h=0,f=0;if(e===c&&(h=this.__charBounds[c][d].left),e>=c&&e<u)f=a&&!this.isEndOfWrapping(e)?this.width:this.getLineWidth(e)||5;else if(e===u)if(0===g)f=this.__charBounds[u][g].left;else{let t=this._getWidthOfCharSpacing();f=this.__charBounds[u][g-1].left+this.__charBounds[u][g-1].width-t}l=o,(this.lineHeight<1||e===u&&this.lineHeight>1)&&(o/=this.lineHeight);let p=i.left+n+h,m=o,y=0,v=f-h;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",m=1,y=o):t.fillStyle=this.selectionColor,"rtl"===s&&("right"===r||"justify"===r||"justify-right"===r?p=this.width-p-v:"left"===r||"justify-left"===r?p=i.left+n-f:"center"!==r&&"justify-center"!==r||(p=i.left+n-f)),t.fillRect(p,i.top+i.topOffset+y,v,m),i.topOffset+=l}}getCurrentCharFontSize(){let t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){let t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,J)}_getCurrentCharIndex(){let t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}};c(nQ,"ownDefaults",{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:{9:nK,27:nK,33:nH,34:nN,35:nq,36:nU,37:nU,38:nH,39:nq,40:nN},keysMapRtl:{9:nK,27:nK,33:nH,34:nN,35:nU,36:nq,37:nq,38:nH,39:nU,40:nN},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"},_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1}),c(nQ,"type","IText"),ti.setClass(nQ),ti.setClass(nQ,"i-text");var nZ=class t extends nQ{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e,i){super(e,{...t.ownDefaults,...i})}static createControls(){return{controls:rP()}}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(t){let e=0,i=0,r=0,s={};for(let n=0;n<t.graphemeLines.length;n++)t.graphemeText[r]===` 57`&&n>0?(i=0,r++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[r])&&n>0&&(i++,r++),s[n]={line:e,offset:i},r+=t.graphemeLines[n].length,i+=t.graphemeLines[n].length;return s}styleHas(t,e){if(this._styleMap&&!this.isWrapping){let t=this._styleMap[e];t&&(e=t.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,r=t+1,s=!1,n=this._styleMap[t],o=this._styleMap[t+1];n&&(t=n.line,i=n.offset),o&&(s=o.line===t,e=o.offset);let a=void 0===t?this.styles:{line:this.styles[t]};for(let t in a)for(let r in a[t]){let n=parseInt(r,10);if(n>=i&&(!s||n<e))for(let e in a[t][r])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){let i=this._styleMap[t];if(!i)return{};t=i.line,e=i.offset+e}return super._getStyleDeclaration(t,e)}
vendor: 2,335 bytes, line 57
57_setStyleDeclaration(t,e,i){let r=this._styleMap[t];super._setStyleDeclaration(r.line,r.offset+e,i)}_deleteStyleDeclaration(t,e){let i=this._styleMap[t];super._deleteStyleDeclaration(i.line,i.offset+e)}_getLineStyle(t){let e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){let e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;let i=this.getGraphemeDataForRender(t),r=[];for(let t=0;t<i.wordsData.length;t++)r.push(...this._wrapLine(t,e,i));return this.isWrapping=!1,r}getGraphemeDataForRender(t){let e=this.splitByGrapheme,i=e?"":" ",r=0;return{wordsData:t.map((t,s)=>{let n=0,o=e?this.graphemeSplit(t):this.wordSplit(t);return 0===o.length?[{word:[],width:0}]:o.map(t=>{let o=e?[t]:this.graphemeSplit(t),a=this._measureWord(o,s,n);return r=Math.max(a,r),n+=o.length+i.length,{word:o,width:a}})}),largestWordWidth:r}}_measureWord(t,e,i=0){let r,s=0;for(let n=0,o=t.length;n<o;n++)s+=this._getGraphemeBox(t[n],e,n+i,r,!0).kernedWidth,r=t[n];return s}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,{largestWordWidth:i,wordsData:r},s=0){let n=this._getWidthOfCharSpacing(),o=this.splitByGrapheme,a=[],l=o?"":" ",h=0,c=[],u=0,d=0,g=!0,f=Math.max(e-=s,i,this.dynamicMinWidth),p=r[t],m;for(u=0,m=0;m<p.length;m++){let{word:e,width:i}=p[m];u+=e.length,(h+=d+i-n)>f&&!g?(a.push(c),c=[],h=i,g=!0):h+=n,g||o||c.push(l),c=c.concat(e),d=o?0:this._measureWord([l],t,u),u++,g=!1}return m&&a.push(c),i+s>this.dynamicMinWidth&&(this.dynamicMinWidth=i-n+s),a}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?+!!this.isEndOfWrapping(t):1}_splitTextIntoLines(t){let e=super._splitTextIntoLines(t),i=this._wrapText(e.lines,this.width),r=Array(i.length);for(let t=0;t<i.length;t++)r[t]=i[t].join("");return e.lines=r,e.graphemeLines=i,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){let t=new Map;for(let e in this._styleMap){let i=parseInt(e,10);if(this._textLines[i]){let i=this._styleMap[e].line;t.set(`${i}`,!0)}}for(let e in this.styles)t.has(e)||delete this.styles[e]}toObject(t=[]){return super.toObject(["minWidth","splitByGrapheme",...t])}};c(nZ,"type","Textbox"),c(nZ,"textLayoutProperties",[...nQ.textLayoutProperties,"width"]),c(n
57Z,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),ti.setClass(nZ);var n0=class extends ss{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){let{target:i}=t,{clipPath:r,group:s}=i;if(!r||!this.shouldPerformLayout(t))return;let{width:n,height:o}=eo(sr(i,r)),a=new tl(n,o);if(r.absolutePositioned)return{center:ef(r.getRelativeCenterPoint(),void 0,s?s.calcTransformMatrix():void 0),size:a};{let s=r.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){let{center:i=new tl,correction:r=new tl}=this.calcBoundingBox(e,t)||{};return{center:i.add(s),correction:r.subtract(s),size:a}}return{center:i.getRelativeCenterPoint().add(s),size:a}}}};c(n0,"type","clip-path"),ti.setClass(n0);var n1=class extends ss{getInitialSize({target:t},{size:e}){return new tl(t.width||e.x,t.height||e.y)}};c(n1,"type","fixed"),ti.setClass(n1);var n2=class extends sa{subscribeTargets(t){let e=t.target;t.targets.reduce((t,e)=>(e.parent&&t.add(e.parent),t),new Set).forEach(t=>{t.layoutManager.subscribeTargets({target:t,targets:[e]})})}unsubscribeTargets(t){let e=t.target,i=e.getObjects();t.targets.reduce((t,e)=>(e.parent&&t.add(e.parent),t),new Set).forEach(t=>{i.some(e=>e.parent===t)||t.layoutManager.unsubscribeTargets({target:t,targets:[e]})})}},n5=class t extends sh{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e=[],i={}){super(),Object.assign(this,t.ownDefaults),this.setOptions(i);let{left:r,top:s,layoutManager:n}=i;this.groupInit(e,{left:r,top:s,layoutManager:null==n?new n2:n})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(...t){"selection-order"===this.multiSelectionStacking?this.add(...t):t.forEach(t=>{let e=this._objects.findIndex(e=>e.isInFrontOf(t)),i=-1===e?this.size():e;this.insertAt(i,t)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(g("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);let i=new Set;e.forEach(t=>{let{parent:e}=t;e&&i.add(e)}),"removed"===t?i.forEach(t=>{t._onAfterObjectsChange(si,e)}):i.forEach(t=>{t._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return`#<ActiveSelection: (${this.complexity()})>`}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;let r={hasControls:!1,...i,forActiveSelection:!0}
vendor: 4,493 bytes, line 57
57;for(let e=0;e<this._objects.length;e++)this._objects[e]._renderControls(t,r);super._renderControls(t,e),t.restore()}};c(n5,"type","ActiveSelection"),c(n5,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),ti.setClass(n5),ti.setClass(n5,"activeSelection");var n3=class{constructor(){c(this,"resources",{})}applyFilters(t,e,i,r,s){let n=s.getContext("2d",{willReadFrequently:!0,desynchronized:!0});if(!n)return;n.drawImage(e,0,0,i,r);let o={sourceWidth:i,sourceHeight:r,imageData:n.getImageData(0,0,i,r),originalEl:e,originalImageData:n.getImageData(0,0,i,r),canvasEl:s,ctx:n,filterBackend:this};t.forEach(t=>{t.applyTo(o)});let{imageData:a}=o;return a.width===i&&a.height===r||(s.width=a.width,s.height=a.height),n.putImageData(a,0,0),o}},n4=class{constructor({tileSize:t=d.textureSize}={}){c(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),c(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){let i=tx({width:t,height:e}),r=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)}applyFilters(t,e,i,r,s,n){let o,a,l,h,c,u,d=this.gl,g=s.getContext("2d");if(!d||!g)return;n&&(u=this.getCachedTexture(n,e));let f={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:r,destinationWidth:i,destinationHeight:r,context:d,sourceTexture:this.createTexture(d,i,r,u?void 0:e),targetTexture:this.createTexture(d,i,r),originalTexture:u||this.createTexture(d,i,r,u?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:s},p=d.createFramebuffer();return d.bindFramebuffer(d.FRAMEBUFFER,p),t.forEach(t=>{t&&t.applyTo(f)}),a=(o=f.targetCanvas).width,l=o.height,h=f.destinationWidth,c=f.destinationHeight,a===h&&l===c||(o.width=h,o.height=c),this.copyGLTo2D(d,f),d.bindTexture(d.TEXTURE_2D,null),d.deleteTexture(f.sourceTexture),d.deleteTexture(f.targetTexture),d.deleteFramebuffer(p),g.setTransform(1,0,0,1,0,0),f}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,r,s){let{NEAREST:n,TEXTURE_2D:o,RGBA:a,UNSIGNED_BYTE:l,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:c,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:d,TEXTURE_WRAP_T:g}=t,f=t.createTexture();return t.bindTexture(o,f),t.texParameteri(o,c,s||n),t.texParameteri(o,u,s||n),t.texParameteri(o,d,h),t.texParameteri(o,g,h),r?t.texImage2D(o,0,a,a,l,r):t.texImage2D(o,0,a,e,i,0,a,l,null),f}getCachedTexture(t,e,i){let{textureCache:r}=this;if(r[t])return r[t];{let s=this.createTexture(this.gl,e.width,e.height,e,i);return s&&(r[t]=s),s}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){let i=t.canvas,r=e.targetCanvas,s=r.getContext("2d");if(!s)return;s.translate(0,r.height),s.scale(1,-1);let n=i.height-r.height;s.drawImage(i,0,n,r.width,r.height,0,0,r.width,r.height)}copyGLTo2DPutImageData(t,e){let i=e.targetCanvas.getContext("2d"),r=e.destinationWidth,s=e.destinationHeight,n=r*s*4;if(!i)return;let o=new Uint8Array(this.imageBuffer,0,n),a=new Uint8ClampedArray(this.imageBuffer,0,n);t.readPixels(0,0,r,s,t.RGBA,t.UNSIGNED_BYTE,o);let l=new ImageData(a,r,s);i.putImageData(l,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;let t=this.gl,e={renderer:"",vendor:""};if(!t)return e;let i=t.getExtension("WEBGL_debug_renderer_info");if(i){let r=t.getParameter(i.UNMASKED_RENDERER_WEBGL),s=t.getParameter(i.UNMASKED_VENDOR_WEBGL);r&&(e.renderer=r.toLowerCase()),s&&(e.vendor=s.toLowerCase())}return this.gpuInfo=e,e}};function n8(){let{WebGLProbe:t}=x();return t.queryWebGL(ty()),d.enableGLFiltering&&t.isSupported(d.textureSize)?new n4({tileSize:d.textureSize}):new n3}function n6(t=!0){return!o&&t&&(o=n8()),o}function n9(t){o=t}let n7=["cropX","cropY"];var ot=class t extends rj{static getDefaults(){return{...super.getDefaults(),...t.ownDefaults}}constructor(e,i){super(),c(this,"_lastScaleX",1),c(this,"_lastScaleY",1),c(this,"_filterScalingX",1),c(this,"_filterScalingY",1),this.filters=[],Object.assign(this,t.ownDefaults),this.setOptions(i),this.cacheKey=`texture${tm()}`,this.setElement("string"==typeof e?(this.canvas&&tQ(this.canvas.getElement())||C()).getElementById(e):e,i)}getElement(){return this._element}
vendor: 4,611 bytes, lines 57-62
57setElement(t,e={}){this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._element=t,this._originalElement=t,this._setWidthHeight(e),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){let e=n6(!1);e instanceof n4&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture(`${this.cacheKey}_filtered`),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(t=>{let e=this[t];e&&x().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){let t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||0===this.strokeWidth)return;let e=this.width/2,i=this.height/2;t.beginPath(),t.moveTo(-e,-i),t.lineTo(e,-i),t.lineTo(e,i),t.lineTo(-e,i),t.lineTo(-e,-i),t.closePath()}toObject(t=[]){let e=[];return this.filters.forEach(t=>{t&&e.push(t.toObject())}),{...super.toObject([...n7,...t]),src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e,...this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{}}}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){let t=[],e=this._element,i=-this.width/2,r=-this.height/2,s=[],n=[],o="",a="";if(!e)return[];if(this.hasCrop()){let t=tm();s.push('<clipPath id="imageCrop_'+t+`"> 58`,` <rect x="`+i+'" y="'+r+'" width="'+t6(this.width)+'" height="'+t6(this.height)+`" /> 59`,`</clipPath> 60`),o=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(a=' image-rendering="optimizeSpeed"'),t.push(` <image `,"COMMON_PARTS",`xlink:href="${t6(this.getSrc(!0))}" x="${i-this.cropX}" y="${r-this.cropY}" width="${e.width||e.naturalWidth}" height="${e.height||e.naturalHeight}"${a}${o}></image> 61`),this.stroke||this.strokeDashArray){let t=this.fill;this.fill=null,n=[` <rect x="${i}" y="${r}" width="${t6(this.width)}" height="${t6(this.height)}" style="${this.getSvgStyles()}" /> 62`],this.fill=t}return"fill"===this.paintFirst?s.concat(t,n):s.concat(n,t)}getSrc(t){let e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t,{crossOrigin:e,signal:i}={}){return tX(t,{crossOrigin:e,signal:i}).then(t=>{void 0!==e&&this.set({crossOrigin:e}),this.setElement(t)})}toString(){return`#<Image: { src: "${this.getSrc()}" }>`}applyResizeFilters(){let t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),r=i.x,s=i.y,n=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||r>e&&s>e)return this._element=n,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=r,void(this._lastScaleY=s);let o=tx(n),{width:a,height:l}=n;this._element=o,this._lastScaleX=t.scaleX=r,this._lastScaleY=t.scaleY=s,n6().applyFilters([t],n,a,l,this._element),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height}applyFilters(t=this.filters||[]){if(t=t.filter(t=>t&&!t.isNeutralState()),this.set("dirty",!0),this.removeTexture(`${this.cacheKey}_filtered`),0===t.length)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);let e=this._originalElement,i=e.naturalWidth||e.width,r=e.naturalHeight||e.height;if(this._element===this._originalElement){let t=tx({width:i,height:r});this._element=t,this._filteredEl=t}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,r),this._lastScaleX=1,this._lastScaleY=1);n6().applyFilters(t,this._originalElement,i,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(t){t.imageSmoothingEnabled=this.imageSmoothing,!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){let e=this._element;if(!e)return;let i=this._filterScalingX,r=this._filterScalingY,s=this.width,n=this.height,o=Math.max(this.cropX,0),a=Math.max(this.cropY,0),l=e.naturalWi
62dth||e.width,h=e.naturalHeight||e.height,c=o*i,u=a*r,d=Math.min(s*i,l-c),g=Math.min(n*r,h-u),f=Math.min(s,l/i-o),p=Math.min(n,h/r-a);e&&t.drawImage(e,c,u,d,g,-s/2,-n/2,f,p)}_needsResize(){let t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight({width:t,height:e}={}){let i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){let t=eN(this.preserveAspectRatio||""),e=this.width,i=this.height,r={width:e,height:i},s,n=this._element.width,o=this._element.height,a=1,l=1,h=0,c=0,u=0,d=0;return t&&("none"!==t.alignX||"none"!==t.alignY)?("meet"===t.meetOrSlice&&(s=(e-n*(a=l=su(this._element,r)))/2,"Min"===t.alignX&&(h=-s),"Max"===t.alignX&&(h=s),s=(i-o*l)/2,"Min"===t.alignY&&(c=-s),"Max"===t.alignY&&(c=s)),"slice"===t.meetOrSlice&&(s=n-e/(a=l=sd(this._element,r)),"Mid"===t.alignX&&(u=s/2),"Max"===t.alignX&&(u=s),s=o-i/l,"Mid"===t.alignY&&(d=s/2),"Max"===t.alignY&&(d=s),n=e/a,o=i/l)):(a=e/n,l=i/o),{width:n,height:o,scaleX:a,scaleY:l,offsetLeft:h,offsetTop:c,cropX:u,cropY:d}}static fromObject({filters:t,resizeFilter:e,src:i,crossOrigin:r,type:s,...n},o){return Promise.all([tX(i,{...o,crossOrigin:r}),t&&tY(t,o),e?tY([e],o):[],tW(n,o)]).then(([t,e=[],[r],s={}])=>new this(t,{...n,src:i,filters:e,resizeFilter:r,...s}))}static fromURL(t,{crossOrigin:e=null,signal:i}={},r){return tX(t,{crossOrigin:e,signal:i}).then(t=>new this(t,r))}static async fromElement(t,e={},i){let r=r9(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(r["xlink:href"]||r.href,e,r).catch(t=>(g("log","Unable to parse Image",t),null))}};function oe(t){if(!ir.test(t.nodeName))return{};let e=t.getAttribute("viewBox"),i,r,s=1,n=1,o=0,a=0,l=t.getAttribute("width"),h=t.getAttribute("height"),c=t.getAttribute("x")||0,u=t.getAttribute("y")||0,d=!(e&&io.test(e)),g=!l||!h||"100%"===l||"100%"===h,f="",p=0,m=0;if(d&&(c||u)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(f=" translate("+eH(c||"0")+" "+eH(u||"0")+") ",i=(t.getAttribute("transform")||"")+f,t.setAttribute("transform",i),t.removeAttribute("x"),t.removeAttribute("y")),d&&g)return{width:0,height:0};let y={width:0,height:0};if(d)return y.width=eH(l),y.height=eH(h),y;let v=e.match(io);o=-parseFloat(v[1]),a=-parseFloat(v[2]);let _=parseFloat(v[3]),x=parseFloat(v[4]);y.minX=o,y.minY=a,y.viewBoxWidth=_,y.viewBoxHeight=x,g?(y.width=_,y.height=x):(y.width=eH(l),y.height=eH(h),s=y.width/_,n=y.height/x);let C=eN(t.getAttribute("preserveAspectRatio")||"");if("none"!==C.alignX&&("meet"===C.meetOrSlice&&(n=s=s>n?n:s),"slice"===C.meetOrSlice&&(n=s=s>n?s:n),p=y.width-_*s,m=y.height-x*s,"Mid"===C.alignX&&(p/=2),"Mid"===C.alignY&&(m/=2),"Min"===C.alignX&&(p=0),"Min"===C.alignY&&(m=0)),1===s&&1===n&&0===o&&0===a&&0===c&&0===u)return y;if((c||u)&&"#document"!==t.parentNode.nodeName&&(f=" translate("+eH(c||"0")+" "+eH(u||"0")+") "),i=f+" matrix("+s+" 0 0 "+n+" "+(o*s+p)+" "+(a*n+m)+") ","svg"===t.nodeName){for(r=t.ownerDocument.createElementNS(e6,"g");t.firstChild;)r.appendChild(t.firstChild);t.appendChild(r)}else(r=t).removeAttribute("x"),r.removeAttribute("y"),i=r.getAttribute("transform")+i;return r.setAttribute("transform",i),y}c(ot,"type","Image"),c(ot,"cacheProperties",[...id,...n7]),c(ot,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),c(ot,"ATTRIBUTE_NAMES",[...rG,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),ti.setClass(ot),ti.setSVGClass(ot);let oi=t=>t.tagName.replace("svg:",""),or=eK(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);function os(t,e){let i,r,s,n,o=[];for(s=0,n=e.length;s<n;s++)i=e[s],r=t.getElementsByTagNameNS("http://www.w3.org/2000/svg",i),o=o.concat(Array.from(r));return o}let on=["gradientTransform","x1","x2","y1","y2","gradientUnits","cx","cy","r","fx","fy"],oo="xlink:href",oa=["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"],ol=t=>ti.getSVGClass(oi(t).toLowerCase());var oh=class{constructor(t,e,i,r,s){this.elements=t,this.options=e,this.reviver=i,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=r,this.clipPaths=s,this.gradientDefs=function(t){let e=os(t,oa),i={},r=e.length;for(;r--;){let s=e[r];s.getAttribute("xlink:href")&&function t(e,i){var r;let s=(null==(r=i.getAttribute(oo))?void 0:r.slice(1))||"",n=e.getElementById(s);if(n&&n.getAttribute(oo)&&t(e,n),n&&(on.forEach(t=>{let e=n.getAttribute(t);!i.hasAttribute(t)&&e&&i.setAttribute(t,e)}),!i.children.length)){let t=n.cloneNode(!0);for(;t.firstChild;)i.appendChild(t.firstChild)}i.removeAttribute(oo)}(t,s);let n=s.getAttribute("id");n&&(i[n]=s)}return i}(r),this.cssRules=function(t){let e=t.getElementsByTagName("style"),i={};for(let t=0;t<e.length;t++){let r=(e[t].textContent||"").replace(/\/\*[\s\S]*?\*\//g,"");""!==r.trim()&&r.split("}").filter((t,e,i)=>i.length>
621&&t.trim()).forEach(t=>{if((t.match(/{/g)||[]).length>1&&t.trim().startsWith("@"))return;let e=t.split("{"),r={},s=e[1].trim().split(";").filter(function(t){return t.trim()});for(let t=0;t<s.length;t++){let e=s[t].split(":");r[e[0].trim()]=e[1].trim()}(t=e[0].trim()).split(",").forEach(t=>{""!==(t=t.replace(/^svg/i,"").trim())&&(i[t]={...i[t]||{},...r})})})}return i}(r)}parse(){return Promise.all(this.elements.map(t=>this.createObject(t)))}async createObject(t){let e=ol(t);if(e){let i=await e.fromElement(t,this.options,this.cssRules);return this.resolveGradient(i,t,J),this.resolveGradient(i,t,Q),i instanceof ot&&i._originalElement?sz(i,i.parsePreserveAspectRatioAttribute()):sz(i),await this.resolveClipPath(i,t),this.reviver&&this.reviver(t,i),i}return null}extractPropertyDefinition(t,e,i){let r=t[e],s=this.regexUrl;if(!s.test(r))return;s.lastIndex=0;let n=s.exec(r)[1];return s.lastIndex=0,i[n]}resolveGradient(t,e,i){let r=this.extractPropertyDefinition(t,i,this.gradientDefs);if(r){let s=e.getAttribute(i+"-opacity"),n=ny.fromElement(r,t,{...this.options,opacity:s});t.set(i,n)}}async resolveClipPath(t,e,i){let r=this.extractPropertyDefinition(t,"clipPath",this.clipPaths);if(r){let s=tk(t.calcTransformMatrix()),n=r[0].parentElement,o=e;for(;!i&&o.parentElement&&o.getAttribute("clip-path")!==t.clipPath;)o=o.parentElement;o.parentElement.appendChild(n);let a=r4(`${o.getAttribute("transform")||""} ${n.getAttribute("originalTransform")||""}`);n.setAttribute("transform",`matrix(${a.join(",")})`);let l=await Promise.all(r.map(t=>ol(t).fromElement(t,this.options,this.cssRules).then(t=>(sz(t),t.fillRule=t.clipRule,delete t.clipRule,t)))),h=1===l.length?l[0]:new sh(l),c=tD(s,h.calcTransformMatrix());h.clipPath&&await this.resolveClipPath(h,o,n.getAttribute("clip-path")?o:void 0);let{scaleX:u,scaleY:d,angle:g,skewX:f,translateX:p,translateY:m}=tE(c);h.set({flipX:!1,flipY:!1}),h.set({scaleX:u,scaleY:d,angle:g,skewX:f,skewY:0}),h.setPositionByOrigin(new tl(p,m),A,A),t.clipPath=h}else delete t.clipPath}};let oc=t=>ii.test(oi(t));async function ou(t,e,{crossOrigin:i,signal:r}={}){if(r&&r.aborted)return g("log",new p("parseSVGDocument")),{objects:[],elements:[],options:{},allElements:[]};let s=t.documentElement;!function(t){let e=os(t,["use","svg:use"]),i=["x","y","xlink:href","href","transform"];for(let r of e){let e=r.attributes,s={};for(let t of e)t.value&&(s[t.name]=t.value);let n=(s["xlink:href"]||s.href||"").slice(1);if(""===n)return;let o=t.getElementById(n);if(null===o)return;let a=o.cloneNode(!0),l=a.attributes,h={};for(let t of l)t.value&&(h[t.name]=t.value);let{x:c=0,y:u=0,transform:d=""}=s,g=`${d} ${h.transform||""} translate(${c}, ${u})`;if(oe(a),/^svg$/i.test(a.nodeName)){let t=a.ownerDocument.createElementNS(e6,"g");Object.entries(h).forEach(([e,i])=>t.setAttributeNS(e6,e,i)),t.append(...a.childNodes),a=t}for(let t of e){if(!t)continue;let{name:e,value:r}=t;if(!i.includes(e))if("style"===e){let t={};r8(r,t),Object.entries(h).forEach(([e,i])=>{t[e]=i}),r8(h.style||"",t);let i=Object.entries(t).map(t=>t.join(":")).join(";");a.setAttribute(e,i)}else h[e]||a.setAttribute(e,r)}a.setAttribute("transform",g),a.setAttribute("instantiated_by_use","1"),a.removeAttribute("id"),r.parentNode.replaceChild(a,r)}}(t);let n=Array.from(s.getElementsByTagName("*")),o={...oe(s),crossOrigin:i,signal:r},a=n.filter(t=>(oe(t),oc(t)&&!function(t){let e=t;for(;e&&(e=e.parentElement);)if(e&&e.nodeName&&or.test(oi(e))&&!e.getAttribute("instantiated_by_use"))return!0;return!1}(t)));if(!a||a&&!a.length)return{objects:[],elements:[],options:{},allElements:[],options:o,allElements:n};let l={};return n.filter(t=>"clipPath"===oi(t)).forEach(t=>{t.setAttribute("originalTransform",t.getAttribute("transform")||""),l[t.getAttribute("id")]=Array.from(t.getElementsByTagName("*")).filter(t=>oc(t))}),{objects:await new oh(a,o,e,t,l).parse(),elements:a,options:o,allElements:n}}function od(t,e,i){return ou(new(b()).DOMParser().parseFromString(t.trim(),"text/xml"),e,i)}function og(t,e,i={}){return fetch(t.replace(/^\n\s*/,"").trim(),{signal:i.signal}).then(t=>{if(!t.ok)throw new f(`HTTP error! status: ${t.status}`);return t.text()}).then(t=>
vendor: 4,227 bytes, lines 62-74
62od(t,e,i)).catch(()=>({objects:[],elements:[],options:{},allElements:[]}))}let of=t=>void 0!==t.webgl,op=(t,e)=>{let i=tx({width:t,height:e}),r=ty().getContext("webgl"),s={imageBuffer:new ArrayBuffer(t*e*4)},n={destinationWidth:t,destinationHeight:e,targetCanvas:i},o;o=b().performance.now(),n4.prototype.copyGLTo2D.call(s,r,n);let a=b().performance.now()-o;return o=b().performance.now(),n4.prototype.copyGLTo2DPutImageData.call(s,r,n),a>b().performance.now()-o},om="precision highp float",oy=` 63 ${om}; 64 varying vec2 vTexCoord; 65 uniform sampler2D uTexture; 66 void main() { 67 gl_FragColor = texture2D(uTexture, vTexCoord); 68 }`,ov=RegExp(om,"g");var o_=class{get type(){return this.constructor.type}constructor({type:t,...e}={}){Object.assign(this,this.constructor.defaults,e)}getFragmentSource(){return oy}getVertexSource(){return` 69 attribute vec2 aPosition; 70 varying vec2 vTexCoord; 71 void main() { 72 vTexCoord = aPosition; 73 gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0); 74 }`}createProgram(t,e=this.getFragmentSource(),i=this.getVertexSource()){let{WebGLProbe:{GLPrecision:r="highp"}}=x();"highp"!==r&&(e=e.replace(ov,om.replace("highp",r)));let s=t.createShader(t.VERTEX_SHADER),n=t.createShader(t.FRAGMENT_SHADER),o=t.createProgram();if(!s||!n||!o)throw new f("Vertex, fragment shader or program creation error");if(t.shaderSource(s,i),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw new f(`Vertex shader compile error for ${this.type}: ${t.getShaderInfoLog(s)}`);if(t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new f(`Fragment shader compile error for ${this.type}: ${t.getShaderInfoLog(n)}`);if(t.attachShader(o,s),t.attachShader(o,n),t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS))throw new f(`Shader link error for "${this.type}" ${t.getProgramInfoLog(o)}`);let a=this.getUniformLocations(t,o)||{};return a.uStepW=t.getUniformLocation(o,"uStepW"),a.uStepH=t.getUniformLocation(o,"uStepH"),{program:o,attributeLocations:this.getAttributeLocations(t,o),uniformLocations:a}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){let i=this.constructor.uniformLocations,r={};for(let s=0;s<i.length;s++)r[i[s]]=t.getUniformLocation(e,i[s]);return r}sendAttributeData(t,e,i){let r=e.aPosition,s=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,s),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,i,t.STATIC_DRAW)}_setupFrameBuffer(t){let e=t.context;if(t.passes>1){let i=t.destinationWidth,r=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===r||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,r)),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.targetTexture,0)}else e.bindFramebuffer(e.FRAMEBUFFER,null),e.finish()}_swapTextures(t){t.passes--,t.pass++;let e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){of(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){let e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){let e=t.context,i=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(i.program),this.sendAttributeData(e,i.attributeLocations,t.aPosition),e.uniform1f(i.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(i.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,i.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,i){t.activeTexture(i),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){let{sourceWidth:e,sourceHeight:i}=t;t.helpLayer=tx({width:e,height:i})}}toObject(){let t=Object.keys(this.constructor.defaults||{});
vendor: 3,989 bytes, lines 74-145
74return{type:this.type,...t.reduce((t,e)=>(t[e]=this[e],t),{})}}toJSON(){return this.toObject()}static async fromObject({type:t,...e},i){return new this(e)}};c(o_,"type","BaseFilter"),c(o_,"uniformLocations",[]);let ox={multiply:`gl_FragColor.rgb *= uColor.rgb; 75`,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb); 76`,add:`gl_FragColor.rgb += uColor.rgb; 77`,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb); 78`,subtract:`gl_FragColor.rgb -= uColor.rgb; 79`,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb); 80`,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb); 81`,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb); 82`,overlay:` 83 if (uColor.r < 0.5) { 84 gl_FragColor.r *= 2.0 * uColor.r; 85 } else { 86 gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r); 87 } 88 if (uColor.g < 0.5) { 89 gl_FragColor.g *= 2.0 * uColor.g; 90 } else { 91 gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g); 92 } 93 if (uColor.b < 0.5) { 94 gl_FragColor.b *= 2.0 * uColor.b; 95 } else { 96 gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b); 97 } 98 `,tint:` 99 gl_FragColor.rgb *= (1.0 - uColor.a); 100 gl_FragColor.rgb += uColor.rgb; 101 `};var oC=class extends o_{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return` 102 precision highp float; 103 uniform sampler2D uTexture; 104 uniform vec4 uColor; 105 varying vec2 vTexCoord; 106 void main() { 107 vec4 color = texture2D(uTexture, vTexCoord); 108 gl_FragColor = color; 109 if (color.a > 0.0) { 110 ${ox[this.mode]} 111 } 112 } 113 `}applyTo2d({imageData:{data:t}}){let e=new eG(this.color).getSource(),i=this.alpha,r=e[0]*i,s=e[1]*i,n=e[2]*i,o=1-i;for(let e=0;e<t.length;e+=4){let i=t[e],a=t[e+1],l=t[e+2],h,c,u;switch(this.mode){case"multiply":h=i*r/255,c=a*s/255,u=l*n/255;break;case"screen":h=255-(255-i)*(255-r)/255,c=255-(255-a)*(255-s)/255,u=255-(255-l)*(255-n)/255;break;case"add":h=i+r,c=a+s,u=l+n;break;case"difference":h=Math.abs(i-r),c=Math.abs(a-s),u=Math.abs(l-n);break;case"subtract":h=i-r,c=a-s,u=l-n;break;case"darken":h=Math.min(i,r),c=Math.min(a,s),u=Math.min(l,n);break;case"lighten":h=Math.max(i,r),c=Math.max(a,s),u=Math.max(l,n);break;case"overlay":h=r<128?2*i*r/255:255-2*(255-i)*(255-r)/255,c=s<128?2*a*s/255:255-2*(255-a)*(255-s)/255,u=n<128?2*l*n/255:255-2*(255-l)*(255-n)/255;break;case"exclusion":h=r+i-2*r*i/255,c=s+a-2*s*a/255,u=n+l-2*n*l/255;break;case"tint":h=r+i*o,c=s+a*o,u=n+l*o}t[e]=h,t[e+1]=c,t[e+2]=u}}sendUniformData(t,e){let i=new eG(this.color).getSource();i[0]=this.alpha*i[0]/255,i[1]=this.alpha*i[1]/255,i[2]=this.alpha*i[2]/255,i[3]=this.alpha,t.uniform4fv(e.uColor,i)}};c(oC,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),c(oC,"type","BlendColor"),c(oC,"uniformLocations",["uColor"]),ti.setClass(oC);let ob={multiply:` 114 precision highp float; 115 uniform sampler2D uTexture; 116 uniform sampler2D uImage; 117 uniform vec4 uColor; 118 varying vec2 vTexCoord; 119 varying vec2 vTexCoord2; 120 void main() { 121 vec4 color = texture2D(uTexture, vTexCoord); 122 vec4 color2 = texture2D(uImage, vTexCoord2); 123 color.rgba *= color2.rgba; 124 gl_FragColor = color; 125 } 126 `,mask:` 127 precision highp float; 128 uniform sampler2D uTexture; 129 uniform sampler2D uImage; 130 uniform vec4 uColor; 131 varying vec2 vTexCoord; 132 varying vec2 vTexCoord2; 133 void main() { 134 vec4 color = texture2D(uTexture, vTexCoord); 135 vec4 color2 = texture2D(uImage, vTexCoord2); 136 color.a = color2.a; 137 gl_FragColor = color; 138 } 139 `};var oS=class extends o_{getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return ob[this.mode]}getVertexSource(){return` 140 attribute vec2 aPosition; 141 varying vec2 vTexCoord; 142 varying vec2 vTexCoord2; 143 uniform mat3 uTransformMatrix; 144 void main() { 145 vTexCoord = aPosition;
146 vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy; 147 gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0); 148 } 149 `}applyToWebGL(t){let e=t.context,i=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,i,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){let t=this.image,{width:e,height:i}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/i,1]}applyTo2d({imageData:{data:t,width:e,height:i},filterBackend:{resources:r}}){let s=this.image;r.blendImage||(r.blendImage=ty());let n=r.blendImage,o=n.getContext("2d");n.width!==e||n.height!==i?(n.width=e,n.height=i):o.clearRect(0,0,e,i),o.setTransform(s.scaleX,0,0,s.scaleY,s.left,s.top),o.drawImage(s.getElement(),0,0,e,i);let a=o.getImageData(0,0,e,i).data;for(let e=0;e<t.length;e+=4){let i=t[e],r=t[e+1],s=t[e+2],n=t[e+3],o=a[e],l=a[e+1],h=a[e+2],c=a[e+3];switch(this.mode){case"multiply":t[e]=i*o/255,t[e+1]=r*l/255,t[e+2]=s*h/255,t[e+3]=n*c/255;break;case"mask":t[e+3]=c}}}sendUniformData(t,e){let i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return{...super.toObject(),image:this.image&&this.image.toObject()}}static async fromObject({type:t,image:e,...i},r){return ot.fromObject(e,r).then(t=>new this({...i,image:t}))}};c(oS,"type","BlendImage"),c(oS,"defaults",{mode:"multiply",alpha:1}),c(oS,"uniformLocations",["uTransformMatrix","uImage"]),ti.setClass(oS);var ow=class extends o_{getFragmentSource(){return` 150 precision highp float; 151 uniform sampler2D uTexture; 152 uniform vec2 uDelta; 153 varying vec2 vTexCoord; 154 const float nSamples = 15.0; 155 vec3 v3offset = vec3(12.9898, 78.233, 151.7182); 156 float random(vec3 scale) { 157 /* use the fragment position for a different seed per-pixel */ 158 return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453); 159 } 160 void main() { 161 vec4 color = vec4(0.0); 162 float totalC = 0.0; 163 float totalA = 0.0; 164 float offset = random(v3offset); 165 for (float t = -nSamples; t <= nSamples; t++) { 166 float percent = (t + offset - 0.5) / nSamples; 167 vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent); 168 float weight = 1.0 - abs(percent); 169 float alpha = weight * sample.a; 170 color.rgb += sample.rgb * alpha; 171 color.a += alpha; 172 totalA += weight; 173 totalC += alpha; 174 } 175 gl_FragColor.rgb = color.rgb / totalC; 176 gl_FragColor.a = color.a / totalA; 177 } 178 `}
vendor: 19,513 bytes, lines 178-475
178applyTo(t){of(t)?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d({imageData:{data:t,width:e,height:i}}){this.aspectRatio=e/i,this.horizontal=!0;let r=this.getBlurValue()*e,s=new Uint8ClampedArray(t),n=4*e;for(let e=0;e<t.length;e+=4){let i=0,o=0,a=0,l=0,h=0,c=e-e%n,u=c+n;for(let s=-14;s<15;s++){let n=s/15,d=4*Math.floor(r*n),g=1-Math.abs(n),f=e+d;f<c?f=c:f>u&&(f=u);let p=t[f+3]*g;i+=t[f]*p,o+=t[f+1]*p,a+=t[f+2]*p,l+=p,h+=g}s[e]=i/l,s[e+1]=o/l,s[e+2]=a/l,s[e+3]=l/h}this.horizontal=!1,r=this.getBlurValue()*i;for(let e=0;e<s.length;e+=4){let i=0,o=0,a=0,l=0,h=0,c=e%n,u=s.length-n+c;for(let t=-14;t<15;t++){let d=t/15,g=Math.floor(r*d)*n,f=1-Math.abs(d),p=e+g;p<c?p=c:p>u&&(p=u);let m=s[p+3]*f;i+=s[p]*m,o+=s[p+1]*m,a+=s[p+2]*m,l+=m,h+=f}t[e]=i/l,t[e+1]=o/l,t[e+2]=a/l,t[e+3]=l/h}}sendUniformData(t,e){let i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return 0===this.blur}getBlurValue(){let t=1,{horizontal:e,aspectRatio:i}=this;return e?i>1&&(t=1/i):i<1&&(t=i),t*this.blur*.12}chooseRightDelta(){let t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}};c(ow,"type","Blur"),c(ow,"defaults",{blur:0}),c(ow,"uniformLocations",["uDelta"]),ti.setClass(ow);var oT=class extends o_{getFragmentSource(){return` 179 precision highp float; 180 uniform sampler2D uTexture; 181 uniform float uBrightness; 182 varying vec2 vTexCoord; 183 void main() { 184 vec4 color = texture2D(uTexture, vTexCoord); 185 color.rgb += uBrightness; 186 gl_FragColor = color; 187 } 188`}applyTo2d({imageData:{data:t}}){let e=Math.round(255*this.brightness);for(let i=0;i<t.length;i+=4)t[i]+=e,t[i+1]+=e,t[i+2]+=e}isNeutralState(){return 0===this.brightness}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}};c(oT,"type","Brightness"),c(oT,"defaults",{brightness:0}),c(oT,"uniformLocations",["uBrightness"]),ti.setClass(oT);let oO={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};var ok=class extends o_{getFragmentSource(){return` 189 precision highp float; 190 uniform sampler2D uTexture; 191 varying vec2 vTexCoord; 192 uniform mat4 uColorMatrix; 193 uniform vec4 uConstants; 194 void main() { 195 vec4 color = texture2D(uTexture, vTexCoord); 196 color *= uColorMatrix; 197 color += uConstants; 198 gl_FragColor = color; 199 }`}applyTo2d(t){let e=t.imageData.data,i=this.matrix,r=this.colorsOnly;for(let t=0;t<e.length;t+=4){let s=e[t],n=e[t+1],o=e[t+2];if(e[t]=s*i[0]+n*i[1]+o*i[2]+255*i[4],e[t+1]=s*i[5]+n*i[6]+o*i[7]+255*i[9],e[t+2]=s*i[10]+n*i[11]+o*i[12]+255*i[14],!r){let r=e[t+3];e[t]+=r*i[3],e[t+1]+=r*i[8],e[t+2]+=r*i[13],e[t+3]=s*i[15]+n*i[16]+o*i[17]+r*i[18]+255*i[19]}}}sendUniformData(t,e){let i=this.matrix,r=[i[0],i[1],i[2],i[3],i[5],i[6],i[7],i[8],i[10],i[11],i[12],i[13],i[15],i[16],i[17],i[18]],s=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,r),t.uniform4fv(e.uConstants,s)}toObject(){return{...super.toObject(),matrix:[...this.matrix]}}};function oD(t,e){var i;let r=(c(i=class extends ok{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",t),c(i,"defaults",{colorsOnly:!1,matrix:e}),i);return ti.setClass(r,t),r}c(ok,"type","ColorMatrix"),c(ok,"defaults",oO),c(ok,"uniformLocations",["uColorMatrix","uConstants"]),ti.setClass(ok);let oM=oD("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),oP=oD("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),oE=oD("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),oA=oD("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),oj=oD("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),oF=oD("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),oL=oD("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 oB=class extends o_{constructor(t={}){super(t),this.subFilters=t.subFilters||[]}applyTo(t){of(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach(e=>{e.applyTo(t)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(t=>t.toObject())}}isNeutralState(){return!this.subFilters.some(t=>!t.isNeutralState())}static fromObject(t,e){return Promise.all((t.subFilters||[]).map(t=>ti.getClass(t.type).fromObject(t,e))).then(t=>new this({subFilters:t}))}};c(oB,"type","Composed"),ti.setClass(oB);var oI=class extends o_{getFragmentSource(){return` 200 precision highp float; 201 uniform sampler2D uTexture; 202 uniform float uContrast; 203 varying vec2 vTexCoord; 204 void main() { 205 vec4 color = texture2D(uTexture, vTexCoord); 206 float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast)); 207 color.rgb = contrastF * (color.rgb - 0.5) + 0.5; 208 gl_FragColor = color; 209 }`}isNeutralState(){return 0===this.contrast}applyTo2d({imageData:{data:t}}){let e=Math.floor(255*this.contrast),i=259*(e+255)/(255*(259-e));for(let e=0;e<t.length;e+=4)t[e]=i*(t[e]-128)+128,t[e+1]=i*(t[e+1]-128)+128,t[e+2]=i*(t[e+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}};c(oI,"type","Contrast"),c(oI,"defaults",{contrast:0}),c(oI,"uniformLocations",["uContrast"]),ti.setClass(oI);let oR={Convolute_3_1:` 210 precision highp float; 211 uniform sampler2D uTexture; 212 uniform float uMatrix[9]; 213 uniform float uStepW; 214 uniform float uStepH; 215 varying vec2 vTexCoord; 216 void main() { 217 vec4 color = vec4(0, 0, 0, 0); 218 for (float h = 0.0; h < 3.0; h+=1.0) { 219 for (float w = 0.0; w < 3.0; w+=1.0) { 220 vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1)); 221 color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)]; 222 } 223 } 224 gl_FragColor = color; 225 } 226 `,Convolute_3_0:` 227 precision highp float; 228 uniform sampler2D uTexture; 229 uniform float uMatrix[9]; 230 uniform float uStepW; 231 uniform float uStepH; 232 varying vec2 vTexCoord; 233 void main() { 234 vec4 color = vec4(0, 0, 0, 1); 235 for (float h = 0.0; h < 3.0; h+=1.0) { 236 for (float w = 0.0; w < 3.0; w+=1.0) { 237 vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0)); 238 color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)]; 239 } 240 } 241 float alpha = texture2D(uTexture, vTexCoord).a; 242 gl_FragColor = color; 243 gl_FragColor.a = alpha; 244 } 245 `,Convolute_5_1:` 246 precision highp float; 247 uniform sampler2D uTexture; 248 uniform float uMatrix[25]; 249 uniform float uStepW; 250 uniform float uStepH; 251 varying vec2 vTexCoord; 252 void main() { 253 vec4 color = vec4(0, 0, 0, 0); 254 for (float h = 0.0; h < 5.0; h+=1.0) { 255 for (float w = 0.0; w < 5.0; w+=1.0) { 256 vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0)); 257 color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)]; 258 } 259 } 260 gl_FragColor = color; 261 } 262 `,Convolute_5_0:` 263 precision highp float; 264 uniform sampler2D uTexture; 265 uniform float uMatrix[25]; 266 uniform float uStepW; 267 uniform float uStepH; 268 varying vec2 vTexCoord; 269 void main() { 270 vec4 color = vec4(0, 0, 0, 1); 271 for (float h = 0.0; h < 5.0; h+=1.0) { 272 for (float w = 0.0; w < 5.0; w+=1.0) { 273 vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0)); 274 color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)]; 275 } 276 } 277 float alpha = texture2D(uTexture, vTexCoord).a; 278 gl_FragColor = color; 279 gl_FragColor.a = alpha; 280 } 281 `,Convolute_7_1:` 282 precision highp float; 283 uniform sampler2D uTexture; 284 uniform float uMatrix[49]; 285 uniform float uStepW; 286 uniform float uStepH; 287 varying vec2 vTexCoord; 288 void main() { 289 vec4 color = vec4(0, 0, 0, 0); 290 for (float h = 0.0; h < 7.0; h+=1.0) { 291 for (float w = 0.0; w < 7.0; w+=1.0) { 292 vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0)); 293 color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)]; 294 } 295 } 296 gl_FragColor = color; 297 } 298 `,Convolute_7_0:` 299 precision highp float; 300 uniform sampler2D uTexture; 301 uniform float uMatrix[49]; 302 uniform float uStepW; 303 uniform float uStepH; 304 varying vec2 vTexCoord; 305 void main() { 306 vec4 color = vec4(0, 0, 0, 1); 307 for (float h = 0.0; h < 7.0; h+=1.0) { 308 for (float w = 0.0; w < 7.0; w+=1.0) { 309 vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0)); 310 color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)]; 311 } 312 } 313 float alpha = texture2D(uTexture, vTexCoord).a; 314 gl_FragColor = color; 315 gl_FragColor.a = alpha; 316 } 317 `,Convolute_9_1:` 318 precision highp float; 319 uniform sampler2D uTexture; 320 uniform float uMatrix[81]; 321 uniform float uStepW; 322 uniform float uStepH; 323 varying vec2 vTexCoord; 324 void main() { 325 vec4 color = vec4(0, 0, 0, 0); 326 for (float h = 0.0; h < 9.0; h+=1.0) { 327 for (float w = 0.0; w < 9.0; w+=1.0) { 328 vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0)); 329 color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)]; 330 } 331 } 332 gl_FragColor = color; 333 } 334 `,Convolute_9_0:` 335 precision highp float; 336 uniform sampler2D uTexture; 337 uniform float uMatrix[81]; 338 uniform float uStepW; 339 uniform float uStepH; 340 varying vec2 vTexCoord; 341 void main() { 342 vec4 color = vec4(0, 0, 0, 1); 343 for (float h = 0.0; h < 9.0; h+=1.0) { 344 for (float w = 0.0; w < 9.0; w+=1.0) { 345 vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0)); 346 color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)]; 347 } 348 } 349 float alpha = texture2D(uTexture, vTexCoord).a; 350 gl_FragColor = color; 351 gl_FragColor.a = alpha; 352 } 353 `};var o$=class extends o_{getCacheKey(){return`${this.type}_${Math.sqrt(this.matrix.length)}_${+!!this.opaque}`}getFragmentSource(){return oR[this.getCacheKey()]}applyTo2d(t){let e=t.imageData,i=e.data,r=this.matrix,s=Math.round(Math.sqrt(r.length)),n=Math.floor(s/2),o=e.width,a=e.height,l=t.ctx.createImageData(o,a),h=l.data,c=+!!this.opaque,u,d,g,f,p,m,y,v,_,x,C,b,S;for(C=0;C<a;C++)for(x=0;x<o;x++){for(p=4*(C*o+x),u=0,d=0,g=0,f=0,S=0;S<s;S++)for(b=0;b<s;b++)y=C+S-n,m=x+b-n,y<0||y>=a||m<0||m>=o||(v=4*(y*o+m),_=r[S*s+b],u+=i[v]*_,d+=i[v+1]*_,g+=i[v+2]*_,c||(f+=i[v+3]*_));h[p]=u,h[p+1]=d,h[p+2]=g,h[p+3]=c?i[p+3]:f}t.imageData=l}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return{...super.toObject(),opaque:this.opaque,matrix:[...this.matrix]}}};c(o$,"type","Convolute"),c(o$,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),c(o$,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),ti.setClass(o$);let oX="Gamma";var oY=class extends o_{getFragmentSource(){return` 354 precision highp float; 355 uniform sampler2D uTexture; 356 uniform vec3 uGamma; 357 varying vec2 vTexCoord; 358 void main() { 359 vec4 color = texture2D(uTexture, vTexCoord); 360 vec3 correction = (1.0 / uGamma); 361 color.r = pow(color.r, correction.r); 362 color.g = pow(color.g, correction.g); 363 color.b = pow(color.b, correction.b); 364 gl_FragColor = color; 365 gl_FragColor.rgb *= color.a; 366 } 367`}constructor(t={}){super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d({imageData:{data:t}}){let e=this.gamma,i=1/e[0],r=1/e[1],s=1/e[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});let n=this.rgbValues;for(let t=0;t<256;t++)n.r[t]=255*(t/255)**i,n.g[t]=255*(t/255)**r,n.b[t]=255*(t/255)**s;for(let e=0;e<t.length;e+=4)t[e]=n.r[t[e]],t[e+1]=n.g[t[e+1]],t[e+2]=n.b[t[e+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){let{gamma:t}=this;return 1===t[0]&&1===t[1]&&1===t[2]}toObject(){return{type:oX,gamma:this.gamma.concat()}}};c(oY,"type",oX),c(oY,"defaults",{gamma:[1,1,1]}),c(oY,"uniformLocations",["uGamma"]),ti.setClass(oY);let oW={average:` 368 precision highp float; 369 uniform sampler2D uTexture; 370 varying vec2 vTexCoord; 371 void main() { 372 vec4 color = texture2D(uTexture, vTexCoord); 373 float average = (color.r + color.b + color.g) / 3.0; 374 gl_FragColor = vec4(average, average, average, color.a); 375 } 376 `,lightness:` 377 precision highp float; 378 uniform sampler2D uTexture; 379 uniform int uMode; 380 varying vec2 vTexCoord; 381 void main() { 382 vec4 col = texture2D(uTexture, vTexCoord); 383 float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0; 384 gl_FragColor = vec4(average, average, average, col.a); 385 } 386 `,luminosity:` 387 precision highp float; 388 uniform sampler2D uTexture; 389 uniform int uMode; 390 varying vec2 vTexCoord; 391 void main() { 392 vec4 col = texture2D(uTexture, vTexCoord); 393 float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b; 394 gl_FragColor = vec4(average, average, average, col.a); 395 } 396 `};var oV=class extends o_{applyTo2d({imageData:{data:t}}){for(let e,i=0;i<t.length;i+=4){let r=t[i],s=t[i+1],n=t[i+2];switch(this.mode){case"average":e=(r+s+n)/3;break;case"lightness":e=(Math.min(r,s,n)+Math.max(r,s,n))/2;break;case"luminosity":e=.21*r+.72*s+.07*n}t[i+2]=t[i+1]=t[i]=e}}getCacheKey(){return`${this.type}_${this.mode}`}getFragmentSource(){return oW[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}};c(oV,"type","Grayscale"),c(oV,"defaults",{mode:"average"}),c(oV,"uniformLocations",["uMode"]),ti.setClass(oV);let oG={...oO,rotation:0};var oz=class extends ok{calculateMatrix(){let t=this.rotation*Math.PI,e=to(t),i=ta(t),r=1/3,s=Math.sqrt(1/3)*i,n=1-e;this.matrix=[e+n/3,r*n-s,r*n+s,0,0,r*n+s,e+r*n,r*n-s,0,0,r*n-s,r*n+s,e+r*n,0,0,0,0,0,1,0]}isNeutralState(){return 0===this.rotation}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}};c(oz,"type","HueRotation"),c(oz,"defaults",oG),ti.setClass(oz);var oH=class extends o_{applyTo2d({imageData:{data:t}}){for(let e=0;e<t.length;e+=4)t[e]=255-t[e],t[e+1]=255-t[e+1],t[e+2]=255-t[e+2],this.alpha&&(t[e+3]=255-t[e+3])}getFragmentSource(){return` 397 precision highp float; 398 uniform sampler2D uTexture; 399 uniform int uInvert; 400 uniform int uAlpha; 401 varying vec2 vTexCoord; 402 void main() { 403 vec4 color = texture2D(uTexture, vTexCoord); 404 if (uInvert == 1) { 405 if (uAlpha == 1) { 406 gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a); 407 } else { 408 gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a); 409 } 410 } else { 411 gl_FragColor = color; 412 } 413 } 414`}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}};c(oH,"type","Invert"),c(oH,"defaults",{alpha:!1,invert:!0}),c(oH,"uniformLocations",["uInvert","uAlpha"]),ti.setClass(oH);var oN=class extends o_{getFragmentSource(){return` 415 precision highp float; 416 uniform sampler2D uTexture; 417 uniform float uStepH; 418 uniform float uNoise; 419 uniform float uSeed; 420 varying vec2 vTexCoord; 421 float rand(vec2 co, float seed, float vScale) { 422 return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0); 423 } 424 void main() { 425 vec4 color = texture2D(uTexture, vTexCoord); 426 color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise; 427 gl_FragColor = color; 428 } 429`}applyTo2d({imageData:{data:t}}){let e=this.noise;for(let i=0;i<t.length;i+=4){let r=(.5-Math.random())*e;t[i]+=r,t[i+1]+=r,t[i+2]+=r}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return 0===this.noise}};c(oN,"type","Noise"),c(oN,"defaults",{noise:0}),c(oN,"uniformLocations",["uNoise","uSeed"]),ti.setClass(oN);var oU=class extends o_{applyTo2d({imageData:{data:t,width:e,height:i}}){for(let r=0;r<i;r+=this.blocksize)for(let s=0;s<e;s+=this.blocksize){let n=4*r*e+4*s,o=t[n],a=t[n+1],l=t[n+2],h=t[n+3];for(let n=r;n<Math.min(r+this.blocksize,i);n++)for(let i=s;i<Math.min(s+this.blocksize,e);i++){let r=4*n*e+4*i;t[r]=o,t[r+1]=a,t[r+2]=l,t[r+3]=h}}}isNeutralState(){return 1===this.blocksize}getFragmentSource(){return` 430 precision highp float; 431 uniform sampler2D uTexture; 432 uniform float uBlocksize; 433 uniform float uStepW; 434 uniform float uStepH; 435 varying vec2 vTexCoord; 436 void main() { 437 float blockW = uBlocksize * uStepW; 438 float blockH = uBlocksize * uStepH; 439 int posX = int(vTexCoord.x / blockW); 440 int posY = int(vTexCoord.y / blockH); 441 float fposX = float(posX); 442 float fposY = float(posY); 443 vec2 squareCoords = vec2(fposX * blockW, fposY * blockH); 444 vec4 color = texture2D(uTexture, squareCoords); 445 gl_FragColor = color; 446 } 447`}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}};c(oU,"type","Pixelate"),c(oU,"defaults",{blocksize:4}),c(oU,"uniformLocations",["uBlocksize"]),ti.setClass(oU);var oq=class extends o_{getFragmentSource(){return` 448precision highp float; 449uniform sampler2D uTexture; 450uniform vec4 uLow; 451uniform vec4 uHigh; 452varying vec2 vTexCoord; 453void main() { 454 gl_FragColor = texture2D(uTexture, vTexCoord); 455 if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) { 456 gl_FragColor.a = 0.0; 457 } 458} 459`}applyTo2d({imageData:{data:t}}){let e=255*this.distance,i=new eG(this.color).getSource(),r=[i[0]-e,i[1]-e,i[2]-e],s=[i[0]+e,i[1]+e,i[2]+e];for(let e=0;e<t.length;e+=4){let i=t[e],n=t[e+1],o=t[e+2];i>r[0]&&n>r[1]&&o>r[2]&&i<s[0]&&n<s[1]&&o<s[2]&&(t[e+3]=0)}}sendUniformData(t,e){let i=new eG(this.color).getSource(),r=this.distance,s=[0+i[0]/255-r,0+i[1]/255-r,0+i[2]/255-r,1],n=[i[0]/255+r,i[1]/255+r,i[2]/255+r,1];t.uniform4fv(e.uLow,s),t.uniform4fv(e.uHigh,n)}};c(oq,"type","RemoveColor"),c(oq,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),c(oq,"uniformLocations",["uLow","uHigh"]),ti.setClass(oq);var oK=class extends o_{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){let t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){let t=this.getFilterWindow();return`${this.type}_${t}`}getFragmentSource(){let t=this.getFilterWindow();return this.generateShader(t)}getTaps(){let t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,i=this.getFilterWindow(),r=Array(i);for(let s=1;s<=i;s++)r[s-1]=t(s*e);return r}generateShader(t){let e=Array(t);for(let i=1;i<=t;i++)e[i-1]=`${i}.0 * uDelta`;return` 460 precision highp float; 461 uniform sampler2D uTexture; 462 uniform vec2 uDelta; 463 varying vec2 vTexCoord; 464 uniform float uTaps[${t}]; 465 void main() { 466 vec4 color = texture2D(uTexture, vTexCoord); 467 float sum = 1.0; 468 ${e.map((t,e)=>` 469 color += texture2D(uTexture, vTexCoord + ${t}) * uTaps[${e}] + texture2D(uTexture, vTexCoord - ${t}) * uTaps[${e}]; 470 sum += 2.0 * uTaps[${e}]; 471 `).join(` 472`)} 473 gl_FragColor = color / sum; 474 } 475 `}
475applyToForWebgl(t){t.passes++,this.width=t.sourceWidth,this.horizontal=!0,this.dW=Math.round(this.width*this.scaleX),this.dH=t.sourceHeight,this.tempScale=this.dW/this.width,this.taps=this.getTaps(),t.destinationWidth=this.dW,super.applyTo(t),t.sourceWidth=t.destinationWidth,this.height=t.sourceHeight,this.horizontal=!1,this.dH=Math.round(this.height*this.scaleY),this.tempScale=this.dH/this.height,this.taps=this.getTaps(),t.destinationHeight=this.dH,super.applyTo(t),t.sourceHeight=t.destinationHeight}applyTo(t){of(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return 1===this.scaleX&&1===this.scaleY}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;let i=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(i)/i}}applyTo2d(t){let e=t.imageData,i=this.scaleX,r=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/r;let s=e.width,n=e.height,o=Math.round(s*i),a=Math.round(n*r),l;l="sliceHack"===this.resizeType?this.sliceByTwo(t,s,n,o,a):"hermite"===this.resizeType?this.hermiteFastResize(t,s,n,o,a):"bilinear"===this.resizeType?this.bilinearFiltering(t,s,n,o,a):"lanczos"===this.resizeType?this.lanczosResize(t,s,n,o,a):new ImageData(o,a),t.imageData=l}sliceByTwo(t,e,i,r,s){let n=t.imageData,o=!1,a=!1,l=.5*e,h=.5*i,c=t.filterBackend.resources,u=0,d=0,g=e,f=0;c.sliceByTwo||(c.sliceByTwo=ty());let p=c.sliceByTwo;(p.width<1.5*e||p.height<i)&&(p.width=1.5*e,p.height=i);let m=p.getContext("2d");for(m.clearRect(0,0,1.5*e,i),m.putImageData(n,0,0),r=Math.floor(r),s=Math.floor(s);!o||!a;)e=l,i=h,r<Math.floor(.5*l)?l=Math.floor(.5*l):(l=r,o=!0),s<Math.floor(.5*h)?h=Math.floor(.5*h):(h=s,a=!0),m.drawImage(p,u,d,e,i,g,f,l,h),u=g,d=f,f+=h;return m.getImageData(u,d,r,s)}lanczosResize(t,e,i,r,s){let n=t.imageData.data,o=t.ctx.createImageData(r,s),a=o.data,l=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,c=this.rcpScaleY,u=2/this.rcpScaleX,d=2/this.rcpScaleY,g=Math.ceil(h*this.lanczosLobes/2),f=Math.ceil(c*this.lanczosLobes/2),p={},m={x:0,y:0},y={x:0,y:0};return function t(v){let _,x,C,b,S,w,T,O,k,D,M;for(m.x=(v+.5)*h,y.x=Math.floor(m.x),_=0;_<s;_++){for(m.y=(_+.5)*c,y.y=Math.floor(m.y),S=0,w=0,T=0,O=0,k=0,x=y.x-g;x<=y.x+g;x++)if(!(x<0||x>=e)){p[D=Math.floor(1e3*Math.abs(x-m.x))]||(p[D]={});for(let t=y.y-f;t<=y.y+f;t++)t<0||t>=i||(M=Math.floor(1e3*Math.abs(t-m.y)),p[D][M]||(p[D][M]=l(Math.sqrt((D*u)**2+(M*d)**2)/1e3)),(C=p[D][M])>0&&(b=4*(t*e+x),S+=C,w+=C*n[b],T+=C*n[b+1],O+=C*n[b+2],k+=C*n[b+3]))}a[b=4*(_*r+v)]=w/S,a[b+1]=T/S,a[b+2]=O/S,a[b+3]=k/S}return++v<r?t(v):o}(0)}bilinearFiltering(t,e,i,r,s){let n,o,a,l,h,c,u,d,g,f,p,m=0,y=this.rcpScaleX,v=this.rcpScaleY,_=4*(e-1),x=t.imageData.data,C=t.ctx.createImageData(r,s),b=C.data;for(h=0;h<s;h++)for(c=0;c<r;c++)for(a=Math.floor(y*c),l=Math.floor(v*h),u=y*c-a,d=v*h-l,p=4*(l*e+a),g=0;g<4;g++)n=x[p+g],o=x[p+4+g],f=n*(1-u)*(1-d)+o*u*(1-d)+x[p+_+g]*d*(1-u)+x[p+_+4+g]*u*d,b[m++]=f;return C}hermiteFastResize(t,e,i,r,s){let n=this.rcpScaleX,o=this.rcpScaleY,a=Math.ceil(n/2),l=Math.ceil(o/2),h=t.imageData.data,c=t.ctx.createImageData(r,s),u=c.data;for(let t=0;t<s;t++)for(let i=0;i<r;i++){let s=4*(i+t*r),c=0,d=0,g=0,f=0,p=0,m=0,y=0,v=(t+.5)*o;for(let r=Math.floor(t*o);r<(t+1)*o;r++){let t=Math.abs(v-(r+.5))/l,s=(i+.5)*n,o=t*t;for(let t=Math.floor(i*n);t<(i+1)*n;
475t++){let i=Math.abs(s-(t+.5))/a,n=Math.sqrt(o+i*i);n>1&&n<-1||(c=2*n*n*n-3*n*n+1)>0&&(y+=c*h[(i=4*(t+r*e))+3],g+=c,h[i+3]<255&&(c=c*h[i+3]/250),f+=c*h[i],p+=c*h[i+1],m+=c*h[i+2],d+=c)}}u[s]=f/d,u[s+1]=p/d,u[s+2]=m/d,u[s+3]=y/g}return c}};c(oK,"type","Resize"),c(oK,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),c(oK,"uniformLocations",["uDelta","uTaps"]),ti.setClass(oK);var oJ=class extends o_{getFragmentSource(){return` 476 precision highp float; 477 uniform sampler2D uTexture; 478 uniform float uSaturation; 479 varying vec2 vTexCoord; 480 void main() { 481 vec4 color = texture2D(uTexture, vTexCoord); 482 float rgMax = max(color.r, color.g); 483 float rgbMax = max(rgMax, color.b); 484 color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00; 485 color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00; 486 color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00; 487 gl_FragColor = color; 488 } 489`}applyTo2d({imageData:{data:t}}){let e=-this.saturation;for(let i=0;i<t.length;i+=4){let r=t[i],s=t[i+1],n=t[i+2],o=Math.max(r,s,n);t[i]+=o===r?0:(o-r)*e,t[i+1]+=o===s?0:(o-s)*e,t[i+2]+=o===n?0:(o-n)*e}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return 0===this.saturation}};c(oJ,"type","Saturation"),c(oJ,"defaults",{saturation:0}),c(oJ,"uniformLocations",["uSaturation"]),ti.setClass(oJ);var oQ=class extends o_{getFragmentSource(){return` 490 precision highp float; 491 uniform sampler2D uTexture; 492 uniform float uVibrance; 493 varying vec2 vTexCoord; 494 void main() { 495 vec4 color = texture2D(uTexture, vTexCoord); 496 float max = max(color.r, max(color.g, color.b)); 497 float avg = (color.r + color.g + color.b) / 3.0; 498 float amt = (abs(max - avg) * 2.0) * uVibrance; 499 color.r += max != color.r ? (max - color.r) * amt : 0.00; 500 color.g += max != color.g ? (max - color.g) * amt : 0.00; 501 color.b += max != color.b ? (max - color.b) * amt : 0.00; 502 gl_FragColor = color; 503 } 504`}applyTo2d({imageData:{data:t}}){let e=-this.vibrance;for(let i=0;i<t.length;i+=4){let r=t[i],s=t[i+1],n=t[i+2],o=Math.max(r,s,n),a=2*Math.abs(o-(r+s+n)/3)/255*e;t[i]+=o===r?0:(o-r)*a,t[i+1]+=o===s?0:(o-s)*a,t[i+2]+=o===n?0:(o-n)*a}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return 0===this.vibrance}};c(oQ,"type","Vibrance"),c(oQ,"defaults",{vibrance:0}),c(oQ,"uniformLocations",["uVibrance"]),ti.setClass(oQ);var oZ=l({BaseFilter:()=>o_,BlackWhite:()=>oL,BlendColor:()=>oC,BlendImage:()=>oS,Blur:()=>ow,Brightness:()=>oT,Brownie:()=>oM,ColorMatrix:()=>ok,Composed:()=>oB,Contrast:()=>oI,Convolute:()=>o$,Gamma:()=>oY,Grayscale:()=>oV,HueRotation:()=>oz,Invert:()=>oH,Kodachrome:()=>oE,Noise:()=>oN,Pixelate:()=>oU,Polaroid:()=>oj,RemoveColor:()=>oq,Resize:()=>oK,Saturation:()=>oJ,Sepia:()=>oF,Technicolor:()=>oA,Vibrance:()=>oQ,Vintage:()=>oP})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.