PageSourceSearch

https://boombam.app/assets/index.min-B_wkc3Zr.js

js boombam.app collected 2026-10-04 13:35:22 UTC 286,589 bytes, 504 lines download raw bytes

1function p(a,t,e){return(t=function(s){var i=function(r,n){if(typeof r!="object"||!r)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var h=o.call(r,n||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(r)}(s,"string");return typeof i=="symbol"?i:i+""}(t))in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}function Pi(a,t){var e=Object.keys(a);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(a);t&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(a,i).enumerable})),e.push.apply(e,s)}return e}function m(a){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Pi(Object(e),!0).forEach(function(s){p(a,s,e[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(e)):Pi(Object(e)).forEach(function(s){Object.defineProperty(a,s,Object.getOwnPropertyDescriptor(e,s))})}return a}function X(a,t){if(a==null)return{};var e,s,i=function(n,o){if(n==null)return{};var h={};for(var c in n)if({}.hasOwnProperty.call(n,c)){if(o.indexOf(c)>=0)continue;h[c]=n[c]}return h}(a,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(a);for(s=0;s<r.length;s++)e=r[s],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(a,e)&&(i[e]=a[e])}return i}function Tt(a,t){return t||(t=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(t)}}))}class Ai{constructor(){p(this,"browserShadowBlurConstant",1),p(this,"DPI",96),p(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),p(this,"perfLimitSizeTotal",2097152),p(this,"maxCacheSideLimit",4096),p(this,"minCacheSideLimit",256),p(this,"disableStyleCopyPaste",!1),p(this,"enableGLFiltering",!0),p(this,"textureSize",4096),p(this,"forceGLPutImageData",!1),p(this,"cachesBoundsOfCurve",!1),p(this,"fontPaths",{}),p(this,"NUM_FRACTION_DIGITS",4)}}const E=new class extends Ai{constructor(a){super(),this.configure(a)}configure(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,a)}addFonts(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=m(m({},this.fontPaths),a)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(a=>{delete this.fontPaths[a]})}clearFonts(){this.fontPaths={}}restoreDefaults(a){const t=new Ai,e=(a==null?void 0:a.reduce((s,i)=>(s[i]=t[i],s),{}))||t;this.configure(e)}},Gt=function(a){for(var t=arguments.length,e=new Array(t>1?t-1:0),s=1;s<t;s++)e[s-1]=arguments[s];return console[a]("fabric",...e)};class St extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class wn extends St{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class Tn{}class On extends Tn{testPrecision(t,e){const s="precision ".concat(e,` float;
2void main(){}`),i=t.createShader(t.FRAGMENT_SHADER);return!!i&&(t.shaderSource(i,s),t.compileShader(i),!!t.getShaderParameter(i,t.COMPILE_STATUS))}queryWebGL(t){const e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(s=>this.testPrecision(e,s)),e.getExtension("WEBGL_lose_context").loseContext(),Gt("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Dn={};let ji;const wt=()=>ji||(ji={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new On,dispose(){},copyPasteData:Dn}),de=()=>wt().document,ks=()=>wt().window,_r=()=>{var a;return Math.max((a=E.devicePixelRatio)!==null&&a!==void 0?a:ks().devicePixelRatio,1)},Te=new class{constructor(){p(this,"boundsOfCurveCache",{}),this.charWidthsCache=new Map}getFontCache(a){let{fontFamily:t,fontStyle:e,fontWeight:s}=a;t=t.toLowerCase();const i=this.charWidthsCache;i.has(t)||i.set(t,new Map);const r=i.get(t),n="".concat(e.toLowerCase(),"_").concat((s+"").toLowerCase());return r.has(n)||r.set(n,new Map),r.get(n)}clearFontCache(a){a?this.charWidthsCache.delete((a||"").toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(a){const{perfLimitSizeTotal:t}
vendor: 5,307 bytes, line 2
2=E,e=Math.sqrt(t*a);return[Math.floor(e),Math.floor(t/e)]}},ti="6.9.0";function us(){}const Le=Math.PI/2,ms=2*Math.PI,gi=Math.PI/180,et=Object.freeze([1,0,0,1,0,0]),di=16,Vt=.4477152502,k="center",j="left",it="top",ei="bottom",Y="right",rt="none",fi=/\r?\n/,xr="moving",Ms="scaling",Cr="rotating",pi="rotate",br="skewing",Me="resizing",kn="modifyPoly",Mn="modifyPath",vs="changed",Es="scale",ot="scaleX",ut="scaleY",fe="skewX",pe="skewY",H="fill",nt="stroke",ys="modified",ie="json",Ys="svg",T=new class{constructor(){this[ie]=new Map,this[Ys]=new Map}has(a){return this[ie].has(a)}getClass(a){const t=this[ie].get(a);if(!t)throw new St("No class registered for ".concat(a));return t}setClass(a,t){t?this[ie].set(t,a):(this[ie].set(a.type,a),this[ie].set(a.type.toLowerCase(),a))}getSVGClass(a){return this[Ys].get(a)}setSVGClass(a,t){this[Ys].set(t??a.type.toLowerCase(),a)}},_s=new class extends Array{remove(a){const t=this.indexOf(a);t>-1&&this.splice(t,1)}cancelAll(){const a=this.splice(0);return a.forEach(t=>t.abort()),a}cancelByCanvas(a){if(!a)return[];const t=this.filter(e=>{var s;return e.target===a||typeof e.target=="object"&&((s=e.target)===null||s===void 0?void 0:s.canvas)===a});return t.forEach(e=>e.abort()),t}cancelByTarget(a){if(!a)return[];const t=this.filter(e=>e.target===a);return t.forEach(e=>e.abort()),t}};class En{constructor(){p(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(s=>{let[i,r]=s;this.on(i,r)}),()=>this.off(t);if(e){const s=t;return this.__eventListeners[s]||(this.__eventListeners[s]=[]),this.__eventListeners[s].push(e),()=>this.off(s,e)}return()=>!1}once(t,e){if(typeof t=="object"){const s=[];return Object.entries(t).forEach(i=>{let[r,n]=i;s.push(this.once(r,n))}),()=>s.forEach(i=>i())}if(e){const s=this.on(t,function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];e.call(this,...r),s()});return s}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const s=this.__eventListeners[t],i=s.indexOf(e);i>-1&&s.splice(i,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(t===void 0)for(const s in this.__eventListeners)this._removeEventListener(s);else typeof t=="object"?Object.entries(t).forEach(s=>{let[i,r]=s;this._removeEventListener(i,r)}):this._removeEventListener(t,e)}fire(t,e){var s;if(!this.__eventListeners)return;const i=(s=this.__eventListeners[t])===null||s===void 0?void 0:s.concat();if(i)for(let r=0;r<i.length;r++)i[r].call(this,e||{})}}const ne=(a,t)=>{const e=a.indexOf(t);return e!==-1&&a.splice(e,1),a},Ft=a=>{if(a===0)return 1;switch(Math.abs(a)/Le){case 1:case 3:return 0;case 2:return-1}return Math.cos(a)},Lt=a=>{if(a===0)return 0;const t=a/Le,e=Math.sign(a);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(a)};class y{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new y(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new y(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new y(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new y(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new y(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new y(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new y(this.x/t.x,this.y/t.y)}scalarDivide(t){return new y(this.x/t,this.y/t)}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(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new y(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,s=this.y-t.y;return Math.sqrt(e*e+s*s)}midPointFrom(t){return this.lerp(t)}min(t){return new y(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new y(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(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){const e=this.x,s=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=s}clone(){return new y(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mi;const s=Lt(t),i=Ft(t),r=this.subtract(e);return new y(r.x*i-r.y*s,r.x*s+r.y*i).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new y(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const mi=new y(0,0),gs=a=>!!a&&Array.isArray(a._objects);function Sr(a){class t extends a{constructor(){super(...arguments),p(this,"_objects",[])}_onObjectAdded(s){}_onObjectRemoved(s){}_onStackOrderChanged(s){}add(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];const n=this._objects.push(...i);
2return i.forEach(o=>this._onObjectAdded(o)),n}insertAt(s){for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];return this._objects.splice(s,0,...r),r.forEach(o=>this._onObjectAdded(o)),this._objects.length}remove(){const s=this._objects,i=[];for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return n.forEach(h=>{const c=s.indexOf(h);c!==-1&&(s.splice(c,1),i.push(h),this._onObjectRemoved(h))}),i}forEachObject(s){this.getObjects().forEach((i,r,n)=>s(i,r,n))}getObjects(){for(var s=arguments.length,i=new Array(s),r=0;r<s;r++)i[r]=arguments[r];return i.length===0?[...this._objects]:this._objects.filter(n=>n.isType(...i))}item(s){return this._objects[s]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(s,i){return!!this._objects.includes(s)||!!i&&this._objects.some(r=>r instanceof t&&r.contains(s,!0))}complexity(){return this._objects.reduce((s,i)=>s+=i.complexity?i.complexity():0,0)}sendObjectToBack(s){return!(!s||s===this._objects[0])&&(ne(this._objects,s),this._objects.unshift(s),this._onStackOrderChanged(s),!0)}bringObjectToFront(s){return!(!s||s===this._objects[this._objects.length-1])&&(ne(this._objects,s),this._objects.push(s),this._onStackOrderChanged(s),!0)}sendObjectBackwards(s,i){if(!s)return!1;const r=this._objects.indexOf(s);if(r!==0){const n=this.findNewLowerIndex(s,r,i);return ne(this._objects,s),this._objects.splice(n,0,s),this._onStackOrderChanged(s),!0}return!1}bringObjectForward(s,i){if(!s)return!1;const r=this._objects.indexOf(s);if(r!==this._objects.length-1){const n=this.findNewUpperIndex(s,r,i);return ne(this._objects,s),this._objects.splice(n,0,s),this._onStackOrderChanged(s),!0}return!1}moveObjectTo(s,i){return s!==this._objects[i]&&(ne(this._objects,s),this._objects.splice(i,0,s),this._onStackOrderChanged(s),!0)}findNewLowerIndex(s,i,r){let n;if(r){n=i;for(let o=i-1;o>=0;--o)if(s.isOverlapping(this._objects[o])){n=o;break}}else n=i-1;return n}findNewUpperIndex(s,i,r){let n;if(r){n=i;for(let o=i+1;o<this._objects.length;++o)if(s.isOverlapping(this._objects[o])){n=o;break}}else n=i+1;return n}collectObjects(s){let{left:i,top:r,width:n,height:o}=s,{includeIntersecting:h=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],l=new y(i,r),u=l.add(new y(n,o));for(let g=this._objects.length-1;g>=0;g--){const d=this._objects[g];d.selectable&&d.visible&&(h&&d.intersectsWithRect(l,u)||d.isContainedWithinRect(l,u)||h&&d.containsPoint(l)||h&&d.containsPoint(u))&&c.push(d)}return c}}return t}class wr extends En{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function ds(a){return ks().requestAnimationFrame(a)}function Pn(a){return ks().cancelAnimationFrame(a)}let An=0;const Ht=()=>An++,Rt=()=>{const a=de().createElement("canvas");if(!a||a.getContext===void 0)throw new St("Failed to create `canvas` element");return a},jn=()=>de().createElement("img"),gt=a=>{const t=Rt();return t.width=a.width,t.height=a.height,t},Tr=(a,t,e)=>a.toDataURL("image/".concat(t),e),Or=(a,t,e)=>new Promise((s,i)=>{a.toBlob(s,"image/".concat(t),e)}),V=a=>a*gi,Bt=a=>a/gi,Fn=a=>a.every((t,e)=>t===et[e]),st=(a,t,e)=>new y(a).transform(t,e),vt=a=>{const t=1/(a[0]*a[3]-a[1]*a[2]),e=[t*a[3],-t*a[1],-t*a[2],t*a[0],0,0],{x:s,y:i}=new y(a[4],a[5]).transform(e,!0);return e[4]=-s,e[5]=-i,e},Z=(a,t,e)=>[a[0]*t[0]+a[2]*t[1],a[1]*t[0]+a[3]*t[1],a[0]*t[2]+a[2]*t[3],a[1]*t[2]+a[3]*t[3],e?0:a[0]*t[4]+a[2]*t[5]+a[4],e?0:a[1]*t[4]+a[3]*t[5]+a[5]],vi=(a,t)=>a.reduceRight((e,s)=>s&&e?Z(s,e,t):s||e,void 0)||et.concat(),Dr=a=>{let[t,e]=a;return Math.atan2(e,t)},xs=a=>{const t=Dr(a),e=Math.pow(a[0],2)+Math.pow(a[1],2),s=Math.sqrt(e),i=(a[0]*a[3]-a[2]*a[1])/s,r=Math.atan2(a[0]*a[2]+a[1]*a[3],e);return{angle:Bt(t),scaleX:s,scaleY:i,skewX:Bt(r),skewY:0,translateX:a[4]||0,translateY:a[5]||0}},Re=function(a){return[1,0,0,1,a,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function me(){let{angle:a=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=V(a),i=Ft(s),r=Lt(s);return[i,r,-r,i,t?t-(i*t-r*e):0,e?e-(r*t+i*e):0]}const yi=function(a){return[a,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:a,0,0]},kr=a=>Math.tan(V(a)),Mr=a=>[1,0,kr(a),1,0,0],Er=a=>
2[1,kr(a),0,1,0,0],Ps=a=>{let{scaleX:t=1,scaleY:e=1,flipX:s=!1,flipY:i=!1,skewX:r=0,skewY:n=0}=a,o=yi(s?-t:t,i?-e:e);return r&&(o=Z(o,Mr(r),!0)),n&&(o=Z(o,Er(n),!0)),o},Ln=a=>{const{translateX:t=0,translateY:e=0,angle:s=0}=a;let i=Re(t,e);s&&(i=Z(i,me({angle:s})));const r=Ps(a);return Fn(r)||(i=Z(i,r)),i},fs=function(a){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(s,i){if(t&&t.aborted)return i(new wn("loadImage"));const r=jn();let n;t&&(n=function(h){r.src="",i(h)},t.addEventListener("abort",n,{once:!0}));const o=function(){r.onload=r.onerror=null,n&&(t==null||t.removeEventListener("abort",n)),s(r)};a?(r.onload=o,r.onerror=function(){n&&(t==null||t.removeEventListener("abort",n)),i(new St("Error loading ".concat(r.src)))},e&&(r.crossOrigin=e),r.src=a):o()})},Ee=function(a){let{signal:t,reviver:e=us}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((s,i)=>{const r=[];t&&t.addEventListener("abort",i,{once:!0}),Promise.all(a.map(n=>T.getClass(n.type).fromObject(n,{signal:t}).then(o=>(e(n,o),r.push(o),o)))).then(s).catch(n=>{r.forEach(o=>{o.dispose&&o.dispose()}),i(n)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},As=function(a){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,s)=>{const i=[];t&&t.addEventListener("abort",s,{once:!0});const r=Object.values(a).map(o=>o&&o.type&&T.has(o.type)?Ee([o],{signal:t}).then(h=>{let[c]=h;return i.push(c),c}):o),n=Object.keys(a);Promise.all(r).then(o=>o.reduce((h,c,l)=>(h[n[l]]=c,h),{})).then(e).catch(o=>{i.forEach(h=>{h.dispose&&h.dispose()}),s(o)}).finally(()=>{t&&t.removeEventListener("abort",s)})})},ve=function(a){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in a&&(t[e]=a[e]),t),{})},_i=(a,t)=>Object.keys(a).reduce((e,s)=>(t(a[s],s,a)&&(e[s]=a[s]),e),{}),I=(a,t)=>parseFloat(Number(a).toFixed(t)),Pe=a=>"matrix("+a.map(t=>I(t,E.NUM_FRACTION_DIGITS)).join(" ")+")",lt=a=>!!a&&a.toLive!==void 0,Fi=a=>!!a&&typeof a.toObject=="function",Li=a=>!!a&&a.offsetX!==void 0&&"source"in a,qt=a=>!!a&&"multiSelectionStacking"in a;function Pr(a){const t=a&&mt(a);let e=0,s=0;if(!a||!t)return{left:e,top:s};let i=a;const r=t.documentElement,n=t.body||{scrollLeft:0,scrollTop:0};for(;i&&(i.parentNode||i.host)&&(i=i.parentNode||i.host,i===t?(e=n.scrollLeft||r.scrollLeft||0,s=n.scrollTop||r.scrollTop||0):(e+=i.scrollLeft||0,s+=i.scrollTop||0),i.nodeType!==1||i.style.position!=="fixed"););return{left:e,top:s}}const mt=a=>a.ownerDocument||null,Ar=a=>{var t;return((t=a.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},jr=function(a,t,e){let{width:s,height:i}=e,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;a.width=s,a.height=i,r>1&&(a.setAttribute("width",(s*r).toString()),a.setAttribute("height",(i*r).toString()),t.scale(r,r))},si=(a,t)=>{let{width:e,height:s}=t;e&&(a.style.width=typeof e=="number"?"".concat(e,"px"):e),s&&(a.style.height=typeof s=="number"?"".concat(s,"px"):s)};function Ri(a){return a.onselectstart!==void 0&&(a.onselectstart=()=>!1),a.style.userSelect=rt,a}class Fr{constructor(t){p(this,"_originalCanvasStyle",void 0),p(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(s=t)&&s.getContext!==void 0?t:t&&de().getElementById(t)||Rt();var s;if(e.hasAttribute("data-fabric"))throw new St("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(t){let{width:e,height:s}=t;const{el:i}=this.lower;i.classList.remove("lower-canvas"),i.removeAttribute("data-fabric"),i.setAttribute("width","".concat(e)),i.setAttribute("height","".concat(s)),i.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:s,ctx:i}=this.lower;jr(s,i,t,e)}setCSSDimensions(t){si(this.lower.el,t)}calcOffset(){return function(t){var e;const s=t&&mt(t),i={left:0,top:0};if(!s)return i;const r=((e=Ar(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};i.left+=parseInt(r.borderLeftWidth,10)||0,i.top+=parseInt(r.borderTopWidth,10)||0,i.left+=parseInt(r.paddingLeft,10)||0,i.top+=parseInt(r.paddingTop,10)||0;let n={left:0,top:0};const o=s.documentElement;t.getBoundingClientRect!==void 0&&(n=t.getBoundingClientRect());const h=Pr(t);return{left:n.left+h.left-(o.clientLeft||0)+i.left,top:n.top+h.top-(o.clientTop||0)+i.top}}(this.lower.el)}dispose(){wt().dispose(this.lower.el),delete this.lower}}
vendor: 8,951 bytes, lines 2-7
2const Rn={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...et]},Bn=["objects"];class Be extends Sr(wr){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return Be.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};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}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new Fr(t)}add(){const t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];const r=super.insertAt(t,...s);return s.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),r}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(Gt("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?_r():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}setWidth(t,e){return this.setDimensions({width:t},e)}setHeight(t,e){return this.setDimensions({height:t},e)}_setDimensionsImpl(t){let{cssOnly:e=!1,backstoreOnly:s=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!e){const i=m({width:this.width,height:this.height},t);this.elements.setDimensions(i,this.getRetinaScaling()),this.hasLostContext=!0,this.width=i.width,this.height=i.height}s||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){const s=t,i=[...this.viewportTransform],r=st(t,vt(i));i[0]=e,i[3]=e;const n=st(r,i);i[4]+=s.x-n.x,i[5]+=s.y-n.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new y(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new y(-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=ds(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,s=vt(this.viewportTransform),i=st({x:0,y:0},s),r=st({x:t,y:e},s),n=i.min(r),o=i.max(r);return this.vptCoords={tl:n,tr:new y(o.x,n.y),bl:new y(n.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(Pn(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const s=this.viewportTransform,i=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),i&&(i._set("canvas",this),i.shouldCache(),i._transformDone=!0,i.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,i)),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){const s=this.viewportTransform;t.save(),t.transform(...s),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 s=0,i=e.length;s<i;++s)e[s]&&e[s].render(t)}_renderBackgroundOrOverlay(t,e){const s=this["".concat(e,"Color")],i=this["".concat(e,"Image")],r=this.viewportTransform,n=this["".concat(e,"Vpt")];if(!s&&!i)return;const o=lt(s);if(s){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?s.toLive(t):s,n&&t.transform(...r),o){t.transform(1,0,0,1,s.offsetX||0,s.offsetY||0);const h=s.gradientTransform||s.patternTransform;h&&t.transform(...h)}t.fill(),t.restore()}if(i){t.save();const{skipOffscreen:h}=this;this.skipOffscreen=n,n&&t.transform(...r),i.render(t),this.skipOffscreen=h,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new y(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new y(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new y(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 y(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new y(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return st(this.getCenterPoint(),vt(this.viewportTransform))}_centerObject(t,e){t.setXY(e,k,k),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){const s=this.clipPath,i=s&&!s.excludeFromExport?this._toObject(s,t,e):null;return m(m(m({version:ti},ve(this,e)),{},{objects:this._objects.filter(r=>!r.excludeFromExport).map(r=>this._toObject(r,t,e))},this.__serializeBgOverlay(t,e)),i?{clipPath:i}:null)}_toObject(t,e,s){let i;this.includeDefaultValues||(i=t.includeDefaultValues,t.includeDefaultValues=!1);const r=t[e](s);return this.includeDefaultValues||(t.includeDefaultValues=!!i),r}__serializeBgOverlay(t,e){const s={},i=this.backgroundImage,r=this.overlayImage,n=this.backgroundColor,o=this.overlayColor;return lt(n)?n.excludeFromExport||(s.background=n.toObject(e)):n&&(s.background=n),lt(o)?o.excludeFromExport||(s.overlay=o.toObject(e)):o&&(s.overlay=o),i&&!i.excludeFromExport&&(s.backgroundImage=this._toObject(i,t,e)),r&&!r.excludeFromExport&&(s.overlayImage=this._toObject(r,t,e)),s}toSVG(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;const s=[];return this._setSVGPreamble(s,t),this._setSVGHeader(s,t),this.clipPath&&s.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,`)" >
4`)),this._setSVGBgOverlayColor(s,"background"),this._setSVGBgOverlayImage(s,"backgroundImage",e),this._setSVGObjects(s,e),this.clipPath&&s.push(`</g>
5`),this._setSVGBgOverlayColor(s,"overlay"),this._setSVGBgOverlayImage(s,"overlayImage",e),s.push("</svg>"),s.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){const s=e.width||"".concat(this.width),i=e.height||"".concat(this.height),r=E.NUM_FRACTION_DIGITS,n=e.viewBox;let o;
7if(n)o='viewBox="'.concat(n.x," ").concat(n.y," ").concat(n.width," ").concat(n.height,'" ');else if(this.svgViewportTransformation){const h=this.viewportTransform;o='viewBox="'.concat(I(-h[4]/h[0],r)," ").concat(I(-h[5]/h[3],r)," ").concat(I(this.width/h[0],r)," ").concat(I(this.height/h[3],r),'" ')}else o='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',s,'" ','height="',i,'" ',o,`xml:space="preserve">
8`,"<desc>Created with Fabric.js ",ti,`</desc>
9`,`<defs>
10`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
11`)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(Ht()),'<clipPath id="'.concat(e.clipPathId,`" >
12`).concat(e.toClipPathSVG(t.reviver),`</clipPath>
13`)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(lt(e)){const s=this["".concat(t,"Vpt")],i=this.viewportTransform,r={isType:()=>!1,width:this.width/(s?i[0]:1),height:this.height/(s?i[3]:1)};return e.toSVG(r,{additionalTransform:s?Pe(i):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},s=E.fontPaths;this._objects.forEach(function r(n){t.push(n),gs(n)&&n._objects.forEach(r)}),t.forEach(r=>{if(!(n=r)||typeof n._renderText!="function")return;var n;const{styles:o,fontFamily:h}=r;!e[h]&&s[h]&&(e[h]=!0,o&&Object.values(o).forEach(c=>{Object.values(c).forEach(l=>{let{fontFamily:u=""}=l;!e[u]&&s[u]&&(e[u]=!0)})}))});const i=Object.keys(e).map(r=>`		@font-face {
14			font-family: '`.concat(r,`';
15			src: url('`).concat(s[r],`');
16		}
17`)).join("");return i?`	<style type="text/css"><![CDATA[
18`.concat(i,`]]></style>
19`):""}_setSVGObjects(t,e){this.forEachObject(s=>{s.excludeFromExport||this._setSVGObject(t,s,e)})}_setSVGObject(t,e,s){t.push(e.toSVG(s))}_setSVGBgOverlayImage(t,e,s){const i=this[e];i&&!i.excludeFromExport&&i.toSVG&&t.push(i.toSVG(s))}_setSVGBgOverlayColor(t,e){const s=this["".concat(e,"Color")];if(s)if(lt(s)){const i=s.repeat||"",r=this.width,n=this.height,o=this["".concat(e,"Vpt")]?Pe
vendor: 51,506 bytes, lines 19-37
19(vt(this.viewportTransform)):"";t.push('<rect transform="'.concat(o," translate(").concat(r/2,",").concat(n/2,')" x="').concat(s.offsetX-r/2,'" y="').concat(s.offsetY-n/2,'" width="').concat(i!=="repeat-y"&&i!=="no-repeat"||!Li(s)?r:s.source.width,'" height="').concat(i!=="repeat-x"&&i!=="no-repeat"||!Li(s)?n:s.source.height,'" fill="url(#SVGID_').concat(s.id,`)"></rect>
20`))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',s,'"',`></rect>
21`)}loadFromJSON(t,e){let{signal:s}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new St("`json` is undefined"));const i=typeof t=="string"?JSON.parse(t):t,{objects:r=[]}=i,n=X(i,Bn),{backgroundImage:o,background:h,overlayImage:c,overlay:l,clipPath:u}=n,g=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Ee(r,{reviver:e,signal:s}),As({backgroundImage:o,backgroundColor:h,overlayImage:c,overlayColor:l,clipPath:u},{signal:s})]).then(d=>{let[f,v]=d;return this.clear(),this.add(...f),this.set(n),this.set(v),this.renderOnAddRemove=g,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=gt(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:s=1,multiplier:i=1,enableRetinaScaling:r=!1}=t,n=i*(r?this.getRetinaScaling():1);return Tr(this.toCanvasElement(n,t),e,s)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:s=1,multiplier:i=1,enableRetinaScaling:r=!1}=t,n=i*(r?this.getRetinaScaling():1);return Or(this.toCanvasElement(n,t),e,s)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:s,left:i,top:r,filter:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=(e||this.width)*t,h=(s||this.height)*t,c=this.getZoom(),l=this.width,u=this.height,g=this.skipControlsDrawing,d=c*t,f=this.viewportTransform,v=[d,0,0,d,(f[4]-(i||0))*t,(f[5]-(r||0))*t],_=this.enableRetinaScaling,x=gt({width:o,height:h}),C=n?this._objects.filter(S=>n(S)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=v,this.width=o,this.height=h,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(x.getContext("2d"),C),this.viewportTransform=f,this.width=l,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=_,this.skipControlsDrawing=g,x}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),_s.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{const s=()=>{this.destroy(),t(!0)};s.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=s:s()})}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 (".concat(this.complexity(),"): { objects: ").concat(this._objects.length," }>")}}p(Be,"ownDefaults",Rn);const In=["touchstart","touchmove","touchend"],Xn=a=>{const t=Pr(a.target),e=function(s){const i=s.changedTouches;return i&&i[0]?i[0]:s}(a);return new y(e.clientX+t.left,e.clientY+t.top)},ii=a=>In.includes(a.type)||a.pointerType==="touch",Bi=a=>{a.preventDefault(),a.stopPropagation()},At=a=>{let t=0,e=0,s=0,i=0;for(let r=0,n=a.length;r<n;r++){const{x:o,y:h}=a[r];(o>s||!r)&&(s=o),(o<t||!r)&&(t=o),(h>i||!r)&&(i=h),(h<e||!r)&&(e=h)}return{left:t,top:e,width:s-t,height:i-e}},Wn=["translateX","translateY","scaleX","scaleY"],Yn=(a,t)=>Cs(a,Z(t,a.calcOwnMatrix())),Cs=(a,t)=>{const e=xs(t),{translateX:s,translateY:i,scaleX:r,scaleY:n}=e,o=X(e,Wn),h=new y(s,i);a.flipX=!1,a.flipY=!1,Object.assign(a,o),a.set({scaleX:r,scaleY:n}),a.setPositionByOrigin(h,k,k)},Vn=a=>{a.scaleX=1,a.scaleY=1,a.skewX=0,a.skewY=0,a.flipX=!1,a.flipY=!1,a.rotate(0)},Lr=a=>({scaleX:a.scaleX,scaleY:a.scaleY,skewX:a.skewX,skewY:a.skewY,angle:a.angle,left:a.left,flipX:a.flipX,flipY:a.flipY,top:a.top}),xi=(a,t,e)=>{const s=a/2,i=t/2,r=[new y(-s,-i),new y(s,-i),new y(-s,i),new y(s,i)].map(o=>o.transform(e)),n=At(r);return new y(n.width,n.height)},js=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:et;return Z(vt(arguments.length>1&&arguments[1]!==void 0?arguments[1]:et),a)},ce=function(a){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:et,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:et;return a.transform(js(t,e))},zn=function(a){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:et,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:et;return a.transform(js(t,e),!0)},Gn=(a,t,e)=>{const s=js(t,e);return Cs(a,Z(s,a.calcOwnMatrix())),s},Rr=(a,t)=>{var e;const{transform:{target:s}}=t;(e=s.canvas)===null||e===void 0||e.fire("object:".concat(a),m(m({},t),{},{target:s})),s.fire(a,t)},Hn={left:-.5,top:-.5,center:0,bottom:.5,right:.5},z=a=>typeof a=="string"?Hn[a]:a-.5,bs="not-allowed";function Br(a){return z(a.originX)===z(k)&&z(a.originY)===z(k)}function Ii(a){return .5-z(a)}const _t=(a,t)=>a[t],Ir=(a,t,e,s)=>({e:a,transform:t,pointer:new y(e,s)});function Xr(a,t){const e=a.getTotalAngle()+Bt(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Ci(a,t,e,s,i){var r;let{target:n,corner:o}=a;const h=n.controls[o],c=((r=n.canvas)===null||r===void 0?void 0:r.getZoom())||1,l=n.padding/c,u=function(g,d,f,v){const _=g.getRelativeCenterPoint(),x=f!==void 0&&v!==void 0?g.translateToGivenOrigin(_,k,k,f,v):new y(g.left,g.top);return(g.angle?d.rotate(-V(g.angle),_):d).subtract(x)}(n,new y(s,i),t,e);return u.x>=l&&(u.x-=l),u.x<=-l&&(u.x+=l),u.y>=l&&(u.y-=l),u.y<=l&&(u.y+=l),u.x-=h.offsetX,u.y-=h.offsetY,u}const Nn=(a,t,e,s)=>{const{target:i,offsetX:r,offsetY:n}=t,o=e-r,h=s-n,c=!_t(i,"lockMovementX")&&i.left!==o,l=!_t(i,"lockMovementY")&&i.top!==h;return c&&i.set(j,o),l&&i.set(it,h),(c||l)&&Rr(xr,Ir(a,t,e,s)),c||l},Ss=a=>a.replace(/\s+/g," "),Xi={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"},Vs=(a,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?a+6*(t-a)*e:e<.5?t:e<2/3?a+(t-a)*(2/3-e)*6:a),Wi=(a,t,e,s)=>{a/=255,t/=255,e/=255;const i=Math.max(a,t,e),r=Math.min(a,t,e);let n,o;const h=(i+r)/2;if(i===r)n=o=0;else{const c=i-r;switch(o=h>.5?c/(2-i-r):c/(i+r),i){case a:n=(t-e)/c+(t<e?6:0);break;case t:n=(e-a)/c+2;break;case e:n=(a-t)/c+4}n/=6}return[Math.round(360*n),Math.round(100*o),Math.round(100*h),s]},Yi=function(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(a)/(a.endsWith("%")?100:1)},We=a=>Math.min(Math.round(a),255).toString(16).toUpperCase().padStart(2,"0"),Vi=a=>{let[t,e,s,i=1]=a;const r=Math.round(.3*t+.59*e+.11*s);return[r,r,r,i]};class F{constructor(t){if(p(this,"isUnrecognised",!1),t)if(t instanceof F)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,s,i,r=1]=t;this.setSource([e,s,i,r])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in Xi&&(t=Xi[t]),t==="transparent"?[255,255,255,0]:F.sourceFromHex(t)||F.sourceFromRgb(t)||F.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,s]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(s,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,s]=Wi(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(s,"%)")}toHsla(){const[t,e,s,i]=Wi(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(s,"%,").concat(i,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,s,i]=this.getSource();return"".concat(We(t)).concat(We(e)).concat(We(s)).concat(We(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Vi(this.getSource())),this}toBlackWhite(t){const[e,,,s]=Vi(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,s]),this}overlayWith(t){t instanceof F||(t=new F(t));const e=this.getSource(),s=t.getSource(),[i,r,n]=e.map((o,h)=>Math.round(.5*o+.5*s[h]));return this.setSource([i,r,n,e[3]]),this}static fromRgb(t){return F.fromRgba(t)}static fromRgba(t){return new F(F.sourceFromRgb(t))}static sourceFromRgb(t){const e=Ss(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){const[s,i,r]=e.slice(1,4).map(n=>{const o=parseFloat(n);return n.endsWith("%")?Math.round(2.55*o):o});return[s,i,r,Yi(e[4])]}}static fromHsl(t){return F.fromHsla(t)}static fromHsla(t){return new F(F.sourceFromHsl(t))}static sourceFromHsl(t){const e=Ss(t).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(!e)return;const s=(F.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,r=parseFloat(e[3])/100;let n,o,h;if(i===0)n=o=h=r;else{const c=r<=.5?r*(i+1):r+i-r*i,l=2*r-c;n=Vs(l,c,s+1/3),o=Vs(l,c,s),h=Vs(l,c,s-1/3)}return[Math.round(255*n),Math.round(255*o),Math.round(255*h),Yi(e[4])]}static fromHex(t){return new F(F.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let s;s=e.length<=4?e.split("").map(h=>h+h):e.match(/.{2}/g);const[i,r,n,o=255]=s.map(h=>parseInt(h,16));return[i,r,n,o/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),s=parseFloat(e);return e.includes("rad")?Bt(s):e.includes("turn")?360*s:s}}const le=function(a){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:di;const e=/\D{0,2}$/.exec(a),s=parseFloat(a),i=E.DPI;switch(e==null?void 0:e[0]){case"mm":return s*i/25.4;case"cm":return s*i/2.54;case"in":return s*i;case"pt":return s*i/72;case"pc":return s*i/72*12;case"em":return s*t;default:return s}},Un=a=>{const[t,e]=a.trim().split(" "),[s,i]=(r=t)&&r!==rt?[r.slice(1,4),r.slice(5,8)]:r===rt?[r,r]:["Mid","Mid"];var r;return{meetOrSlice:e||"meet",alignX:s,alignY:i}},Ae=function(a,t){let e,s,i=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const r=new F(t),n=r.getAlpha();e=r.toRgb(),n!==1&&(s=n.toString())}else e="none";return i?"".concat(a,": ").concat(e,"; ").concat(s?"".concat(a,"-opacity: ").concat(s,"; "):""):"".concat(a,'="').concat(e,'" ').concat(s?"".concat(a,'-opacity="').concat(s,'" '):"")};class Wr{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",s=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):rt,r=this.strokeDashOffset?this.strokeDashOffset:"0",n=this.strokeLineCap?this.strokeLineCap:"butt",o=this.strokeLineJoin?this.strokeLineJoin:"miter",h=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",l=this.visible?"":" visibility: hidden;",u=t?"":this.getSvgFilter(),g=Ae(H,this.fill);return[Ae(nt,this.stroke),"stroke-width: ",s,"; ","stroke-dasharray: ",i,"; ","stroke-linecap: ",n,"; ","stroke-dashoffset: ",r,"; ","stroke-linejoin: ",o,"; ","stroke-miterlimit: ",h,"; ",g,"fill-rule: ",e,"; ","opacity: ",c,";",u,l].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const s=t?this.calcTransformMatrix():this.calcOwnMatrix(),i='transform="'.concat(Pe(s));return"".concat(i).concat(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){let{reviver:e,additionalTransform:s=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[this.getSvgTransform(!0,s),this.getSvgCommons()].join(""),r=t.indexOf("COMMON_PARTS");return t[r]=i,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:s,withShadow:i,additionalTransform:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const n=e?"":'style="'.concat(this.getSvgStyles(),'" '),o=i?'style="'.concat(this.getSvgFilter(),'" '):"",h=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",l=h&&h.absolutePositioned,u=this.stroke,g=this.fill,d=this.shadow,f=[],v=t.indexOf("COMMON_PARTS");let _;h&&(h.clipPathId="CLIPPATH_".concat(Ht()),_='<clipPath id="'.concat(h.clipPathId,`" >
22`).concat(h.toClipPathSVG(s),`</clipPath>
23`)),l&&f.push("<g ",o,this.getSvgCommons(),` >
24`),f.push("<g ",this.getSvgTransform(!1),l?"":o+this.getSvgCommons(),` >
25`);const x=[n,c,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[v]=x,lt(g)&&f.push(g.toSVG(this)),lt(u)&&f.push(u.toSVG(this)),d&&f.push(d.toSVG(this)),h&&f.push(_),f.push(t.join("")),f.push(`</g>
26`),l&&f.push(`</g>
27`),s?s(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==H?' paint-order="'.concat(this.paintFirst,'" '):""}}function Fs(a){return new RegExp("^("+a.join("|")+")\\b","i")}const ee="textDecorationThickness",Yr=["fontSize","fontWeight","fontFamily","fontStyle"],Vr=["underline","overline","linethrough"],zr=[...Yr,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Gr=[...zr,...Vr,"textBackgroundColor","direction",ee],qn=[...Yr,...Vr,nt,"strokeWidth",H,"deltaY","textBackgroundColor",ee],Kn={_reNewline:fi,_reSpacesAndTabs:/[ \t\r]/g,_reSpaceAndTab:/[ \t\r]/,_reWords:/\S+/g,fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",underline:!1,overline:!1,linethrough:!1,textAlign:j,fontStyle:"normal",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,[ee]:66.667},bt="justify",ws="justify-left",Oe="justify-right",De="justify-center";var zi,Gi,Hi;const yt=String.raw(zi||(zi=Tt(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),zs=String.raw(Gi||(Gi=Tt(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),Jn=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+yt+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+yt+"))?\\s+(.*)"),Zn={cx:j,x:j,r:"radius",cy:it,y:it,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":ee},Gs="font-size",Hs="clip-path";Fs(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);Fs(["symbol","image","marker","pattern","view","svg"]);const Ni=Fs(["symbol","g","a","svg","clipPath","defs"]);new RegExp(String.raw(Hi||(Hi=Tt(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),yt,zs,yt,zs,yt,zs,yt));const $n=new y(1,0),Hr=new y,Nr=(a,t)=>a.rotate(t),ri=(a,t)=>new y(t).subtract(a),ni=a=>a.distanceFrom(Hr),oi=(a,t)=>Math.atan2(ke(a,t),to(a,t)),Qn=a=>oi($n,a),bi=a=>a.eq(Hr)?a:a.scalarDivide(ni(a)),Ur=function(a){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return bi(new y(-a.y,a.x).scalarMultiply(t?1:-1))},ke=(a,t)=>a.x*t.y-a.y*t.x,to=(a,t)=>a.x*t.x+a.y*t.y,Ui=(a,t,e)=>{if(a.eq(t)||a.eq(e))return!0;const s=ke(t,e),i=ke(t,a),r=ke(e,a);return s>=0?i>=0&&r<=0:!(i<=0&&r>=0)},qi="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Ki=new RegExp("(?:\\s|^)"+qi+qi+"("+yt+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class jt{constructor(t){const e=typeof t=="string"?jt.parseShadow(t):t;Object.assign(this,jt.ownDefaults,e),this.id=Ht()}static parseShadow(t){const e=t.trim(),[,s=0,i=0,r=0]=(Ki.exec(e)||[]).map(n=>parseFloat(n)||0);return{color:(e.replace(Ki,"")||"rgb(0,0,0)").trim(),offsetX:s,offsetY:i,blur:r}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=Nr(new y(this.offsetX,this.offsetY),V(-t.angle)),s=new F(this.color);let i=40,r=40;return t.width&&t.height&&(i=100*I((Math.abs(e.x)+this.blur)/t.width,E.NUM_FRACTION_DIGITS)+20,r=100*I((Math.abs(e.y)+this.blur)/t.height,E.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(r,'%" height="').concat(100+2*r,'%" x="-').concat(i,'%" width="').concat(100+2*i,`%" >
28	<feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(I(this.blur?this.blur/2:0,E.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
29	<feOffset dx="`).concat(I(e.x,E.NUM_FRACTION_DIGITS),'" dy="').concat(I(e.y,E.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
30	<feFlood flood-color="`).concat(s.toRgb(),'" flood-opacity="').concat(s.getAlpha(),`"/>
31	<feComposite in2="oBlur" operator="in" />
32	<feMerge>
33		<feMergeNode></feMergeNode>
34		<feMergeNode in="SourceGraphic"></feMergeNode>
35	</feMerge>
36</filter>
37`)}toObject(){const t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=jt.ownDefaults;return this.includeDefaultValues?t:_i(t,(s,i)=>s!==e[i])}static async fromObject(t){return new this(t)}}p(jt,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),p(jt,"type","shadow"),T.setClass(jt,"shadow");const ge=(a,t,e)=>Math.max(a,Math.min(t,e)),eo=[it,j,ot,ut,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",fe,pe],It=[H,nt,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],so={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:j,originY:it,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:H,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},io=(a,t,e,s)=>-e*Math.cos(a/s*Le)+e+t,ro=()=>!1;class Si{constructor(t){let{startValue:e,byValue:s,duration:i=500,delay:r=0,easing:n=io,onStart:o=us,onChange:h=us,onComplete:c=us,abort:l=ro,target:u}=t;p(this,"_state","pending"),p(this,"durationProgress",0),p(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=i,this.delay=r,this.easing=n,this._onStart=o,this._onChange=h,this._onComplete=c,this._abort=l,this.target=u,this.startValue=e,this.byValue=s,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}get state(){return this._state}isDone(){return this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>ds(t),this.delay):ds(t)}tick(t){const e=(t||+new Date)-this.startTime,s=Math.min(e,this.duration);this.durationProgress=s/this.duration;const{value:i,valueProgress:r}=this.calculate(s);this.value=Object.freeze(i),this.valueProgress=r,this._state!=="aborted"&&(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._onChange(this.value,this.valueProgress,this.durationProgress),ds(this.tick)))}register(){_s.push(this)}unregister(){_s.remove(this)}abort(){this._state="aborted",this.unregister()}}const no=["startValue","endValue"];class oo extends Si{constructor(t){let{startValue:e=0,endValue:s=100}=t;super(m(m({},X(t,no)),{},{startValue:e,byValue:s-e}))}calculate(t){const e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}}const ao=["startValue","endValue"];class ho extends Si{constructor(t){let{startValue:e=[0],endValue:s=[100]}=t;super(m(m({},X(t,ao)),{},{startValue:e,byValue:s.map((i,r)=>i-e[r])}))}calculate(t){const e=this.startValue.map((s,i)=>this.easing(t,s,this.byValue[i],this.duration,i));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const co=["startValue","endValue","easing","onChange","onComplete","abort"],lo=(a,t,e,s)=>t+e*(1-Math.cos(a/s*Le)),Ns=a=>a&&((t,e,s)=>a(new F(t).toRgba(),e,s));class uo extends Si{constructor(t){let{startValue:e,endValue:s,easing:i=lo,onChange:r,onComplete:n,abort:o}=t,h=X(t,co);const c=new F(e).getSource(),l=new F(s).getSource();super(m(m({},h),{},{startValue:c,byValue:l.map((u,g)=>u-c[g]),easing:i,onChange:Ns(r),onComplete:Ns(n),abort:Ns(o)}))}calculate(t){const[e,s,i,r]=this.startValue.map((o,h)=>this.easing(t,o,this.byValue[h],this.duration,h)),n=[...[e,s,i].map(Math.round),ge(0,r,1)];return{value:n,valueProgress:n.map((o,h)=>this.byValue[h]!==0?Math.abs((o-this.startValue[h])/this.byValue[h]):0).find(o=>o!==0)||0}}}function qr(a){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(a)?new ho(a):new oo(a);return t.start(),t}function go(a){const t=new uo(a);return t.start(),t}class W{constructor(t){this.status=t,this.points=[]}includes(t){return this.points.some(e=>e.eq(t))}append(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return this.points=this.points.concat(e.filter(i=>!this.includes(i))),this}static isPointContained(t,e,s){let i=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e.eq(s))return t.eq(e);if(e.x===s.x)return t.x===e.x&&(i||t.y>=Math.min(e.y,s.y)&&t.y<=Math.max(e.y,s.y));if(e.y===s.y)return t.y===e.y&&(i||t.x>=Math.min(e.x,s.x)&&t.x<=Math.max(e.x,s.x));{const r=ri(e,s),n=ri(e,t).divide(r);return i?Math.abs(n.x)===Math.abs(n.y):n.x===n.y&&n.x>=0&&n.x<=1}}static isPointInPolygon(t,e){const s=new y(t).setX(Math.min(t.x-1,...e.map(r=>r.x)));let i=0;for(let r=0;r<e.length;r++){const n=this.intersectSegmentSegment(e[r],e[(r+1)%e.length],t,s);if(n.includes(t))return!0;i+=+(n.status==="Intersection")}return i%2==1}static intersectLineLine(t,e,s,i){let r=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],n=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const o=e.x-t.x,h=e.y-t.y,c=i.x-s.x,l=i.y-s.y,u=t.x-s.x,g=t.y-s.y,d=c*g-l*u,f=o*g-h*u,v=l*o-c*h;if(v!==0){const _=d/v,x=f/v;return(r||0<=_&&_<=1)&&(n||0<=x&&x<=1)?new W("Intersection").append(new y(t.x+_*o,t.y+_*h)):new W}if(d===0||f===0){const _=r||n||W.isPointContained(t,s,i)||W.isPointContained(e,s,i)||W.isPointContained(s,t,e)||W.isPointContained(i,t,e);return new W(_?"Coincident":void 0)}return new W("Parallel")}static intersectSegmentLine(t,e,s,i){return W.intersectLineLine(t,e,s,i,!1,!0)}static intersectSegmentSegment(t,e,s,i){return W.intersectLineLine(t,e,s,i,!1,!1)}static intersectLinePolygon(t,e,s){let i=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const r=new W,n=s.length;for(let o,h,c,l=0;l<n;l++){if(o=s[l],h=s[(l+1)%n],c=W.intersectLineLine(t,e,o,h,i,!1),c.status==="Coincident")return c;r.append(...c.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,s){return W.intersectLinePolygon(t,e,s,!1)}static intersectPolygonPolygon(t,e){const s=new W,i=t.length,r=[];for(let n=0;n<i;n++){const o=t[n],h=t[(n+1)%i],c=W.intersectSegmentPolygon(o,h,e);c.status==="Coincident"?(r.push(c),s.append(o,h)):s.append(...c.points)}return r.length>0&&r.length===t.length?new W("Coincident"):(s.points.length>0&&(s.status="Intersection"),s)}static intersectPolygonRectangle(t,e,s){const i=e.min(s),r=e.max(s),n=new y(r.x,i.y),o=new y(i.x,r.y);return W.intersectPolygonPolygon(t,[i,n,r,o])}}class fo extends wr{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(){const t=this.getRelativeXY();return this.group?st(t,this.group.calcTransformMatrix()):t}setXY(t,e,s){this.group&&(t=st(t,vt(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,s)}getRelativeXY(){return new y(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.originY;this.setPositionByOrigin(t,e,s)}isStrokeAccountedForInDimensions(){return!1}getCoords(){const{tl:t,tr:e,br:s,bl:i}=this.aCoords||(this.aCoords=this.calcACoords()),r=[t,e,s,i];if(this.group){const n=this.group.calcTransformMatrix();return r.map(o=>st(o,n))}return r}intersectsWithRect(t,e){return W.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=W.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){const{left:s,top:i,width:r,height:n}=this.getBoundingRect();return s>=t.x&&s+r<=e.x&&i>=t.y&&i+n<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return W.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(s=>s.x<=e.x&&s.x>=t.x&&s.y<=e.y&&s.y>=t.y)||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;const{tl:t,br:e}=this.canvas.vptCoords;return this.intersectsWithRect(t,e)?!0:this.getCoords().every(s=>(s.x>=e.x||s.x<=t.x)&&(s.y>=e.y||s.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return At(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(ot,t),this._set(ut,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?Bt(Dr(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||et.concat()}calcACoords(){const t=me({angle:this.angle}),{x:e,y:s}=this.getRelativeCenterPoint(),i=Re(e,s),r=Z(i,t),n=this._getTransformedDimensions(),o=n.x/2,h=n.y/2;return{tl:st({x:-o,y:-h},r),tr:st({x:o,y:-h},r),bl:st({x:-o,y:h},r),br:st({x:o,y:h},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],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,z(this.originX),z(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const s=this.transformMatrixKey(t),i=this.matrixCache;return i&&i.key.every((r,n)=>r===s[n])?i.value:(this.group&&(e=Z(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:s,value:e},e)}calcOwnMatrix(){const t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;const s=this.getRelativeCenterPoint(),i={angle:this.angle,translateX:s.x,translateY:s.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY},r=Ln(i);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new y(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=m({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),s=e.strokeWidth;let i=s,r=0;this.strokeUniform&&(i=0,r=s);const n=e.width+i,o=e.height+i;let h;return h=e.skewX===0&&e.skewY===0?new y(n*e.scaleX,o*e.scaleY):xi(n,o,Ps(e)),h.scalarAdd(r)}translateToGivenOrigin(t,e,s,i,r){let n=t.x,o=t.y;const h=z(i)-z(e),c=z(r)-z(s);if(h||c){const l=this._getTransformedDimensions();n+=h*l.x,o+=c*l.y}return new y(n,o)}translateToCenterPoint(t,e,s){if(e===k&&s===k)return t;const i=this.translateToGivenOrigin(t,e,s,k,k);return this.angle?i.rotate(V(this.angle),t):i}translateToOriginPoint(t,e,s){const i=this.translateToGivenOrigin(t,k,k,e,s);return this.angle?i.rotate(V(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?st(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new y(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,s){const i=this.translateToCenterPoint(t,e,s),r=this.translateToOriginPoint(i,this.originX,this.originY);this.set({left:r.x,top:r.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),j,it)}}const po=["type"],mo=["extraParam"];let Dt=class ps extends fo{static getDefaults(){return ps.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){Gt("warn","Setting type has no effect",t)}constructor(t){super(),p(this,"_cacheContext",null),Object.assign(this,ps.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=Rt(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,s=t.height,i=E.maxCacheSideLimit,r=E.minCacheSideLimit;if(e<=i&&s<=i&&e*s<=E.perfLimitSizeTotal)return e<r&&(t.width=r),s<r&&(t.height=r),t;const n=e/s,[o,h]=Te.limitDimsByArea(n),c=ge(r,o,i),l=ge(r,h,i);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),s>l&&(t.zoomY/=s/l,t.height=l,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),s=e.x*t.x/this.scaleX,i=e.y*t.y/this.scaleY;return{width:Math.ceil(s+2),height:Math.ceil(i+2),zoomX:t.x,zoomY:t.y,x:s,y:i}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:s,height:i,zoomX:r,zoomY:n,x:o,y:h}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=s!==t.width||i!==t.height,l=this.zoomX!==r||this.zoomY!==n;if(!t||!e)return!1;if(c||l){s!==t.width||i!==t.height?(t.width=s,t.height=i):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const u=o/2,g=h/2;return this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-g)+g,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(r,n),this.zoomX=r,this.zoomY=n,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,s=this.calcTransformMatrix(!e);t.transform(s[0],s[1],s[2],s[3],s[4],s[5])}getObjectScaling(){if(!this.group)return new y(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=xs(this.calcTransformMatrix());return new y(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),s=this.getCanvasRetinaScaling();return t.scalarMultiply(e*s)}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:t===0?1e-4:t}_set(t,e){t!==ot&&t!==ut||(e=this._constrainScale(e)),t===ot&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof jt||(e=new jt(e));const s=this[t]!==e;return this[t]=e,s&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||s&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(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){const{zoomX:e,zoomY:s,cacheTranslationX:i,cacheTranslationY:r}=this,{width:n,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:s,cacheTranslationX:i,cacheTranslationY:r,width:n,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===nt&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,s){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(s,0,0),t.restore()}drawObject(t,e,s){const i=this.fill,r=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,s),this.fill=i,this.stroke=r}createClipPathLayer(t,e){const s=gt(e),i=s.getContext("2d");if(i.translate(e.cacheTranslationX,e.cacheTranslationY),i.scale(e.zoomX,e.zoomY),t._cacheCanvas=s,e.parentClipPaths.forEach(r=>{r.transform(i)}),e.parentClipPaths.push(t),t.absolutePositioned){const r=vt(this.calcTransformMatrix());i.transform(r[0],r[1],r[2],r[3],r[4],r[5])}return t.transform(i),t.drawObject(i,!0,e),s}_drawClipPath(t,e,s){if(!e)return;e._transformDone=!0;const i=this.createClipPathLayer(e,s);this.drawClipPathOnCache(t,e,i)}drawCacheOnCanvas(t){t.scale(1/this.zoomX,1/this.zoomY),t.drawImage(this._cacheCanvas,-this.cacheTranslationX,-this.cacheTranslationY)}isCacheDirty(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(this.isNotVisible())return!1;const e=this._cacheCanvas,s=this._cacheContext;return!(!e||!s||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&s&&!t&&(s.save(),s.setTransform(1,0,0,1,0,0),s.clearRect(0,0,e.width,e.height),s.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;const 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){const s=e.stroke;s&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,lt(s)?s.gradientUnits==="percentage"||s.gradientTransform||s.patternTransform?this._applyPatternForTransformedGradient(t,s):(t.strokeStyle=s.toLive(t),this._applyPatternGradientTransform(t,s)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:s}=e;s&&(lt(s)?(t.fillStyle=s.toLive(t),this._applyPatternGradientTransform(t,s)):t.fillStyle=s)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,s=this.canvas,i=this.getCanvasRetinaScaling(),[r,,,n]=(s==null?void 0:s.viewportTransform)||et,o=r*i,h=n*i,c=e.nonScaling?new y(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*E.browserShadowBlurConstant*(o+h)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*o*c.x,t.shadowOffsetY=e.offsetY*h*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!lt(e))return{offsetX:0,offsetY:0};const s=e.gradientTransform||e.patternTransform,i=-this.width/2+e.offsetX||0,r=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,i,r):t.transform(1,0,0,1,i,r),s&&t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),{offsetX:i,offsetY:r}}_renderPaintInOrder(t){this.paintFirst===nt?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const 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 s;const i=this._limitCacheSize(this._getCacheCanvasDimensions()),r=this.getCanvasRetinaScaling(),n=i.x/this.scaleX/r,o=i.y/this.scaleY/r,h=gt({width:Math.ceil(n),height:Math.ceil(o)}),c=h.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(n,0),c.lineTo(n,o),c.lineTo(0,o),c.closePath(),c.translate(n/2,o/2),c.scale(i.zoomX/this.scaleX/r,i.zoomY/this.scaleY/r),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(r*this.scaleX/i.zoomX,r*this.scaleY/i.zoomY),t.strokeStyle=(s=c.createPattern(h,"no-repeat"))!==null&&s!==void 0?s:"")}_findCenterFromElement(){return new y(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(T.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=Lr(this),s=this.group,i=this.shadow,r=Math.abs,n=t.enableRetinaScaling?_r():1,o=(t.multiplier||1)*n,h=t.canvasProvider||(C=>new Be(C,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Vn(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Gn(this,this.getViewportTransform()),this.setCoords();const c=Rt(),l=this.getBoundingRect(),u=this.shadow,g=new y;if(u){const C=u.blur,S=u.nonScaling?new y(1,1):this.getObjectScaling();g.x=2*Math.round(r(u.offsetX)+C)*r(S.x),g.y=2*Math.round(r(u.offsetY)+C)*r(S.y)}const d=l.width+g.x,f=l.height+g.y;c.width=Math.ceil(d),c.height=Math.ceil(f);const v=h(c);t.format==="jpeg"&&(v.backgroundColor="#fff"),this.setPositionByOrigin(new y(v.width/2,v.height/2),k,k);const _=this.canvas;v._objects=[this],this.set("canvas",v),this.setCoords();const x=v.toCanvasElement(o||1,t);return this.set("canvas",_),this.shadow=i,s&&(this.group=s),this.set(e),this.setCoords(),v._objects=[],v.destroy(),x}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Tr(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Or(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){const{centeredRotation:e,originX:s,originY:i}=this;if(e){const{x:r,y:n}=this.getRelativeCenterPoint();this.originX=k,this.originY=k,this.left=r,this.top=n}if(this.set("angle",t),e){const{x:r,y:n}=this.translateToOriginPoint(this.getRelativeCenterPoint(),s,i);this.left=r,this.top=n,this.originX=s,this.originY=i}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){_s.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&wt().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((s,i)=>{let[r,n]=i;return s[r]=this._animate(r,n,e),s},{})}_animate(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=t.split("."),r=this.constructor.colorProperties.includes(i[i.length-1]),{abort:n,startValue:o,onChange:h,onComplete:c}=s,l=m(m({},s),{},{target:this,startValue:o??i.reduce((u,g)=>u[g],this),endValue:e,abort:n==null?void 0:n.bind(this),onChange:(u,g,d)=>{i.reduce((f,v,_)=>(_===i.length-1&&(f[v]=u),f[v]),this),h&&h(u,g,d)},onComplete:(u,g,d)=>{this.setCoords(),c&&c(u,g,d)}});return r?go(l):qr(l)}isDescendantOf(t){const{parent:e,group:s}=this;return e===t||s===t||!!e&&e.isDescendantOf(t)||!!s&&s!==e&&s.isDescendantOf(t)}getAncestors(){const t=[];let e=this;do e=e.parent,e&&t.push(e);while(e);return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};const e=this.getAncestors(),s=t.getAncestors();if(e.length===0&&s.length>0&&this===s[s.length-1])return{fork:[],otherFork:[t,...s.slice(0,s.length-1)],common:[this]};for(let i,r=0;r<e.length;r++){if(i=e[r],i===t)return{fork:[this,...e.slice(0,r)],otherFork:[],common:e.slice(r)};for(let n=0;n<s.length;n++){if(this===s[n])return{fork:[],otherFork:[t,...s.slice(0,n)],common:[this,...e]};if(i===s[n])return{fork:[this,...e.slice(0,r)],otherFork:[t,...s.slice(0,n)],common:e.slice(r)}}}return{fork:[this,...e],otherFork:[t,...s],common:[]}}hasCommonAncestors(t){const e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;const e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;const s=e.common[0]||this.canvas;if(!s)return;const i=e.fork.pop(),r=e.otherFork.pop(),n=s._objects.indexOf(i),o=s._objects.indexOf(r);return n>-1&&n>o}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(ps.customProperties,this.constructor.customProperties||[]);let e;const s=E.NUM_FRACTION_DIGITS,{clipPath:i,fill:r,stroke:n,shadow:o,strokeDashArray:h,left:c,top:l,originX:u,originY:g,width:d,height:f,strokeWidth:v,strokeLineCap:_,strokeDashOffset:x,strokeLineJoin:C,strokeUniform:S,strokeMiterLimit:b,scaleX:w,scaleY:D,angle:M,flipX:O,flipY:A,opacity:G,visible:U,backgroundColor:R,fillRule:L,paintFirst:P,globalCompositeOperation:K,skewX:q,skewY:J}=this;i&&!i.excludeFromExport&&(e=i.toObject(t.concat("inverted","absolutePositioned")));const B=Ot=>I(Ot,s),xt=m(m({},ve(this,t)),{},{type:this.constructor.type,version:ti,originX:u,originY:g,left:B(c),top:B(l),width:B(d),height:B(f),fill:Fi(r)?r.toObject():r,stroke:Fi(n)?n.toObject():n,strokeWidth:B(v),strokeDashArray:h&&h.concat(),strokeLineCap:_,strokeDashOffset:x,strokeLineJoin:C,strokeUniform:S,strokeMiterLimit:B(b),scaleX:B(w),scaleY:B(D),angle:B(M),flipX:O,flipY:A,opacity:B(G),shadow:o&&o.toObject(),visible:U,backgroundColor:R,fillRule:L,paintFirst:P,globalCompositeOperation:K,skewX:B(q),skewY:B(J)},e?{clipPath:e}:null);return this.includeDefaultValues?xt:this._removeDefaultValues(xt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),s=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return _i(t,(i,r)=>{if(r===j||r===it||r==="type")return!0;const n=s[r];return i!==n&&!(Array.isArray(i)&&Array.isArray(n)&&i.length===0&&n.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=X(t,po),s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:i}=s,r=X(s,mo);return As(e,r).then(n=>i?(delete n[i],new this(e[i],n)):new this(n))}static fromObject(t,e){return this._fromObject(t,e)}};p(Dt,"stateProperties",eo),p(Dt,"cacheProperties",It),p(Dt,"ownDefaults",so),p(Dt,"type","FabricObject"),p(Dt,"colorProperties",[H,nt,"backgroundColor"]),p(Dt,"customProperties",[]),T.setClass(Dt),T.setClass(Dt,"object");const ye=(a,t,e)=>(s,i,r,n)=>{const o=t(s,i,r,n);return o&&Rr(a,m(m({},Ir(s,i,r,n)),e)),o};function _e(a){return(t,e,s,i)=>{const{target:r,originX:n,originY:o}=e,h=r.getRelativeCenterPoint(),c=r.translateToOriginPoint(h,n,o),l=a(t,e,s,i);return r.setPositionByOrigin(c,e.originX,e.originY),l}}const Ji=ye(Me,_e((a,t,e,s)=>{const i=Ci(t,t.originX,t.originY,e,s);if(z(t.originX)===z(k)||z(t.originX)===z(Y)&&i.x<0||z(t.originX)===z(j)&&i.x>0){const{target:r}=t,n=r.strokeWidth/(r.strokeUniform?r.scaleX:1),o=Br(t)?2:1,h=r.width,c=Math.abs(i.x*o/r.scaleX)-n;return r.set("width",Math.max(c,1)),h!==r.width}return!1}));function vo(a,t,e,s,i){s=s||{};const r=this.sizeX||s.cornerSize||i.cornerSize,n=this.sizeY||s.cornerSize||i.cornerSize,o=s.transparentCorners!==void 0?s.transparentCorners:i.transparentCorners,h=o?nt:H,c=!o&&(s.cornerStrokeColor||i.cornerStrokeColor);let l,u=t,g=e;a.save(),a.fillStyle=s.cornerColor||i.cornerColor||"",a.strokeStyle=s.cornerStrokeColor||i.cornerStrokeColor||"",r>n?(l=r,a.scale(1,n/r),g=e*r/n):n>r?(l=n,a.scale(r/n,1),u=t*n/r):l=r,a.beginPath(),a.arc(u,g,l/2,0,ms,!1),a[h](),c&&a.stroke(),a.restore()}function yo(a,t,e,s,i){s=s||{};const r=this.sizeX||s.cornerSize||i.cornerSize,n=this.sizeY||s.cornerSize||i.cornerSize,o=s.transparentCorners!==void 0?s.transparentCorners:i.transparentCorners,h=o?nt:H,c=!o&&(s.cornerStrokeColor||i.cornerStrokeColor),l=r/2,u=n/2;a.save(),a.fillStyle=s.cornerColor||i.cornerColor||"",a.strokeStyle=s.cornerStrokeColor||i.cornerStrokeColor||"",a.translate(t,e);const g=i.getTotalAngle();a.rotate(V(g)),a["".concat(h,"Rect")](-l,-u,r,n),c&&a.strokeRect(-l,-u,r,n),a.restore()}class ft{constructor(t){p(this,"visible",!0),p(this,"actionName",Es),p(this,"angle",0),p(this,"x",0),p(this,"y",0),p(this,"offsetX",0),p(this,"offsetY",0),p(this,"sizeX",0),p(this,"sizeY",0),p(this,"touchSizeX",0),p(this,"touchSizeY",0),p(this,"cursorStyle","crosshair"),p(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,s,i){var r;let{tl:n,tr:o,br:h,bl:c}=i;return((r=e.canvas)===null||r===void 0?void 0:r.getActiveObject())===e&&e.isControlVisible(t)&&W.isPointInPolygon(s,[n,o,h,c])}getActionHandler(t,e,s){return this.actionHandler}getMouseDownHandler(t,e,s){return this.mouseDownHandler}getMouseUpHandler(t,e,s){return this.mouseUpHandler}cursorStyleHandler(t,e,s){return e.cursorStyle}getActionName(t,e,s){return e.actionName}getVisibility(t,e){var s,i;return(s=(i=t._controlsVisibility)===null||i===void 0?void 0:i[e])!==null&&s!==void 0?s:this.visible}setVisibility(t,e,s){this.visible=t}
vendor: 5,185 bytes, line 37
37positionHandler(t,e,s,i){return new y(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,s,i,r,n){const o=vi([Re(s,i),me({angle:t}),yi((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new y(-.5,-.5).transform(o),tr:new y(.5,-.5).transform(o),br:new y(.5,.5).transform(o),bl:new y(-.5,.5).transform(o)}}render(t,e,s,i,r){((i=i||{}).cornerStyle||r.cornerStyle)==="circle"?vo.call(this,t,e,s,i,r):yo.call(this,t,e,s,i,r)}}const _o=(a,t,e)=>e.lockRotation?bs:t.cursorStyle,xo=ye(Cr,_e((a,t,e,s)=>{let{target:i,ex:r,ey:n,theta:o,originX:h,originY:c}=t;const l=i.translateToOriginPoint(i.getRelativeCenterPoint(),h,c);if(_t(i,"lockRotation"))return!1;const u=Math.atan2(n-l.y,r-l.x),g=Math.atan2(s-l.y,e-l.x);let d=Bt(g-u+o);if(i.snapAngle&&i.snapAngle>0){const v=i.snapAngle,_=i.snapThreshold||v,x=Math.ceil(d/v)*v,C=Math.floor(d/v)*v;Math.abs(d-C)<_?d=C:Math.abs(d-x)<_&&(d=x)}d<0&&(d=360+d),d%=360;const f=i.angle!==d;return i.angle=d,f}));function Kr(a,t){const e=t.canvas,s=a[e.uniScaleKey];return e.uniformScaling&&!s||!e.uniformScaling&&s}function Jr(a,t,e){const s=_t(a,"lockScalingX"),i=_t(a,"lockScalingY");if(s&&i||!t&&(s||i)&&e||s&&t==="x"||i&&t==="y")return!0;const{width:r,height:n,strokeWidth:o}=a;return r===0&&o===0&&t!=="y"||n===0&&o===0&&t!=="x"}const Co=["e","se","s","sw","w","nw","n","ne","e"],we=(a,t,e)=>{const s=Kr(a,e);if(Jr(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",s))return bs;const i=Xr(e,t);return"".concat(Co[i],"-resize")};function wi(a,t,e,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const r=t.target,n=i.by,o=Kr(a,r);let h,c,l,u,g,d;if(Jr(r,n,o))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,l=t.scaleY*t.gestureScale;else{if(h=Ci(t,t.originX,t.originY,e,s),g=n!=="y"?Math.sign(h.x||t.signX||1):1,d=n!=="x"?Math.sign(h.y||t.signY||1):1,t.signX||(t.signX=g),t.signY||(t.signY=d),_t(r,"lockScalingFlip")&&(t.signX!==g||t.signY!==d))return!1;if(u=r._getTransformedDimensions(),o&&!n){const _=Math.abs(h.x)+Math.abs(h.y),{original:x}=t,C=_/(Math.abs(u.x*x.scaleX/r.scaleX)+Math.abs(u.y*x.scaleY/r.scaleY));c=x.scaleX*C,l=x.scaleY*C}else c=Math.abs(h.x*r.scaleX/u.x),l=Math.abs(h.y*r.scaleY/u.y);Br(t)&&(c*=2,l*=2),t.signX!==g&&n!=="y"&&(t.originX=Ii(t.originX),c*=-1,t.signX=g),t.signY!==d&&n!=="x"&&(t.originY=Ii(t.originY),l*=-1,t.signY=d)}const f=r.scaleX,v=r.scaleY;return n?(n==="x"&&r.set(ot,c),n==="y"&&r.set(ut,l)):(!_t(r,"lockScalingX")&&r.set(ot,c),!_t(r,"lockScalingY")&&r.set(ut,l)),f!==r.scaleX||v!==r.scaleY}const Ye=ye(Ms,_e((a,t,e,s)=>wi(a,t,e,s))),bo=ye(Ms,_e((a,t,e,s)=>wi(a,t,e,s,{by:"x"}))),So=ye(Ms,_e((a,t,e,s)=>wi(a,t,e,s,{by:"y"}))),wo=["target","ex","ey","skewingSide"],Us={x:{counterAxis:"y",scale:ot,skew:fe,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:ut,skew:pe,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},To=["ns","nesw","ew","nwse"],Oo=(a,t,e)=>{if(t.x!==0&&_t(e,"lockSkewingY")||t.y!==0&&_t(e,"lockSkewingX"))return bs;const s=Xr(e,t)%4;return"".concat(To[s],"-resize")};function Zr(a,t,e,s,i){const{target:r}=e,{counterAxis:n,origin:o,lockSkewing:h,skew:c,flip:l}=Us[a];if(_t(r,h))return!1;const{origin:u,flip:g}=Us[n],d=z(e[u])*(r[g]?-1:1),f=-Math.sign(d)*(r[l]?-1:1),v=.5*-((r[c]===0&&Ci(e,k,k,s,i)[a]>0||r[c]>0?1:-1)*f)+.5;return ye(br,_e((x,C,S,b)=>function(w,D,M){let{target:O,ex:A,ey:G,skewingSide:U}=D,R=X(D,wo);const{skew:L}=Us[w],P=M.subtract(new y(A,G)).divide(new y(O.scaleX,O.scaleY))[w],K=O[L],q=R[L],J=Math.tan(V(q)),B=w==="y"?O._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:O._getTransformedDimensions({scaleX:1,scaleY:1}).y,xt=2*P*U/Math.max(B,1)+J,Ot=Bt(Math.atan(xt));O.set(L,Ot);const Ie=K!==O[L];if(Ie&&w==="y"){const{skewX:Xs,scaleX:xe}=O,Wt=O._getTransformedDimensions({skewY:K}),Xe=O._getTransformedDimensions(),Ut=Xs!==0?Wt.x/Xe.x:1;Ut!==1&&O.set(ot,Ut*xe)}return Ie}(a,C,new y(S,b))))(t,m(m({},e),{},{[o]:v,skewingSide:f}),s,i)}const Do=(a,t,e,s)=>Zr("x",a,t,e,s),ko=(a,t,e,s)=>Zr("y",a,t,e,s);function Ls(a,t){return a[t.canvas.altActionKey]}const Ve=(a,t,e)=>{const s=Ls(a,e);return t.x===0?s?fe:ut:t.y===0?s?pe:ot:""},oe=(a,t,e)=>Ls(a,e)?Oo(0,t,e):we(a,t,e),Zi=(a,t,e,s)=>Ls(a,t.target)?ko(a,t,e,s):bo(a,t,e,s),$i=(a,t,e,s)=>Ls(a,t.target)?Do(a,t,e,s):So(a,t,e,s),$r=()=>({ml:new ft({x:-.5,y:0,cursorStyleHandler:oe,actionHandler:Zi,getActionName:Ve}),mr:new ft({x:.5,y:0,cursorStyleHandler:oe,actionHandler:Zi,getActionName:Ve}),mb:new ft({x:0,y:.5,cursorStyleHandler:oe,actionHandler:$i,getActionName:Ve}),mt:new ft({x:0,y:-.5,cursorStyleHandler:oe,actionHandler:$i,getActionName:Ve}),tl:new ft({x:-.5,y:-.5,cursorStyleHandler:we,actionHandler:Ye}),tr:new ft({x:.5,y:-.5,cursorStyleHandler:we,actionHandler:Ye}),bl:new ft({x:-.5,y:.5,cursorStyleHandler:we,actionHandler:Ye}),br:new ft({x:.5,y:.5,cursorStyleHandler:we,actionHandler:Ye}),mtr:new ft({x:0,y:-.5,actionHandler:xo,cursorStyleHandler:_o,offsetY:-40,withConnection:!0,actionName:pi})}),Mo=()=>({mr:new ft({x:.5,y:0,actionHandler:Ji,cursorStyleHandler:oe,actionName:Me}),ml:new ft({x:-.5,y:0,actionHandler:Ji,cursorStyleHandler:oe,actionName:Me})}),Eo=()=>m(m({},$r()),Mo());
vendor: 8,506 bytes, line 37
37class je extends Dt{static getDefaults(){return m(m({},super.getDefaults()),je.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),je.ownDefaults),this.setOptions(t)}static createControls(){return{controls:$r()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,s=e.target,i=e.action;if(this===s&&i&&i.startsWith(Es))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const s=Object.entries(this.oCoords);for(let i=s.length-1;i>=0;i--){const[r,n]=s[i],o=this.controls[r];if(o.shouldActivate(r,this,t,e?n.touchCorner:n.corner))return this.__corner=r,{key:r,control:o,coord:this.oCoords[r]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),s=Re(e.x,e.y),i=me({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=Z(s,i),n=Z(t,r),o=Z(n,[1/t[0],0,0,1/t[3],0,0]),h=this.group?xs(this.calcTransformMatrix()):void 0;h&&(h.scaleX=Math.abs(h.scaleX),h.scaleY=Math.abs(h.scaleY));const c=this._calculateCurrentDimensions(h),l={};return this.forEachControl((u,g)=>{const d=u.positionHandler(c,o,this,u);l[g]=Object.assign(d,this._calcCornerCoords(u,d))}),l}_calcCornerCoords(t,e){const s=this.getTotalAngle();return{corner:t.calcCornerCoords(s,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(s,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(const e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),s=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(V(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-s.x/2,-s.y/2,s.x,s.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=m({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},s);t.save(),t.strokeStyle=i.borderColor,this._setLineDash(t,i.borderDashArray),this.strokeBorders(t,e),i.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:s,hasControls:i}=this,r=m({hasBorders:s,hasControls:i},e),n=this.getViewportTransform(),o=r.hasBorders,h=r.hasControls,c=Z(n,this.calcTransformMatrix()),l=xs(c);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(V(this.group?l.angle:this.angle)),o&&this.drawBorders(t,l,e),h&&this.drawControls(t,e),t.restore()}drawBorders(t,e,s){let i;if(s&&s.forActiveSelection||this.group){const r=xi(this.width,this.height,Ps(e)),n=this.isStrokeAccountedForInDimensions()?mi:(this.strokeUniform?new y().scalarAdd(this.canvas?this.canvas.getZoom():1):new y(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);i=r.add(n).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else i=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,i,s)}drawControlsConnectingLines(t,e){let s=!1;t.beginPath(),this.forEachControl((i,r)=>{i.withConnection&&i.getVisibility(this,r)&&(s=!0,t.moveTo(i.x*e.x,i.y*e.y),t.lineTo(i.x*e.x+i.offsetX,i.y*e.y+i.offsetY))}),s&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const s=this.getCanvasRetinaScaling(),{cornerStrokeColor:i,cornerDashArray:r,cornerColor:n}=this,o=m({cornerStrokeColor:i,cornerDashArray:r,cornerColor:n},e);t.setTransform(s,0,0,s,0,0),t.strokeStyle=t.fillStyle=o.cornerColor,this.transparentCorners||(t.strokeStyle=o.cornerStrokeColor),this._setLineDash(t,o.cornerDashArray),this.forEachControl((h,c)=>{if(h.getVisibility(this,c)){const l=this.oCoords[c];h.render(t,l.x,l.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(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach(e=>{let[s,i]=e;return this.setControlVisible(s,i)})}clearContextTop(t){if(!this.canvas)return;const e=this.canvas.contextTop;if(!e)return;const s=this.canvas.viewportTransform;e.save(),e.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this.transform(e);const i=this.width+4,r=this.height+4;return e.clearRect(-i/2,-r/2,i,r),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 Qr(a,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(s=>{s!=="constructor"&&Object.defineProperty(a.prototype,s,Object.getOwnPropertyDescriptor(e.prototype,s)||Object.create(null))})}),a}p(je,"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});class $ extends je{}Qr($,[Wr]),T.setClass($),T.setClass($,"object");const Po=(a,t,e,s)=>{const i=2*(s=Math.round(s))+1,{data:r}=a.getImageData(t-s,e-s,i,i);for(let n=3;n<r.length;n+=4)if(r[n]>0)return!1;return!0};class tn{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new y(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new y(1/this.options.scaleX,1/this.options.scaleY):new y(1,1)}createSideVector(t,e){const s=ri(t,e);return this.options.strokeUniform?s.multiply(this.scale):s}projectOrthogonally(t,e,s){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,s)))}isSkewed(){return this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new y(t);return e.y+=e.x*Math.tan(V(this.options.skewY)),e.x+=e.y*Math.tan(V(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Ao=new y;class ue extends tn{static getOrthogonalRotationFactor(t,e){const s=e?oi(t,e):Qn(t);return Math.abs(s)<Le?-1:1}constructor(t,e,s,i){super(i),p(this,"AB",void 0),p(this,"AC",void 0),p(this,"alpha",void 0),p(this,"bisector",void 0),this.A=new y(t),this.B=new y(e),this.C=new y(s),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=oi(this.AB,this.AC),this.bisector=bi(Nr(this.AB.eq(Ao)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),r=Ur(i),n=ue.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,s*n)}projectBevel(){const t=[];return(this.alpha%ms==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(){const t=[],e=Math.abs(this.alpha),s=1/Math.sin(e/2),i=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*s),r=this.options.strokeUniform?ni(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return ni(i)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const s=[],i=new y(ue.getOrthogonalRotationFactor(this.bisector),ue.getOrthogonalRotationFactor(new y(this.bisector.y,this.bisector.x)));return[new y(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new y(0,
371).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(r=>{Ui(r,t,e)&&s.push(this.A.add(r))}),s}projectRoundWithSkew(t,e){const s=[],{skewX:i,skewY:r,scaleX:n,scaleY:o,strokeUniform:h}=this.options,c=new y(Math.tan(V(i)),Math.tan(V(r))),l=this.strokeProjectionMagnitude,u=h?l/o/Math.sqrt(1/o**2+1/n**2*c.y**2):l/Math.sqrt(1+c.y**2),g=new y(Math.sqrt(Math.max(l**2-u**2,0)),u),d=h?l/Math.sqrt(1+c.x**2*(1/o)**2/(1/n+1/n*c.x*c.y)**2):l/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),f=new y(d,Math.sqrt(Math.max(l**2-d**2,0)));return[f,f.scalarMultiply(-1),g,g.scalarMultiply(-1)].map(v=>this.applySkew(h?v.multiply(this.strokeUniformScalar):v)).forEach(v=>{Ui(v,t,e)&&s.push(this.applySkew(this.A).add(v))}),s}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%ms==0,s=this.applySkew(this.A),i=t[e?0:2].subtract(s),r=t[e?1:0].subtract(s),n=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),o=ke(i,n)>0,h=o?i:r,c=o?r:i;return this.isSkewed()?t.push(...this.projectRoundWithSkew(h,c)):t.push(...this.projectRoundNoSkew(h,c)),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}))}}class Qi extends tn{constructor(t,e,s){super(s),this.A=new y(t),this.T=new y(e)}calcOrthogonalProjection(t,e){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e);return this.scaleUnitVector(Ur(i),s)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){const t=[];if(!this.isSkewed()&&this.A.eq(this.T)){const e=new y(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 ue(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new y(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),s=this.scaleUnitVector(bi(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),i=this.A.add(s);t.push(i.add(e),i.subtract(e))}return t.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}}const jo=function(a,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const s=[];if(a.length===0)return s;const i=a.reduce((r,n)=>(r[r.length-1].eq(n)||r.push(new y(n)),r),[new y(a[0])]);if(i.length===1)e=!0;else if(!e){const r=i[0],n=((o,h)=>{for(let c=o.length-1;c>=0;c--)if(h(o[c],c,o))return c;return-1})(i,o=>!o.eq(r));i.splice(n+1)}return i.forEach((r,n,o)=>{let h,c;n===0?(c=o[1],h=e?r:o[o.length-1]):n===o.length-1?(h=o[n-1],c=e?r:o[0]):(h=o[n-1],c=o[n+1]),e&&o.length===1?s.push(...new Qi(r,r,t).project()):!e||n!==0&&n!==o.length-1?s.push(...new ue(r,h,c,t).project()):s.push(...new Qi(r,n===0?c:h,t).project())}),s},Ti=a=>{const t={};return Object.keys(a).forEach(e=>{t[e]={},Object.keys(a[e]).forEach(s=>{t[e][s]=m({},a[e][s])})}),t},Fo=a=>a.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let be;const Oi=a=>{if(be||be||(be="Intl"in ks()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),be){const t=be.segment(a);return Array.from(t).map(e=>{let{segment:s}=e;return s})}return Lo(a)},Lo=a=>{const t=[];for(let e,s=0;s<a.length;s++)(e=Ro(a,s))!==!1&&t.push(e);return t},Ro=(a,t)=>
vendor: 4,973 bytes, lines 37-38
37{const e=a.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return a.charAt(t);if(55296<=e&&e<=56319){if(a.length<=t+1)throw"High surrogate without following low surrogate";const i=a.charCodeAt(t+1);if(56320>i||i>57343)throw"High surrogate without following low surrogate";return a.charAt(t)+a.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const s=a.charCodeAt(t-1);if(55296>s||s>56319)throw"Low surrogate without preceding high surrogate";return!1},Di=function(a,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return a.fill!==t.fill||a.stroke!==t.stroke||a.strokeWidth!==t.strokeWidth||a.fontSize!==t.fontSize||a.fontFamily!==t.fontFamily||a.fontWeight!==t.fontWeight||a.fontStyle!==t.fontStyle||a.textDecorationThickness!==t.textDecorationThickness||a.textBackgroundColor!==t.textBackgroundColor||a.deltaY!==t.deltaY||e&&(a.overline!==t.overline||a.underline!==t.underline||a.linethrough!==t.linethrough)},Bo=(a,t)=>{const e=t.split(`
38`),s=[];let i=-1,r={};a=Ti(a);for(let n=0;n<e.length;n++){const o=Oi(e[n]);if(a[n])for(let h=0;h<o.length;h++){i++;const c=a[n][h];c&&Object.keys(c).length>0&&(Di(r,c,!0)?s.push({start:i,end:i+1,style:c}):s[s.length-1].end++),r=c||{}}else i+=o.length,r={}}return s},Io=(a,t)=>{if(!Array.isArray(a))return Ti(a);const e=t.split(fi),s={};let i=-1,r=0;for(let n=0;n<e.length;n++){const o=Oi(e[n]);for(let h=0;h<o.length;h++)i++,a[r]&&a[r].start<=i&&i<a[r].end&&(s[n]=s[n]||{},s[n][h]=m({},a[r].style),i===a[r].end-1&&r++)}return s},Nt=["display","transform",H,"fill-opacity","fill-rule","opacity",nt,"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 tr(a,t){const e=a.nodeName,s=a.getAttribute("class"),i=a.getAttribute("id"),r="(?![a-zA-Z\\-]+)";let n;if(n=new RegExp("^"+e,"i"),t=t.replace(n,""),i&&t.length&&(n=new RegExp("#"+i+r,"i"),t=t.replace(n,"")),s&&t.length){const o=s.split(" ");for(let h=o.length;h--;)n=new RegExp("\\."+o[h]+r,"i"),t=t.replace(n,"")}return t.length===0}function Xo(a,t){let e=!0;const s=tr(a,t.pop());return s&&t.length&&(e=function(i,r){let n,o=!0;for(;i.parentElement&&i.parentElement.nodeType===1&&r.length;)o&&(n=r.pop()),o=tr(i=i.parentElement,n);return r.length===0}(a,t)),s&&e&&t.length===0}const Wo=a=>{var t;return(t=Zn[a])!==null&&t!==void 0?t:a},Yo=new RegExp("(".concat(yt,")"),"gi"),Vo=a=>Ss(a.replace(Yo," $1 ").replace(/,/gi," "));var er,sr,ir,rr,nr,or,ar;const tt="(".concat(yt,")"),zo=String.raw(er||(er=Tt(["(skewX)(",")"],["(skewX)\\(","\\)"])),tt),Go=String.raw(sr||(sr=Tt(["(skewY)(",")"],["(skewY)\\(","\\)"])),tt),Ho=String.raw(ir||(ir=Tt(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),tt,tt,tt),No=String.raw(rr||(rr=Tt(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),tt,tt),Uo=String.raw(nr||(nr=Tt(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),tt,tt),qo=String.raw(or||(or=Tt(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),tt,tt,tt,tt,tt,tt),ki="(?:".concat(qo,"|").concat(Uo,"|").concat(Ho,"|").concat(No,"|").concat(zo,"|").concat(Go,")"),Ko="(?:".concat(ki,"*)"),Jo=String.raw(ar||(ar=Tt(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Ko),Zo=new RegExp(Jo),$o=new RegExp(ki),Qo=new RegExp(ki,"g");function ai(a){const t=[];if(!(a=Vo(a).replace(/\s*([()])\s*/gi,"$1"))||a&&!Zo.test(a))return[...et];for(const e of a.matchAll(Qo)){const s=$o.exec(e[0]);if(!s)continue;let i=et;const r=s.filter(f=>!!f),[,n,...o]=r,[h,c,l,u,g,d]=o.map(f=>parseFloat(f));switch(n){case"translate":i=Re(h,c);break;case pi:i=me({angle:h},{x:c,y:l});break;case Es:i=yi(h,c);break;case fe:i=Mr(h);break;case pe:i=Er(h);break;case"matrix":i=[h,c,l,u,g,d]}t.push(i)}return vi(t)}function ta(a,t,e,s){const i=Array.isArray(t);let r,n=t;if(a!==H&&a!==nt||t!==rt){if(a==="strokeUniform")return t==="non-scaling-stroke";if(a==="strokeDashArray")n=t===rt?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(a==="transformMatrix")n=e&&e.transformMatrix?Z(e.transformMatrix,ai(t)):ai(t);else if(a==="visible")n=t!==rt&&t!=="hidden",e&&e.visible===!1&&(n=!1);else if(a==="opacity")n=parseFloat(t),e&&e.opacity!==void 0&&(n*=e.opacity);else if(a==="textAnchor")n=t==="start"?j:t==="end"?Y:k;else if(a==="charSpacing"||a===ee)r=le(t,s)/s*1e3;else if(a==="paintFirst"){const o=t.indexOf(H),h=t.indexOf(nt);n=H,(o>-1&&h>-1&&h<o||o===-1&&h>-1)&&(n=nt)}else{if(a==="href"||a==="xlink:href"||a==="font"||a==="id")return t;if(a==="imageSmoothing")return t==="optimizeQuality";r=i?t.map(le):le(t,s)}}else n="";return!i&&isNaN(r)?n:r}function ea(a,t){const e=a.match(Jn);if(!e)return;const s=e[1],i=e[3],r=e[4],n=e[5],o=e[6];s&&(t.fontStyle=s),i&&(t.fontWeight=isNaN(parseFloat(i))?i:parseFloat(i)),r&&(t.fontSize=le(r)),o&&(t.fontFamily=o),n&&(t.lineHeight=n==="normal"?1:n)}function sa(a,t){a.replace(/;\s*$/,"").split(";
38").forEach(e=>{if(!e)return;const[s,i]=e.split(":");t[s.trim().toLowerCase()]=i.trim()})}function ia(a){const t={},e=a.getAttribute("style");return e&&(typeof e=="string"?sa(e,t):function(s,i){Object.entries(s).forEach(r=>{let[n,o]=r;o!==void 0&&(i[n.toLowerCase()]=o)})}(e,t)),t}const ra={stroke:"strokeOpacity",fill:"fillOpacity"};function Xt(a,t,e){if(!a)return{};let s,i={},r=di;a.parentNode&&Ni.test(a.parentNode.nodeName)&&(i=Xt(a.parentElement,t,e),i.fontSize&&(s=r=le(i.fontSize)));const n=m(m(m({},t.reduce((c,l)=>{const u=a.getAttribute(l);return u&&(c[l]=u),c},{})),function(c){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u={};for(const g in l)Xo(c,g.split(" "))&&(u=m(m({},u),l[g]));return u}(a,e)),ia(a));n[Hs]&&a.setAttribute(Hs,n[Hs]),n[Gs]&&(s=le(n[Gs],r),n[Gs]="".concat(s));const o={};for(const c in n){const l=Wo(c),u=ta(l,n[c],i,s);o[l]=u}o&&o.font&&ea(o.font,o);const h=m(m({},i),o);return Ni.test(a.nodeName)?h:function(c){const l=$.getDefaults();return Object.entries(ra).forEach(u=>{let[g,d]=u;if(c[d]===void 0||c[g]==="")return;if(c[g]===void 0){if(!l[g])return;c[g]=l[g]}if(c[g].indexOf("url(")===0)return;const f=new F(c[g]);c[g]=f.setAlpha(I(f.getAlpha()*c[d],2)).toRgba()}),c}(h)}const na=["left","top","width","height","visible"],en=["rx","ry"];class Ct extends ${static getDefaults(){return m(m({},super.getDefaults()),Ct.ownDefaults)}constructor(t){super(),Object.assign(this,Ct.ownDefaults),this.setOptions(t),this._initRxRy()}_initRxRy(){const{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){const{width:e,height:s}=this,i=-e/2,r=-s/2,n=this.rx?Math.min(this.rx,e/2):0,o=this.ry?Math.min(this.ry,s/2):0,h=n!==0||o!==0;t.beginPath(),t.moveTo(i+n,r),t.lineTo(i+e-n,r),h&&t.bezierCurveTo(i+e-Vt*n,r,i+e,r+Vt*o,i+e,r+o),t.lineTo(i+e,r+s-o),h&&t.bezierCurveTo(i+e,r+s-Vt*o,i+e-Vt*n,r+s,i+e-n,r+s),t.lineTo(i+n,r+s),h&&t.bezierCurveTo(i+Vt*n,r+s,i,r+s-Vt*o,i,r+s-o),t.lineTo(i,r+o),h&&t.bezierCurveTo(i,r+Vt*o,i+Vt*n,r,i+n,r),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...en,...t])}_toSVG(){const{width:t,height:e,rx:s,ry:i}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(s,'" ry="').concat(i,'" width="').concat(t,'" height="').concat(e,`" />
39`)]}static async fromElement(t,e,s){const i=Xt(t,this.ATTRIBUTE_NAMES,s),{left:r=0,top:n=0,width:o=0,height:h=0,visible:c=!0}=i,l=X(i,na);return new this(m(m(m({},e),l),{},{left:r,top:n,width:o,height:h,visible:!!(c&&o&&h)}))}}p(Ct,"type","Rect"),p(Ct,"cacheProperties",[...It,...en]),p(Ct,"ownDefaults",{rx:0,ry:0}),p(Ct,"ATTRIBUTE_NAMES",[...Nt,"x","y","rx","ry","width","height"]),T.setClass(Ct),T.setSVGClass(Ct);const Et="initialization",Ts="added",Mi="removed",Os="imperative",sn=(a,t)=>{const{strokeUniform:e,strokeWidth:s,width:i,height:r,group:n}=t,o=n&&n!==a?js(n.calcTransformMatrix(),a.calcTransformMatrix()):null,h=o?t.getRelativeCenterPoint().transform(o):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),l=e&&c?zn(new y(s,s),void 0,a.calcTransformMatrix()):mi,u=!e&&c?s:0,g=xi(i+u,r+u,vi([o,t.calcOwnMatrix()],!0)).add(l).scalarDivide(2);return[h.subtract(g),h.add(g)]};class Rs{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:s,strategy:i}=t;return e===Et||e===Os||!!s&&i!==s}shouldLayoutClipPath(t){let{type:e,target:{clipPath:s}}=t;return e!==Et&&s&&!s.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:s,target:i}=e;if(s===Os&&e.overrides)return e.overrides;if(t.length===0)return;const{left:r,top:n,width:o,height:h}=At(t.map(u=>sn(i,u)).reduce((u,g)=>u.concat(g),[])),c=new y(o,h),l=new y(r,n).add(c.scalarDivide(2));if(s===Et){const u=this.getInitialSize(e,{size:c,center:l});return{center:l,relativeCorrection:new y(0,0),size:u}}return{center:l.transform(i.calcOwnMatrix()),size:c}}}p(Rs,"type","strategy");class hi extends Rs{shouldPerformLayout(t){return!0}}p(hi,"type","fit-content"),T.setClass(hi);const oa=["strategy"],aa=["target","strategy","bubbles","prevStrategy"],rn="layoutManager";class Fe{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new hi;p(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=m(m({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const s=this.getLayoutResult(e);s&&this.commitLayout(e,s),this.onAfterLayout(e,s),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:s}=e;return[ys,xr,Me,Cr,Ms,br,vs,kn,Mn].map(i=>t.on(i,r=>this.performLayout(i===ys?{type:"object_modified",trigger:i,e:r,target:s}:{type:"object_modifying",trigger:i,e:r,target:s})))}subscribe(t,e){this.unsubscribe(t,e);const s=this.attachHandlers(t,e);this._subscriptions.set(t,s)}
39unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(s=>s()),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){const{target:e,type:s}=t,{canvas:i}=e;if(s===Et||s===Ts?this.subscribeTargets(t):s===Mi&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),i&&i.fire("object:layout:before",{target:e,context:t}),s===Os&&t.deep){const r=X(t,oa);e.forEachObject(n=>n.layoutManager&&n.layoutManager.performLayout(m(m({},r),{},{bubbles:!1,target:n})))}}getLayoutResult(t){const{target:e,strategy:s,type:i}=t,r=s.calcLayoutResult(t,e.getObjects());if(!r)return;const n=i===Et?new y:e.getRelativeCenterPoint(),{center:o,correction:h=new y,relativeCorrection:c=new y}=r,l=n.subtract(o).add(h).transform(i===Et?et:vt(e.calcOwnMatrix()),!0).add(c);return{result:r,prevCenter:n,nextCenter:o,offset:l}}commitLayout(t,e){const{target:s}=t,{result:{size:i},nextCenter:r}=e;var n,o;s.set({width:i.x,height:i.y}),this.layoutObjects(t,e),t.type===Et?s.set({left:(n=t.x)!==null&&n!==void 0?n:r.x+i.x*z(s.originX),top:(o=t.y)!==null&&o!==void 0?o:r.y+i.y*z(s.originY)}):(s.setPositionByOrigin(r,k,k),s.setCoords(),s.set("dirty",!0))}layoutObjects(t,e){const{target:s}=t;s.forEachObject(i=>{i.group===s&&this.layoutObject(t,e,i)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,s.clipPath)}layoutObject(t,e,s){let{offset:i}=e;s.set({left:s.left+i.x,top:s.top+i.y})}onAfterLayout(t,e){const{target:s,strategy:i,bubbles:r,prevStrategy:n}=t,o=X(t,aa),{canvas:h}=s;s.fire("layout:after",{context:t,result:e}),h&&h.fire("object:layout:after",{context:t,result:e,target:s});const c=s.parent;r&&c!=null&&c.layoutManager&&((o.path||(o.path=[])).push(s),c.layoutManager.performLayout(m(m({},o),{},{target:c}))),s.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(s=>s())),t.clear()}toObject(){return{type:rn,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}T.setClass(Fe,rn);const ha=["type","objects","layoutManager"];class ca extends Fe{performLayout(){}}class te extends Sr($){static getDefaults(){return m(m({},super.getDefaults()),te.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),p(this,"_activeObjects",[]),p(this,"__objectSelectionTracker",void 0),p(this,"__objectSelectionDisposer",void 0),Object.assign(this,te.ownDefaults),this.setOptions(e),this.groupInit(t,e)}groupInit(t,e){var s;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(i=>{this.enterGroup(i,!1)}),this.layoutManager=(s=e.layoutManager)!==null&&s!==void 0?s:new Fe,this.layoutManager.performLayout({type:Et,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(Gt("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(Gt("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,s,i)=>this.canEnterGroup(e)&&i.indexOf(e)===s)}add(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];const i=this._filterObjectsBeforeEnteringGroup(e),r=super.add(...i);return this._onAfterObjectsChange(Ts,i),r}insertAt(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];const r=this._filterObjectsBeforeEnteringGroup(s),n=super.insertAt(t,...r);return this._onAfterObjectsChange(Ts,r),n}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Mi,t),t}_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){const s=this[t];return super._set(t,e),t==="canvas"&&s!==e&&(this._objects||[]).forEac
vendor: 40,125 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,e){let{target:s}=e;const i=this._activeObjects;if(t)i.push(s),this._set("dirty",!0);else if(i.length>0){const r=i.indexOf(s);r>-1&&(i.splice(r,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&&Cs(t,Z(vt(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);const s=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();s&&(s===t||t.isDescendantOf(s))&&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||(Cs(t,Z(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);const s=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;s>-1&&this._activeObjects.splice(s,1)}shouldCache(){const t=$.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].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,s){this._renderBackground(t);for(let r=0;r<this._objects.length;r++){var i;const n=this._objects[r];(i=this.canvas)!==null&&i!==void 0&&i.preserveObjectStacking&&n.group!==this?(t.save(),t.transform(...vt(this.calcTransformMatrix())),n.render(t),t.restore()):n.group===this&&n.render(t)}this._drawClipPath(t,this.clipPath,s)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(m({target:this,type:Os},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const s=this.includeDefaultValues;return this._objects.filter(function(i){return!i.excludeFromExport}).map(function(i){const r=i.includeDefaultValues;i.includeDefaultValues=s;const n=i[t||"toObject"](e);return i.includeDefaultValues=r,n})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return m(m(m({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".concat(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"";const e=Ct.prototype._toSVG.call(this),s=e.indexOf("COMMON_PARTS");e[s]='for="group" ';const i=e.join("");return t?t(i):i}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
40`],s=this._createSVGBgRect(t);s&&e.push("		",s);for(let i=0;i<this._objects.length;i++)e.push("		",this._objects[i].toSVG(t));return e.push(`</g>
41`),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],s=this._createSVGBgRect(t);s&&e.push("	",s);for(let i=0;i<this._objects.length;i++)e.push("	",this._objects[i].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:s,objects:i=[],layoutManager:r}=t,n=X(t,ha);return Promise.all([Ee(i,e),As(n,e)]).then(o=>{let[h,c]=o;const l=new this(h,m(m(m({},n),c),{},{layoutManager:new ca}));if(r){const u=T.getClass(r.type),g=T.getClass(r.strategy);l.layoutManager=new u(new g)}else l.layoutManager=new Fe;return l.layoutManager.subscribeTargets({type:Et,target:l,targets:l.getObjects()}),l.setCoords(),l})}}p(te,"type","Group"),p(te,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),T.setClass(te);const la=(a,t)=>Math.min(t.width/a.width,t.height/a.height),ua=(a,t)=>Math.max(t.width/a.width,t.height/a.height),ci="\\s*,?\\s*",Se="".concat(ci,"(").concat(yt,")"),ga="".concat(Se).concat(Se).concat(Se).concat(ci,"([01])").concat(ci,"([01])").concat(Se).concat(Se),da={m:"l",M:"L"},fa=(a,t,e,s,i,r,n,o,h,c,l)=>{const u=Ft(a),g=Lt(a),d=Ft(t),f=Lt(t),v=e*i*d-s*r*f+n,_=s*i*d+e*r*f+o;return["C",c+h*(-e*i*g-s*r*u),l+h*(-s*i*g+e*r*u),v+h*(e*i*f+s*r*d),_+h*(s*i*f-e*r*d),v,_]},hr=(a,t,e,s)=>{const i=Math.atan2(t,a),r=Math.atan2(s,e);return r>=i?r-i:2*Math.PI-(i-r)};function cr(a,t,e,s,i,r,n,o){let h;if(E.cachesBoundsOfCurve&&(h=[...arguments].join(),Te.boundsOfCurveCache[h]))return Te.boundsOfCurveCache[h];const c=Math.sqrt,l=Math.abs,u=[],g=[[0,0],[0,0]];let d=6*a-12*e+6*i,f=-3*a+9*e-9*i+3*n,v=3*e-3*a;for(let b=0;b<2;++b){if(b>0&&(d=6*t-12*s+6*r,f=-3*t+9*s-9*r+3*o,v=3*s-3*t),l(f)<1e-12){if(l(d)<1e-12)continue;const A=-v/d;0<A&&A<1&&u.push(A);continue}const w=d*d-4*v*f;if(w<0)continue;const D=c(w),M=(-d+D)/(2*f);0<M&&M<1&&u.push(M);const O=(-d-D)/(2*f);0<O&&O<1&&u.push(O)}let _=u.length;const x=_,C=nn(a,t,e,s,i,r,n,o);for(;_--;){const{x:b,y:w}=C(u[_]);g[0][_]=b,g[1][_]=w}g[0][x]=a,g[1][x]=t,g[0][x+1]=n,g[1][x+1]=o;const S=[new y(Math.min(...g[0]),Math.min(...g[1])),new y(Math.max(...g[0]),Math.max(...g[1]))];return E.cachesBoundsOfCurve&&(Te.boundsOfCurveCache[h]=S),S}const pa=(a,t,e)=>{let[s,i,r,n,o,h,c,l]=e;const u=((g,d,f,v,_,x,C)=>{if(f===0||v===0)return[];let S=0,b=0,w=0;const D=Math.PI,M=C*gi,O=Lt(M),A=Ft(M),G=.5*(-A*g-O*d),U=.5*(-A*d+O*g),R=f**2,L=v**2,P=U**2,K=G**2,q=R*L-R*P-L*K;let J=Math.abs(f),B=Math.abs(v);if(q<0){const Yt=Math.sqrt(1-q/(R*L));J*=Yt,B*=Yt}else w=(_===x?-1:1)*Math.sqrt(q/(R*P+L*K));const xt=w*J*U/B,Ot=-w*B*G/J,Ie=A*xt-O*Ot+.5*g,Xs=O*xt+A*Ot+.5*d;let xe=hr(1,0,(G-xt)/J,(U-Ot)/B),Wt=hr((G-xt)/J,(U-Ot)/B,(-G-xt)/J,(-U-Ot)/B);x===0&&Wt>0?Wt-=2*D:x===1&&Wt<0&&(Wt+=2*D);const Xe=Math.ceil(Math.abs(Wt/D*2)),Ut=[],Ce=Wt/Xe,Sn=8/3*Math.sin(Ce/4)*Math.sin(Ce/4)/Math.sin(Ce/2);let Ws=xe+Ce;for(let Yt=0;Yt<Xe;Yt++)Ut[Yt]=fa(xe,Ws,A,O,J,B,Ie,Xs,Sn,S,b),S=Ut[Yt][5],b=Ut[Yt][6],xe=Ws,Ws+=Ce;return Ut})(c-a,l-t,i,r,o,h,n);for(let g=0,d=u.length;g<d;g++)u[g][1]+=a,u[g][2]+=t,u[g][3]+=a,u[g][4]+=t,u[g][5]+=a,u[g][6]+=t;return u},ma=a=>{let t=0,e=0,s=0,i=0;const r=[];let n,o=0,h=0;for(const c of a){const l=[...c];let u;switch(l[0]){case"l":l[1]+=t,l[2]+=e;case"L":t=l[1],e=l[2],u=["L",t,e];break;case"h":l[1]+=t;case"H":t=l[1],u=["L",t,e];break;case"v":l[1]+=e;case"V":e=l[1],u=["L",t,e];break;case"m":l[1]+=t,l[2]+=e;case"M":t=l[1],e=l[2],s=l[1],i=l[2],u=["M",t,e];break;case"c":l[1]+=t,l[2]+=e,l[3]+=t,l[4]+=e,l[5]+=t,l[6]+=e;case"C":o=l[3],h=l[4],t=l[5],e=l[6],u=["C",l[1],l[2],o,h,t,e];break;case"s":l[1]+=t,l[2]+=e,l[3]+=t,l[4]+=e;case"S":n==="C"?(o=2*t-o,h=2*e-h):(o=t,h=e),t=l[3],e=l[4],u=["C",o,h,l[1],l[2],t,e],o=u[3],h=u[4];break;case"q":l[1]+=t,l[2]+=e,l[3]+=t,l[4]+=e;case"Q":o=l[1],h=l[2],t=l[3],e=l[4],u=["Q",o,h,t,e];break;case"t":l[1]+=t,l[2]+=e;case"T":n==="Q"?(o=2*t-o,h=2*e-h):(o=t,h=e),t=l[1],e=l[2],u=["Q",o,h,t,e];break;case"a":l[6]+=t,l[7]+=e;case"A":pa(t,e,l).forEach(g=>r.push(g)),t=l[6],e=l[7];break;case"z":case"Z":t=s,e=i,u=["Z"]}u?(r.push(u),n=u[0]):n=""}return r},Ds=(a,t,e,s)=>Math.sqrt((e-a)**2+(s-t)**2),nn=(a,t,e,s,i,r,n,o)=>h=>{const c=h**3,l=(d=>3*d**2*(1-d))(h),u=(d=>3*d*(1-d)**2)(h),g=(d=>(1-d)**3)(h);return new y(n*c+i*l+e*u+a*g,o*c+r*l+s*u+t*g)},on=a=>a**2,an=a=>2*a*(1-a),hn=a=>(1-a)**2,va=(a,t,e,s,i,r,n,o)=>h=>{const c=on(h),l=an(h),u=hn(h),g=3*(u*(e-a)+l*(i-e)+c*(n-i)),d=3*(u*(s-t)+l*(r-s)+c*(o-r));return Math.atan2(d,g)},ya=(a,t,e,s,i,r)=>n=>{const o=on(n),h=an(n),c=hn(n);return new y(i*o+e*h+a*c,r*o+s*h+t*c)},_a=(a,t,e,s,i,r)=>n=>{const o=1-n,h=2*(o*(e-a)+n*(i-e)),c=2*(o*(s-t)+n*(r-s));return Math.atan2(c,h)},lr=(a,t,e)=>{let s=new y(t,e),i=0;for(let r=1;r<=100;r+=1){const n=a(r/100);i+=Ds(s.x,s.y,n.x,n.y),s=n}return i},xa=(a,t)=>{let e,s=0,i=0,r={x:a.x,y:a.y},n=m({},r),o=.01,h=0;const c=a.iterator,l=a.angleFinder;for(;i<t&&o>1e-4;)n=c(s),h=s,e=Ds(r.x,r.y,n.x,n.y),e+i>t?(s-=o,o/=2):(r=n,s+=o,i+=e);return m(m({},n),{},{angle:l(h)})},cn=a=>{let t,e,s=0,i=0,r=0,n=0,o=0;const h=[];for(const c of a){const l={x:i,y:r,command:c[0],length:0};switch(c[0]){case"M":e=l,e.x=n=i=c[1],e.y=o=r=c[2];break;case"L":e=l,e.length=Ds(i,r,c[1],c[2]),i=c[1],r=c[2];break;case"C":t=nn(i,r,c[1],c[2],c[3],c[4],c[5],c[6]),e=l,e.iterator=t,e.angleFinder=va(i,r,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=lr(t,i,r),i=c[5],r=c[6];break;case"Q":t=ya(i,r,c[1],c[2],c[3],c[4]),e=l,e.iterator=t,e.angleFinder=_a(i,r,c[1],c[2],c[3],c[4]),e.length=lr(t,i,r),i=c[3],r=c[4];break;case"Z":e=l,e.destX=n,e.destY=o,e.length=Ds(i,r,n,o),i=n,r=o}s+=e.length,h.push(e)}return h.push({length:s,x:i,y:r}),h},Ca=function(a,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:cn(a),s=0;for(;t-e[s].length>0&&s<e.length-2;)t-=e[s].length,s++;const i=e[s],r=t/i.length,n=a[s];switch(i.command){case"M":return{x:i.x,y:i.y,angle:0};case"Z":return m(m({},new y(i.x,i.y).lerp(new y(i.destX,i.destY),r)),{},{angle:Math.atan2(i.destY-i.y,i.destX-i.x)});case"L":return m(m({},new y(i.x,i.y).lerp(new y(n[1],n[2]),r)),{},{angle:Math.atan2(n[2]-i.y,n[1]-i.x)});case"C":case"Q":return xa(i,t)}},ba=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),ur=new RegExp(ga,"g"),Sa=new RegExp(yt,"gi"),wa={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Ta=a=>{var t;const e=[],s=(t=a.match(ba))!==null&&t!==void 0?t:[];for(const i of s){const r=i[0];if(r==="z"||r==="Z"){e.push([r]);continue}const n=wa[r.toLowerCase()];let o=[];if(r==="a"||r==="A"){ur.lastIndex=0;for(let h=null;h=ur.exec(i);)o.push(...h.slice(1))}else o=i.match(Sa)||[];for(let h=0;h<o.length;h+=n){const c=new Array(n),l=da[r];c[0]=h>0&&l?l:r;for(let u=0;u<n;u++)c[u+1]=parseFloat(o[h+u]);e.push(c)}}return e},Oa=(a,t)=>a.map(e=>e.map((s,i)=>i===0||t===void 0?s:I(s,t)).join(" ")).join(" ");function li(a,t){const e=a.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(s=>{let[i,r]=s;return e.setProperty(i,r)}))}class Da extends Fr{constructor(t){let{allowTouchScrolling:e=!1,containerClass:s=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),p(this,"upper",void 0),p(this,"container",void 0);const{el:i}=this.lower,r=this.createUpperCanvas();this.upper={el:r,ctx:r.getContext("2d")},this.applyCanvasStyle(i,{allowTouchScrolling:e}),this.applyCanvasStyle(r,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const n=this.createContainerElement();n.classList.add(s),i.parentNode&&i.parentNode.replaceChild(n,i),n.append(i,r),this.container=n}createUpperCanvas(){const{el:t}=this.lower,e=Rt();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(){const t=de().createElement("div");return t.setAttribute("data-fabric","wrapper"),li(t,{position:"relative"}),Ri(t),t}applyCanvasStyle(t,e){const{styles:s,allowTouchScrolling:i}=e;li(t,m(m({},s),{},{"touch-action":i?"manipulation":rt})),Ri(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:s,ctx:i}=this.upper;jr(s,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),si(this.upper.el,t),si(this.container,t)}cleanupDOM(t){const e=this.container,{el:s}=this.lower,{el:i}=this.upper;super.cleanupDOM(t),e.removeChild(i),e.removeChild(s),e.parentNode&&e.parentNode.replaceChild(s,e)}dispose(){super.dispose(),wt().dispose(this.upper.el),delete this.upper,delete this.container}}class Bs extends Be{constructor(){super(...arguments),p(this,"targets",[]),p(this,"_hoveredTargets",[]),p(this,"_currentTransform",null),p(this,"_groupSelector",null),p(this,"contextTopDirty",!1)}static getDefaults(){return m(m({},super.getDefaults()),Bs.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Da(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(){const 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(){const t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;const e=this.getRetinaScaling(),s=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=s,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,s){const i=this.targetFindTolerance,r=this.pixelFindContext;this.clearContext(r),r.save(),r.translate(-e+i,-s+i),r.transform(...this.viewportTransform);const n=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(r),t.selectionBackgroundColor=n,r.restore();const o=Math.round(i*this.getRetinaScaling());return Po(r,o,o,o)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(s=>!!s&&t[s]===!0):t[e])}_shouldClearSelection(t,e){const s=this.getActiveObjects(),i=this._activeObject;return!!(!e||e&&i&&s.length>1&&s.indexOf(e)===-1&&i!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&i&&i!==e)}_shouldCenterTransform(t,e,s){if(!t)return;let i;return e===Es||e===ot||e===ut||e===Me?i=this.centeredScaling||t.centeredScaling:e===pi&&(i=this.centeredRotation||t.centeredRotation),i?!s:s}_getOriginFromCorner(t,e){const s={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?s.x=Y:["mr","tr","br"].includes(e)&&(s.x=j),["tl","mt","tr"].includes(e)?s.y=ei:["bl","mb","br"].includes(e)&&(s.y=it)),s}_setupCurrentTransform(t,e,s){var i;const r=e.group?ce(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:n="",control:o}=e.getActiveControl()||{},h=s&&o?(i=o.getActionHandler(t,e,o))===null||i===void 0?void 0:i.bind(o):Nn,c=((d,f,v,_)=>{if(!f||!d)return"drag";const x=_.controls[f];return x.getActionName(v,x,_)})(s,n,t,e),l=t[this.centeredKey],u=this._shouldCenterTransform(e,c,l)?{x:k,y:k}:this._getOriginFromCorner(e,n),g={target:e,action:c,actionHandler:h,actionPerformed:!1,corner:n,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:r.x-e.left,offsetY:r.y-e.top,originX:u.x,originY:u.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:V(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:l,original:m(m({},Lr(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=g,this.fire("before:transform",{e:t,transform:g})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:s,deltaX:i,deltaY:r}=this._groupSelector,n=new y(e,s).transform(this.viewportTransform),o=new y(e+i,s+r).transform(this.viewportTransform),h=this.selectionLineWidth/2;let c=Math.min(n.x,o.x),l=Math.min(n.y,o.y),u=Math.max(n.x,o.x),g=Math.max(n.y,o.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,l,u-c,g-l)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=h,l+=h,u-=h,g-=h,$.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,l,u-c,g-l))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),s=this._activeObject,i=this.getActiveObjects();if(this.targets=[],s&&i.length>=1){if(s.findControl(e,ii(t))||i.length>1&&this.searchPossibleTargets([s],e))return s;if(s===this.searchPossibleTargets([s],e)){if(this.preserveObjectStacking){const r=this.targets;this.targets=[];const n=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&n&&n!==s?(this.targets=r,s):n}return s}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let s=t.getCoords();const i=this.getZoom(),r=t.padding/i;if(r){const[n,o,h,c]=s,l=Math.atan2(o.y-n.y,o.x-n.x),u=Ft(l)*r,g=Lt(l)*r,d=u+g,f=u-g;s=[new y(n.x-f,n.y-d),new y(o.x+d,o.y-f),new y(h.x+f,h.y+d),new y(c.x-d,c.y+f)]}return W.isPointInPolygon(e,s)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,ce(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let s=t.length;for(;s--;){const i=t[s];if(this._checkTarget(i,e)){if(gs(i)&&i.subTargetCheck){const r=this._searchPossibleTargets(i._objects,e);r&&this.targets.push(r)}return i}}}searchPossibleTargets(t,e){const s=this._searchPossibleTargets(t,e);if(s&&gs(s)&&s.interactive&&this.targets[0]){const i=this.targets;for(let r=i.length-1;r>0;r--){const n=i[r];if(!gs(n)||!n.interactive)return n}return i[0]}return s}getViewportPoint(t){return this._pointer?this._pointer:this.getPointer(t,!0)}getScenePoint(t){return this._absolutePointer?this._absolutePointer:this.getPointer(t)}getPointer(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];const s=this.upperCanvasEl,i=s.getBoundingClientRect();let r=Xn(t),n=i.width||0,o=i.height||0;n&&o||(it in i&&ei in i&&(o=Math.abs(i.top-i.bottom)),Y in i&&j in i&&(n=Math.abs(i.right-i.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=ce(r,void 0,this.viewportTransform));const h=this.getRetinaScaling();h!==1&&(r.x/=h,r.y/=h);const c=n===0||o===0?new y(1,1):new y(s.width/n,s.height/o);return r.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=Rt(),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(){const t=this._activeObject;return qt(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let s=!1,i=!1;const r=this.getActiveObjects(),n=[],o=[];t.forEach(h=>{r.includes(h)||(s=!0,h.fire("deselected",{e,target:h}),o.push(h))}),r.forEach(h=>{t.includes(h)||(s=!0,h.fire("selected",{e,target:h}),n.push(h))}),t.length>0&&r.length>0?(i=!0,s&&this.fire("selection:updated",{e,selected:n,deselected:o})):r.length>0?(i=!0,this.fire("selection:created",{e,selected:n})):t.length>0&&(i=!0,this.fire("selection:cleared",{e,deselected:o})),i&&(this._objectsToRender=void 0)}setActiveObject(t,e){const s=this.getActiveObjects(),i=this._setActiveObject(t,e);return this._fireSelectionEvents(s,e),i}_setActiveObject(t,e){const s=this._activeObject;return s!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,qt(t)&&s!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){const s=this._activeObject;return!!s&&!s.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===s&&this.endCurrentTransform(t),qt(s)&&s===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){const e=this.getActiveObjects(),s=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[s]});const i=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),i}endCurrentTransform(t){const e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){const e=this._currentTransform,s=e.target,i={e:t,target:s,transform:e,action:e.action};s._scaling&&(s._scaling=!1),s.setCoords(),e.actionPerformed&&(this.fire("object:modified",i),s.fire(ys,i))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;qt(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){const e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,s){const i=this._realizeGroupTransformOnObject(t),r=super._toObject(t,e,s);return t.set(i),r}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&qt(e)&&this._activeObject===e){const s=ve(t,["angle","flipX","flipY",j,ot,ut,fe,pe,it]);return Yn(t,e.calcOwnMatrix()),s}return{}}_setSVGObject(t,e,s){const i=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,s),e.set(i)}}p(Bs,"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,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",notAllowedCursor:"not-allowed",perPixelTargetFind:!1,targetFindTolerance:0,skipTargetFind:!1,stopContextMenu:!1,fireRightClick:!1,fireMiddleClick:!1,enablePointerEvents:!1,containerClass:"canvas-container",preserveObjectStacking:!1});class ka{constructor(t){p(this,"targets",[]),p(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:i}=t.getActiveObject()||{};i&&i.focus()},s=t.upperCanvasEl;s.addEventListener("click",e),this.__disposer=()=>s.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),ne(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Ma=["target","oldTarget","fireCanvas","e"],at={passive:!1},re=(a,t)=>{const e=a.getViewportPoint(t),s=a.getScenePoint(t);return{viewportPoint:e,scenePoint:s,pointer:e,absolutePointer:s}},zt=function(a){for(var t=arguments.length,e=new Array(t>1?t-1:0),s=1;s<t;s++)e[s-1]=arguments[s];return a.addEventListener(...e)},ht=function(a){for(var t=arguments.length,e=new Array(t>1?t-1:0),s=1;s<t;s++)e[s-1]=arguments[s];return a.removeEventListener(...e)},Ea={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"}};class gr extends Bs{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),p(this,"_isClick",void 0),p(this,"textEditingManager",new ka(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(zt,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const s=this.upperCanvasEl,i=this._getEventPrefix();t(Ar(s),"resize",this._onResize),t(s,i+"down",this._onMouseDown),t(s,"".concat(i,"move"),this._onMouseMove,at),t(s,"".concat(i,"out"),this._onMouseOut),t(s,"".concat(i,"enter"),this._onMouseEnter),t(s,"wheel",this._onMouseWheel,{passive:!1}),t(s,"contextmenu",this._onContextMenu),t(s,"click",this._onClick),t(s,"dblclick",this._onClick),t(s,"dragstart",this._onDragStart),t(s,"dragend",this._onDragEnd),t(s,"dragover",this._onDragOver),t(s,"dragenter",this._onDragEnter),t(s,"dragleave",this._onDragLeave),t(s,"drop",this._onDrop),this.enablePointerEvents||t(s,"touchstart",this._onTouchStart,at)}removeListeners(){this.addOrRemove(ht,"remove");const t=this._getEventPrefix(),e=mt(this.upperCanvasEl);ht(e,"".concat(t,"up"),this._onMouseUp),ht(e,"touchend",this._onTouchEnd,at),ht(e,"".concat(t,"move"),this._onMouseMove,at),ht(e,"touchmove",this._onMouseMove,at),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,s=m({e:t},re(this,t));this.fire("mouse:out",m(m({},s),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",m({},s)),this._hoveredTargets.forEach(i=>{this.fire("mouse:out",m(m({},s),{},{target:i})),i&&i.fire("mouseout",m({},s))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",m({e:t},re(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;const e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;const s={e:t,target:e};return this.fire("dragstart",s),e.fire("dragstart",s),void zt(this.upperCanvasEl,"drag",this._onDragProgress)}Bi(t)}_renderDragEffects(t,e,s){let i=!1;const r=this._dropTarget;r&&r!==e&&r!==s&&(r.clearContextTop(),i=!0),e==null||e.clearContextTop(),s!==e&&(s==null||s.clearContextTop());const n=this.contextTop;n.save(),n.transform(...this.viewportTransform),e&&(n.save(),e.transform(n),e.renderDragSourceEffect(t),n.restore(),i=!0),s&&(n.save(),s.transform(n),s.renderDropTargetEffect(t),n.restore(),i=!0),n.restore(),i&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==rt,s=e?this._activeObject:void 0,i={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:s};ht(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",i),this._dragSource&&this._dragSource.fire("dragend",i),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){const e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){const e="dragover",{target:s,targets:i}=this.findDragTargets(t),r=this._dragSource,n={e:t,target:s,subTargets:i,dragSource:r,canDrop:!1,dropTarget:void 0};let o;this.fire(e,n),this._fireEnterLeaveEvents(s,n),s&&(s.canDrop(t)&&(o=s),s.fire(e,n));for(let h=0;h<i.length;h++){const c=i[h];c.canDrop(t)&&(o=c),c.fire(e,n)}this._renderDragEffects(t,r,o),this._dropTarget=o}_onDragEnter(t){const{target:e,targets:s}=this.findDragTargets(t),i={e:t,target:e,subTargets:s,dragSource:this._dragSource};this.fire("dragenter",i),this._fireEnterLeaveEvents(e,i)}_onDragLeave(t){const e={e:t,target:this._draggedoverTarget,subTargets:this.targets,dragSource:this._dragSource};this.fire("dragleave",e),this._fireEnterLeaveEvents(void 0,e),this._renderDragEffects(t,this._dragSource),this._dropTarget=void 0,this.targets=[],this._hoveredTargets=[]}_onDrop(t){const{target:e,targets:s}=this.findDragTargets(t),i=this._basicEventHandler("drop:before",m({e:t,target:e,subTargets:s,dragSource:this._dragSource},re(this,t)));i.didDrop=!1,i.dropTarget=void 0,this._basicEventHandler("drop",i),this.fire("drop:after",i)}_onContextMenu(t){const e=this.findTarget(t),s=this.targets||[],i=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:s});return this.stopContextMenu&&Bi(t),this._basicEventHandler("contextmenu",i),!1}_onClick(t){const e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),e==2&&t.type==="dblclick"&&this._handleEvent(t,"dblclick"),e==3&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){const e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const s=this._activeObject;this.mainTouchId===void 0&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||s&&this._target===s)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();const i=this.upperCanvasEl,r=this._getEventPrefix(),n=mt(i);zt(n,"touchend",this._onTouchEnd,at),e&&zt(n,"touchmove",this._onMouseMove,at),ht(i,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,s=this._getEventPrefix();ht(e,"".concat(s,"move"),this._onMouseMove,at);const i=mt(e);zt(i,"".concat(s,"up"),this._onMouseUp),zt(i,"".concat(s,"move"),this._onMouseMove,at)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),s=mt(this.upperCanvasEl);ht(s,"touchend",this._onTouchEnd,at),ht(s,"touchmove",this._onMouseMove,at),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{zt(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();const e=this.upperCanvasEl,s=this._getEventPrefix();if(this._isMainEvent(t)){const i=mt(this.upperCanvasEl);ht(i,"".concat(s,"up"),this._onMouseUp),ht(i,"".concat(s,"move"),this._onMouseMove,at),zt(e,"".concat(s,"move"),this._onMouseMove,at)}}_onMouseMove(t){const e=this.getActiveObject();!this.allowTouchScrolling&&(!e||!e.shouldStartDragging(t))&&t.preventDefault&&t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){const e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");const s=this._currentTransform,i=this._isClick,r=this._target,{button:n}=t;if(n)return(this.fireMiddleClick&&n===1||this.fireRightClick&&n===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let o,h,c=!1;if(s&&(this._finalizeCurrentTransform(t),c=s.actionPerformed),!i){const l=r===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(r)||!l&&r===this._activeObject)}if(r){const l=r.findControl(this.getViewportPoint(t),ii(t)),{key:u,control:g}=l||{};if(h=u,r.selectable&&r!==this._activeObject&&r.activeOn==="up")this.setActiveObject(r,t),c=!0;else if(g){const d=g.getMouseUpHandler(t,r,g);d&&(o=this.getScenePoint(t),d.call(g,t,s,o.x,o.y))}r.isMoving=!1}if(s&&(s.target!==r||s.corner!==h)){const l=s.target&&s.target.controls[s.corner],u=l&&l.getMouseUpHandler(t,s.target,l);o=o||this.getScenePoint(t),u&&u.call(l,t,s,o.x,o.y)}this._setCursorFromEvent(t,r),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,r&&(r.__corner=void 0),c?this.requestRenderAll():i||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:s,subTargets:i=[]}=e;this.fire(t,e),s&&s.fire(t,e);for(let r=0;r<i.length;r++)i[r]!==s&&i[r].fire(t,e);return e}_handleEvent(t,e,s){const i=this._target,r=this.targets||[],n=m(m(m({e:t,target:i,subTargets:r},re(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),e==="down:before"||e==="down"?s:{});this.fire("mouse:".concat(e),n),i&&i.fire("mouse".concat(e),n);for(let o=0;o<r.length;o++)r[o]!==i&&r[o].fire("mouse".concat(e),n)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());const 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){const e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){const 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._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,s=!!e&&e===this._activeObject;const{button:i}=t;if(i)return(this.fireMiddleClick&&i===1||this.fireRightClick&&i===2)&&this._handleEvent(t,"down",{alreadySelected:s}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let r=this._shouldRender(e),n=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,n=!0,r=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const o=this.getScenePoint(t);this._groupSelector={x:o.x,y:o.y,deltaY:0,deltaX:0}}if(s=!!e&&e===this._activeObject,e){e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const o=e.findControl(this.getViewportPoint(t),ii(t));if(e===this._activeObject&&(o||!n)){this._setupCurrentTransform(t,e,s);const h=o?o.control:void 0,c=this.getScenePoint(t),l=h&&h.getMouseDownHandler(t,e,h);l&&l.call(h,t,this._currentTransform,c.x,c.y)}}r&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:s}),r&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=ce(this._pointer,void 0,this.viewportTransform),this._target=this._currentTransform?this._currentTransform.target:this.findTarget(t)}__onMouseMove(t){if(this._isClick=!1,this._cacheTransformEventData(t),this._handleEvent(t,"move:before"),this.isDrawingMode)return void this._onMouseMoveInDrawingMode(t);if(!this._isMainEvent(t))return;const e=this._groupSelector;if(e){const s=this.getScenePoint(t);e.deltaX=s.x-e.x,e.deltaY=s.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{const s=this.findTarget(t);this._setCursorFromEvent(t,s),this._fireOverOutEvents(t,s)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const s=this._hoveredTarget,i=this._hoveredTargets,r=this.targets,n=Math.max(i.length,r.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:s,fireCanvas:!0});for(let o=0;o<n;o++)r[o]===e||i[o]&&i[o]===s||this.fireSyntheticInOutEvents("mouse",{e:t,target:r[o],oldTarget:i[o]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const s=this._draggedoverTarget,i=this._hoveredTargets,r=this.targets,n=Math.max(i.length,r.length);this.fireSyntheticInOutEvents("drag",m(m({},e),{},{target:t,oldTarget:s,fireCanvas:!0}));for(let o=0;o<n;o++)this.fireSyntheticInOutEvents("drag",m(m({},e),{},{target:r[o],oldTarget:i[o]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:s,oldTarget:i,fireCanvas:r,e:n}=e,o=X(e,Ma);const{targetIn:h,targetOut:c,canvasIn:l,canvasOut:u}=Ea[t],g=i!==s;if(i&&g){const d=m(m({},o),{},{e:n,target:i,nextTarget:s},re(this,n));r&&this.fire(u,d),i.fire(c,d)}if(s&&g){const d=m(m({},o),{},{e:n,target:s,previousTarget:i},re(this,n));r&&this.fire(l,d),s.fire(h,d)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),s=this._currentTransform,i=s.target,r=i.group?ce(e,void 0,i.group.calcTransformMatrix()):e;s.shiftKey=t.shiftKey,s.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,s,r),s.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,s){const{action:i,actionHandler:r,target:n}=e,o=!!r&&r(t,e,s.x,s.y);o&&n.setCoords(),i==="drag"&&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 s=e.hoverCursor||this.hoverCursor;const i=qt(this._activeObject)?this._activeObject:null,r=(!i||e.group!==i)&&e.findControl(this.getViewportPoint(t));if(r){const n=r.control;this.setCursor(n.cursorStyleHandler(t,n,e))}else e.subTargetCheck&&this.targets.concat().reverse().map(n=>{s=n.hoverCursor||s}),this.setCursor(s)}handleMultiSelection(t,e){const s=this._activeObject,i=qt(s);if(s&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(s!==e||i)&&(i||!e.isDescendantOf(s)&&!s.isDescendantOf(e))&&!e.onSelect({e:t})&&!s.getActiveControl()){if(i){const r=s.getObjects();if(e===s){const n=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(r,n)||this.searchPossibleTargets(this._objects,n))||!e.selectable)return!1}e.group===s?(s.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],s.size()===1&&this._setActiveObject(s.item(0),t)):(s.multiSelectAdd(e),this._hoveredTarget=s,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(r,t)}else{s.isEditing&&s.exitEditing();const r=new(T.getClass("ActiveSelection"))([],{canvas:this});r.multiSelectAdd(s,e),this._hoveredTarget=r,this._setActiveObject(r,t),this._fireSelectionEvents([s],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:s,deltaX:i,deltaY:r}=this._groupSelector,n=new y(e,s),o=n.add(new y(i,r)),h=n.min(o),c=n.max(o).subtract(h),l=this.collectObjects({left:h.x,top:h.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),u=n.eq(o)?l[0]?[l[0]]:[]:l.length>1?l.filter(g=>!g.onSelect({e:t})).reverse():l;if(u.length===1)this.setActiveObject(u[0],t);else if(u.length>1){const g=T.getClass("ActiveSelection");this.setActiveObject(new g(u,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const ln={x1:0,y1:0,x2:0,y2:0},Pa=m(m({},ln),{},{r1:0,r2:0}),ae=(a,t)=>isNaN(a)&&typeof t=="number"?t:a;function un(a){return a&&/%$/.test(a)&&Number.isFinite(parseFloat(a))}
41function gn(a,t){const e=typeof a=="number"?a:typeof a=="string"?parseFloat(a)/(un(a)?100:1):NaN;return ge(0,ae(e,t),1)}const Aa=/\s*;\s*/,ja=/\s*:\s*/;function Fa(a,t){let e,s;const i=a.getAttribute("style");if(i){const n=i.split(Aa);n[n.length-1]===""&&n.pop();for(let o=n.length;o--;){const[h,c]=n[o].split(ja).map(l=>l.trim());h==="stop-color"?e=c:h==="stop-opacity"&&(s=c)}}const r=new F(e||a.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:gn(a.getAttribute("offset"),0),color:r.toRgb(),opacity:ae(parseFloat(s||a.getAttribute("stop-opacity")||""),1)*r.getAlpha()*t}}function La(a,t){const e=[],s=a.getElementsByTagName("stop"),i=gn(t,1);for(let r=s.length;r--;)e.push(Fa(s[r],i));return e}function dn(a){return a.nodeName==="linearGradient"||a.nodeName==="LINEARGRADIENT"?"linear":"radial"}function fn(a){return a.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function dt(a,t){return a.getAttribute(t)}function Ra(a,t){return function(e,s){let i,{width:r,height:n,gradientUnits:o}=s;return Object.entries(e).reduce((h,c)=>{let[l,u]=c;if(u==="Infinity")i=1;else if(u==="-Infinity")i=0;else{const g=typeof u=="string";i=g?parseFloat(u):u,g&&un(u)&&(i*=.01,o==="pixels"&&(l!=="x1"&&l!=="x2"&&l!=="r2"||(i*=r),l!=="y1"&&l!=="y2"||(i*=n)))}return h[l]=i,h},{})}(dn(a)==="linear"?function(e){return{x1:dt(e,"x1")||0,y1:dt(e,"y1")||0,x2:dt(e,"x2")||"100%",y2:dt(e,"y2")||0}}(a):function(e){return{x1:dt(e,"fx")||dt(e,"cx")||"50%",y1:dt(e,"fy")||dt(e,"cy")||"50%",r1:0,x2:dt(e,"cx")||"50%",y2:dt(e,"cy")||"50%",r2:dt(e,"r")||"50%"}}(a),m(m({},t),{},{gradientUnits:fn(a)}))}class ze{constructor(t){const{type:e="linear",gradientUnits:s="pixels",coords:i={},colorStops:r=[],offsetX:n=0,offsetY:o=0,gradientTransform:h,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:s,coords:m(m({},e==="radial"?Pa:ln),i),colorStops:r,offsetX:n,offsetY:o,gradientTransform:h,id:c?"".concat(c,"_").concat(Ht()):Ht()})}addColorStop(t){for(const e in t){const s=new F(t[e]);this.colorStops.push({offset:parseFloat(e),color:s.toRgb(),opacity:s.getAlpha()})}return this}toObject(t){return m(m({},ve(this,t)),{}
41,{type:this.type,coords:m({},this.coords),colorStops:this.colorStops.map(e=>m({},e)),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=[],i=this.gradientTransform?this.gradientTransform.concat():et.concat(),r=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",n=this.colorStops.map(u=>m({},u)).sort((u,g)=>u.offset-g.offset);let o=-this.offsetX,h=-this.offsetY;var c;r==="objectBoundingBox"?(o/=t.width,h/=t.height):(o+=t.width/2,h+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(o-=t.pathOffset.x,h-=t.pathOffset.y),i[4]-=o,i[5]-=h;const l=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(r,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Pe(i),'"'),""].join(" ");if(this.type==="linear"){const{x1:u,y1:g,x2:d,y2:f}=this.coords;s.push("<linearGradient ",l,' x1="',u,'" y1="',g,'" x2="',d,'" y2="',f,`">
42`)}else if(this.type==="radial"){const{x1:u,y1:g,x2:d,y2:f,r1:v,r2:_}=this.coords,x=v>_;
vendor: 4,378 bytes, lines 42-46
42s.push("<radialGradient ",l,' cx="',x?u:d,'" cy="',x?g:f,'" r="',x?v:_,'" fx="',x?d:u,'" fy="',x?f:g,`">
43`),x&&(n.reverse(),n.forEach(S=>{S.offset=1-S.offset}));const C=Math.min(v,_);if(C>0){const S=C/Math.max(v,_);n.forEach(b=>{b.offset+=S*(1-b.offset)})}}return n.forEach(u=>{let{color:g,offset:d,opacity:f}=u;s.push("<stop ",'offset="',100*d+"%",'" style="stop-color:',g,f!==void 0?";stop-opacity: "+f:";",`"/>
44`)}),s.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
45`),s.join("")}toLive(t){const{x1:e,y1:s,x2:i,y2:r,r1:n,r2:o}=this.coords,h=this.type==="linear"?t.createLinearGradient(e,s,i,r):t.createRadialGradient(e,s,n,i,r,o);return this.colorStops.forEach(c=>{let{color:l,opacity:u,offset:g}=c;h.addColorStop(g,u!==void 0?new F(l).setAlpha(u).toRgba():l)}),h}static async fromObject(t){const{colorStops:e,gradientTransform:s}=t;return new this(m(m({},t),{},{colorStops:e?e.map(i=>m({},i)):void 0,gradientTransform:s?[...s]:void 0}))}static fromElement(t,e,s){const i=fn(t),r=e._findCenterFromElement();return new this(m({id:t.getAttribute("id")||void 0,type:dn(t),coords:Ra(t,{width:s.viewBoxWidth||s.width,height:s.viewBoxHeight||s.height}),colorStops:La(t,s.opacity),gradientUnits:i,gradientTransform:ai(t.getAttribute("gradientTransform")||"")},i==="pixels"?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}p(ze,"type","Gradient"),T.setClass(ze,"gradient"),T.setClass(ze,"linear"),T.setClass(ze,"radial");const Ba=["type","source","patternTransform"];class qs{get type(){return"pattern"}set type(t){Gt("warn","Setting type has no effect",t)}constructor(t){p(this,"repeat","repeat"),p(this,"offsetX",0),p(this,"offsetY",0),p(this,"crossOrigin",""),this.id=Ht(),Object.assign(this,t)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:s}=this;return m(m({},ve(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:s,offsetX:I(this.offsetX,E.NUM_FRACTION_DIGITS),offsetY:I(this.offsetY,E.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:s}=t;const{source:i,repeat:r,id:n}=this,o=ae(this.offsetX/e,0),h=ae(this.offsetY/s,0),c=r==="repeat-y"||r==="no-repeat"?1+Math.abs(o||0):ae(i.width/e,0),l=r==="repeat-x"||r==="no-repeat"?1+Math.abs(h||0):ae(i.height/s,0);return['<pattern id="SVGID_'.concat(n,'" x="').concat(o,'" y="').concat(h,'" width="').concat(c,'" height="').concat(l,'">'),'<image x="0" y="0" width="'.concat(i.width,'" height="').concat(i.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
46`)}static async fromObject(t,e){let{type:s,source:i,patternTransform:r}=t,n=X(t,Ba);const o=await fs(i,m(m({},e),{},{crossOrigin:n.crossOrigin}));return new this(m(m({},n),{},{patternTransform:r&&r.slice(0),source:o}))}}p(qs,"type","Pattern"),T.setClass(qs),T.setClass(qs,"pattern");const Ia=["path","left","top"],Xa=["d"];class Kt extends ${constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:s,left:i,top:r}=e,n=X(e,Ia);super(),Object.assign(this,Kt.ownDefaults),this.setOptions(n),this._setPath(t||[],!0),typeof i=="number"&&this.set(j,i),typeof r=="number"&&this.set(it,r)}_setPath(t,e){this.path=ma(Array.isArray(t)?t:Ta(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new y(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,s=-this.pathOffset.y;t.beginPath();for(const i of this.path)switch(i[0]){case"L":t.lineTo(i[1]+e,i[2]+s);break;case"M":t.moveTo(i[1]+e,i[2]+s);break;case"C":t.bezierCurveTo(i[1]+e,i[2]+s,i[3]+e,i[4]+s,i[5]+e,i[6]+s);break;case"Q":t.quadraticCurveTo(i[1]+e,i[2]+s,i[3]+e,i[4]+s);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left"
46: ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return m(m({},super.toObject(t)),{},{path:this.path.map(e=>e.slice())})}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=Oa(this.path,E.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
47`)]}_getOffsetTransform(){const t=E.NUM_FRACTION_DIGITS;return" translate(".concat(I(-this.pathOffset.x,t),", ").concat(I(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return"	"+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:s,pathOffset:i}=this._calcDimensions();this.set({width:e,height:s,pathOffset:i}),t&&this.setPositionByOrigin(i,k,k)}_calcBoundsFromPath(){const t=[];let e=0,s=0,i=0,r=0;for(const n of this.path)switch(n[0]){case"L":i=n[1],r=n[2],t.push({x:e,y:s},{x:i,y:r});break;case"M":i=n[1],r=n[2],e=i,s=r;break;case"C":t.push(...cr(i,r,n[1],n[2],n[3],n[4],n[5],n[6])),i=n[5],r=n[6];break;case"Q":t.push(...cr(i,r,n[1],n[2],n[1],n[2],n[3],n[4])),i=n[3],r=n[4];break;case"Z":i=e,r=s}return At(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return m(m({},t),{},{pathOffset:new y(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,s){const i=Xt(t,this.ATTRIBUTE_NAMES,s),{d:r}=i;return new this(r,m(m(m({},X(i,Xa)),e),{},{left:void 0,top:void 0}))}}p(Kt,"type","Path"),p(Kt,"cacheProperties",[...It,"path","fillRule"]),p(Kt,"ATTRIBUTE_NAMES",[...Nt,"d"]),T.setClass(Kt),T.setSVGClass(Kt);const Wa=["left","top","radius"],pn=["radius","startAngle","endAngle","counterClockwise"];class kt extends ${static getDefaults(){return m(m({},super.getDefaults()),kt.ownDefaults)}constructor(t){super(),Object.assign(this,kt.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,V(this.startAngle),V(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(ot)}getRadiusY(){return this.get("radius")*this.get(ut)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...pn,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
48`];{const{radius:e}=this,s=V(this.startAngle),i=V(this.endAngle),r=Ft(s)*e,n=Lt(s)*e,o=Ft(i)*e,h=Lt(i)*e,c=t>180?1:0,l=this.counterClockwise?0:1;return['<path d="M '.concat(r," ").concat(n," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(l," ").concat(o," ").concat(h,'" '),"COMMON_PARTS",` />
49`]}}static async fromElement(t,e,s){const i=Xt(t,this.ATTRIBUTE_NAMES,s),{left:r=0,top:n=0,radius:o=0}=i;return new this(m(m({},X(i,Wa)),{},{radius:o,left:r-o,top:n-o}))}static fromObject(t){return super._fromObject(t)}}p(kt,"type","Circle"),p(kt,"cacheProperties",[...It,...pn]),p(kt,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),p(kt,"ATTRIBUTE_NAMES",["cx","cy","r",...Nt]),T.setClass(kt),T.setSVGClass(kt);const Ya=["x1","y1","x2","y2"],Va=["x1","y1","x2","y2"],ui=["x1","x2","y1","y2"];class Jt extends ${constructor(){let[t,e,s,i]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Jt.ownDefaults),this.setOptions(r),this.x1=t,this.x2=s,this.y1=e,this.y2=i,this._setWidthHeight();const{left:n,top:o}=r;typeof n=="number"&&this.set(j,n),typeof o=="number"&&this.set(it,o)}_setWidthHeight(){const{x1:t,y1:e,x2:s,y2:i}=this;this.width=Math.abs(s-t),this.height=Math.abs(i-e);const{left:r,top:n,width:o,height:h}=At([{x:t,y:e},{x:s,y:i}]),c=new y(r+o/2,n+h/2);this.setPositionByOrigin(c,k,k)}
vendor: 98,648 bytes, lines 49-199
49_set(t,e){return super._set(t,e),ui.includes(t)&&this._setWidthHeight(),this}_render(t){t.beginPath();const e=this.calcLinePoints();t.moveTo(e.x1,e.y1),t.lineTo(e.x2,e.y2),t.lineWidth=this.strokeWidth;const s=t.strokeStyle;var i;lt(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(i=this.stroke)!==null&&i!==void 0?i:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=s}_findCenterFromElement(){return new y((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return m(m({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:s,y2:i,width:r,height:n}=this,o=t<=e?-1:1,h=s<=i?-1:1;return{x1:o*r/2,x2:o*-r/2,y1:h*n/2,y2:h*-n/2}}_toSVG(){const{x1:t,x2:e,y1:s,y2:i}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(s,'" x2="').concat(e,'" y2="').concat(i,`" />
50`)]}static async fromElement(t,e,s){const i=Xt(t,this.ATTRIBUTE_NAMES,s),{x1:r=0,y1:n=0,x2:o=0,y2:h=0}=i;return new this([r,n,o,h],X(i,Ya))}static fromObject(t){let{x1:e,y1:s,x2:i,y2:r}=t,n=X(t,Va);return this._fromObject(m(m({},n),{},{points:[e,s,i,r]}),{extraParam:"points"})}}p(Jt,"type","Line"),p(Jt,"cacheProperties",[...It,...ui]),p(Jt,"ATTRIBUTE_NAMES",Nt.concat(ui)),T.setClass(Jt),T.setSVGClass(Jt);class Zt extends ${static getDefaults(){return m(m({},super.getDefaults()),Zt.ownDefaults)}constructor(t){super(),Object.assign(this,Zt.ownDefaults),this.setOptions(t)}_render(t){const e=this.width/2,s=this.height/2;t.beginPath(),t.moveTo(-e,s),t.lineTo(0,-s),t.lineTo(e,s),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){const t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}}p(Zt,"type","Triangle"),p(Zt,"ownDefaults",{width:100,height:100}),T.setClass(Zt),T.setSVGClass(Zt);const mn=["rx","ry"];class Mt extends ${static getDefaults(){return m(m({},super.getDefaults()),Mt.ownDefaults)}constructor(t){super(),Object.assign(this,Mt.ownDefaults),this.setOptions(t)}_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(ot)}getRy(){return this.get("ry")*this.get(ut)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...mn,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(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,ms,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,s){const i=Xt(t,this.ATTRIBUTE_NAMES,s);return i.left=(i.left||0)-i.rx,i.top=(i.top||0)-i.ry,new this(i)}}function za(a){if(!a)return[];const t=a.replace(/,/g," ").trim().split(/\s+/),e=[];for(let s=0;s<t.length;s+=2)e.push({x:parseFloat(t[s]),y:parseFloat(t[s+1])});return e}p(Mt,"type","Ellipse"),p(Mt,"cacheProperties",[...It,...mn]),p(Mt,"ownDefaults",{rx:0,ry:0}),p(Mt,"ATTRIBUTE_NAMES",[...Nt,"cx","cy","rx","ry"]),T.setClass(Mt),T.setSVGClass(Mt);const Ga=["left","top"],vn={exactBoundingBox:!1};class pt extends ${static getDefaults(){return m(m({},super.getDefaults()),pt.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),p(this,"strokeDiff",void 0),Object.assign(this,pt.ownDefaults),this.setOptions(e),this.points=t;const{left:s,top:i}=e;this.initialized=!0,this.setBoundingBox(!0),typeof s=="number"&&this.set(j,s),typeof i=="number"&&this.set(it,i)}isOpen(){return!0}_projectStrokeOnPoints(t){return jo(this.points,t,this.isOpen())}_calcDimensions(t){t=m({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||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(c=>c.projectedPoint):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new y,strokeOffset:new y,strokeDiff:new y};const s=At(e),i=Ps(m(m({},t),{},{scaleX:1,scaleY:1})),r=At(this.points.map(c=>st(c,i,!0))),n=new y(this.scaleX,this.scaleY);let o=s.left+s.width/2,h=s.top+s.height/2;return this.exactBoundingBox&&(o-=h*Math.tan(V(this.skewX)),h-=o*Math.tan(V(this.skewY))),m(m({},s),{},{pathOffset:new y(o,h),strokeOffset:new y(r.left,r.top).subtract(new y(s.left,s.top)).multiply(n),strokeDiff:new y(s.width,s.height).subtract(new y(r.width,r.height)).multiply(n)})}_findCenterFromElement(){const t=At(this.points);return new y(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:s,width:i,height:r,pathOffset:n,strokeOffset:o,strokeDiff:h}=this._calcDimensions();this.set({width:i,height:r,pathOffset:n,strokeOffset:o,strokeDiff:h}),t&&this.setPositionByOrigin(new y(e+i/2,s+r/2),k,k)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new y(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let n;if(Object.keys(t).some(o=>this.strokeUniform||this.constructor.layoutProperties.includes(o))){var e,s;const{width:o,height:h}=this._calcDimensions(t);n=new y((e=t.width)!==null&&e!==void 0?e:o,(s=t.height)!==null&&s!==void 0?s:h)}else{var i,r;n=new y((i=t.width)!==null&&i!==void 0?i:this.width,(r=t.height)!==null&&r!==void 0?r:this.height)}return n.multiply(new y(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const s=this.initialized&&this[t]!==e,i=super._set(t,e);return this.exactBoundingBox&&s&&((t===ot||t===ut)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),i}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return m(m({},super.toObject(t)),{},{points:this.points.map(e=>{let{x:s,y:i}=e;return{x:s,y:i}})})}_toSVG(){const t=[],e=this.pathOffset.x,s=this.pathOffset.y,i=E.NUM_FRACTION_DIGITS;for(let r=0,n=this.points.length;r<n;r++)t.push(I(this.points[r].x-e,i),",",I(this.points[r].y-s,i)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
52`)]}_render(t){const e=this.points.length,s=this.pathOffset.x,i=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-s,this.points[0].y-i);for(let r=0;r<e;r++){const n=this.points[r];t.lineTo(n.x-s,n.y-i)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,s){return new this(za(t.getAttribute("points")),m(m({},X(Xt(t,this.ATTRIBUTE_NAMES,s),Ga)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}p(pt,"ownDefaults",vn),p(pt,"type","Polyline"),p(pt,"layoutProperties",[fe,pe,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),p(pt,"cacheProperties",[...It,"points"]),p(pt,"ATTRIBUTE_NAMES",[...Nt]),T.setClass(pt),T.setSVGClass(pt);class Ge extends pt{isOpen(){return!1}}p(Ge,"ownDefaults",vn),p(Ge,"type","Polygon"),T.setClass(Ge),T.setSVGClass(Ge);class yn extends ${isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const s in e)for(const i in e[s])for(const r in e[s][i])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const s=e===void 0?this.styles:{0:this.styles[e]};for(const i in s)for(const r in s[i])if(s[i][r][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let s,i,r=0,n=!0,o=0;for(const h in e){s=0;for(const c in e[h]){const l=e[h][c]||{};r++,l[t]!==void 0?(i?l[t]!==i&&(n=!1):i=l[t],l[t]===this[t]&&delete l[t]):n=!1,Object.keys(l).length!==0?s++:delete e[h][c]}s===0&&delete e[h]}for(let h=0;h<this._textLines.length;h++)o+=this._textLines[h].length;n&&r===o&&(this[t]=i,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let s,i,r;for(i in e){for(r in s=e[i],s)delete s[r][t],Object.keys(s[r]).length===0&&delete s[r];Object.keys(s).length===0&&delete e[i]}}_extendStyles(t,e){const{lineIndex:s,charIndex:i}=this.get2DCursorLocation(t);this._getLineStyle(s)||this._setLineStyle(s);const r=_i(m(m({},this._getStyleDeclaration(s,i)),e),n=>n!==void 0);this._setStyleDeclaration(s,i,r)}getSelectionStyles(t,e,s){const i=[];for(let r=t;r<(e||t);r++)i.push(this.getStyleAtPosition(r,s));return i}getStyleAtPosition(t,e){const{lineIndex:s,charIndex:i}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(s,i):this._getStyleDeclaration(s,i)}setSelectionStyles(t,e,s){for(let i=e;i<(s||e);i++)this._extendStyles(i,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var s;const i=this.styles&&this.styles[t];return i&&(s=i[e])!==null&&s!==void 0?s:{}}getCompleteStyleDeclaration(t,e){return m(m({},ve(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,s){this.styles[t][e]=s}_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]}}p(yn,"_styleProperties",qn);const Ha=/  +/g,Na=/"/g;function Ks(a,t,e,s,i){return"		".concat(function(r,n){let{left:o,top:h,width:c,height:l}=n,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:E.NUM_FRACTION_DIGITS;const g=Ae(H,r,!1),[d,f,v,_]=[o,h,c,l].map(x=>I(x,u));return"<rect ".concat(g,' x="').concat(d,'" y="').concat(f,'" width="').concat(v,'" height="').concat(_,'"></rect>')}(a,{left:t,top:e,width:s,height:i}),`
53`)}const Ua=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Js;class Q extends yn{static getDefaults(){return m(m({},super.getDefaults()),Q.ownDefaults)}constructor(t,e){super(),p(this,"__charBounds",[]),Object.assign(this,Q.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=cn(t.path))}_splitText(){const 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(bt)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,s,i,r,n,o;for(let h=0,c=this._textLines.length;h<c;h++)if((this.textAlign===bt||h!==c-1&&!this.isEndOfWrapping(h))&&(i=0,r=this._textLines[h],e=this.getLineWidth(h),e<this.width&&(o=this.textLines[h].match(this._reSpacesAndTabs)))){s=o.length,t=(this.width-e)/s;for(let l=0;l<=r.length;l++)n=this.__charBounds[h][l],this._reSpaceAndTab.test(r[l])?(n.width+=t,n.kernedWidth+=t,n.left+=i,i+=t):n.left+=i}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const s=e?this._unwrappedTextLines:this._textLines;let i;for(i=0;i<s.length;i++){if(t<=s[i].length)return{lineIndex:i,charIndex:t};t-=s[i].length+this.missingNewlineOffset(i,e)}return{lineIndex:i-1,charIndex:s[i-1].length<t?s[i-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){const t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){const e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===nt?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,s){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case k:t.textBaseline="middle";break;case"ascender":t.textBaseline=it;break;case"descender":t.textBaseline=ei}t.font=this._getFontDeclaration(e,s)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,s=this._textLines.length;e<s;e++){const i=this.getLineWidth(e);i>t&&(t=i)}return t}_renderTextLine(t,e,s,i,r,n){this._renderChars(t,e,s,i,r,n)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,s=this._getLeftOffset();let i=this._getTopOffset();for(let r=0,n=this._textLines.length;r<n;r++){const o=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){i+=o;continue}const h=this._textLines[r].length,c=this._getLineLeftOffset(r);let l,u,g=0,d=0,f=this.getValueOfPropertyAt(r,0,"textBackgroundColor");const v=this.getHeightOfLineImpl(r);for(let _=0;_<h;_++){const x=this.__charBounds[r][_];u=this.getValueOfPropertyAt(r,_,"textBackgroundColor"),this.path?(t.save(),t.translate(x.renderLeft,x.renderTop),t.rotate(x.angle),t.fillStyle=u,u&&t.fillRect(-x.width/2,-v*(1-this._fontSizeFraction),x.width,v),t.restore()):u!==f?(l=s+c+d,this.direction==="rtl"&&(l=this.width-l-g),t.fillStyle=f,f&&t.fillRect(l,i,g,v),d=x.left,g=x.width,f=u):g+=x.kernedWidth}u&&!this.path&&(l=s+c+d,this.direction==="rtl"&&(l=this.width-l-g),t.fillStyle=u,t.fillRect(l,i,g,v)),i+=o}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,s,i){const r=Te.getFontCache(e),n=this._getFontDeclaration(e),o=s+t,h=s&&n===this._getFontDeclaration(i),c=e.fontSize/this.CACHE_FONT_SIZE;let l,u,g,d;if(s&&r.has(s)&&(g=r.get(s)),r.has(t)&&(d=l=r.get(t)),h&&r.has(o)&&(u=r.get(o),d=u-g),l===void 0||g===void 0||u===void 0){const f=function(){return Js||(Js=gt({width:0,height:0}).getContext("2d")),Js}();this._setTextStyles(f,e,!0),l===void 0&&(d=l=f.measureText(t).width,r.set(t,l)),g===void 0&&h&&s&&(g=f.measureText(s).width,r.set(s,g)),h&&u===void 0&&(u=f.measureText(o).width,r.set(o,u),d=u-g)}return{width:l*c,kernedWidth:d*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,s,i=0;const r=this.pathSide===Y,n=this.path,o=this._textLines[t],h=o.length,c=new Array(h);this.__charBounds[t]=c;for(let l=0;l<h;l++){const u=o[l];s=this._getGraphemeBox(u,t,l,e),c[l]=s,i+=s.kernedWidth,e=u}if(c[h]={left:s?s.left+s.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},n&&n.segmentsInfo){let l=0;const u=n.segmentsInfo[n.segmentsInfo.length-1].length;switch(this.textAlign){case j:l=r?u-i:0;break;case k:l=(u-i)/2;break;case Y:l=r?0:u-i}l+=this.pathStartOffset*(r?-1:1);for(let g=r?h-1:0;r?g>=0:g<h;r?g--:g++)s=c[g],l>u?l%=u:l<0&&(l+=u),this._setGraphemeOnPath(l,s),l+=s.kernedWidth}return{width:i,numOfSpaces:0}}_setGraphemeOnPath(t,e){const s=t+e.kernedWidth/2,i=this.path,r=Ca(i.path,s,i.segmentsInfo);e.renderLeft=r.x-i.pathOffset.x,e.renderTop=r.y-i.pathOffset.y,e.angle=r.angle+(this.pathSide===Y?Math.PI:0)}_getGraphemeBox(t,e,s,i,r){const n=this.getCompleteStyleDeclaration(e,s),o=i?this.getCompleteStyleDeclaration(e,s-1):{},h=this._measureChar(t,n,i,o);let c,l=h.kernedWidth,u=h.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,l+=c);const g={width:u,left:0,height:n.fontSize,kernedWidth:l,deltaY:n.deltaY};if(s>0&&!r){const d=this.__charBounds[e][s-1];g.left=d.left+d.width+h.kernedWidth-h.width}return g}getHeightOfLineImpl(t){const e=this.__lineHeights;if(e[t])return e[t];let s=this.getHeightOfChar(t,0);for(let i=1,r=this._textLines[t].length;i<r;i++)s=Math.max(this.getHeightOfChar(t,i),s);return e[t]=s*this._fontSizeMult}getHeightOfLine(t){return this.getHeightOfLineImpl(t)*this.lineHeight}calcTextHeight(){let t=0;for(let e=0,s=this._textLines.length;e<s;e++)t+=e===s-1?this.getHeightOfLineImpl(e):this.getHeightOfLine(e);return t}_getLeftOffset(){return this.direction==="ltr"?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let s=0;const i=this._getLeftOffset(),r=this._getTopOffset();for(let n=0,o=this._textLines.length;n<o;n++)this._renderTextLine(e,t,this._textLines[n],i+this._getLineLeftOffset(n),r+s+this.getHeightOfLineImpl(n),n),s+=this.getHeightOfLine(n);t.restore()}_renderTextFill(t){(this.fill||this.styleHas(H))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,s,i,r,n){const o=this.textAlign.includes(bt),h=this.path,c=!o&&this.charSpacing===0&&this.isEmptyStyles(n)&&!h,l=this.direction==="ltr",u=this.direction==="ltr"?1:-1,g=e.direction;let d,f,v,_,x,C="",S=0;if(e.save(),g!==this.direction&&(e.canvas.setAttribute("dir",l?"ltr":"rtl"),e.direction=l?"ltr":"rtl",e.textAlign=l?j:Y),r-=this.getHeightOfLineImpl(n)*this._fontSizeFraction,c)return this._renderChar(t,e,n,0,s.join(""),i,r),void e.restore();for(let b=0,w=s.length-1;b<=w;b++)_=b===w||this.charSpacing||h,C+=s[b],v=this.__charBounds[n][b],S===0?(i+=u*(v.kernedWidth-v.width),S+=v.width):S+=v.kernedWidth,o&&!_&&this._reSpaceAndTab.test(s[b])&&(_=!0),_||(d=d||this.getCompleteStyleDeclaration(n,b),f=this.getCompleteStyleDeclaration(n,b+1),_=Di(d,f,!1)),_&&(h?(e.save(),e.translate(v.renderLeft,v.renderTop),e.rotate(v.angle),this._renderChar(t,e,n,b,C,-S/2,0),e.restore()):(x=i,this._renderChar(t,e,n,b,C,x,r)),C="",d=f,i+=u*S,S=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,s=this.height+this.strokeWidth,i=gt({width:e,height:s}),r=i.getContext("2d");return i.width=e,i.height=s,r.beginPath(),r.moveTo(0,0),r.lineTo(e,0),r.lineTo(e,s),r.lineTo(0,s),r.closePath(),r.translate(e/2,s/2),r.fillStyle=t.toLive(r),this._applyPatternGradientTransform(r,t),r.fill(),r.createPattern(i,"no-repeat")}handleFiller(t,e,s){let i,r;return lt(s)?s.gradientUnits==="percentage"||s.gradientTransform||s.patternTransform?(i=-this.width/2,r=-this.height/2,t.translate(i,r),t[e]=this._applyPatternGradientTransformText(s),{offsetX:i,offsetY:r}):(t[e]=s.toLive(t),this._applyPatternGradientTransform(t,s)):(t[e]=s,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:s,strokeWidth:i}=e;return t.lineWidth=i,t.lineCap=this.strokeLineCap,t.lineDashOffset=this.strokeDashOffset,t.lineJoin=this.strokeLineJoin,t.miterLimit=this.strokeMiterLimit,this.handleFiller(t,"strokeStyle",s)}_setFillStyles(t,e){let{fill:s}=e;return this.handleFiller(t,"fillStyle",s)}_renderChar(t,e,s,i,r,n,o){const h=this._getStyleDeclaration(s,i),c=this.getCompleteStyleDeclaration(s,i),l=t==="fillText"&&c.fill,u=t==="strokeText"&&c.stroke&&c.strokeWidth;if(u||l){if(e.save(),e.font=this._getFontDeclaration(c),h.textBackgroundColor&&this._removeShadow(e),h.deltaY&&(o+=h.deltaY),l){const g=this._setFillStyles(e,c);e.fillText(r,n-g.offsetX,o-g.offsetY)}if(u){const g=this._setStrokeStyles(e,c);e.strokeText(r,n-g.offsetX,o-g.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,s){const i=this.get2DCursorLocation(t,!0),r=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"fontSize"),n=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"deltaY"),o={fontSize:r*s.size,deltaY:n+r*s.baseline};this.setSelectionStyles(o,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),s=this.width-e,i=this.textAlign,r=this.direction,n=this.isEndOfWrapping(t);let o=0;return i===bt||i===De&&!n||i===Oe&&!n||i===ws&&!n?0:(i===k&&(o=s/2),i===Y&&(o=s),i===De&&(o=s/2),i===Oe&&(o=s),r==="rtl"&&(i===Y||i===bt||i===Oe?o=0:i===j||i===ws?o=-s:i!==k&&i!==De||(o=-s/2)),o)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,s){var i;return(i=this._getStyleDeclaration(t,e)[s])!==null&&i!==void 0?i:this[s]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let s=this._getTopOffset();const i=this._getLeftOffset(),r=this.path,n=this._getWidthOfCharSpacing(),o=e==="linethrough"?.5:e==="overline"?1:0,h=this.offsets[e];for(let c=0,l=this._textLines.length;c<l;c++){const u=this.getHeightOfLine(c);if(!this[e]&&!this.styleHas(e,c)){s+=u;continue}const g=this._textLines[c],d=u/this.lineHeight,f=this._getLineLeftOffset(c);let v=0,_=0,x=this.getValueOfPropertyAt(c,0,e),C=this.getValueOfPropertyAt(c,0,H),S=this.getValueOfPropertyAt(c,0,ee),b=x,w=C,D=S;const M=s+d*(1-this._fontSizeFraction);let O=this.getHeightOfChar(c,0),A=this.getValueOfPropertyAt(c,0,"deltaY");for(let R=0,L=g.length;R<L;R++){const P=this.__charBounds[c][R];b=this.getValueOfPropertyAt(c,R,e),w=this.getValueOfPropertyAt(c,R,H),D=this.getValueOfPropertyAt(c,R,ee);const K=this.getHeightOfChar(c,R),q=this.getValueOfPropertyAt(c,R,"deltaY");if(r&&b&&w){const J=this.fontSize*D/1e3;t.save(),t.fillStyle=C,t.translate(P.renderLeft,P.renderTop),t.rotate(P.angle),t.fillRect(-P.kernedWidth/2,h*K+q-o*J,P.kernedWidth,J),t.restore()}else if((b!==x||w!==C||K!==O||D!==S||q!==A)&&_>0){const J=this.fontSize*S/1e3;let B=i+f+v;this.direction==="rtl"&&(B=this.width-B-_),x&&C&&S&&(t.fillStyle=C,t.fillRect(B,M+h*O+A-o*J,_,J)),v=P.left,_=P.width,x=b,S=D,C=w,O=K,A=q}else _+=P.kernedWidth}let G=i+f+v;this.direction==="rtl"&&(G=this.width-G-_),t.fillStyle=w;const U=this.fontSize*D/1e3;b&&w&&D&&t.fillRect(G,M+h*O+A-o*U,_-n,U),s+=u}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:s=this.fontWeight,fontSize:i=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;const n=t.includes("'")||t.includes('"')||t.includes(",")||Q.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,s,"".concat(r?this.CACHE_FONT_SIZE:i,"px"),n].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return Oi(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),s=new Array(e.length),i=[`
54`];let r=[];for(let n=0;n<e.length;n++)s[n]=this.graphemeSplit(e[n]),r=r.concat(s[n],i);return r.pop(),{_unwrappedLines:s,lines:e,graphemeText:r,graphemeLines:s}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return m(m({},super.toObject([...Gr,...t])),{},{styles:Bo(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:s}=this.constructor;super.set(t,e);let i=!1,r=!1;if(typeof t=="object")for(const n in t)n==="path"&&this.setPathInfo(),i=i||s.includes(n),r=r||n==="path";else i=s.includes(t),r=t==="path";return r&&this.setPathInfo(),i&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,s){const i=Xt(t,Q.ATTRIBUTE_NAMES,s),r=m(m({},e),i),{textAnchor:n=j,textDecoration:o="",dx:h=0,dy:c=0,top:l=0,left:u=0,fontSize:g=di,strokeWidth:d=1}=r,f=X(r,Ua),v=new this(Ss(t.textContent||"").trim(),m({left:u+h,top:l+c,underline:o.includes("underline"),overline:o.includes("overline"),linethrough:o.includes("line-through"),strokeWidth:0,fontSize:g},f)),_=v.getScaledHeight()/v.height,x=((v.height+v.strokeWidth)*v.lineHeight-v.height)*_,C=v.getScaledHeight()+x;let S=0;return n===k&&(S=v.getScaledWidth()/2),n===Y&&(S=v.getScaledWidth()),v.set({left:v.left-S,top:v.top-(C-v.fontSize*(.07+v._fontSizeFraction))/v.lineHeight,strokeWidth:d}),v}static fromObject(t){return this._fromObject(m(m({},t),{},{styles:Io(t.styles||{},t.text)}),{extraParam:"text"})}}p(Q,"textLayoutProperties",zr),p(Q,"cacheProperties",[...It,...Gr]),p(Q,"ownDefaults",Kn),p(Q,"type","Text"),p(Q,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),p(Q,"ATTRIBUTE_NAMES",Nt.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Qr(Q,[class extends Wr{_toSVG(){const a=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(a.textTop,a.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(a){const t=this._createBaseSVGMarkup(this._toSVG(),{reviver:a,noStyle:!0,withShadow:!0}),e=this.path;return e?t+e._createBaseSVGMarkup(e._toSVG(),{reviver:a,withShadow:!0,additionalTransform:Pe(this.calcOwnMatrix())}):t}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(a){let{textBgRects:t,textSpans:e}=a;const s=this.getSvgTextDecoration(this);return[t.join(""),'		<text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(Na,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",s?'text-decoration="'.concat(s,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
55`]}_getSVGTextAndBg(a,t){const e=[],s=[];let i,r=a;this.backgroundColor&&s.push(...Ks(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let n=0,o=this._textLines.length;n<o;n++)i=this._getLineLeftOffset(n),this.direction==="rtl"&&(i+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",n))&&this._setSVGTextLineBg(s,n,t+i,r),this._setSVGTextLineText(e,n,t+i,r),r+=this.getHeightOfLine(n);return{textSpans:e,textBgRects:s}}_createTextCharSpan(a,t,e,s,i){const r=E.NUM_FRACTION_DIGITS,n=this.getSvgSpanStyles(t,a!==a.trim()||!!a.match(Ha)),o=n?'style="'.concat(n,'"'):"",h=t.deltaY,c=h?' dy="'.concat(I(h,r),'" '):"",{angle:l,renderLeft:u,renderTop:g,width:d}=i;let f="";if(u!==void 0){const v=d/2;l&&(f=' rotate="'.concat(I(Bt(l),r),'"'));const _=me({angle:Bt(l)});_[4]=u,_[5]=g;const x=new y(-v,0).transform(_);e=x.x,s=x.y}return'<tspan x="'.concat(I(e,r),'" y="').concat(I(s,r),'" ').concat(c).concat(f).concat(o,">").concat(Fo(a),"</tspan>")}_setSVGTextLineText(a,t,e,s){const i=this.getHeightOfLine(t),r=this.textAlign.includes(bt),n=this._textLines[t];let o,h,c,l,u,g="",d=0;s+=i*(1-this._fontSizeFraction)/this.lineHeight;for(let f=0,v=n.length-1;f<=v;f++)u=f===v||this.charSpacing||this.path,g+=n[f],c=this.__charBounds[t][f],d===0?(e+=c.kernedWidth-c.width,d+=c.width):d+=c.kernedWidth,r&&!u&&this._reSpaceAndTab.test(n[f])&&(u=!0),u||(o=o||this.getCompleteStyleDeclaration(t,f),h=this.getCompleteStyleDeclaration(t,f+1),u=Di(o,h,!0)),u&&(l=this._getStyleDeclaration(t,f),a.push(this._createTextCharSpan(g,l,e,s,c)),g="",o=h,this.direction==="rtl"?e-=d:e+=d,d=0)}_setSVGTextLineBg(a,t,e,s){const i=this._textLines[t],r=this.getHeightOfLine(t)/this.lineHeight;let n,o=0,h=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let l=0;l<i.length;l++){const{left:u,width:g,kernedWidth:d}=this.__charBounds[t][l];n=this.getValueOfPropertyAt(t,l,"textBackgroundColor"),n!==c?(c&&a.push(...Ks(c,e+h,s,o,r)),h=u,o=g,c=n):o+=d}n&&a.push(...Ks(c,e+h,s,o,r))}_getSVGLineTopOffset(a){let t,e=0;for(t=0;t<a;t++)e+=this.getHeightOfLine(t);const s=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*s/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(a){return"".concat(super.getSvgStyles(a)," text-decoration-thickness: ").concat(I(this.textDecorationThickness*this.getObjectScaling().y/10,E.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(a,t){const{fontFamily:e,strokeWidth:s,stroke:i,fill:r,fontSize:n,fontStyle:o,fontWeight:h,deltaY:c,textDecorationThickness:l,linethrough:u,overline:g,underline:d}=a,f=this.getSvgTextDecoration({underline:d??this.underline,overline:g??this.overline,linethrough:u??this.linethrough}),v=l||this.textDecorationThickness;return[i?Ae(nt,i):"",s?"stroke-width: ".concat(s,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",n?"font-size: ".concat(n,"px; "):"",o?"font-style: ".concat(o,"; "):"",h?"font-weight: ".concat(h,"; "):"",f?"text-decoration: ".concat(f,"; text-decoration-thickness: ").concat(I(v*this.getObjectScaling().y/10,E.NUM_FRACTION_DIGITS),"%; "):"",r?Ae(H,r):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(a){return["overline","underline","line-through"].filter(t=>a[t.replace("-","")]).join(" ")}}]),T.setClass(Q),T.setSVGClass(Q);class qa{constructor(t){p(this,"target",void 0),p(this,"__mouseDownInPlace",!1),p(this,"__dragStartFired",!1),p(this,"__isDraggingOver",!1),p(this,"__dragStartSelection",void 0),p(this,"__dragImageDisposer",void 0),p(this,"_dispose",void 0),this.target=t;const 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(s=>s()),this._dispose=void 0}}isPointerOverSelection(t){const e=this.target,s=e.getSelectionStartFromPointer(t);return e.isEditing&&s>=e.selectionStart&&s<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){const 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,e){var s;let{selectionStart:i,selectionEnd:r}=e;const n=this.target,o=n.canvas,h=new y(n.flipX?-1:1,n.flipY?-1:1),c=n._getCursorBoundaries(i),l=new y(c.left+c.leftOffset,c.top+c.topOffset).multiply(h).transform(n.calcTransformMatrix()),u=o.getScenePoint(t).subtract(l),g=n.getCanvasRetinaScaling(),d=n.getBoundingRect(),f=l.subtract(new y(d.left,d.top)),v=o.viewportTransform,_=f.add(u).transform(v,!0),x=n.backgroundColor,C=Ti(n.styles);n.backgroundColor="";const S={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};n.setSelectionStyles(S,0,i),n.setSelectionStyles(S,r,n.text.length),n.dirty=!0;const b=n.toCanvasElement({enableRetinaScaling:o.enableRetinaScaling,viewportTransform:!0});n.backgroundColor=x,n.styles=C,n.dirty=!0,li(b,{position:"fixed",left:"".concat(-b.width,"px"),border:rt,width:"".concat(b.width/g,"px"),height:"".concat(b.height/g,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{b.remove()},mt(t.target||this.target.hiddenTextarea).body.appendChild(b),(s=t.dataTransfer)===null||s===void 0||s.setDragImage(b,_.x,_.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,s=this.isActive();if(s&&t.dataTransfer){const i=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},r=e._text.slice(i.selectionStart,i.selectionEnd).join(""),n=m({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,n)}return e.abortCursorAnimation(),s}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){const e=this.target.getSelectionStartFromPointer(t),s=this.__dragStartSelection;return e<s.selectionStart||e>s.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e}=t;const s=this.targetCanDrop(e);!this.__isDraggingOver&&s&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{e}=t,s=this.targetCanDrop(e);!this.__isDraggingOver&&s?this.__isDraggingOver=!0:this.__isDraggingOver&&!s&&(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;const{e:s}=t,i=s.defaultPrevented;this.__isDraggingOver=!1,s.preventDefault();let r=(e=s.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(r&&!i){const n=this.target,o=n.canvas;let h=n.getSelectionStartFromPointer(s);const{styles:c}=s.dataTransfer.types.includes("application/fabric")?JSON.parse(s.dataTransfer.getData("application/fabric")):{},l=r[Math.max(0,r.length-1)],u=0;if(this.__dragStartSelection){const g=this.__dragStartSelection.selectionStart,d=this.__dragStartSelection.selectionEnd;h>g&&h<=d?h=g:h>d&&(h-=d-g),n.removeChars(g,d),delete this.__dragStartSelection}n._reNewline.test(l)&&(n._reNewline.test(n._text[h])||h===n._text.length)&&(r=r.trimEnd()),t.didDrop=!0,t.dropTarget=n,n.insertChars(r,c,h),o.setActiveObject(n),n.enterEditing(s),n.selectionStart=Math.min(h+u,n._text.length),n.selectionEnd=Math.min(n.selectionStart+r.length,n._text.length),n.hiddenTextarea.value=n.text,n._updateTextarea(),n.hiddenTextarea.focus(),n.fire(vs,{index:h+u,action:"drop"}),o.fire("text:changed",{target:n}),o.contextTopDirty=!0,o.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var s;const i=this.target,r=this.target.canvas,{selectionStart:n,selectionEnd:o}=this.__dragStartSelection,h=((s=e.dataTransfer)===null||s===void 0?void 0:s.dropEffect)||rt;h===rt?(i.selectionStart=n,i.selectionEnd=o,i._updateTextarea(),i.hiddenTextarea.focus()):(i.clearContextTop(),h==="move"&&(i.removeChars(n,o),i.selectionStart=i.selectionEnd=n,i.hiddenTextarea&&(i.hiddenTextarea.value=i.text),i._updateTextarea(),i.fire(vs,{index:n,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()}}const dr=/[ \n\.,;!\?\-]/;class Ka extends Q{constructor(){super(...arguments),p(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(t){let{toValue:e,duration:s,delay:i,onComplete:r}=t;return qr({startValue:this._currentCursorOpacity,endValue:e,duration:s,delay:i,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:n=>{this._currentCursorOpacity=n,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;(t=this._currentTickCompleteState)===null||t===void 0||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,s=t-1;if(this._reSpace.test(this._text[s]))for(;this._reSpace.test(this._text[s]);)e++,s--;for(;/\S/.test(this._text[s])&&s>-1;)e++,s--;return t-e}findWordBoundaryRight(t){let e=0,s=t;if(this._reSpace.test(this._text[s]))for(;this._reSpace.test(this._text[s]);)e++,s++;for(;/\S/.test(this._text[s])&&s<this._text.length;)e++,s++;return t+e}findLineBoundaryLeft(t){let e=0,s=t-1;for(;!/\n/.test(this._text[s])&&s>-1;)e++,s--;return t-e}findLineBoundaryRight(t){let e=0,s=t;for(;!/\n/.test(this._text[s])&&s<this._text.length;)e++,s++;return t+e}searchWordBoundary(t,e){const s=this._text;let i=t>0&&this._reSpace.test(s[t])&&(e===-1||!fi.test(s[t-1]))?t-1:t,r=s[i];for(;i>0&&i<s.length&&!dr.test(r);)i+=e,r=s[i];return e===-1&&dr.test(r)&&i++,i}selectWord(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const s=this.searchWordBoundary(t,-1),i=Math.max(s,this.searchWordBoundary(t,1));this.selectionStart=s,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=(e=t)!==null&&e!==void 0?e:this.selectionStart;const s=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);this.selectionStart=s,this.selectionEnd=i,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;const e=this.hiddenTextarea;mt(e).activeElement!==e&&e.focus();const s=this.getSelectionStartFromPointer(t),i=this.selectionStart,r=this.selectionEnd;(s===this.__selectionStartOnMouseDown&&i!==r||i!==s&&r!==s)&&(s>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=s):(this.selectionStart=s,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===r||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,s){const i=s.slice(0,t),r=this.graphemeSplit(i).length;if(t===e)return{selectionStart:r,selectionEnd:r};const n=s.slice(t,e);return{selectionStart:r,selectionEnd:r+this.graphemeSplit(n).length}}fromGraphemeToStringSelection(t,e,s){const i=s.slice(0,t).join("").length;return t===e?{selectionStart:i,selectionEnd:i}:{selectionStart:i,selectionEnd:i+s.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){const t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};const t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();const e=this.fromStringToGraphemeSelection(t.selectionStart,t.selectionEnd,t.value);this.selectionEnd=this.selectionStart=e.selectionEnd,this.inCompositionMode||(this.selectionStart=e.selectionStart),this.updateTextareaPosition()}updateTextareaPosition(){if(this.selectionStart===this.selectionEnd){const t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};const t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),s=this.get2DCursorLocation(t),i=s.lineIndex,r=s.charIndex,n=this.getValueOfPropertyAt(i,r,"fontSize")*this.lineHeight,o=e.leftOffset,h=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,l=c.width/h,u=c.height/h,g=l-n,d=u-n,f=new y(e.left+o,e.top+e.topOffset+n).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new y(c.clientWidth/l,c.clientHeight/u));return f.x<0&&(f.x=0),f.x>g&&(f.x=g),f.y<0&&(f.y=0),f.y>d&&(f.y=d),f.x+=this.canvas._offset.left,f.y+=this.canvas._offset.top,{left:"".concat(f.x,"px"),top:"".concat(f.y,"px"),fontSize:"".concat(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)}_exitEditing(){const 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()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(ys),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(const t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){const{lineIndex:s,charIndex:i}=this.get2DCursorLocation(t,!0),{lineIndex:r,charIndex:n}=this.get2DCursorLocation(e,!0);if(s!==r){if(this.styles[s])for(let o=i;o<this._unwrappedTextLines[s].length;o++)delete this.styles[s][o];if(this.styles[r])for(let o=n;o<this._unwrappedTextLines[r].length;o++){const h=this.styles[r][o];h&&(this.styles[s]||(this.styles[s]={}),this.styles[s][i+o-n]=h)}for(let o=s+1;o<=r;o++)delete this.styles[o];this.shiftLineStyles(r,s-r)}else if(this.styles[s]){const o=this.styles[s],h=n-i;for(let c=i;c<n;c++)delete o[c];for(const c in this.styles[s]){const l=parseInt(c,10);l>=n&&(o[l-h]=o[c],delete o[c])}}}shiftLineStyles(t,e){const s=Object.assign({},this.styles);for(const i in this.styles){const r=parseInt(i,10);r>t&&(this.styles[r+e]=s[r],s[r-e]||delete this.styles[r])}}insertNewlineStyleObject(t,e,s,i){const r={},n=this._unwrappedTextLines[t].length,o=n===e;let h=!1;s||(s=1),this.shiftLineStyles(t,s);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const u in this.styles[t]){const g=parseInt(u,10);g>=e&&(h=!0,r[g-e]=this.styles[t][u],o&&e===0||delete this.styles[t][u])}let l=!1;for(h&&!o&&(this.styles[t+s]=r,l=!0),(l||n>e)&&s--;s>0;)i&&i[s-1]?this.styles[t+s]={0:m({},i[s-1])}:c?this.styles[t+s]={0:m({},c)}:delete this.styles[t+s],s--;this._forceClearCache=!0}insertCharStyleObject(t,e,s,i){this.styles||(this.styles={});const r=this.styles[t],n=r?m({},r):{};s||(s=1);for(const h in n){const c=parseInt(h,10);c>=e&&(r[c+s]=n[c],n[c-s]||delete r[c])}if(this._forceClearCache=!0,i){for(;s--;)Object.keys(i[s]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+s]=m({},i[s]));return}if(!r)return;const o=r[e?e-1:1];for(;o&&s--;)this.styles[t][e+s]=m({},o)}insertNewStyleBlock(t,e,s){const i=this.get2DCursorLocation(e,!0),r=[0];let n,o=0;for(let h=0;h<t.length;h++)t[h]===`
56`?(o++,r[o]=0):r[o]++;for(r[0]>0&&(this.insertCharStyleObject(i.lineIndex,i.charIndex,r[0],s),s=s&&s.slice(r[0]+1)),o&&this.insertNewlineStyleObject(i.lineIndex,i.charIndex+r[0],o),n=1;n<o;n++)r[n]>0?this.insertCharStyleObject(i.lineIndex+n,0,r[n],s):s&&this.styles[i.lineIndex+n]&&s[0]&&(this.styles[i.lineIndex+n][0]=s[0]),s=s&&s.slice(r[n]+1);r[n]>0&&this.insertCharStyleObject(i.lineIndex+n,0,r[n],s)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]: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,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:s;i>s&&this.removeStyleFromTo(s,i);const r=this.graphemeSplit(t);this.insertNewStyleBlock(r,s,e),this._text=[...this._text.slice(0,s),...r,...this._text.slice(i)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,s){s<=t?(e===t?this._selectionDirection=j:this._selectionDirection===Y&&(this._selectionDirection=j,this.selectionEnd=t),this.selectionStart=s):s>t&&s<e?this._selectionDirection===Y?this.selectionEnd=s:this.selectionStart=s:(e===t?this._selectionDirection=Y:this._selectionDirection===j&&(this._selectionDirection=Y,this.selectionStart=e),this.selectionEnd=s)}}class Ja extends Ka{initHiddenTextarea(){const t=this.canvas&&mt(this.canvas.getElement())||de(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off",name:"fabricTextarea"}).map(n=>{let[o,h]=n;return e.setAttribute(o,h)});const{top:s,left:i,fontSize:r}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(s,"; left: ").concat(i,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(r,";"),(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(n=>{let[o,h]=n;return e.addEventListener(o,this[h].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?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){const e=this.fromPaste,{value:s,selectionStart:i,selectionEnd:r}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const n=()=>{this.updateFromTextArea(),this.fire(vs),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void n();const o=this._splitTextIntoLines(s).graphemeText,h=this._text.length,c=o.length,l=this.selectionStart,u=this.selectionEnd,g=l!==u;let d,f,v,_,x=c-h;const C=this.fromStringToGraphemeSelection(i,r,s),S=l>C.selectionStart;g?(f=this._text.slice(l,u),x+=u-l):c<h&&(f=S?this._text.slice(u+x,u):this._text.slice(l,l-x));const b=o.slice(C.selectionEnd-x,C.selectionEnd);if(f&&f.length&&(b.length&&(d=this.getSelectionStyles(l,l+1,!1),d=b.map(()=>d[0])),g?(v=l,_=u):S?(v=u-f.length,_=u):(v=u,_=u+f.length),this.removeStyleFromTo(v,_)),b.length){const{copyPasteData:w}=wt();e&&b.join("")===w.copiedText&&!E.disableStyleCopyPaste&&(d=w.copiedTextStyle),this.insertNewStyleBlock(b,l,d)}n()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:s,selectionEnd:i}=e;this.compositionStart=s,this.compositionEnd=i,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=wt();t.copiedText=this.getSelectedText(),E.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 s,i=this._getLineLeftOffset(t);return e>0&&(s=this.__charBounds[t][e-1],i+=s.left+s.width),i}getDownCursorOffset(t,e){const s=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(s),r=i.lineIndex;if(r===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-s;const n=i.charIndex,o=this._getWidthBeforeCursor(r,n),h=this._getIndexOnLine(r+1,o);return this._textLines[r].slice(n).length+h+1+this.missingNewlineOffset(r)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const s=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(s),r=i.lineIndex;if(r===0||t.metaKey||t.keyCode===33)return-s;const n=i.charIndex,o=this._getWidthBeforeCursor(r,n),h=this._getIndexOnLine(r-1,o),c=this._textLines[r].slice(0,n),l=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+h-c.length+(1-l)}_getIndexOnLine(t,e){const s=this._textLines[t];let i,r,n=this._getLineLeftOffset(t),o=0;for(let h=0,c=s.length;h<c;h++)if(i=this.__charBounds[t][h].width,n+=i,n>e){r=!0;const l=n-i,u=n,g=Math.abs(l-e);o=Math.abs(u-e)<g?h:h-1;break}return r||(o=s.length-1),o}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const s=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===Y);if(e.shiftKey?this.moveCursorWithShift(s):this.moveCursorWithoutShift(s),s!==0){const i=this.text.length;this.selectionStart=ge(0,this.selectionStart,i),this.selectionEnd=ge(0,this.selectionEnd,i),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===j?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,s){let i;if(t.altKey)i=this["findWordBoundary".concat(s)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=s==="Left"?-1:1,!0;i=this["findLineBoundary".concat(s)](this[e])}return i!==void 0&&this[e]!==i&&(this[e]=i,!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&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===Y&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=j,this._moveLeft(t,"selectionStart")):void 0}moveCursorRight(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorLeftOrRight("Right",t)}_moveCursorLeftOrRight(t,e){const s="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[s](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===j&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=Y,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=Y,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const fr=a=>!!a.button;class Za extends Ja{constructor(){super(...arguments),p(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 qa(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(t){let{e,alreadySelected:s}=t;this.canvas&&this.editable&&!fr(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),s&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=s||this.isEditing)))}mouseUpHandler(t){let{e,transform:s}=t;const i=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const r=this.canvas._activeObject;if(r&&r!==this)return}!this.editable||this.group&&!this.group.interactive||s&&s.actionPerformed||fr(e)||i||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){const e=this.getSelectionStartFromPointer(t),s=this.selectionStart,i=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(s,i,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(vt(this.calcTransformMatrix())).add(new y(-this._getLeftOffset(),-this._getTopOffset()));let s=0,i=0,r=0;for(let c=0;c<this._textLines.length&&s<=e.y;c++)s+=this.getHeightOfLine(c),r=c,c>0&&(i+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let n=Math.abs(this._getLineLeftOffset(r));const o=this._textLines[r].length,h=this.__charBounds[r];for(let c=0;c<o;c++){const l=n+h[c].kernedWidth;if(e.x<=l){Math.abs(e.x-l)<=Math.abs(e.x-n)&&i++;break}n=l,i++}return Math.min(this.flipX?o-i:i,this._text.length)}}const He="moveCursorUp",Ne="moveCursorDown",Ue="moveCursorLeft",qe="moveCursorRight",Ke="exitEditing",pr=(a,t)=>{const e=t.getRetinaScaling();a.setTransform(e,0,0,e,0,0);const s=t.viewportTransform;a.transform(s[0],s[1],s[2],s[3],s[4],s[5])},$a=m({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:Ke,27:Ke,33:He,34:Ne,35:qe,36:Ue,37:Ue,38:He,39:qe,40:Ne},keysMapRtl:{9:Ke,27:Ke,33:He,34:Ne,35:Ue,36:qe,37:qe,38:He,39:Ue,40:Ne},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class Pt extends Za{static getDefaults(){return m(m({},super.getDefaults()),Pt.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,m(m({},Pt.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof gr&&this.canvas.textEditingManager.remove(this),e instanceof gr&&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(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,s=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,s)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,s)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const s=super.toCanvasElement(t);return this.isEditing=e,s}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries(),s=this.findAncestorsWithClipPath(),i=s.length>0;let r,n=t;if(i){r=gt(t.canvas),n=r.getContext("2d"),pr(n,this.canvas);const o=this.calcTransformMatrix();n.transform(o[0],o[1],o[2],o[3],o[4],o[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(n,e):this.renderCursor(n,e),i)for(const o of s){const h=o.clipPath,c=gt(t.canvas),l=c.getContext("2d");if(pr(l,this.canvas),!h.absolutePositioned){const u=o.calcTransformMatrix();l.transform(u[0],u[1],u[2],u[3],u[4],u[5])}h.transform(l),h.drawObject(l,!0,{}),this.drawClipPathOnCache(n,h,c)}i&&(t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){const t=[];let e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;const s=this._getLeftOffset(),i=this._getTopOffset(),r=this._getCursorBoundariesOffsets(t,e);return{left:s,top:i,leftOffset:r.left,topOffset:r.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,s=0;const{charIndex:i,lineIndex:r}=this.get2DCursorLocation(t);for(let c=0;c<r;c++)e+=this.getHeightOfLine(c);const n=this._getLineLeftOffset(r),o=this.__charBounds[r][i];o&&(s=o.left),this.charSpacing!==0&&i===this._textLines[r].length&&(s-=this._getWidthOfCharSpacing());const h={top:e,left:n+(s>0?s:0)};return this.direction==="rtl"&&(this.textAlign===Y||this.textAlign===bt||this.textAlign===Oe?h.left*=-1:this.textAlign===j||this.textAlign===ws?h.left=n-(s>0?s:0):this.textAlign!==k&&this.textAlign!==De||(h.left=n-(s>0?s:0))),h}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const s=this.get2DCursorLocation(t),i=s.lineIndex,r=s.charIndex>0?s.charIndex-1:0,n=this.getValueOfPropertyAt(i,r,"fontSize"),o=this.getObjectScaling().x*this.canvas.getZoom(),h=this.cursorWidth/o,c=this.getValueOfPropertyAt(i,r,"deltaY"),l=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(i)/this.lineHeight-n*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(i,r,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-h/2,top:l+e.top+c,width:h,height:n}}_renderCursor(t,e,s){const{color:i,opacity:r,left:n,top:o,width:h,height:c}=this.getCursorRenderingData(s,e);t.fillStyle=i,t.globalAlpha=r,t.fillRect(n,o,h,c)}renderSelection(t,e){const s={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,s,e)}renderDragSourceEffect(){const t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){const e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,s){const i=e.selectionStart,r=e.selectionEnd,n=this.textAlign.includes(bt),o=this.get2DCursorLocation(i),h=this.get2DCursorLocation(r),c=o.lineIndex,l=h.lineIndex,u=o.charIndex<0?0:o.charIndex,g=h.charIndex<0?0:h.charIndex;for(let d=c;d<=l;d++){const f=this._getLineLeftOffset(d)||0;let v=this.getHeightOfLine(d),_=0,x=0,C=0;if(d===c&&(x=this.__charBounds[c][u].left),d>=c&&d<l)C=n&&!this.isEndOfWrapping(d)?this.width:this.getLineWidth(d)||5;else if(d===l)if(g===0)C=this.__charBounds[l][g].left;else{const M=this._getWidthOfCharSpacing();C=this.__charBounds[l][g-1].left+this.__charBounds[l][g-1].width-M}_=v,(this.lineHeight<1||d===l&&this.lineHeight>1)&&(v/=this.lineHeight);let S=s.left+f+x,b=v,w=0;const D=C-x;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",b=1,w=v):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===Y||this.textAlign===bt||this.textAlign===Oe?S=this.width-S-D:this.textAlign===j||this.textAlign===ws?S=s.left+f-C:this.textAlign!==k&&this.textAlign!==De||(S=s.left+f-C)),t.fillRect(S,s.top+s.topOffset+w,D,b),s.topOffset+=_}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,H)}_getCurrentCharIndex(){const 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()}}p(Pt,"ownDefaults",$a),p(Pt,"type","IText"),T.setClass(Pt),T.setClass(Pt,"i-text");class $t extends Pt{static getDefaults(){return m(m({},super.getDefaults()),$t.ownDefaults)}constructor(t,e){super(t,m(m({},$t.ownDefaults),e))}static createControls(){return{controls:Eo()}}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(bt)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,s=0,i=0;const r={};for(let n=0;n<t.graphemeLines.length;n++)t.graphemeText[i]===`
57`&&n>0?(s=0,i++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[i])&&n>0&&(s++,i++),r[n]={line:e,offset:s},i+=t.graphemeLines[n].length,s+=t.graphemeLines[n].length;return r}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const s=this._styleMap[e];s&&(e=s.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,s=0,i=t+1,r=!1;const n=this._styleMap[t],o=this._styleMap[t+1];n&&(t=n.line,s=n.offset),o&&(i=o.line,r=i===t,e=o.offset);const h=t===void 0?this.styles:{line:this.styles[t]};for(const c in h)for(const l in h[c]){const u=parseInt(l,10);if(u>=s&&(!r||u<e))for(const g in h[c][l])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){const s=this._styleMap[t];if(!s)return{};t=s.line,e=s.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,s){const i=this._styleMap[t];super._setStyleDeclaration(i.line,i.offset+e,s)}_deleteStyleDeclaration(t,e){const s=this._styleMap[t];super._deleteStyleDeclaration(s.line,s.offset+e)}_getLineStyle(t){const e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){const e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;const s=this.getGraphemeDataForRender(t),i=[];for(let r=0;r<s.wordsData.length;r++)i.push(...this._wrapLine(r,e,s));return this.isWrapping=!1,i}getGraphemeDataForRender(t){const e=this.splitByGrapheme,s=e?"":" ";let i=0;return{wordsData:t.map((r,n)=>{let o=0;const h=e?this.graphemeSplit(r):this.wordSplit(r);return h.length===0?[{word:[],width:0}]:h.map(c=>{const l=e?[c]:this.graphemeSplit(c),u=this._measureWord(l,n,o);return i=Math.max(u,i),o+=l.length+s.length,{word:l,width:u}})}),largestWordWidth:i}}_measureWord(t,e){let s,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=0;for(let n=0,o=t.length;n<o;n++)r+=this._getGraphemeBox(t[n],e,n+i,s,!0).kernedWidth,s=t[n];return r}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,s){let{largestWordWidth:i,wordsData:r}=s,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const o=this._getWidthOfCharSpacing(),h=this.splitByGrapheme,c=[],l=h?"":" ";let u=0,g=[],d=0,f=0,v=!0;e-=n;const _=Math.max(e,i,this.dynamicMinWidth),x=r[t];let C;for(d=0,C=0;C<x.length;C++){const{word:S,width:b}=x[C];d+=S.length,u+=f+b-o,u>_&&!v?(c.push(g),g=[],u=b,v=!0):u+=o,v||h||g.push(l),g=g.concat(S),f=h?0:this._measureWord([l],t,d),d++,v=!1}return C&&c.push(g),i+n>this.dynamicMinWidth&&(this.dynamicMinWidth=i-o+n),c}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:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),s=this._wrapText(e.lines,this.width),i=new Array(s.length);for(let r=0;r<s.length;r++)i[r]=s[r].join("");return e.lines=i,e.graphemeLines=s,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){const t=new Map;for(const e in this._styleMap){const s=parseInt(e,10);if(this._textLines[s]){const i=this._styleMap[e].line;t.set("".concat(i),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}p($t,"type","Textbox"),p($t,"textLayoutProperties",[...Pt.textLayoutProperties,"width"]),p($t,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),T.setClass($t);class mr extends Rs{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:s}=t,{clipPath:i,group:r}=s;if(!i||!this.shouldPerformLayout(t))return;const{width:n,height:o}=At(sn(s,i)),h=new y(n,o);if(i.absolutePositioned)return{center:ce(i.getRelativeCenterPoint(),void 0,r?r.calcTransformMatrix():void 0),size:h};{const c=i.getRelativeCenterPoint().transform(s.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:l=new y,correction:u=new y}=this.calcBoundingBox(e,t)||{};return{center:l.add(c),correction:u.subtract(c),size:h}}return{center:s.getRelativeCenterPoint().add(c),size:h}}}}p(mr,"type","clip-path"),T.setClass(mr);class vr extends Rs{getInitialSize(t,e){let{target:s}=t,{size:i}=e;return new y(s.width||i.x,s.height||i.y)}}p(vr,"type","fixed"),T.setClass(vr);class Qa extends Fe{subscribeTargets(t){const e=t.target;t.targets.reduce((s,i)=>(i.parent&&s.add(i.parent),s),new Set).forEach(s=>{s.layoutManager.subscribeTargets({target:s,targets:[e]})})}unsubscribeTargets(t){const e=t.target,s=e.getObjects();t.targets.reduce((i,r)=>(r.parent&&i.add(r.parent),i),new Set).forEach(i=>{!s.some(r=>r.parent===i)&&i.layoutManager.unsubscribeTargets({target:i,targets:[e]})})}}class Qt extends te{static getDefaults(){return m(m({},super.getDefaults()),Qt.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Qt.ownDefaults),this.setOptions(e);const{left:s,top:i,layoutManager:r}=e;this.groupInit(t,{left:s,top:i,layoutManager:r??new Qa})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach(i=>{const r=this._objects.findIndex(o=>o.isInFrontOf(i)),n=r===-1?this.size():r;this.insertAt(n,i)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(Gt("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);const s=new Set;e.forEach(i=>{const{parent:r}=i;r&&s.add(r)}),t===Mi?s.forEach(i=>{i._onAfterObjectsChange(Ts,e)}):s.forEach(i=>{i._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,s){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const i=m(m({hasControls:!1},s),{},{forActiveSelection:!0});for(let r=0;r<this._objects.length;r++)this._objects[r]._renderControls(t,i);super._renderControls(t,e),t.restore()}}p(Qt,"type","ActiveSelection"),p(Qt,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),T.setClass(Qt),T.setClass(Qt,"activeSelection");class th{constructor(){p(this,"resources",{})}applyFilters(t,e,s,i,r){const n=r.getContext("2d");if(!n)return;n.drawImage(e,0,0,s,i);const o={sourceWidth:s,sourceHeight:i,imageData:n.getImageData(0,0,s,i),originalEl:e,originalImageData:n.getImageData(0,0,s,i),canvasEl:r,ctx:n,filterBackend:this};t.forEach(c=>{c.applyTo(o)});const{imageData:h}=o;return h.width===s&&h.height===i||(r.width=h.width,r.height=h.height),n.putImageData(h,0,0),o}}class _n{constructor(){let{tileSize:t=E.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};p(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),p(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const s=gt({width:t,height:e}),i=s.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});i&&(i.clearColor(0,0,0,0),this.canvas=s,this.gl=i)}applyFilters(t,e,s,i,r,n){const o=this.gl,h=r.getContext("2d");if(!o||!h)return;let c;n&&(c=this.getCachedTexture(n,e));const l={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:s,sourceHeight:i,destinationWidth:s,destinationHeight:i,context:o,sourceTexture:this.createTexture(o,s,i,c?void 0:e),targetTexture:this.createTexture(o,s,i),originalTexture:c||this.createTexture(o,s,i,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},u=o.createFramebuffer();return o.bindFramebuffer(o.FRAMEBUFFER,u),t.forEach(g=>{g&&g.applyTo(l)}),function(g){const d=g.targetCanvas,f=d.width,v=d.height,_=g.destinationWidth,x=g.destinationHeight;f===_&&v===x||(d.width=_,d.height=x)}(l),this.copyGLTo2D(o,l),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(l.sourceTexture),o.deleteTexture(l.targetTexture),o.deleteFramebuffer(u),h.setTransform(1,0,0,1,0,0),l}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,s,i,r){const{NEAREST:n,TEXTURE_2D:o,RGBA:h,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:l,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:g,TEXTURE_WRAP_S:d,TEXTURE_WRAP_T:f}=t,v=t.createTexture();return t.bindTexture(o,v),t.texParameteri(o,u,r||n),t.texParameteri(o,g,r||n),t.texParameteri(o,d,l),t.texParameteri(o,f,l),i?t.texImage2D(o,0,h,h,c,i):t.texImage2D(o,0,h,e,s,0,h,c,null),v}getCachedTexture(t,e,s){const{textureCache:i}=this;if(i[t])return i[t];{const r=this.createTexture(this.gl,e.width,e.height,e,s);return r&&(i[t]=r),r}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const s=t.canvas,i=e.targetCanvas,r=i.getContext("2d");if(!r)return;r.translate(0,i.height),r.scale(1,-1);const n=s.height-i.height;r.drawImage(s,0,n,i.width,i.height,0,0,i.width,i.height)}copyGLTo2DPutImageData(t,e){const s=e.targetCanvas.getContext("2d"),i=e.destinationWidth,r=e.destinationHeight,n=i*r*4;if(!s)return;const o=new Uint8Array(this.imageBuffer,0,n),h=new Uint8ClampedArray(this.imageBuffer,0,n);t.readPixels(0,0,i,r,t.RGBA,t.UNSIGNED_BYTE,o);const c=new ImageData(h,i,r);s.putImageData(c,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;const t=this.gl,e={renderer:"",vendor:""};if(!t)return e;const s=t.getExtension("WEBGL_debug_renderer_info");if(s){const i=t.getParameter(s.UNMASKED_RENDERER_WEBGL),r=t.getParameter(s.UNMASKED_VENDOR_WEBGL);i&&(e.renderer=i.toLowerCase()),r&&(e.vendor=r.toLowerCase())}return this.gpuInfo=e,e}}let Zs;function eh(){const{WebGLProbe:a}=wt();return a.queryWebGL(Rt()),E.enableGLFiltering&&a.isSupported(E.textureSize)?new _n({tileSize:E.textureSize}):new th}function $s(){return!Zs&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(Zs=eh()),Zs}const sh=["filters","resizeFilter","src","crossOrigin","type"],xn=["cropX","cropY"];class ct extends ${static getDefaults(){return m(m({},super.getDefaults()),ct.ownDefaults)}constructor(t,e){super(),p(this,"_lastScaleX",1),p(this,"_lastScaleY",1),p(this,"_filterScalingX",1),p(this,"_filterScalingY",1),this.filters=[],Object.assign(this,ct.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(Ht()),this.setElement(typeof t=="string"?(this.canvas&&mt(this.canvas.getElement())||de()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){var e;let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(s),(e=t.classList)===null||e===void 0||e.add(ct.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=$s(!1);e instanceof _n&&e.evictCachesForKey(t)}dispose(){super.dispose(),this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._cacheContext=null,["_originalElement","_element","_filteredEl","_cacheCanvas"].forEach(t=>{const e=this[t];e&&wt().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,s=this.height/2;t.beginPath(),t.moveTo(-e,-s),t.lineTo(e,-s),t.lineTo(e,s),t.lineTo(-e,s),t.lineTo(-e,-s),t.closePath()}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach(s=>{s&&e.push(s.toObject())}),m(m({},super.toObject([...xn,...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(){const t=[],e=this._element,s=-this.width/2,i=-this.height/2;let r=[],n=[],o="",h="";if(!e)return[];if(this.hasCrop()){const c=Ht();r.push('<clipPath id="imageCrop_'+c+`">
58`,'	<rect x="'+s+'" y="'+i+'" width="'+this.width+'" height="'+this.height+`" />
59`,`</clipPath>
60`),o=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(h=' image-rendering="optimizeSpeed"'),t.push("	<image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(s-this.cropX,'" y="').concat(i-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(h).concat(o,`></image>
61`)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,n=['	<rect x="'.concat(s,'" y="').concat(i,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
62`)],this.fill=c}return r=this.paintFirst!==H?r.concat(n,t):r.concat(t,n),r}getSrc(t){const 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){let{crossOrigin:e,signal:s}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return fs(t,{crossOrigin:e,signal:s}).then(i=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(i)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,s=this.getTotalObjectScaling(),i=s.x,r=s.y,n=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||i>e&&r>e)return this._element=n,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=i,void(this._lastScaleY=r);const o=gt(n),{width:h,height:c}=n;this._element=o,this._lastScaleX=t.scaleX=i,this._lastScaleY=t.scaleY=r,$s().applyFilters([t],n,h,c,this._element),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter(r=>r&&!r.isNeutralState()),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,s=e.naturalWidth||e.width,i=e.naturalHeight||e.height;if(this._element===this._originalElement){const r=gt({width:s,height:i});this._element=r,this._filteredEl=r}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,s,i),this._lastScaleX=1,this._lastScaleY=1);$s().applyFilters(t,this._originalElement,s,i,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,this.isMoving!==!0&&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){const e=this._element;if(!e)return;const s=this._filterScalingX,i=this._filterScalingY,r=this.width,n=this.height,o=Math.max(this.cropX,0),h=Math.max(this.cropY,0),c=e.naturalWidth||e.width,l=e.naturalHeight||e.height,u=o*s,g=h*i,d=Math.min(r*s,c-u),f=Math.min(n*i,l-g),v=-r/2,_=-n/2,x=Math.min(r,c/s-o),C=Math.min(n,l/i-h);e&&t.drawImage(e,u,g,d,f,v,_,x,C)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const s=this.getOriginalSize();this.width=t||s.width,this.height=e||s.height}parsePreserveAspectRatioAttribute(){const t=Un(this.preserveAspectRatio||""),e=this.width,s=this.height,i={width:e,height:s};let r,n=this._element.width,o=this._element.height,h=1,c=1,l=0,u=0,g=0,d=0;return!t||t.alignX===rt&&t.alignY===rt?(h=e/n,c=s/o):(t.meetOrSlice==="meet"&&(h=c=la(this._element,i),r=(e-n*h)/2,t.alignX==="Min"&&(l=-r),t.alignX==="Max"&&(l=r),r=(s-o*c)/2,t.alignY==="Min"&&(u=-r),t.alignY==="Max"&&(u=r)),t.meetOrSlice==="slice"&&(h=c=ua(this._element,i),r=n-e/h,t.alignX==="Mid"&&(g=r/2),t.alignX==="Max"&&(g=r),r=o-s/c,t.alignY==="Mid"&&(d=r/2),t.alignY==="Max"&&(d=r),n=e/h,o=s/c)),{width:n,height:o,scaleX:h,scaleY:c,offsetLeft:l,offsetTop:u,cropX:g,cropY:d}}static fromObject(t,e){let{filters:s,resizeFilter:i,src:r,crossOrigin:n,type:o}=t,h=X(t,sh);return Promise.all([fs(r,m(m({},e),{},{crossOrigin:n})),s&&Ee(s,e),i&&Ee([i],e),As(h,e)]).then(c=>{let[l,u=[],[g]=[],d={}]=c;return new this(l,m(m({},h),{},{src:r,filters:u,resizeFilter:g},d))})}static fromURL(t){let{crossOrigin:e=null,signal:s}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;return fs(t,{crossOrigin:e,signal:s}).then(r=>new this(r,i))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;const i=Xt(t,this.ATTRIBUTE_NAMES,s);return this.fromURL(i["xlink:href"]||i.href,e,i).catch(r=>(Gt("log","Unable to parse Image",r),null))}}p(ct,"type","Image"),p(ct,"cacheProperties",[...It,...xn]),p(ct,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),p(ct,"CSS_CANVAS","canvas-img"),p(ct,"ATTRIBUTE_NAMES",[...Nt,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),T.setClass(ct),T.setSVGClass(ct);Fs(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const Is=a=>a.webgl!==void 0,Ei="precision highp float",ih=`
63    `.concat(Ei,`;
64    varying vec2 vTexCoord;
65    uniform sampler2D uTexture;
66    void main() {
67      gl_FragColor = texture2D(uTexture, vTexCoord);
68    }`),rh=["type"],nh=["type"],oh=new RegExp(Ei,"g");class N{get type(){return this.constructor.type}constructor(){let t=X(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},rh);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return ih}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){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:i="highp"}}=wt();i!=="highp"&&(e=e.replace(oh,Ei.replace("highp",i)));const r=t.createShader(t.VERTEX_SHADER),n=t.createShader(t.FRAGMENT_SHADER),o=t.createProgram();if(!r||!n||!o)throw new St("Vertex, fragment shader or program creation error");if(t.shaderSource(r,s),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new St("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(r)));if(t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new St("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(n)));if(t.attachShader(o,r),t.attachShader(o,n),t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS))throw new St('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(o)));const h=this.getUniformLocations(t,o)||{};return h.uStepW=t.getUniformLocation(o,"uStepW"),h.uStepH=t.getUniformLocation(o,"uStepH"),{program:o,attributeLocations:this.getAttributeLocations(t,o),uniformLocations:h}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const s=this.constructor.uniformLocations,i={};for(let r=0;r<s.length;r++)i[s[r]]=t.getUniformLocation(e,s[r]);return i}sendAttributeData(t,e,s){const i=e.aPosition,r=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,r),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW)}_setupFrameBuffer(t){const e=t.context;if(t.passes>1){const s=t.destinationWidth,i=t.destinationHeight;t.sourceWidth===s&&t.sourceHeight===i||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,s,i)),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++;const e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){Is(t)?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){const e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){const e=t.context,s=this.retrieveShader(t);t.pass===0&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(s.program),this.sendAttributeData(e,s.attributeLocations,t.aPosition),e.uniform1f(s.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(s.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,s.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,s){t.activeTexture(s),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){const{sourceWidth:e,sourceHeight:s}=t,i=gt({width:e,height:s});t.helpLayer=i}}toObject(){const t=Object.keys(this.constructor.defaults||{});return m({type:this.type},t.reduce((e,s)=>(e[s]=this[s],e),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(X(t,nh))}}p(N,"type","BaseFilter"),p(N,"uniformLocations",[]);const ah={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    `};class Je extends N{getCacheKey(){return"".concat(this.type,"_").concat(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          `.concat(ah[this.mode],`
111        }
112      }
113      `)}applyTo2d(t){let{imageData:{data:e}}=t;const s=new F(this.color).getSource(),i=this.alpha,r=s[0]*i,n=s[1]*i,o=s[2]*i,h=1-i;for(let c=0;c<e.length;c+=4){const l=e[c],u=e[c+1],g=e[c+2];let d,f,v;switch(this.mode){case"multiply":d=l*r/255,f=u*n/255,v=g*o/255;break;case"screen":d=255-(255-l)*(255-r)/255,f=255-(255-u)*(255-n)/255,v=255-(255-g)*(255-o)/255;break;case"add":d=l+r,f=u+n,v=g+o;break;case"difference":d=Math.abs(l-r),f=Math.abs(u-n),v=Math.abs(g-o);break;case"subtract":d=l-r,f=u-n,v=g-o;break;case"darken":d=Math.min(l,r),f=Math.min(u,n),v=Math.min(g,o);break;case"lighten":d=Math.max(l,r),f=Math.max(u,n),v=Math.max(g,o);break;case"overlay":d=r<128?2*l*r/255:255-2*(255-l)*(255-r)/255,f=n<128?2*u*n/255:255-2*(255-u)*(255-n)/255,v=o<128?2*g*o/255:255-2*(255-g)*(255-o)/255;break;case"exclusion":d=r+l-2*r*l/255,f=n+u-2*n*u/255,v=o+g-2*o*g/255;break;case"tint":d=r+l*h,f=n+u*h,v=o+g*h}e[c]=d,e[c+1]=f,e[c+2]=v}}sendUniformData(t,e){const s=new F(this.color).getSource();s[0]=this.alpha*s[0]/255,s[1]=this.alpha*s[1]/255,s[2]=this.alpha*s[2]/255,s[3]=this.alpha,t.uniform4fv(e.uColor,s)}}p(Je,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),p(Je,"type","BlendColor"),p(Je,"uniformLocations",["uColor"]),T.setClass(Je);const hh={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    `},ch=["type","image"];class Ze extends N{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return hh[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){const e=t.context,s=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,s,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){const t=this.image,{width:e,height:s}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/s,1]}applyTo2d(t){let{imageData:{data:e,width:s,height:i},filterBackend:{resources:r}}=t;const n=this.image;r.blendImage||(r.blendImage=Rt());const o=r.blendImage,h=o.getContext("2d");o.width!==s||o.height!==i?(o.width=s,o.height=i):h.clearRect(0,0,s,i),h.setTransform(n.scaleX,0,0,n.scaleY,n.left,n.top),h.drawImage(n.getElement(),0,0,s,i);const c=h.getImageData(0,0,s,i).data;for(let l=0;l<e.length;l+=4){const u=e[l],g=e[l+1],d=e[l+2],f=e[l+3],v=c[l],_=c[l+1],x=c[l+2],C=c[l+3];switch(this.mode){case"multiply":e[l]=u*v/255,e[l+1]=g*_/255,e[l+2]=d*x/255,e[l+3]=f*C/255;break;case"mask":e[l+3]=C}}}sendUniformData(t,e){const s=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,s)}toObject(){return m(m({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:s,image:i}=t,r=X(t,ch);return ct.fromObject(i,e).then(n=>new this(m(m({},r),{},{image:n})))}}p(Ze,"type","BlendImage"),p(Ze,"defaults",{mode:"multiply",alpha:1}),p(Ze,"uniformLocations",["uTransformMatrix","uImage"]),T.setClass(Ze);class $e extends N{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  `}applyTo(t){Is(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(t){let{imageData:{data:e,width:s,height:i}}=t;this.aspectRatio=s/i,this.horizontal=!0;let r=this.getBlurValue()*s;const n=new Uint8ClampedArray(e),o=15,h=4*s;for(let c=0;c<e.length;c+=4){let l=0,u=0,g=0,d=0,f=0;const v=c-c%h,_=v+h;for(let x=-14;x<o;x++){const C=x/o,S=4*Math.floor(r*C),b=1-Math.abs(C);let w=c+S;w<v?w=v:w>_&&(w=_);const D=e[w+3]*b;l+=e[w]*D,u+=e[w+1]*D,g+=e[w+2]*D,d+=D,f+=b}n[c]=l/d,n[c+1]=u/d,n[c+2]=g/d,n[c+3]=d/f}this.horizontal=!1,r=this.getBlurValue()*i;for(let c=0;c<n.length;c+=4){let l=0,u=0,g=0,d=0,f=0;const v=c%h,_=n.length-h+v;for(let x=-14;x<o;x++){const C=x/o,S=Math.floor(r*C)*h,b=1-Math.abs(C);let w=c+S;w<v?w=v:w>_&&(w=_);const D=n[w+3]*b;l+=n[w]*D,u+=n[w+1]*D,g+=n[w+2]*D,d+=D,f+=b}e[c]=l/d,e[c+1]=u/d,e[c+2]=g/d,e[c+3]=d/f}}sendUniformData(t,e){const s=this.chooseRightDelta();t.uniform2fv(e.uDelta,s)}isNeutralState(){return this.blur===0}getBlurValue(){let t=1;const{horizontal:e,aspectRatio:s}=this;return e?s>1&&(t=1/s):s<1&&(t=s),t*this.blur*.12}chooseRightDelta(){const t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}p($e,"type","Blur"),p($e,"defaults",{blur:0}),p($e,"uniformLocations",["uDelta"]),T.setClass($e);class Qe extends N{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(t){let{imageData:{data:e}}=t;const s=Math.round(255*this.brightness);for(let i=0;i<e.length;i+=4)e[i]+=s,e[i+1]+=s,e[i+2]+=s}isNeutralState(){return this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}p(Qe,"type","Brightness"),p(Qe,"defaults",{brightness:0}),p(Qe,"uniformLocations",["uBrightness"]),T.setClass(Qe);const Cn={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class he extends N{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){const e=t.imageData.data,s=this.matrix,i=this.colorsOnly;for(let r=0;r<e.length;r+=4){const n=e[r],o=e[r+1],h=e[r+2];if(e[r]=n*s[0]+o*s[1]+h*s[2]+255*s[4],e[r+1]=n*s[5]+o*s[6]+h*s[7]+255*s[9],e[r+2]=n*s[10]+o*s[11]+h*s[12]+255*s[14],!i){const c=e[r+3];e[r]+=c*s[3],e[r+1]+=c*s[8],e[r+2]+=c*s[13],e[r+3]=n*s[15]+o*s[16]+h*s[17]+c*s[18]+255*s[19]}}}sendUniformData(t,e){const s=this.matrix,i=[s[0],s[1],s[2],s[3],s[5],s[6],s[7],s[8],s[10],s[11],s[12],s[13],s[15],s[16],s[17],s[18]],r=[s[4],s[9],s[14],s[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,i),t.uniform4fv(e.uConstants,r)}toObject(){return m(m({},super.toObject()),{},{matrix:[...this.matrix]})}}function se(a,t){var e;const s=(p(e=class extends he{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",a),p(e,"defaults",{colorsOnly:!1,matrix:t}),e);return T.setClass(s,a),s}p(he,"type","ColorMatrix"),p(he,"defaults",Cn),p(he,"uniformLocations",["uColorMatrix","uConstants"]),T.setClass(he);se("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);se("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);se("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);se("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);se("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);se("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);se("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]);class yr extends N{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){Is(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEac
199h(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(s=>T.getClass(s.type).fromObject(s,e))).then(s=>new this({subFilters:s}))}}p(yr,"type","Composed"),T.setClass(yr);class ts extends N{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 this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const s=Math.floor(255*this.contrast),i=259*(s+255)/(255*(259-s));for(let r=0;r<e.length;r+=4)e[r]=i*(e[r]-128)+128,e[r+1]=i*(e[r+1]-128)+128,e[r+2]=i*(e[r+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}p(ts,"type","Contrast"),p(ts,"defaults",{contrast:0}),p(ts,"uniformLocations",["uContrast"]),T.setClass(ts);const lh={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    `};
vendor: 16,364 bytes, lines 353-504
353class es extends N{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return lh[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,s=e.data,i=this.matrix,r=Math.round(Math.sqrt(i.length)),n=Math.floor(r/2),o=e.width,h=e.height,c=t.ctx.createImageData(o,h),l=c.data,u=this.opaque?1:0;let g,d,f,v,_,x,C,S,b,w,D,M,O;for(D=0;D<h;D++)for(w=0;w<o;w++){for(_=4*(D*o+w),g=0,d=0,f=0,v=0,O=0;O<r;O++)for(M=0;M<r;M++)C=D+O-n,x=w+M-n,C<0||C>=h||x<0||x>=o||(S=4*(C*o+x),b=i[O*r+M],g+=s[S]*b,d+=s[S+1]*b,f+=s[S+2]*b,u||(v+=s[S+3]*b));l[_]=g,l[_+1]=d,l[_+2]=f,l[_+3]=u?s[_+3]:v}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return m(m({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}p(es,"type","Convolute"),p(es,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),p(es,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),T.setClass(es);const bn="Gamma";class ss extends N{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(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const s=this.gamma,i=1/s[0],r=1/s[1],n=1/s[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const o=this.rgbValues;for(let h=0;h<256;h++)o.r[h]=255*Math.pow(h/255,i),o.g[h]=255*Math.pow(h/255,r),o.b[h]=255*Math.pow(h/255,n);for(let h=0;h<e.length;h+=4)e[h]=o.r[e[h]],e[h+1]=o.g[e[h+1]],e[h+2]=o.b[e[h+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:bn,gamma:this.gamma.concat()}}}p(ss,"type",bn),p(ss,"defaults",{gamma:[1,1,1]}),p(ss,"uniformLocations",["uGamma"]),T.setClass(ss);const uh={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    `};class is extends N{applyTo2d(t){let{imageData:{data:e}}=t;for(let s,i=0;i<e.length;i+=4){const r=e[i],n=e[i+1],o=e[i+2];switch(this.mode){case"average":s=(r+n+o)/3;break;case"lightness":s=(Math.min(r,n,o)+Math.max(r,n,o))/2;break;case"luminosity":s=.21*r+.72*n+.07*o}e[i+2]=e[i+1]=e[i]=s}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return uh[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}p(is,"type","Grayscale"),p(is,"defaults",{mode:"average"}),p(is,"uniformLocations",["uMode"]),T.setClass(is);const gh=m(m({},Cn),{},{rotation:0});class Qs extends he{calculateMatrix(){const t=this.rotation*Math.PI,e=Ft(t),s=Lt(t),i=1/3,r=Math.sqrt(i)*s,n=1-e;this.matrix=[e+n/3,i*n-r,i*n+r,0,0,i*n+r,e+i*n,i*n-r,0,0,i*n-r,i*n+r,e+i*n,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}p(Qs,"type","HueRotation"),p(Qs,"defaults",gh),T.setClass(Qs);class rs extends N{applyTo2d(t){let{imageData:{data:e}}=t;for(let s=0;s<e.length;s+=4)e[s]=255-e[s],e[s+1]=255-e[s+1],e[s+2]=255-e[s+2],this.alpha&&(e[s+3]=255-e[s+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))}}p(rs,"type","Invert"),p(rs,"defaults",{alpha:!1,invert:!0}),p(rs,"uniformLocations",["uInvert","uAlpha"]),T.setClass(rs);class ns extends N{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(t){let{imageData:{data:e}}=t;const s=this.noise;for(let i=0;i<e.length;i+=4){const r=(.5-Math.random())*s;e[i]+=r,e[i+1]+=r,e[i+2]+=r}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}p(ns,"type","Noise"),p(ns,"defaults",{noise:0}),p(ns,"uniformLocations",["uNoise","uSeed"]),T.setClass(ns);class os extends N{applyTo2d(t){let{imageData:{data:e,width:s,height:i}}=t;for(let r=0;r<i;r+=this.blocksize)for(let n=0;n<s;n+=this.blocksize){const o=4*r*s+4*n,h=e[o],c=e[o+1],l=e[o+2],u=e[o+3];for(let g=r;g<Math.min(r+this.blocksize,i);g++)for(let d=n;d<Math.min(n+this.blocksize,s);d++){const f=4*g*s+4*d;e[f]=h,e[f+1]=c,e[f+2]=l,e[f+3]=u}}}isNeutralState(){return this.blocksize===1}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)}}p(os,"type","Pixelate"),p(os,"defaults",{blocksize:4}),p(os,"uniformLocations",["uBlocksize"]),T.setClass(os);class as extends N{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(t){let{imageData:{data:e}}=t;const s=255*this.distance,i=new F(this.color).getSource(),r=[i[0]-s,i[1]-s,i[2]-s],n=[i[0]+s,i[1]+s,i[2]+s];for(let o=0;o<e.length;o+=4){const h=e[o],c=e[o+1],l=e[o+2];h>r[0]&&c>r[1]&&l>r[2]&&h<n[0]&&c<n[1]&&l<n[2]&&(e[o+3]=0)}}sendUniformData(t,e){const s=new F(this.color).getSource(),i=this.distance,r=[0+s[0]/255-i,0+s[1]/255-i,0+s[2]/255-i,1],n=[s[0]/255+i,s[1]/255+i,s[2]/255+i,1];t.uniform4fv(e.uLow,r),t.uniform4fv(e.uHigh,n)}}p(as,"type","RemoveColor"),p(as,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),p(as,"uniformLocations",["uLow","uHigh"]),T.setClass(as);class hs extends N{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,s=this.getFilterWindow(),i=new Array(s);for(let r=1;r<=s;r++)i[r-1]=t(r*e);return i}generateShader(t){const e=new Array(t);for(let s=1;s<=t;s++)e[s-1]="".concat(s,".0 * uDelta");return`
460      precision highp float;
461      uniform sampler2D uTexture;
462      uniform vec2 uDelta;
463      varying vec2 vTexCoord;
464      uniform float uTaps[`.concat(t,`];
465      void main() {
466        vec4 color = texture2D(uTexture, vTexCoord);
467        float sum = 1.0;
468        `).concat(e.map((s,i)=>`
469              color += texture2D(uTexture, vTexCoord + `.concat(s,") * uTaps[").concat(i,"] + texture2D(uTexture, vTexCoord - ").concat(s,") * uTaps[").concat(i,`];
470              sum += 2.0 * uTaps[`).concat(i,`];
471            `)).join(`
472`),`
473        gl_FragColor = color / sum;
474      }
475    `)}applyToForWebgl(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){Is(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const s=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(s)/s}}applyTo2d(t){const e=t.imageData,s=this.scaleX,i=this.scaleY;this.rcpScaleX=1/s,this.rcpScaleY=1/i;const r=e.width,n=e.height,o=Math.round(r*s),h=Math.round(n*i);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,r,n,o,h):this.resizeType==="hermite"?this.hermiteFastResize(t,r,n,o,h):this.resizeType==="bilinear"?this.bilinearFiltering(t,r,n,o,h):this.resizeType==="lanczos"?this.lanczosResize(t,r,n,o,h):new ImageData(o,h),t.imageData=c}sliceByTwo(t,e,s,i,r){const n=t.imageData,o=.5;let h=!1,c=!1,l=e*o,u=s*o;const g=t.filterBackend.resources;let d=0,f=0;const v=e;let _=0;g.sliceByTwo||(g.sliceByTwo=Rt());const x=g.sliceByTwo;(x.width<1.5*e||x.height<s)&&(x.width=1.5*e,x.height=s);const C=x.getContext("2d");for(C.clearRect(0,0,1.5*e,s),C.putImageData(n,0,0),i=Math.floor(i),r=Math.floor(r);!h||!c;)e=l,s=u,i<Math.floor(l*o)?l=Math.floor(l*o):(l=i,h=!0),r<Math.floor(u*o)?u=Math.floor(u*o):(u=r,c=!0),C.drawImage(x,d,f,e,s,v,_,l,u),d=v,f=_,_+=u;return C.getImageData(d,f,i,r)}lanczosResize(t,e,s,i,r){const n=t.imageData.data,o=t.ctx.createImageData(i,r),h=o.data,c=this.lanczosCreate(this.lanczosLobes),l=this.rcpScaleX,u=this.rcpScaleY,g=2/this.rcpScaleX,d=2/this.rcpScaleY,f=Math.ceil(l*this.lanczosLobes/2),v=Math.ceil(u*this.lanczosLobes/2),_={},x={x:0,y:0},C={x:0,y:0};return function S(b){let w,D,M,O,A,G,U,R,L,P,K;for(x.x=(b+.5)*l,C.x=Math.floor(x.x),w=0;w<r;w++){for(x.y=(w+.5)*u,C.y=Math.floor(x.y),A=0,G=0,U=0,R=0,L=0,D=C.x-f;D<=C.x+f;D++)if(!(D<0||D>=e)){P=Math.floor(1e3*Math.abs(D-x.x)),_[P]||(_[P]={});for(let q=C.y-v;q<=C.y+v;q++)q<0||q>=s||(K=Math.floor(1e3*Math.abs(q-x.y)),_[P][K]||(_[P][K]=c(Math.sqrt(Math.pow(P*g,2)+Math.pow(K*d,2))/1e3)),M=_[P][K],M>0&&(O=4*(q*e+D),A+=M,G+=M*n[O],U+=M*n[O+1],R+=M*n[O+2],L+=M*n[O+3]))}O=4*(w*i+b),h[O]=G/A,h[O+1]=U/A,h[O+2]=R/A,h[O+3]=L/A}return++b<i?S(b):o}(0)}bilinearFiltering(t,e,s,i,r){let n,o,h,c,l,u,g,d,f,v,_,x,C,S=0;const b=this.rcpScaleX,w=this.rcpScaleY,D=4*(e-1),M=t.imageData.data,O=t.ctx.createImageData(i,r),A=O.data;for(g=0;g<r;g++)for(d=0;d<i;d++)for(l=Math.floor(b*d),u=Math.floor(w*g),f=b*d-l,v=w*g-u,C=4*(u*e+l),_=0;_<4;_++)n=M[C+_],o=M[C+4+_],h=M[C+D+_],c=M[C+D+4+_],x=n*(1-f)*(1-v)+o*f*(1-v)+h*v*(1-f)+c*f*v,A[S++]=x;return O}hermiteFastResize(t,e,s,i,r){const n=this.rcpScaleX,o=this.rcpScaleY,h=Math.ceil(n/2),c=Math.ceil(o/2),l=t.imageData.data,u=t.ctx.createImageData(i,r),g=u.data;for(let d=0;d<r;d++)for(let f=0;f<i;f++){const v=4*(f+d*i);let _=0,x=0,C=0,S=0,b=0,w=0,D=0;const M=(d+.5)*o;for(let O=Math.floor(d*o);O<(d+1)*o;O++){const A=Math.abs(M-(O+.5))/c,G=(f+.5)*n,U=A*A;for(let R=Math.floor(f*n);R<(f+1)*n;R++){let L=Math.abs(G-(R+.5))/h;const P=Math.sqrt(U+L*L);P>1&&P<-1||(_=2*P*P*P-3*P*P+1,_>0&&(L=4*(R+O*e),D+=_*l[L+3],C+=_,l[L+3]<255&&(_=_*l[L+3]/250),S+=_*l[L],b+=_*l[L+1],w+=_*l[L+2],x+=_))}}g[v]=S/x,g[v+1]=b/x,g[v+2]=w/x,g[v+3]=D/C}return u}}p(hs,"type","Resize"),p(hs,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),p(hs,"uniformLocations",["uDelta","uTaps"]),T.setClass(hs);class cs extends N{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(t){let{imageData:{data:e}}=t;const s=-this.saturation;for(let i=0;i<e.length;i+=4){const r=e[i],n=e[i+1],o=e[i+2],h=Math.max(r,n,o);e[i]+=h!==r?(h-r)*s:0,e[i+1]+=h!==n?(h-n)*s:0,e[i+2]+=h!==o?(h-o)*s:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}p(cs,"type","Saturation"),p(cs,"defaults",{saturation:0}),p(cs,"uniformLocations",["uSaturation"]),T.setClass(cs);class ls extends N{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(t){let{imageData:{data:e}}=t;const s=-this.vibrance;for(let i=0;i<e.length;i+=4){const r=e[i],n=e[i+1],o=e[i+2],h=Math.max(r,n,o),c=(r+n+o)/3,l=2*Math.abs(h-c)/255*s;e[i]+=h!==r?(h-r)*l:0,e[i+1]+=h!==n?(h-n)*l:0,e[i+2]+=h!==o?(h-o)*l:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}p(ls,"type","Vibrance"),p(ls,"defaults",{vibrance:0}),p(ls,"uniformLocations",["uVibrance"]),T.setClass(ls);export{Qt as ActiveSelection,Dt as BaseFabricObject,gr as Canvas,th as Canvas2dFilterBackend,Da as CanvasDOMManager,kt as Circle,mr as ClipPathLayout,F as Color,ft as Control,Mt as Ellipse,ct as FabricImage,$ as FabricObject,Q as FabricText,hi as FitContentLayout,vr as FixedLayout,ze as Gradient,te as Group,Pt as IText,ct as Image,je as InteractiveFabricObject,W as Intersection,Fe as LayoutManager,Rs as LayoutStrategy,Jt as Line,$ as Object,En as Observable,Kt as Path,qs as Pattern,y as Point,Ge as Polygon,pt as Polyline,Ct as Rect,jt as Shadow,Be as StaticCanvas,Fr as StaticCanvasDOMManager,Q as Text,$t as Textbox,Zt as Triangle,_n as WebGLFilterBackend,Te as cache,T as classRegistry,E as config,Sr as createCollectionMixin,wt as getEnv,de as getFabricDocument,ks as getFabricWindow,$s as getFilterBackend,et as iMatrix,eh as initFilterBackend,Is as isWebGLPipelineState,Xt as parseAttributes,ea as parseFontDeclaration,za as parsePointsAttribute,ia as parseStyleAttribute,ai as parseTransformAttribute,_s as runningAnimations,ti as version};

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.