mirror of
https://github.com/exogen/t2-model-skinner.git
synced 2026-07-12 06:55:13 +00:00
1 line
No EOL
439 KiB
JavaScript
1 line
No EOL
439 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,43794,(t,e,r)=>{!function(){"use strict";var r={}.hasOwnProperty;function i(){for(var t=[],e=0;e<arguments.length;e++){var n=arguments[e];if(n){var s=typeof n;if("string"===s||"number"===s)t.push(n);else if(Array.isArray(n)){if(n.length){var o=i.apply(null,n);o&&t.push(o)}}else if("object"===s){if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]")){t.push(n.toString());continue}for(var a in n)r.call(n,a)&&n[a]&&t.push(a)}}}return t.join(" ")}if(e.exports)i.default=i,e.exports=i;else if("function"==typeof define&&"object"==typeof define.amd&&define.amd)void 0!==i&&t.v(i);else window.classNames=i}()},79702,t=>{t.v(t.b(["static/chunks/9338a92aac995757.js","static/chunks/a55df98dcb3b60ad.js","static/chunks/turbopack-95cb340f669027bc.js"]))},67585,(t,e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"BailoutToCSR",{enumerable:!0,get:function(){return n}});let i=t.r(32061);function n(t){let{reason:e,children:r}=t;if("undefined"==typeof window)throw Object.defineProperty(new i.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return r}},9885,(t,e,r)=>{"use strict";function i(t){return t.split("/").map(t=>encodeURIComponent(t)).join("/")}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"encodeURIPath",{enumerable:!0,get:function(){return i}})},52157,(t,e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"PreloadChunks",{enumerable:!0,get:function(){return a}});let i=t.r(43476),n=t.r(74080),s=t.r(63599),o=t.r(9885);function a(t){let{moduleIds:e}=t;if("undefined"!=typeof window)return null;let r=s.workAsyncStorage.getStore();if(void 0===r)return null;let a=[];if(r.reactLoadableManifest&&e){let t=r.reactLoadableManifest;for(let r of e){if(!t[r])continue;let e=t[r].files;a.push(...e)}}return 0===a.length?null:(0,i.jsx)(i.Fragment,{children:a.map(t=>{let e=r.assetPrefix+"/_next/"+(0,o.encodeURIPath)(t);return t.endsWith(".css")?(0,i.jsx)("link",{precedence:"dynamic",href:e,rel:"stylesheet",as:"style"},t):((0,n.preload)(e,{as:"script",fetchPriority:"low"}),null)})})}},69093,(t,e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return h}});let i=t.r(43476),n=t.r(71645),s=t.r(67585),o=t.r(52157);function a(t){return{default:t&&"default"in t?t.default:t}}let l={loader:()=>Promise.resolve(a(()=>null)),loading:null,ssr:!0},h=function(t){let e={...l,...t},r=(0,n.lazy)(()=>e.loader().then(a)),h=e.loading;function c(t){let a=h?(0,i.jsx)(h,{isLoading:!0,pastDelay:!0,error:null}):null,l=!e.ssr||!!e.loading,c=l?n.Suspense:n.Fragment,u=e.ssr?(0,i.jsxs)(i.Fragment,{children:["undefined"==typeof window?(0,i.jsx)(o.PreloadChunks,{moduleIds:e.modules}):null,(0,i.jsx)(r,{...t})]}):(0,i.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,i.jsx)(r,{...t})});return(0,i.jsx)(c,{...l?{fallback:a}:{},children:u})}return c.displayName="LoadableComponent",c}},70703,(t,e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return n}});let i=t.r(55682)._(t.r(69093));function n(t,e){var r;let n={};"function"==typeof t&&(n.loader=t);let s={...n,...e};return(0,i.default)({...s,modules:null==(r=s.loadableGenerated)?void 0:r.modules})}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),e.exports=r.default)},52683,t=>{"use strict";let e,r,i,n;t.s(["default",()=>u7],52683);var s,o,a,l,h,c,u,d,f,g,p,m,y,x,b,_,w,C,S,T,O,k,M,E,D,j,A,P,F,L,R,I,B,N,W,U,H,X,V,Y,z,G,q,K,Q=t.i(43476),J=t.i(71645);function Z(t,e,r){var i;return(e="symbol"==typeof(i=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(e,"string"))?i:i+"")in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,i)}return r}function tt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$(Object(r),!0).forEach(function(e){Z(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function te(t,e){if(null==t)return{};var r,i,n=function(t,e){if(null==t)return{};var r={};for(var i in t)if(({}).hasOwnProperty.call(t,i)){if(e.indexOf(i)>=0)continue;r[i]=t[i]}return r}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i<s.length;i++)r=s[i],e.indexOf(r)>=0||({}).propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function tr(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}class ti{constructor(){Z(this,"browserShadowBlurConstant",1),Z(this,"DPI",96),Z(this,"devicePixelRatio","undefined"!=typeof window?window.devicePixelRatio:1),Z(this,"perfLimitSizeTotal",2097152),Z(this,"maxCacheSideLimit",4096),Z(this,"minCacheSideLimit",256),Z(this,"disableStyleCopyPaste",!1),Z(this,"enableGLFiltering",!0),Z(this,"textureSize",4096),Z(this,"forceGLPutImageData",!1),Z(this,"cachesBoundsOfCurve",!1),Z(this,"fontPaths",{}),Z(this,"NUM_FRACTION_DIGITS",4)}}let tn=new class extends ti{configure(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Object.assign(this,t)}addFonts(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.fontPaths=tt(tt({},this.fontPaths),t)}removeFonts(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(t=>{delete this.fontPaths[t]})}clearFonts(){this.fontPaths={}}restoreDefaults(t){let e=new ti,r=(null==t?void 0:t.reduce((t,r)=>(t[r]=e[r],t),{}))||e;this.configure(r)}constructor(t){super(),this.configure(t)}},ts=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return console[t]("fabric",...r)};class to extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class ta extends to{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class tl{}class th extends tl{testPrecision(t,e){let r=t.createShader(t.FRAGMENT_SHADER);return!!r&&(t.shaderSource(r,"precision ".concat(e," float;\nvoid main(){}")),t.compileShader(r),!!t.getShaderParameter(r,t.COMPILE_STATUS))}queryWebGL(t){let e=t.getContext("webgl");e&&(this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.GLPrecision=["highp","mediump","lowp"].find(t=>this.testPrecision(e,t)),e.getExtension("WEBGL_lose_context").loseContext(),ts("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}let tc={},tu=()=>e||(e={document:document,window:window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new th,dispose(){},copyPasteData:tc}),td=()=>tu().document,tf=()=>tu().window,tg=()=>{var t;return Math.max(null!=(t=tn.devicePixelRatio)?t:tf().devicePixelRatio,1)},tp=new class{getFontCache(t){let{fontFamily:e,fontStyle:r,fontWeight:i}=t;e=e.toLowerCase(),this.charWidthsCache[e]||(this.charWidthsCache[e]={});let n=this.charWidthsCache[e],s="".concat(r.toLowerCase(),"_").concat((i+"").toLowerCase());return n[s]||(n[s]={}),n[s]}clearFontCache(t){(t=(t||"").toLowerCase())?this.charWidthsCache[t]&&delete this.charWidthsCache[t]:this.charWidthsCache={}}limitDimsByArea(t){let{perfLimitSizeTotal:e}=tn,r=Math.sqrt(e*t);return[Math.floor(r),Math.floor(e/r)]}constructor(){Z(this,"charWidthsCache",{}),Z(this,"boundsOfCurveCache",{})}},tm="6.7.1";function tv(){}let ty=Math.PI/2,tx=2*Math.PI,tb=Math.PI/180,t_=Object.freeze([1,0,0,1,0,0]),tw="center",tC="left",tS="bottom",tT="right",tO="none",tk=/\r?\n/,tM="moving",tE="scaling",tD="rotating",tj="rotate",tA="skewing",tP="resizing",tF="modifyPoly",tL="changed",tR="scale",tI="scaleX",tB="scaleY",tN="skewX",tW="skewY",tU="fill",tH="stroke",tX="modified",tV="json",tY=new class{has(t){return this[tV].has(t)}getClass(t){let e=this[tV].get(t);if(!e)throw new to("No class registered for ".concat(t));return e}setClass(t,e){e?this[tV].set(e,t):(this[tV].set(t.type,t),this[tV].set(t.type.toLowerCase(),t))}getSVGClass(t){return this.svg.get(t)}setSVGClass(t,e){this.svg.set(null!=e?e:t.type.toLowerCase(),t)}constructor(){this[tV]=new Map,this.svg=new Map}},tz=new class extends Array{remove(t){let e=this.indexOf(t);e>-1&&this.splice(e,1)}cancelAll(){let t=this.splice(0);return t.forEach(t=>t.abort()),t}cancelByCanvas(t){if(!t)return[];let e=this.filter(e=>{var r;return e.target===t||"object"==typeof e.target&&(null==(r=e.target)?void 0:r.canvas)===t});return e.forEach(t=>t.abort()),e}cancelByTarget(t){if(!t)return[];let e=this.filter(e=>e.target===t);return e.forEach(t=>t.abort()),e}};class tG{on(t,e){return(this.__eventListeners||(this.__eventListeners={}),"object"==typeof t)?(Object.entries(t).forEach(t=>{let[e,r]=t;this.on(e,r)}),()=>this.off(t)):e?(this.__eventListeners[t]||(this.__eventListeners[t]=[]),this.__eventListeners[t].push(e),()=>this.off(t,e)):()=>!1}once(t,e){if("object"==typeof t){let e=[];return Object.entries(t).forEach(t=>{let[r,i]=t;e.push(this.once(r,i))}),()=>e.forEach(t=>t())}if(e){let r=this.on(t,function(){for(var t=arguments.length,i=Array(t),n=0;n<t;n++)i[n]=arguments[n];e.call(this,...i),r()});return r}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){let r=this.__eventListeners[t],i=r.indexOf(e);i>-1&&r.splice(i,1)}else this.__eventListeners[t]=[]}off(t,e){if(this.__eventListeners)if(void 0===t)for(let t in this.__eventListeners)this._removeEventListener(t);else"object"==typeof t?Object.entries(t).forEach(t=>{let[e,r]=t;this._removeEventListener(e,r)}):this._removeEventListener(t,e)}fire(t,e){var r;if(!this.__eventListeners)return;let i=null==(r=this.__eventListeners[t])?void 0:r.concat();if(i)for(let t=0;t<i.length;t++)i[t].call(this,e||{})}constructor(){Z(this,"__eventListeners",{})}}let tq=(t,e)=>{let r=t.indexOf(e);return -1!==r&&t.splice(r,1),t},tK=t=>{if(0===t)return 1;switch(Math.abs(t)/ty){case 1:case 3:return 0;case 2:return -1}return Math.cos(t)},tQ=t=>{if(0===t)return 0;let e=Math.sign(t);switch(t/ty){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)};class tJ{add(t){return new tJ(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new tJ(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new tJ(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new tJ(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new tJ(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new tJ(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new tJ(this.x/t.x,this.y/t.y)}scalarDivide(t){return new tJ(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&&void 0!==arguments[1]?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new tJ(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){let e=this.x-t.x,r=this.y-t.y;return Math.sqrt(e*e+r*r)}midPointFrom(t){return this.lerp(t)}min(t){return new tJ(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new tJ(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){let e=this.x,r=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=r}clone(){return new tJ(this.x,this.y)}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tZ,r=tQ(t),i=tK(t),n=this.subtract(e);return new tJ(n.x*i-n.y*r,n.x*r+n.y*i).add(e)}transform(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new tJ(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;"object"==typeof t?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}}let tZ=new tJ(0,0),t$=t=>!!t&&Array.isArray(t._objects);function t0(t){class e extends t{_onObjectAdded(t){}_onObjectRemoved(t){}_onStackOrderChanged(t){}add(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];let i=this._objects.push(...e);return e.forEach(t=>this._onObjectAdded(t)),i}insertAt(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return this._objects.splice(t,0,...r),r.forEach(t=>this._onObjectAdded(t)),this._objects.length}remove(){let t=this._objects,e=[];for(var r=arguments.length,i=Array(r),n=0;n<r;n++)i[n]=arguments[n];return i.forEach(r=>{let i=t.indexOf(r);-1!==i&&(t.splice(i,1),e.push(r),this._onObjectRemoved(r))}),e}forEachObject(t){this.getObjects().forEach((e,r,i)=>t(e,r,i))}getObjects(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];return 0===e.length?[...this._objects]:this._objects.filter(t=>t.isType(...e))}item(t){return this._objects[t]}isEmpty(){return 0===this._objects.length}size(){return this._objects.length}contains(t,r){return!!this._objects.includes(t)||!!r&&this._objects.some(r=>r instanceof e&&r.contains(t,!0))}complexity(){return this._objects.reduce((t,e)=>t+=e.complexity?e.complexity():0,0)}sendObjectToBack(t){return!(!t||t===this._objects[0])&&(tq(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),!0)}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1])&&(tq(this._objects,t),this._objects.push(t),this._onStackOrderChanged(t),!0)}sendObjectBackwards(t,e){if(!t)return!1;let r=this._objects.indexOf(t);if(0!==r){let i=this.findNewLowerIndex(t,r,e);return tq(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}bringObjectForward(t,e){if(!t)return!1;let r=this._objects.indexOf(t);if(r!==this._objects.length-1){let i=this.findNewUpperIndex(t,r,e);return tq(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(tq(this._objects,t),this._objects.splice(e,0,t),this._onStackOrderChanged(t),!0)}findNewLowerIndex(t,e,r){let i;if(r){i=e;for(let r=e-1;r>=0;--r)if(t.isOverlapping(this._objects[r])){i=r;break}}else i=e-1;return i}findNewUpperIndex(t,e,r){let i;if(r){i=e;for(let r=e+1;r<this._objects.length;++r)if(t.isOverlapping(this._objects[r])){i=r;break}}else i=e+1;return i}collectObjects(t){let{left:e,top:r,width:i,height:n}=t,{includeIntersecting:s=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=[],a=new tJ(e,r),l=a.add(new tJ(i,n));for(let t=this._objects.length-1;t>=0;t--){let e=this._objects[t];e.selectable&&e.visible&&(s&&e.intersectsWithRect(a,l)||e.isContainedWithinRect(a,l)||s&&e.containsPoint(a)||s&&e.containsPoint(l))&&o.push(e)}return o}constructor(){super(...arguments),Z(this,"_objects",[])}}return e}class t1 extends tG{_setOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(let e in t)this.set(e,t[e])}_setObject(t){for(let e in t)this._set(e,t[e])}set(t,e){return"object"==typeof t?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){let e=this.get(t);return"boolean"==typeof e&&this.set(t,!e),this}get(t){return this[t]}}function t2(t){return tf().requestAnimationFrame(t)}function t5(t){return tf().cancelAnimationFrame(t)}let t4=0,t3=()=>t4++,t9=()=>{let t=td().createElement("canvas");if(!t||void 0===t.getContext)throw new to("Failed to create `canvas` element");return t},t6=()=>td().createElement("img"),t8=t=>{let e=t9();return e.width=t.width,e.height=t.height,e},t7=(t,e,r)=>t.toDataURL("image/".concat(e),r),et=(t,e,r)=>new Promise((i,n)=>{t.toBlob(i,"image/".concat(e),r)}),ee=t=>t*tb,er=t=>t/tb,ei=t=>t.every((t,e)=>t===t_[e]),en=(t,e,r)=>new tJ(t).transform(e,r),es=t=>{let e=1/(t[0]*t[3]-t[1]*t[2]),r=[e*t[3],-e*t[1],-e*t[2],e*t[0],0,0],{x:i,y:n}=new tJ(t[4],t[5]).transform(r,!0);return r[4]=-i,r[5]=-n,r},eo=(t,e,r)=>[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],r?0:t[0]*e[4]+t[2]*e[5]+t[4],r?0:t[1]*e[4]+t[3]*e[5]+t[5]],ea=(t,e)=>t.reduceRight((t,r)=>r&&t?eo(r,t,e):r||t,void 0)||t_.concat(),el=t=>{let[e,r]=t;return Math.atan2(r,e)},eh=t=>{let e=el(t),r=Math.pow(t[0],2)+Math.pow(t[1],2),i=Math.sqrt(r),n=(t[0]*t[3]-t[2]*t[1])/i,s=Math.atan2(t[0]*t[2]+t[1]*t[3],r);return{angle:er(e),scaleX:i,scaleY:n,skewX:er(s),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},ec=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function eu(){let{angle:t=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{x:e=0,y:r=0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=ee(t),n=tK(i),s=tQ(i);return[n,s,-s,n,e?e-(n*e-s*r):0,r?r-(s*e+n*r):0]}let ed=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},ef=t=>Math.tan(ee(t)),eg=t=>[1,0,ef(t),1,0,0],ep=t=>[1,ef(t),0,1,0,0],em=t=>{let{scaleX:e=1,scaleY:r=1,flipX:i=!1,flipY:n=!1,skewX:s=0,skewY:o=0}=t,a=ed(i?-e:e,n?-r:r);return s&&(a=eo(a,eg(s),!0)),o&&(a=eo(a,ep(o),!0)),a},ev=t=>{let{translateX:e=0,translateY:r=0,angle:i=0}=t,n=ec(e,r);i&&(n=eo(n,eu({angle:i})));let s=em(t);return ei(s)||(n=eo(n,s)),n},ey=function(t){let{signal:e,crossOrigin:r=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(function(i,n){let s;if(e&&e.aborted)return n(new ta("loadImage"));let o=t6();e&&(s=function(t){o.src="",n(t)},e.addEventListener("abort",s,{once:!0}));let a=function(){o.onload=o.onerror=null,s&&(null==e||e.removeEventListener("abort",s)),i(o)};t?(o.onload=a,o.onerror=function(){s&&(null==e||e.removeEventListener("abort",s)),n(new to("Error loading ".concat(o.src)))},r&&(o.crossOrigin=r),o.src=t):a()})},ex=function(t){let{signal:e,reviver:r=tv}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((i,n)=>{let s=[];e&&e.addEventListener("abort",n,{once:!0}),Promise.all(t.map(t=>tY.getClass(t.type).fromObject(t,{signal:e}).then(e=>(r(t,e),s.push(e),e)))).then(i).catch(t=>{s.forEach(t=>{t.dispose&&t.dispose()}),n(t)}).finally(()=>{e&&e.removeEventListener("abort",n)})})},eb=function(t){let{signal:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((r,i)=>{let n=[];e&&e.addEventListener("abort",i,{once:!0});let s=Object.values(t).map(t=>t&&t.type&&tY.has(t.type)?ex([t],{signal:e}).then(t=>{let[e]=t;return n.push(e),e}):t),o=Object.keys(t);Promise.all(s).then(t=>t.reduce((t,e,r)=>(t[o[r]]=e,t),{})).then(r).catch(t=>{n.forEach(t=>{t.dispose&&t.dispose()}),i(t)}).finally(()=>{e&&e.removeEventListener("abort",i)})})},e_=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce((e,r)=>(r in t&&(e[r]=t[r]),e),{})},ew=(t,e)=>Object.keys(t).reduce((r,i)=>(e(t[i],i,t)&&(r[i]=t[i]),r),{}),eC=(t,e)=>parseFloat(Number(t).toFixed(e)),eS=t=>"matrix("+t.map(t=>eC(t,tn.NUM_FRACTION_DIGITS)).join(" ")+")",eT=t=>!!t&&void 0!==t.toLive,eO=t=>!!t&&"function"==typeof t.toObject,ek=t=>!!t&&void 0!==t.offsetX&&"source"in t,eM=t=>!!t&&"multiSelectionStacking"in t;function eE(t){let e=t&&eD(t),r=0,i=0;if(!t||!e)return{left:r,top:i};let n=t,s=e.documentElement,o=e.body||{scrollLeft:0,scrollTop:0};for(;n&&(n.parentNode||n.host)&&((n=n.parentNode||n.host)===e?(r=o.scrollLeft||s.scrollLeft||0,i=o.scrollTop||s.scrollTop||0):(r+=n.scrollLeft||0,i+=n.scrollTop||0),1!==n.nodeType||"fixed"!==n.style.position););return{left:r,top:i}}let eD=t=>t.ownerDocument||null,ej=t=>{var e;return(null==(e=t.ownerDocument)?void 0:e.defaultView)||null},eA=function(t,e,r){let{width:i,height:n}=r,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;t.width=i,t.height=n,s>1&&(t.setAttribute("width",(i*s).toString()),t.setAttribute("height",(n*s).toString()),e.scale(s,s))},eP=(t,e)=>{let{width:r,height:i}=e;r&&(t.style.width="number"==typeof r?"".concat(r,"px"):r),i&&(t.style.height="number"==typeof i?"".concat(i,"px"):i)};function eF(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=tO,t}class eL{createLowerCanvas(t){let e=t&&void 0!==t.getContext?t:t&&td().getElementById(t)||t9();if(e.hasAttribute("data-fabric"))throw new to("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:r}=t,{el:i}=this.lower;i.classList.remove("lower-canvas"),i.removeAttribute("data-fabric"),i.setAttribute("width","".concat(e)),i.setAttribute("height","".concat(r)),i.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){let{el:r,ctx:i}=this.lower;eA(r,i,t,e)}setCSSDimensions(t){eP(this.lower.el,t)}calcOffset(){return function(t){var e;let r=t&&eD(t),i={left:0,top:0};if(!r)return i;let n=(null==(e=ej(t))?void 0:e.getComputedStyle(t,null))||{};i.left+=parseInt(n.borderLeftWidth,10)||0,i.top+=parseInt(n.borderTopWidth,10)||0,i.left+=parseInt(n.paddingLeft,10)||0,i.top+=parseInt(n.paddingTop,10)||0;let s={left:0,top:0},o=r.documentElement;void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect());let a=eE(t);return{left:s.left+a.left-(o.clientLeft||0)+i.left,top:s.top+a.top-(o.clientTop||0)+i.top}}(this.lower.el)}dispose(){tu().dispose(this.lower.el),delete this.lower}constructor(t){Z(this,"_originalCanvasStyle",void 0),Z(this,"lower",void 0);let e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}}let eR={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...t_]};class eI extends t0(t1){get lowerCanvasEl(){var t;return null==(t=this.elements.lower)?void 0:t.el}get contextContainer(){var t;return null==(t=this.elements.lower)?void 0:t.ctx}static getDefaults(){return eI.ownDefaults}initElements(t){this.elements=new eL(t)}add(){let t=super.add(...arguments);return arguments.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];let n=super.insertAt(t,...r);return r.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(){let t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(ts("warn","Canvas is trying to add an object that belongs to a different canvas.\nResulting 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?tg():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:r=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e){let e=tt({width:this.width,height:this.height},t);this.elements.setDimensions(e,this.getRetinaScaling()),this.hasLostContext=!0,this.width=e.width,this.height=e.height}r||this.elements.setCSSDimensions(t),this.calcOffset()}setDimensions(t,e){this._setDimensionsImpl(t,e),e&&e.cssOnly||this.requestRenderAll()}getZoom(){return this.viewportTransform[0]}setViewportTransform(t){this.viewportTransform=t,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(t,e){let r=[...this.viewportTransform],i=en(t,es(r));r[0]=e,r[3]=e;let n=en(i,r);r[4]+=t.x-n.x,r[5]+=t.y-n.y,this.setViewportTransform(r)}setZoom(t){this.zoomToPoint(new tJ(0,0),t)}absolutePan(t){let e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new tJ(-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=t2(()=>this.renderAndReset()))}calcViewportBoundaries(){let t=this.width,e=this.height,r=es(this.viewportTransform),i=en({x:0,y:0},r),n=en({x:t,y:e},r),s=i.min(n),o=i.max(n);return this.vptCoords={tl:s,tr:new tJ(o.x,s.y),bl:new tJ(s.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(t5(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;let r=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(r[0],r[1],r[2],r[3],r[4],r[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){let r=this.viewportTransform;t.save(),t.transform(...r),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 r=0,i=e.length;r<i;++r)e[r]&&e[r].render(t)}_renderBackgroundOrOverlay(t,e){let r=this["".concat(e,"Color")],i=this["".concat(e,"Image")],n=this.viewportTransform,s=this["".concat(e,"Vpt")];if(!r&&!i)return;let o=eT(r);if(r){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?r.toLive(t):r,s&&t.transform(...n),o){t.transform(1,0,0,1,r.offsetX||0,r.offsetY||0);let e=r.gradientTransform||r.patternTransform;e&&t.transform(...e)}t.fill(),t.restore()}if(i){t.save();let{skipOffscreen:e}=this;this.skipOffscreen=s,s&&t.transform(...n),i.render(t),this.skipOffscreen=e,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 tJ(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new tJ(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new tJ(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 tJ(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new tJ(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return en(this.getCenterPoint(),es(this.viewportTransform))}_centerObject(t,e){t.setXY(e,tw,tw),t.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(t){return this.toDatalessObject(t)}toObject(t){return this._toObjectMethod("toObject",t)}toJSON(){return this.toObject()}toDatalessObject(t){return this._toObjectMethod("toDatalessObject",t)}_toObjectMethod(t,e){let r=this.clipPath,i=r&&!r.excludeFromExport?this._toObject(r,t,e):null;return tt(tt(tt({version:tm},e_(this,e)),{},{objects:this._objects.filter(t=>!t.excludeFromExport).map(r=>this._toObject(r,t,e))},this.__serializeBgOverlay(t,e)),i?{clipPath:i}:null)}_toObject(t,e,r){let i;this.includeDefaultValues||(i=t.includeDefaultValues,t.includeDefaultValues=!1);let n=t[e](r);return this.includeDefaultValues||(t.includeDefaultValues=!!i),n}__serializeBgOverlay(t,e){let r={},i=this.backgroundImage,n=this.overlayImage,s=this.backgroundColor,o=this.overlayColor;return eT(s)?s.excludeFromExport||(r.background=s.toObject(e)):s&&(r.background=s),eT(o)?o.excludeFromExport||(r.overlay=o.toObject(e)):o&&(r.overlay=o),i&&!i.excludeFromExport&&(r.backgroundImage=this._toObject(i,t,e)),n&&!n.excludeFromExport&&(r.overlayImage=this._toObject(n,t,e)),r}toSVG(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;t.reviver=e;let r=[];return this._setSVGPreamble(r,t),this._setSVGHeader(r,t),this.clipPath&&r.push('<g clip-path="url(#'.concat(this.clipPath.clipPathId,')" >\n')),this._setSVGBgOverlayColor(r,"background"),this._setSVGBgOverlayImage(r,"backgroundImage",e),this._setSVGObjects(r,e),this.clipPath&&r.push("</g>\n"),this._setSVGBgOverlayColor(r,"overlay"),this._setSVGBgOverlayImage(r,"overlayImage",e),r.push("</svg>"),r.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')}_setSVGHeader(t,e){let r,i=e.width||"".concat(this.width),n=e.height||"".concat(this.height),s=tn.NUM_FRACTION_DIGITS,o=e.viewBox;if(o)r='viewBox="'.concat(o.x," ").concat(o.y," ").concat(o.width," ").concat(o.height,'" ');else if(this.svgViewportTransformation){let t=this.viewportTransform;r='viewBox="'.concat(eC(-t[4]/t[0],s)," ").concat(eC(-t[5]/t[3],s)," ").concat(eC(this.width/t[0],s)," ").concat(eC(this.height/t[3],s),'" ')}else r='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="',i,'" ','height="',n,'" ',r,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",tm,"</desc>\n","<defs>\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"</defs>\n")}createSVGClipPathMarkup(t){let e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(t3()),'<clipPath id="'.concat(e.clipPathId,'" >\n').concat(e.toClipPathSVG(t.reviver),"</clipPath>\n")):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{let e=this["".concat(t,"Color")];if(eT(e)){let r=this["".concat(t,"Vpt")],i=this.viewportTransform,n={isType:()=>!1,width:this.width/(r?i[0]:1),height:this.height/(r?i[3]:1)};return e.toSVG(n,{additionalTransform:r?eS(i):""})}}).join("")}createSVGFontFacesMarkup(){let t=[],e={},r=tn.fontPaths;this._objects.forEach(function e(r){t.push(r),t$(r)&&r._objects.forEach(e)}),t.forEach(t=>{if(!t||"function"!=typeof t._renderText)return;let{styles:i,fontFamily:n}=t;!e[n]&&r[n]&&(e[n]=!0,i&&Object.values(i).forEach(t=>{Object.values(t).forEach(t=>{let{fontFamily:i=""}=t;!e[i]&&r[i]&&(e[i]=!0)})}))});let i=Object.keys(e).map(t=>" @font-face {\n font-family: '".concat(t,"';\n src: url('").concat(r[t],"');\n }\n")).join("");return i?' <style type="text/css"><![CDATA[\n'.concat(i,"]]></style>\n"):""}_setSVGObjects(t,e){this.forEachObject(r=>{r.excludeFromExport||this._setSVGObject(t,r,e)})}_setSVGObject(t,e,r){t.push(e.toSVG(r))}_setSVGBgOverlayImage(t,e,r){let i=this[e];i&&!i.excludeFromExport&&i.toSVG&&t.push(i.toSVG(r))}_setSVGBgOverlayColor(t,e){let r=this["".concat(e,"Color")];if(r)if(eT(r)){let i=r.repeat||"",n=this.width,s=this.height,o=this["".concat(e,"Vpt")]?eS(es(this.viewportTransform)):"";t.push('<rect transform="'.concat(o," translate(").concat(n/2,",").concat(s/2,')" x="').concat(r.offsetX-n/2,'" y="').concat(r.offsetY-s/2,'" width="').concat("repeat-y"!==i&&"no-repeat"!==i||!ek(r)?n:r.source.width,'" height="').concat("repeat-x"!==i&&"no-repeat"!==i||!ek(r)?s:r.source.height,'" fill="url(#SVGID_').concat(r.id,')"></rect>\n'))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',r,'"',"></rect>\n")}loadFromJSON(t,e){let{signal:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Promise.reject(new to("`json` is undefined"));let i="string"==typeof t?JSON.parse(t):t,{objects:n=[],backgroundImage:s,background:o,overlayImage:a,overlay:l,clipPath:h}=i,c=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([ex(n,{reviver:e,signal:r}),eb({backgroundImage:s,backgroundColor:o,overlayImage:a,overlayColor:l,clipPath:h},{signal:r})]).then(t=>{let[e,r]=t;return this.clear(),this.add(...e),this.set(i),this.set(r),this.renderOnAddRemove=c,this})}clone(t){let e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){let t=t8(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{format:e="png",quality:r=1,multiplier:i=1,enableRetinaScaling:n=!1}=t,s=i*(n?this.getRetinaScaling():1);return t7(this.toCanvasElement(s,t),e,r)}toBlob(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{format:e="png",quality:r=1,multiplier:i=1,enableRetinaScaling:n=!1}=t,s=i*(n?this.getRetinaScaling():1);return et(this.toCanvasElement(s,t),e,r)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,{width:e,height:r,left:i,top:n,filter:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=(e||this.width)*t,a=(r||this.height)*t,l=this.getZoom(),h=this.width,c=this.height,u=this.skipControlsDrawing,d=l*t,f=this.viewportTransform,g=[d,0,0,d,(f[4]-(i||0))*t,(f[5]-(n||0))*t],p=this.enableRetinaScaling,m=t8({width:o,height:a}),y=s?this._objects.filter(t=>s(t)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=g,this.width=o,this.height=a,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),y),this.viewportTransform=f,this.width=h,this.height=c,this.calcViewportBoundaries(),this.enableRetinaScaling=p,this.skipControlsDrawing=u,m}dispose(){return this.disposed||this.elements.cleanupDOM({width:this.width,height:this.height}),tz.cancelByCanvas(this),this.disposed=!0,new Promise((t,e)=>{let r=()=>{this.destroy(),t(!0)};r.kill=e,this.__cleanupTask&&this.__cleanupTask.kill("aborted"),this.destroyed?t(!1):this.nextRenderHandle?this.__cleanupTask=r:r()})}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," }>")}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?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()}}Z(eI,"ownDefaults",eR);let eB=["touchstart","touchmove","touchend"],eN=t=>{let e=eE(t.target),r=function(t){let e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new tJ(r.clientX+e.left,r.clientY+e.top)},eW=t=>eB.includes(t.type)||"touch"===t.pointerType,eU=t=>{t.preventDefault(),t.stopPropagation()},eH=t=>{let e=0,r=0,i=0,n=0;for(let s=0,o=t.length;s<o;s++){let{x:o,y:a}=t[s];(o>i||!s)&&(i=o),(o<e||!s)&&(e=o),(a>n||!s)&&(n=a),(a<r||!s)&&(r=a)}return{left:e,top:r,width:i-e,height:n-r}},eX=["translateX","translateY","scaleX","scaleY"],eV=(t,e)=>eY(t,eo(e,t.calcOwnMatrix())),eY=(t,e)=>{let r=eh(e),{translateX:i,translateY:n,scaleX:s,scaleY:o}=r,a=te(r,eX),l=new tJ(i,n);t.flipX=!1,t.flipY=!1,Object.assign(t,a),t.set({scaleX:s,scaleY:o}),t.setPositionByOrigin(l,tw,tw)},ez=t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},eG=t=>({scaleX:t.scaleX,scaleY:t.scaleY,skewX:t.skewX,skewY:t.skewY,angle:t.angle,left:t.left,flipX:t.flipX,flipY:t.flipY,top:t.top}),eq=(t,e,r)=>{let i=t/2,n=e/2,s=eH([new tJ(-i,-n),new tJ(i,-n),new tJ(-i,n),new tJ(i,n)].map(t=>t.transform(r)));return new tJ(s.width,s.height)},eK=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t_;return eo(es(arguments.length>1&&void 0!==arguments[1]?arguments[1]:t_),t)},eQ=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t_,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t_;return t.transform(eK(e,r))},eJ=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t_,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t_;return t.transform(eK(e,r),!0)},eZ=(t,e,r)=>{let i=eK(e,r);return eY(t,eo(i,t.calcOwnMatrix())),i},e$=(t,e)=>{var r;let{transform:{target:i}}=e;null==(r=i.canvas)||r.fire("object:".concat(t),tt(tt({},e),{},{target:i})),i.fire(t,e)},e0={left:-.5,top:-.5,center:0,bottom:.5,right:.5},e1=t=>"string"==typeof t?e0[t]:t-.5,e2="not-allowed";function e5(t){return e1(t.originX)===e1(tw)&&e1(t.originY)===e1(tw)}let e4=(t,e)=>t[e],e3=(t,e,r,i)=>({e:t,transform:e,pointer:new tJ(r,i)});function e9(t,e){return Math.round((t.getTotalAngle()+er(Math.atan2(e.y,e.x))+360)%360/45)}function e6(t,e,r,i,n){var s;let{target:o,corner:a}=t,l=o.controls[a],h=(null==(s=o.canvas)?void 0:s.getZoom())||1,c=o.padding/h,u=function(t,e,r,i){let n=t.getRelativeCenterPoint(),s=void 0!==r&&void 0!==i?t.translateToGivenOrigin(n,tw,tw,r,i):new tJ(t.left,t.top);return(t.angle?e.rotate(-ee(t.angle),n):e).subtract(s)}(o,new tJ(i,n),e,r);return u.x>=c&&(u.x-=c),u.x<=-c&&(u.x+=c),u.y>=c&&(u.y-=c),u.y<=c&&(u.y+=c),u.x-=l.offsetX,u.y-=l.offsetY,u}let e8=(t,e,r,i)=>{let{target:n,offsetX:s,offsetY:o}=e,a=r-s,l=i-o,h=!e4(n,"lockMovementX")&&n.left!==a,c=!e4(n,"lockMovementY")&&n.top!==l;return h&&n.set(tC,a),c&&n.set("top",l),(h||c)&&e$(tM,e3(t,e,r,i)),h||c},e7={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"},rt=(t,e,r)=>(r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t),re=(t,e,r,i)=>{let n,s;t/=255;let o=Math.max(t,e/=255,r/=255),a=Math.min(t,e,r),l=(o+a)/2;if(o===a)n=s=0;else{let i=o-a;switch(s=l>.5?i/(2-o-a):i/(o+a),o){case t:n=(e-r)/i+6*(e<r);break;case e:n=(r-t)/i+2;break;case r:n=(t-e)/i+4}n/=6}return[Math.round(360*n),Math.round(100*s),Math.round(100*l),i]},rr=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1";return parseFloat(t)/(t.endsWith("%")?100:1)},ri=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),rn=t=>{let[e,r,i,n=1]=t,s=Math.round(.3*e+.59*r+.11*i);return[s,s,s,n]};class rs{_tryParsingColor(t){return(t=t.toLowerCase())in e7&&(t=e7[t]),"transparent"===t?[255,255,255,0]:rs.sourceFromHex(t)||rs.sourceFromRgb(t)||rs.sourceFromHsl(t)||(this.isUnrecognised=!0,[0,0,0,1])}getSource(){return this._source}setSource(t){this._source=t}toRgb(){let[t,e,r]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(r,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){let[t,e,r]=re(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(r,"%)")}toHsla(){let[t,e,r,i]=re(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(r,"%,").concat(i,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){let[t,e,r,i]=this.getSource();return"".concat(ri(t)).concat(ri(e)).concat(ri(r)).concat(ri(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(rn(this.getSource())),this}toBlackWhite(t){let[e,,,r]=rn(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,r]),this}overlayWith(t){t instanceof rs||(t=new rs(t));let e=this.getSource(),r=t.getSource(),[i,n,s]=e.map((t,e)=>Math.round(.5*t+.5*r[e]));return this.setSource([i,n,s,e[3]]),this}static fromRgb(t){return rs.fromRgba(t)}static fromRgba(t){return new rs(rs.sourceFromRgb(t))}static sourceFromRgb(t){let e=t.match(/^rgba?\(\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d{0,3}(?:\.\d+)?%?)\s*)?\)$/i);if(e){let[t,r,i]=e.slice(1,4).map(t=>{let e=parseFloat(t);return t.endsWith("%")?Math.round(2.55*e):e});return[t,r,i,rr(e[4])]}}static fromHsl(t){return rs.fromHsla(t)}static fromHsla(t){return new rs(rs.sourceFromHsl(t))}static sourceFromHsl(t){let e,r,i,n=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(!n)return;let s=(rs.parseAngletoDegrees(n[1])%360+360)%360/360,o=parseFloat(n[2])/100,a=parseFloat(n[3])/100;if(0===o)e=r=i=a;else{let t=a<=.5?a*(o+1):a+o-a*o,n=2*a-t;e=rt(n,t,s+1/3),r=rt(n,t,s),i=rt(n,t,s-1/3)}return[Math.round(255*e),Math.round(255*r),Math.round(255*i),rr(n[4])]}static fromHex(t){return new rs(rs.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){let e=t.slice(t.indexOf("#")+1),[r,i,n,s=255]=(e.length<=4?e.split("").map(t=>t+t):e.match(/.{2}/g)).map(t=>parseInt(t,16));return[r,i,n,s/255]}}static parseAngletoDegrees(t){let e=t.toLowerCase(),r=parseFloat(e);return e.includes("rad")?er(r):e.includes("turn")?360*r:r}constructor(t){if(Z(this,"isUnrecognised",!1),t)if(t instanceof rs)this.setSource([...t._source]);else if(Array.isArray(t)){let[e,r,i,n=1]=t;this.setSource([e,r,i,n])}else this.setSource(this._tryParsingColor(t));else this.setSource([0,0,0,1])}}let ro=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,r=/\D{0,2}$/.exec(t),i=parseFloat(t),n=tn.DPI;switch(null==r?void 0:r[0]){case"mm":return i*n/25.4;case"cm":return i*n/2.54;case"in":return i*n;case"pt":return i*n/72;case"pc":return i*n/72*12;case"em":return i*e;default:return i}},ra=t=>{let[e,r]=t.trim().split(" "),[i,n]=e&&e!==tO?[e.slice(1,4),e.slice(5,8)]:e===tO?[e,e]:["Mid","Mid"];return{meetOrSlice:r||"meet",alignX:i,alignY:n}},rl=function(t,e){let r,i,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e)if(e.toLive)r="url(#SVGID_".concat(e.id,")");else{let t=new rs(e),n=t.getAlpha();r=t.toRgb(),1!==n&&(i=n.toString())}else r="none";return n?"".concat(t,": ").concat(r,"; ").concat(i?"".concat(t,"-opacity: ").concat(i,"; "):""):"".concat(t,'="').concat(r,'" ').concat(i?"".concat(t,'-opacity="').concat(i,'" '):"")};class rh{getSvgStyles(t){let e=this.fillRule?this.fillRule:"nonzero",r=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):tO,n=this.strokeDashOffset?this.strokeDashOffset:"0",s=this.strokeLineCap?this.strokeLineCap:"butt",o=this.strokeLineJoin?this.strokeLineJoin:"miter",a=this.strokeMiterLimit?this.strokeMiterLimit:"4",l=void 0!==this.opacity?this.opacity:"1",h=this.visible?"":" visibility: hidden;",c=t?"":this.getSvgFilter(),u=rl(tU,this.fill);return rl(tH,this.stroke)+"stroke-width: "+r+"; stroke-dasharray: "+i+"; stroke-linecap: "+s+"; stroke-dashoffset: "+n+"; stroke-linejoin: "+o+"; stroke-miterlimit: "+a+"; "+u+"fill-rule: "+e+"; opacity: "+l+";"+c+h}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&&void 0!==arguments[1]?arguments[1]:"",r=t?this.calcTransformMatrix():this.calcOwnMatrix(),i='transform="'.concat(eS(r));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:r=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=[this.getSvgTransform(!0,r),this.getSvgCommons()].join(""),n=t.indexOf("COMMON_PARTS");return t[n]=i,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let e,{noStyle:r,reviver:i,withShadow:n,additionalTransform:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r?"":'style="'.concat(this.getSvgStyles(),'" '),a=n?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,h=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",c=l&&l.absolutePositioned,u=this.stroke,d=this.fill,f=this.shadow,g=[],p=t.indexOf("COMMON_PARTS");l&&(l.clipPathId="CLIPPATH_".concat(t3()),e='<clipPath id="'.concat(l.clipPathId,'" >\n').concat(l.toClipPathSVG(i),"</clipPath>\n")),c&&g.push("<g ",a,this.getSvgCommons()," >\n"),g.push("<g ",this.getSvgTransform(!1),c?"":a+this.getSvgCommons()," >\n");let m=""+o+h+(r?"":this.addPaintOrder())+" "+(s?'transform="'.concat(s,'" '):"");return t[p]=m,eT(d)&&g.push(d.toSVG(this)),eT(u)&&g.push(u.toSVG(this)),f&&g.push(f.toSVG(this)),l&&g.push(e),g.push(t.join("")),g.push("</g>\n"),c&&g.push("</g>\n"),i?i(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==tU?' paint-order="'.concat(this.paintFirst,'" '):""}}function rc(t){return RegExp("^("+t.join("|")+")\\b","i")}let ru="textDecorationThickness",rd=["fontSize","fontWeight","fontFamily","fontStyle"],rf=["underline","overline","linethrough"],rg=[...rd,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],rp=[...rg,...rf,"textBackgroundColor","direction",ru],rm=[...rd,...rf,tH,"strokeWidth",tU,"deltaY","textBackgroundColor",ru],rv="justify",ry="justify-left",rx="justify-right",rb="justify-center",r_=String.raw(s||(s=tr(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),rw=String.raw(o||(o=tr(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),rC=RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+r_+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+r_+"))?\\s+(.*)"),rS={cx:tC,x:tC,r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","letter-spacing":"charSpacing","paint-order":"paintFirst","stroke-dasharray":"strokeDashArray","stroke-dashoffset":"strokeDashOffset","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"textAnchor",opacity:"opacity","clip-path":"clipPath","clip-rule":"clipRule","vector-effect":"strokeUniform","image-rendering":"imageSmoothing","text-decoration-thickness":ru},rT="font-size",rO="clip-path",rk=(rc(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),rc(["symbol","image","marker","pattern","view","svg"]),rc(["symbol","g","a","svg","clipPath","defs"])),rM=(new RegExp(String.raw(a||(a=tr(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),r_,rw,r_,rw,r_,rw,r_)),new tJ(1,0)),rE=new tJ,rD=(t,e)=>t.rotate(e),rj=(t,e)=>new tJ(e).subtract(t),rA=t=>t.distanceFrom(rE),rP=(t,e)=>Math.atan2(rI(t,e),rB(t,e)),rF=t=>rP(rM,t),rL=t=>t.eq(rE)?t:t.scalarDivide(rA(t)),rR=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return rL(new tJ(-t.y,t.x).scalarMultiply(e?1:-1))},rI=(t,e)=>t.x*e.y-t.y*e.x,rB=(t,e)=>t.x*e.x+t.y*e.y,rN=(t,e,r)=>{if(t.eq(e)||t.eq(r))return!0;let i=rI(e,r),n=rI(e,t),s=rI(r,t);return i>=0?n>=0&&s<=0:!(n<=0&&s>=0)},rW="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",rU=RegExp("(?:\\s|^)"+rW+rW+"("+r_+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class rH{static parseShadow(t){let e=t.trim(),[,r=0,i=0,n=0]=(rU.exec(e)||[]).map(t=>parseFloat(t)||0);return{color:(e.replace(rU,"")||"rgb(0,0,0)").trim(),offsetX:r,offsetY:i,blur:n}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){let e=rD(new tJ(this.offsetX,this.offsetY),ee(-t.angle)),r=new rs(this.color),i=40,n=40;return t.width&&t.height&&(i=100*eC((Math.abs(e.x)+this.blur)/t.width,tn.NUM_FRACTION_DIGITS)+20,n=100*eC((Math.abs(e.y)+this.blur)/t.height,tn.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(n,'%" height="').concat(100+2*n,'%" x="-').concat(i,'%" width="').concat(100+2*i,'%" >\n <feGaussianBlur in="SourceAlpha" stdDeviation="').concat(eC(this.blur?this.blur/2:0,tn.NUM_FRACTION_DIGITS),'"></feGaussianBlur>\n <feOffset dx="').concat(eC(e.x,tn.NUM_FRACTION_DIGITS),'" dy="').concat(eC(e.y,tn.NUM_FRACTION_DIGITS),'" result="oBlur" ></feOffset>\n <feFlood flood-color="').concat(r.toRgb(),'" flood-opacity="').concat(r.getAlpha(),'"/>\n <feComposite in2="oBlur" operator="in" />\n <feMerge>\n <feMergeNode></feMergeNode>\n <feMergeNode in="SourceGraphic"></feMergeNode>\n </feMerge>\n</filter>\n')}toObject(){let t={color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke,nonScaling:this.nonScaling,type:this.constructor.type},e=rH.ownDefaults;return this.includeDefaultValues?t:ew(t,(t,r)=>t!==e[r])}static async fromObject(t){return new this(t)}constructor(t){let e="string"==typeof t?rH.parseShadow(t):t;Object.assign(this,rH.ownDefaults,e),this.id=t3()}}Z(rH,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),Z(rH,"type","shadow"),tY.setClass(rH,"shadow");let rX=(t,e,r)=>Math.max(t,Math.min(e,r)),rV=["top",tC,tI,tB,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",tN,tW],rY=[tU,tH,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],rz=(t,e,r,i)=>(t<Math.abs(e)?(t=e,i=r/4):i=0===e&&0===t?r/tx*Math.asin(1):r/tx*Math.asin(e/t),{a:t,c:e,p:r,s:i}),rG=(t,e,r,i,n)=>t*Math.pow(2,10*(i-=1))*Math.sin((i*n-e)*tx/r),rq=(t,e,r,i)=>-r*Math.cos(t/i*ty)+r+e,rK=(t,e,r,i)=>(t/=i)<1/2.75?7.5625*t*t*r+e:t<2/2.75?r*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?r*(7.5625*(t-=2.25/2.75)*t+.9375)+e:r*(7.5625*(t-=2.625/2.75)*t+.984375)+e,rQ=(t,e,r,i)=>r-rK(i-t,0,r,i)+e;var rJ=Object.freeze({__proto__:null,defaultEasing:rq,easeInBack:function(t,e,r,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return r*(t/=i)*t*((n+1)*t-n)+e},easeInBounce:rQ,easeInCirc:(t,e,r,i)=>-r*(Math.sqrt(1-(t/=i)*t)-1)+e,easeInCubic:(t,e,r,i)=>r*(t/i)**3+e,easeInElastic:(t,e,r,i)=>{let n=0;if(0===t)return e;if(1==(t/=i))return e+r;n||(n=.3*i);let{a:s,s:o,p:a}=rz(r,r,n,1.70158);return-rG(s,o,a,t,i)+e},easeInExpo:(t,e,r,i)=>0===t?e:r*2**(10*(t/i-1))+e,easeInOutBack:function(t,e,r,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return(t/=i/2)<1?r/2*(t*t*((1+(n*=1.525))*t-n))+e:r/2*((t-=2)*t*((1+(n*=1.525))*t+n)+2)+e},easeInOutBounce:(t,e,r,i)=>t<i/2?.5*rQ(2*t,0,r,i)+e:.5*rK(2*t-i,0,r,i)+.5*r+e,easeInOutCirc:(t,e,r,i)=>(t/=i/2)<1?-r/2*(Math.sqrt(1-t**2)-1)+e:r/2*(Math.sqrt(1-(t-=2)*t)+1)+e,easeInOutCubic:(t,e,r,i)=>(t/=i/2)<1?r/2*t**3+e:r/2*((t-2)**3+2)+e,easeInOutElastic:(t,e,r,i)=>{let n=0;if(0===t)return e;if(2==(t/=i/2))return e+r;n||(n=.3*1.5*i);let{a:s,s:o,p:a,c:l}=rz(r,r,n,1.70158);return t<1?-.5*rG(s,o,a,t,i)+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*i-o)*tx/a)*.5+l+e},easeInOutExpo:(t,e,r,i)=>0===t?e:t===i?e+r:(t/=i/2)<1?r/2*2**(10*(t-1))+e:-(r/2*(2**(-10*--t)+2))+e,easeInOutQuad:(t,e,r,i)=>(t/=i/2)<1?r/2*t**2+e:-r/2*(--t*(t-2)-1)+e,easeInOutQuart:(t,e,r,i)=>(t/=i/2)<1?r/2*t**4+e:-r/2*((t-=2)*t**3-2)+e,easeInOutQuint:(t,e,r,i)=>(t/=i/2)<1?r/2*t**5+e:r/2*((t-2)**5+2)+e,easeInOutSine:(t,e,r,i)=>-r/2*(Math.cos(Math.PI*t/i)-1)+e,easeInQuad:(t,e,r,i)=>r*(t/=i)*t+e,easeInQuart:(t,e,r,i)=>r*(t/=i)*t**3+e,easeInQuint:(t,e,r,i)=>r*(t/i)**5+e,easeInSine:(t,e,r,i)=>-r*Math.cos(t/i*ty)+r+e,easeOutBack:function(t,e,r,i){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return r*((t=t/i-1)*t*((n+1)*t+n)+1)+e},easeOutBounce:rK,easeOutCirc:(t,e,r,i)=>r*Math.sqrt(1-(t=t/i-1)*t)+e,easeOutCubic:(t,e,r,i)=>r*((t/i-1)**3+1)+e,easeOutElastic:(t,e,r,i)=>{let n=0;if(0===t)return e;if(1==(t/=i))return e+r;n||(n=.3*i);let{a:s,s:o,p:a,c:l}=rz(r,r,n,1.70158);return s*2**(-10*t)*Math.sin((t*i-o)*tx/a)+l+e},easeOutExpo:(t,e,r,i)=>t===i?e+r:-(r*(2**(-10*t/i)+1))+e,easeOutQuad:(t,e,r,i)=>-r*(t/=i)*(t-2)+e,easeOutQuart:(t,e,r,i)=>-r*((t=t/i-1)*t**3-1)+e,easeOutQuint:(t,e,r,i)=>r*((t/i-1)**5+1)+e,easeOutSine:(t,e,r,i)=>r*Math.sin(t/i*ty)+e});let rZ=()=>!1;class r${get state(){return this._state}isDone(){return"aborted"===this._state||"completed"===this._state}start(){let t=t=>{"pending"===this._state&&(this.startTime=t||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>t2(t),this.delay):t2(t)}tick(t){let e=(t||+new Date)-this.startTime,r=Math.min(e,this.duration);this.durationProgress=r/this.duration;let{value:i,valueProgress:n}=this.calculate(r);this.value=Object.freeze(i),this.valueProgress=n,"aborted"!==this._state&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),t2(this.tick)))}register(){tz.push(this)}unregister(){tz.remove(this)}abort(){this._state="aborted",this.unregister()}constructor(t){let{startValue:e,byValue:r,duration:i=500,delay:n=0,easing:s=rq,onStart:o=tv,onChange:a=tv,onComplete:l=tv,abort:h=rZ,target:c}=t;Z(this,"_state","pending"),Z(this,"durationProgress",0),Z(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=i,this.delay=n,this.easing=s,this._onStart=o,this._onChange=a,this._onComplete=l,this._abort=h,this.target=c,this.startValue=e,this.byValue=r,this.value=this.startValue,this.endValue=Object.freeze(this.calculate(this.duration).value)}}let r0=["startValue","endValue"];class r1 extends r${calculate(t){let e=this.easing(t,this.startValue,this.byValue,this.duration);return{value:e,valueProgress:Math.abs((e-this.startValue)/this.byValue)}}constructor(t){let{startValue:e=0,endValue:r=100}=t;super(tt(tt({},te(t,r0)),{},{startValue:e,byValue:r-e}))}}let r2=["startValue","endValue"];class r5 extends r${calculate(t){let e=this.startValue.map((e,r)=>this.easing(t,e,this.byValue[r],this.duration,r));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}constructor(t){let{startValue:e=[0],endValue:r=[100]}=t;super(tt(tt({},te(t,r2)),{},{startValue:e,byValue:r.map((t,r)=>t-e[r])}))}}let r4=["startValue","endValue","easing","onChange","onComplete","abort"],r3=(t,e,r,i)=>e+r*(1-Math.cos(t/i*ty)),r9=t=>t&&((e,r,i)=>t(new rs(e).toRgba(),r,i));class r6 extends r${calculate(t){let[e,r,i,n]=this.startValue.map((e,r)=>this.easing(t,e,this.byValue[r],this.duration,r)),s=[...[e,r,i].map(Math.round),rX(0,n,1)];return{value:s,valueProgress:s.map((t,e)=>0!==this.byValue[e]?Math.abs((t-this.startValue[e])/this.byValue[e]):0).find(t=>0!==t)||0}}constructor(t){let{startValue:e,endValue:r,easing:i=r3,onChange:n,onComplete:s,abort:o}=t,a=te(t,r4),l=new rs(e).getSource();super(tt(tt({},a),{},{startValue:l,byValue:new rs(r).getSource().map((t,e)=>t-l[e]),easing:i,onChange:r9(n),onComplete:r9(s),abort:r9(o)}))}}function r8(t){let e=Array.isArray(t.startValue)||Array.isArray(t.endValue)?new r5(t):new r1(t);return e.start(),e}function r7(t){let e=new r6(t);return e.start(),e}class it{includes(t){return this.points.some(e=>e.eq(t))}append(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];return this.points=this.points.concat(e.filter(t=>!this.includes(t))),this}static isPointContained(t,e,r){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(e.eq(r))return t.eq(e);if(e.x===r.x)return t.x===e.x&&(i||t.y>=Math.min(e.y,r.y)&&t.y<=Math.max(e.y,r.y));if(e.y===r.y)return t.y===e.y&&(i||t.x>=Math.min(e.x,r.x)&&t.x<=Math.max(e.x,r.x));{let n=rj(e,r),s=rj(e,t).divide(n);return i?Math.abs(s.x)===Math.abs(s.y):s.x===s.y&&s.x>=0&&s.x<=1}}static isPointInPolygon(t,e){let r=new tJ(t).setX(Math.min(t.x-1,...e.map(t=>t.x))),i=0;for(let n=0;n<e.length;n++){let s=this.intersectSegmentSegment(e[n],e[(n+1)%e.length],t,r);if(s.includes(t))return!0;i+=Number("Intersection"===s.status)}return i%2==1}static intersectLineLine(t,e,r,i){let n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],s=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],o=e.x-t.x,a=e.y-t.y,l=i.x-r.x,h=i.y-r.y,c=t.x-r.x,u=t.y-r.y,d=l*u-h*c,f=o*u-a*c,g=h*o-l*a;if(0!==g){let e=d/g,r=f/g;return(n||0<=e&&e<=1)&&(s||0<=r&&r<=1)?new it("Intersection").append(new tJ(t.x+e*o,t.y+e*a)):new it}if(0===d||0===f){let o=n||s||it.isPointContained(t,r,i)||it.isPointContained(e,r,i)||it.isPointContained(r,t,e)||it.isPointContained(i,t,e);return new it(o?"Coincident":void 0)}return new it("Parallel")}static intersectSegmentLine(t,e,r,i){return it.intersectLineLine(t,e,r,i,!1,!0)}static intersectSegmentSegment(t,e,r,i){return it.intersectLineLine(t,e,r,i,!1,!1)}static intersectLinePolygon(t,e,r){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],n=new it,s=r.length;for(let o,a,l,h=0;h<s;h++){if(o=r[h],a=r[(h+1)%s],"Coincident"===(l=it.intersectLineLine(t,e,o,a,i,!1)).status)return l;n.append(...l.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(t,e,r){return it.intersectLinePolygon(t,e,r,!1)}static intersectPolygonPolygon(t,e){let r=new it,i=t.length,n=[];for(let s=0;s<i;s++){let o=t[s],a=t[(s+1)%i],l=it.intersectSegmentPolygon(o,a,e);"Coincident"===l.status?(n.push(l),r.append(o,a)):r.append(...l.points)}return n.length>0&&n.length===t.length?new it("Coincident"):(r.points.length>0&&(r.status="Intersection"),r)}static intersectPolygonRectangle(t,e,r){let i=e.min(r),n=e.max(r),s=new tJ(n.x,i.y),o=new tJ(i.x,n.y);return it.intersectPolygonPolygon(t,[i,s,n,o])}constructor(t){this.status=t,this.points=[]}}class ie extends t1{getX(){return this.getXY().x}setX(t){this.setXY(this.getXY().setX(t))}getY(){return this.getXY().y}setY(t){this.setXY(this.getXY().setY(t))}getRelativeX(){return this.left}setRelativeX(t){this.left=t}getRelativeY(){return this.top}setRelativeY(t){this.top=t}getXY(){let t=this.getRelativeXY();return this.group?en(t,this.group.calcTransformMatrix()):t}setXY(t,e,r){this.group&&(t=en(t,es(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,r)}getRelativeXY(){return new tJ(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.originX,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.originY;this.setPositionByOrigin(t,e,r)}isStrokeAccountedForInDimensions(){return!1}getCoords(){let{tl:t,tr:e,br:r,bl:i}=this.aCoords||(this.aCoords=this.calcACoords()),n=[t,e,r,i];if(this.group){let t=this.group.calcTransformMatrix();return n.map(e=>en(e,t))}return n}intersectsWithRect(t,e){return"Intersection"===it.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){let e=it.intersectPolygonPolygon(this.getCoords(),t.getCoords());return"Intersection"===e.status||"Coincident"===e.status||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){let{left:r,top:i,width:n,height:s}=this.getBoundingRect();return r>=t.x&&r+n<=e.x&&i>=t.y&&i+s<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return it.isPointInPolygon(t,this.getCoords())}isOnScreen(){if(!this.canvas)return!1;let{tl:t,br:e}=this.canvas.vptCoords;return!!this.getCoords().some(r=>r.x<=e.x&&r.x>=t.x&&r.y<=e.y&&r.y>=t.y)||!!this.intersectsWithRect(t,e)||this.containsPoint(t.midPointFrom(e))}isPartiallyOnScreen(){if(!this.canvas)return!1;let{tl:t,br:e}=this.canvas.vptCoords;return!!this.intersectsWithRect(t,e)||this.getCoords().every(r=>(r.x>=e.x||r.x<=t.x)&&(r.y>=e.y||r.y<=t.y))&&this.containsPoint(t.midPointFrom(e))}getBoundingRect(){return eH(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(tI,t),this._set(tB,t),this.setCoords()}scaleToWidth(t){let e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){let e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return(null==(t=this.canvas)?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?er(el(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null==(t=this.canvas)?void 0:t.viewportTransform)||t_.concat()}calcACoords(){let t=eu({angle:this.angle}),{x:e,y:r}=this.getRelativeCenterPoint(),i=eo(ec(e,r),t),n=this._getTransformedDimensions(),s=n.x/2,o=n.y/2;return{tl:en({x:-s,y:-o},i),tr:en({x:s,y:-o},i),bl:en({x:-s,y:o},i),br:en({x:s,y:o},i)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&void 0!==arguments[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,e1(this.originX),e1(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;let r=this.transformMatrixKey(t),i=this.matrixCache;return i&&i.key.every((t,e)=>t===r[e])?i.value:(this.group&&(e=eo(this.group.calcTransformMatrix(!1),e)),this.matrixCache={key:r,value:e},e)}calcOwnMatrix(){let t=this.transformMatrixKey(!0),e=this.ownMatrixCache;if(e&&e.key===t)return e.value;let r=this.getRelativeCenterPoint(),i=ev({angle:this.angle,translateX:r.x,translateY:r.y,scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,flipX:this.flipX,flipY:this.flipY});return this.ownMatrixCache={key:t,value:i},i}_getNonTransformedDimensions(){return new tJ(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&&void 0!==arguments[0]?arguments[0]:{},e=tt({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),r=e.strokeWidth,i=r,n=0;this.strokeUniform&&(i=0,n=r);let s=e.width+i,o=e.height+i;return(0===e.skewX&&0===e.skewY?new tJ(s*e.scaleX,o*e.scaleY):eq(s,o,em(e))).scalarAdd(n)}translateToGivenOrigin(t,e,r,i,n){let s=t.x,o=t.y,a=e1(i)-e1(e),l=e1(n)-e1(r);if(a||l){let t=this._getTransformedDimensions();s+=a*t.x,o+=l*t.y}return new tJ(s,o)}translateToCenterPoint(t,e,r){if(e===tw&&r===tw)return t;let i=this.translateToGivenOrigin(t,e,r,tw,tw);return this.angle?i.rotate(ee(this.angle),t):i}translateToOriginPoint(t,e,r){let i=this.translateToGivenOrigin(t,tw,tw,e,r);return this.angle?i.rotate(ee(this.angle),t):i}getCenterPoint(){let t=this.getRelativeCenterPoint();return this.group?en(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new tJ(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,r){let i=this.translateToCenterPoint(t,e,r),n=this.translateToOriginPoint(i,this.originX,this.originY);this.set({left:n.x,top:n.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),tC,"top")}}let ir=["type"],ii=["extraParam"],is=class t extends ie{static getDefaults(){return t.ownDefaults}get type(){let t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){ts("warn","Setting type has no effect",t)}_createCacheCanvas(){this._cacheCanvas=t9(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){let e=t.width,r=t.height,i=tn.maxCacheSideLimit,n=tn.minCacheSideLimit;if(e<=i&&r<=i&&e*r<=tn.perfLimitSizeTotal)return e<n&&(t.width=n),r<n&&(t.height=n),t;let[s,o]=tp.limitDimsByArea(e/r),a=rX(n,s,i),l=rX(n,o,i);return e>a&&(t.zoomX/=e/a,t.width=a,t.capped=!0),r>l&&(t.zoomY/=r/l,t.height=l,t.capped=!0),t}_getCacheCanvasDimensions(){let t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),r=e.x*t.x/this.scaleX,i=e.y*t.y/this.scaleY;return{width:Math.ceil(r+2),height:Math.ceil(i+2),zoomX:t.x,zoomY:t.y,x:r,y:i}}_updateCacheCanvas(){let t=this._cacheCanvas,e=this._cacheContext,{width:r,height:i,zoomX:n,zoomY:s,x:o,y:a}=this._limitCacheSize(this._getCacheCanvasDimensions()),l=r!==t.width||i!==t.height,h=this.zoomX!==n||this.zoomY!==s;if(!t||!e)return!1;if(l||h){r!==t.width||i!==t.height?(t.width=r,t.height=i):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));let l=o/2,h=a/2;return this.cacheTranslationX=Math.round(t.width/2-l)+l,this.cacheTranslationY=Math.round(t.height/2-h)+h,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(n,s),this.zoomX=n,this.zoomY=s,!0}return!1}setOptions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this._setOptions(t)}transform(t){let e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,r=this.calcTransformMatrix(!e);t.transform(r[0],r[1],r[2],r[3],r[4],r[5])}getObjectScaling(){if(!this.group)return new tJ(Math.abs(this.scaleX),Math.abs(this.scaleY));let t=eh(this.calcTransformMatrix());return new tJ(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){let t=this.getObjectScaling();if(this.canvas){let e=this.canvas.getZoom(),r=this.getCanvasRetinaScaling();return t.scalarMultiply(e*r)}return t}getObjectOpacity(){let t=this.opacity;return this.group&&(t*=this.group.getObjectOpacity()),t}_constrainScale(t){return Math.abs(t)<this.minScaleLimit?t<0?-this.minScaleLimit:this.minScaleLimit:0===t?1e-4:t}_set(t,e){t!==tI&&t!==tB||(e=this._constrainScale(e)),t===tI&&e<0?(this.flipX=!this.flipX,e*=-1):"scaleY"===t&&e<0?(this.flipY=!this.flipY,e*=-1):"shadow"!==t||!e||e instanceof rH||(e=new rH(e));let r=this[t]!==e;return this[t]=e,r&&this.constructor.cacheProperties.includes(t)&&(this.dirty=!0),this.parent&&(this.dirty||r&&this.constructor.stateProperties.includes(t))&&this.parent._set("dirty",!0),this}isNotVisible(){return 0===this.opacity||!this.width&&!this.height&&0===this.strokeWidth||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.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){let{zoomX:e,zoomY:r,cacheTranslationX:i,cacheTranslationY:n}=this,{width:s,height:o}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:r,cacheTranslationX:i,cacheTranslationY:n,width:s,height:o,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&"transparent"!==this.stroke&&0!==this.strokeWidth}hasFill(){return this.fill&&"transparent"!==this.fill}needsItsOwnCache(){return!!(this.paintFirst===tH&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(0!==this.shadow.offsetX||0!==this.shadow.offsetY)}drawClipPathOnCache(t,e,r){t.save(),e.inverted?t.globalCompositeOperation="destination-out":t.globalCompositeOperation="destination-in",t.setTransform(1,0,0,1,0,0),t.drawImage(r,0,0),t.restore()}drawObject(t,e,r){let i=this.fill,n=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,r),this.fill=i,this.stroke=n}createClipPathLayer(t,e){let r=t8(e),i=r.getContext("2d");if(i.translate(e.cacheTranslationX,e.cacheTranslationY),i.scale(e.zoomX,e.zoomY),t._cacheCanvas=r,e.parentClipPaths.forEach(t=>{t.transform(i)}),e.parentClipPaths.push(t),t.absolutePositioned){let t=es(this.calcTransformMatrix());i.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return t.transform(i),t.drawObject(i,!0,e),r}_drawClipPath(t,e,r){if(!e)return;e._transformDone=!0;let i=this.createClipPathLayer(e,r);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&&void 0!==arguments[0]&&arguments[0];if(this.isNotVisible())return!1;let e=this._cacheCanvas,r=this._cacheContext;return!(!e||!r||t||!this._updateCacheCanvas())||!!(this.dirty||this.clipPath&&this.clipPath.absolutePositioned)&&(e&&r&&!t&&(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e.width,e.height),r.restore()),!0)}_renderBackground(t){if(!this.backgroundColor)return;let e=this._getNonTransformedDimensions();t.fillStyle=this.backgroundColor,t.fillRect(-e.x/2,-e.y/2,e.x,e.y),this._removeShadow(t)}_setOpacity(t){this.group&&!this.group._transformDone?t.globalAlpha=this.getObjectOpacity():t.globalAlpha*=this.opacity}_setStrokeStyles(t,e){let r=e.stroke;r&&(t.lineWidth=e.strokeWidth,t.lineCap=e.strokeLineCap,t.lineDashOffset=e.strokeDashOffset,t.lineJoin=e.strokeLineJoin,t.miterLimit=e.strokeMiterLimit,eT(r)?"percentage"===r.gradientUnits||r.gradientTransform||r.patternTransform?this._applyPatternForTransformedGradient(t,r):(t.strokeStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.strokeStyle=e.stroke)}_setFillStyles(t,e){let{fill:r}=e;r&&(eT(r)?(t.fillStyle=r.toLive(t),this._applyPatternGradientTransform(t,r)):t.fillStyle=r)}_setClippingProperties(t){t.globalAlpha=1,t.strokeStyle="transparent",t.fillStyle="#000000"}_setLineDash(t,e){e&&0!==e.length&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;let e=this.shadow,r=this.canvas,i=this.getCanvasRetinaScaling(),[n,,,s]=(null==r?void 0:r.viewportTransform)||t_,o=n*i,a=s*i,l=e.nonScaling?new tJ(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*tn.browserShadowBlurConstant*(o+a)*(l.x+l.y)/4,t.shadowOffsetX=e.offsetX*o*l.x,t.shadowOffsetY=e.offsetY*a*l.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!eT(e))return{offsetX:0,offsetY:0};let r=e.gradientTransform||e.patternTransform,i=-this.width/2+e.offsetX||0,n=-this.height/2+e.offsetY||0;return"percentage"===e.gradientUnits?t.transform(this.width,0,0,this.height,i,n):t.transform(1,0,0,1,i,n),r&&t.transform(r[0],r[1],r[2],r[3],r[4],r[5]),{offsetX:i,offsetY:n}}_renderPaintInOrder(t){this.paintFirst===tH?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),"evenodd"===this.fillRule?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&0!==this.strokeWidth){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){let e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var r;let i=this._limitCacheSize(this._getCacheCanvasDimensions()),n=this.getCanvasRetinaScaling(),s=i.x/this.scaleX/n,o=i.y/this.scaleY/n,a=t8({width:Math.ceil(s),height:Math.ceil(o)}),l=a.getContext("2d");l&&(l.beginPath(),l.moveTo(0,0),l.lineTo(s,0),l.lineTo(s,o),l.lineTo(0,o),l.closePath(),l.translate(s/2,o/2),l.scale(i.zoomX/this.scaleX/n,i.zoomY/this.scaleY/n),this._applyPatternGradientTransform(l,e),l.fillStyle=e.toLive(t),l.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(n*this.scaleX/i.zoomX,n*this.scaleY/i.zoomY),t.strokeStyle=null!=(r=l.createPattern(a,"no-repeat"))?r:"")}_findCenterFromElement(){return new tJ(this.left+this.width/2,this.top+this.height/2)}clone(t){let e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){let e=this.toCanvasElement(t);return new(tY.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=eG(this),r=this.group,i=this.shadow,n=Math.abs,s=t.enableRetinaScaling?tg():1,o=(t.multiplier||1)*s,a=t.canvasProvider||(t=>new eI(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&ez(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&eZ(this,this.getViewportTransform()),this.setCoords();let l=t9(),h=this.getBoundingRect(),c=this.shadow,u=new tJ;if(c){let t=c.blur,e=c.nonScaling?new tJ(1,1):this.getObjectScaling();u.x=2*Math.round(n(c.offsetX)+t)*n(e.x),u.y=2*Math.round(n(c.offsetY)+t)*n(e.y)}let d=h.width+u.x,f=h.height+u.y;l.width=Math.ceil(d),l.height=Math.ceil(f);let g=a(l);"jpeg"===t.format&&(g.backgroundColor="#fff"),this.setPositionByOrigin(new tJ(g.width/2,g.height/2),tw,tw);let p=this.canvas;g._objects=[this],this.set("canvas",g),this.setCoords();let m=g.toCanvasElement(o||1,t);return this.set("canvas",p),this.shadow=i,r&&(this.group=r),this.set(e),this.setCoords(),g._objects=[],g.destroy(),m}toDataURL(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t7(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return et(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.includes(this.constructor.type)||e.includes(this.type)}complexity(){return 1}toJSON(){return this.toObject()}rotate(t){let{centeredRotation:e,originX:r,originY:i}=this;if(e){let{x:t,y:e}=this.getRelativeCenterPoint();this.originX=tw,this.originY=tw,this.left=t,this.top=e}if(this.set("angle",t),e){let{x:t,y:e}=this.translateToOriginPoint(this.getRelativeCenterPoint(),r,i);this.left=t,this.top=e,this.originX=r,this.originY=i}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){tz.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&tu().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((t,r)=>{let[i,n]=r;return t[i]=this._animate(i,n,e),t},{})}_animate(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.split("."),n=this.constructor.colorProperties.includes(i[i.length-1]),{abort:s,startValue:o,onChange:a,onComplete:l}=r,h=tt(tt({},r),{},{target:this,startValue:null!=o?o:i.reduce((t,e)=>t[e],this),endValue:e,abort:null==s?void 0:s.bind(this),onChange:(t,e,r)=>{i.reduce((e,r,n)=>(n===i.length-1&&(e[r]=t),e[r]),this),a&&a(t,e,r)},onComplete:(t,e,r)=>{this.setCoords(),l&&l(t,e,r)}});return n?r7(h):r8(h)}isDescendantOf(t){let{parent:e,group:r}=this;return e===t||r===t||!!e&&e.isDescendantOf(t)||!!r&&r!==e&&r.isDescendantOf(t)}getAncestors(){let t=[],e=this;do(e=e.parent)&&t.push(e);while(e)return t}findCommonAncestors(t){if(this===t)return{fork:[],otherFork:[],common:[this,...this.getAncestors()]};let e=this.getAncestors(),r=t.getAncestors();if(0===e.length&&r.length>0&&this===r[r.length-1])return{fork:[],otherFork:[t,...r.slice(0,r.length-1)],common:[this]};for(let i,n=0;n<e.length;n++){if((i=e[n])===t)return{fork:[this,...e.slice(0,n)],otherFork:[],common:e.slice(n)};for(let s=0;s<r.length;s++){if(this===r[s])return{fork:[],otherFork:[t,...r.slice(0,s)],common:[this,...e]};if(i===r[s])return{fork:[this,...e.slice(0,n)],otherFork:[t,...r.slice(0,s)],common:e.slice(n)}}}return{fork:[this,...e],otherFork:[t,...r],common:[]}}hasCommonAncestors(t){let e=this.findCommonAncestors(t);return e&&!!e.common.length}isInFrontOf(t){if(this===t)return;let e=this.findCommonAncestors(t);if(e.fork.includes(t))return!0;if(e.otherFork.includes(this))return!1;let r=e.common[0]||this.canvas;if(!r)return;let i=e.fork.pop(),n=e.otherFork.pop(),s=r._objects.indexOf(i),o=r._objects.indexOf(n);return s>-1&&s>o}toObject(){let e,r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).concat(t.customProperties,this.constructor.customProperties||[]),i=tn.NUM_FRACTION_DIGITS,{clipPath:n,fill:s,stroke:o,shadow:a,strokeDashArray:l,left:h,top:c,originX:u,originY:d,width:f,height:g,strokeWidth:p,strokeLineCap:m,strokeDashOffset:y,strokeLineJoin:x,strokeUniform:b,strokeMiterLimit:_,scaleX:w,scaleY:C,angle:S,flipX:T,flipY:O,opacity:k,visible:M,backgroundColor:E,fillRule:D,paintFirst:j,globalCompositeOperation:A,skewX:P,skewY:F}=this;n&&!n.excludeFromExport&&(e=n.toObject(r.concat("inverted","absolutePositioned")));let L=t=>eC(t,i),R=tt(tt({},e_(this,r)),{},{type:this.constructor.type,version:tm,originX:u,originY:d,left:L(h),top:L(c),width:L(f),height:L(g),fill:eO(s)?s.toObject():s,stroke:eO(o)?o.toObject():o,strokeWidth:L(p),strokeDashArray:l?l.concat():l,strokeLineCap:m,strokeDashOffset:y,strokeLineJoin:x,strokeUniform:b,strokeMiterLimit:L(_),scaleX:L(w),scaleY:L(C),angle:L(S),flipX:T,flipY:O,opacity:L(k),shadow:a?a.toObject():a,visible:M,backgroundColor:E,fillRule:D,paintFirst:j,globalCompositeOperation:A,skewX:L(P),skewY:L(F)},e?{clipPath:e}:null);return this.includeDefaultValues?R:this._removeDefaultValues(R)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){let e=this.constructor.getDefaults(),r=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return ew(t,(t,e)=>{if(e===tC||"top"===e||"type"===e)return!0;let i=r[e];return t!==i&&!(Array.isArray(t)&&Array.isArray(i)&&0===t.length&&0===i.length)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=te(t,ir),r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{extraParam:i}=r;return eb(e,te(r,ii)).then(t=>i?(delete t[i],new this(e[i],t)):new this(t))}static fromObject(t,e){return this._fromObject(t,e)}constructor(e){super(),Z(this,"_cacheContext",null),Object.assign(this,t.ownDefaults),this.setOptions(e)}};Z(is,"stateProperties",rV),Z(is,"cacheProperties",rY),Z(is,"ownDefaults",{top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:tC,originY:"top",strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:tU,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}),Z(is,"type","FabricObject"),Z(is,"colorProperties",[tU,tH,"backgroundColor"]),Z(is,"customProperties",[]),tY.setClass(is),tY.setClass(is,"object");let io=(t,e,r)=>(i,n,s,o)=>{let a=e(i,n,s,o);return a&&e$(t,tt(tt({},e3(i,n,s,o)),r)),a};function ia(t){return(e,r,i,n)=>{let{target:s,originX:o,originY:a}=r,l=s.getRelativeCenterPoint(),h=s.translateToOriginPoint(l,o,a),c=t(e,r,i,n);return s.setPositionByOrigin(h,r.originX,r.originY),c}}let il=io(tP,ia((t,e,r,i)=>{let n=e6(e,e.originX,e.originY,r,i);if(e1(e.originX)===e1(tw)||e1(e.originX)===e1(tT)&&n.x<0||e1(e.originX)===e1(tC)&&n.x>0){let{target:t}=e,r=t.strokeWidth/(t.strokeUniform?t.scaleX:1),i=e5(e)?2:1,s=t.width,o=Math.abs(n.x*i/t.scaleX)-r;return t.set("width",Math.max(o,1)),s!==t.width}return!1}));function ih(t,e,r,i,n){i=i||{};let s=this.sizeX||i.cornerSize||n.cornerSize,o=this.sizeY||i.cornerSize||n.cornerSize,a=void 0!==i.transparentCorners?i.transparentCorners:n.transparentCorners,l=a?tH:tU,h=!a&&(i.cornerStrokeColor||n.cornerStrokeColor),c,u=e,d=r;t.save(),t.fillStyle=i.cornerColor||n.cornerColor||"",t.strokeStyle=i.cornerStrokeColor||n.cornerStrokeColor||"",s>o?(c=s,t.scale(1,o/s),d=r*s/o):o>s?(c=o,t.scale(s/o,1),u=e*o/s):c=s,t.beginPath(),t.arc(u,d,c/2,0,tx,!1),t[l](),h&&t.stroke(),t.restore()}function ic(t,e,r,i,n){i=i||{};let s=this.sizeX||i.cornerSize||n.cornerSize,o=this.sizeY||i.cornerSize||n.cornerSize,a=void 0!==i.transparentCorners?i.transparentCorners:n.transparentCorners,l=a?tH:tU,h=!a&&(i.cornerStrokeColor||n.cornerStrokeColor),c=s/2,u=o/2;t.save(),t.fillStyle=i.cornerColor||n.cornerColor||"",t.strokeStyle=i.cornerStrokeColor||n.cornerStrokeColor||"",t.translate(e,r);let d=n.getTotalAngle();t.rotate(ee(d)),t["".concat(l,"Rect")](-c,-u,s,o),h&&t.strokeRect(-c,-u,s,o),t.restore()}class iu{shouldActivate(t,e,r,i){var n;let{tl:s,tr:o,br:a,bl:l}=i;return(null==(n=e.canvas)?void 0:n.getActiveObject())===e&&e.isControlVisible(t)&&it.isPointInPolygon(r,[s,o,a,l])}getActionHandler(t,e,r){return this.actionHandler}getMouseDownHandler(t,e,r){return this.mouseDownHandler}getMouseUpHandler(t,e,r){return this.mouseUpHandler}cursorStyleHandler(t,e,r){return e.cursorStyle}getActionName(t,e,r){return e.actionName}getVisibility(t,e){var r,i;return null!=(r=null==(i=t._controlsVisibility)?void 0:i[e])?r:this.visible}setVisibility(t,e,r){this.visible=t}positionHandler(t,e,r,i){return new tJ(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,r,i,n,s){let o=ea([ec(r,i),eu({angle:t}),ed((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new tJ(-.5,-.5).transform(o),tr:new tJ(.5,-.5).transform(o),br:new tJ(.5,.5).transform(o),bl:new tJ(-.5,.5).transform(o)}}render(t,e,r,i,n){"circle"===((i=i||{}).cornerStyle||n.cornerStyle)?ih.call(this,t,e,r,i,n):ic.call(this,t,e,r,i,n)}constructor(t){Z(this,"visible",!0),Z(this,"actionName",tR),Z(this,"angle",0),Z(this,"x",0),Z(this,"y",0),Z(this,"offsetX",0),Z(this,"offsetY",0),Z(this,"sizeX",0),Z(this,"sizeY",0),Z(this,"touchSizeX",0),Z(this,"touchSizeY",0),Z(this,"cursorStyle","crosshair"),Z(this,"withConnection",!1),Object.assign(this,t)}}let id=(t,e,r)=>r.lockRotation?e2:e.cursorStyle,ig=io(tD,ia((t,e,r,i)=>{let{target:n,ex:s,ey:o,theta:a,originX:l,originY:h}=e,c=n.translateToOriginPoint(n.getRelativeCenterPoint(),l,h);if(e4(n,"lockRotation"))return!1;let u=Math.atan2(o-c.y,s-c.x),d=er(Math.atan2(i-c.y,r-c.x)-u+a);if(n.snapAngle&&n.snapAngle>0){let t=n.snapAngle,e=n.snapThreshold||t,r=Math.ceil(d/t)*t,i=Math.floor(d/t)*t;Math.abs(d-i)<e?d=i:Math.abs(d-r)<e&&(d=r)}d<0&&(d=360+d),d%=360;let f=n.angle!==d;return n.angle=d,f}));function ip(t,e){let r=e.canvas,i=t[r.uniScaleKey];return r.uniformScaling&&!i||!r.uniformScaling&&i}function im(t,e,r){let i=e4(t,"lockScalingX"),n=e4(t,"lockScalingY");if(i&&n||!e&&(i||n)&&r||i&&"x"===e||n&&"y"===e)return!0;let{width:s,height:o,strokeWidth:a}=t;return 0===s&&0===a&&"y"!==e||0===o&&0===a&&"x"!==e}let iv=["e","se","s","sw","w","nw","n","ne","e"],iy=(t,e,r)=>{let i=ip(t,r);if(im(r,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",i))return e2;let n=e9(r,e);return"".concat(iv[n],"-resize")};function ix(t,e,r,i){let n,s,o,a,l,h,c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},u=e.target,d=c.by,f=ip(t,u);if(im(u,d,f))return!1;if(e.gestureScale)s=e.scaleX*e.gestureScale,o=e.scaleY*e.gestureScale;else{if(n=e6(e,e.originX,e.originY,r,i),l="y"!==d?Math.sign(n.x||e.signX||1):1,h="x"!==d?Math.sign(n.y||e.signY||1):1,e.signX||(e.signX=l),e.signY||(e.signY=h),e4(u,"lockScalingFlip")&&(e.signX!==l||e.signY!==h))return!1;if(a=u._getTransformedDimensions(),f&&!d){let t=Math.abs(n.x)+Math.abs(n.y),{original:r}=e,i=t/(Math.abs(a.x*r.scaleX/u.scaleX)+Math.abs(a.y*r.scaleY/u.scaleY));s=r.scaleX*i,o=r.scaleY*i}else s=Math.abs(n.x*u.scaleX/a.x),o=Math.abs(n.y*u.scaleY/a.y);e5(e)&&(s*=2,o*=2),e.signX!==l&&"y"!==d&&(e.originX=.5-e1(e.originX),s*=-1,e.signX=l),e.signY!==h&&"x"!==d&&(e.originY=.5-e1(e.originY),o*=-1,e.signY=h)}let g=u.scaleX,p=u.scaleY;return d?("x"===d&&u.set(tI,s),"y"===d&&u.set(tB,o)):(e4(u,"lockScalingX")||u.set(tI,s),e4(u,"lockScalingY")||u.set(tB,o)),g!==u.scaleX||p!==u.scaleY}let ib=io(tE,ia((t,e,r,i)=>ix(t,e,r,i))),i_=io(tE,ia((t,e,r,i)=>ix(t,e,r,i,{by:"x"}))),iw=io(tE,ia((t,e,r,i)=>ix(t,e,r,i,{by:"y"}))),iC=["target","ex","ey","skewingSide"],iS={x:{counterAxis:"y",scale:tI,skew:tN,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:tB,skew:tW,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},iT=["ns","nesw","ew","nwse"],iO=(t,e,r)=>{if(0!==e.x&&e4(r,"lockSkewingY")||0!==e.y&&e4(r,"lockSkewingX"))return e2;let i=e9(r,e)%4;return"".concat(iT[i],"-resize")};function ik(t,e,r,i,n){let{target:s}=r,{counterAxis:o,origin:a,lockSkewing:l,skew:h,flip:c}=iS[t];if(e4(s,l))return!1;let{origin:u,flip:d}=iS[o],f=-Math.sign(e1(r[u])*(s[d]?-1:1))*(s[c]?-1:1),g=-(.5*((0===s[h]&&e6(r,tw,tw,i,n)[t]>0||s[h]>0?1:-1)*f))+.5;return io(tA,ia((e,r,i,n)=>(function(t,e,r){let{target:i,ex:n,ey:s,skewingSide:o}=e,a=te(e,iC),{skew:l}=iS[t],h=r.subtract(new tJ(n,s)).divide(new tJ(i.scaleX,i.scaleY))[t],c=i[l],u=Math.tan(ee(a[l])),d=er(Math.atan(2*h*o/Math.max("y"===t?i._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:i._getTransformedDimensions({scaleX:1,scaleY:1}).y,1)+u));i.set(l,d);let f=c!==i[l];if(f&&"y"===t){let{skewX:t,scaleX:e}=i,r=i._getTransformedDimensions({skewY:c}),n=i._getTransformedDimensions(),s=0!==t?r.x/n.x:1;1!==s&&i.set(tI,s*e)}return f})(t,r,new tJ(i,n))))(e,tt(tt({},r),{},{[a]:g,skewingSide:f}),i,n)}let iM=(t,e,r,i)=>ik("x",t,e,r,i),iE=(t,e,r,i)=>ik("y",t,e,r,i);function iD(t,e){return t[e.canvas.altActionKey]}let ij=(t,e,r)=>{let i=iD(t,r);return 0===e.x?i?tN:tB:0===e.y?i?tW:tI:""},iA=(t,e,r)=>iD(t,r)?iO(0,e,r):iy(t,e,r),iP=(t,e,r,i)=>iD(t,e.target)?iE(t,e,r,i):i_(t,e,r,i),iF=(t,e,r,i)=>iD(t,e.target)?iM(t,e,r,i):iw(t,e,r,i),iL=()=>({ml:new iu({x:-.5,y:0,cursorStyleHandler:iA,actionHandler:iP,getActionName:ij}),mr:new iu({x:.5,y:0,cursorStyleHandler:iA,actionHandler:iP,getActionName:ij}),mb:new iu({x:0,y:.5,cursorStyleHandler:iA,actionHandler:iF,getActionName:ij}),mt:new iu({x:0,y:-.5,cursorStyleHandler:iA,actionHandler:iF,getActionName:ij}),tl:new iu({x:-.5,y:-.5,cursorStyleHandler:iy,actionHandler:ib}),tr:new iu({x:.5,y:-.5,cursorStyleHandler:iy,actionHandler:ib}),bl:new iu({x:-.5,y:.5,cursorStyleHandler:iy,actionHandler:ib}),br:new iu({x:.5,y:.5,cursorStyleHandler:iy,actionHandler:ib}),mtr:new iu({x:0,y:-.5,actionHandler:ig,cursorStyleHandler:id,offsetY:-40,withConnection:!0,actionName:tj})}),iR=()=>({mr:new iu({x:.5,y:0,actionHandler:il,cursorStyleHandler:iA,actionName:tP}),ml:new iu({x:-.5,y:0,actionHandler:il,cursorStyleHandler:iA,actionName:tP})}),iI=()=>tt(tt({},iL()),iR());class iB extends is{static getDefaults(){return tt(tt({},super.getDefaults()),iB.ownDefaults)}static createControls(){return{controls:iL()}}_updateCacheCanvas(){let t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){let e=t._currentTransform,r=e.target,i=e.action;if(this===r&&i&&i.startsWith(tR))return!1}return super._updateCacheCanvas()}getActiveControl(){let t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;let r=Object.entries(this.oCoords);for(let i=r.length-1;i>=0;i--){let[n,s]=r[i],o=this.controls[n];if(o.shouldActivate(n,this,t,e?s.touchCorner:s.corner))return this.__corner=n,{key:n,control:o,coord:this.oCoords[n]}}}calcOCoords(){let t=this.getViewportTransform(),e=this.getCenterPoint(),r=eo(ec(e.x,e.y),eu({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)})),i=eo(t,r),n=eo(i,[1/t[0],0,0,1/t[3],0,0]),s=this.group?eh(this.calcTransformMatrix()):void 0;s&&(s.scaleX=Math.abs(s.scaleX),s.scaleY=Math.abs(s.scaleY));let o=this._calculateCurrentDimensions(s),a={};return this.forEachControl((t,e)=>{let r=t.positionHandler(o,n,this,t);a[e]=Object.assign(r,this._calcCornerCoords(t,r))}),a}_calcCornerCoords(t,e){let r=this.getTotalAngle();return{corner:t.calcCornerCoords(r,this.cornerSize,e.x,e.y,!1,this),touchCorner:t.calcCornerCoords(r,this.touchCornerSize,e.x,e.y,!0,this)}}setCoords(){super.setCoords(),this.canvas&&(this.oCoords=this.calcOCoords())}forEachControl(t){for(let e in this.controls)t(this.controls[e],e,this)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();let e=this.getRelativeCenterPoint(),r=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(ee(this.angle)),t.fillStyle=this.selectionBackgroundColor,t.fillRect(-r.x/2,-r.y/2,r.x,r.y),t.restore()}strokeBorders(t,e){t.strokeRect(-e.x/2,-e.y/2,e.x,e.y)}_drawBorders(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=tt({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},r);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&&void 0!==arguments[1]?arguments[1]:{},{hasBorders:r,hasControls:i}=this,n=tt({hasBorders:r,hasControls:i},e),s=this.getViewportTransform(),o=n.hasBorders,a=n.hasControls,l=eh(eo(s,this.calcTransformMatrix()));t.save(),t.translate(l.translateX,l.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(l.angle-=180),t.rotate(ee(this.group?l.angle:this.angle)),o&&this.drawBorders(t,l,e),a&&this.drawControls(t,e),t.restore()}drawBorders(t,e,r){let i;if(r&&r.forActiveSelection||this.group){let t=eq(this.width,this.height,em(e)),r=this.isStrokeAccountedForInDimensions()?tZ:(this.strokeUniform?(new tJ).scalarAdd(this.canvas?this.canvas.getZoom():1):new tJ(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);i=t.add(r).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else i=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,i,r)}drawControlsConnectingLines(t,e){let r=!1;t.beginPath(),this.forEachControl((i,n)=>{i.withConnection&&i.getVisibility(this,n)&&(r=!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))}),r&&t.stroke()}drawControls(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t.save();let r=this.getCanvasRetinaScaling(),{cornerStrokeColor:i,cornerDashArray:n,cornerColor:s}=this,o=tt({cornerStrokeColor:i,cornerDashArray:n,cornerColor:s},e);t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=o.cornerColor,this.transparentCorners||(t.strokeStyle=o.cornerStrokeColor),this._setLineDash(t,o.cornerDashArray),this.forEachControl((e,r)=>{if(e.getVisibility(this,r)){let i=this.oCoords[r];e.render(t,i.x,i.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&&void 0!==arguments[0]?arguments[0]:{};Object.entries(t).forEach(t=>{let[e,r]=t;return this.setControlVisible(e,r)})}clearContextTop(t){if(!this.canvas)return;let e=this.canvas.contextTop;if(!e)return;let r=this.canvas.viewportTransform;e.save(),e.transform(r[0],r[1],r[2],r[3],r[4],r[5]),this.transform(e);let i=this.width+4,n=this.height+4;return e.clearRect(-i/2,-n/2,i,n),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){}constructor(t){super(),Object.assign(this,this.constructor.createControls(),iB.ownDefaults),this.setOptions(t)}}function iN(t,e){return e.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(r=>{"constructor"!==r&&Object.defineProperty(t.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r)||Object.create(null))})}),t}Z(iB,"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 iW extends iB{}iN(iW,[rh]),tY.setClass(iW),tY.setClass(iW,"object");let iU=(t,e,r,i)=>{let n=2*(i=Math.round(i))+1,{data:s}=t.getImageData(e-i,r-i,n,n);for(let t=3;t<s.length;t+=4)if(s[t]>0)return!1;return!0};class iH{createSideVector(t,e){let r=rj(t,e);return this.options.strokeUniform?r.multiply(this.scale):r}projectOrthogonally(t,e,r){return this.applySkew(t.add(this.calcOrthogonalProjection(t,e,r)))}isSkewed(){return 0!==this.options.skewX||0!==this.options.skewY}applySkew(t){let e=new tJ(t);return e.y+=e.x*Math.tan(ee(this.options.skewY)),e.x+=e.y*Math.tan(ee(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new tJ(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new tJ(1/this.options.scaleX,1/this.options.scaleY):new tJ(1,1)}}let iX=new tJ;class iV extends iH{static getOrthogonalRotationFactor(t,e){return Math.abs(e?rP(t,e):rF(t))<ty?-1:1}calcOrthogonalProjection(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude,i=rR(this.createSideVector(t,e)),n=iV.getOrthogonalRotationFactor(i,this.bisector);return this.scaleUnitVector(i,r*n)}projectBevel(){let t=[];return(this.alpha%tx==0?[this.B]:[this.B,this.C]).forEach(e=>{t.push(this.projectOrthogonally(this.A,e)),t.push(this.projectOrthogonally(this.A,e,-this.strokeProjectionMagnitude))}),t}projectMiter(){let t=[],e=1/Math.sin(Math.abs(this.alpha)/2),r=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*e),i=this.options.strokeUniform?rA(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return rA(r)/this.strokeProjectionMagnitude<=i&&t.push(this.applySkew(this.A.add(r))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){let r=[],i=new tJ(iV.getOrthogonalRotationFactor(this.bisector),iV.getOrthogonalRotationFactor(new tJ(this.bisector.y,this.bisector.x)));return[new tJ(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new tJ(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(i=>{rN(i,t,e)&&r.push(this.A.add(i))}),r}projectRoundWithSkew(t,e){let r=[],{skewX:i,skewY:n,scaleX:s,scaleY:o,strokeUniform:a}=this.options,l=new tJ(Math.tan(ee(i)),Math.tan(ee(n))),h=this.strokeProjectionMagnitude,c=a?h/o/Math.sqrt(1/o**2+1/s**2*l.y**2):h/Math.sqrt(1+l.y**2),u=new tJ(Math.sqrt(Math.max(h**2-c**2,0)),c),d=a?h/Math.sqrt(1+l.x**2*(1/o)**2/(1/s+1/s*l.x*l.y)**2):h/Math.sqrt(1+l.x**2/(1+l.x*l.y)**2),f=new tJ(d,Math.sqrt(Math.max(h**2-d**2,0)));return[f,f.scalarMultiply(-1),u,u.scalarMultiply(-1)].map(t=>this.applySkew(a?t.multiply(this.strokeUniformScalar):t)).forEach(i=>{rN(i,t,e)&&r.push(this.applySkew(this.A).add(i))}),r}projectRound(){let t=[];t.push(...this.projectBevel());let e=this.alpha%tx==0,r=this.applySkew(this.A),i=t[2*!e].subtract(r),n=t[+!!e].subtract(r),s=rI(i,e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)))>0,o=s?i:n,a=s?n:i;return this.isSkewed()?t.push(...this.projectRoundWithSkew(o,a)):t.push(...this.projectRoundNoSkew(o,a)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}constructor(t,e,r,i){super(i),Z(this,"AB",void 0),Z(this,"AC",void 0),Z(this,"alpha",void 0),Z(this,"bisector",void 0),this.A=new tJ(t),this.B=new tJ(e),this.C=new tJ(r),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=rP(this.AB,this.AC),this.bisector=rL(rD(this.AB.eq(iX)?this.AC:this.AB,this.alpha/2))}}class iY extends iH{calcOrthogonalProjection(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude,i=this.createSideVector(t,e);return this.scaleUnitVector(rR(i),r)}projectButt(){return[this.projectOrthogonally(this.A,this.T,this.strokeProjectionMagnitude),this.projectOrthogonally(this.A,this.T,-this.strokeProjectionMagnitude)]}projectRound(){let t=[];if(!this.isSkewed()&&this.A.eq(this.T)){let e=new tJ(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 iV(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){let t=[];if(this.A.eq(this.T)){let e=new tJ(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{let e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),r=this.scaleUnitVector(rL(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),i=this.A.add(r);t.push(i.add(e),i.subtract(e))}return t.map(t=>this.applySkew(t))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}constructor(t,e,r){super(r),this.A=new tJ(t),this.T=new tJ(e)}}let iz=function(t,e){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[];if(0===t.length)return i;let n=t.reduce((t,e)=>(t[t.length-1].eq(e)||t.push(new tJ(e)),t),[new tJ(t[0])]);if(1===n.length)r=!0;else if(!r){let t=n[0],e=((t,e)=>{for(let r=t.length-1;r>=0;r--)if(e(t[r],r,t))return r;return -1})(n,e=>!e.eq(t));n.splice(e+1)}return n.forEach((t,n,s)=>{let o,a;0===n?(a=s[1],o=r?t:s[s.length-1]):n===s.length-1?(o=s[n-1],a=r?t:s[0]):(o=s[n-1],a=s[n+1]),r&&1===s.length?i.push(...new iY(t,t,e).project()):r&&(0===n||n===s.length-1)?i.push(...new iY(t,0===n?a:o,e).project()):i.push(...new iV(t,o,a,e).project())}),i},iG=t=>{let e={};return Object.keys(t).forEach(r=>{e[r]={},Object.keys(t[r]).forEach(i=>{e[r][i]=tt({},t[r][i])})}),e},iq=t=>t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),iK=t=>(r||r||(r="Intl"in tf()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),r)?Array.from(r.segment(t)).map(t=>{let{segment:e}=t;return e}):iQ(t),iQ=t=>{let e=[];for(let r,i=0;i<t.length;i++)!1!==(r=iJ(t,i))&&e.push(r);return e},iJ=(t,e)=>{let r=t.charCodeAt(e);if(isNaN(r))return"";if(r<55296||r>57343)return t.charAt(e);if(55296<=r&&r<=56319){if(t.length<=e+1)throw"High surrogate without following low surrogate";let r=t.charCodeAt(e+1);if(56320>r||r>57343)throw"High surrogate without following low surrogate";return t.charAt(e)+t.charAt(e+1)}if(0===e)throw"Low surrogate without preceding high surrogate";let i=t.charCodeAt(e-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1};var iZ=Object.freeze({__proto__:null,capitalize:function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"".concat(t.charAt(0).toUpperCase()).concat(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:iq,graphemeSplit:iK});let i$=function(t,e){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t.fill!==e.fill||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth||t.fontSize!==e.fontSize||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.textDecorationThickness!==e.textDecorationThickness||t.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||r&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough)},i0=(t,e)=>{let r=e.split("\n"),i=[],n=-1,s={};t=iG(t);for(let e=0;e<r.length;e++){let o=iK(r[e]);if(t[e])for(let r=0;r<o.length;r++){n++;let o=t[e][r];o&&Object.keys(o).length>0&&(i$(s,o,!0)?i.push({start:n,end:n+1,style:o}):i[i.length-1].end++),s=o||{}}else n+=o.length,s={}}return i},i1=(t,e)=>{if(!Array.isArray(t))return iG(t);let r=e.split(tk),i={},n=-1,s=0;for(let e=0;e<r.length;e++){let o=iK(r[e]);for(let r=0;r<o.length;r++)n++,t[s]&&t[s].start<=n&&n<t[s].end&&(i[e]=i[e]||{},i[e][r]=tt({},t[s].style),n===t[s].end-1&&s++)}return i},i2=["display","transform",tU,"fill-opacity","fill-rule","opacity",tH,"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 i5(t,e){let r,i=t.nodeName,n=t.getAttribute("class"),s=t.getAttribute("id"),o="(?![a-zA-Z\\-]+)";if(r=RegExp("^"+i,"i"),e=e.replace(r,""),s&&e.length&&(r=RegExp("#"+s+o,"i"),e=e.replace(r,"")),n&&e.length){let t=n.split(" ");for(let i=t.length;i--;)r=RegExp("\\."+t[i]+o,"i"),e=e.replace(r,"")}return 0===e.length}let i4=t=>{var e;return null!=(e=rS[t])?e:t},i3=RegExp("(".concat(r_,")"),"gi"),i9="(".concat(r_,")"),i6=String.raw(l||(l=tr(["(skewX)(",")"],["(skewX)\\(","\\)"])),i9),i8=String.raw(h||(h=tr(["(skewY)(",")"],["(skewY)\\(","\\)"])),i9),i7=String.raw(c||(c=tr(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),i9,i9,i9),nt=String.raw(u||(u=tr(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),i9,i9),ne=String.raw(d||(d=tr(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),i9,i9),nr=String.raw(f||(f=tr(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),i9,i9,i9,i9,i9,i9),ni="(?:".concat(nr,"|").concat(ne,"|").concat(i7,"|").concat(nt,"|").concat(i6,"|").concat(i8,")"),nn=new RegExp(String.raw(g||(g=tr(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),"(?:".concat(ni,"*)"))),ns=new RegExp(ni),no=RegExp(ni,"g");function na(t){let e=[];if(!(t=t.replace(i3," $1 ").replace(/,/gi," ").replace(/\s+/gi," ").replace(/\s*([()])\s*/gi,"$1"))||t&&!nn.test(t))return[...t_];for(let r of t.matchAll(no)){let t=ns.exec(r[0]);if(!t)continue;let i=t_,[,n,...s]=t.filter(t=>!!t),[o,a,l,h,c,u]=s.map(t=>parseFloat(t));switch(n){case"translate":i=ec(o,a);break;case tj:i=eu({angle:o},{x:a,y:l});break;case tR:i=ed(o,a);break;case tN:i=eg(o);break;case tW:i=ep(o);break;case"matrix":i=[o,a,l,h,c,u]}e.push(i)}return ea(e)}let nl={stroke:"strokeOpacity",fill:"fillOpacity"};function nh(t,e,r){if(!t)return{};let i,n={},s=16;t.parentNode&&rk.test(t.parentNode.nodeName)&&(n=nh(t.parentElement,e,r)).fontSize&&(i=s=ro(n.fontSize));let o=tt(tt(tt({},e.reduce((e,r)=>{let i=t.getAttribute(r);return i&&(e[r]=i),e},{})),function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={};for(let i in e)(function(t,e){let r=!0,i=i5(t,e.pop());return i&&e.length&&(r=function(t,e){let r,i=!0;for(;t.parentElement&&1===t.parentElement.nodeType&&e.length;)i&&(r=e.pop()),i=i5(t=t.parentElement,r);return 0===e.length}(t,e)),i&&r&&0===e.length})(t,i.split(" "))&&(r=tt(tt({},r),e[i]));return r}(t,r)),function(t){let e={},r=t.getAttribute("style");return r&&("string"==typeof r?r.replace(/;\s*$/,"").split(";").forEach(t=>{if(!t)return;let[r,i]=t.split(":");e[r.trim().toLowerCase()]=i.trim()}):Object.entries(r).forEach(t=>{let[r,i]=t;void 0!==i&&(e[r.toLowerCase()]=i)})),e}(t));o[rO]&&t.setAttribute(rO,o[rO]),o[rT]&&(i=ro(o[rT],s),o[rT]="".concat(i));let a={};for(let t in o){let e=i4(t),r=function(t,e,r,i){let n=Array.isArray(e),s,o=e;if(t!==tU&&t!==tH||e!==tO){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)o=e===tO?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)o=r&&r.transformMatrix?eo(r.transformMatrix,na(e)):na(e);else if("visible"===t)o=e!==tO&&"hidden"!==e,r&&!1===r.visible&&(o=!1);else if("opacity"===t)o=parseFloat(e),r&&void 0!==r.opacity&&(o*=r.opacity);else if("textAnchor"===t)o="start"===e?tC:"end"===e?tT:tw;else if("charSpacing"===t||t===ru)s=ro(e,i)/i*1e3;else if("paintFirst"===t){let t=e.indexOf(tU),r=e.indexOf(tH);o=tU,(t>-1&&r>-1&&r<t||-1===t&&r>-1)&&(o=tH)}else{if("href"===t||"xlink:href"===t||"font"===t||"id"===t)return e;if("imageSmoothing"===t)return"optimizeQuality"===e;s=n?e.map(ro):ro(e,i)}}else o="";return!n&&isNaN(s)?o:s}(e,o[t],n,i);a[e]=r}a&&a.font&&function(t,e){let r=t.match(rC);if(!r)return;let i=r[1],n=r[3],s=r[4],o=r[5],a=r[6];i&&(e.fontStyle=i),n&&(e.fontWeight=isNaN(parseFloat(n))?n:parseFloat(n)),s&&(e.fontSize=ro(s)),a&&(e.fontFamily=a),o&&(e.lineHeight="normal"===o?1:o)}(a.font,a);let l=tt(tt({},n),a);return rk.test(t.nodeName)?l:function(t){let e=iW.getDefaults();return Object.entries(nl).forEach(r=>{let[i,n]=r;if(void 0===t[n]||""===t[i])return;if(void 0===t[i]){if(!e[i])return;t[i]=e[i]}if(0===t[i].indexOf("url("))return;let s=new rs(t[i]);t[i]=s.setAlpha(eC(s.getAlpha()*t[n],2)).toRgba()}),t}(l)}let nc=["left","top","width","height","visible"],nu=["rx","ry"];class nd extends iW{static getDefaults(){return tt(tt({},super.getDefaults()),nd.ownDefaults)}_initRxRy(){let{rx:t,ry:e}=this;t&&!e?this.ry=t:e&&!t&&(this.rx=e)}_render(t){let{width:e,height:r}=this,i=-e/2,n=-r/2,s=this.rx?Math.min(this.rx,e/2):0,o=this.ry?Math.min(this.ry,r/2):0,a=0!==s||0!==o;t.beginPath(),t.moveTo(i+s,n),t.lineTo(i+e-s,n),a&&t.bezierCurveTo(i+e-.4477152502*s,n,i+e,n+.4477152502*o,i+e,n+o),t.lineTo(i+e,n+r-o),a&&t.bezierCurveTo(i+e,n+r-.4477152502*o,i+e-.4477152502*s,n+r,i+e-s,n+r),t.lineTo(i+s,n+r),a&&t.bezierCurveTo(i+.4477152502*s,n+r,i,n+r-.4477152502*o,i,n+r-o),t.lineTo(i,n+o),a&&t.bezierCurveTo(i,n+.4477152502*o,i+.4477152502*s,n,i+s,n),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...nu,...t])}_toSVG(){let{width:t,height:e,rx:r,ry:i}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(r,'" ry="').concat(i,'" width="').concat(t,'" height="').concat(e,'" />\n')]}static async fromElement(t,e,r){let i=nh(t,this.ATTRIBUTE_NAMES,r),{left:n=0,top:s=0,width:o=0,height:a=0,visible:l=!0}=i,h=te(i,nc);return new this(tt(tt(tt({},e),h),{},{left:n,top:s,width:o,height:a,visible:!!(l&&o&&a)}))}constructor(t){super(),Object.assign(this,nd.ownDefaults),this.setOptions(t),this._initRxRy()}}Z(nd,"type","Rect"),Z(nd,"cacheProperties",[...rY,...nu]),Z(nd,"ownDefaults",{rx:0,ry:0}),Z(nd,"ATTRIBUTE_NAMES",[...i2,"x","y","rx","ry","width","height"]),tY.setClass(nd),tY.setSVGClass(nd);let nf="initialization",ng="added",np="removed",nm="imperative",nv=(t,e)=>{let{strokeUniform:r,strokeWidth:i,width:n,height:s,group:o}=e,a=o&&o!==t?eK(o.calcTransformMatrix(),t.calcTransformMatrix()):null,l=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),h=!e.isStrokeAccountedForInDimensions(),c=r&&h?eJ(new tJ(i,i),void 0,t.calcTransformMatrix()):tZ,u=!r&&h?i:0,d=eq(n+u,s+u,ea([a,e.calcOwnMatrix()],!0)).add(c).scalarDivide(2);return[l.subtract(d),l.add(d)]};class ny{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:r,strategy:i}=t;return e===nf||e===nm||!!r&&i!==r}shouldLayoutClipPath(t){let{type:e,target:{clipPath:r}}=t;return e!==nf&&r&&!r.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){let{type:r,target:i}=e;if(r===nm&&e.overrides)return e.overrides;if(0===t.length)return;let{left:n,top:s,width:o,height:a}=eH(t.map(t=>nv(i,t)).reduce((t,e)=>t.concat(e),[])),l=new tJ(o,a),h=new tJ(n,s).add(l.scalarDivide(2));if(r===nf){let t=this.getInitialSize(e,{size:l,center:h});return{center:h,relativeCorrection:new tJ(0,0),size:t}}return{center:h.transform(i.calcOwnMatrix()),size:l}}}Z(ny,"type","strategy");class nx extends ny{shouldPerformLayout(t){return!0}}Z(nx,"type","fit-content"),tY.setClass(nx);let nb=["strategy"],n_=["target","strategy","bubbles","prevStrategy"],nw="layoutManager";class nC{performLayout(t){let e=tt(tt({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);let r=this.getLayoutResult(e);r&&this.commitLayout(e,r),this.onAfterLayout(e,r),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){let{target:r}=e;return[tX,tM,tP,tD,tE,tA,tL,tF,"modifyPath"].map(e=>t.on(e,t=>this.performLayout(e===tX?{type:"object_modified",trigger:e,e:t,target:r}:{type:"object_modifying",trigger:e,e:t,target:r})))}subscribe(t,e){this.unsubscribe(t,e);let r=this.attachHandlers(t,e);this._subscriptions.set(t,r)}unsubscribe(t,e){(this._subscriptions.get(t)||[]).forEach(t=>t()),this._subscriptions.delete(t)}unsubscribeTargets(t){t.targets.forEach(e=>this.unsubscribe(e,t))}subscribeTargets(t){t.targets.forEach(e=>this.subscribe(e,t))}onBeforeLayout(t){let{target:e,type:r}=t,{canvas:i}=e;if(r===nf||r===ng?this.subscribeTargets(t):r===np&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),i&&i.fire("object:layout:before",{target:e,context:t}),r===nm&&t.deep){let r=te(t,nb);e.forEachObject(t=>t.layoutManager&&t.layoutManager.performLayout(tt(tt({},r),{},{bubbles:!1,target:t})))}}getLayoutResult(t){let{target:e,strategy:r,type:i}=t,n=r.calcLayoutResult(t,e.getObjects());if(!n)return;let s=i===nf?new tJ:e.getRelativeCenterPoint(),{center:o,correction:a=new tJ,relativeCorrection:l=new tJ}=n,h=s.subtract(o).add(a).transform(i===nf?t_:es(e.calcOwnMatrix()),!0).add(l);return{result:n,prevCenter:s,nextCenter:o,offset:h}}commitLayout(t,e){var r,i;let{target:n}=t,{result:{size:s},nextCenter:o}=e;(n.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===nf)?n.set({left:null!=(r=t.x)?r:o.x+s.x*e1(n.originX),top:null!=(i=t.y)?i:o.y+s.y*e1(n.originY)}):(n.setPositionByOrigin(o,tw,tw),n.setCoords(),n.set("dirty",!0))}layoutObjects(t,e){let{target:r}=t;r.forEachObject(i=>{i.group===r&&this.layoutObject(t,e,i)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,r.clipPath)}layoutObject(t,e,r){let{offset:i}=e;r.set({left:r.left+i.x,top:r.top+i.y})}onAfterLayout(t,e){let{target:r,strategy:i,bubbles:n,prevStrategy:s}=t,o=te(t,n_),{canvas:a}=r;r.fire("layout:after",{context:t,result:e}),a&&a.fire("object:layout:after",{context:t,result:e,target:r});let l=r.parent;n&&null!=l&&l.layoutManager&&((o.path||(o.path=[])).push(r),l.layoutManager.performLayout(tt(tt({},o),{},{target:l}))),r.set("dirty",!0)}dispose(){let{_subscriptions:t}=this;t.forEach(t=>t.forEach(t=>t())),t.clear()}toObject(){return{type:nw,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new nx;Z(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}}tY.setClass(nC,nw);let nS=["type","objects","layoutManager"];class nT extends nC{performLayout(){}}class nO extends t0(iW){static getDefaults(){return tt(tt({},super.getDefaults()),nO.ownDefaults)}groupInit(t,e){var r;this._objects=[...t],this.__objectSelectionTracker=this.__objectSelectionMonitor.bind(this,!0),this.__objectSelectionDisposer=this.__objectSelectionMonitor.bind(this,!1),this.forEachObject(t=>{this.enterGroup(t,!1)}),this.layoutManager=null!=(r=e.layoutManager)?r:new nC,this.layoutManager.performLayout({type:nf,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(ts("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(ts("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((t,e,r)=>this.canEnterGroup(t)&&r.indexOf(t)===e)}add(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];let i=this._filterObjectsBeforeEnteringGroup(e),n=super.add(...i);return this._onAfterObjectsChange(ng,i),n}insertAt(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];let n=this._filterObjectsBeforeEnteringGroup(r),s=super.insertAt(t,...n);return this._onAfterObjectsChange(ng,n),s}remove(){let t=super.remove(...arguments);return this._onAfterObjectsChange(np,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){let r=this[t];return super._set(t,e),"canvas"===t&&r!==e&&(this._objects||[]).forEach(r=>{r._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:r}=e,i=this._activeObjects;if(t)i.push(r),this._set("dirty",!0);else if(i.length>0){let t=i.indexOf(r);t>-1&&(i.splice(t,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&eY(t,eo(es(this.calcTransformMatrix()),t.calcTransformMatrix())),this._shouldSetNestedCoords()&&t.setCoords(),t._set("group",this),t._set("canvas",this.canvas),this._watchObject(!0,t);let r=this.canvas&&this.canvas.getActiveObject&&this.canvas.getActiveObject();r&&(r===t||t.isDescendantOf(r))&&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||(eY(t,eo(this.calcTransformMatrix(),t.calcTransformMatrix())),t.setCoords()),this._watchObject(!1,t);let r=this._activeObjects.length>0?this._activeObjects.indexOf(t):-1;r>-1&&this._activeObjects.splice(r,1)}shouldCache(){let t=iW.prototype.shouldCache.call(this);if(t){for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,r){this._renderBackground(t);for(let e=0;e<this._objects.length;e++){var i;let r=this._objects[e];null!=(i=this.canvas)&&i.preserveObjectStacking&&r.group!==this?(t.save(),t.transform(...es(this.calcTransformMatrix())),r.render(t),t.restore()):r.group===this&&r.render(t)}this._drawClipPath(t,this.clipPath,r)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.layoutManager.performLayout(tt({target:this,type:nm},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){let r=this.includeDefaultValues;return this._objects.filter(function(t){return!t.excludeFromExport}).map(function(i){let n=i.includeDefaultValues;i.includeDefaultValues=r;let s=i[t||"toObject"](e);return i.includeDefaultValues=n,s})}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=this.layoutManager.toObject();return tt(tt(tt({},super.toObject(["subTargetCheck","interactive",...t])),"fit-content"!==e.strategy||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"";let e=nd.prototype._toSVG.call(this),r=e.indexOf("COMMON_PARTS");e[r]='for="group" ';let i=e.join("");return t?t(i):i}_toSVG(t){let e=["<g ","COMMON_PARTS"," >\n"],r=this._createSVGBgRect(t);r&&e.push(" ",r);for(let r=0;r<this._objects.length;r++)e.push(" ",this._objects[r].toSVG(t));return e.push("</g>\n"),e}getSvgStyles(){let t=void 0!==this.opacity&&1!==this.opacity?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){let e=[],r=this._createSVGBgRect(t);r&&e.push(" ",r);for(let r=0;r<this._objects.length;r++)e.push(" ",this._objects[r].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:r,objects:i=[],layoutManager:n}=t,s=te(t,nS);return Promise.all([ex(i,e),eb(s,e)]).then(t=>{let[e,r]=t,i=new this(e,tt(tt(tt({},s),r),{},{layoutManager:new nT}));return n?i.layoutManager=new(tY.getClass(n.type))(new(tY.getClass(n.strategy))):i.layoutManager=new nC,i.layoutManager.subscribeTargets({type:nf,target:i,targets:i.getObjects()}),i.setCoords(),i})}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Z(this,"_activeObjects",[]),Z(this,"__objectSelectionTracker",void 0),Z(this,"__objectSelectionDisposer",void 0),Object.assign(this,nO.ownDefaults),this.setOptions(e),this.groupInit(t,e)}}Z(nO,"type","Group"),Z(nO,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),tY.setClass(nO);let nk=(t,e)=>Math.min(e.width/t.width,e.height/t.height),nM=(t,e)=>Math.max(e.width/t.width,e.height/t.height),nE="\\s*,?\\s*",nD="".concat(nE,"(").concat(r_,")"),nj="".concat(nD).concat(nD).concat(nD).concat(nE,"([01])").concat(nE,"([01])").concat(nD).concat(nD),nA={m:"l",M:"L"},nP=(t,e,r,i,n,s,o,a,l,h,c)=>{let u=tK(t),d=tQ(t),f=tK(e),g=tQ(e),p=r*n*f-i*s*g+o,m=i*n*f+r*s*g+a;return["C",h+l*(-r*n*d-i*s*u),c+l*(-i*n*d+r*s*u),p+l*(r*n*g+i*s*f),m+l*(i*n*g-r*s*f),p,m]},nF=(t,e,r,i)=>{let n=Math.atan2(e,t),s=Math.atan2(i,r);return s>=n?s-n:2*Math.PI-(n-s)};function nL(t,e,r,i,n,s,o,a){let l;if(tn.cachesBoundsOfCurve&&(l=[...arguments].join(),tp.boundsOfCurveCache[l]))return tp.boundsOfCurveCache[l];let h=Math.sqrt,c=Math.abs,u=[],d=[[0,0],[0,0]],f=6*t-12*r+6*n,g=-3*t+9*r-9*n+3*o,p=3*r-3*t;for(let t=0;t<2;++t){if(t>0&&(f=6*e-12*i+6*s,g=-3*e+9*i-9*s+3*a,p=3*i-3*e),1e-12>c(g)){if(1e-12>c(f))continue;let t=-p/f;0<t&&t<1&&u.push(t);continue}let r=f*f-4*p*g;if(r<0)continue;let n=h(r),o=(-f+n)/(2*g);0<o&&o<1&&u.push(o);let l=(-f-n)/(2*g);0<l&&l<1&&u.push(l)}let m=u.length,y=m,x=nN(t,e,r,i,n,s,o,a);for(;m--;){let{x:t,y:e}=x(u[m]);d[0][m]=t,d[1][m]=e}d[0][y]=t,d[1][y]=e,d[0][y+1]=o,d[1][y+1]=a;let b=[new tJ(Math.min(...d[0]),Math.min(...d[1])),new tJ(Math.max(...d[0]),Math.max(...d[1]))];return tn.cachesBoundsOfCurve&&(tp.boundsOfCurveCache[l]=b),b}let nR=(t,e,r)=>{let[i,n,s,o,a,l,h,c]=r,u=((t,e,r,i,n,s,o)=>{if(0===r||0===i)return[];let a=0,l=0,h=0,c=Math.PI,u=o*tb,d=tQ(u),f=tK(u),g=.5*(-f*t-d*e),p=.5*(-f*e+d*t),m=r**2,y=i**2,x=p**2,b=g**2,_=m*y-m*x-y*b,w=Math.abs(r),C=Math.abs(i);if(_<0){let t=Math.sqrt(1-_/(m*y));w*=t,C*=t}else h=(n===s?-1:1)*Math.sqrt(_/(m*x+y*b));let S=h*w*p/C,T=-h*C*g/w,O=f*S-d*T+.5*t,k=d*S+f*T+.5*e,M=nF(1,0,(g-S)/w,(p-T)/C),E=nF((g-S)/w,(p-T)/C,(-g-S)/w,(-p-T)/C);0===s&&E>0?E-=2*c:1===s&&E<0&&(E+=2*c);let D=Math.ceil(Math.abs(E/c*2)),j=[],A=E/D,P=8/3*Math.sin(A/4)*Math.sin(A/4)/Math.sin(A/2),F=M+A;for(let t=0;t<D;t++)j[t]=nP(M,F,f,d,w,C,O,k,P,a,l),a=j[t][5],l=j[t][6],M=F,F+=A;return j})(h-t,c-e,n,s,a,l,o);for(let r=0,i=u.length;r<i;r++)u[r][1]+=t,u[r][2]+=e,u[r][3]+=t,u[r][4]+=e,u[r][5]+=t,u[r][6]+=e;return u},nI=t=>{let e=0,r=0,i=0,n=0,s=[],o,a=0,l=0;for(let h of t){let t,c=[...h];switch(c[0]){case"l":c[1]+=e,c[2]+=r;case"L":t=["L",e=c[1],r=c[2]];break;case"h":c[1]+=e;case"H":t=["L",e=c[1],r];break;case"v":c[1]+=r;case"V":t=["L",e,r=c[1]];break;case"m":c[1]+=e,c[2]+=r;case"M":e=c[1],r=c[2],i=c[1],n=c[2],t=["M",e,r];break;case"c":c[1]+=e,c[2]+=r,c[3]+=e,c[4]+=r,c[5]+=e,c[6]+=r;case"C":a=c[3],l=c[4],e=c[5],r=c[6],t=["C",c[1],c[2],a,l,e,r];break;case"s":c[1]+=e,c[2]+=r,c[3]+=e,c[4]+=r;case"S":"C"===o?(a=2*e-a,l=2*r-l):(a=e,l=r),e=c[3],r=c[4],a=(t=["C",a,l,c[1],c[2],e,r])[3],l=t[4];break;case"q":c[1]+=e,c[2]+=r,c[3]+=e,c[4]+=r;case"Q":a=c[1],l=c[2],t=["Q",a,l,e=c[3],r=c[4]];break;case"t":c[1]+=e,c[2]+=r;case"T":"Q"===o?(a=2*e-a,l=2*r-l):(a=e,l=r),t=["Q",a,l,e=c[1],r=c[2]];break;case"a":c[6]+=e,c[7]+=r;case"A":nR(e,r,c).forEach(t=>s.push(t)),e=c[6],r=c[7];break;case"z":case"Z":e=i,r=n,t=["Z"]}t?(s.push(t),o=t[0]):o=""}return s},nB=(t,e,r,i)=>Math.sqrt((r-t)**2+(i-e)**2),nN=(t,e,r,i,n,s,o,a)=>l=>{let h=l**3,c=(t=>3*t**2*(1-t))(l),u=(t=>3*t*(1-t)**2)(l),d=(1-l)**3;return new tJ(o*h+n*c+r*u+t*d,a*h+s*c+i*u+e*d)},nW=t=>2*t*(1-t),nU=(t,e,r,i,n,s,o,a)=>l=>{let h=l**2,c=nW(l),u=(1-l)**2;return Math.atan2(3*(u*(i-e)+c*(s-i)+h*(a-s)),3*(u*(r-t)+c*(n-r)+h*(o-n)))},nH=(t,e,r,i,n,s)=>o=>{let a=o**2,l=nW(o),h=(1-o)**2;return new tJ(n*a+r*l+t*h,s*a+i*l+e*h)},nX=(t,e,r,i,n,s)=>o=>{let a=1-o;return Math.atan2(2*(a*(i-e)+o*(s-i)),2*(a*(r-t)+o*(n-r)))},nV=(t,e,r)=>{let i=new tJ(e,r),n=0;for(let e=1;e<=100;e+=1){let r=t(e/100);n+=nB(i.x,i.y,r.x,r.y),i=r}return n},nY=t=>{let e,r,i=0,n=0,s=0,o=0,a=0,l=[];for(let h of t){let t={x:n,y:s,command:h[0],length:0};switch(h[0]){case"M":(r=t).x=o=n=h[1],r.y=a=s=h[2];break;case"L":(r=t).length=nB(n,s,h[1],h[2]),n=h[1],s=h[2];break;case"C":e=nN(n,s,h[1],h[2],h[3],h[4],h[5],h[6]),(r=t).iterator=e,r.angleFinder=nU(n,s,h[1],h[2],h[3],h[4],h[5],h[6]),r.length=nV(e,n,s),n=h[5],s=h[6];break;case"Q":e=nH(n,s,h[1],h[2],h[3],h[4]),(r=t).iterator=e,r.angleFinder=nX(n,s,h[1],h[2],h[3],h[4]),r.length=nV(e,n,s),n=h[3],s=h[4];break;case"Z":(r=t).destX=o,r.destY=a,r.length=nB(n,s,o,a),n=o,s=a}i+=r.length,l.push(r)}return l.push({length:i,x:n,y:s}),l},nz=function(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:nY(t),i=0;for(;e-r[i].length>0&&i<r.length-2;)e-=r[i].length,i++;let n=r[i],s=e/n.length,o=t[i];switch(n.command){case"M":return{x:n.x,y:n.y,angle:0};case"Z":return tt(tt({},new tJ(n.x,n.y).lerp(new tJ(n.destX,n.destY),s)),{},{angle:Math.atan2(n.destY-n.y,n.destX-n.x)});case"L":return tt(tt({},new tJ(n.x,n.y).lerp(new tJ(o[1],o[2]),s)),{},{angle:Math.atan2(o[2]-n.y,o[1]-n.x)});case"C":case"Q":return((t,e)=>{let r,i=0,n=0,s={x:t.x,y:t.y},o=tt({},s),a=.01,l=0,h=t.iterator,c=t.angleFinder;for(;n<e&&a>1e-4;)o=h(i),l=i,(r=nB(s.x,s.y,o.x,o.y))+n>e?(i-=a,a/=2):(s=o,i+=a,n+=r);return tt(tt({},o),{},{angle:c(l)})})(n,e)}},nG=RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),nq=RegExp(nj,"g"),nK=RegExp(r_,"gi"),nQ={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},nJ=t=>{var e;let r=[];for(let i of null!=(e=t.match(nG))?e:[]){let t=i[0];if("z"===t||"Z"===t){r.push([t]);continue}let e=nQ[t.toLowerCase()],n=[];if("a"===t||"A"===t){nq.lastIndex=0;for(let t=null;t=nq.exec(i);)n.push(...t.slice(1))}else n=i.match(nK)||[];for(let i=0;i<n.length;i+=e){let s=Array(e),o=nA[t];s[0]=i>0&&o?o:t;for(let t=0;t<e;t++)s[t+1]=parseFloat(n[i+t]);r.push(s)}}return r},nZ=function(t){let e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=new tJ(t[0]),n=new tJ(t[1]),s=1,o=0,a=[],l=t.length,h=l>2;for(h&&(s=t[2].x<n.x?-1:+(t[2].x!==n.x),o=t[2].y<n.y?-1:+(t[2].y!==n.y)),a.push(["M",i.x-s*r,i.y-o*r]),e=1;e<l;e++){if(!i.eq(n)){let t=i.midPointFrom(n);a.push(["Q",i.x,i.y,t.x,t.y])}i=t[e],e+1<t.length&&(n=t[e+1])}return h&&(s=i.x>t[e-2].x?1:i.x===t[e-2].x?0:-1,o=i.y>t[e-2].y?1:i.y===t[e-2].y?0:-1),a.push(["L",i.x+s*r,i.y+o*r]),a},n$=(t,e)=>t.map(t=>t.map((t,r)=>0===r||void 0===e?t:eC(t,e)).join(" ")).join(" ");function n0(t,e){let r=t.style;r&&e&&("string"==typeof e?r.cssText+=";"+e:Object.entries(e).forEach(t=>{let[e,i]=t;return r.setProperty(e,i)}))}Object.freeze({__proto__:null,addTransformToObject:eV,animate:r8,animateColor:r7,applyTransformToObject:eY,calcAngleBetweenVectors:rP,calcDimensionsMatrix:em,calcPlaneChangeMatrix:eK,calcVectorRotation:rF,cancelAnimFrame:t5,capValue:rX,composeMatrix:ev,copyCanvasElement:t=>{var e;let r=t8(t);return null==(e=r.getContext("2d"))||e.drawImage(t,0,0),r},cos:tK,createCanvasElement:t9,createImage:t6,createRotateMatrix:eu,createScaleMatrix:ed,createSkewXMatrix:eg,createSkewYMatrix:ep,createTranslateMatrix:ec,createVector:rj,crossProduct:rI,degreesToRadians:ee,dotProduct:rB,ease:rJ,enlivenObjectEnlivables:eb,enlivenObjects:ex,findScaleToCover:nM,findScaleToFit:nk,getBoundsOfCurve:nL,getOrthonormalVector:rR,getPathSegmentsInfo:nY,getPointOnPath:nz,getPointer:eN,getRandomInt:(t,e)=>Math.floor(Math.random()*(e-t+1))+t,getRegularPolygonPath:(t,e)=>{let r=2*Math.PI/t,i=-ty;t%2==0&&(i+=r/2);let n=Array(t+1);for(let s=0;s<t;s++){let t=s*r+i,{x:o,y:a}=new tJ(tK(t),tQ(t)).scalarMultiply(e);n[s]=[0===s?"M":"L",o,a]}return n[t]=["Z"],n},getSmoothPathFromPoints:nZ,getSvgAttributes:t=>{let e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":return e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);case"radialGradient":return e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);case"stop":return e.concat(["offset","stop-color","stop-opacity"])}return e},getUnitVector:rL,groupSVGElements:(t,e)=>t&&1===t.length?t[0]:new nO(t,e),hasStyleChanged:i$,invertTransform:es,isBetweenVectors:rN,isIdentityMatrix:ei,isTouchEvent:eW,isTransparent:iU,joinPath:n$,loadImage:ey,magnitude:rA,makeBoundingBoxFromPoints:eH,makePathSimpler:nI,matrixToSVG:eS,mergeClipPaths:(t,e)=>{var r;let i=t,n=e;i.inverted&&!n.inverted&&(i=e,n=t),eZ(n,null==(r=n.group)?void 0:r.calcTransformMatrix(),i.calcTransformMatrix());let s=i.inverted&&n.inverted;return s&&(i.inverted=n.inverted=!1),new nO([i],{clipPath:n,inverted:s})},multiplyTransformMatrices:eo,multiplyTransformMatrixArray:ea,parsePath:nJ,parsePreserveAspectRatioAttribute:ra,parseUnit:ro,pick:e_,projectStrokeOnPoints:iz,qrDecompose:eh,radiansToDegrees:er,removeFromArray:tq,removeTransformFromObject:(t,e)=>{let r=eo(es(e),t.calcOwnMatrix());eY(t,r)},removeTransformMatrixForSvgParsing:(t,e)=>{let r=t._findCenterFromElement();t.transformMatrix&&((t=>{if(t.transformMatrix){let{scaleX:e,scaleY:r,angle:i,skewX:n}=eh(t.transformMatrix);t.flipX=!1,t.flipY=!1,t.set(tI,e),t.set(tB,r),t.angle=i,t.skewX=n,t.skewY=0}})(t),r=r.transform(t.transformMatrix)),delete t.transformMatrix,e&&(t.scaleX*=e.scaleX,t.scaleY*=e.scaleY,t.cropX=e.cropX,t.cropY=e.cropY,r.x+=e.offsetLeft,r.y+=e.offsetTop,t.width=e.width,t.height=e.height),t.setPositionByOrigin(r,tw,tw)},request:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.onComplete||tv,i=new(tf()).XMLHttpRequest,n=e.signal,s=function(){i.abort()},o=function(){n&&n.removeEventListener("abort",s),i.onerror=i.ontimeout=tv};if(n&&n.aborted)throw new ta("request");return n&&n.addEventListener("abort",s,{once:!0}),i.onreadystatechange=function(){4===i.readyState&&(o(),r(i),i.onreadystatechange=tv)},i.onerror=i.ontimeout=o,i.open("get",t,!0),i.send(),i},requestAnimFrame:t2,resetObjectTransform:ez,rotatePoint:(t,e,r)=>t.rotate(r,e),rotateVector:rD,saveObjectTransform:eG,sendObjectToPlane:eZ,sendPointToPlane:eQ,sendVectorToPlane:eJ,setStyle:n0,sin:tQ,sizeAfterTransform:eq,string:iZ,stylesFromArray:i1,stylesToArray:i0,toBlob:et,toDataURL:t7,toFixed:eC,transformPath:(t,e,r)=>(r&&(e=eo(e,[1,0,0,1,-r.x,-r.y])),t.map(t=>{let r=[...t];for(let i=1;i<t.length-1;i+=2){let{x:n,y:s}=en({x:t[i],y:t[i+1]},e);r[i]=n,r[i+1]=s}return r})),transformPoint:en});class n1 extends eL{createUpperCanvas(){let{el:t}=this.lower,e=t9();return e.className=t.className,e.classList.remove("lower-canvas"),e.classList.add("upper-canvas"),e.setAttribute("data-fabric","top"),e.style.cssText=t.style.cssText,e.setAttribute("draggable","true"),e}createContainerElement(){let t=td().createElement("div");return t.setAttribute("data-fabric","wrapper"),n0(t,{position:"relative"}),eF(t),t}applyCanvasStyle(t,e){let{styles:r,allowTouchScrolling:i}=e;n0(t,tt(tt({},r),{},{"touch-action":i?"manipulation":tO})),eF(t)}setDimensions(t,e){super.setDimensions(t,e);let{el:r,ctx:i}=this.upper;eA(r,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),eP(this.upper.el,t),eP(this.container,t)}cleanupDOM(t){let e=this.container,{el:r}=this.lower,{el:i}=this.upper;super.cleanupDOM(t),e.removeChild(i),e.removeChild(r),e.parentNode&&e.parentNode.replaceChild(r,e)}dispose(){super.dispose(),tu().dispose(this.upper.el),delete this.upper,delete this.container}constructor(t){let{allowTouchScrolling:e=!1,containerClass:r=""}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t),Z(this,"upper",void 0),Z(this,"container",void 0);let{el:i}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(i,{allowTouchScrolling:e}),this.applyCanvasStyle(n,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});let s=this.createContainerElement();s.classList.add(r),i.parentNode&&i.parentNode.replaceChild(s,i),s.append(i,n),this.container=s}}class n2 extends eI{static getDefaults(){return tt(tt({},super.getDefaults()),n2.ownDefaults)}get upperCanvasEl(){var t;return null==(t=this.elements.upper)?void 0:t.el}get contextTop(){var t;return null==(t=this.elements.upper)?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new n1(t,{allowTouchScrolling:this.allowTouchScrolling,containerClass:this.containerClass}),this._createCacheCanvas()}_onObjectAdded(t){this._objectsToRender=void 0,super._onObjectAdded(t)}_onObjectRemoved(t){this._objectsToRender=void 0,t===this._activeObject&&(this.fire("before:selection:cleared",{deselected:[t]}),this._discardActiveObject(),this.fire("selection:cleared",{deselected:[t]}),t.fire("deselected",{target:t})),t===this._hoveredTarget&&(this._hoveredTarget=void 0,this._hoveredTargets=[]),super._onObjectRemoved(t)}_onStackOrderChanged(){this._objectsToRender=void 0,super._onStackOrderChanged()}_chooseObjectsToRender(){let t=this._activeObject;return!this.preserveObjectStacking&&t?this._objects.filter(e=>!e.group&&e!==t).concat(t):this._objects}renderAll(){this.cancelRequestedRender(),this.destroyed||(!this.contextTopDirty||this._groupSelector||this.isDrawingMode||(this.clearContext(this.contextTop),this.contextTopDirty=!1),this.hasLostContext&&(this.renderTopLayer(this.contextTop),this.hasLostContext=!1),this._objectsToRender||(this._objectsToRender=this._chooseObjectsToRender()),this.renderCanvas(this.getContext(),this._objectsToRender))}renderTopLayer(t){t.save(),this.isDrawingMode&&this._isCurrentlyDrawing&&(this.freeDrawingBrush&&this.freeDrawingBrush._render(),this.contextTopDirty=!0),this.selection&&this._groupSelector&&(this._drawSelection(t),this.contextTopDirty=!0),t.restore()}renderTop(){let t=this.contextTop;this.clearContext(t),this.renderTopLayer(t),this.fire("after:render",{ctx:t})}setTargetFindTolerance(t){t=Math.round(t),this.targetFindTolerance=t;let e=this.getRetinaScaling(),r=Math.ceil((2*t+1)*e);this.pixelFindCanvasEl.width=this.pixelFindCanvasEl.height=r,this.pixelFindContext.scale(e,e)}isTargetTransparent(t,e,r){let i=this.targetFindTolerance,n=this.pixelFindContext;this.clearContext(n),n.save(),n.translate(-e+i,-r+i),n.transform(...this.viewportTransform);let s=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(n),t.selectionBackgroundColor=s,n.restore();let o=Math.round(i*this.getRetinaScaling());return iU(n,o,o,o)}_isSelectionKeyPressed(t){let e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(e=>!!e&&!0===t[e]):t[e])}_shouldClearSelection(t,e){let r=this.getActiveObjects(),i=this._activeObject;return!!(!e||e&&i&&r.length>1&&-1===r.indexOf(e)&&i!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&i&&i!==e)}_shouldCenterTransform(t,e,r){let i;if(t)return e===tR||e===tI||e===tB||e===tP?i=this.centeredScaling||t.centeredScaling:e===tj&&(i=this.centeredRotation||t.centeredRotation),i?!r:r}_getOriginFromCorner(t,e){let r={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?r.x=tT:["mr","tr","br"].includes(e)&&(r.x=tC),["tl","mt","tr"].includes(e)?r.y=tS:["bl","mb","br"].includes(e)&&(r.y="top")),r}_setupCurrentTransform(t,e,r){var i;let n=e.group?eQ(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:s="",control:o}=e.getActiveControl()||{},a=r&&o?null==(i=o.getActionHandler(t,e,o))?void 0:i.bind(o):e8,l=((t,e,r,i)=>{if(!e||!t)return"drag";let n=i.controls[e];return n.getActionName(r,n,i)})(r,s,t,e),h=t[this.centeredKey],c=this._shouldCenterTransform(e,l,h)?{x:tw,y:tw}:this._getOriginFromCorner(e,s),u={target:e,action:l,actionHandler:a,actionPerformed:!1,corner:s,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:n.x-e.left,offsetY:n.y-e.top,originX:c.x,originY:c.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:ee(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:tt(tt({},eG(e)),{},{originX:c.x,originY:c.y})};this._currentTransform=u,this.fire("before:transform",{e:t,transform:u})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){let{x:e,y:r,deltaX:i,deltaY:n}=this._groupSelector,s=new tJ(e,r).transform(this.viewportTransform),o=new tJ(e+i,r+n).transform(this.viewportTransform),a=this.selectionLineWidth/2,l=Math.min(s.x,o.x),h=Math.min(s.y,o.y),c=Math.max(s.x,o.x),u=Math.max(s.y,o.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(l,h,c-l,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,l+=a,h+=a,c-=a,u-=a,iW.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(l,h,c-l,u-h))}findTarget(t){if(this.skipTargetFind)return;let e=this.getViewportPoint(t),r=this._activeObject,i=this.getActiveObjects();if(this.targets=[],r&&i.length>=1){if(r.findControl(e,eW(t))||i.length>1&&this.searchPossibleTargets([r],e))return r;if(r===this.searchPossibleTargets([r],e)){if(this.preserveObjectStacking){let i=this.targets;this.targets=[];let n=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&n&&n!==r?(this.targets=i,r):n}return r}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let r=t.getCoords(),i=this.getZoom(),n=t.padding/i;if(n){let[t,e,i,s]=r,o=Math.atan2(e.y-t.y,e.x-t.x),a=tK(o)*n,l=tQ(o)*n,h=a+l,c=a-l;r=[new tJ(t.x-c,t.y-h),new tJ(e.x+h,e.y-c),new tJ(i.x+c,i.y+h),new tJ(s.x-h,s.y+c)]}return it.isPointInPolygon(e,r)}_checkTarget(t,e){return!(!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,eQ(e,void 0,this.viewportTransform)))||(this.perPixelTargetFind||t.perPixelTargetFind)&&!t.isEditing&&this.isTargetTransparent(t,e.x,e.y))||!1}_searchPossibleTargets(t,e){let r=t.length;for(;r--;){let i=t[r];if(this._checkTarget(i,e)){if(t$(i)&&i.subTargetCheck){let t=this._searchPossibleTargets(i._objects,e);t&&this.targets.push(t)}return i}}}searchPossibleTargets(t,e){let r=this._searchPossibleTargets(t,e);if(r&&t$(r)&&r.interactive&&this.targets[0]){let t=this.targets;for(let e=t.length-1;e>0;e--){let r=t[e];if(!t$(r)||!r.interactive)return r}return t[0]}return r}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&&void 0!==arguments[1]&&arguments[1],r=this.upperCanvasEl,i=r.getBoundingClientRect(),n=eN(t),s=i.width||0,o=i.height||0;s&&o||("top"in i&&tS in i&&(o=Math.abs(i.top-i.bottom)),tT in i&&tC in i&&(s=Math.abs(i.right-i.left))),this.calcOffset(),n.x=n.x-this._offset.left,n.y=n.y-this._offset.top,e||(n=eQ(n,void 0,this.viewportTransform));let a=this.getRetinaScaling();1!==a&&(n.x/=a,n.y/=a);let l=0===s||0===o?new tJ(1,1):new tJ(r.width/s,r.height/o);return n.multiply(l)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=t9(),this.pixelFindContext=this.pixelFindCanvasEl.getContext("2d",{willReadFrequently:!0}),this.setTargetFindTolerance(this.targetFindTolerance)}getTopContext(){return this.elements.upper.ctx}getSelectionContext(){return this.elements.upper.ctx}getSelectionElement(){return this.elements.upper.el}getActiveObject(){return this._activeObject}getActiveObjects(){let t=this._activeObject;return eM(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let r=!1,i=!1,n=this.getActiveObjects(),s=[],o=[];t.forEach(t=>{n.includes(t)||(r=!0,t.fire("deselected",{e:e,target:t}),o.push(t))}),n.forEach(i=>{t.includes(i)||(r=!0,i.fire("selected",{e:e,target:i}),s.push(i))}),t.length>0&&n.length>0?(i=!0,r&&this.fire("selection:updated",{e:e,selected:s,deselected:o})):n.length>0?(i=!0,this.fire("selection:created",{e:e,selected:s})):t.length>0&&(i=!0,this.fire("selection:cleared",{e:e,deselected:o})),i&&(this._objectsToRender=void 0)}setActiveObject(t,e){let r=this.getActiveObjects(),i=this._setActiveObject(t,e);return this._fireSelectionEvents(r,e),i}_setActiveObject(t,e){let r=this._activeObject;return r!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e:e})&&(this._activeObject=t,eM(t)&&r!==t&&t.set("canvas",this),t.setCoords(),!0)}_discardActiveObject(t,e){let r=this._activeObject;return!!r&&!r.onDeselect({e:t,object:e})&&(this._currentTransform&&this._currentTransform.target===r&&this.endCurrentTransform(t),eM(r)&&r===this._hoveredTarget&&(this._hoveredTarget=void 0),this._activeObject=void 0,!0)}discardActiveObject(t){let e=this.getActiveObjects(),r=this.getActiveObject();e.length&&this.fire("before:selection:cleared",{e:t,deselected:[r]});let i=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),i}endCurrentTransform(t){let e=this._currentTransform;this._finalizeCurrentTransform(t),e&&e.target&&(e.target.isMoving=!1),this._currentTransform=null}_finalizeCurrentTransform(t){let e=this._currentTransform,r=e.target,i={e:t,target:r,transform:e,action:e.action};r._scaling&&(r._scaling=!1),r.setCoords(),e.actionPerformed&&(this.fire("object:modified",i),r.fire(tX,i))}setViewportTransform(t){super.setViewportTransform(t);let e=this._activeObject;e&&e.setCoords()}destroy(){let t=this._activeObject;eM(t)&&(t.removeAll(),t.dispose()),delete this._activeObject,super.destroy(),this.pixelFindContext=null,this.pixelFindCanvasEl=void 0}clear(){this.discardActiveObject(),this._activeObject=void 0,this.clearContext(this.contextTop),super.clear()}drawControls(t){let e=this._activeObject;e&&e._renderControls(t)}_toObject(t,e,r){let i=this._realizeGroupTransformOnObject(t),n=super._toObject(t,e,r);return t.set(i),n}_realizeGroupTransformOnObject(t){let{group:e}=t;if(e&&eM(e)&&this._activeObject===e){let r=e_(t,["angle","flipX","flipY",tC,tI,tB,tN,tW,"top"]);return eV(t,e.calcOwnMatrix()),r}return{}}_setSVGObject(t,e,r){let i=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,r),e.set(i)}constructor(){super(...arguments),Z(this,"targets",[]),Z(this,"_hoveredTargets",[]),Z(this,"_objectsToRender",void 0),Z(this,"_currentTransform",null),Z(this,"_groupSelector",null),Z(this,"contextTopDirty",!1)}}Z(n2,"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 n5{exitTextEditing(){this.target=void 0,this.targets.forEach(t=>{t.isEditing&&t.exitEditing()})}add(t){this.targets.push(t)}remove(t){this.unregister(t),tq(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;(null==(e=this.target)?void 0:e.isEditing)&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}constructor(t){Z(this,"targets",[]),Z(this,"__disposer",void 0);let e=()=>{let{hiddenTextarea:e}=t.getActiveObject()||{};e&&e.focus()},r=t.upperCanvasEl;r.addEventListener("click",e),this.__disposer=()=>r.removeEventListener("click",e)}}let n4=["target","oldTarget","fireCanvas","e"],n3={passive:!1},n9=(t,e)=>{let r=t.getViewportPoint(e),i=t.getScenePoint(e);return{viewportPoint:r,scenePoint:i,pointer:r,absolutePointer:i}},n6=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return t.addEventListener(...r)},n8=function(t){for(var e=arguments.length,r=Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return t.removeEventListener(...r)},n7={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 st extends n2{_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){let r=this.upperCanvasEl,i=this._getEventPrefix();t(ej(r),"resize",this._onResize),t(r,i+"down",this._onMouseDown),t(r,"".concat(i,"move"),this._onMouseMove,n3),t(r,"".concat(i,"out"),this._onMouseOut),t(r,"".concat(i,"enter"),this._onMouseEnter),t(r,"wheel",this._onMouseWheel),t(r,"contextmenu",this._onContextMenu),t(r,"click",this._onClick),t(r,"dblclick",this._onClick),t(r,"dragstart",this._onDragStart),t(r,"dragend",this._onDragEnd),t(r,"dragover",this._onDragOver),t(r,"dragenter",this._onDragEnter),t(r,"dragleave",this._onDragLeave),t(r,"drop",this._onDrop),this.enablePointerEvents||t(r,"touchstart",this._onTouchStart,n3)}removeListeners(){this.addOrRemove(n8,"remove");let t=this._getEventPrefix(),e=eD(this.upperCanvasEl);n8(e,"".concat(t,"up"),this._onMouseUp),n8(e,"touchend",this._onTouchEnd,n3),n8(e,"".concat(t,"move"),this._onMouseMove,n3),n8(e,"touchmove",this._onMouseMove,n3),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){let e=this._hoveredTarget,r=tt({e:t},n9(this,t));this.fire("mouse:out",tt(tt({},r),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",tt({},r)),this._hoveredTargets.forEach(t=>{this.fire("mouse:out",tt(tt({},r),{},{target:t})),t&&t.fire("mouseout",tt({},r))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",tt({e:t},n9(this,t))),this._hoveredTarget=void 0,this._hoveredTargets=[])}_onDragStart(t){this._isClick=!1;let e=this.getActiveObject();if(e&&e.onDragStart(t)){this._dragSource=e;let r={e:t,target:e};return this.fire("dragstart",r),e.fire("dragstart",r),void n6(this.upperCanvasEl,"drag",this._onDragProgress)}eU(t)}_renderDragEffects(t,e,r){let i=!1,n=this._dropTarget;n&&n!==e&&n!==r&&(n.clearContextTop(),i=!0),null==e||e.clearContextTop(),r!==e&&(null==r||r.clearContextTop());let s=this.contextTop;s.save(),s.transform(...this.viewportTransform),e&&(s.save(),e.transform(s),e.renderDragSourceEffect(t),s.restore(),i=!0),r&&(s.save(),r.transform(s),r.renderDropTargetEffect(t),s.restore(),i=!0),s.restore(),i&&(this.contextTopDirty=!0)}_onDragEnd(t){let e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==tO,r=e?this._activeObject:void 0,i={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:r};n8(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",i),this._dragSource&&this._dragSource.fire("dragend",i),delete this._dragSource,this._onMouseUp(t)}_onDragProgress(t){let e={e:t,target:this._dragSource,dragSource:this._dragSource,dropTarget:this._draggedoverTarget};this.fire("drag",e),this._dragSource&&this._dragSource.fire("drag",e)}findDragTargets(t){return this.targets=[],{target:this._searchPossibleTargets(this._objects,this.getViewportPoint(t)),targets:[...this.targets]}}_onDragOver(t){let e,r="dragover",{target:i,targets:n}=this.findDragTargets(t),s=this._dragSource,o={e:t,target:i,subTargets:n,dragSource:s,canDrop:!1,dropTarget:void 0};this.fire(r,o),this._fireEnterLeaveEvents(i,o),i&&(i.canDrop(t)&&(e=i),i.fire(r,o));for(let i=0;i<n.length;i++){let s=n[i];s.canDrop(t)&&(e=s),s.fire(r,o)}this._renderDragEffects(t,s,e),this._dropTarget=e}_onDragEnter(t){let{target:e,targets:r}=this.findDragTargets(t),i={e:t,target:e,subTargets:r,dragSource:this._dragSource};this.fire("dragenter",i),this._fireEnterLeaveEvents(e,i)}_onDragLeave(t){let 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){let{target:e,targets:r}=this.findDragTargets(t),i=this._basicEventHandler("drop:before",tt({e:t,target:e,subTargets:r,dragSource:this._dragSource},n9(this,t)));i.didDrop=!1,i.dropTarget=void 0,this._basicEventHandler("drop",i),this.fire("drop:after",i)}_onContextMenu(t){let e=this.findTarget(t),r=this.targets||[],i=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:r});return this.stopContextMenu&&eU(t),this._basicEventHandler("contextmenu",i),!1}_onClick(t){let e=t.detail;e>3||e<2||(this._cacheTransformEventData(t),2==e&&"dblclick"===t.type&&this._handleEvent(t,"dblclick"),3==e&&this._handleEvent(t,"tripleclick"),this._resetTransformEventData())}getPointerId(t){let e=t.changedTouches;return e?e[0]&&e[0].identifier:this.enablePointerEvents?t.pointerId:-1}_isMainEvent(t){return!0===t.isPrimary||!1!==t.isPrimary&&("touchend"===t.type&&0===t.touches.length||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling,r=this._activeObject;void 0===this.mainTouchId&&(this.mainTouchId=this.getPointerId(t)),this.__onMouseDown(t),(this.isDrawingMode||r&&this._target===r)&&(e=!0),e&&t.preventDefault(),this._resetTransformEventData();let i=this.upperCanvasEl,n=this._getEventPrefix(),s=eD(i);n6(s,"touchend",this._onTouchEnd,n3),e&&n6(s,"touchmove",this._onMouseMove,n3),n8(i,"".concat(n,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();let e=this.upperCanvasEl,r=this._getEventPrefix();n8(e,"".concat(r,"move"),this._onMouseMove,n3);let i=eD(e);n6(i,"".concat(r,"up"),this._onMouseUp),n6(i,"".concat(r,"move"),this._onMouseMove,n3)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;let e=this._getEventPrefix(),r=eD(this.upperCanvasEl);n8(r,"touchend",this._onTouchEnd,n3),n8(r,"touchmove",this._onMouseMove,n3),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{n6(this.upperCanvasEl,"".concat(e,"down"),this._onMouseDown),this._willAddMouseDown=0},400)}_onMouseUp(t){this.__onMouseUp(t),this._resetTransformEventData();let e=this.upperCanvasEl,r=this._getEventPrefix();if(this._isMainEvent(t)){let t=eD(this.upperCanvasEl);n8(t,"".concat(r,"up"),this._onMouseUp),n8(t,"".concat(r,"move"),this._onMouseMove,n3),n6(e,"".concat(r,"move"),this._onMouseMove,n3)}}_onMouseMove(t){let e=this.getActiveObject();this.allowTouchScrolling||e&&e.shouldStartDragging(t)||!t.preventDefault||t.preventDefault(),this.__onMouseMove(t)}_onResize(){this.calcOffset(),this._resetTransformEventData()}_shouldRender(t){let e=this.getActiveObject();return!!e!=!!t||e&&t&&e!==t}__onMouseUp(t){var e;this._cacheTransformEventData(t),this._handleEvent(t,"up:before");let r=this._currentTransform,i=this._isClick,n=this._target,{button:s}=t;if(s)return(this.fireMiddleClick&&1===s||this.fireRightClick&&2===s)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let o,a,l=!1;if(r&&(this._finalizeCurrentTransform(t),l=r.actionPerformed),!i){let e=n===this._activeObject;this.handleSelection(t),l||(l=this._shouldRender(n)||!e&&n===this._activeObject)}if(n){let{key:e,control:i}=n.findControl(this.getViewportPoint(t),eW(t))||{};if(a=e,n.selectable&&n!==this._activeObject&&"up"===n.activeOn)this.setActiveObject(n,t),l=!0;else if(i){let e=i.getMouseUpHandler(t,n,i);e&&(o=this.getScenePoint(t),e.call(i,t,r,o.x,o.y))}n.isMoving=!1}if(r&&(r.target!==n||r.corner!==a)){let e=r.target&&r.target.controls[r.corner],i=e&&e.getMouseUpHandler(t,r.target,e);o=o||this.getScenePoint(t),i&&i.call(e,t,r,o.x,o.y)}this._setCursorFromEvent(t,n),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,n&&(n.__corner=void 0),l?this.requestRenderAll():i||null!=(e=this._activeObject)&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){let{target:r,subTargets:i=[]}=e;this.fire(t,e),r&&r.fire(t,e);for(let n=0;n<i.length;n++)i[n]!==r&&i[n].fire(t,e);return e}_handleEvent(t,e,r){let i=this._target,n=this.targets||[],s=tt(tt(tt({e:t,target:i,subTargets:n},n9(this,t)),{},{transform:this._currentTransform},"up:before"===e||"up"===e?{isClick:this._isClick,currentTarget:this.findTarget(t),currentSubTargets:this.targets}:{}),"down:before"===e||"down"===e?r:{});this.fire("mouse:".concat(e),s),i&&i.fire("mouse".concat(e),s);for(let t=0;t<n.length;t++)n[t]!==i&&n[t].fire("mouse".concat(e),s)}_onMouseDownInDrawingMode(t){this._isCurrentlyDrawing=!0,this.getActiveObject()&&(this.discardActiveObject(t),this.requestRenderAll());let e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseDown(e,{e:t,pointer:e}),this._handleEvent(t,"down",{alreadySelected:!1})}_onMouseMoveInDrawingMode(t){if(this._isCurrentlyDrawing){let e=this.getScenePoint(t);this.freeDrawingBrush&&this.freeDrawingBrush.onMouseMove(e,{e:t,pointer:e})}this.setCursor(this.freeDrawingCursor),this._handleEvent(t,"move")}_onMouseUpInDrawingMode(t){let e=this.getScenePoint(t);this.freeDrawingBrush?this._isCurrentlyDrawing=!!this.freeDrawingBrush.onMouseUp({e:t,pointer:e}):this._isCurrentlyDrawing=!1,this._handleEvent(t,"up")}__onMouseDown(t){this._isClick=!0,this._cacheTransformEventData(t),this._handleEvent(t,"down:before");let e=this._target,r=!!e&&e===this._activeObject,{button:i}=t;if(i)return(this.fireMiddleClick&&1===i||this.fireRightClick&&2===i)&&this._handleEvent(t,"down",{alreadySelected:r}),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||this._currentTransform)return;let n=this._shouldRender(e),s=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,s=!0,n=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){let e=this.getScenePoint(t);this._groupSelector={x:e.x,y:e.y,deltaY:0,deltaX:0}}if(r=!!e&&e===this._activeObject,e){e.selectable&&"down"===e.activeOn&&this.setActiveObject(e,t);let i=e.findControl(this.getViewportPoint(t),eW(t));if(e===this._activeObject&&(i||!s)){this._setupCurrentTransform(t,e,r);let n=i?i.control:void 0,s=this.getScenePoint(t),o=n&&n.getMouseDownHandler(t,e,n);o&&o.call(n,t,this._currentTransform,s.x,s.y)}}n&&(this._objectsToRender=void 0),this._handleEvent(t,"down",{alreadySelected:r}),n&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=eQ(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;let e=this._groupSelector;if(e){let r=this.getScenePoint(t);e.deltaX=r.x-e.x,e.deltaY=r.y-e.y,this.renderTop()}else if(this._currentTransform)this._transformObject(t);else{let e=this.findTarget(t);this._setCursorFromEvent(t,e),this._fireOverOutEvents(t,e)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){let r=this._hoveredTarget,i=this._hoveredTargets,n=this.targets,s=Math.max(i.length,n.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:r,fireCanvas:!0});for(let e=0;e<s;e++)this.fireSyntheticInOutEvents("mouse",{e:t,target:n[e],oldTarget:i[e]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){let r=this._draggedoverTarget,i=this._hoveredTargets,n=this.targets,s=Math.max(i.length,n.length);this.fireSyntheticInOutEvents("drag",tt(tt({},e),{},{target:t,oldTarget:r,fireCanvas:!0}));for(let t=0;t<s;t++)this.fireSyntheticInOutEvents("drag",tt(tt({},e),{},{target:n[t],oldTarget:i[t]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:r,oldTarget:i,fireCanvas:n,e:s}=e,o=te(e,n4),{targetIn:a,targetOut:l,canvasIn:h,canvasOut:c}=n7[t],u=i!==r;if(i&&u){let t=tt(tt({},o),{},{e:s,target:i,nextTarget:r},n9(this,s));n&&this.fire(c,t),i.fire(l,t)}if(r&&u){let t=tt(tt({},o),{},{e:s,target:r,previousTarget:i},n9(this,s));n&&this.fire(h,t),r.fire(a,t)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){let e=this.getScenePoint(t),r=this._currentTransform,i=r.target,n=i.group?eQ(e,void 0,i.group.calcTransformMatrix()):e;r.shiftKey=t.shiftKey,r.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,r,n),r.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,r){let{action:i,actionHandler:n,target:s}=e,o=!!n&&n(t,e,r.x,r.y);o&&s.setCoords(),"drag"===i&&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 r=e.hoverCursor||this.hoverCursor,i=eM(this._activeObject)?this._activeObject:null,n=(!i||e.group!==i)&&e.findControl(this.getViewportPoint(t));if(n){let r=n.control;this.setCursor(r.cursorStyleHandler(t,r,e))}else e.subTargetCheck&&this.targets.concat().reverse().map(t=>{r=t.hoverCursor||r}),this.setCursor(r)}handleMultiSelection(t,e){let r=this._activeObject,i=eM(r);if(r&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(r!==e||i)&&(i||!e.isDescendantOf(r)&&!r.isDescendantOf(e))&&!e.onSelect({e:t})&&!r.getActiveControl()){if(i){let i=r.getObjects();if(e===r){let r=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(i,r)||this.searchPossibleTargets(this._objects,r))||!e.selectable)return!1}e.group===r?(r.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],1===r.size()&&this._setActiveObject(r.item(0),t)):(r.multiSelectAdd(e),this._hoveredTarget=r,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(i,t)}else{r.isEditing&&r.exitEditing();let i=new(tY.getClass("ActiveSelection"))([],{canvas:this});i.multiSelectAdd(r,e),this._hoveredTarget=i,this._setActiveObject(i,t),this._fireSelectionEvents([r],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;let{x:e,y:r,deltaX:i,deltaY:n}=this._groupSelector,s=new tJ(e,r),o=s.add(new tJ(i,n)),a=s.min(o),l=s.max(o).subtract(a),h=this.collectObjects({left:a.x,top:a.y,width:l.x,height:l.y},{includeIntersecting:!this.selectionFullyContained}),c=s.eq(o)?h[0]?[h[0]]:[]:h.length>1?h.filter(e=>!e.onSelect({e:t})).reverse():h;if(1===c.length)this.setActiveObject(c[0],t);else if(c.length>1){let e=tY.getClass("ActiveSelection");this.setActiveObject(new e(c,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),Z(this,"_isClick",void 0),Z(this,"textEditingManager",new n5(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(t=>{this[t]=this[t].bind(this)}),this.addOrRemove(n6,"add")}}let se={x1:0,y1:0,x2:0,y2:0},sr=tt(tt({},se),{},{r1:0,r2:0}),si=(t,e)=>isNaN(t)&&"number"==typeof e?e:t,sn=/^(\d+\.\d+)%|(\d+)%$/;function ss(t){return t&&sn.test(t)}function so(t,e){return rX(0,si("number"==typeof t?t:"string"==typeof t?parseFloat(t)/(ss(t)?100:1):NaN,e),1)}let sa=/\s*;\s*/,sl=/\s*:\s*/;function sh(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function sc(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function su(t,e){return t.getAttribute(e)}class sd{addColorStop(t){for(let e in t){let r=new rs(t[e]);this.colorStops.push({offset:parseFloat(e),color:r.toRgb(),opacity:r.getAlpha()})}return this}toObject(t){return tt(tt({},e_(this,t)),{},{type:this.type,coords:tt({},this.coords),colorStops:this.colorStops.map(t=>tt({},t)),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=[],i=this.gradientTransform?this.gradientTransform.concat():t_.concat(),n="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",s=this.colorStops.map(t=>tt({},t)).sort((t,e)=>t.offset-e.offset),o=-this.offsetX,a=-this.offsetY;"objectBoundingBox"===n?(o/=t.width,a/=t.height):(o+=t.width/2,a+=t.height/2),t&&"function"==typeof t._renderPathCommands&&"percentage"!==this.gradientUnits&&(o-=t.pathOffset.x,a-=t.pathOffset.y),i[4]-=o,i[5]-=a;let l=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(eS(i),'"'),""].join(" ");if("linear"===this.type){let{x1:t,y1:e,x2:i,y2:n}=this.coords;r.push("<linearGradient ",l,' x1="',t,'" y1="',e,'" x2="',i,'" y2="',n,'">\n')}else if("radial"===this.type){let{x1:t,y1:e,x2:i,y2:n,r1:o,r2:a}=this.coords,h=o>a;r.push("<radialGradient ",l,' cx="',h?t:i,'" cy="',h?e:n,'" r="',h?o:a,'" fx="',h?i:t,'" fy="',h?n:e,'">\n'),h&&(s.reverse(),s.forEach(t=>{t.offset=1-t.offset}));let c=Math.min(o,a);if(c>0){let t=c/Math.max(o,a);s.forEach(e=>{e.offset+=t*(1-e.offset)})}}return s.forEach(t=>{let{color:e,offset:i,opacity:n}=t;r.push("<stop ",'offset="',100*i+"%",'" style="stop-color:',e,void 0!==n?";stop-opacity: "+n:";",'"/>\n')}),r.push("linear"===this.type?"</linearGradient>":"</radialGradient>","\n"),r.join("")}toLive(t){let{x1:e,y1:r,x2:i,y2:n,r1:s,r2:o}=this.coords,a="linear"===this.type?t.createLinearGradient(e,r,i,n):t.createRadialGradient(e,r,s,i,n,o);return this.colorStops.forEach(t=>{let{color:e,opacity:r,offset:i}=t;a.addColorStop(i,void 0!==r?new rs(e).setAlpha(r).toRgba():e)}),a}static async fromObject(t){let{colorStops:e,gradientTransform:r}=t;return new this(tt(tt({},t),{},{colorStops:e?e.map(t=>tt({},t)):void 0,gradientTransform:r?[...r]:void 0}))}static fromElement(t,e,r){var i;let n=sc(t),s=e._findCenterFromElement();return new this(tt({id:t.getAttribute("id")||void 0,type:sh(t),coords:(i={width:r.viewBoxWidth||r.width,height:r.viewBoxHeight||r.height},function(t,e){let r,{width:i,height:n,gradientUnits:s}=e;return Object.keys(t).reduce((e,o)=>{let a=t[o];return"Infinity"===a?r=1:"-Infinity"===a?r=0:(r="string"==typeof a?parseFloat(a):a,"string"==typeof a&&ss(a)&&(r*=.01,"pixels"===s&&("x1"!==o&&"x2"!==o&&"r2"!==o||(r*=i),"y1"!==o&&"y2"!==o||(r*=n)))),e[o]=r,e},{})}("linear"===sh(t)?{x1:su(t,"x1")||0,y1:su(t,"y1")||0,x2:su(t,"x2")||"100%",y2:su(t,"y2")||0}:{x1:su(t,"fx")||su(t,"cx")||"50%",y1:su(t,"fy")||su(t,"cy")||"50%",r1:0,x2:su(t,"cx")||"50%",y2:su(t,"cy")||"50%",r2:su(t,"r")||"50%"},tt(tt({},i),{},{gradientUnits:sc(t)}))),colorStops:function(t,e){let r=[],i=t.getElementsByTagName("stop"),n=so(e,1);for(let t=i.length;t--;)r.push(function(t,e){let r,i,n=t.getAttribute("style");if(n){let t=n.split(sa);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){let[n,s]=t[e].split(sl).map(t=>t.trim());"stop-color"===n?r=s:"stop-opacity"===n&&(i=s)}}let s=new rs(r||t.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:so(t.getAttribute("offset"),0),color:s.toRgb(),opacity:si(parseFloat(i||t.getAttribute("stop-opacity")||""),1)*s.getAlpha()*e}}(i[t],n));return r}(t,r.opacity),gradientUnits:n,gradientTransform:na(t.getAttribute("gradientTransform")||"")},"pixels"===n?{offsetX:e.width/2-s.x,offsetY:e.height/2-s.y}:{offsetX:0,offsetY:0}))}constructor(t){let{type:e="linear",gradientUnits:r="pixels",coords:i={},colorStops:n=[],offsetX:s=0,offsetY:o=0,gradientTransform:a,id:l}=t||{};Object.assign(this,{type:e,gradientUnits:r,coords:tt(tt({},"radial"===e?sr:se),i),colorStops:n,offsetX:s,offsetY:o,gradientTransform:a,id:l?"".concat(l,"_").concat(t3()):t3()})}}Z(sd,"type","Gradient"),tY.setClass(sd,"gradient"),tY.setClass(sd,"linear"),tY.setClass(sd,"radial");let sf=["type","source","patternTransform"];class sg{get type(){return"pattern"}set type(t){ts("warn","Setting type has no effect",t)}isImageSource(){return!!this.source&&"string"==typeof this.source.src}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&0!==this.source.naturalWidth&&0!==this.source.naturalHeight)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{repeat:e,crossOrigin:r}=this;return tt(tt({},e_(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:r,offsetX:eC(this.offsetX,tn.NUM_FRACTION_DIGITS),offsetY:eC(this.offsetY,tn.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:r}=t,{source:i,repeat:n,id:s}=this,o=si(this.offsetX/e,0),a=si(this.offsetY/r,0),l="repeat-y"===n||"no-repeat"===n?1+Math.abs(o||0):si(i.width/e,0),h="repeat-x"===n||"no-repeat"===n?1+Math.abs(a||0):si(i.height/r,0);return['<pattern id="SVGID_'.concat(s,'" x="').concat(o,'" y="').concat(a,'" width="').concat(l,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(i.width,'" height="').concat(i.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>\n"].join("\n")}static async fromObject(t,e){let{type:r,source:i,patternTransform:n}=t,s=te(t,sf),o=await ey(i,tt(tt({},e),{},{crossOrigin:s.crossOrigin}));return new this(tt(tt({},s),{},{patternTransform:n&&n.slice(0),source:o}))}constructor(t){Z(this,"repeat","repeat"),Z(this,"offsetX",0),Z(this,"offsetY",0),Z(this,"crossOrigin",""),this.id=t3(),Object.assign(this,t)}}Z(sg,"type","Pattern"),tY.setClass(sg),tY.setClass(sg,"pattern");class sp{_setBrushStyles(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])}_saveAndTransform(t){let e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}needsFullRender(){return 1>new rs(this.color).getAlpha()||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;let t=this.canvas,e=this.shadow,r=t.contextTop,i=t.getZoom()*t.getRetinaScaling();r.shadowColor=e.color,r.shadowBlur=e.blur*i,r.shadowOffsetX=e.offsetX*i,r.shadowOffsetY=e.offsetY*i}_resetShadow(){let t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}_isOutSideCanvas(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}constructor(t){Z(this,"color","rgb(0, 0, 0)"),Z(this,"width",1),Z(this,"shadow",null),Z(this,"strokeLineCap","round"),Z(this,"strokeLineJoin","round"),Z(this,"strokeMiterLimit",10),Z(this,"strokeDashArray",null),Z(this,"limitedToCanvasSize",!1),this.canvas=t}}let sm=["path","left","top"],sv=["d"];class sy extends iW{_setPath(t,e){this.path=nI(Array.isArray(t)?t:nJ(t)),this.setBoundingBox(e)}_findCenterFromElement(){let t=this._calcBoundsFromPath();return new tJ(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){let e=-this.pathOffset.x,r=-this.pathOffset.y;for(let i of(t.beginPath(),this.path))switch(i[0]){case"L":t.lineTo(i[1]+e,i[2]+r);break;case"M":t.moveTo(i[1]+e,i[2]+r);break;case"C":t.bezierCurveTo(i[1]+e,i[2]+r,i[3]+e,i[4]+r,i[5]+e,i[6]+r);break;case"Q":t.quadraticCurveTo(i[1]+e,i[2]+r,i[3]+e,i[4]+r);break;case"Z":t.closePath()}}_render(t){this._renderPathCommands(t),this._renderPaintInOrder(t)}toString(){return"#<Path (".concat(this.complexity(),'): { "top": ').concat(this.top,', "left": ').concat(this.left," }>")}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return tt(tt({},super.toObject(t)),{},{path:this.path.map(t=>t.slice())})}toDatalessObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){let t=n$(this.path,tn.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,'" stroke-linecap="round" />\n')]}_getOffsetTransform(){let t=tn.NUM_FRACTION_DIGITS;return" translate(".concat(eC(-this.pathOffset.x,t),", ").concat(eC(-this.pathOffset.y,t),")")}toClipPathSVG(t){let e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){let e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){let{width:e,height:r,pathOffset:i}=this._calcDimensions();this.set({width:e,height:r,pathOffset:i}),t&&this.setPositionByOrigin(i,tw,tw)}_calcBoundsFromPath(){let t=[],e=0,r=0,i=0,n=0;for(let s of this.path)switch(s[0]){case"L":i=s[1],n=s[2],t.push({x:e,y:r},{x:i,y:n});break;case"M":i=s[1],n=s[2],e=i,r=n;break;case"C":t.push(...nL(i,n,s[1],s[2],s[3],s[4],s[5],s[6])),i=s[5],n=s[6];break;case"Q":t.push(...nL(i,n,s[1],s[2],s[1],s[2],s[3],s[4])),i=s[3],n=s[4];break;case"Z":i=e,n=r}return eH(t)}_calcDimensions(){let t=this._calcBoundsFromPath();return tt(tt({},t),{},{pathOffset:new tJ(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,r){let i=nh(t,this.ATTRIBUTE_NAMES,r),{d:n}=i;return new this(n,tt(tt(tt({},te(i,sv)),e),{},{left:void 0,top:void 0}))}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{path:r,left:i,top:n}=e,s=te(e,sm);super(),Object.assign(this,sy.ownDefaults),this.setOptions(s),this._setPath(t||[],!0),"number"==typeof i&&this.set(tC,i),"number"==typeof n&&this.set("top",n)}}Z(sy,"type","Path"),Z(sy,"cacheProperties",[...rY,"path","fillRule"]),Z(sy,"ATTRIBUTE_NAMES",[...i2,"d"]),tY.setClass(sy),tY.setSVGClass(sy);class sx extends sp{needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(t,e,r){let i=e.midPointFrom(r);return t.quadraticCurveTo(e.x,e.y,i.x,i.y),i}onMouseDown(t,e){let{e:r}=e;this.canvas._isMainEvent(r)&&(this.drawStraightLine=!!this.straightLineKey&&r[this.straightLineKey],this._prepareForDrawing(t),this._addPoint(t),this._render())}onMouseMove(t,e){let{e:r}=e;if(this.canvas._isMainEvent(r)&&(this.drawStraightLine=!!this.straightLineKey&&r[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{let t=this._points,e=t.length,r=this.canvas.contextTop;this._saveAndTransform(r),this.oldEnd&&(r.beginPath(),r.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=sx.drawSegment(r,t[e-2],t[e-1]),r.stroke(),r.restore()}}onMouseUp(t){let{e:e}=t;return!this.canvas._isMainEvent(e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(t){this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)}_addPoint(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.canvas.contextTop,e=this._points[0],r=this._points[1];if(this._saveAndTransform(t),t.beginPath(),2===this._points.length&&e.x===r.x&&e.y===r.y){let t=this.width/1e3;e.x-=t,r.x+=t}t.moveTo(e.x,e.y);for(let i=1;i<this._points.length;i++)sx.drawSegment(t,e,r),e=this._points[i],r=this._points[i+1];t.lineTo(e.x,e.y),t.stroke(),t.restore()}convertPointsToSVGPath(t){return nZ(t,this.width/1e3)}createPath(t){let e=new sy(t,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeMiterLimit:this.strokeMiterLimit,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray});return this.shadow&&(this.shadow.affectStroke=!0,e.shadow=new rH(this.shadow)),e}decimatePoints(t,e){if(t.length<=2)return t;let r=t[0],i=Math.pow(e/this.canvas.getZoom(),2),n=t.length-1,s=[r];for(let e=1;e<n-1;e++)Math.pow(r.x-t[e].x,2)+Math.pow(r.y-t[e].y,2)>=i&&s.push(r=t[e]);return s.push(t[n]),s}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));let t=this.convertPointsToSVGPath(this._points);if("M 0 0 Q 0 0 0 0 L 0 0"===n$(t))return void this.canvas.requestRenderAll();let e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}constructor(t){super(t),Z(this,"decimate",.4),Z(this,"drawStraightLine",!1),Z(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}}let sb=["left","top","radius"],s_=["radius","startAngle","endAngle","counterClockwise"];class sw extends iW{static getDefaults(){return tt(tt({},super.getDefaults()),sw.ownDefaults)}_set(t,e){return super._set(t,e),"radius"===t&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,ee(this.startAngle),ee(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(tI)}getRadiusY(){return this.get("radius")*this.get(tB)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...s_,...t])}_toSVG(){let t=(this.endAngle-this.startAngle)%360;if(0===t)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),'" />\n'];{let{radius:e}=this,r=ee(this.startAngle),i=ee(this.endAngle),n=tK(r)*e,s=tQ(r)*e,o=tK(i)*e,a=tQ(i)*e,l=+!this.counterClockwise;return['<path d="M '.concat(n," ").concat(s," A ").concat(e," ").concat(e," 0 ").concat(+(t>180)," ").concat(l," ").concat(o," ").concat(a,'" '),"COMMON_PARTS"," />\n"]}}static async fromElement(t,e,r){let i=nh(t,this.ATTRIBUTE_NAMES,r),{left:n=0,top:s=0,radius:o=0}=i;return new this(tt(tt({},te(i,sb)),{},{radius:o,left:n-o,top:s-o}))}static fromObject(t){return super._fromObject(t)}constructor(t){super(),Object.assign(this,sw.ownDefaults),this.setOptions(t)}}Z(sw,"type","Circle"),Z(sw,"cacheProperties",[...rY,...s_]),Z(sw,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),Z(sw,"ATTRIBUTE_NAMES",["cx","cy","r",...i2]),tY.setClass(sw),tY.setSVGClass(sw);let sC=["x1","y1","x2","y2"],sS=["x1","y1","x2","y2"],sT=["x1","x2","y1","y2"];class sO extends iW{_setWidthHeight(){let{x1:t,y1:e,x2:r,y2:i}=this;this.width=Math.abs(r-t),this.height=Math.abs(i-e);let{left:n,top:s,width:o,height:a}=eH([{x:t,y:e},{x:r,y:i}]),l=new tJ(n+o/2,s+a/2);this.setPositionByOrigin(l,tw,tw)}_set(t,e){return super._set(t,e),sT.includes(t)&&this._setWidthHeight(),this}_render(t){var e;t.beginPath();let r=this.calcLinePoints();t.moveTo(r.x1,r.y1),t.lineTo(r.x2,r.y2),t.lineWidth=this.strokeWidth;let i=t.strokeStyle;eT(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=null!=(e=this.stroke)?e:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new tJ((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return tt(tt({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){let t=super._getNonTransformedDimensions();return"butt"===this.strokeLineCap&&(0===this.width&&(t.y-=this.strokeWidth),0===this.height&&(t.x-=this.strokeWidth)),t}calcLinePoints(){let{x1:t,x2:e,y1:r,y2:i,width:n,height:s}=this,o=t<=e?-1:1,a=r<=i?-1:1;return{x1:o*n/2,x2:-(o*n)/2,y1:a*s/2,y2:-(a*s)/2}}_toSVG(){let{x1:t,x2:e,y1:r,y2:i}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(r,'" x2="').concat(e,'" y2="').concat(i,'" />\n')]}static async fromElement(t,e,r){let i=nh(t,this.ATTRIBUTE_NAMES,r),{x1:n=0,y1:s=0,x2:o=0,y2:a=0}=i;return new this([n,s,o,a],te(i,sC))}static fromObject(t){let{x1:e,y1:r,x2:i,y2:n}=t,s=te(t,sS);return this._fromObject(tt(tt({},s),{},{points:[e,r,i,n]}),{extraParam:"points"})}constructor(){let[t,e,r,i]=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,sO.ownDefaults),this.setOptions(n),this.x1=t,this.x2=r,this.y1=e,this.y2=i,this._setWidthHeight();let{left:s,top:o}=n;"number"==typeof s&&this.set(tC,s),"number"==typeof o&&this.set("top",o)}}Z(sO,"type","Line"),Z(sO,"cacheProperties",[...rY,...sT]),Z(sO,"ATTRIBUTE_NAMES",i2.concat(sT)),tY.setClass(sO),tY.setSVGClass(sO);class sk extends iW{static getDefaults(){return tt(tt({},super.getDefaults()),sk.ownDefaults)}_render(t){let e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,r),t.lineTo(0,-r),t.lineTo(e,r),t.closePath(),this._renderPaintInOrder(t)}_toSVG(){let t=this.width/2,e=this.height/2;return["<polygon ","COMMON_PARTS",'points="',"".concat(-t," ").concat(e,",0 ").concat(-e,",").concat(t," ").concat(e),'" />']}constructor(t){super(),Object.assign(this,sk.ownDefaults),this.setOptions(t)}}Z(sk,"type","Triangle"),Z(sk,"ownDefaults",{width:100,height:100}),tY.setClass(sk),tY.setSVGClass(sk);let sM=["rx","ry"];class sE extends iW{static getDefaults(){return tt(tt({},super.getDefaults()),sE.ownDefaults)}_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(tI)}getRy(){return this.get("ry")*this.get(tB)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...sM,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,'" />\n')]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,tx,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,r){let i=nh(t,this.ATTRIBUTE_NAMES,r);return i.left=(i.left||0)-i.rx,i.top=(i.top||0)-i.ry,new this(i)}constructor(t){super(),Object.assign(this,sE.ownDefaults),this.setOptions(t)}}Z(sE,"type","Ellipse"),Z(sE,"cacheProperties",[...rY,...sM]),Z(sE,"ownDefaults",{rx:0,ry:0}),Z(sE,"ATTRIBUTE_NAMES",[...i2,"cx","cy","rx","ry"]),tY.setClass(sE),tY.setSVGClass(sE);let sD=["left","top"],sj={exactBoundingBox:!1};class sA extends iW{static getDefaults(){return tt(tt({},super.getDefaults()),sA.ownDefaults)}isOpen(){return!0}_projectStrokeOnPoints(t){return iz(this.points,t,this.isOpen())}_calcDimensions(t){t=tt({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});let e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(t=>t.projectedPoint):this.points;if(0===e.length)return{left:0,top:0,width:0,height:0,pathOffset:new tJ,strokeOffset:new tJ,strokeDiff:new tJ};let r=eH(e),i=em(tt(tt({},t),{},{scaleX:1,scaleY:1})),n=eH(this.points.map(t=>en(t,i,!0))),s=new tJ(this.scaleX,this.scaleY),o=r.left+r.width/2,a=r.top+r.height/2;return this.exactBoundingBox&&(o-=a*Math.tan(ee(this.skewX)),a-=o*Math.tan(ee(this.skewY))),tt(tt({},r),{},{pathOffset:new tJ(o,a),strokeOffset:new tJ(n.left,n.top).subtract(new tJ(r.left,r.top)).multiply(s),strokeDiff:new tJ(r.width,r.height).subtract(new tJ(n.width,n.height)).multiply(s)})}_findCenterFromElement(){let t=eH(this.points);return new tJ(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){let{left:e,top:r,width:i,height:n,pathOffset:s,strokeOffset:o,strokeDiff:a}=this._calcDimensions();this.set({width:i,height:n,pathOffset:s,strokeOffset:o,strokeDiff:a}),t&&this.setPositionByOrigin(new tJ(e+i/2,r+n/2),tw,tw)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new tJ(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.exactBoundingBox){var e,r,i,n;let s;if(Object.keys(t).some(t=>this.strokeUniform||this.constructor.layoutProperties.includes(t))){let{width:i,height:n}=this._calcDimensions(t);s=new tJ(null!=(e=t.width)?e:i,null!=(r=t.height)?r:n)}else s=new tJ(null!=(i=t.width)?i:this.width,null!=(n=t.height)?n:this.height);return s.multiply(new tJ(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){let r=this.initialized&&this[t]!==e,i=super._set(t,e);return this.exactBoundingBox&&r&&((t===tI||t===tB)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),i}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return tt(tt({},super.toObject(t)),{},{points:this.points.map(t=>{let{x:e,y:r}=t;return{x:e,y:r}})})}_toSVG(){let t=[],e=this.pathOffset.x,r=this.pathOffset.y,i=tn.NUM_FRACTION_DIGITS;for(let n=0,s=this.points.length;n<s;n++)t.push(eC(this.points[n].x-e,i),",",eC(this.points[n].y-r,i)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),'" />\n')]}_render(t){let e=this.points.length,r=this.pathOffset.x,i=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-r,this.points[0].y-i);for(let n=0;n<e;n++){let e=this.points[n];t.lineTo(e.x-r,e.y-i)}this.isOpen()||t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,r){return new this(function(t){if(!t)return[];let e=t.replace(/,/g," ").trim().split(/\s+/),r=[];for(let t=0;t<e.length;t+=2)r.push({x:parseFloat(e[t]),y:parseFloat(e[t+1])});return r}(t.getAttribute("points")),tt(tt({},te(nh(t,this.ATTRIBUTE_NAMES,r),sD)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Z(this,"strokeDiff",void 0),Object.assign(this,sA.ownDefaults),this.setOptions(e),this.points=t;let{left:r,top:i}=e;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof r&&this.set(tC,r),"number"==typeof i&&this.set("top",i)}}Z(sA,"ownDefaults",sj),Z(sA,"type","Polyline"),Z(sA,"layoutProperties",[tN,tW,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),Z(sA,"cacheProperties",[...rY,"points"]),Z(sA,"ATTRIBUTE_NAMES",[...i2]),tY.setClass(sA),tY.setSVGClass(sA);class sP extends sA{isOpen(){return!1}}Z(sP,"ownDefaults",sj),Z(sP,"type","Polygon"),tY.setClass(sP),tY.setSVGClass(sP);class sF extends iW{isEmptyStyles(t){if(!this.styles||void 0!==t&&!this.styles[t])return!0;let e=void 0===t?this.styles:{line:this.styles[t]};for(let t in e)for(let r in e[t])for(let i in e[t][r])return!1;return!0}styleHas(t,e){if(!this.styles||void 0!==e&&!this.styles[e])return!1;let r=void 0===e?this.styles:{0:this.styles[e]};for(let e in r)for(let i in r[e])if(void 0!==r[e][i][t])return!0;return!1}cleanStyle(t){if(!this.styles)return!1;let e=this.styles,r,i,n=0,s=!0,o=0;for(let o in e){for(let a in r=0,e[o]){let l=e[o][a]||{};n++,void 0!==l[t]?(i?l[t]!==i&&(s=!1):i=l[t],l[t]===this[t]&&delete l[t]):s=!1,0!==Object.keys(l).length?r++:delete e[o][a]}0===r&&delete e[o]}for(let t=0;t<this._textLines.length;t++)o+=this._textLines[t].length;s&&n===o&&(this[t]=i,this.removeStyle(t))}removeStyle(t){let e,r,i;if(!this.styles)return;let n=this.styles;for(r in n){for(i in e=n[r])delete e[i][t],0===Object.keys(e[i]).length&&delete e[i];0===Object.keys(e).length&&delete n[r]}}_extendStyles(t,e){let{lineIndex:r,charIndex:i}=this.get2DCursorLocation(t);this._getLineStyle(r)||this._setLineStyle(r);let n=ew(tt(tt({},this._getStyleDeclaration(r,i)),e),t=>void 0!==t);this._setStyleDeclaration(r,i,n)}getSelectionStyles(t,e,r){let i=[];for(let n=t;n<(e||t);n++)i.push(this.getStyleAtPosition(n,r));return i}getStyleAtPosition(t,e){let{lineIndex:r,charIndex:i}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(r,i):this._getStyleDeclaration(r,i)}setSelectionStyles(t,e,r){for(let i=e;i<(r||e);i++)this._extendStyles(i,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var r;let i=this.styles&&this.styles[t];return i&&null!=(r=i[e])?r:{}}getCompleteStyleDeclaration(t,e){return tt(tt({},e_(this,this.constructor._styleProperties)),this._getStyleDeclaration(t,e))}_setStyleDeclaration(t,e,r){this.styles[t][e]=r}_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]}}Z(sF,"_styleProperties",rm);let sL=/ +/g,sR=/"/g;function sI(t,e,r,i,n){return" ".concat(function(t,e){let{left:r,top:i,width:n,height:s}=e,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:tn.NUM_FRACTION_DIGITS,a=rl(tU,t,!1),[l,h,c,u]=[r,i,n,s].map(t=>eC(t,o));return"<rect ".concat(a,' x="').concat(l,'" y="').concat(h,'" width="').concat(c,'" height="').concat(u,'"></rect>')}(t,{left:e,top:r,width:i,height:n}),"\n")}let sB=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];class sN extends sF{static getDefaults(){return tt(tt({},super.getDefaults()),sN.ownDefaults)}setPathInfo(){let t=this.path;t&&(t.segmentsInfo=nY(t.path))}_splitText(){let t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(rv)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,r,i,n,s,o;for(let a=0,l=this._textLines.length;a<l;a++)if((this.textAlign===rv||a!==l-1&&!this.isEndOfWrapping(a))&&(i=0,n=this._textLines[a],(e=this.getLineWidth(a))<this.width&&(o=this.textLines[a].match(this._reSpacesAndTabs)))){r=o.length,t=(this.width-e)/r;for(let e=0;e<=n.length;e++)s=this.__charBounds[a][e],this._reSpaceAndTab.test(n[e])?(s.width+=t,s.kernedWidth+=t,s.left+=i,i+=t):s.left+=i}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){let r,i=e?this._unwrappedTextLines:this._textLines;for(r=0;r<i.length;r++){if(t<=i[r].length)return{lineIndex:r,charIndex:t};t-=i[r].length+this.missingNewlineOffset(r,e)}return{lineIndex:r-1,charIndex:i[r-1].length<t?i[r-1].length:t}}toString(){return"#<Text (".concat(this.complexity(),'): { "text": "').concat(this.text,'", "fontFamily": "').concat(this.fontFamily,'" }>')}_getCacheCanvasDimensions(){let t=super._getCacheCanvasDimensions(),e=this.fontSize;return t.width+=e*t.zoomX,t.height+=e*t.zoomY,t}_render(t){let e=this.path;e&&!e.isNotVisible()&&e._render(t),this._setTextStyles(t),this._renderTextLinesBackground(t),this._renderTextDecoration(t,"underline"),this._renderText(t),this._renderTextDecoration(t,"overline"),this._renderTextDecoration(t,"linethrough")}_renderText(t){this.paintFirst===tH?(this._renderTextStroke(t),this._renderTextFill(t)):(this._renderTextFill(t),this._renderTextStroke(t))}_setTextStyles(t,e,r){if(t.textBaseline="alphabetic",this.path)switch(this.pathAlign){case tw:t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline=tS}t.font=this._getFontDeclaration(e,r)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,r=this._textLines.length;e<r;e++){let r=this.getLineWidth(e);r>t&&(t=r)}return t}_renderTextLine(t,e,r,i,n,s){this._renderChars(t,e,r,i,n,s)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;let e=t.fillStyle,r=this._getLeftOffset(),i=this._getTopOffset();for(let e=0,n=this._textLines.length;e<n;e++){let n=this.getHeightOfLine(e);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",e)){i+=n;continue}let s=this._textLines[e].length,o=this._getLineLeftOffset(e),a,l,h=0,c=0,u=this.getValueOfPropertyAt(e,0,"textBackgroundColor");for(let d=0;d<s;d++){let s=this.__charBounds[e][d];l=this.getValueOfPropertyAt(e,d,"textBackgroundColor"),this.path?(t.save(),t.translate(s.renderLeft,s.renderTop),t.rotate(s.angle),t.fillStyle=l,l&&t.fillRect(-s.width/2,-n/this.lineHeight*(1-this._fontSizeFraction),s.width,n/this.lineHeight),t.restore()):l!==u?(a=r+o+c,"rtl"===this.direction&&(a=this.width-a-h),t.fillStyle=u,u&&t.fillRect(a,i,h,n/this.lineHeight),c=s.left,h=s.width,u=l):h+=s.kernedWidth}l&&!this.path&&(a=r+o+c,"rtl"===this.direction&&(a=this.width-a-h),t.fillStyle=l,t.fillRect(a,i,h,n/this.lineHeight)),i+=n}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,r,n){let s,o,a,l,h=tp.getFontCache(e),c=this._getFontDeclaration(e),u=r+t,d=r&&c===this._getFontDeclaration(n),f=e.fontSize/this.CACHE_FONT_SIZE;if(r&&void 0!==h[r]&&(a=h[r]),void 0!==h[t]&&(l=s=h[t]),d&&void 0!==h[u]&&(l=(o=h[u])-a),void 0===s||void 0===a||void 0===o){let n=(i||(i=t8({width:0,height:0}).getContext("2d")),i);this._setTextStyles(n,e,!0),void 0===s&&(l=s=n.measureText(t).width,h[t]=s),void 0===a&&d&&r&&(a=n.measureText(r).width,h[r]=a),d&&void 0===o&&(o=n.measureText(u).width,h[u]=o,l=o-a)}return{width:s*f,kernedWidth:l*f}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){let e=this._measureLine(t);return 0!==this.charSpacing&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,r,i=0,n=this.pathSide===tT,s=this.path,o=this._textLines[t],a=o.length,l=Array(a);this.__charBounds[t]=l;for(let n=0;n<a;n++){let s=o[n];r=this._getGraphemeBox(s,t,n,e),l[n]=r,i+=r.kernedWidth,e=s}if(l[a]={left:r?r.left+r.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},s&&s.segmentsInfo){let t=0,e=s.segmentsInfo[s.segmentsInfo.length-1].length;switch(this.textAlign){case tC:t=n?e-i:0;break;case tw:t=(e-i)/2;break;case tT:t=n?0:e-i}t+=this.pathStartOffset*(n?-1:1);for(let i=n?a-1:0;n?i>=0:i<a;n?i--:i++)r=l[i],t>e?t%=e:t<0&&(t+=e),this._setGraphemeOnPath(t,r),t+=r.kernedWidth}return{width:i,numOfSpaces:0}}_setGraphemeOnPath(t,e){let r=t+e.kernedWidth/2,i=this.path,n=nz(i.path,r,i.segmentsInfo);e.renderLeft=n.x-i.pathOffset.x,e.renderTop=n.y-i.pathOffset.y,e.angle=n.angle+(this.pathSide===tT?Math.PI:0)}_getGraphemeBox(t,e,r,i,n){let s=this.getCompleteStyleDeclaration(e,r),o=i?this.getCompleteStyleDeclaration(e,r-1):{},a=this._measureChar(t,s,i,o),l,h=a.kernedWidth,c=a.width;0!==this.charSpacing&&(c+=l=this._getWidthOfCharSpacing(),h+=l);let u={width:c,left:0,height:s.fontSize,kernedWidth:h,deltaY:s.deltaY};if(r>0&&!n){let t=this.__charBounds[e][r-1];u.left=t.left+t.width+a.kernedWidth-a.width}return u}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let r=1,i=this._textLines[t].length;r<i;r++)e=Math.max(this.getHeightOfChar(t,r),e);return this.__lineHeights[t]=e*this.lineHeight*this._fontSizeMult}calcTextHeight(){let t,e=0;for(let r=0,i=this._textLines.length;r<i;r++)t=this.getHeightOfLine(r),e+=r===i-1?t/this.lineHeight:t;return e}_getLeftOffset(){return"ltr"===this.direction?-this.width/2:this.width/2}_getTopOffset(){return-this.height/2}_renderTextCommon(t,e){t.save();let r=0,i=this._getLeftOffset(),n=this._getTopOffset();for(let s=0,o=this._textLines.length;s<o;s++){let o=this.getHeightOfLine(s),a=o/this.lineHeight,l=this._getLineLeftOffset(s);this._renderTextLine(e,t,this._textLines[s],i+l,n+r+a,s),r+=o}t.restore()}_renderTextFill(t){(this.fill||this.styleHas(tU))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&0!==this.strokeWidth||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,r,i,n,s){let o=this.getHeightOfLine(s),a=this.textAlign.includes(rv),l=this.path,h=!a&&0===this.charSpacing&&this.isEmptyStyles(s)&&!l,c="ltr"===this.direction,u="ltr"===this.direction?1:-1,d=e.direction,f,g,p,m,y,x="",b=0;if(e.save(),d!==this.direction&&(e.canvas.setAttribute("dir",c?"ltr":"rtl"),e.direction=c?"ltr":"rtl",e.textAlign=c?tC:tT),n-=o*this._fontSizeFraction/this.lineHeight,h)return this._renderChar(t,e,s,0,r.join(""),i,n),void e.restore();for(let o=0,h=r.length-1;o<=h;o++)m=o===h||this.charSpacing||l,x+=r[o],p=this.__charBounds[s][o],0===b?(i+=u*(p.kernedWidth-p.width),b+=p.width):b+=p.kernedWidth,a&&!m&&this._reSpaceAndTab.test(r[o])&&(m=!0),m||(m=i$(f=f||this.getCompleteStyleDeclaration(s,o),g=this.getCompleteStyleDeclaration(s,o+1),!1)),m&&(l?(e.save(),e.translate(p.renderLeft,p.renderTop),e.rotate(p.angle),this._renderChar(t,e,s,o,x,-b/2,0),e.restore()):(y=i,this._renderChar(t,e,s,o,x,y,n)),x="",f=g,i+=u*b,b=0);e.restore()}_applyPatternGradientTransformText(t){let e=this.width+this.strokeWidth,r=this.height+this.strokeWidth,i=t8({width:e,height:r}),n=i.getContext("2d");return i.width=e,i.height=r,n.beginPath(),n.moveTo(0,0),n.lineTo(e,0),n.lineTo(e,r),n.lineTo(0,r),n.closePath(),n.translate(e/2,r/2),n.fillStyle=t.toLive(n),this._applyPatternGradientTransform(n,t),n.fill(),n.createPattern(i,"no-repeat")}handleFiller(t,e,r){let i,n;return eT(r)?"percentage"===r.gradientUnits||r.gradientTransform||r.patternTransform?(i=-this.width/2,n=-this.height/2,t.translate(i,n),t[e]=this._applyPatternGradientTransformText(r),{offsetX:i,offsetY:n}):(t[e]=r.toLive(t),this._applyPatternGradientTransform(t,r)):(t[e]=r,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:r,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",r)}_setFillStyles(t,e){let{fill:r}=e;return this.handleFiller(t,"fillStyle",r)}_renderChar(t,e,r,i,n,s,o){let a=this._getStyleDeclaration(r,i),l=this.getCompleteStyleDeclaration(r,i),h="fillText"===t&&l.fill,c="strokeText"===t&&l.stroke&&l.strokeWidth;if(c||h){if(e.save(),e.font=this._getFontDeclaration(l),a.textBackgroundColor&&this._removeShadow(e),a.deltaY&&(o+=a.deltaY),h){let t=this._setFillStyles(e,l);e.fillText(n,s-t.offsetX,o-t.offsetY)}if(c){let t=this._setStrokeStyles(e,l);e.strokeText(n,s-t.offsetX,o-t.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,r){let i=this.get2DCursorLocation(t,!0),n=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"fontSize"),s=this.getValueOfPropertyAt(i.lineIndex,i.charIndex,"deltaY"),o={fontSize:n*r.size,deltaY:s+n*r.baseline};this.setSelectionStyles(o,t,e)}_getLineLeftOffset(t){let e=this.getLineWidth(t),r=this.width-e,i=this.textAlign,n=this.direction,s=this.isEndOfWrapping(t),o=0;return i!==rv&&(i!==rb||s)&&(i!==rx||s)&&(i!==ry||s)?(i===tw&&(o=r/2),i===tT&&(o=r),i===rb&&(o=r/2),i===rx&&(o=r),"rtl"===n&&(i===tT||i===rv||i===rx?o=0:i===tC||i===ry?o=-r:i!==tw&&i!==rb||(o=-r/2)),o):0}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(void 0!==this.__lineWidths[t])return this.__lineWidths[t];let{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return 0!==this.charSpacing?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,r){var i;return null!=(i=this._getStyleDeclaration(t,e)[r])?i:this[r]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let r=this._getTopOffset(),i=this._getLeftOffset(),n=this.path,s=this._getWidthOfCharSpacing(),o="linethrough"===e?.5:+("overline"===e),a=this.offsets[e];for(let l=0,h=this._textLines.length;l<h;l++){let h=this.getHeightOfLine(l);if(!this[e]&&!this.styleHas(e,l)){r+=h;continue}let c=this._textLines[l],u=h/this.lineHeight,d=this._getLineLeftOffset(l),f=0,g=0,p=this.getValueOfPropertyAt(l,0,e),m=this.getValueOfPropertyAt(l,0,tU),y=this.getValueOfPropertyAt(l,0,ru),x=p,b=m,_=y,w=r+u*(1-this._fontSizeFraction),C=this.getHeightOfChar(l,0),S=this.getValueOfPropertyAt(l,0,"deltaY");for(let r=0,s=c.length;r<s;r++){let s=this.__charBounds[l][r];x=this.getValueOfPropertyAt(l,r,e),b=this.getValueOfPropertyAt(l,r,tU),_=this.getValueOfPropertyAt(l,r,ru);let h=this.getHeightOfChar(l,r),c=this.getValueOfPropertyAt(l,r,"deltaY");if(n&&x&&b){let e=this.fontSize*_/1e3;t.save(),t.fillStyle=m,t.translate(s.renderLeft,s.renderTop),t.rotate(s.angle),t.fillRect(-s.kernedWidth/2,a*h+c-o*e,s.kernedWidth,e),t.restore()}else if((x!==p||b!==m||h!==C||_!==y||c!==S)&&g>0){let e=this.fontSize*y/1e3,r=i+d+f;"rtl"===this.direction&&(r=this.width-r-g),p&&m&&y&&(t.fillStyle=m,t.fillRect(r,w+a*C+S-o*e,g,e)),f=s.left,g=s.width,p=x,y=_,m=b,C=h,S=c}else g+=s.kernedWidth}let T=i+d+f;"rtl"===this.direction&&(T=this.width-T-g),t.fillStyle=b;let O=this.fontSize*_/1e3;x&&b&&_&&t.fillRect(T,w+a*C+S-o*O,g-s,O),r+=h}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:r=this.fontWeight,fontSize:i=this.fontSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0,s=t.includes("'")||t.includes('"')||t.includes(",")||sN.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,r,"".concat(n?this.CACHE_FONT_SIZE:i,"px"),s].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return iK(t)}_splitTextIntoLines(t){let e=t.split(this._reNewline),r=Array(e.length),i=["\n"],n=[];for(let t=0;t<e.length;t++)r[t]=this.graphemeSplit(e[t]),n=n.concat(r[t],i);return n.pop(),{_unwrappedLines:r,lines:e,graphemeText:n,graphemeLines:r}}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return tt(tt({},super.toObject([...rp,...t])),{},{styles:i0(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){let{textLayoutProperties:r}=this.constructor;super.set(t,e);let i=!1,n=!1;if("object"==typeof t)for(let e in t)"path"===e&&this.setPathInfo(),i=i||r.includes(e),n=n||"path"===e;else i=r.includes(t),n="path"===t;return n&&this.setPathInfo(),i&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,r){let i=nh(t,sN.ATTRIBUTE_NAMES,r),n=tt(tt({},e),i),{textAnchor:s=tC,textDecoration:o="",dx:a=0,dy:l=0,top:h=0,left:c=0,fontSize:u=16,strokeWidth:d=1}=n,f=te(n,sB),g=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),tt({left:c+a,top:h+l,underline:o.includes("underline"),overline:o.includes("overline"),linethrough:o.includes("line-through"),strokeWidth:0,fontSize:u},f)),p=g.getScaledHeight()/g.height,m=((g.height+g.strokeWidth)*g.lineHeight-g.height)*p,y=g.getScaledHeight()+m,x=0;return s===tw&&(x=g.getScaledWidth()/2),s===tT&&(x=g.getScaledWidth()),g.set({left:g.left-x,top:g.top-(y-g.fontSize*(.07+g._fontSizeFraction))/g.lineHeight,strokeWidth:d}),g}static fromObject(t){return this._fromObject(tt(tt({},t),{},{styles:i1(t.styles||{},t.text)}),{extraParam:"text"})}constructor(t,e){super(),Z(this,"__charBounds",[]),Object.assign(this,sN.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}}Z(sN,"textLayoutProperties",rg),Z(sN,"cacheProperties",[...rY,...rp]),Z(sN,"ownDefaults",{_reNewline:tk,_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:tC,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:tC,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,[ru]:66.667}),Z(sN,"type","Text"),Z(sN,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),Z(sN,"ATTRIBUTE_NAMES",i2.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),iN(sN,[class extends rh{_toSVG(){let t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(t){let e=this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0}),r=this.path;return r?e+r._createBaseSVGMarkup(r._toSVG(),{reviver:t,withShadow:!0,additionalTransform:eS(this.calcOwnMatrix())}):e}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(t){let{textBgRects:e,textSpans:r}=t,i=this.getSvgTextDecoration(this);return[e.join(""),' <text xml:space="preserve" ','font-family="'.concat(this.fontFamily.replace(sR,"'"),'" '),'font-size="'.concat(this.fontSize,'" '),this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",i?'text-decoration="'.concat(i,'" '):"","rtl"===this.direction?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",r.join(""),"</text>\n"]}_getSVGTextAndBg(t,e){let r=[],i=[],n,s=t;this.backgroundColor&&i.push(...sI(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let t=0,o=this._textLines.length;t<o;t++)n=this._getLineLeftOffset(t),"rtl"===this.direction&&(n+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",t))&&this._setSVGTextLineBg(i,t,e+n,s),this._setSVGTextLineText(r,t,e+n,s),s+=this.getHeightOfLine(t);return{textSpans:r,textBgRects:i}}_createTextCharSpan(t,e,r,i,n){let s=tn.NUM_FRACTION_DIGITS,o=this.getSvgSpanStyles(e,t!==t.trim()||!!t.match(sL)),a=e.deltaY,l=a?' dy="'.concat(eC(a,s),'" '):"",{angle:h,renderLeft:c,renderTop:u,width:d}=n,f="";if(void 0!==c){h&&(f=' rotate="'.concat(eC(er(h),s),'"'));let t=eu({angle:er(h)});t[4]=c,t[5]=u;let e=new tJ(-(d/2),0).transform(t);r=e.x,i=e.y}return'<tspan x="'.concat(eC(r,s),'" y="').concat(eC(i,s),'" ').concat(l).concat(f).concat(o?'style="'.concat(o,'"'):"",">").concat(iq(t),"</tspan>")}_setSVGTextLineText(t,e,r,i){let n=this.getHeightOfLine(e),s=this.textAlign.includes(rv),o=this._textLines[e],a,l,h,c,u,d="",f=0;i+=n*(1-this._fontSizeFraction)/this.lineHeight;for(let n=0,g=o.length-1;n<=g;n++)u=n===g||this.charSpacing||this.path,d+=o[n],h=this.__charBounds[e][n],0===f?(r+=h.kernedWidth-h.width,f+=h.width):f+=h.kernedWidth,s&&!u&&this._reSpaceAndTab.test(o[n])&&(u=!0),u||(u=i$(a=a||this.getCompleteStyleDeclaration(e,n),l=this.getCompleteStyleDeclaration(e,n+1),!0)),u&&(c=this._getStyleDeclaration(e,n),t.push(this._createTextCharSpan(d,c,r,i,h)),d="",a=l,"rtl"===this.direction?r-=f:r+=f,f=0)}_setSVGTextLineBg(t,e,r,i){let n=this._textLines[e],s=this.getHeightOfLine(e)/this.lineHeight,o,a=0,l=0,h=this.getValueOfPropertyAt(e,0,"textBackgroundColor");for(let c=0;c<n.length;c++){let{left:n,width:u,kernedWidth:d}=this.__charBounds[e][c];(o=this.getValueOfPropertyAt(e,c,"textBackgroundColor"))!==h?(h&&t.push(...sI(h,r+l,i,a,s)),l=n,a=u,h=o):a+=d}o&&t.push(...sI(h,r+l,i,a,s))}_getSVGLineTopOffset(t){let e,r=0;for(e=0;e<t;e++)r+=this.getHeightOfLine(e);let i=this.getHeightOfLine(e);return{lineTop:r,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(t){return"".concat(super.getSvgStyles(t)," text-decoration-thickness: ").concat(eC(this.textDecorationThickness*this.getObjectScaling().y/10,tn.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(t,e){let{fontFamily:r,strokeWidth:i,stroke:n,fill:s,fontSize:o,fontStyle:a,fontWeight:l,deltaY:h,textDecorationThickness:c,linethrough:u,overline:d,underline:f}=t,g=this.getSvgTextDecoration({underline:null!=f?f:this.underline,overline:null!=d?d:this.overline,linethrough:null!=u?u:this.linethrough}),p=c||this.textDecorationThickness;return[n?rl(tH,n):"",i?"stroke-width: ".concat(i,"; "):"",r?"font-family: ".concat(r.includes("'")||r.includes('"')?r:"'".concat(r,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",g?"text-decoration: ".concat(g,"; text-decoration-thickness: ").concat(eC(p*this.getObjectScaling().y/10,tn.NUM_FRACTION_DIGITS),"%; "):"",s?rl(tU,s):"",h?"baseline-shift: ".concat(-h,"; "):"",e?"white-space: pre; ":""].join("")}getSvgTextDecoration(t){return["overline","underline","line-through"].filter(e=>t[e.replace("-","")]).join(" ")}}]),tY.setClass(sN),tY.setSVGClass(sN);class sW{isPointerOverSelection(t){let e=this.target,r=e.getSelectionStartFromPointer(t);return e.isEditing&&r>=e.selectionStart&&r<=e.selectionEnd&&e.selectionStart<e.selectionEnd}start(t){return this.__mouseDownInPlace=this.isPointerOverSelection(t)}isActive(){return this.__mouseDownInPlace}end(t){let e=this.isActive();return e&&!this.__dragStartFired&&(this.target.setCursorByClick(t),this.target.initDelayedCursor(!0)),this.__mouseDownInPlace=!1,this.__dragStartFired=!1,this.__isDraggingOver=!1,e}getDragStartSelection(){return this.__dragStartSelection}setDragImage(t,e){var r;let{selectionStart:i,selectionEnd:n}=e,s=this.target,o=s.canvas,a=new tJ(s.flipX?-1:1,s.flipY?-1:1),l=s._getCursorBoundaries(i),h=new tJ(l.left+l.leftOffset,l.top+l.topOffset).multiply(a).transform(s.calcTransformMatrix()),c=o.getScenePoint(t).subtract(h),u=s.getCanvasRetinaScaling(),d=s.getBoundingRect(),f=h.subtract(new tJ(d.left,d.top)),g=o.viewportTransform,p=f.add(c).transform(g,!0),m=s.backgroundColor,y=iG(s.styles);s.backgroundColor="";let x={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};s.setSelectionStyles(x,0,i),s.setSelectionStyles(x,n,s.text.length),s.dirty=!0;let b=s.toCanvasElement({enableRetinaScaling:o.enableRetinaScaling,viewportTransform:!0});s.backgroundColor=m,s.styles=y,s.dirty=!0,n0(b,{position:"fixed",left:"".concat(-b.width,"px"),border:tO,width:"".concat(b.width/u,"px"),height:"".concat(b.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{b.remove()},eD(t.target||this.target.hiddenTextarea).body.appendChild(b),null==(r=t.dataTransfer)||r.setDragImage(b,p.x,p.y)}onDragStart(t){this.__dragStartFired=!0;let e=this.target,r=this.isActive();if(r&&t.dataTransfer){let r=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},i=e._text.slice(r.selectionStart,r.selectionEnd).join(""),n=tt({text:e.text,value:i},r);t.dataTransfer.setData("text/plain",i),t.dataTransfer.setData("application/fabric",JSON.stringify({value:i,styles:e.getSelectionStyles(r.selectionStart,r.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,n)}return e.abortCursorAnimation(),r}canDrop(t){if(this.target.editable&&!this.target.getActiveControl()&&!t.defaultPrevented){if(this.isActive()&&this.__dragStartSelection){let e=this.target.getSelectionStartFromPointer(t),r=this.__dragStartSelection;return e<r.selectionStart||e>r.selectionEnd}return!0}return!1}targetCanDrop(t){return this.target.canDrop(t)}dragEnterHandler(t){let{e:e}=t,r=this.targetCanDrop(e);!this.__isDraggingOver&&r&&(this.__isDraggingOver=!0)}dragOverHandler(t){let{e:e}=t,r=this.targetCanDrop(e);!this.__isDraggingOver&&r?this.__isDraggingOver=!0:this.__isDraggingOver&&!r&&(this.__isDraggingOver=!1),this.__isDraggingOver&&(e.preventDefault(),t.canDrop=!0,t.dropTarget=this.target)}dragLeaveHandler(){(this.__isDraggingOver||this.isActive())&&(this.__isDraggingOver=!1)}dropHandler(t){var e;let{e:r}=t,i=r.defaultPrevented;this.__isDraggingOver=!1,r.preventDefault();let n=null==(e=r.dataTransfer)?void 0:e.getData("text/plain");if(n&&!i){let e=this.target,i=e.canvas,s=e.getSelectionStartFromPointer(r),{styles:o}=r.dataTransfer.types.includes("application/fabric")?JSON.parse(r.dataTransfer.getData("application/fabric")):{},a=n[Math.max(0,n.length-1)];if(this.__dragStartSelection){let t=this.__dragStartSelection.selectionStart,r=this.__dragStartSelection.selectionEnd;s>t&&s<=r?s=t:s>r&&(s-=r-t),e.removeChars(t,r),delete this.__dragStartSelection}e._reNewline.test(a)&&(e._reNewline.test(e._text[s])||s===e._text.length)&&(n=n.trimEnd()),t.didDrop=!0,t.dropTarget=e,e.insertChars(n,o,s),i.setActiveObject(e),e.enterEditing(r),e.selectionStart=Math.min(s+0,e._text.length),e.selectionEnd=Math.min(e.selectionStart+n.length,e._text.length),e.hiddenTextarea.value=e.text,e._updateTextarea(),e.hiddenTextarea.focus(),e.fire(tL,{index:s+0,action:"drop"}),i.fire("text:changed",{target:e}),i.contextTopDirty=!0,i.requestRenderAll()}}dragEndHandler(t){let{e:e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var r;let t=this.target,i=this.target.canvas,{selectionStart:n,selectionEnd:s}=this.__dragStartSelection,o=(null==(r=e.dataTransfer)?void 0:r.dropEffect)||tO;o===tO?(t.selectionStart=n,t.selectionEnd=s,t._updateTextarea(),t.hiddenTextarea.focus()):(t.clearContextTop(),"move"===o&&(t.removeChars(n,s),t.selectionStart=t.selectionEnd=n,t.hiddenTextarea&&(t.hiddenTextarea.value=t.text),t._updateTextarea(),t.fire(tL,{index:n,action:"dragend"}),i.fire("text:changed",{target:t}),i.requestRenderAll()),t.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}constructor(t){Z(this,"target",void 0),Z(this,"__mouseDownInPlace",!1),Z(this,"__dragStartFired",!1),Z(this,"__isDraggingOver",!1),Z(this,"__dragStartSelection",void 0),Z(this,"__dragImageDisposer",void 0),Z(this,"_dispose",void 0),this.target=t;let e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach(t=>t()),this._dispose=void 0}}}let sU=/[ \n\.,;!\?\-]/;class sH extends sN{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:r,delay:i,onComplete:n}=t;return r8({startValue:this._currentCursorOpacity,endValue:e,duration:r,delay:i,onComplete:n,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:t=>{this._currentCursorOpacity=t,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;null==(t=this._currentTickCompleteState)||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}cmdAll(){this.selectAll(),this.renderCursorOrSelection()}getSelectedText(){return this._text.slice(this.selectionStart,this.selectionEnd).join("")}findWordBoundaryLeft(t){let e=0,r=t-1;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r--;for(;/\S/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findWordBoundaryRight(t){let e=0,r=t;if(this._reSpace.test(this._text[r]))for(;this._reSpace.test(this._text[r]);)e++,r++;for(;/\S/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}findLineBoundaryLeft(t){let e=0,r=t-1;for(;!/\n/.test(this._text[r])&&r>-1;)e++,r--;return t-e}findLineBoundaryRight(t){let e=0,r=t;for(;!/\n/.test(this._text[r])&&r<this._text.length;)e++,r++;return t+e}searchWordBoundary(t,e){let r=this._text,i=t>0&&this._reSpace.test(r[t])&&(-1===e||!tk.test(r[t-1]))?t-1:t,n=r[i];for(;i>0&&i<r.length&&!sU.test(n);)i+=e,n=r[i];return -1===e&&sU.test(n)&&i++,i}selectWord(t){var e;t=null!=(e=t)?e:this.selectionStart;let r=this.searchWordBoundary(t,-1),i=Math.max(r,this.searchWordBoundary(t,1));this.selectionStart=r,this.selectionEnd=i,this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()}selectLine(t){var e;t=null!=(e=t)?e:this.selectionStart;let r=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);this.selectionStart=r,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;let e=this.hiddenTextarea;eD(e).activeElement!==e&&e.focus();let r=this.getSelectionStartFromPointer(t),i=this.selectionStart,n=this.selectionEnd;(r===this.__selectionStartOnMouseDown&&i!==n||i!==r&&n!==r)&&(r>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=r):(this.selectionStart=r,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===i&&this.selectionEnd===n||(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,r){let i=r.slice(0,t),n=this.graphemeSplit(i).length;if(t===e)return{selectionStart:n,selectionEnd:n};let s=r.slice(t,e);return{selectionStart:n,selectionEnd:n+this.graphemeSplit(s).length}}fromGraphemeToStringSelection(t,e,r){let i=r.slice(0,t).join("").length;return t===e?{selectionStart:i,selectionEnd:i}:{selectionStart:i,selectionEnd:i+r.slice(t,e).join("").length}}_updateTextarea(){if(this.cursorOffsetCache={},this.hiddenTextarea){if(!this.inCompositionMode){let t=this.fromGraphemeToStringSelection(this.selectionStart,this.selectionEnd,this._text);this.hiddenTextarea.selectionStart=t.selectionStart,this.hiddenTextarea.selectionEnd=t.selectionEnd}this.updateTextareaPosition()}}updateFromTextArea(){if(!this.hiddenTextarea)return;this.cursorOffsetCache={};let t=this.hiddenTextarea;this.text=t.value,this.set("dirty",!0),this.initDimensions(),this.setCoords();let 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){let t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.left,this.hiddenTextarea.style.top=t.top}}_calcTextareaPosition(){if(!this.canvas)return{left:"1px",top:"1px"};let t=this.inCompositionMode?this.compositionStart:this.selectionStart,e=this._getCursorBoundaries(t),r=this.get2DCursorLocation(t),i=r.lineIndex,n=r.charIndex,s=this.getValueOfPropertyAt(i,n,"fontSize")*this.lineHeight,o=e.leftOffset,a=this.getCanvasRetinaScaling(),l=this.canvas.upperCanvasEl,h=l.width/a,c=l.height/a,u=h-s,d=c-s,f=new tJ(e.left+o,e.top+e.topOffset+s).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new tJ(l.clientWidth/h,l.clientHeight/c));return f.x<0&&(f.x=0),f.x>u&&(f.x=u),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(s,"px"),charHeight:s}}_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(){let t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){let t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(tX),this.canvas&&(this.canvas.fire("text:editing:exited",{target:this}),t&&this.canvas.fire("object:modified",{target:this})),this}_removeExtraneousStyles(){for(let t in this.styles)this._textLines[t]||delete this.styles[t]}removeStyleFromTo(t,e){let{lineIndex:r,charIndex:i}=this.get2DCursorLocation(t,!0),{lineIndex:n,charIndex:s}=this.get2DCursorLocation(e,!0);if(r!==n){if(this.styles[r])for(let t=i;t<this._unwrappedTextLines[r].length;t++)delete this.styles[r][t];if(this.styles[n])for(let t=s;t<this._unwrappedTextLines[n].length;t++){let e=this.styles[n][t];e&&(this.styles[r]||(this.styles[r]={}),this.styles[r][i+t-s]=e)}for(let t=r+1;t<=n;t++)delete this.styles[t];this.shiftLineStyles(n,r-n)}else if(this.styles[r]){let t=this.styles[r],e=s-i;for(let e=i;e<s;e++)delete t[e];for(let i in this.styles[r]){let r=parseInt(i,10);r>=s&&(t[r-e]=t[i],delete t[i])}}}shiftLineStyles(t,e){let r=Object.assign({},this.styles);for(let i in this.styles){let n=parseInt(i,10);n>t&&(this.styles[n+e]=r[n],r[n-e]||delete this.styles[n])}}insertNewlineStyleObject(t,e,r,i){let n={},s=this._unwrappedTextLines[t].length,o=s===e,a=!1;r||(r=1),this.shiftLineStyles(t,r);let l=this.styles[t]?this.styles[t][0===e?e:e-1]:void 0;for(let r in this.styles[t]){let i=parseInt(r,10);i>=e&&(a=!0,n[i-e]=this.styles[t][r],o&&0===e||delete this.styles[t][r])}let h=!1;for(a&&!o&&(this.styles[t+r]=n,h=!0),(h||s>e)&&r--;r>0;)i&&i[r-1]?this.styles[t+r]={0:tt({},i[r-1])}:l?this.styles[t+r]={0:tt({},l)}:delete this.styles[t+r],r--;this._forceClearCache=!0}insertCharStyleObject(t,e,r,i){this.styles||(this.styles={});let n=this.styles[t],s=n?tt({},n):{};for(let t in r||(r=1),s){let i=parseInt(t,10);i>=e&&(n[i+r]=s[i],s[i-r]||delete n[i])}if(this._forceClearCache=!0,i){for(;r--;)Object.keys(i[r]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+r]=tt({},i[r]));return}if(!n)return;let o=n[e?e-1:1];for(;o&&r--;)this.styles[t][e+r]=tt({},o)}insertNewStyleBlock(t,e,r){let i=this.get2DCursorLocation(e,!0),n=[0],s,o=0;for(let e=0;e<t.length;e++)"\n"===t[e]?n[++o]=0:n[o]++;for(n[0]>0&&(this.insertCharStyleObject(i.lineIndex,i.charIndex,n[0],r),r=r&&r.slice(n[0]+1)),o&&this.insertNewlineStyleObject(i.lineIndex,i.charIndex+n[0],o),s=1;s<o;s++)n[s]>0?this.insertCharStyleObject(i.lineIndex+s,0,n[s],r):r&&this.styles[i.lineIndex+s]&&r[0]&&(this.styles[i.lineIndex+s][0]=r[0]),r=r&&r.slice(n[s]+1);n[s]>0&&this.insertCharStyleObject(i.lineIndex+s,0,n[s],r)}removeChars(t){let e=arguments.length>1&&void 0!==arguments[1]?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,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r;i>r&&this.removeStyleFromTo(r,i);let n=this.graphemeSplit(t);this.insertNewStyleBlock(n,r,e),this._text=[...this._text.slice(0,r),...n,...this._text.slice(i)],this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}setSelectionStartEndWithShift(t,e,r){r<=t?(e===t?this._selectionDirection=tC:this._selectionDirection===tT&&(this._selectionDirection=tC,this.selectionEnd=t),this.selectionStart=r):r>t&&r<e?this._selectionDirection===tT?this.selectionEnd=r:this.selectionStart=r:(e===t?this._selectionDirection=tT:this._selectionDirection===tC&&(this._selectionDirection=tT,this.selectionStart=e),this.selectionEnd=r)}constructor(){super(...arguments),Z(this,"_currentCursorOpacity",1)}}class sX extends sH{initHiddenTextarea(){let t=this.canvas&&eD(this.canvas.getElement())||td(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off"}).map(t=>{let[r,i]=t;return e.setAttribute(r,i)});let{top:r,left:i,fontSize:n}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(r,"; left: ").concat(i,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(n,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map(t=>{let[r,i]=t;return e.addEventListener(r,this[i].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;let e="rtl"===this.direction?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){let e=this.fromPaste,{value:r,selectionStart:i,selectionEnd:n}=this.hiddenTextarea;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;let s=()=>{this.updateFromTextArea(),this.fire(tL),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void s();let o=this._splitTextIntoLines(r).graphemeText,a=this._text.length,l=o.length,h=this.selectionStart,c=this.selectionEnd,u=h!==c,d,f,g,p,m=l-a,y=this.fromStringToGraphemeSelection(i,n,r),x=h>y.selectionStart;u?(f=this._text.slice(h,c),m+=c-h):l<a&&(f=x?this._text.slice(c+m,c):this._text.slice(h,h-m));let b=o.slice(y.selectionEnd-m,y.selectionEnd);if(f&&f.length&&(b.length&&(d=this.getSelectionStyles(h,h+1,!1),d=b.map(()=>d[0])),u?(g=h,p=c):x?(g=c-f.length,p=c):(g=c,p=c+f.length),this.removeStyleFromTo(g,p)),b.length){let{copyPasteData:t}=tu();e&&b.join("")===t.copiedText&&!tn.disableStyleCopyPaste&&(d=t.copiedTextStyle),this.insertNewStyleBlock(b,h,d)}s()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t,{selectionStart:r,selectionEnd:i}=e;this.compositionStart=r,this.compositionEnd=i,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;let{copyPasteData:t}=tu();t.copiedText=this.getSelectedText(),tn.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 r,i=this._getLineLeftOffset(t);return e>0&&(i+=(r=this.__charBounds[t][e-1]).left+r.width),i}getDownCursorOffset(t,e){let r=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(r),n=i.lineIndex;if(n===this._textLines.length-1||t.metaKey||34===t.keyCode)return this._text.length-r;let s=i.charIndex,o=this._getWidthBeforeCursor(n,s),a=this._getIndexOnLine(n+1,o);return this._textLines[n].slice(s).length+a+1+this.missingNewlineOffset(n)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){let r=this._getSelectionForOffset(t,e),i=this.get2DCursorLocation(r),n=i.lineIndex;if(0===n||t.metaKey||33===t.keyCode)return-r;let s=i.charIndex,o=this._getWidthBeforeCursor(n,s),a=this._getIndexOnLine(n-1,o),l=this._textLines[n].slice(0,s),h=this.missingNewlineOffset(n-1);return-this._textLines[n-1].length+a-l.length+(1-h)}_getIndexOnLine(t,e){let r=this._textLines[t],i,n,s=this._getLineLeftOffset(t),o=0;for(let a=0,l=r.length;a<l;a++)if((s+=i=this.__charBounds[t][a].width)>e){n=!0;let t=Math.abs(s-i-e);o=Math.abs(s-e)<t?a:a-1;break}return n||(o=r.length-1),o}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){let r=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===tT);if(e.shiftKey?this.moveCursorWithShift(r):this.moveCursorWithoutShift(r),0!==r){let t=this.text.length;this.selectionStart=rX(0,this.selectionStart,t),this.selectionEnd=rX(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){let e=this._selectionDirection===tC?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),0!==t}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),0!==t}moveCursorLeft(t){0===this.selectionStart&&0===this.selectionEnd||this._moveCursorLeftOrRight("Left",t)}_move(t,e,r){let i;if(t.altKey)i=this["findWordBoundary".concat(r)](this[e]);else{if(!t.metaKey&&35!==t.keyCode&&36!==t.keyCode)return this[e]+="Left"===r?-1:1,!0;i=this["findLineBoundary".concat(r)](this[e])}return void 0!==i&&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=tC,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===tT&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection=tC,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){let r="moveCursor".concat(t).concat(e.shiftKey?"WithShift":"WithoutShift");this._currentCursorOpacity=1,this[r](e)&&(this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea())}moveCursorRightWithShift(t){return this._selectionDirection===tC&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=tT,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=tT,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}class sV extends sX{initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new sW(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:e,alreadySelected:r}=t;this.canvas&&this.editable&&!e.button&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),r&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection()),this.selected||(this.selected=r||this.isEditing)))}mouseUpHandler(t){let{e:e,transform:r}=t,i=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);let t=this.canvas._activeObject;if(t&&t!==this)return}!this.editable||this.group&&!this.group.interactive||r&&r.actionPerformed||e.button||i||this.selected&&!this.getActiveControl()&&(this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection())}setCursorByClick(t){let e=this.getSelectionStartFromPointer(t),r=this.selectionStart,i=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(r,i,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){let e=this.canvas.getScenePoint(t).transform(es(this.calcTransformMatrix())).add(new tJ(-this._getLeftOffset(),-this._getTopOffset())),r=0,i=0,n=0;for(let t=0;t<this._textLines.length&&r<=e.y;t++)r+=this.getHeightOfLine(t),n=t,t>0&&(i+=this._textLines[t-1].length+this.missingNewlineOffset(t-1));let s=Math.abs(this._getLineLeftOffset(n)),o=this._textLines[n].length,a=this.__charBounds[n];for(let t=0;t<o;t++){let r=s+a[t].kernedWidth;if(e.x<=r){Math.abs(e.x-r)<=Math.abs(e.x-s)&&i++;break}s=r,i++}return Math.min(this.flipX?o-i:i,this._text.length)}constructor(){super(...arguments),Z(this,"draggableTextDelegate",void 0)}}let sY="moveCursorUp",sz="moveCursorDown",sG="moveCursorLeft",sq="moveCursorRight",sK="exitEditing",sQ=(t,e)=>{let r=e.getRetinaScaling();t.setTransform(r,0,0,r,0,0);let i=e.viewportTransform;t.transform(i[0],i[1],i[2],i[3],i[4],i[5])},sJ=tt({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:sK,27:sK,33:sY,34:sz,35:sq,36:sG,37:sG,38:sY,39:sq,40:sz},keysMapRtl:{9:sK,27:sK,33:sY,34:sz,35:sG,36:sq,37:sq,38:sY,39:sG,40:sz},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class sZ extends sV{static getDefaults(){return tt(tt({},super.getDefaults()),sZ.ownDefaults)}get type(){let t=super.type;return"itext"===t?"i-text":t}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):("canvas"===t&&(this.canvas instanceof st&&this.canvas.textEditingManager.remove(this),e instanceof st&&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&&void 0!==arguments[0]?arguments[0]:this.selectionStart||0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selectionEnd,r=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,r)}setSelectionStyles(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.selectionStart||0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,r)}get2DCursorLocation(){let t=arguments.length>0&&void 0!==arguments[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){let e=this.isEditing;this.isEditing=!1;let r=super.toCanvasElement(t);return this.isEditing=e,r}renderCursorOrSelection(){if(!this.isEditing||!this.canvas)return;let t=this.clearContextTop(!0);if(!t)return;let e=this._getCursorBoundaries(),r=this.findAncestorsWithClipPath(),i=r.length>0,n,s=t;if(i){sQ(s=(n=t8(t.canvas)).getContext("2d"),this.canvas);let e=this.calcTransformMatrix();s.transform(e[0],e[1],e[2],e[3],e[4],e[5])}if(this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(s,e):this.renderCursor(s,e),i)for(let e of r){let r=e.clipPath,i=t8(t.canvas),n=i.getContext("2d");if(sQ(n,this.canvas),!r.absolutePositioned){let t=e.calcTransformMatrix();n.transform(t[0],t[1],t[2],t[3],t[4],t[5])}r.transform(n),r.drawObject(n,!0,{}),this.drawClipPathOnCache(s,r,i)}i&&(t.setTransform(1,0,0,1,0,0),t.drawImage(n,0,0)),this.canvas.contextTopDirty=!0,t.restore()}findAncestorsWithClipPath(){let t=[],e=this;for(;e;)e.clipPath&&t.push(e),e=e.parent;return t}_getCursorBoundaries(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0,r=this._getLeftOffset(),i=this._getTopOffset(),n=this._getCursorBoundariesOffsets(t,e);return{left:r,top:i,leftOffset:n.left,topOffset:n.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,r=0,{charIndex:i,lineIndex:n}=this.get2DCursorLocation(t);for(let t=0;t<n;t++)e+=this.getHeightOfLine(t);let s=this._getLineLeftOffset(n),o=this.__charBounds[n][i];o&&(r=o.left),0!==this.charSpacing&&i===this._textLines[n].length&&(r-=this._getWidthOfCharSpacing());let a={top:e,left:s+(r>0?r:0)};return"rtl"===this.direction&&(this.textAlign===tT||this.textAlign===rv||this.textAlign===rx?a.left*=-1:this.textAlign===tC||this.textAlign===ry?a.left=s-(r>0?r:0):this.textAlign!==tw&&this.textAlign!==rb||(a.left=s-(r>0?r:0))),a}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&&void 0!==arguments[0]?arguments[0]:this.selectionStart,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._getCursorBoundaries(t),r=this.get2DCursorLocation(t),i=r.lineIndex,n=r.charIndex>0?r.charIndex-1:0,s=this.getValueOfPropertyAt(i,n,"fontSize"),o=this.getObjectScaling().x*this.canvas.getZoom(),a=this.cursorWidth/o,l=this.getValueOfPropertyAt(i,n,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(i)/this.lineHeight-s*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(i,n,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-a/2,top:h+e.top+l,width:a,height:s}}_renderCursor(t,e,r){let{color:i,opacity:n,left:s,top:o,width:a,height:l}=this.getCursorRenderingData(r,e);t.fillStyle=i,t.globalAlpha=n,t.fillRect(s,o,a,l)}renderSelection(t,e){let r={selectionStart:this.inCompositionMode?this.hiddenTextarea.selectionStart:this.selectionStart,selectionEnd:this.inCompositionMode?this.hiddenTextarea.selectionEnd:this.selectionEnd};this._renderSelection(t,r,e)}renderDragSourceEffect(){let t=this.draggableTextDelegate.getDragStartSelection();this._renderSelection(this.canvas.contextTop,t,this._getCursorBoundaries(t.selectionStart,!0))}renderDropTargetEffect(t){let e=this.getSelectionStartFromPointer(t);this.renderCursorAt(e)}_renderSelection(t,e,r){let i=e.selectionStart,n=e.selectionEnd,s=this.textAlign.includes(rv),o=this.get2DCursorLocation(i),a=this.get2DCursorLocation(n),l=o.lineIndex,h=a.lineIndex,c=o.charIndex<0?0:o.charIndex,u=a.charIndex<0?0:a.charIndex;for(let e=l;e<=h;e++){let i=this._getLineLeftOffset(e)||0,n=this.getHeightOfLine(e),o=0,a=0,d=0;if(e===l&&(a=this.__charBounds[l][c].left),e>=l&&e<h)d=s&&!this.isEndOfWrapping(e)?this.width:this.getLineWidth(e)||5;else if(e===h)if(0===u)d=this.__charBounds[h][u].left;else{let t=this._getWidthOfCharSpacing();d=this.__charBounds[h][u-1].left+this.__charBounds[h][u-1].width-t}o=n,(this.lineHeight<1||e===h&&this.lineHeight>1)&&(n/=this.lineHeight);let f=r.left+i+a,g=n,p=0,m=d-a;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",g=1,p=n):t.fillStyle=this.selectionColor,"rtl"===this.direction&&(this.textAlign===tT||this.textAlign===rv||this.textAlign===rx?f=this.width-f-m:this.textAlign===tC||this.textAlign===ry?f=r.left+i-d:this.textAlign!==tw&&this.textAlign!==rb||(f=r.left+i-d)),t.fillRect(f,r.top+r.topOffset+p,m,g),r.topOffset+=o}}getCurrentCharFontSize(){let t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){let t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,tU)}_getCurrentCharIndex(){let t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}constructor(t,e){super(t,tt(tt({},sZ.ownDefaults),e)),this.initBehavior()}}Z(sZ,"ownDefaults",sJ),Z(sZ,"type","IText"),tY.setClass(sZ),tY.setClass(sZ,"i-text");class s$ extends sZ{static getDefaults(){return tt(tt({},super.getDefaults()),s$.ownDefaults)}static createControls(){return{controls:iI()}}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(rv)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,r=0,i=0,n={};for(let s=0;s<t.graphemeLines.length;s++)"\n"===t.graphemeText[i]&&s>0?(r=0,i++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[i])&&s>0&&(r++,i++),n[s]={line:e,offset:r},i+=t.graphemeLines[s].length,r+=t.graphemeLines[s].length;return n}styleHas(t,e){if(this._styleMap&&!this.isWrapping){let t=this._styleMap[e];t&&(e=t.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,r=0,i=!1,n=this._styleMap[t],s=this._styleMap[t+1];n&&(t=n.line,r=n.offset),s&&(i=s.line===t,e=s.offset);let o=void 0===t?this.styles:{line:this.styles[t]};for(let t in o)for(let n in o[t]){let s=parseInt(n,10);if(s>=r&&(!i||s<e))for(let e in o[t][n])return!1}return!0}_getStyleDeclaration(t,e){if(this._styleMap&&!this.isWrapping){let r=this._styleMap[t];if(!r)return{};t=r.line,e=r.offset+e}return super._getStyleDeclaration(t,e)}_setStyleDeclaration(t,e,r){let i=this._styleMap[t];super._setStyleDeclaration(i.line,i.offset+e,r)}_deleteStyleDeclaration(t,e){let r=this._styleMap[t];super._deleteStyleDeclaration(r.line,r.offset+e)}_getLineStyle(t){let e=this._styleMap[t];return!!this.styles[e.line]}_setLineStyle(t){let e=this._styleMap[t];super._setLineStyle(e.line)}_wrapText(t,e){this.isWrapping=!0;let r=this.getGraphemeDataForRender(t),i=[];for(let t=0;t<r.wordsData.length;t++)i.push(...this._wrapLine(t,e,r));return this.isWrapping=!1,i}getGraphemeDataForRender(t){let e=this.splitByGrapheme,r=e?"":" ",i=0;return{wordsData:t.map((t,n)=>{let s=0,o=e?this.graphemeSplit(t):this.wordSplit(t);return 0===o.length?[{word:[],width:0}]:o.map(t=>{let o=e?[t]:this.graphemeSplit(t),a=this._measureWord(o,n,s);return i=Math.max(a,i),s+=o.length+r.length,{word:o,width:a}})}),largestWordWidth:i}}_measureWord(t,e){let r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=0;for(let s=0,o=t.length;s<o;s++)n+=this._getGraphemeBox(t[s],e,s+i,r,!0).kernedWidth,r=t[s];return n}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,r){let i,{largestWordWidth:n,wordsData:s}=r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,h=[],c=l?"":" ",u=0,d=[],f=0,g=0,p=!0,m=Math.max(e-=o,n,this.dynamicMinWidth),y=s[t];for(f=0,i=0;i<y.length;i++){let{word:e,width:r}=y[i];f+=e.length,(u+=g+r-a)>m&&!p?(h.push(d),d=[],u=r,p=!0):u+=a,p||l||d.push(c),d=d.concat(e),g=l?0:this._measureWord([c],t,f),f++,p=!1}return i&&h.push(d),n+o>this.dynamicMinWidth&&(this.dynamicMinWidth=n-a+o),h}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?+!!this.isEndOfWrapping(t):1}_splitTextIntoLines(t){let e=super._splitTextIntoLines(t),r=this._wrapText(e.lines,this.width),i=Array(r.length);for(let t=0;t<r.length;t++)i[t]=r[t].join("");return e.lines=i,e.graphemeLines=r,e}getMinWidth(){return Math.max(this.minWidth,this.dynamicMinWidth)}_removeExtraneousStyles(){let t=new Map;for(let e in this._styleMap){let r=parseInt(e,10);if(this._textLines[r]){let r=this._styleMap[e].line;t.set("".concat(r),!0)}}for(let e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}constructor(t,e){super(t,tt(tt({},s$.ownDefaults),e))}}Z(s$,"type","Textbox"),Z(s$,"textLayoutProperties",[...sZ.textLayoutProperties,"width"]),Z(s$,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),tY.setClass(s$);class s0 extends ny{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){let{target:r}=t,{clipPath:i,group:n}=r;if(!i||!this.shouldPerformLayout(t))return;let{width:s,height:o}=eH(nv(r,i)),a=new tJ(s,o);if(i.absolutePositioned)return{center:eQ(i.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:a};{let n=i.getRelativeCenterPoint().transform(r.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){let{center:r=new tJ,correction:i=new tJ}=this.calcBoundingBox(e,t)||{};return{center:r.add(n),correction:i.subtract(n),size:a}}return{center:r.getRelativeCenterPoint().add(n),size:a}}}}Z(s0,"type","clip-path"),tY.setClass(s0);class s1 extends ny{getInitialSize(t,e){let{target:r}=t,{size:i}=e;return new tJ(r.width||i.x,r.height||i.y)}}Z(s1,"type","fixed"),tY.setClass(s1);class s2 extends nC{subscribeTargets(t){let e=t.target;t.targets.reduce((t,e)=>(e.parent&&t.add(e.parent),t),new Set).forEach(t=>{t.layoutManager.subscribeTargets({target:t,targets:[e]})})}unsubscribeTargets(t){let e=t.target,r=e.getObjects();t.targets.reduce((t,e)=>(e.parent&&t.add(e.parent),t),new Set).forEach(t=>{r.some(e=>e.parent===t)||t.layoutManager.unsubscribeTargets({target:t,targets:[e]})})}}class s5 extends nO{static getDefaults(){return tt(tt({},super.getDefaults()),s5.ownDefaults)}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];"selection-order"===this.multiSelectionStacking?this.add(...e):e.forEach(t=>{let e=this._objects.findIndex(e=>e.isInFrontOf(t)),r=-1===e?this.size():e;this.insertAt(r,t)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(ts("error","ActiveSelection: circular object trees are not supported, this call has no effect"),!1):super.canEnterGroup(t)}enterGroup(t,e){t.parent&&t.parent===t.group?t.parent._exitGroup(t):t.group&&t.parent!==t.group&&t.group.remove(t),this._enterGroup(t,e)}exitGroup(t,e){this._exitGroup(t,e),t.parent&&t.parent._enterGroup(t,!0)}_onAfterObjectsChange(t,e){super._onAfterObjectsChange(t,e);let r=new Set;e.forEach(t=>{let{parent:e}=t;e&&r.add(e)}),t===np?r.forEach(t=>{t._onAfterObjectsChange(ng,e)}):r.forEach(t=>{t._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,r){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;let i=tt(tt({hasControls:!1},r),{},{forActiveSelection:!0});for(let e=0;e<this._objects.length;e++)this._objects[e]._renderControls(t,i);super._renderControls(t,e),t.restore()}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,s5.ownDefaults),this.setOptions(e);let{left:r,top:i,layoutManager:n}=e;this.groupInit(t,{left:r,top:i,layoutManager:null!=n?n:new s2})}}Z(s5,"type","ActiveSelection"),Z(s5,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),tY.setClass(s5),tY.setClass(s5,"activeSelection");class s4{applyFilters(t,e,r,i,n){let s=n.getContext("2d");if(!s)return;s.drawImage(e,0,0,r,i);let o={sourceWidth:r,sourceHeight:i,imageData:s.getImageData(0,0,r,i),originalEl:e,originalImageData:s.getImageData(0,0,r,i),canvasEl:n,ctx:s,filterBackend:this};t.forEach(t=>{t.applyTo(o)});let{imageData:a}=o;return a.width===r&&a.height===i||(n.width=a.width,n.height=a.height),s.putImageData(a,0,0),o}constructor(){Z(this,"resources",{})}}class s3{setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){let r=t8({width:t,height:e}),i=r.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});i&&(i.clearColor(0,0,0,0),this.canvas=r,this.gl=i)}applyFilters(t,e,r,i,n,s){let o,a=this.gl,l=n.getContext("2d");if(!a||!l)return;s&&(o=this.getCachedTexture(s,e));let h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:r,sourceHeight:i,destinationWidth:r,destinationHeight:i,context:a,sourceTexture:this.createTexture(a,r,i,o?void 0:e),targetTexture:this.createTexture(a,r,i),originalTexture:o||this.createTexture(a,r,i,o?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},c=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,c),t.forEach(t=>{t&&t.applyTo(h)}),function(t){let e=t.targetCanvas,r=e.width,i=e.height,n=t.destinationWidth,s=t.destinationHeight;r===n&&i===s||(e.width=n,e.height=s)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(c),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,r,i,n){let{NEAREST:s,TEXTURE_2D:o,RGBA:a,UNSIGNED_BYTE:l,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:c,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:d,TEXTURE_WRAP_T:f}=t,g=t.createTexture();return t.bindTexture(o,g),t.texParameteri(o,c,n||s),t.texParameteri(o,u,n||s),t.texParameteri(o,d,h),t.texParameteri(o,f,h),i?t.texImage2D(o,0,a,a,l,i):t.texImage2D(o,0,a,e,r,0,a,l,null),g}getCachedTexture(t,e,r){let{textureCache:i}=this;if(i[t])return i[t];{let n=this.createTexture(this.gl,e.width,e.height,e,r);return n&&(i[t]=n),n}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){let r=t.canvas,i=e.targetCanvas,n=i.getContext("2d");if(!n)return;n.translate(0,i.height),n.scale(1,-1);let s=r.height-i.height;n.drawImage(r,0,s,i.width,i.height,0,0,i.width,i.height)}copyGLTo2DPutImageData(t,e){let r=e.targetCanvas.getContext("2d"),i=e.destinationWidth,n=e.destinationHeight,s=i*n*4;if(!r)return;let o=new Uint8Array(this.imageBuffer,0,s),a=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,i,n,t.RGBA,t.UNSIGNED_BYTE,o);let l=new ImageData(a,i,n);r.putImageData(l,0,0)}captureGPUInfo(){if(this.gpuInfo)return this.gpuInfo;let t=this.gl,e={renderer:"",vendor:""};if(!t)return e;let r=t.getExtension("WEBGL_debug_renderer_info");if(r){let i=t.getParameter(r.UNMASKED_RENDERER_WEBGL),n=t.getParameter(r.UNMASKED_VENDOR_WEBGL);i&&(e.renderer=i.toLowerCase()),n&&(e.vendor=n.toLowerCase())}return this.gpuInfo=e,e}constructor(){let{tileSize:t=tn.textureSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Z(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),Z(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}}function s9(){return n||arguments.length>0&&void 0!==arguments[0]&&!arguments[0]||(n=function(){let{WebGLProbe:t}=tu();return t.queryWebGL(t9()),tn.enableGLFiltering&&t.isSupported(tn.textureSize)?new s3({tileSize:tn.textureSize}):new s4}()),n}let s6=["filters","resizeFilter","src","crossOrigin","type"],s8=["cropX","cropY"];class s7 extends iW{static getDefaults(){return tt(tt({},super.getDefaults()),s7.ownDefaults)}getElement(){return this._element}setElement(t){var e;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(r),null==(e=t.classList)||e.add(s7.CSS_CANVAS),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){let e=s9(!1);e instanceof s3&&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=>{let e=this[t];e&&tu().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){let t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||0===this.strokeWidth)return;let e=this.width/2,r=this.height/2;t.beginPath(),t.moveTo(-e,-r),t.lineTo(e,-r),t.lineTo(e,r),t.lineTo(-e,r),t.lineTo(-e,-r),t.closePath()}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=[];return this.filters.forEach(t=>{t&&e.push(t.toObject())}),tt(tt({},super.toObject([...s8,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width<this._element.width||this.height<this._element.height}_toSVG(){let t=[],e=this._element,r=-this.width/2,i=-this.height/2,n=[],s=[],o="",a="";if(!e)return[];if(this.hasCrop()){let t=t3();n.push('<clipPath id="imageCrop_'+t+'">\n',' <rect x="'+r+'" y="'+i+'" width="'+this.width+'" height="'+this.height+'" />\n',"</clipPath>\n"),o=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(a=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(r-this.cropX,'" y="').concat(i-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(a).concat(o,"></image>\n")),this.stroke||this.strokeDashArray){let t=this.fill;this.fill=null,s=[' <rect x="'.concat(r,'" y="').concat(i,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),'" />\n')],this.fill=t}return this.paintFirst!==tU?n.concat(s,t):n.concat(t,s)}getSrc(t){let e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ey(t,{crossOrigin:e,signal:r}).then(t=>{void 0!==e&&this.set({crossOrigin:e}),this.setElement(t)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){let t=this.resizeFilter,e=this.minimumScaleTrigger,r=this.getTotalObjectScaling(),i=r.x,n=r.y,s=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||i>e&&n>e)return this._element=s,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=i,void(this._lastScaleY=n);let o=t8(s),{width:a,height:l}=s;this._element=o,this._lastScaleX=t.scaleX=i,this._lastScaleY=t.scaleY=n,s9().applyFilters([t],s,a,l,this._element),this._filterScalingX=o.width/this._originalElement.width,this._filterScalingY=o.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.filters||[];if(t=t.filter(t=>t&&!t.isNeutralState()),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),0===t.length)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);let e=this._originalElement,r=e.naturalWidth||e.width,i=e.naturalHeight||e.height;if(this._element===this._originalElement){let t=t8({width:r,height:i});this._element=t,this._filteredEl=t}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,r,i),this._lastScaleX=1,this._lastScaleY=1);s9().applyFilters(t,this._originalElement,r,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,!0!==this.isMoving&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){let e=this._element;if(!e)return;let r=this._filterScalingX,i=this._filterScalingY,n=this.width,s=this.height,o=Math.max(this.cropX,0),a=Math.max(this.cropY,0),l=e.naturalWidth||e.width,h=e.naturalHeight||e.height,c=o*r,u=a*i,d=Math.min(n*r,l-c),f=Math.min(s*i,h-u),g=Math.min(n,l/r-o),p=Math.min(s,h/i-a);e&&t.drawImage(e,c,u,d,f,-n/2,-s/2,g,p)}_needsResize(){let 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&&void 0!==arguments[0]?arguments[0]:{},r=this.getOriginalSize();this.width=t||r.width,this.height=e||r.height}parsePreserveAspectRatioAttribute(){let t=ra(this.preserveAspectRatio||""),e=this.width,r=this.height,i={width:e,height:r},n,s=this._element.width,o=this._element.height,a=1,l=1,h=0,c=0,u=0,d=0;return t&&(t.alignX!==tO||t.alignY!==tO)?("meet"===t.meetOrSlice&&(n=(e-s*(a=l=nk(this._element,i)))/2,"Min"===t.alignX&&(h=-n),"Max"===t.alignX&&(h=n),n=(r-o*l)/2,"Min"===t.alignY&&(c=-n),"Max"===t.alignY&&(c=n)),"slice"===t.meetOrSlice&&(n=s-e/(a=l=nM(this._element,i)),"Mid"===t.alignX&&(u=n/2),"Max"===t.alignX&&(u=n),n=o-r/l,"Mid"===t.alignY&&(d=n/2),"Max"===t.alignY&&(d=n),s=e/a,o=r/l)):(a=e/s,l=r/o),{width:s,height:o,scaleX:a,scaleY:l,offsetLeft:h,offsetTop:c,cropX:u,cropY:d}}static fromObject(t,e){let{filters:r,resizeFilter:i,src:n,crossOrigin:s,type:o}=t,a=te(t,s6);return Promise.all([ey(n,tt(tt({},e),{},{crossOrigin:s})),r&&ex(r,e),i&&ex([i],e),eb(a,e)]).then(t=>{let[e,r=[],[i]=[],s={}]=t;return new this(e,tt(tt({},a),{},{src:n,filters:r,resizeFilter:i},s))})}static fromURL(t){let{crossOrigin:e=null,signal:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;return ey(t,{crossOrigin:e,signal:r}).then(t=>new this(t,i))}static async fromElement(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,i=nh(t,this.ATTRIBUTE_NAMES,r);return this.fromURL(i["xlink:href"]||i.href,e,i).catch(t=>(ts("log","Unable to parse Image",t),null))}constructor(t,e){super(),Z(this,"_lastScaleX",1),Z(this,"_lastScaleY",1),Z(this,"_filterScalingX",1),Z(this,"_filterScalingY",1),this.filters=[],Object.assign(this,s7.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(t3()),this.setElement("string"==typeof t?(this.canvas&&eD(this.canvas.getElement())||td()).getElementById(t):t,e)}}Z(s7,"type","Image"),Z(s7,"cacheProperties",[...rY,...s8]),Z(s7,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),Z(s7,"CSS_CANVAS","canvas-img"),Z(s7,"ATTRIBUTE_NAMES",[...i2,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),tY.setClass(s7),tY.setSVGClass(s7),rc(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);let ot=t=>function(e,r,i){let{points:n,pathOffset:s}=i;return new tJ(n[t]).subtract(s).transform(eo(i.getViewportTransform(),i.calcTransformMatrix()))},oe=(t,e,r,i)=>{let{target:n,pointIndex:s}=e,o=eQ(new tJ(r,i),void 0,n.calcOwnMatrix());return n.points[s]=o.add(n.pathOffset),n.setDimensions(),n.set("dirty",!0),!0},or=(t,e)=>function(r,i,n,s){let o=i.target,a=new tJ(o.points[(t>0?t:o.points.length)-1]),l=a.subtract(o.pathOffset).transform(o.calcOwnMatrix()),h=e(r,tt(tt({},i),{},{pointIndex:t}),n,s),c=a.subtract(o.pathOffset).transform(o.calcOwnMatrix()).subtract(l);return o.left-=c.x,o.top-=c.y,h},oi=t=>io(tF,or(t,oe)),on=(t,e,r)=>{let{path:i,pathOffset:n}=t,s=i[e];return new tJ(s[r]-n.x,s[r+1]-n.y).transform(eo(t.getViewportTransform(),t.calcTransformMatrix()))};function os(t,e,r){let{commandIndex:i,pointIndex:n}=this;return on(r,i,n)}function oo(t,e,r,i){let{target:n}=e,{commandIndex:s,pointIndex:o}=this,a=((t,e,r,i,n)=>{let{path:s,pathOffset:o}=t,a=s[(i>0?i:s.length)-1],l=new tJ(a[n],a[n+1]),h=l.subtract(o).transform(t.calcOwnMatrix()),c=eQ(new tJ(e,r),void 0,t.calcOwnMatrix());s[i][n]=c.x+o.x,s[i][n+1]=c.y+o.y,t.setDimensions();let u=l.subtract(t.pathOffset).transform(t.calcOwnMatrix()).subtract(h);return t.left-=u.x,t.top-=u.y,t.set("dirty",!0),!0})(n,r,i,s,o);return e$(this.actionName,tt(tt({},e3(t,e,r,i)),{},{commandIndex:s,pointIndex:o})),a}class oa extends iu{render(t,e,r,i,n){let s=tt(tt({},i),{},{cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill});super.render(t,e,r,s,n)}constructor(t){super(t)}}class ol extends oa{render(t,e,r,i,n){let{path:s}=n,{commandIndex:o,pointIndex:a,connectToCommandIndex:l,connectToPointIndex:h}=this;t.save(),t.strokeStyle=this.controlStroke,this.connectionDashArray&&t.setLineDash(this.connectionDashArray);let[c]=s[o],u=on(n,l,h);if("Q"===c){let i=on(n,o,a+2);t.moveTo(i.x,i.y),t.lineTo(e,r)}else t.moveTo(e,r);t.lineTo(u.x,u.y),t.stroke(),t.restore(),super.render(t,e,r,i,n)}constructor(t){super(t)}}let oh=(t,e,r,i,n,s)=>new(r?ol:oa)(tt(tt({commandIndex:t,pointIndex:e,actionName:"modifyPath",positionHandler:os,actionHandler:oo,connectToCommandIndex:n,connectToPointIndex:s},i),r?i.controlPointStyle:i.pointStyle));Object.freeze({__proto__:null,changeWidth:il,createObjectDefaultControls:iL,createPathControls:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={},i="M";return t.path.forEach((t,n)=>{let s=t[0];switch("Z"!==s&&(r["c_".concat(n,"_").concat(s)]=oh(n,t.length-2,!1,e)),s){case"C":let o;r["c_".concat(n,"_C_CP_1")]=oh(n,1,!0,e,n-1,"C"===(o=i)?5:"Q"===o?3:1),r["c_".concat(n,"_C_CP_2")]=oh(n,3,!0,e,n,5);break;case"Q":r["c_".concat(n,"_Q_CP_1")]=oh(n,1,!0,e,n,3)}i=s}),r},createPolyActionHandler:oi,createPolyControls:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={};for(let i=0;i<("number"==typeof t?t:t.points.length);i++)r["p".concat(i)]=new iu(tt({actionName:tF,positionHandler:ot(i),actionHandler:oi(i)},e));return r},createPolyPositionHandler:ot,createResizeControls:iR,createTextboxDefaultControls:iI,dragHandler:e8,factoryPolyActionHandler:or,getLocalPoint:e6,polyActionHandler:oe,renderCircleControl:ih,renderSquareControl:ic,rotationStyleHandler:id,rotationWithSnapping:ig,scaleCursorStyleHandler:iy,scaleOrSkewActionName:ij,scaleSkewCursorStyleHandler:iA,scalingEqually:ib,scalingX:i_,scalingXOrSkewingY:iP,scalingY:iw,scalingYOrSkewingX:iF,skewCursorStyleHandler:iO,skewHandlerX:iM,skewHandlerY:iE,wrapWithFireEvent:io,wrapWithFixedAnchor:ia});let oc="precision highp float",ou="\n ".concat(oc,";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }"),od=["type"],of=["type"],og=RegExp(oc,"g");class op{get type(){return this.constructor.type}getFragmentSource(){return ou}getVertexSource(){return"\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n void main() {\n vTexCoord = aPosition;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }"}createProgram(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.getFragmentSource(),r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.getVertexSource(),{WebGLProbe:{GLPrecision:i="highp"}}=tu();"highp"!==i&&(e=e.replace(og,oc.replace("highp",i)));let n=t.createShader(t.VERTEX_SHADER),s=t.createShader(t.FRAGMENT_SHADER),o=t.createProgram();if(!n||!s||!o)throw new to("Vertex, fragment shader or program creation error");if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new to("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(n)));if(t.shaderSource(s,e),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw new to("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(s)));if(t.attachShader(o,n),t.attachShader(o,s),t.linkProgram(o),!t.getProgramParameter(o,t.LINK_STATUS))throw new to('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(o)));let a=this.getUniformLocations(t,o)||{};return a.uStepW=t.getUniformLocation(o,"uStepW"),a.uStepH=t.getUniformLocation(o,"uStepH"),{program:o,attributeLocations:this.getAttributeLocations(t,o),uniformLocations:a}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){let r=this.constructor.uniformLocations,i={};for(let n=0;n<r.length;n++)i[r[n]]=t.getUniformLocation(e,r[n]);return i}sendAttributeData(t,e,r){let i=e.aPosition,n=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,n),t.enableVertexAttribArray(i),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW)}_setupFrameBuffer(t){let e=t.context;if(t.passes>1){let r=t.destinationWidth,i=t.destinationHeight;t.sourceWidth===r&&t.sourceHeight===i||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,r,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++;let e=t.targetTexture;t.targetTexture=t.sourceTexture,t.sourceTexture=e}isNeutralState(t){return!1}applyTo(t){void 0!==t.webgl?(this._setupFrameBuffer(t),this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){}getCacheKey(){return this.type}retrieveShader(t){let e=this.getCacheKey();return t.programCache[e]||(t.programCache[e]=this.createProgram(t.context)),t.programCache[e]}applyToWebGL(t){let e=t.context,r=this.retrieveShader(t);0===t.pass&&t.originalTexture?e.bindTexture(e.TEXTURE_2D,t.originalTexture):e.bindTexture(e.TEXTURE_2D,t.sourceTexture),e.useProgram(r.program),this.sendAttributeData(e,r.attributeLocations,t.aPosition),e.uniform1f(r.uniformLocations.uStepW,1/t.sourceWidth),e.uniform1f(r.uniformLocations.uStepH,1/t.sourceHeight),this.sendUniformData(e,r.uniformLocations),e.viewport(0,0,t.destinationWidth,t.destinationHeight),e.drawArrays(e.TRIANGLE_STRIP,0,4)}bindAdditionalTexture(t,e,r){t.activeTexture(r),t.bindTexture(t.TEXTURE_2D,e),t.activeTexture(t.TEXTURE0)}unbindAdditionalTexture(t,e){t.activeTexture(e),t.bindTexture(t.TEXTURE_2D,null),t.activeTexture(t.TEXTURE0)}sendUniformData(t,e){}createHelpLayer(t){if(!t.helpLayer){let{sourceWidth:e,sourceHeight:r}=t;t.helpLayer=t8({width:e,height:r})}}toObject(){let t=Object.keys(this.constructor.defaults||{});return tt({type:this.type},t.reduce((t,e)=>(t[e]=this[e],t),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(te(t,of))}constructor(){let t=te(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},od);Object.assign(this,this.constructor.defaults,t)}}Z(op,"type","BaseFilter"),Z(op,"uniformLocations",[]);let om={multiply:"gl_FragColor.rgb *= uColor.rgb;\n",screen:"gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\n",add:"gl_FragColor.rgb += uColor.rgb;\n",difference:"gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\n",subtract:"gl_FragColor.rgb -= uColor.rgb;\n",lighten:"gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\n",darken:"gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\n",exclusion:"gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\n",overlay:"\n if (uColor.r < 0.5) {\n gl_FragColor.r *= 2.0 * uColor.r;\n } else {\n gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);\n }\n if (uColor.g < 0.5) {\n gl_FragColor.g *= 2.0 * uColor.g;\n } else {\n gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);\n }\n if (uColor.b < 0.5) {\n gl_FragColor.b *= 2.0 * uColor.b;\n } else {\n gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);\n }\n ",tint:"\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n "};class ov extends op{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n gl_FragColor = color;\n if (color.a > 0.0) {\n ".concat(om[this.mode],"\n }\n }\n ")}applyTo2d(t){let{imageData:{data:e}}=t,r=new rs(this.color).getSource(),i=this.alpha,n=r[0]*i,s=r[1]*i,o=r[2]*i,a=1-i;for(let t=0;t<e.length;t+=4){let r,i,l,h=e[t],c=e[t+1],u=e[t+2];switch(this.mode){case"multiply":r=h*n/255,i=c*s/255,l=u*o/255;break;case"screen":r=255-(255-h)*(255-n)/255,i=255-(255-c)*(255-s)/255,l=255-(255-u)*(255-o)/255;break;case"add":r=h+n,i=c+s,l=u+o;break;case"difference":r=Math.abs(h-n),i=Math.abs(c-s),l=Math.abs(u-o);break;case"subtract":r=h-n,i=c-s,l=u-o;break;case"darken":r=Math.min(h,n),i=Math.min(c,s),l=Math.min(u,o);break;case"lighten":r=Math.max(h,n),i=Math.max(c,s),l=Math.max(u,o);break;case"overlay":r=n<128?2*h*n/255:255-2*(255-h)*(255-n)/255,i=s<128?2*c*s/255:255-2*(255-c)*(255-s)/255,l=o<128?2*u*o/255:255-2*(255-u)*(255-o)/255;break;case"exclusion":r=n+h-2*n*h/255,i=s+c-2*s*c/255,l=o+u-2*o*u/255;break;case"tint":r=n+h*a,i=s+c*a,l=o+u*a}e[t]=r,e[t+1]=i,e[t+2]=l}}sendUniformData(t,e){let r=new rs(this.color).getSource();r[0]=this.alpha*r[0]/255,r[1]=this.alpha*r[1]/255,r[2]=this.alpha*r[2]/255,r[3]=this.alpha,t.uniform4fv(e.uColor,r)}}Z(ov,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),Z(ov,"type","BlendColor"),Z(ov,"uniformLocations",["uColor"]),tY.setClass(ov);let oy={multiply:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform sampler2D uImage;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec4 color2 = texture2D(uImage, vTexCoord2);\n color.rgba *= color2.rgba;\n gl_FragColor = color;\n }\n ",mask:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform sampler2D uImage;\n uniform vec4 uColor;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec4 color2 = texture2D(uImage, vTexCoord2);\n color.a = color2.a;\n gl_FragColor = color;\n }\n "},ox=["type","image"];class ob extends op{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return oy[this.mode]}getVertexSource(){return"\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n "}applyToWebGL(t){let e=t.context,r=this.createTexture(t.filterBackend,this.image);this.bindAdditionalTexture(e,r,e.TEXTURE1),super.applyToWebGL(t),this.unbindAdditionalTexture(e,e.TEXTURE1)}createTexture(t,e){return t.getCachedTexture(e.cacheKey,e.getElement())}calculateMatrix(){let t=this.image,{width:e,height:r}=t.getElement();return[1/t.scaleX,0,0,0,1/t.scaleY,0,-t.left/e,-t.top/r,1]}applyTo2d(t){let{imageData:{data:e,width:r,height:i},filterBackend:{resources:n}}=t,s=this.image;n.blendImage||(n.blendImage=t9());let o=n.blendImage,a=o.getContext("2d");o.width!==r||o.height!==i?(o.width=r,o.height=i):a.clearRect(0,0,r,i),a.setTransform(s.scaleX,0,0,s.scaleY,s.left,s.top),a.drawImage(s.getElement(),0,0,r,i);let l=a.getImageData(0,0,r,i).data;for(let t=0;t<e.length;t+=4){let r=e[t],i=e[t+1],n=e[t+2],s=e[t+3],o=l[t],a=l[t+1],h=l[t+2],c=l[t+3];switch(this.mode){case"multiply":e[t]=r*o/255,e[t+1]=i*a/255,e[t+2]=n*h/255,e[t+3]=s*c/255;break;case"mask":e[t+3]=c}}}sendUniformData(t,e){let r=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,r)}toObject(){return tt(tt({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:r,image:i}=t,n=te(t,ox);return s7.fromObject(i,e).then(t=>new this(tt(tt({},n),{},{image:t})))}}Z(ob,"type","BlendImage"),Z(ob,"defaults",{mode:"multiply",alpha:1}),Z(ob,"uniformLocations",["uTransformMatrix","uImage"]),tY.setClass(ob);class o_ extends op{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n const float nSamples = 15.0;\n vec3 v3offset = vec3(12.9898, 78.233, 151.7182);\n float random(vec3 scale) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);\n }\n void main() {\n vec4 color = vec4(0.0);\n float totalC = 0.0;\n float totalA = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n vec4 sample = texture2D(uTexture, vTexCoord + uDelta * percent);\n float weight = 1.0 - abs(percent);\n float alpha = weight * sample.a;\n color.rgb += sample.rgb * alpha;\n color.a += alpha;\n totalA += weight;\n totalC += alpha;\n }\n gl_FragColor.rgb = color.rgb / totalC;\n gl_FragColor.a = color.a / totalA;\n }\n "}applyTo(t){void 0!==t.webgl?(this.aspectRatio=t.sourceWidth/t.sourceHeight,t.passes++,this._setupFrameBuffer(t),this.horizontal=!0,this.applyToWebGL(t),this._swapTextures(t),this._setupFrameBuffer(t),this.horizontal=!1,this.applyToWebGL(t),this._swapTextures(t)):this.applyTo2d(t)}applyTo2d(t){let{imageData:{data:e,width:r,height:i}}=t;this.aspectRatio=r/i,this.horizontal=!0;let n=this.getBlurValue()*r,s=new Uint8ClampedArray(e),o=4*r;for(let t=0;t<e.length;t+=4){let r=0,i=0,a=0,l=0,h=0,c=t-t%o,u=c+o;for(let s=-14;s<15;s++){let o=s/15,d=4*Math.floor(n*o),f=1-Math.abs(o),g=t+d;g<c?g=c:g>u&&(g=u);let p=e[g+3]*f;r+=e[g]*p,i+=e[g+1]*p,a+=e[g+2]*p,l+=p,h+=f}s[t]=r/l,s[t+1]=i/l,s[t+2]=a/l,s[t+3]=l/h}this.horizontal=!1,n=this.getBlurValue()*i;for(let t=0;t<s.length;t+=4){let r=0,i=0,a=0,l=0,h=0,c=t%o,u=s.length-o+c;for(let e=-14;e<15;e++){let d=e/15,f=Math.floor(n*d)*o,g=1-Math.abs(d),p=t+f;p<c?p=c:p>u&&(p=u);let m=s[p+3]*g;r+=s[p]*m,i+=s[p+1]*m,a+=s[p+2]*m,l+=m,h+=g}e[t]=r/l,e[t+1]=i/l,e[t+2]=a/l,e[t+3]=l/h}}sendUniformData(t,e){let r=this.chooseRightDelta();t.uniform2fv(e.uDelta,r)}isNeutralState(){return 0===this.blur}getBlurValue(){let t=1,{horizontal:e,aspectRatio:r}=this;return e?r>1&&(t=1/r):r<1&&(t=r),t*this.blur*.12}chooseRightDelta(){let t=this.getBlurValue();return this.horizontal?[t,0]:[0,t]}}Z(o_,"type","Blur"),Z(o_,"defaults",{blur:0}),Z(o_,"uniformLocations",["uDelta"]),tY.setClass(o_);class ow extends op{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uBrightness;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color.rgb += uBrightness;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t,r=Math.round(255*this.brightness);for(let t=0;t<e.length;t+=4)e[t]+=r,e[t+1]+=r,e[t+2]+=r}isNeutralState(){return 0===this.brightness}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}Z(ow,"type","Brightness"),Z(ow,"defaults",{brightness:0}),Z(ow,"uniformLocations",["uBrightness"]),tY.setClass(ow);let oC={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class oS extends op{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n varying vec2 vTexCoord;\n uniform mat4 uColorMatrix;\n uniform vec4 uConstants;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color *= uColorMatrix;\n color += uConstants;\n gl_FragColor = color;\n }"}applyTo2d(t){let e=t.imageData.data,r=this.matrix,i=this.colorsOnly;for(let t=0;t<e.length;t+=4){let n=e[t],s=e[t+1],o=e[t+2];if(e[t]=n*r[0]+s*r[1]+o*r[2]+255*r[4],e[t+1]=n*r[5]+s*r[6]+o*r[7]+255*r[9],e[t+2]=n*r[10]+s*r[11]+o*r[12]+255*r[14],!i){let i=e[t+3];e[t]+=i*r[3],e[t+1]+=i*r[8],e[t+2]+=i*r[13],e[t+3]=n*r[15]+s*r[16]+o*r[17]+i*r[18]+255*r[19]}}}sendUniformData(t,e){let r=this.matrix,i=[r[0],r[1],r[2],r[3],r[5],r[6],r[7],r[8],r[10],r[11],r[12],r[13],r[15],r[16],r[17],r[18]],n=[r[4],r[9],r[14],r[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,i),t.uniform4fv(e.uConstants,n)}toObject(){return tt(tt({},super.toObject()),{},{matrix:[...this.matrix]})}}function oT(t,e){var r;let i=(Z(r=class extends oS{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",t),Z(r,"defaults",{colorsOnly:!1,matrix:e}),r);return tY.setClass(i,t),i}Z(oS,"type","ColorMatrix"),Z(oS,"defaults",oC),Z(oS,"uniformLocations",["uColorMatrix","uConstants"]),tY.setClass(oS);let oO=oT("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),ok=oT("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),oM=oT("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),oE=oT("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),oD=oT("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),oj=oT("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),oA=oT("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 oP extends op{applyTo(t){void 0!==t.webgl&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach(e=>{e.applyTo(t)})}toObject(){return{type:this.type,subFilters:this.subFilters.map(t=>t.toObject())}}isNeutralState(){return!this.subFilters.some(t=>!t.isNeutralState())}static fromObject(t,e){return Promise.all((t.subFilters||[]).map(t=>tY.getClass(t.type).fromObject(t,e))).then(t=>new this({subFilters:t}))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}}Z(oP,"type","Composed"),tY.setClass(oP);class oF extends op{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uContrast;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));\n color.rgb = contrastF * (color.rgb - 0.5) + 0.5;\n gl_FragColor = color;\n }"}isNeutralState(){return 0===this.contrast}applyTo2d(t){let{imageData:{data:e}}=t,r=Math.floor(255*this.contrast),i=259*(r+255)/(255*(259-r));for(let t=0;t<e.length;t+=4)e[t]=i*(e[t]-128)+128,e[t+1]=i*(e[t+1]-128)+128,e[t+2]=i*(e[t+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}Z(oF,"type","Contrast"),Z(oF,"defaults",{contrast:0}),Z(oF,"uniformLocations",["uContrast"]),tY.setClass(oF);let oL={Convolute_3_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[9];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 3.0; h+=1.0) {\n for (float w = 0.0; w < 3.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_3_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[9];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 3.0; h+=1.0) {\n for (float w = 0.0; w < 3.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n ",Convolute_5_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[25];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 5.0; h+=1.0) {\n for (float w = 0.0; w < 5.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_5_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[25];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 5.0; h+=1.0) {\n for (float w = 0.0; w < 5.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n ",Convolute_7_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[49];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 7.0; h+=1.0) {\n for (float w = 0.0; w < 7.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_7_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[49];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 7.0; h+=1.0) {\n for (float w = 0.0; w < 7.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n ",Convolute_9_1:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[81];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 0);\n for (float h = 0.0; h < 9.0; h+=1.0) {\n for (float w = 0.0; w < 9.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];\n }\n }\n gl_FragColor = color;\n }\n ",Convolute_9_0:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uMatrix[81];\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = vec4(0, 0, 0, 1);\n for (float h = 0.0; h < 9.0; h+=1.0) {\n for (float w = 0.0; w < 9.0; w+=1.0) {\n vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));\n color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];\n }\n }\n float alpha = texture2D(uTexture, vTexCoord).a;\n gl_FragColor = color;\n gl_FragColor.a = alpha;\n }\n "};class oR extends op{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(+!!this.opaque)}getFragmentSource(){return oL[this.getCacheKey()]}applyTo2d(t){let e,r,i,n,s,o,a,l,h,c,u,d,f,g=t.imageData,p=g.data,m=this.matrix,y=Math.round(Math.sqrt(m.length)),x=Math.floor(y/2),b=g.width,_=g.height,w=t.ctx.createImageData(b,_),C=w.data,S=+!!this.opaque;for(u=0;u<_;u++)for(c=0;c<b;c++){for(s=4*(u*b+c),e=0,r=0,i=0,n=0,f=0;f<y;f++)for(d=0;d<y;d++)a=u+f-x,o=c+d-x,a<0||a>=_||o<0||o>=b||(l=4*(a*b+o),h=m[f*y+d],e+=p[l]*h,r+=p[l+1]*h,i+=p[l+2]*h,S||(n+=p[l+3]*h));C[s]=e,C[s+1]=r,C[s+2]=i,C[s+3]=S?p[s+3]:n}t.imageData=w}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return tt(tt({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}Z(oR,"type","Convolute"),Z(oR,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),Z(oR,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),tY.setClass(oR);let oI="Gamma";class oB extends op{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec3 uGamma;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n vec3 correction = (1.0 / uGamma);\n color.r = pow(color.r, correction.r);\n color.g = pow(color.g, correction.g);\n color.b = pow(color.b, correction.b);\n gl_FragColor = color;\n gl_FragColor.rgb *= color.a;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t,r=this.gamma,i=1/r[0],n=1/r[1],s=1/r[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});let o=this.rgbValues;for(let t=0;t<256;t++)o.r[t]=255*Math.pow(t/255,i),o.g[t]=255*Math.pow(t/255,n),o.b[t]=255*Math.pow(t/255,s);for(let t=0;t<e.length;t+=4)e[t]=o.r[e[t]],e[t+1]=o.g[e[t+1]],e[t+2]=o.b[e[t+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){let{gamma:t}=this;return 1===t[0]&&1===t[1]&&1===t[2]}toObject(){return{type:oI,gamma:this.gamma.concat()}}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}}Z(oB,"type",oI),Z(oB,"defaults",{gamma:[1,1,1]}),Z(oB,"uniformLocations",["uGamma"]),tY.setClass(oB);let oN={average:"\n precision highp float;\n uniform sampler2D uTexture;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float average = (color.r + color.b + color.g) / 3.0;\n gl_FragColor = vec4(average, average, average, color.a);\n }\n ",lightness:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform int uMode;\n varying vec2 vTexCoord;\n void main() {\n vec4 col = texture2D(uTexture, vTexCoord);\n float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;\n gl_FragColor = vec4(average, average, average, col.a);\n }\n ",luminosity:"\n precision highp float;\n uniform sampler2D uTexture;\n uniform int uMode;\n varying vec2 vTexCoord;\n void main() {\n vec4 col = texture2D(uTexture, vTexCoord);\n float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;\n gl_FragColor = vec4(average, average, average, col.a);\n }\n "};class oW extends op{applyTo2d(t){let{imageData:{data:e}}=t;for(let t,r=0;r<e.length;r+=4){let i=e[r],n=e[r+1],s=e[r+2];switch(this.mode){case"average":t=(i+n+s)/3;break;case"lightness":t=(Math.min(i,n,s)+Math.max(i,n,s))/2;break;case"luminosity":t=.21*i+.72*n+.07*s}e[r+2]=e[r+1]=e[r]=t}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return oN[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}Z(oW,"type","Grayscale"),Z(oW,"defaults",{mode:"average"}),Z(oW,"uniformLocations",["uMode"]),tY.setClass(oW);let oU=tt(tt({},oC),{},{rotation:0});class oH extends oS{calculateMatrix(){let t=this.rotation*Math.PI,e=tK(t),r=tQ(t),i=1/3,n=Math.sqrt(1/3)*r,s=1-e;this.matrix=[e+s/3,i*s-n,i*s+n,0,0,i*s+n,e+i*s,i*s-n,0,0,i*s-n,i*s+n,e+i*s,0,0,0,0,0,1,0]}isNeutralState(){return 0===this.rotation}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}Z(oH,"type","HueRotation"),Z(oH,"defaults",oU),tY.setClass(oH);class oX extends op{applyTo2d(t){let{imageData:{data:e}}=t;for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2],this.alpha&&(e[t+3]=255-e[t+3])}getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform int uInvert;\n uniform int uAlpha;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n if (uInvert == 1) {\n if (uAlpha == 1) {\n gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);\n } else {\n gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);\n }\n } else {\n gl_FragColor = color;\n }\n }\n"}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}Z(oX,"type","Invert"),Z(oX,"defaults",{alpha:!1,invert:!0}),Z(oX,"uniformLocations",["uInvert","uAlpha"]),tY.setClass(oX);class oV extends op{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uStepH;\n uniform float uNoise;\n uniform float uSeed;\n varying vec2 vTexCoord;\n float rand(vec2 co, float seed, float vScale) {\n return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);\n }\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t,r=this.noise;for(let t=0;t<e.length;t+=4){let i=(.5-Math.random())*r;e[t]+=i,e[t+1]+=i,e[t+2]+=i}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return 0===this.noise}}Z(oV,"type","Noise"),Z(oV,"defaults",{noise:0}),Z(oV,"uniformLocations",["uNoise","uSeed"]),tY.setClass(oV);class oY extends op{applyTo2d(t){let{imageData:{data:e,width:r,height:i}}=t;for(let t=0;t<i;t+=this.blocksize)for(let n=0;n<r;n+=this.blocksize){let s=4*t*r+4*n,o=e[s],a=e[s+1],l=e[s+2],h=e[s+3];for(let s=t;s<Math.min(t+this.blocksize,i);s++)for(let t=n;t<Math.min(n+this.blocksize,r);t++){let i=4*s*r+4*t;e[i]=o,e[i+1]=a,e[i+2]=l,e[i+3]=h}}}isNeutralState(){return 1===this.blocksize}getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uBlocksize;\n uniform float uStepW;\n uniform float uStepH;\n varying vec2 vTexCoord;\n void main() {\n float blockW = uBlocksize * uStepW;\n float blockH = uBlocksize * uStepH;\n int posX = int(vTexCoord.x / blockW);\n int posY = int(vTexCoord.y / blockH);\n float fposX = float(posX);\n float fposY = float(posY);\n vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);\n vec4 color = texture2D(uTexture, squareCoords);\n gl_FragColor = color;\n }\n"}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}Z(oY,"type","Pixelate"),Z(oY,"defaults",{blocksize:4}),Z(oY,"uniformLocations",["uBlocksize"]),tY.setClass(oY);class oz extends op{getFragmentSource(){return"\nprecision highp float;\nuniform sampler2D uTexture;\nuniform vec4 uLow;\nuniform vec4 uHigh;\nvarying vec2 vTexCoord;\nvoid main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {\n gl_FragColor.a = 0.0;\n }\n}\n"}applyTo2d(t){let{imageData:{data:e}}=t,r=255*this.distance,i=new rs(this.color).getSource(),n=[i[0]-r,i[1]-r,i[2]-r],s=[i[0]+r,i[1]+r,i[2]+r];for(let t=0;t<e.length;t+=4){let r=e[t],i=e[t+1],o=e[t+2];r>n[0]&&i>n[1]&&o>n[2]&&r<s[0]&&i<s[1]&&o<s[2]&&(e[t+3]=0)}}sendUniformData(t,e){let r=new rs(this.color).getSource(),i=this.distance,n=[0+r[0]/255-i,0+r[1]/255-i,0+r[2]/255-i,1],s=[r[0]/255+i,r[1]/255+i,r[2]/255+i,1];t.uniform4fv(e.uLow,n),t.uniform4fv(e.uHigh,s)}}Z(oz,"type","RemoveColor"),Z(oz,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),Z(oz,"uniformLocations",["uLow","uHigh"]),tY.setClass(oz);class oG extends op{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){let t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){let t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){let t=this.getFilterWindow();return this.generateShader(t)}getTaps(){let t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,r=this.getFilterWindow(),i=Array(r);for(let n=1;n<=r;n++)i[n-1]=t(n*e);return i}generateShader(t){let e=Array(t);for(let r=1;r<=t;r++)e[r-1]="".concat(r,".0 * uDelta");return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[".concat(t,"];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ").concat(e.map((t,e)=>"\n color += texture2D(uTexture, vTexCoord + ".concat(t,") * uTaps[").concat(e,"] + texture2D(uTexture, vTexCoord - ").concat(t,") * uTaps[").concat(e,"];\n sum += 2.0 * uTaps[").concat(e,"];\n ")).join("\n"),"\n gl_FragColor = color / sum;\n }\n ")}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){void 0!==t.webgl?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return 1===this.scaleX&&1===this.scaleY}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;let r=(e*=Math.PI)/t;return Math.sin(e)/e*Math.sin(r)/r}}applyTo2d(t){let e,r=t.imageData,i=this.scaleX,n=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/n;let s=r.width,o=r.height,a=Math.round(s*i),l=Math.round(o*n);e="sliceHack"===this.resizeType?this.sliceByTwo(t,s,o,a,l):"hermite"===this.resizeType?this.hermiteFastResize(t,s,o,a,l):"bilinear"===this.resizeType?this.bilinearFiltering(t,s,o,a,l):"lanczos"===this.resizeType?this.lanczosResize(t,s,o,a,l):new ImageData(a,l),t.imageData=e}sliceByTwo(t,e,r,i,n){let s=t.imageData,o=!1,a=!1,l=.5*e,h=.5*r,c=t.filterBackend.resources,u=0,d=0,f=e,g=0;c.sliceByTwo||(c.sliceByTwo=t9());let p=c.sliceByTwo;(p.width<1.5*e||p.height<r)&&(p.width=1.5*e,p.height=r);let m=p.getContext("2d");for(m.clearRect(0,0,1.5*e,r),m.putImageData(s,0,0),i=Math.floor(i),n=Math.floor(n);!o||!a;)e=l,r=h,i<Math.floor(.5*l)?l=Math.floor(.5*l):(l=i,o=!0),n<Math.floor(.5*h)?h=Math.floor(.5*h):(h=n,a=!0),m.drawImage(p,u,d,e,r,f,g,l,h),u=f,d=g,g+=h;return m.getImageData(u,d,i,n)}lanczosResize(t,e,r,i,n){let s=t.imageData.data,o=t.ctx.createImageData(i,n),a=o.data,l=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,c=this.rcpScaleY,u=2/this.rcpScaleX,d=2/this.rcpScaleY,f=Math.ceil(h*this.lanczosLobes/2),g=Math.ceil(c*this.lanczosLobes/2),p={},m={x:0,y:0},y={x:0,y:0};return function t(x){let b,_,w,C,S,T,O,k,M,E,D;for(m.x=(x+.5)*h,y.x=Math.floor(m.x),b=0;b<n;b++){for(m.y=(b+.5)*c,y.y=Math.floor(m.y),S=0,T=0,O=0,k=0,M=0,_=y.x-f;_<=y.x+f;_++)if(!(_<0||_>=e)){p[E=Math.floor(1e3*Math.abs(_-m.x))]||(p[E]={});for(let t=y.y-g;t<=y.y+g;t++)t<0||t>=r||(D=Math.floor(1e3*Math.abs(t-m.y)),p[E][D]||(p[E][D]=l(Math.sqrt(Math.pow(E*u,2)+Math.pow(D*d,2))/1e3)),(w=p[E][D])>0&&(C=4*(t*e+_),S+=w,T+=w*s[C],O+=w*s[C+1],k+=w*s[C+2],M+=w*s[C+3]))}a[C=4*(b*i+x)]=T/S,a[C+1]=O/S,a[C+2]=k/S,a[C+3]=M/S}return++x<i?t(x):o}(0)}bilinearFiltering(t,e,r,i,n){let s,o,a,l,h,c,u,d,f,g,p,m=0,y=this.rcpScaleX,x=this.rcpScaleY,b=4*(e-1),_=t.imageData.data,w=t.ctx.createImageData(i,n),C=w.data;for(h=0;h<n;h++)for(c=0;c<i;c++)for(a=Math.floor(y*c),l=Math.floor(x*h),u=y*c-a,d=x*h-l,p=4*(l*e+a),f=0;f<4;f++)s=_[p+f],o=_[p+4+f],g=s*(1-u)*(1-d)+o*u*(1-d)+_[p+b+f]*d*(1-u)+_[p+b+4+f]*u*d,C[m++]=g;return w}hermiteFastResize(t,e,r,i,n){let s=this.rcpScaleX,o=this.rcpScaleY,a=Math.ceil(s/2),l=Math.ceil(o/2),h=t.imageData.data,c=t.ctx.createImageData(i,n),u=c.data;for(let t=0;t<n;t++)for(let r=0;r<i;r++){let n=4*(r+t*i),c=0,d=0,f=0,g=0,p=0,m=0,y=0,x=(t+.5)*o;for(let i=Math.floor(t*o);i<(t+1)*o;i++){let t=Math.abs(x-(i+.5))/l,n=(r+.5)*s,o=t*t;for(let t=Math.floor(r*s);t<(r+1)*s;t++){let r=Math.abs(n-(t+.5))/a,s=Math.sqrt(o+r*r);s>1&&s<-1||(c=2*s*s*s-3*s*s+1)>0&&(y+=c*h[(r=4*(t+i*e))+3],f+=c,h[r+3]<255&&(c=c*h[r+3]/250),g+=c*h[r],p+=c*h[r+1],m+=c*h[r+2],d+=c)}}u[n]=g/d,u[n+1]=p/d,u[n+2]=m/d,u[n+3]=y/f}return c}}Z(oG,"type","Resize"),Z(oG,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),Z(oG,"uniformLocations",["uDelta","uTaps"]),tY.setClass(oG);class oq extends op{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uSaturation;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float rgMax = max(color.r, color.g);\n float rgbMax = max(rgMax, color.b);\n color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;\n color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;\n color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t,r=-this.saturation;for(let t=0;t<e.length;t+=4){let i=e[t],n=e[t+1],s=e[t+2],o=Math.max(i,n,s);e[t]+=o!==i?(o-i)*r:0,e[t+1]+=o!==n?(o-n)*r:0,e[t+2]+=o!==s?(o-s)*r:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return 0===this.saturation}}Z(oq,"type","Saturation"),Z(oq,"defaults",{saturation:0}),Z(oq,"uniformLocations",["uSaturation"]),tY.setClass(oq);class oK extends op{getFragmentSource(){return"\n precision highp float;\n uniform sampler2D uTexture;\n uniform float uVibrance;\n varying vec2 vTexCoord;\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float max = max(color.r, max(color.g, color.b));\n float avg = (color.r + color.g + color.b) / 3.0;\n float amt = (abs(max - avg) * 2.0) * uVibrance;\n color.r += max != color.r ? (max - color.r) * amt : 0.00;\n color.g += max != color.g ? (max - color.g) * amt : 0.00;\n color.b += max != color.b ? (max - color.b) * amt : 0.00;\n gl_FragColor = color;\n }\n"}applyTo2d(t){let{imageData:{data:e}}=t,r=-this.vibrance;for(let t=0;t<e.length;t+=4){let i=e[t],n=e[t+1],s=e[t+2],o=Math.max(i,n,s),a=2*Math.abs(o-(i+n+s)/3)/255*r;e[t]+=o!==i?(o-i)*a:0,e[t+1]+=o!==n?(o-n)*a:0,e[t+2]+=o!==s?(o-s)*a:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return 0===this.vibrance}}Z(oK,"type","Vibrance"),Z(oK,"defaults",{vibrance:0}),Z(oK,"uniformLocations",["uVibrance"]),tY.setClass(oK);var oQ=Object.freeze({__proto__:null,BaseFilter:op,BlackWhite:oA,BlendColor:ov,BlendImage:ob,Blur:o_,Brightness:ow,Brownie:oO,ColorMatrix:oS,Composed:oP,Contrast:oF,Convolute:oR,Gamma:oB,Grayscale:oW,HueRotation:oH,Invert:oX,Kodachrome:oM,Noise:oV,Pixelate:oY,Polaroid:oD,RemoveColor:oz,Resize:oG,Saturation:oq,Sepia:oj,Technicolor:oE,Vibrance:oK,Vintage:ok});let oJ=J.default.createContext(null);oJ.displayName="CanvasContext";let oZ=function(t){var e;let r=(0,J.useContext)(oJ);if(!r)throw Error("No CanvasContext.Provider");return void 0===t?r:null==t?{}:null!=(e=r.canvases[t])?e:{}},o$=J.default.createContext(null);function o0(){let t=(0,J.useContext)(o$);if(!t)throw Error("No ToolsContext.Provider");return t}o$.displayName="ToolsContext";let o1=Math.min,o2=Math.max,o5=Math.round,o4=Math.floor,o3=t=>({x:t,y:t}),o9={left:"right",right:"left",bottom:"top",top:"bottom"},o6={start:"end",end:"start"};function o8(t,e){return"function"==typeof t?t(e):t}function o7(t){return t.split("-")[0]}function at(t){return t.split("-")[1]}function ae(t){return"y"===t?"height":"width"}let ar=new Set(["top","bottom"]);function ai(t){return ar.has(o7(t))?"y":"x"}function an(t){return"x"===ai(t)?"y":"x"}function as(t){return t.replace(/start|end/g,t=>o6[t])}let ao=["left","right"],aa=["right","left"],al=["top","bottom"],ah=["bottom","top"];function ac(t){return t.replace(/left|right|bottom|top/g,t=>o9[t])}function au(t){let{x:e,y:r,width:i,height:n}=t;return{width:i,height:n,top:r,left:e,right:e+i,bottom:r+n,x:e,y:r}}function ad(t,e,r){let i,{reference:n,floating:s}=t,o=ai(e),a=an(e),l=ae(a),h=o7(e),c="y"===o,u=n.x+n.width/2-s.width/2,d=n.y+n.height/2-s.height/2,f=n[l]/2-s[l]/2;switch(h){case"top":i={x:u,y:n.y-s.height};break;case"bottom":i={x:u,y:n.y+n.height};break;case"right":i={x:n.x+n.width,y:d};break;case"left":i={x:n.x-s.width,y:d};break;default:i={x:n.x,y:n.y}}switch(at(e)){case"start":i[a]-=f*(r&&c?-1:1);break;case"end":i[a]+=f*(r&&c?-1:1)}return i}let af=async(t,e,r)=>{let{placement:i="bottom",strategy:n="absolute",middleware:s=[],platform:o}=r,a=s.filter(Boolean),l=await (null==o.isRTL?void 0:o.isRTL(e)),h=await o.getElementRects({reference:t,floating:e,strategy:n}),{x:c,y:u}=ad(h,i,l),d=i,f={},g=0;for(let r=0;r<a.length;r++){let{name:s,fn:p}=a[r],{x:m,y:y,data:x,reset:b}=await p({x:c,y:u,initialPlacement:i,placement:d,strategy:n,middlewareData:f,rects:h,platform:o,elements:{reference:t,floating:e}});c=null!=m?m:c,u=null!=y?y:u,f={...f,[s]:{...f[s],...x}},b&&g<=50&&(g++,"object"==typeof b&&(b.placement&&(d=b.placement),b.rects&&(h=!0===b.rects?await o.getElementRects({reference:t,floating:e,strategy:n}):b.rects),{x:c,y:u}=ad(h,d,l)),r=-1)}return{x:c,y:u,placement:d,strategy:n,middlewareData:f}};async function ag(t,e){var r,i;void 0===e&&(e={});let{x:n,y:s,platform:o,rects:a,elements:l,strategy:h}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:g=0}=o8(e,t),p="number"!=typeof(i=g)?{top:0,right:0,bottom:0,left:0,...i}:{top:i,right:i,bottom:i,left:i},m=l[f?"floating"===d?"reference":"floating":d],y=au(await o.getClippingRect({element:null==(r=await (null==o.isElement?void 0:o.isElement(m)))||r?m:m.contextElement||await (null==o.getDocumentElement?void 0:o.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:h})),x="floating"===d?{x:n,y:s,width:a.floating.width,height:a.floating.height}:a.reference,b=await (null==o.getOffsetParent?void 0:o.getOffsetParent(l.floating)),_=await (null==o.isElement?void 0:o.isElement(b))&&await (null==o.getScale?void 0:o.getScale(b))||{x:1,y:1},w=au(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:b,strategy:h}):x);return{top:(y.top-w.top+p.top)/_.y,bottom:(w.bottom-y.bottom+p.bottom)/_.y,left:(y.left-w.left+p.left)/_.x,right:(w.right-y.right+p.right)/_.x}}let ap=new Set(["left","top"]);async function am(t,e){let{placement:r,platform:i,elements:n}=t,s=await (null==i.isRTL?void 0:i.isRTL(n.floating)),o=o7(r),a=at(r),l="y"===ai(r),h=ap.has(o)?-1:1,c=s&&l?-1:1,u=o8(e,t),{mainAxis:d,crossAxis:f,alignmentAxis:g}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&"number"==typeof g&&(f="end"===a?-1*g:g),l?{x:f*c,y:d*h}:{x:d*h,y:f*c}}function av(){return"undefined"!=typeof window}function ay(t){return a_(t)?(t.nodeName||"").toLowerCase():"#document"}function ax(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function ab(t){var e;return null==(e=(a_(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function a_(t){return!!av()&&(t instanceof Node||t instanceof ax(t).Node)}function aw(t){return!!av()&&(t instanceof Element||t instanceof ax(t).Element)}function aC(t){return!!av()&&(t instanceof HTMLElement||t instanceof ax(t).HTMLElement)}function aS(t){return!!av()&&"undefined"!=typeof ShadowRoot&&(t instanceof ShadowRoot||t instanceof ax(t).ShadowRoot)}let aT=new Set(["inline","contents"]);function aO(t){let{overflow:e,overflowX:r,overflowY:i,display:n}=aI(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+r)&&!aT.has(n)}let ak=new Set(["table","td","th"]),aM=[":popover-open",":modal"];function aE(t){return aM.some(e=>{try{return t.matches(e)}catch(t){return!1}})}let aD=["transform","translate","scale","rotate","perspective"],aj=["transform","translate","scale","rotate","perspective","filter"],aA=["paint","layout","strict","content"];function aP(t){let e=aF(),r=aw(t)?aI(t):t;return aD.some(t=>!!r[t]&&"none"!==r[t])||!!r.containerType&&"normal"!==r.containerType||!e&&!!r.backdropFilter&&"none"!==r.backdropFilter||!e&&!!r.filter&&"none"!==r.filter||aj.some(t=>(r.willChange||"").includes(t))||aA.some(t=>(r.contain||"").includes(t))}function aF(){return"undefined"!=typeof CSS&&!!CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")}let aL=new Set(["html","body","#document"]);function aR(t){return aL.has(ay(t))}function aI(t){return ax(t).getComputedStyle(t)}function aB(t){return aw(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function aN(t){if("html"===ay(t))return t;let e=t.assignedSlot||t.parentNode||aS(t)&&t.host||ab(t);return aS(e)?e.host:e}function aW(t,e,r){var i;void 0===e&&(e=[]),void 0===r&&(r=!0);let n=function t(e){let r=aN(e);return aR(r)?e.ownerDocument?e.ownerDocument.body:e.body:aC(r)&&aO(r)?r:t(r)}(t),s=n===(null==(i=t.ownerDocument)?void 0:i.body),o=ax(n);if(s){let t=aU(o);return e.concat(o,o.visualViewport||[],aO(n)?n:[],t&&r?aW(t):[])}return e.concat(n,aW(n,[],r))}function aU(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function aH(t){let e=aI(t),r=parseFloat(e.width)||0,i=parseFloat(e.height)||0,n=aC(t),s=n?t.offsetWidth:r,o=n?t.offsetHeight:i,a=o5(r)!==s||o5(i)!==o;return a&&(r=s,i=o),{width:r,height:i,$:a}}function aX(t){return aw(t)?t:t.contextElement}function aV(t){let e=aX(t);if(!aC(e))return o3(1);let r=e.getBoundingClientRect(),{width:i,height:n,$:s}=aH(e),o=(s?o5(r.width):r.width)/i,a=(s?o5(r.height):r.height)/n;return o&&Number.isFinite(o)||(o=1),a&&Number.isFinite(a)||(a=1),{x:o,y:a}}let aY=o3(0);function az(t){let e=ax(t);return aF()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:aY}function aG(t,e,r,i){var n;void 0===e&&(e=!1),void 0===r&&(r=!1);let s=t.getBoundingClientRect(),o=aX(t),a=o3(1);e&&(i?aw(i)&&(a=aV(i)):a=aV(t));let l=(void 0===(n=r)&&(n=!1),i&&(!n||i===ax(o))&&n)?az(o):o3(0),h=(s.left+l.x)/a.x,c=(s.top+l.y)/a.y,u=s.width/a.x,d=s.height/a.y;if(o){let t=ax(o),e=i&&aw(i)?ax(i):i,r=t,n=aU(r);for(;n&&i&&e!==r;){let t=aV(n),e=n.getBoundingClientRect(),i=aI(n),s=e.left+(n.clientLeft+parseFloat(i.paddingLeft))*t.x,o=e.top+(n.clientTop+parseFloat(i.paddingTop))*t.y;h*=t.x,c*=t.y,u*=t.x,d*=t.y,h+=s,c+=o,n=aU(r=ax(n))}}return au({width:u,height:d,x:h,y:c})}function aq(t,e){let r=aB(t).scrollLeft;return e?e.left+r:aG(ab(t)).left+r}function aK(t,e){let r=t.getBoundingClientRect();return{x:r.left+e.scrollLeft-aq(t,r),y:r.top+e.scrollTop}}let aQ=new Set(["absolute","fixed"]);function aJ(t,e,r){let i;if("viewport"===e)i=function(t,e){let r=ax(t),i=ab(t),n=r.visualViewport,s=i.clientWidth,o=i.clientHeight,a=0,l=0;if(n){s=n.width,o=n.height;let t=aF();(!t||t&&"fixed"===e)&&(a=n.offsetLeft,l=n.offsetTop)}let h=aq(i);if(h<=0){let t=i.ownerDocument,e=t.body,r=getComputedStyle(e),n="CSS1Compat"===t.compatMode&&parseFloat(r.marginLeft)+parseFloat(r.marginRight)||0,o=Math.abs(i.clientWidth-e.clientWidth-n);o<=25&&(s-=o)}else h<=25&&(s+=h);return{width:s,height:o,x:a,y:l}}(t,r);else if("document"===e)i=function(t){let e=ab(t),r=aB(t),i=t.ownerDocument.body,n=o2(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=o2(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),o=-r.scrollLeft+aq(t),a=-r.scrollTop;return"rtl"===aI(i).direction&&(o+=o2(e.clientWidth,i.clientWidth)-n),{width:n,height:s,x:o,y:a}}(ab(t));else if(aw(e))i=function(t,e){let r=aG(t,!0,"fixed"===e),i=r.top+t.clientTop,n=r.left+t.clientLeft,s=aC(t)?aV(t):o3(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y;return{width:o,height:a,x:n*s.x,y:i*s.y}}(e,r);else{let r=az(t);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return au(i)}function aZ(t){return"static"===aI(t).position}function a$(t,e){if(!aC(t)||"fixed"===aI(t).position)return null;if(e)return e(t);let r=t.offsetParent;return ab(t)===r&&(r=r.ownerDocument.body),r}function a0(t,e){var r;let i=ax(t);if(aE(t))return i;if(!aC(t)){let e=aN(t);for(;e&&!aR(e);){if(aw(e)&&!aZ(e))return e;e=aN(e)}return i}let n=a$(t,e);for(;n&&(r=n,ak.has(ay(r)))&&aZ(n);)n=a$(n,e);return n&&aR(n)&&aZ(n)&&!aP(n)?i:n||function(t){let e=aN(t);for(;aC(e)&&!aR(e);){if(aP(e))return e;if(aE(e))break;e=aN(e)}return null}(t)||i}let a1=async function(t){let e=this.getOffsetParent||a0,r=this.getDimensions,i=await r(t.floating);return{reference:function(t,e,r){let i=aC(e),n=ab(e),s="fixed"===r,o=aG(t,!0,s,e),a={scrollLeft:0,scrollTop:0},l=o3(0);if(i||!i&&!s)if(("body"!==ay(e)||aO(n))&&(a=aB(e)),i){let t=aG(e,!0,s,e);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}else n&&(l.x=aq(n));s&&!i&&n&&(l.x=aq(n));let h=!n||i||s?o3(0):aK(n,a);return{x:o.left+a.scrollLeft-l.x-h.x,y:o.top+a.scrollTop-l.y-h.y,width:o.width,height:o.height}}(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},a2={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:r,offsetParent:i,strategy:n}=t,s="fixed"===n,o=ab(i),a=!!e&&aE(e.floating);if(i===o||a&&s)return r;let l={scrollLeft:0,scrollTop:0},h=o3(1),c=o3(0),u=aC(i);if((u||!u&&!s)&&(("body"!==ay(i)||aO(o))&&(l=aB(i)),aC(i))){let t=aG(i);h=aV(i),c.x=t.x+i.clientLeft,c.y=t.y+i.clientTop}let d=!o||u||s?o3(0):aK(o,l);return{width:r.width*h.x,height:r.height*h.y,x:r.x*h.x-l.scrollLeft*h.x+c.x+d.x,y:r.y*h.y-l.scrollTop*h.y+c.y+d.y}},getDocumentElement:ab,getClippingRect:function(t){let{element:e,boundary:r,rootBoundary:i,strategy:n}=t,s=[..."clippingAncestors"===r?aE(e)?[]:function(t,e){let r=e.get(t);if(r)return r;let i=aW(t,[],!1).filter(t=>aw(t)&&"body"!==ay(t)),n=null,s="fixed"===aI(t).position,o=s?aN(t):t;for(;aw(o)&&!aR(o);){let e=aI(o),r=aP(o);r||"fixed"!==e.position||(n=null),(s?!r&&!n:!r&&"static"===e.position&&!!n&&aQ.has(n.position)||aO(o)&&!r&&function t(e,r){let i=aN(e);return!(i===r||!aw(i)||aR(i))&&("fixed"===aI(i).position||t(i,r))}(t,o))?i=i.filter(t=>t!==o):n=e,o=aN(o)}return e.set(t,i),i}(e,this._c):[].concat(r),i],o=s[0],a=s.reduce((t,r)=>{let i=aJ(e,r,n);return t.top=o2(i.top,t.top),t.right=o1(i.right,t.right),t.bottom=o1(i.bottom,t.bottom),t.left=o2(i.left,t.left),t},aJ(e,o,n));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},getOffsetParent:a0,getElementRects:a1,getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){let{width:e,height:r}=aH(t);return{width:e,height:r}},getScale:aV,isElement:aw,isRTL:function(t){return"rtl"===aI(t).direction}};function a5(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function a4(t,e,r,i){let n;void 0===i&&(i={});let{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:h=!1}=i,c=aX(t),u=s||o?[...c?aW(c):[],...aW(e)]:[];u.forEach(t=>{s&&t.addEventListener("scroll",r,{passive:!0}),o&&t.addEventListener("resize",r)});let d=c&&l?function(t,e){let r,i=null,n=ab(t);function s(){var t;clearTimeout(r),null==(t=i)||t.disconnect(),i=null}return!function o(a,l){void 0===a&&(a=!1),void 0===l&&(l=1),s();let h=t.getBoundingClientRect(),{left:c,top:u,width:d,height:f}=h;if(a||e(),!d||!f)return;let g=o4(u),p=o4(n.clientWidth-(c+d)),m={rootMargin:-g+"px "+-p+"px "+-o4(n.clientHeight-(u+f))+"px "+-o4(c)+"px",threshold:o2(0,o1(1,l))||1},y=!0;function x(e){let i=e[0].intersectionRatio;if(i!==l){if(!y)return o();i?o(!1,i):r=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==i||a5(h,t.getBoundingClientRect())||o(),y=!1}try{i=new IntersectionObserver(x,{...m,root:n.ownerDocument})}catch(t){i=new IntersectionObserver(x,m)}i.observe(t)}(!0),s}(c,r):null,f=-1,g=null;a&&(g=new ResizeObserver(t=>{let[i]=t;i&&i.target===c&&g&&(g.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var t;null==(t=g)||t.observe(e)})),r()}),c&&!h&&g.observe(c),g.observe(e));let p=h?aG(t):null;return h&&function e(){let i=aG(t);p&&!a5(p,i)&&r(),p=i,n=requestAnimationFrame(e)}(),r(),()=>{var t;u.forEach(t=>{s&&t.removeEventListener("scroll",r),o&&t.removeEventListener("resize",r)}),null==d||d(),null==(t=g)||t.disconnect(),g=null,h&&cancelAnimationFrame(n)}}var a3=t.i(74080),a9="undefined"!=typeof document?J.useLayoutEffect:function(){};function a6(t,e){let r,i,n;if(t===e)return!0;if(typeof t!=typeof e)return!1;if("function"==typeof t&&t.toString()===e.toString())return!0;if(t&&e&&"object"==typeof t){if(Array.isArray(t)){if((r=t.length)!==e.length)return!1;for(i=r;0!=i--;)if(!a6(t[i],e[i]))return!1;return!0}if((r=(n=Object.keys(t)).length)!==Object.keys(e).length)return!1;for(i=r;0!=i--;)if(!({}).hasOwnProperty.call(e,n[i]))return!1;for(i=r;0!=i--;){let r=n[i];if(("_owner"!==r||!t.$$typeof)&&!a6(t[r],e[r]))return!1}return!0}return t!=t&&e!=e}function a8(t){return"undefined"==typeof window?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function a7(t,e){let r=a8(t);return Math.round(e*r)/r}function lt(t){let e=J.useRef(t);return a9(()=>{e.current=t}),e}let le=(t,e)=>({...function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var r,i;let{x:n,y:s,placement:o,middlewareData:a}=e,l=await am(e,t);return o===(null==(r=a.offset)?void 0:r.placement)&&null!=(i=a.arrow)&&i.alignmentOffset?{}:{x:n+l.x,y:s+l.y,data:{...l,placement:o}}}}}(t),options:[t,e]}),lr=(t,e)=>({...function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var r,i,n,s,o;let{placement:a,middlewareData:l,rects:h,initialPlacement:c,platform:u,elements:d}=e,{mainAxis:f=!0,crossAxis:g=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:x=!0,...b}=o8(t,e);if(null!=(r=l.arrow)&&r.alignmentOffset)return{};let _=o7(a),w=ai(c),C=o7(c)===c,S=await (null==u.isRTL?void 0:u.isRTL(d.floating)),T=p||(C||!x?[ac(c)]:function(t){let e=ac(t);return[as(t),e,as(e)]}(c)),O="none"!==y;!p&&O&&T.push(...function(t,e,r,i){let n=at(t),s=function(t,e,r){switch(t){case"top":case"bottom":if(r)return e?aa:ao;return e?ao:aa;case"left":case"right":return e?al:ah;default:return[]}}(o7(t),"start"===r,i);return n&&(s=s.map(t=>t+"-"+n),e&&(s=s.concat(s.map(as)))),s}(c,x,y,S));let k=[c,...T],M=await ag(e,b),E=[],D=(null==(i=l.flip)?void 0:i.overflows)||[];if(f&&E.push(M[_]),g){let t=function(t,e,r){void 0===r&&(r=!1);let i=at(t),n=an(t),s=ae(n),o="x"===n?i===(r?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=ac(o)),[o,ac(o)]}(a,h,S);E.push(M[t[0]],M[t[1]])}if(D=[...D,{placement:a,overflows:E}],!E.every(t=>t<=0)){let t=((null==(n=l.flip)?void 0:n.index)||0)+1,e=k[t];if(e&&("alignment"!==g||w===ai(e)||D.every(t=>ai(t.placement)!==w||t.overflows[0]>0)))return{data:{index:t,overflows:D},reset:{placement:e}};let r=null==(s=D.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:s.placement;if(!r)switch(m){case"bestFit":{let t=null==(o=D.filter(t=>{if(O){let e=ai(t.placement);return e===w||"y"===e}return!0}).map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:o[0];t&&(r=t);break}case"initialPlacement":r=c}if(a!==r)return{reset:{placement:r}}}return{}}}}(t),options:[t,e]});t.i(47167);var li='input:not([inert]),select:not([inert]),textarea:not([inert]),a[href]:not([inert]),button:not([inert]),[tabindex]:not(slot):not([inert]),audio[controls]:not([inert]),video[controls]:not([inert]),[contenteditable]:not([contenteditable="false"]):not([inert]),details>summary:first-of-type:not([inert]),details:not([inert])',ln="undefined"==typeof Element,ls=ln?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,lo=!ln&&Element.prototype.getRootNode?function(t){var e;return null==t||null==(e=t.getRootNode)?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},la=function t(e,r){void 0===r&&(r=!0);var i,n=null==e||null==(i=e.getAttribute)?void 0:i.call(e,"inert");return""===n||"true"===n||r&&e&&t(e.parentNode)},ll=function(t){var e,r=null==t||null==(e=t.getAttribute)?void 0:e.call(t,"contenteditable");return""===r||"true"===r},lh=function(t,e,r){if(la(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(li));return e&&ls.call(t,li)&&i.unshift(t),i=i.filter(r)},lc=function t(e,r,i){for(var n=[],s=Array.from(e);s.length;){var o=s.shift();if(!la(o,!1))if("SLOT"===o.tagName){var a=o.assignedElements(),l=t(a.length?a:o.children,!0,i);i.flatten?n.push.apply(n,l):n.push({scopeParent:o,candidates:l})}else{ls.call(o,li)&&i.filter(o)&&(r||!e.includes(o))&&n.push(o);var h=o.shadowRoot||"function"==typeof i.getShadowRoot&&i.getShadowRoot(o),c=!la(h,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(o));if(h&&c){var u=t(!0===h?o.children:h.children,!0,i);i.flatten?n.push.apply(n,u):n.push({scopeParent:o,candidates:u})}else s.unshift.apply(s,o.children)}}return n},lu=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},ld=function(t){if(!t)throw Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||ll(t))&&!lu(t)?0:t.tabIndex},lf=function(t,e){var r=ld(t);return r<0&&e&&!lu(t)?0:r},lg=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},lp=function(t){return"INPUT"===t.tagName},lm=function(t,e){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===e)return t[r]},lv=function(t){if(!t.name)return!0;var e,r=t.form||lo(t),i=function(t){return r.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=i(window.CSS.escape(t.name));else try{e=i(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var n=lm(e,t.form);return!n||n===t},ly=function(t){return lp(t)&&"radio"===t.type&&!lv(t)},lx=function(t){var e,r,i,n,s,o,a,l=t&&lo(t),h=null==(e=l)?void 0:e.host,c=!1;if(l&&l!==t)for(c=!!(null!=(r=h)&&null!=(i=r.ownerDocument)&&i.contains(h)||null!=t&&null!=(n=t.ownerDocument)&&n.contains(t));!c&&h;)c=!!(null!=(o=h=null==(s=l=lo(h))?void 0:s.host)&&null!=(a=o.ownerDocument)&&a.contains(h));return c},lb=function(t){var e=t.getBoundingClientRect(),r=e.width,i=e.height;return 0===r&&0===i},l_=function(t,e){var r=e.displayCheck,i=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var n=ls.call(t,"details>summary:first-of-type")?t.parentElement:t;if(ls.call(n,"details:not([open]) *"))return!0;if(r&&"full"!==r&&"legacy-full"!==r){if("non-zero-area"===r)return lb(t)}else{if("function"==typeof i){for(var s=t;t;){var o=t.parentElement,a=lo(t);if(o&&!o.shadowRoot&&!0===i(o))return lb(t);t=t.assignedSlot?t.assignedSlot:o||a===t.ownerDocument?o:a.host}t=s}if(lx(t))return!t.getClientRects().length;if("legacy-full"!==r)return!0}return!1},lw=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var r=0;r<e.children.length;r++){var i=e.children.item(r);if("LEGEND"===i.tagName)return!!ls.call(e,"fieldset[disabled] *")||!i.contains(t)}return!0}e=e.parentElement}return!1},lC=function(t,e){return!(e.disabled||la(e)||lp(e)&&"hidden"===e.type||l_(e,t)||"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(t){return"SUMMARY"===t.tagName})||lw(e))},lS=function(t,e){return!(ly(e)||0>ld(e))&&!!lC(t,e)},lT=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!isNaN(e)||!!(e>=0)},lO=function t(e){var r=[],i=[];return e.forEach(function(e,n){var s=!!e.scopeParent,o=s?e.scopeParent:e,a=lf(o,s),l=s?t(e.candidates):o;0===a?s?r.push.apply(r,l):r.push(o):i.push({documentOrder:n,tabIndex:a,item:e,isScope:s,content:l})}),i.sort(lg).reduce(function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t},[]).concat(r)},lk=function(t,e){return lO((e=e||{}).getShadowRoot?lc([t],e.includeContainer,{filter:lS.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:lT}):lh(t,e.includeContainer,lS.bind(null,e)))},lM=function(t,e){return(e=e||{}).getShadowRoot?lc([t],e.includeContainer,{filter:lC.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):lh(t,e.includeContainer,lC.bind(null,e))},lE=function(t,e){if(e=e||{},!t)throw Error("No node provided");return!1!==ls.call(t,li)&&lS(e,t)};function lD(){let t=navigator.userAgentData;return t&&Array.isArray(t.brands)?t.brands.map(t=>{let{brand:e,version:r}=t;return e+"/"+r}).join(" "):navigator.userAgent}function lj(){let t=/android/i;return t.test(function(){let t=navigator.userAgentData;return null!=t&&t.platform?t.platform:navigator.platform}())||t.test(lD())}let lA="data-floating-ui-focusable";function lP(t){let e=t.activeElement;for(;(null==(r=e)||null==(r=r.shadowRoot)?void 0:r.activeElement)!=null;){var r;e=e.shadowRoot.activeElement}return e}function lF(t,e){if(!t||!e)return!1;let r=null==e.getRootNode?void 0:e.getRootNode();if(t.contains(e))return!0;if(r&&aS(r)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function lL(t){return"composedPath"in t?t.composedPath()[0]:t.target}function lR(t,e){return null!=e&&("composedPath"in t?t.composedPath().includes(e):null!=t.target&&e.contains(t.target))}function lI(t){return(null==t?void 0:t.ownerDocument)||document}function lB(t){return aC(t)&&t.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function lN(t){return!!t&&"combobox"===t.getAttribute("role")&&lB(t)}function lW(t){return t?t.hasAttribute(lA)?t:t.querySelector("["+lA+"]")||t:null}function lU(t,e,r){return void 0===r&&(r=!0),t.filter(t=>{var i;return t.parentId===e&&(!r||(null==(i=t.context)?void 0:i.open))}).flatMap(e=>[e,...lU(t,e.id,r)])}function lH(t,e){var r;let i=[],n=null==(r=t.find(t=>t.id===e))?void 0:r.parentId;for(;n;){let e=t.find(t=>t.id===n);n=null==e?void 0:e.parentId,e&&(i=i.concat(e))}return i}function lX(t){t.preventDefault(),t.stopPropagation()}function lV(t,e){let r=["mouse","pen"];return e||r.push("",void 0),r.includes(t)}var lY="undefined"!=typeof document?J.useLayoutEffect:function(){};function lz(t){let e=J.useRef(t);return lY(()=>{e.current=t}),e}let lG={...J}.useInsertionEffect||(t=>t());function lq(t){let e=J.useRef(()=>{});return lG(()=>{e.current=t}),J.useCallback(function(){for(var t=arguments.length,r=Array(t),i=0;i<t;i++)r[i]=arguments[i];return null==e.current?void 0:e.current(...r)},[])}let lK=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function lQ(t,e){let r=lk(t,lK()),i=r.length;if(0===i)return;let n=lP(lI(t)),s=r.indexOf(n);return r[-1===s?1===e?0:i-1:s+e]}function lJ(t,e){let r=e||t.currentTarget,i=t.relatedTarget;return!i||!lF(r,i)}let lZ="active",l$="selected",l0={...J},l1=!1,l2=0,l5=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+l2++,l4=l0.useId||function(){let[t,e]=J.useState(()=>l1?l5():void 0);return lY(()=>{null==t&&e(l5())},[]),J.useEffect(()=>{l1=!0},[]),t},l3=J.createContext(null),l9=J.createContext(null),l6=()=>{var t;return(null==(t=J.useContext(l3))?void 0:t.id)||null},l8=()=>J.useContext(l9);function l7(t){return"data-floating-ui-"+t}let ht=0;function he(t,e){void 0===e&&(e={});let{preventScroll:r=!1,cancelPrevious:i=!0,sync:n=!1}=e;i&&cancelAnimationFrame(ht);let s=()=>null==t?void 0:t.focus({preventScroll:r});n?s():ht=requestAnimationFrame(s)}let hr={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function hi(t){return"inert"===t?hr.inert:"aria-hidden"===t?hr["aria-hidden"]:hr.none}let hn=new WeakSet,hs={},ho=0,ha=t=>t&&(t.host||ha(t.parentNode));function hl(t,e,r){var i;void 0===e&&(e=!1),void 0===r&&(r=!1);let n=((null==(i=t[0])?void 0:i.ownerDocument)||document).body;return function(t,e,r,i){let n="data-floating-ui-inert",s=i?"inert":r?"aria-hidden":null,o=t.map(t=>{if(e.contains(t))return t;let r=ha(t);return e.contains(r)?r:null}).filter(t=>null!=t),a=new Set,l=new Set(o),h=[];hs[n]||(hs[n]=new WeakMap);let c=hs[n];return o.forEach(function t(e){!(!e||a.has(e))&&(a.add(e),e.parentNode&&t(e.parentNode))}),function t(e){!e||l.has(e)||[].forEach.call(e.children,e=>{if("script"!==ay(e))if(a.has(e))t(e);else{let t=s?e.getAttribute(s):null,r=null!==t&&"false"!==t,i=hi(s),o=(i.get(e)||0)+1,a=(c.get(e)||0)+1;i.set(e,o),c.set(e,a),h.push(e),1===o&&r&&hn.add(e),1===a&&e.setAttribute(n,""),!r&&s&&e.setAttribute(s,"inert"===s?"":"true")}})}(e),a.clear(),ho++,()=>{h.forEach(t=>{let e=hi(s),r=(e.get(t)||0)-1,i=(c.get(t)||0)-1;e.set(t,r),c.set(t,i),r||(!hn.has(t)&&s&&t.removeAttribute(s),hn.delete(t)),i||t.removeAttribute(n)}),--ho||(hr.inert=new WeakMap,hr["aria-hidden"]=new WeakMap,hr.none=new WeakMap,hn=new WeakSet,hs={})}}(t.concat(Array.from(n.querySelectorAll('[aria-live],[role="status"],output'))),n,e,r)}let hh={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},hc=J.forwardRef(function(t,e){let[r,i]=J.useState();lY(()=>{/apple/i.test(navigator.vendor)&&i("button")},[]);let n={ref:e,tabIndex:0,role:r,"aria-hidden":!r||void 0,[l7("focus-guard")]:"",style:hh};return(0,Q.jsx)("span",{...t,...n})}),hu=J.createContext(null);function hd(t){return J.useMemo(()=>e=>{t.forEach(t=>{t&&(t.current=e)})},t)}let hf=[];function hg(){hf=hf.filter(t=>t.isConnected)}function hp(){return hg(),hf[hf.length-1]}function hm(t,e){var r;if(!e.current.includes("floating")&&!(null!=(r=t.getAttribute("role"))&&r.includes("dialog")))return;let i=lK(),n=lM(t,i).filter(t=>{let e=t.getAttribute("data-tabindex")||"";return lE(t,i)||t.hasAttribute("data-tabindex")&&!e.startsWith("-")}),s=t.getAttribute("tabindex");e.current.includes("floating")||0===n.length?"0"!==s&&t.setAttribute("tabindex","0"):("-1"!==s||t.hasAttribute("data-tabindex")&&"-1"!==t.getAttribute("data-tabindex"))&&(t.setAttribute("tabindex","-1"),t.setAttribute("data-tabindex","-1"))}let hv=J.forwardRef(function(t,e){return(0,Q.jsx)("button",{...t,type:"button",ref:e,tabIndex:-1,style:hh})});function hy(t){let{context:e,children:r,disabled:i=!1,order:n=["content"],guards:s=!0,initialFocus:o=0,returnFocus:a=!0,restoreFocus:l=!1,modal:h=!0,visuallyHiddenDismiss:c=!1,closeOnFocusOut:u=!0,outsideElementsInert:d=!1,getInsideElements:f=()=>[]}=t,{open:g,onOpenChange:p,events:m,dataRef:y,elements:{domReference:x,floating:b}}=e,_=lq(()=>{var t;return null==(t=y.current.floatingContext)?void 0:t.nodeId}),w=lq(f),C="number"==typeof o&&o<0,S=lN(x)&&C,T="undefined"!=typeof HTMLElement&&"inert"in HTMLElement.prototype,O=!T||s,k=!O||T&&d,M=lz(n),E=lz(o),D=lz(a),j=l8(),A=J.useContext(hu),P=J.useRef(null),F=J.useRef(null),L=J.useRef(!1),R=J.useRef(!1),I=J.useRef(-1),B=J.useRef(-1),N=null!=A,W=lW(b),U=lq(function(t){return void 0===t&&(t=W),t?lk(t,lK()):[]}),H=lq(t=>{let e=U(t);return M.current.map(t=>x&&"reference"===t?x:W&&"floating"===t?W:e).filter(Boolean).flat()});J.useEffect(()=>{if(i||!h)return;function t(t){if("Tab"===t.key){lF(W,lP(lI(W)))&&0===U().length&&!S&&lX(t);let e=H(),r=lL(t);"reference"===M.current[0]&&r===x&&(lX(t),t.shiftKey?he(e[e.length-1]):he(e[1])),"floating"===M.current[1]&&r===W&&t.shiftKey&&(lX(t),he(e[0]))}}let e=lI(W);return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}},[i,x,W,h,M,S,U,H]),J.useEffect(()=>{if(!i&&b)return b.addEventListener("focusin",t),()=>{b.removeEventListener("focusin",t)};function t(t){let e=lL(t),r=U().indexOf(e);-1!==r&&(I.current=r)}},[i,b,U]),J.useEffect(()=>{if(i||!u)return;function t(){R.current=!0,setTimeout(()=>{R.current=!1})}function e(t){let e=t.relatedTarget,r=t.currentTarget,i=lL(t);queueMicrotask(()=>{let n=_(),s=!(lF(x,e)||lF(b,e)||lF(e,b)||lF(null==A?void 0:A.portalNode,e)||null!=e&&e.hasAttribute(l7("focus-guard"))||j&&(lU(j.nodesRef.current,n).find(t=>{var r,i;return lF(null==(r=t.context)?void 0:r.elements.floating,e)||lF(null==(i=t.context)?void 0:i.elements.domReference,e)})||lH(j.nodesRef.current,n).find(t=>{var r,i,n;return[null==(r=t.context)?void 0:r.elements.floating,lW(null==(i=t.context)?void 0:i.elements.floating)].includes(e)||(null==(n=t.context)?void 0:n.elements.domReference)===e})));if(r===x&&W&&hm(W,M),l&&r!==x&&!(null!=i&&i.isConnected)&&lP(lI(W))===lI(W).body){aC(W)&&W.focus();let t=I.current,e=U(),r=e[t]||e[e.length-1]||W;aC(r)&&r.focus()}if(y.current.insideReactTree){y.current.insideReactTree=!1;return}(S||!h)&&e&&s&&!R.current&&e!==hp()&&(L.current=!0,p(!1,t,"focus-out"))})}let r=!!(!j&&A);function n(){-1!==B.current&&(clearTimeout(B.current),B.current=-1),y.current.insideReactTree=!0,B.current=window.setTimeout(()=>{y.current.insideReactTree=!1})}if(b&&aC(x))return x.addEventListener("focusout",e),x.addEventListener("pointerdown",t),b.addEventListener("focusout",e),r&&b.addEventListener("focusout",n,!0),()=>{x.removeEventListener("focusout",e),x.removeEventListener("pointerdown",t),b.removeEventListener("focusout",e),r&&b.removeEventListener("focusout",n,!0)}},[i,x,b,W,h,j,A,p,u,l,U,S,_,M,y]);let X=J.useRef(null),V=J.useRef(null),Y=hd([X,null==A?void 0:A.beforeInsideRef]),z=hd([V,null==A?void 0:A.afterInsideRef]);function G(t){return!i&&c&&h?(0,Q.jsx)(hv,{ref:"start"===t?P:F,onClick:t=>p(!1,t.nativeEvent),children:"string"==typeof c?c:"Dismiss"}):null}J.useEffect(()=>{var t,e;if(i||!b)return;let r=Array.from((null==A||null==(t=A.portalNode)?void 0:t.querySelectorAll("["+l7("portal")+"]"))||[]),n=[b,null==(e=(j?lH(j.nodesRef.current,_()):[]).find(t=>{var e;return lN((null==(e=t.context)?void 0:e.elements.domReference)||null)}))||null==(e=e.context)?void 0:e.elements.domReference,...r,...w(),P.current,F.current,X.current,V.current,null==A?void 0:A.beforeOutsideRef.current,null==A?void 0:A.afterOutsideRef.current,M.current.includes("reference")||S?x:null].filter(t=>null!=t),s=h||S?hl(n,!k,k):hl(n);return()=>{s()}},[i,x,b,h,M,A,S,O,k,j,_,w]),lY(()=>{if(i||!aC(W))return;let t=lP(lI(W));queueMicrotask(()=>{let e=H(W),r=E.current,i=("number"==typeof r?e[r]:r.current)||W,n=lF(W,t);C||n||!g||he(i,{preventScroll:i===W})})},[i,g,W,C,H,E]),lY(()=>{var t;if(i||!W)return;let e=lI(W);function r(t){let{reason:e,event:r,nested:i}=t;if(["hover","safe-polygon"].includes(e)&&"mouseleave"===r.type&&(L.current=!0),"outside-press"===e)if(i)L.current=!1;else if(0===r.mozInputSource&&r.isTrusted||(lj()&&r.pointerType?"click"===r.type&&1===r.buttons:0===r.detail&&!r.pointerType)||!lD().includes("jsdom/")&&(!lj()&&0===r.width&&0===r.height||lj()&&1===r.width&&1===r.height&&0===r.pressure&&0===r.detail&&"mouse"===r.pointerType||r.width<1&&r.height<1&&0===r.pressure&&0===r.detail&&"touch"===r.pointerType))L.current=!1;else{let t=!1;document.createElement("div").focus({get preventScroll(){return t=!0,!1}}),t?L.current=!1:L.current=!0}}t=lP(e),hg(),t&&"body"!==ay(t)&&(hf.push(t),hf.length>20&&(hf=hf.slice(-20))),m.on("openchange",r);let n=e.createElement("span");return n.setAttribute("tabindex","-1"),n.setAttribute("aria-hidden","true"),Object.assign(n.style,hh),N&&x&&x.insertAdjacentElement("afterend",n),()=>{m.off("openchange",r);let t=lP(e),i=lF(b,t)||j&&lU(j.nodesRef.current,_(),!1).some(e=>{var r;return lF(null==(r=e.context)?void 0:r.elements.floating,t)}),s=function(){if("boolean"==typeof D.current){let t=x||hp();return t&&t.isConnected?t:n}return D.current.current||n}();queueMicrotask(()=>{let r=function(t){let e=lK();return lE(t,e)?t:lk(t,e)[0]||t}(s);D.current&&!L.current&&aC(r)&&(r===t||t===e.body||i)&&r.focus({preventScroll:!0}),n.remove()})}},[i,b,W,D,y,m,j,N,x,_]),J.useEffect(()=>(queueMicrotask(()=>{L.current=!1}),()=>{queueMicrotask(hg)}),[i]),lY(()=>{if(!i&&A)return A.setFocusManagerState({modal:h,closeOnFocusOut:u,open:g,onOpenChange:p,domReference:x}),()=>{A.setFocusManagerState(null)}},[i,A,h,g,p,u,x]),lY(()=>{!i&&W&&hm(W,M)},[i,W,M]);let q=!i&&O&&(!h||!S)&&(N||h);return(0,Q.jsxs)(Q.Fragment,{children:[q&&(0,Q.jsx)(hc,{"data-type":"inside",ref:Y,onFocus:t=>{var e;if(h){let t=H();he("reference"===n[0]?t[0]:t[t.length-1])}else if(null!=A&&A.preserveTabOrder&&A.portalNode)if(L.current=!1,lJ(t,A.portalNode)){let t=lQ(lI(x).body,1)||x;null==t||t.focus()}else null==(e=A.beforeOutsideRef.current)||e.focus()}}),!S&&G("start"),r,G("end"),q&&(0,Q.jsx)(hc,{"data-type":"inside",ref:z,onFocus:t=>{var e;if(h)he(H()[0]);else if(null!=A&&A.preserveTabOrder&&A.portalNode)if(u&&(L.current=!0),lJ(t,A.portalNode)){let t=lQ(lI(x).body,-1)||x;null==t||t.focus()}else null==(e=A.afterOutsideRef.current)||e.focus()}})]})}function hx(t){return aC(t.target)&&"BUTTON"===t.target.tagName}function hb(t,e){void 0===e&&(e={});let{open:r,onOpenChange:i,dataRef:n,elements:{domReference:s}}=t,{enabled:o=!0,event:a="click",toggle:l=!0,ignoreMouse:h=!1,keyboardHandlers:c=!0,stickIfOpen:u=!0}=e,d=J.useRef(),f=J.useRef(!1),g=J.useMemo(()=>({onPointerDown(t){d.current=t.pointerType},onMouseDown(t){let e=d.current;0===t.button&&"click"!==a&&(lV(e,!0)&&h||(r&&l&&(!n.current.openEvent||!u||"mousedown"===n.current.openEvent.type)?i(!1,t.nativeEvent,"click"):(t.preventDefault(),i(!0,t.nativeEvent,"click"))))},onClick(t){let e=d.current;if("mousedown"===a&&d.current){d.current=void 0;return}lV(e,!0)&&h||(r&&l&&(!n.current.openEvent||!u||"click"===n.current.openEvent.type)?i(!1,t.nativeEvent,"click"):i(!0,t.nativeEvent,"click"))},onKeyDown(t){d.current=void 0,!(t.defaultPrevented||!c||hx(t))&&(" "!==t.key||lB(s)||(t.preventDefault(),f.current=!0),aC(t.target)&&"A"===t.target.tagName||"Enter"!==t.key||(r&&l?i(!1,t.nativeEvent,"click"):i(!0,t.nativeEvent,"click")))},onKeyUp(t){!(t.defaultPrevented||!c||hx(t)||lB(s))&&" "===t.key&&f.current&&(f.current=!1,r&&l?i(!1,t.nativeEvent,"click"):i(!0,t.nativeEvent,"click"))}}),[n,s,a,h,c,i,r,u,l]);return J.useMemo(()=>o?{reference:g}:{},[o,g])}let h_={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},hw={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},hC=t=>{var e,r;return{escapeKey:"boolean"==typeof t?t:null!=(e=null==t?void 0:t.escapeKey)&&e,outsidePress:"boolean"==typeof t?t:null==(r=null==t?void 0:t.outsidePress)||r}};function hS(t,e){void 0===e&&(e={});let{open:r,onOpenChange:i,elements:n,dataRef:s}=t,{enabled:o=!0,escapeKey:a=!0,outsidePress:l=!0,outsidePressEvent:h="pointerdown",referencePress:c=!1,referencePressEvent:u="pointerdown",ancestorScroll:d=!1,bubbles:f,capture:g}=e,p=l8(),m=lq("function"==typeof l?l:()=>!1),y="function"==typeof l?m:l,x=J.useRef(!1),{escapeKey:b,outsidePress:_}=hC(f),{escapeKey:w,outsidePress:C}=hC(g),S=J.useRef(!1),T=lq(t=>{var e;if(!r||!o||!a||"Escape"!==t.key||S.current)return;let n=null==(e=s.current.floatingContext)?void 0:e.nodeId,l=p?lU(p.nodesRef.current,n):[];if(!b&&(t.stopPropagation(),l.length>0)){let t=!0;if(l.forEach(e=>{var r;if(null!=(r=e.context)&&r.open&&!e.context.dataRef.current.__escapeKeyBubbles){t=!1;return}}),!t)return}i(!1,"nativeEvent"in t?t.nativeEvent:t,"escape-key")}),O=lq(t=>{var e;let r=()=>{var e;T(t),null==(e=lL(t))||e.removeEventListener("keydown",r)};null==(e=lL(t))||e.addEventListener("keydown",r)}),k=lq(t=>{var e;let r=s.current.insideReactTree;s.current.insideReactTree=!1;let o=x.current;if(x.current=!1,"click"===h&&o||r||"function"==typeof y&&!y(t))return;let a=lL(t),l="["+l7("inert")+"]",c=lI(n.floating).querySelectorAll(l),u=aw(a)?a:null;for(;u&&!aR(u);){let t=aN(u);if(aR(t)||!aw(t))break;u=t}if(c.length&&aw(a)&&!a.matches("html,body")&&!lF(a,n.floating)&&Array.from(c).every(t=>!lF(u,t)))return;if(aC(a)&&D){let e=aR(a),r=aI(a),i=/auto|scroll/,n=e||i.test(r.overflowX),s=e||i.test(r.overflowY),o=n&&a.clientWidth>0&&a.scrollWidth>a.clientWidth,l=s&&a.clientHeight>0&&a.scrollHeight>a.clientHeight,h="rtl"===r.direction,c=l&&(h?t.offsetX<=a.offsetWidth-a.clientWidth:t.offsetX>a.clientWidth),u=o&&t.offsetY>a.clientHeight;if(c||u)return}let d=null==(e=s.current.floatingContext)?void 0:e.nodeId,f=p&&lU(p.nodesRef.current,d).some(e=>{var r;return lR(t,null==(r=e.context)?void 0:r.elements.floating)});if(lR(t,n.floating)||lR(t,n.domReference)||f)return;let g=p?lU(p.nodesRef.current,d):[];if(g.length>0){let t=!0;if(g.forEach(e=>{var r;if(null!=(r=e.context)&&r.open&&!e.context.dataRef.current.__outsidePressBubbles){t=!1;return}}),!t)return}i(!1,t,"outside-press")}),M=lq(t=>{var e;let r=()=>{var e;k(t),null==(e=lL(t))||e.removeEventListener(h,r)};null==(e=lL(t))||e.addEventListener(h,r)});J.useEffect(()=>{if(!r||!o)return;s.current.__escapeKeyBubbles=b,s.current.__outsidePressBubbles=_;let t=-1;function e(t){i(!1,t,"ancestor-scroll")}function l(){window.clearTimeout(t),S.current=!0}function c(){t=window.setTimeout(()=>{S.current=!1},5*!!aF())}let u=lI(n.floating);a&&(u.addEventListener("keydown",w?O:T,w),u.addEventListener("compositionstart",l),u.addEventListener("compositionend",c)),y&&u.addEventListener(h,C?M:k,C);let f=[];return d&&(aw(n.domReference)&&(f=aW(n.domReference)),aw(n.floating)&&(f=f.concat(aW(n.floating))),!aw(n.reference)&&n.reference&&n.reference.contextElement&&(f=f.concat(aW(n.reference.contextElement)))),(f=f.filter(t=>{var e;return t!==(null==(e=u.defaultView)?void 0:e.visualViewport)})).forEach(t=>{t.addEventListener("scroll",e,{passive:!0})}),()=>{a&&(u.removeEventListener("keydown",w?O:T,w),u.removeEventListener("compositionstart",l),u.removeEventListener("compositionend",c)),y&&u.removeEventListener(h,C?M:k,C),f.forEach(t=>{t.removeEventListener("scroll",e)}),window.clearTimeout(t)}},[s,n,a,y,h,r,i,d,o,b,_,T,w,O,k,C,M]),J.useEffect(()=>{s.current.insideReactTree=!1},[s,y,h]);let E=J.useMemo(()=>({onKeyDown:T,...c&&{[h_[u]]:t=>{i(!1,t.nativeEvent,"reference-press")},..."click"!==u&&{onClick(t){i(!1,t.nativeEvent,"reference-press")}}}}),[T,i,c,u]),D=J.useMemo(()=>({onKeyDown:T,onMouseDown(){x.current=!0},onMouseUp(){x.current=!0},[hw[h]]:()=>{s.current.insideReactTree=!0}}),[T,h,s]);return J.useMemo(()=>o?{reference:E,floating:D}:{},[o,E,D])}function hT(t){void 0===t&&(t={});let{nodeId:e}=t,r=function(t){let{open:e=!1,onOpenChange:r,elements:i}=t,n=l4(),s=J.useRef({}),[o]=J.useState(()=>(function(){let t=new Map;return{emit(e,r){var i;null==(i=t.get(e))||i.forEach(t=>t(r))},on(e,r){t.has(e)||t.set(e,new Set),t.get(e).add(r)},off(e,r){var i;null==(i=t.get(e))||i.delete(r)}}})()),a=null!=l6(),[l,h]=J.useState(i.reference),c=lq((t,e,i)=>{s.current.openEvent=t?e:void 0,o.emit("openchange",{open:t,event:e,reason:i,nested:a}),null==r||r(t,e,i)}),u=J.useMemo(()=>({setPositionReference:h}),[]),d=J.useMemo(()=>({reference:l||i.reference||null,floating:i.floating||null,domReference:i.reference}),[l,i.reference,i.floating]);return J.useMemo(()=>({dataRef:s,open:e,onOpenChange:c,elements:d,events:o,floatingId:n,refs:u}),[e,c,d,o,n,u])}({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||r,n=i.elements,[s,o]=J.useState(null),[a,l]=J.useState(null),h=(null==n?void 0:n.domReference)||s,c=J.useRef(null),u=l8();lY(()=>{h&&(c.current=h)},[h]);let d=function(t){void 0===t&&(t={});let{placement:e="bottom",strategy:r="absolute",middleware:i=[],platform:n,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:h}=t,[c,u]=J.useState({x:0,y:0,strategy:r,placement:e,middlewareData:{},isPositioned:!1}),[d,f]=J.useState(i);a6(d,i)||f(i);let[g,p]=J.useState(null),[m,y]=J.useState(null),x=J.useCallback(t=>{t!==C.current&&(C.current=t,p(t))},[]),b=J.useCallback(t=>{t!==S.current&&(S.current=t,y(t))},[]),_=s||g,w=o||m,C=J.useRef(null),S=J.useRef(null),T=J.useRef(c),O=null!=l,k=lt(l),M=lt(n),E=lt(h),D=J.useCallback(()=>{if(!C.current||!S.current)return;let t={placement:e,strategy:r,middleware:d};M.current&&(t.platform=M.current),((t,e,r)=>{let i=new Map,n={platform:a2,...r},s={...n.platform,_c:i};return af(t,e,{...n,platform:s})})(C.current,S.current,t).then(t=>{let e={...t,isPositioned:!1!==E.current};j.current&&!a6(T.current,e)&&(T.current=e,a3.flushSync(()=>{u(e)}))})},[d,e,r,M,E]);a9(()=>{!1===h&&T.current.isPositioned&&(T.current.isPositioned=!1,u(t=>({...t,isPositioned:!1})))},[h]);let j=J.useRef(!1);a9(()=>(j.current=!0,()=>{j.current=!1}),[]),a9(()=>{if(_&&(C.current=_),w&&(S.current=w),_&&w){if(k.current)return k.current(_,w,D);D()}},[_,w,D,k,O]);let A=J.useMemo(()=>({reference:C,floating:S,setReference:x,setFloating:b}),[x,b]),P=J.useMemo(()=>({reference:_,floating:w}),[_,w]),F=J.useMemo(()=>{let t={position:r,left:0,top:0};if(!P.floating)return t;let e=a7(P.floating,c.x),i=a7(P.floating,c.y);return a?{...t,transform:"translate("+e+"px, "+i+"px)",...a8(P.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:e,top:i}},[r,a,P.floating,c.x,c.y]);return J.useMemo(()=>({...c,update:D,refs:A,elements:P,floatingStyles:F}),[c,D,A,P,F])}({...t,elements:{...n,...a&&{reference:a}}}),f=J.useCallback(t=>{let e=aw(t)?{getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>t.getClientRects(),contextElement:t}:t;l(e),d.refs.setReference(e)},[d.refs]),g=J.useCallback(t=>{(aw(t)||null===t)&&(c.current=t,o(t)),(aw(d.refs.reference.current)||null===d.refs.reference.current||null!==t&&!aw(t))&&d.refs.setReference(t)},[d.refs]),p=J.useMemo(()=>({...d.refs,setReference:g,setPositionReference:f,domReference:c}),[d.refs,g,f]),m=J.useMemo(()=>({...d.elements,domReference:h}),[d.elements,h]),y=J.useMemo(()=>({...d,...i,refs:p,elements:m,nodeId:e}),[d,p,m,e,i]);return lY(()=>{i.dataRef.current.floatingContext=y;let t=null==u?void 0:u.nodesRef.current.find(t=>t.id===e);t&&(t.context=y)}),J.useMemo(()=>({...d,context:y,refs:p,elements:m}),[d,p,m,y])}function hO(t,e,r){let i=new Map,n="item"===r,s=t;if(n&&t){let{[lZ]:e,[l$]:r,...i}=t;s=i}return{..."floating"===r&&{tabIndex:-1,"data-floating-ui-focusable":""},...s,...e.map(e=>{let i=e?e[r]:null;return"function"==typeof i?t?i(t):null:i}).concat(t).reduce((t,e)=>(e&&Object.entries(e).forEach(e=>{let[r,s]=e;if(!(n&&[lZ,l$].includes(r)))if(0===r.indexOf("on")){if(i.has(r)||i.set(r,[]),"function"==typeof s){var o;null==(o=i.get(r))||o.push(s),t[r]=function(){for(var t,e=arguments.length,n=Array(e),s=0;s<e;s++)n[s]=arguments[s];return null==(t=i.get(r))?void 0:t.map(t=>t(...n)).find(t=>void 0!==t)}}}else t[r]=s}),t),{})}}function hk(t){void 0===t&&(t=[]);let e=t.map(t=>null==t?void 0:t.reference),r=t.map(t=>null==t?void 0:t.floating),i=t.map(t=>null==t?void 0:t.item),n=J.useCallback(e=>hO(e,t,"reference"),e),s=J.useCallback(e=>hO(e,t,"floating"),r),o=J.useCallback(e=>hO(e,t,"item"),i);return J.useMemo(()=>({getReferenceProps:n,getFloatingProps:s,getItemProps:o}),[n,s,o])}let hM=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function hE(t,e){var r,i;void 0===e&&(e={});let{open:n,elements:s,floatingId:o}=t,{enabled:a=!0,role:l="dialog"}=e,h=l4(),c=(null==(r=s.domReference)?void 0:r.id)||h,u=J.useMemo(()=>{var t;return(null==(t=lW(s.floating))?void 0:t.id)||o},[s.floating,o]),d=null!=(i=hM.get(l))?i:l,f=null!=l6(),g=J.useMemo(()=>"tooltip"===d||"label"===l?{["aria-"+("label"===l?"labelledby":"describedby")]:n?u:void 0}:{"aria-expanded":n?"true":"false","aria-haspopup":"alertdialog"===d?"dialog":d,"aria-controls":n?u:void 0,..."listbox"===d&&{role:"combobox"},..."menu"===d&&{id:c},..."menu"===d&&f&&{role:"menuitem"},..."select"===l&&{"aria-autocomplete":"none"},..."combobox"===l&&{"aria-autocomplete":"list"}},[d,u,f,n,c,l]),p=J.useMemo(()=>{let t={id:u,...d&&{role:d}};return"tooltip"===d||"label"===l?t:{...t,..."menu"===d&&{"aria-labelledby":c}}},[d,u,c,l]),m=J.useCallback(t=>{let{active:e,selected:r}=t,i={role:"option",...e&&{id:u+"-fui-option"}};switch(l){case"select":case"combobox":return{...i,"aria-selected":r}}return{}},[u,l]);return J.useMemo(()=>a?{reference:g,floating:p,item:m}:{},[a,g,p,m])}var hD=t.i(40141);function hj(t){return(0,hD.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6Z"},child:[]}]})(t)}function hA(t){return(0,hD.GenIcon)({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M5 2a1 1 0 011 1v1h1a1 1 0 010 2H6v1a1 1 0 01-2 0V6H3a1 1 0 010-2h1V3a1 1 0 011-1zm0 10a1 1 0 011 1v1h1a1 1 0 110 2H6v1a1 1 0 11-2 0v-1H3a1 1 0 110-2h1v-1a1 1 0 011-1zM12 2a1 1 0 01.967.744L14.146 7.2 17.5 9.134a1 1 0 010 1.732l-3.354 1.935-1.18 4.455a1 1 0 01-1.933 0L9.854 12.8 6.5 10.866a1 1 0 010-1.732l3.354-1.935 1.18-4.455A1 1 0 0112 2z",clipRule:"evenodd"},child:[]}]})(t)}var hP=t.i(11152);function hF(t){return(0,hD.GenIcon)({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M123.193 29.635L121 406.18l84.31-82.836 65.87 159.02 67.5-27.96-65.87-159.02L391 294.342z"},child:[]}]})(t)}function hL(t){return(0,hD.GenIcon)({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M149.9 302.2c-39.1 0-70.7 31-70.7 69.3 0 30.3-27.3 46.2-47.2 46.2C53.7 446 90.7 464 126.3 464c52.1 0 94.3-41.4 94.3-92.4 0-38.4-31.6-69.4-70.7-69.4zM473.1 85.7l-31.6-31c-9.2-9-24-9-33.2 0L197 261.8l64.8 63.5 211.2-207c9.3-9 9.3-23.6.1-32.6z"},child:[]}]})(t)}function hR(t){return(0,hD.GenIcon)({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M96 448h106.7V64H96v384zM309.3 64v384H416V64H309.3z"},child:[]}]})(t)}function hI(t){return(0,hD.GenIcon)({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M96 52v408l320-204L96 52z"},child:[]}]})(t)}function hB(t){return(0,hD.GenIcon)({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M11.904 16c1.777-3.219 2.076-8.13-4.904-7.966v3.966l-6-6 6-6v3.881c8.359-0.218 9.29 7.378 4.904 12.119z"},child:[]}]})(t)}function hN(t){return(0,hD.GenIcon)({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M9 3.881v-3.881l6 6-6 6v-3.966c-6.98-0.164-6.681 4.747-4.904 7.966-4.386-4.741-3.455-12.337 4.904-12.119z"},child:[]}]})(t)}function hW(t){return(0,hD.GenIcon)({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M8 0c-4.418 0-8 3.582-8 8s3.582 8 8 8 8-3.582 8-8-3.582-8-8-8zM2 8c0-3.314 2.686-6 6-6v12c-3.314 0-6-2.686-6-6z"},child:[]}]})(t)}function hU(t){return(0,hD.GenIcon)({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M8 4c-2.209 0-4 1.791-4 4s1.791 4 4 4 4-1.791 4-4-1.791-4-4-4zM8 10.5v-5c1.379 0 2.5 1.122 2.5 2.5s-1.121 2.5-2.5 2.5zM8 13c0.552 0 1 0.448 1 1v1c0 0.552-0.448 1-1 1s-1-0.448-1-1v-1c0-0.552 0.448-1 1-1zM8 3c-0.552 0-1-0.448-1-1v-1c0-0.552 0.448-1 1-1s1 0.448 1 1v1c0 0.552-0.448 1-1 1zM15 7c0.552 0 1 0.448 1 1s-0.448 1-1 1h-1c-0.552 0-1-0.448-1-1s0.448-1 1-1h1zM3 8c0 0.552-0.448 1-1 1h-1c-0.552 0-1-0.448-1-1s0.448-1 1-1h1c0.552 0 1 0.448 1 1zM12.95 11.536l0.707 0.707c0.39 0.39 0.39 1.024 0 1.414s-1.024 0.39-1.414 0l-0.707-0.707c-0.39-0.39-0.39-1.024 0-1.414s1.024-0.39 1.414 0zM3.050 4.464l-0.707-0.707c-0.391-0.391-0.391-1.024 0-1.414s1.024-0.391 1.414 0l0.707 0.707c0.391 0.391 0.391 1.024 0 1.414s-1.024 0.391-1.414 0zM12.95 4.464c-0.39 0.391-1.024 0.391-1.414 0s-0.39-1.024 0-1.414l0.707-0.707c0.39-0.391 1.024-0.391 1.414 0s0.39 1.024 0 1.414l-0.707 0.707zM3.050 11.536c0.39-0.39 1.024-0.39 1.414 0s0.391 1.024 0 1.414l-0.707 0.707c-0.391 0.39-1.024 0.39-1.414 0s-0.391-1.024 0-1.414l0.707-0.707z"},child:[]}]})(t)}function hH(t){return(0,hD.GenIcon)({tag:"svg",attr:{version:"1.1",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M15.5 6h-5.5v-5.5c0-0.276-0.224-0.5-0.5-0.5h-3c-0.276 0-0.5 0.224-0.5 0.5v5.5h-5.5c-0.276 0-0.5 0.224-0.5 0.5v3c0 0.276 0.224 0.5 0.5 0.5h5.5v5.5c0 0.276 0.224 0.5 0.5 0.5h3c0.276 0 0.5-0.224 0.5-0.5v-5.5h5.5c0.276 0 0.5-0.224 0.5-0.5v-3c0-0.276-0.224-0.5-0.5-0.5z"},child:[]}]})(t)}let hX=J.default.createContext(null);function hV(){let t=(0,J.useContext)(hX);if(!t)throw Error("No WarriorContext.Provider");return t}hX.displayName="WarriorContext";let hY="undefined"!=typeof window&&window.document&&window.document.createElement?J.useLayoutEffect:J.useEffect,hz=(t,e)=>{let r=J.useRef(!0);hY(()=>t(r.current),e),hY(()=>(r.current=!1,()=>{r.current=!0}),[])},hG=function(t){let e=J.useRef();return e.current=t,J.useCallback(function(){for(var t,r=arguments.length,i=Array(r),n=0;n<r;n++)i[n]=arguments[n];return null==(t=e.current)?void 0:t.call(e,...i)},[])},hq={},hK=[];function hQ(t,e){}function hJ(t,e){}function hZ(t,e,r){e||hq[r]||(t(!1,r),hq[r]=!0)}function h$(t,e){hZ(hQ,t,e)}h$.preMessage=t=>{hK.push(t)},h$.resetWarned=function(){hq={}},h$.noteOnce=function(t,e){hZ(hJ,t,e)};let h0=function(t,e){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=new Set;return function t(e,n){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=i.has(e);if(h$(!o,"Warning: There may be circular references"),o)return!1;if(e===n)return!0;if(r&&s>1)return!1;i.add(e);let a=s+1;if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(!t(e[r],n[r],a))return!1;return!0}if(e&&n&&"object"==typeof e&&"object"==typeof n){let r=Object.keys(e);return r.length===Object.keys(n).length&&r.every(r=>t(e[r],n[r],a))}return!1}(t,e)};var h1=t.i(43794);function h2(t,e,r,i){let n=(e-r)/(i-r),s={};switch(t){case"rtl":s.right="".concat(100*n,"%"),s.transform="translateX(50%)";break;case"btt":s.bottom="".concat(100*n,"%"),s.transform="translateY(50%)";break;case"ttb":s.top="".concat(100*n,"%"),s.transform="translateY(-50%)";break;default:s.left="".concat(100*n,"%"),s.transform="translateX(-50%)"}return s}function h5(t,e){return Array.isArray(t)?t[e]:t}let h4={MAC_ENTER:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,QUESTION_MARK:63,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,WIN_KEY_RIGHT:92,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,PERIOD:190,SLASH:191,APOSTROPHE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221,WIN_KEY:224,MAC_FF_META:224,WIN_IME:229,isTextModifyingKeyEvent:function(t){let{keyCode:e}=t;if(t.altKey&&!t.ctrlKey||t.metaKey||e>=h4.F1&&e<=h4.F12)return!1;switch(e){case h4.ALT:case h4.CAPS_LOCK:case h4.CONTEXT_MENU:case h4.CTRL:case h4.DOWN:case h4.END:case h4.ESC:case h4.HOME:case h4.INSERT:case h4.LEFT:case h4.MAC_FF_META:case h4.META:case h4.NUMLOCK:case h4.NUM_CENTER:case h4.PAGE_DOWN:case h4.PAGE_UP:case h4.PAUSE:case h4.PRINT_SCREEN:case h4.RIGHT:case h4.SHIFT:case h4.UP:case h4.WIN_KEY:case h4.WIN_KEY_RIGHT:return!1;default:return!0}},isCharacterKey:function(t){if(t>=h4.ZERO&&t<=h4.NINE||t>=h4.NUM_ZERO&&t<=h4.NUM_MULTIPLY||t>=h4.A&&t<=h4.Z||-1!==window.navigator.userAgent.indexOf("WebKit")&&0===t)return!0;switch(t){case h4.SPACE:case h4.QUESTION_MARK:case h4.NUM_PLUS:case h4.NUM_MINUS:case h4.NUM_PERIOD:case h4.NUM_DIVISION:case h4.SEMICOLON:case h4.DASH:case h4.EQUALS:case h4.COMMA:case h4.PERIOD:case h4.SLASH:case h4.APOSTROPHE:case h4.SINGLE_QUOTE:case h4.OPEN_SQUARE_BRACKET:case h4.BACKSLASH:case h4.CLOSE_SQUARE_BRACKET:return!0;default:return!1}}},h3=J.createContext({min:0,max:0,direction:"ltr",step:1,includedStart:0,includedEnd:0,tabIndex:0,keyboard:!0,styles:{},classNames:{}}),h9=J.createContext({});function h6(){return(h6=Object.assign.bind()).apply(this,arguments)}let h8=J.forwardRef((t,e)=>{let{prefixCls:r,value:i,valueIndex:n,onStartMove:s,onDelete:o,style:a,render:l,dragging:h,draggingDelete:c,onOffsetChange:u,onChangeComplete:d,onFocus:f,onMouseEnter:g,...p}=t,{min:m,max:y,direction:x,disabled:b,keyboard:_,range:w,tabIndex:C,ariaLabelForHandle:S,ariaLabelledByForHandle:T,ariaRequired:O,ariaValueTextFormatterForHandle:k,styles:M,classNames:E}=J.useContext(h3),D="".concat(r,"-handle"),j=t=>{b||s(t,n)},A=h2(x,i,m,y),P={};if(null!==n){var F;P={tabIndex:b?null:h5(C,n),role:"slider","aria-valuemin":m,"aria-valuemax":y,"aria-valuenow":i,"aria-disabled":b,"aria-label":h5(S,n),"aria-labelledby":h5(T,n),"aria-required":h5(O,n),"aria-valuetext":null==(F=h5(k,n))?void 0:F(i),"aria-orientation":"ltr"===x||"rtl"===x?"horizontal":"vertical",onMouseDown:j,onTouchStart:j,onFocus:t=>{null==f||f(t,n)},onMouseEnter:t=>{g(t,n)},onKeyDown:t=>{if(!b&&_){let e=null;switch(t.which||t.keyCode){case h4.LEFT:e="ltr"===x||"btt"===x?-1:1;break;case h4.RIGHT:e="ltr"===x||"btt"===x?1:-1;break;case h4.UP:e="ttb"!==x?1:-1;break;case h4.DOWN:e="ttb"!==x?-1:1;break;case h4.HOME:e="min";break;case h4.END:e="max";break;case h4.PAGE_UP:e=2;break;case h4.PAGE_DOWN:e=-2;break;case h4.BACKSPACE:case h4.DELETE:null==o||o(n)}null!==e&&(t.preventDefault(),u(e,n))}},onKeyUp:t=>{switch(t.which||t.keyCode){case h4.LEFT:case h4.RIGHT:case h4.UP:case h4.DOWN:case h4.HOME:case h4.END:case h4.PAGE_UP:case h4.PAGE_DOWN:null==d||d()}}}}let L=J.createElement("div",h6({ref:e,className:(0,h1.default)(D,{["".concat(D,"-").concat(n+1)]:null!==n&&w,["".concat(D,"-dragging")]:h,["".concat(D,"-dragging-delete")]:c},E.handle),style:{...A,...a,...M.handle}},P,p));return l&&(L=l(L,{index:n,prefixCls:r,value:i,dragging:h,draggingDelete:c})),L});function h7(){return(h7=Object.assign.bind()).apply(this,arguments)}let ct=J.forwardRef((t,e)=>{let{prefixCls:r,style:i,onStartMove:n,onOffsetChange:s,values:o,handleRender:a,activeHandleRender:l,draggingIndex:h,draggingDelete:c,onFocus:u,...d}=t,f=J.useRef({}),[g,p]=J.useState(!1),[m,y]=J.useState(-1),x=t=>{y(t),p(!0)};J.useImperativeHandle(e,()=>({focus:t=>{var e;null==(e=f.current[t])||e.focus()},hideHelp:()=>{(0,a3.flushSync)(()=>{p(!1)})}}));let b={prefixCls:r,onStartMove:n,onOffsetChange:s,render:a,onFocus:(t,e)=>{x(e),null==u||u(t)},onMouseEnter:(t,e)=>{x(e)},...d};return J.createElement(J.Fragment,null,o.map((t,e)=>{let r=h===e;return J.createElement(h8,h7({ref:t=>{t?f.current[e]=t:delete f.current[e]},dragging:r,draggingDelete:r&&c,style:h5(i,e),key:e,value:t,valueIndex:e},b))}),l&&g&&J.createElement(h8,h7({key:"a11y"},b,{value:o[m],valueIndex:null,dragging:-1!==h,draggingDelete:c,render:l,style:{pointerEvents:"none"},tabIndex:null,"aria-hidden":!0})))}),ce=t=>{let{prefixCls:e,style:r,children:i,value:n,onClick:s}=t,{min:o,max:a,direction:l,includedStart:h,includedEnd:c,included:u}=J.useContext(h3),d="".concat(e,"-text"),f=h2(l,n,o,a);return J.createElement("span",{className:(0,h1.default)(d,{["".concat(d,"-active")]:u&&h<=n&&n<=c}),style:{...f,...r},onMouseDown:t=>{t.stopPropagation()},onClick:()=>{s(n)}},i)},cr=t=>{let{prefixCls:e,marks:r,onClick:i}=t,n="".concat(e,"-mark");return r.length?J.createElement("div",{className:n},r.map(t=>{let{value:e,style:r,label:s}=t;return J.createElement(ce,{key:e,prefixCls:n,style:r,value:e,onClick:i},s)})):null},ci=t=>{let{prefixCls:e,value:r,style:i,activeStyle:n}=t,{min:s,max:o,direction:a,included:l,includedStart:h,includedEnd:c}=J.useContext(h3),u="".concat(e,"-dot"),d=l&&h<=r&&r<=c,f={...h2(a,r,s,o),..."function"==typeof i?i(r):i};return d&&(f={...f,..."function"==typeof n?n(r):n}),J.createElement("span",{className:(0,h1.default)(u,{["".concat(u,"-active")]:d}),style:f})},cn=t=>{let{prefixCls:e,marks:r,dots:i,style:n,activeStyle:s}=t,{min:o,max:a,step:l}=J.useContext(h3),h=J.useMemo(()=>{let t=new Set;if(r.forEach(e=>{t.add(e.value)}),i&&null!==l){let e=o;for(;e<=a;)t.add(e),e+=l}return Array.from(t)},[o,a,l,i,r]);return J.createElement("div",{className:"".concat(e,"-step")},h.map(t=>J.createElement(ci,{prefixCls:e,key:t,value:t,style:n,activeStyle:s})))},cs=t=>{let{prefixCls:e,style:r,start:i,end:n,index:s,onStartMove:o,replaceCls:a}=t,{direction:l,min:h,max:c,disabled:u,range:d,classNames:f}=J.useContext(h3),g="".concat(e,"-track"),p=(i-h)/(c-h),m=(n-h)/(c-h),y=t=>{!u&&o&&o(t,-1)},x={};switch(l){case"rtl":x.right="".concat(100*p,"%"),x.width="".concat(100*m-100*p,"%");break;case"btt":x.bottom="".concat(100*p,"%"),x.height="".concat(100*m-100*p,"%");break;case"ttb":x.top="".concat(100*p,"%"),x.height="".concat(100*m-100*p,"%");break;default:x.left="".concat(100*p,"%"),x.width="".concat(100*m-100*p,"%")}let b=a||(0,h1.default)(g,{["".concat(g,"-").concat(s+1)]:null!==s&&d,["".concat(e,"-track-draggable")]:o},f.track);return J.createElement("div",{className:b,style:{...x,...r},onMouseDown:y,onTouchStart:y})},co=t=>{let{prefixCls:e,style:r,values:i,startPoint:n,onStartMove:s}=t,{included:o,range:a,min:l,styles:h,classNames:c}=J.useContext(h3),u=J.useMemo(()=>{if(!a){if(0===i.length)return[];let t=null!=n?n:l,e=i[0];return[{start:Math.min(t,e),end:Math.max(t,e)}]}let t=[];for(let e=0;e<i.length-1;e+=1)t.push({start:i[e],end:i[e+1]});return t},[i,a,n,l]);if(!o)return null;let d=(null==u?void 0:u.length)&&(c.tracks||h.tracks)?J.createElement(cs,{index:null,prefixCls:e,start:u[0].start,end:u[u.length-1].end,replaceCls:(0,h1.default)(c.tracks,"".concat(e,"-tracks")),style:h.tracks}):null;return J.createElement(J.Fragment,null,d,u.map((t,i)=>{let{start:n,end:o}=t;return J.createElement(cs,{index:i,prefixCls:e,style:{...h5(r,i),...h.track},start:n,end:o,key:i,onStartMove:s})}))};function ca(t){let e="targetTouches"in t?t.targetTouches[0]:t;return{pageX:e.pageX,pageY:e.pageY}}let cl=function(t,e,r,i,n,s,o,a,l,h,c){let[u,d]=J.useState(null),[f,g]=J.useState(-1),[p,m]=J.useState(!1),[y,x]=J.useState(r),[b,_]=J.useState(r),w=J.useRef(null),C=J.useRef(null),S=J.useRef(null),{onDragStart:T,onDragChange:O}=J.useContext(h9);hz(()=>{-1===f&&x(r)},[r,f]),J.useEffect(()=>()=>{document.removeEventListener("mousemove",w.current),document.removeEventListener("mouseup",C.current),S.current&&(S.current.removeEventListener("touchmove",w.current),S.current.removeEventListener("touchend",C.current))},[]);let k=(t,e,r)=>{void 0!==e&&d(e),x(t);let i=t;r&&(i=t.filter((t,e)=>e!==f)),o(i),O&&O({rawValues:t,deleteIndex:r?f:-1,draggingIndex:f,draggingValue:e})},M=hG((t,e,r)=>{if(-1===t){let t=b[0],r=b[b.length-1],o=e*(n-i);o=Math.min(o=Math.max(o,i-t),n-r),o=s(t+o)-t,k(b.map(t=>t+o))}else{let s=[...y];s[t]=b[t];let o=l(s,(n-i)*e,t,"dist");k(o.values,o.value,r)}});return[f,u,p,J.useMemo(()=>{let t=[...r].sort((t,e)=>t-e),e=[...y].sort((t,e)=>t-e),i={};e.forEach(t=>{i[t]=(i[t]||0)+1}),t.forEach(t=>{i[t]=(i[t]||0)-1});let n=+!!h;return Object.values(i).reduce((t,e)=>t+Math.abs(e),0)<=n?y:r},[r,y,h]),(i,n,s)=>{i.stopPropagation();let o=s||r,l=o[n];g(n),d(l),_(o),x(o),m(!1);let{pageX:u,pageY:f}=ca(i),p=!1;T&&T({rawValues:o,draggingIndex:n,draggingValue:l});let b=r=>{let i,s;r.preventDefault();let{pageX:o,pageY:a}=ca(r),l=o-u,d=a-f,{width:g,height:x}=t.current.getBoundingClientRect();switch(e){case"btt":i=-d/x,s=l;break;case"ttb":i=d/x,s=l;break;case"rtl":i=-l/g,s=d;break;default:i=l/g,s=d}m(p=!!h&&Math.abs(s)>130&&c<y.length),M(n,i,p)},O=t=>{t.preventDefault(),document.removeEventListener("mouseup",O),document.removeEventListener("mousemove",b),S.current&&(S.current.removeEventListener("touchmove",w.current),S.current.removeEventListener("touchend",C.current)),w.current=null,C.current=null,S.current=null,a(p),g(-1),m(!1)};document.addEventListener("mouseup",O),document.addEventListener("mousemove",b),i.currentTarget.addEventListener("touchend",O),i.currentTarget.addEventListener("touchmove",b),w.current=b,C.current=O,S.current=i.currentTarget}]},ch=J.forwardRef((t,e)=>{let{prefixCls:r="rc-slider",className:i,style:n,classNames:s,styles:o,id:a,disabled:l=!1,keyboard:h=!0,autoFocus:c,onFocus:u,onBlur:d,min:f=0,max:g=100,step:p=1,value:m,defaultValue:y,range:x,count:b,onChange:_,onBeforeChange:w,onAfterChange:C,onChangeComplete:S,allowCross:T=!0,pushable:O=!1,reverse:k,vertical:M,included:E=!0,startPoint:D,trackStyle:j,handleStyle:A,railStyle:P,dotStyle:F,activeDotStyle:L,marks:R,dots:I,handleRender:B,activeHandleRender:N,track:W,tabIndex:U=0,ariaLabelForHandle:H,ariaLabelledByForHandle:X,ariaRequired:V,ariaValueTextFormatterForHandle:Y}=t,z=J.useRef(null),G=J.useRef(null),q=J.useMemo(()=>M?k?"ttb":"btt":k?"rtl":"ltr",[k,M]),[K,Q,Z,$,tt]=function(t){return(0,J.useMemo)(()=>{if(!0===t||!t)return[!!t,!1,!1,0];let{editable:e,draggableTrack:r,minCount:i,maxCount:n}=t;return[!0,e,!e&&r,i||0,n]},[t])}(x),te=J.useMemo(()=>isFinite(f)?f:0,[f]),tr=J.useMemo(()=>isFinite(g)?g:100,[g]),ti=J.useMemo(()=>null!==p&&p<=0?1:p,[p]),tn=J.useMemo(()=>"boolean"==typeof O?!!O&&ti:O>=0&&O,[O,ti]),ts=J.useMemo(()=>Object.keys(R||{}).map(t=>{let e=R[t],r={value:Number(t)};return e&&"object"==typeof e&&!J.isValidElement(e)&&("label"in e||"style"in e)?(r.style=e.style,r.label=e.label):r.label=e,r}).filter(t=>{let{label:e}=t;return e||"number"==typeof e}).sort((t,e)=>t.value-e.value),[R]),[to,ta]=function(t,e,r,i,n,s){let o=J.useCallback(r=>Math.max(t,Math.min(e,r)),[t,e]),a=J.useCallback(i=>{if(null!==r){let n=t+Math.round((o(i)-t)/r)*r,s=t=>(String(t).split(".")[1]||"").length,a=Math.max(s(r),s(e),s(t)),l=Number(n.toFixed(a));return t<=l&&l<=e?l:null}return null},[r,t,e,o]),l=J.useCallback(n=>{let s=o(n),l=i.map(t=>t.value);null!==r&&l.push(a(n)),l.push(t,e);let h=l[0],c=e-t;return l.forEach(t=>{let e=Math.abs(s-t);e<=c&&(h=t,c=e)}),h},[t,e,i,r,o,a]),h=function(n,s,o){let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit";if("number"==typeof s){let c,u=n[o],d=u+s,f=[];i.forEach(t=>{f.push(t.value)}),f.push(t,e),f.push(a(u));let g=s>0?1:-1;"unit"===l?f.push(a(u+g*r)):f.push(a(d)),f=f.filter(t=>null!==t).filter(t=>s<0?t<=u:t>=u),"unit"===l&&(f=f.filter(t=>t!==u));let p="unit"===l?u:d,m=Math.abs((c=f[0])-p);if(f.forEach(t=>{let e=Math.abs(t-p);e<m&&(c=t,m=e)}),void 0===c)return s<0?t:e;if("dist"===l)return c;if(Math.abs(s)>1){let t=[...n];return t[o]=c,h(t,s-g,o,l)}return c}return"min"===s?t:"max"===s?e:void 0},c=function(t,e,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit",n=t[r],s=h(t,e,r,i);return{value:s,changed:s!==n}},u=t=>null===s&&0===t||"number"==typeof s&&t<s;return[l,function(t,e,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit",o=t.map(l),a=o[r],d=h(o,e,r,i);if(o[r]=d,!1===n){let t=s||0;r>0&&o[r-1]!==a&&(o[r]=Math.max(o[r],o[r-1]+t)),r<o.length-1&&o[r+1]!==a&&(o[r]=Math.min(o[r],o[r+1]-t))}else if("number"==typeof s||null===s){for(let t=r+1;t<o.length;t+=1){let e=!0;for(;u(o[t]-o[t-1])&&e;)({value:o[t],changed:e}=c(o,1,t))}for(let t=r;t>0;t-=1){let e=!0;for(;u(o[t]-o[t-1])&&e;)({value:o[t-1],changed:e}=c(o,-1,t-1))}for(let t=o.length-1;t>0;t-=1){let e=!0;for(;u(o[t]-o[t-1])&&e;)({value:o[t-1],changed:e}=c(o,-1,t-1))}for(let t=0;t<o.length-1;t+=1){let e=!0;for(;u(o[t+1]-o[t])&&e;)({value:o[t+1],changed:e}=c(o,1,t+1))}}return{value:o[r],values:o}}]}(te,tr,ti,ts,T,tn),[tl,th]=function(t,e){let[r,i]=(0,J.useState)(t),n=void 0!==e?e:r;return hz(t=>{t||i(e)},[e]),[n,i]}(y,m),tc=J.useMemo(()=>{let t=null==tl?[]:Array.isArray(tl)?tl:[tl],[e=te]=t,r=null===tl?[]:[e];if(K){if(r=[...t],b||void 0===tl){let t=b>=0?b+1:2;for(r=r.slice(0,t);r.length<t;){var i;r.push(null!=(i=r[r.length-1])?i:te)}}r.sort((t,e)=>t-e)}return r.forEach((t,e)=>{r[e]=to(t)}),r},[tl,K,te,b,to]),tu=t=>K?t:t[0],td=hG(t=>{let e=[...t].sort((t,e)=>t-e);_&&!h0(e,tc,!0)&&_(tu(e)),th(e)}),tf=hG(t=>{t&&z.current.hideHelp();let e=tu(tc);null==C||C(e),h$(!C,"[rc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead."),null==S||S(e)}),[tg,tp,tm,tv,ty]=cl(G,q,tc,te,tr,to,td,tf,ta,Q,$),tx=(t,e)=>{if(!l){let n=[...tc],s=0,o=0,a=tr-te;tc.forEach((e,r)=>{let i=Math.abs(t-e);i<=a&&(a=i,s=r),e<t&&(o=r)});let l=s;Q&&0!==a&&(!tt||tc.length<tt)?(n.splice(o+1,0,t),l=o+1):n[s]=t,K&&!tc.length&&void 0===b&&n.push(t);let h=tu(n);if(null==w||w(h),td(n),e){var r,i;null==(i=document.activeElement)||null==(r=i.blur)||r.call(i),z.current.focus(l),ty(e,l,n)}else null==C||C(h),h$(!C,"[rc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead."),null==S||S(h)}},[tb,t_]=J.useState(null);J.useEffect(()=>{if(null!==tb){let t=tc.indexOf(tb);t>=0&&z.current.focus(t)}t_(null)},[tb]);let tw=J.useMemo(()=>(!Z||null!==ti)&&Z,[Z,ti]),tC=hG((t,e)=>{ty(t,e),null==w||w(tu(tc))}),tS=-1!==tg;J.useEffect(()=>{if(!tS){let t=tc.lastIndexOf(tp);z.current.focus(t)}},[tS]);let tT=J.useMemo(()=>[...tv].sort((t,e)=>t-e),[tv]),[tO,tk]=J.useMemo(()=>K?[tT[0],tT[tT.length-1]]:[te,tT[0]],[tT,K,te]);J.useImperativeHandle(e,()=>({focus:()=>{z.current.focus(0)},blur:()=>{var t;let{activeElement:e}=document;(null==(t=G.current)?void 0:t.contains(e))&&(null==e||e.blur())}})),J.useEffect(()=>{c&&z.current.focus(0)},[]);let tM=J.useMemo(()=>({min:te,max:tr,direction:q,disabled:l,keyboard:h,step:ti,included:E,includedStart:tO,includedEnd:tk,range:K,tabIndex:U,ariaLabelForHandle:H,ariaLabelledByForHandle:X,ariaRequired:V,ariaValueTextFormatterForHandle:Y,styles:o||{},classNames:s||{}}),[te,tr,q,l,h,ti,E,tO,tk,K,U,H,X,V,Y,o,s]);return J.createElement(h3.Provider,{value:tM},J.createElement("div",{ref:G,className:(0,h1.default)(r,i,{["".concat(r,"-disabled")]:l,["".concat(r,"-vertical")]:M,["".concat(r,"-horizontal")]:!M,["".concat(r,"-with-marks")]:ts.length}),style:n,onMouseDown:t=>{let e;t.preventDefault();let{width:r,height:i,left:n,top:s,bottom:o,right:a}=G.current.getBoundingClientRect(),{clientX:l,clientY:h}=t;switch(q){case"btt":e=(o-h)/i;break;case"ttb":e=(h-s)/i;break;case"rtl":e=(a-l)/r;break;default:e=(l-n)/r}tx(to(te+e*(tr-te)),t)},id:a},J.createElement("div",{className:(0,h1.default)("".concat(r,"-rail"),null==s?void 0:s.rail),style:{...P,...null==o?void 0:o.rail}}),!1!==W&&J.createElement(co,{prefixCls:r,style:j,values:tc,startPoint:D,onStartMove:tw?tC:void 0}),J.createElement(cn,{prefixCls:r,marks:ts,dots:I,style:F,activeStyle:L}),J.createElement(ct,{ref:z,prefixCls:r,style:A,values:tv,draggingIndex:tg,draggingDelete:tm,onStartMove:tC,onOffsetChange:(t,e)=>{if(!l){let r=ta(tc,t,e);null==w||w(tu(tc)),td(r.values),t_(r.value)}},onFocus:u,onBlur:d,handleRender:B,activeHandleRender:N,onChangeComplete:tf,onDelete:Q?t=>{if(l||!Q||tc.length<=$)return;let e=[...tc];e.splice(t,1),null==w||w(tu(e)),td(e);let r=Math.max(0,t-1);z.current.hideHelp(),z.current.focus(r)}:void 0}),J.createElement(cr,{prefixCls:r,marks:ts,onClick:tx})))}),cc={track:{height:8,background:"#03fccf"},handle:{width:20,height:20,marginTop:-6,borderColor:"#03fccf",background:"rgb(5, 69, 76)",opacity:1},rail:{height:8,border:"1px solid #555",background:"rgba(255, 255, 255, 0.3)"}};function cu(t){return(0,Q.jsx)(ch,{...t,styles:{...cc,...t.styles}})}var cd=t.i(20592);let{materials:cf}=cd.default;function cg(){var t;let e=(0,J.useRef)(null),r=(0,J.useRef)(null),[i,n]=(0,J.useState)("vl2"),{activeCanvas:s,backgroundColor:o,setBackgroundColor:a,selectedObjects:l,lockedObjects:h,lockSelection:c,unlockSelection:u,bringForward:d,sendBackward:f,duplicate:g,deleteSelection:p,undo:m,redo:y,canUndo:x,canRedo:b,copyToMetallic:_,brushColor:w,setBrushColor:C,brushSize:S,setBrushSize:T,hueRotate:O,setHueRotate:k,saturation:M,setSaturation:E,brightness:D,setBrightness:j,contrast:A,setContrast:P,opacity:F,setOpacity:L,layerMode:R,setLayerMode:I,activeCanvasType:B,addImages:N,exportSkin:W,selectedExportMaterials:U,setSelectedExportMaterials:H}=o0(),{actualModel:X}=hV(),V=cf[X],{canvas:Y,isDrawingMode:z,setDrawingMode:G}=oZ(s),[q,K]=(0,J.useState)(!1),Z=q?"⌘":"Ctrl ",[$,tt]=(0,J.useState)(!1),{refs:te,floatingStyles:tr,context:ti}=hT({open:$,onOpenChange:tt,placement:"bottom-end",middleware:[lr(),le(10)],whileElementsMounted:a4}),tn=hb(ti),ts=hS(ti),to=hE(ti);(0,J.useEffect)(()=>{$&&G(!0)},[$,G]);let{getReferenceProps:ta,getFloatingProps:tl}=hk([tn,ts,to]),[th,tc]=(0,J.useState)(!1),{refs:tu,floatingStyles:td,context:tf}=hT({open:th,onOpenChange:tc,placement:"bottom-end",middleware:[lr(),le(10)],whileElementsMounted:a4}),tg=hb(tf),{getReferenceProps:tp,getFloatingProps:tm}=hk([tg,hS(tf),hE(tf)]),[tv,ty]=(0,J.useState)(!1),{refs:tx,floatingStyles:tb,context:t_}=hT({open:tv,onOpenChange:ty,placement:"bottom-end",middleware:[lr(),le(10)],whileElementsMounted:a4}),tw=hb(t_),{getReferenceProps:tC,getFloatingProps:tS}=hk([tw,hS(t_),hE(t_)]),tT=!!l.length&&l.every(t=>h.has(t)),tO=l.length>0,tk=l.filter(t=>t instanceof s7).length>0,tM=t=>{a(t.target.value)};return(0,J.useEffect)(()=>{try{let t=localStorage.getItem("exportFileType");switch(t){case"vl2":case"png":n(t)}}catch(t){}},[]),(0,J.useEffect)(()=>{navigator.platform&&navigator.platform.startsWith("Mac")?K(!0):navigator.userAgent.match(/\(Macintosh;/)&&K(!0)},[]),(0,Q.jsxs)("div",{className:"CanvasTools",children:[(0,Q.jsxs)("div",{className:"CanvasBackgroundColor",children:[(0,Q.jsx)("input",{className:"ColorSwatch",type:"radio",name:"backgroundColor",id:"canvasBackgroundColorBlack",value:"black",checked:"black"===o,onChange:tM}),(0,Q.jsx)("label",{htmlFor:"canvasBackgroundColorBlack",children:(0,Q.jsx)("span",{className:"HiddenLabel",children:"Black"})}),(0,Q.jsx)("input",{className:"ColorSwatch",type:"radio",name:"backgroundColor",id:"canvasBackgroundColorMagenta",value:"magenta",checked:"magenta"===o,onChange:tM}),(0,Q.jsx)("label",{htmlFor:"canvasBackgroundColorMagenta",children:(0,Q.jsx)("span",{className:"HiddenLabel",children:"Magenta"})}),(0,Q.jsx)("input",{className:"ColorSwatch",type:"radio",name:"backgroundColor",id:"canvasBackgroundColorWhite",value:"white",checked:"white"===o,onChange:tM}),(0,Q.jsx)("label",{htmlFor:"canvasBackgroundColorWhite",children:(0,Q.jsx)("span",{className:"HiddenLabel",children:"White"})})]}),(0,Q.jsxs)("div",{className:"Buttons",children:["metallic"===B?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)("div",{className:"ButtonGroup",children:[(0,Q.jsx)("button",{className:"ButtonGroup",type:"button","data-active":z?void 0:"","aria-label":"Select Mode",title:"Select Mode (S)",onClick:()=>{G(!1)},children:(0,Q.jsx)(hF,{})}),(0,Q.jsx)("button",{className:"ButtonGroup",type:"button","data-active":z?"":void 0,"aria-label":"Paint Mode",title:"Paint Mode (P)",ref:te.setReference,...ta(),children:(0,Q.jsx)(hL,{})})]}),$?(0,Q.jsx)(hy,{context:ti,modal:!1,children:(0,Q.jsx)("div",{className:"BrushToolsPopup",ref:te.setFloating,style:tr,...tl(),children:(0,Q.jsxs)("div",{className:"Fields",children:[(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsx)("label",{children:"Metallic Amount"}),(0,Q.jsx)("div",{className:"SliderContainer",children:(0,Q.jsx)(cu,{min:0,max:255,value:w,onChange:t=>{Array.isArray(t)&&(t=t[0]),C(t)},styles:{track:{display:"none"},handle:{width:20,height:20,marginTop:-6,borderColor:"rgb(20, 105, 241)",background:"rgb(".concat(w,", ").concat(w,", ").concat(w,")"),opacity:1},rail:{height:8,border:"1px solid #555",background:"linear-gradient(to right, black 0%, white 100%)"}}})})]}),(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsx)("label",{children:"Brush Size"}),(0,Q.jsx)("div",{className:"SliderContainer",children:(0,Q.jsx)(cu,{min:1,max:50,value:S,onChange:t=>{Array.isArray(t)&&(t=t[0]),T(t)}})})]})]})})}):null]}):null,(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("input",{ref:r,onChange:async t=>{N([await new Promise((e,r)=>{var i;let n=null==(i=t.target.files)?void 0:i[0];if(n){let t=new FileReader;t.addEventListener("load",t=>{var r;e(null==(r=t.target)?void 0:r.result)}),t.readAsDataURL(n)}else r(Error("No input file provided."))})])},type:"file",accept:".png, image/png",hidden:!0}),(0,Q.jsx)("button",{type:"button","aria-label":"Add Image",title:"Add Image",onClick:()=>{r.current&&r.current.click()},children:(0,Q.jsx)(hH,{style:{fontSize:14}})}),(0,Q.jsx)("button",{type:"button","data-active":th?"":void 0,"aria-label":"Filters",title:"Filters",disabled:tO&&!tk,ref:tu.setReference,...tp(),children:(0,Q.jsx)(hW,{})}),th?(0,Q.jsx)(hy,{context:tf,modal:!1,children:(0,Q.jsx)("div",{className:"BrushToolsPopup",ref:tu.setFloating,style:td,...tm(),children:(0,Q.jsxs)("div",{className:"Fields",children:[(0,Q.jsxs)("div",{className:"Field ApplyTo",children:[(0,Q.jsx)("label",{children:"Layer:"}),(0,Q.jsx)("ul",{children:l.length?(0,Q.jsxs)("li",{children:[(0,Q.jsx)("input",{type:"radio",name:"FilterLayer",value:"SelectedLayer",id:"FilterLayer-SelectedLayer",checked:"SelectedLayer"===R,onChange:()=>{I("SelectedLayer")}}),(0,Q.jsxs)("label",{htmlFor:"FilterLayer-SelectedLayer",children:["selected (",l.length.toLocaleString(),")"]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)("li",{children:[(0,Q.jsx)("input",{type:"radio",name:"FilterLayer",value:"BaseLayer",id:"FilterLayer-BaseLayer",checked:"BaseLayer"===R,onChange:()=>{I("BaseLayer")}})," ",(0,Q.jsx)("label",{htmlFor:"FilterLayer-BaseLayer",children:"base"})]}),(0,Q.jsxs)("li",{children:[(0,Q.jsx)("input",{type:"radio",name:"FilterLayer",value:"AllLayers",id:"FilterLayer-AllLayers",checked:"AllLayers"===R,onChange:()=>{I("AllLayers")}}),(0,Q.jsxs)("label",{htmlFor:"FilterLayer-AllLayers",children:["all (",null!=(t=null==Y?void 0:Y._objects.filter(t=>t instanceof s7).length.toLocaleString())?t:0,")"]})]})]})})]}),"color"===B?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsxs)("label",{children:["Hue:"," ",(0,Q.jsx)("strong",{children:null==O?"MULTIPLE VALUES":(0,Q.jsxs)(Q.Fragment,{children:[Math.round(180*O),"°"]})})]}),(0,Q.jsx)("div",{className:"SliderContainer",children:(0,Q.jsx)(cu,{min:-180,max:180,startPoint:0,value:Math.round((null!=O?O:0)*180),onChange:t=>{Array.isArray(t)&&(t=t[0]),k(t/180)}})})]}),(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsxs)("label",{children:["Saturation:"," ",(0,Q.jsx)("strong",{children:null==M?"MULTIPLE VALUES":"".concat(Math.round(100*M+100),"%")})]}),(0,Q.jsx)("div",{className:"SliderContainer",children:(0,Q.jsx)(cu,{min:-100,max:100,startPoint:0,value:Math.round((null!=M?M:0)*100),onChange:t=>{Array.isArray(t)&&(t=t[0]),E(t/100)}})})]})]}):null,(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsxs)("label",{children:["Brightness:"," ",(0,Q.jsx)("strong",{children:null==D?"MULTIPLE VALUES":"".concat(Math.round(100*D+100),"%")})]}),(0,Q.jsx)("div",{className:"SliderContainer",children:(0,Q.jsx)(cu,{min:-100,max:100,startPoint:0,value:Math.round((null!=D?D:0)*100),onChange:t=>{Array.isArray(t)&&(t=t[0]),j(t/100)}})})]}),(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsxs)("label",{children:["Contrast:"," ",(0,Q.jsx)("strong",{children:null==A?"MULTIPLE VALUES":"".concat(Math.round(100*A+100),"%")})]}),(0,Q.jsx)("div",{className:"SliderContainer",children:(0,Q.jsx)(cu,{min:-100,max:100,startPoint:0,value:Math.round((null!=A?A:0)*100),onChange:t=>{Array.isArray(t)&&(t=t[0]),P(t/100)}})})]}),(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsxs)("label",{children:["Opacity:"," ",(0,Q.jsx)("strong",{children:null==F?"MULTIPLE VALUES":"".concat(Math.round((null!=F?F:1)*100),"%")})]}),(0,Q.jsx)("div",{className:"SliderContainer",children:(0,Q.jsx)(cu,{min:0,max:100,startPoint:0,value:Math.round((null!=F?F:1)*100),onChange:t=>{Array.isArray(t)&&(t=t[0]),L(t/100)}})})]})]})})}):null,(0,Q.jsx)("button",{type:"button","aria-label":tT?"Unlock":"Lock",title:tT?"Unlock (L)":"Lock (L)",onClick:tT?u:c,"data-locked":tT?"":void 0,disabled:!tO,children:tT?(0,Q.jsx)(hP.FaUnlock,{style:{fontSize:14}}):(0,Q.jsx)(hP.FaLock,{style:{fontSize:14}})}),(0,Q.jsxs)("div",{className:"ButtonGroup",children:[(0,Q.jsx)("button",{type:"button","aria-label":"Bring Forward",title:"Bring Forward (F)",onClick:d,disabled:!tO,children:(0,Q.jsx)(hP.FaArrowUp,{})}),(0,Q.jsx)("button",{type:"button","aria-label":"Send Backward",title:"Send Backward (B)",onClick:f,disabled:!tO,children:(0,Q.jsx)(hP.FaArrowDown,{})})]}),(0,Q.jsx)("button",{type:"button","aria-label":"Duplicate",title:"Duplicate (D)",onClick:g,disabled:!tO,children:(0,Q.jsx)(hj,{})}),(0,Q.jsx)("button",{type:"button","aria-label":"Delete",title:"Delete (Backspace)",onClick:p,disabled:tT||!tO,children:(0,Q.jsx)(hP.FaTrashAlt,{})}),(0,Q.jsxs)("div",{className:"ButtonGroup",children:[(0,Q.jsx)("button",{type:"button","aria-label":"Undo",title:"Undo (".concat(Z,"Z)"),onClick:m,disabled:!x,children:(0,Q.jsx)(hB,{})}),(0,Q.jsx)("button",{type:"button","aria-label":"Redo",title:"Redo (".concat(q?"".concat("⇧").concat(Z,"Z)"):"".concat(Z," Y"),")"),onClick:y,disabled:!b,children:(0,Q.jsx)(hN,{})})]}),"color"===B?(0,Q.jsxs)("button",{type:"button",className:"MetallicButton","aria-label":"Copy to Metallic",title:"Copy to Metallic",onClick:_,children:[(0,Q.jsx)(hA,{})," ",(0,Q.jsx)("span",{className:"ButtonLabel",children:"Metal"})]}):null]})]}),(0,Q.jsxs)("div",{className:"Export",children:[(0,Q.jsx)("input",{ref:e,type:"text",name:"CustomSkinName",placeholder:"Skin Name",size:12}),(0,Q.jsxs)("button",{className:"ExportOptionsButton",type:"button","data-active":tv?"":void 0,"aria-label":"Export Options",title:"Export Options",ref:tx.setReference,...tC(),children:[".",i,(0,Q.jsx)(hP.FaAngleDown,{})]}),tv?(0,Q.jsx)(hy,{context:t_,modal:!1,children:(0,Q.jsx)("div",{className:"ExportOptionsPopup",ref:tx.setFloating,style:tb,...tS(),children:(0,Q.jsxs)("div",{className:"Fields",children:[(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsx)("label",{children:"Export Materials"}),(0,Q.jsx)("ul",{className:"ExportOptionsList",children:V.map((t,e)=>t&&!1!==t.selectable&&!t.hidden?(0,Q.jsxs)("li",{children:[(0,Q.jsx)("input",{id:"MaterialSelect-".concat(t.name),type:"checkbox",checked:!1!==U[e],onChange:t=>{H(r=>{let i=r.slice();return i[e]=t.target.checked,i})}}),(0,Q.jsx)("label",{htmlFor:"MaterialSelect-".concat(t.name),children:t.label})]},t.name):null)})]}),(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsx)("label",{htmlFor:"ExportFormat",children:"Export Format"}),(0,Q.jsxs)("select",{id:"ExportFormat",value:i,onChange:t=>{n(t.target.value);try{localStorage.setItem("exportFileType",t.target.value)}catch(t){}},children:[(0,Q.jsx)("option",{value:"png",children:".png"}),(0,Q.jsx)("option",{value:"vl2",children:".vl2"})]})]})]})})}):null,(0,Q.jsx)("button",{type:"button",onClick:()=>{W({name:e.current?e.current.value:"",format:i})},children:"Export"})]})]})}function cp(){return(0,Q.jsxs)("footer",{className:"AppFooter",children:[(0,Q.jsx)("a",{href:"https://github.com/exogen/t2-model-skinner",className:"IconLink",children:(0,Q.jsx)(hP.FaGithub,{size:24})}),(0,Q.jsxs)("div",{className:"Sponsor",children:[(0,Q.jsx)("a",{href:"https://github.com/sponsors/exogen",target:"_blank",rel:"noreferrer",children:"Support this project"})," ",(0,Q.jsx)("span",{className:"Separator",children:"or"})," ",(0,Q.jsx)("a",{href:"https://www.buymeacoffee.com/mosswood",target:"_blank",rel:"noreferrer",children:(0,Q.jsx)("img",{src:"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png",alt:"Buy Me A Coffee",width:109,height:31})})]})]})}async function cm(t){return await s7.fromURL(t,{crossOrigin:"anonymous"})}var cv=t.i(55519);function cy(){let e=(0,J.useRef)(null),r=(0,J.useRef)(null),i=(0,J.useMemo)(()=>({async combineColorAndAlphaImageUrls(){for(var t=arguments.length,e=Array(t),i=0;i<t;i++)e[i]=arguments[i];let n=r.current;return await (null==n?void 0:n.combineColorAndAlphaImageUrls(...e))},async removeAlphaFromArrayBuffer(){for(var t=arguments.length,e=Array(t),i=0;i<t;i++)e[i]=arguments[i];let n=r.current;return await (null==n?void 0:n.removeAlphaFromArrayBuffer(...e))},async convertArrayBufferAlphaToGrayscale(){for(var t=arguments.length,e=Array(t),i=0;i<t;i++)e[i]=arguments[i];let n=r.current;return await (null==n?void 0:n.convertArrayBufferAlphaToGrayscale(...e))},async convertGrayscaleImageUrlToMetallicRoughness(){for(var t=arguments.length,e=Array(t),i=0;i<t;i++)e[i]=arguments[i];let n=await r.current;return null==n?void 0:n.convertGrayscaleImageUrlToMetallicRoughness(...e)}}),[]);return(0,J.useEffect)(()=>{let i=new Worker(t.r(79702)),n=cv.wrap(i);return e.current=i,r.current=n,()=>{n[cv.releaseProxy](),r.current=null,i.terminate()}},[]),i}function cx(){return{canvasPadding:64,basePath:"/t2-model-skinner"}}var cb=t.i(54826);let{materials:c_}=cd.default,cw=[512,512];function cC(e){var r,i;let{children:n}=e,{actualModel:s,selectedModelType:o}=hV(),[a,l]=(0,J.useState)(0),[h,c]=(0,J.useState)(0),[u,d]=(0,J.useState)(1),f=c_[s],g=null!=(r=f[a])?r:null,p=null!=(i=g.frameCount)?i:1,m=p>1,[y,x]=(0,J.useState)([]),b=(0,J.useMemo)(()=>{var t;let[e,r]=null!=(t=g.size)?t:cw;return[e*u,r*u]},[g.size,u]),_=0!==g.metallicFactor||1!==g.roughnessFactor,[w,C]=(0,J.useState)("color");_||"metallic"!==w||C("color"),h>=p&&c(0),(0,J.useEffect)(()=>{try{let t=localStorage.getItem("sizeMultiplier");switch(t){case"1":case"2":case"4":d(+t)}}catch(t){}},[]),(0,J.useEffect)(()=>{x(f.map(t=>!!(t&&!1!==t.selectable&&!t.hidden)))},[f]),(0,J.useEffect)(()=>{c(0)},[g]);let[S,T]=(0,J.useState)("black"),[O,k]=(0,J.useState)(()=>new Set),[M,E]=(0,J.useState)(200),[D,j]=(0,J.useState)(10),[A,P]=(0,J.useState)(()=>new Map),[F,L]=(0,J.useState)(()=>[]),R=g?"".concat(g.name,":").concat(w,":").concat(h,":").concat(u):null,I=g?"".concat(g.name,":metallic:").concat(h,":").concat(u):null,{canvases:B}=oZ(),{canvas:N,notifyChange:W,undo:U,redo:H,canUndo:X,canRedo:V}=oZ(R),{canvas:Y,setDrawingMode:z}=oZ(I),{combineColorAndAlphaImageUrls:G}=cy(),{canvasPadding:q}=cx(),[K,Z]=(0,J.useState)(()=>[]),[$,tt]=(0,J.useState)("BaseLayer");F.length?"SelectedLayer"!==$&&tt("SelectedLayer"):"SelectedLayer"===$&&tt("BaseLayer");let te=(0,J.useCallback)((t,e)=>{var r,i,n;let s=[],o=new Map(A),a=F;for(let l of("AllLayers"===$?a=null!=(r=null==N?void 0:N._objects)?r:[]:"BaseLayer"===$&&(a=null!=(i=null==N?void 0:N._objects.slice(0,1))?i:[]),a))if(l instanceof s7){let r={...null!=(n=A.get(l))?n:{},[t]:e};o.set(l,r),s.push([l,r])}P(o),Z(s)},[N,$,A,F]),tr=t=>{var e,r;let i=+("Opacity"===t),n=F;if("AllLayers"===$?n=null!=(e=null==N?void 0:N._objects)?e:[]:"BaseLayer"===$&&(n=null!=(r=null==N?void 0:N._objects.slice(0,1))?r:[]),!(n=n.filter(t=>t instanceof s7)).length)return[i,e=>te(t,e)];{let e=e=>{var r,s;return null!=(s=(null!=(r=A.get(n[e]))?r:{})[t])?s:i},r=e(0);return n.slice(1).every((t,i)=>e(i+1)===r)?[r,e=>te(t,e)]:[null,e=>te(t,e)]}},[ti,tn]=tr("HueRotation"),[ts,to]=tr("Saturation"),[ta,tl]=tr("Brightness"),[th,tc]=tr("Contrast"),[tu,td]=tr("Opacity");(0,J.useEffect)(()=>{if(K.length){for(let[t,e]of K)if(t instanceof s7){if(t.filters=[],"metallic"===w){let e=new oQ.Grayscale;t.filters.push(e)}for(let r in e){let i=e[r];if(null!=i)switch(r){case"HueRotation":t.filters.push(new oQ.HueRotation({rotation:i}));break;case"Saturation":t.filters.push(new oQ.Saturation({saturation:i}));break;case"Brightness":t.filters.push(new oQ.Brightness({brightness:i}));break;case"Contrast":t.filters.push(new oQ.Contrast({contrast:i}));break;case"Opacity":t.opacity=i}}t.applyFilters()}Z([]),W&&W()}},[K,w,W]);let tf=(0,J.useCallback)(()=>{F.length&&k(t=>{let e=new Set(t);for(let t of F)e.add(t),t.lockMovementX=!0,t.lockMovementY=!0,t.lockScalingX=!0,t.lockScalingY=!0,t.lockRotation=!0;return e})},[F]),tg=(0,J.useCallback)(()=>{F.length&&k(t=>{let e=new Set(t);for(let t of F)e.delete(t),t.lockMovementX=!1,t.lockMovementY=!1,t.lockScalingX=!1,t.lockScalingY=!1,t.lockRotation=!1;return e})},[F]),tp=(0,J.useCallback)(async()=>{let t=N.getActiveObject();t&&(N.bringObjectForward(t,!0),W())},[N,W]),tm=(0,J.useCallback)(async()=>{let t=N.getActiveObject();if(t){if(N._objects[0]===t||N._objects[1]===t)return;N.sendObjectBackwards(t,!0),W()}},[N,W]),tv=(0,J.useCallback)(async t=>{let e;for(let r of t){let t=await cm(r);if(!t.width||!t.height)throw Error("Zero-height image");let i=t.width/b[0],n=t.height/b[1];if(i>1||n>1){let e;t.scaleX=e=i>n?1/i:1/n,t.scaleY=e}if("metallic"===w){t.filters||(t.filters=[]);let e=new oQ.Grayscale;t.filters.push(e),t.applyFilters()}Y&&z(!1),N.centerObject(t),N.add(t),e=t}e&&(N.setActiveObject(e),N.requestRenderAll())},[b,w,Y,N,z]),ty=(0,J.useCallback)(async()=>{let t=N.getActiveObject();if(t){var e,r;let i=await t.clone();i.set({top:(null!=(e=i.top)?e:0)+20,left:(null!=(r=i.left)?r:0)+20,evented:!0}),"activeSelection"===i.type&&(i.canvas=N,i.forEachObject(t=>{N.add(t)}),i.setCoords()),N.discardActiveObject(),N.add(i),N.setActiveObject(i)}},[N]),tx=(0,J.useCallback)(async()=>{let t=N.getActiveObjects();N.discardActiveObject(),N.remove(...t),N.requestRenderAll()},[N]),tb=(0,J.useCallback)(async()=>{if("color"===w&&Y){let t=N.toDataURL({format:"png",multiplier:1,top:q,left:q,width:b[0],height:b[1]}),e=await cm(t);e.filters||(e.filters=[]);let r=new oQ.Grayscale;e.filters.push(r),e.applyFilters(),Y.centerObject(e),Y.add(e),Y.setActiveObject(e),z(!1),C("metallic")}},[Y,N,w,q,z,b]),t_=(0,J.useCallback)(async e=>{let{format:r,name:i=""}=e,{savePngFile:n,saveZipFile:a,createZipFile:l}=await t.A(91135);i=i.trim()||"MyCustomSkin";let h=await Promise.all(f.filter((t,e)=>!1!==y[e]).map(t=>{var e;let r=null!=(e=t.frameCount)?e:1;return Array(r).fill(null).map(async(e,n)=>{var a,l,h,c;let d,f,g=null==(a=B["".concat(t.name,":color:").concat(n,":").concat(u)])?void 0:a.canvas,p=null==(l=B["".concat(t.name,":metallic:").concat(n,":").concat(u)])?void 0:l.canvas,m=null!=(h=t.size)?h:cw,y=[m[0]*u,m[1]*u],x=g.toDataURL({format:"png",multiplier:1,top:q,left:q,width:y[0],height:y[1]});if(p){let t=p.toDataURL({format:"png",multiplier:1,top:q,left:q,width:y[0],height:y[1]});d=await G({colorImageUrl:x,metallicImageUrl:t})}else d=x;switch(o){case"player":f="".concat(i,".").concat(s,".png");break;case"weapon":case"vehicle":if(t){let e=null!=(c=t.file)?c:t.name;if(r>1){let t=e.match(/^(.+)(\d\d)$/);if(t){let e=t[1];f="".concat(e).concat(n.toString().padStart(2,"0"),".png")}else throw Error("Unexpected animation filename")}else f="".concat(e,".png")}else f="weapon"===o?"weapon_".concat(s,".png"):"".concat(s,".png");break;default:throw Error("Unknown model type")}return{imageUrl:d,filename:f}})}).flat());switch(r){case"png":h.forEach(t=>{let{imageUrl:e,filename:r}=t;n(e,r)});break;case"vl2":{let t=l(await Promise.all(h.map(async t=>({data:await (0,cb.imageUrlToArrayBuffer)(t.imageUrl),name:t.filename})))),e=s.replace(/(?:^([a-z])|_([a-z]))/g,(t,e,r)=>(e||r).toUpperCase()),r="",n=u>1?"-@".concat(u,"x"):"";switch(o){case"player":r="zPlayerSkin-".concat(i).concat(n,".vl2");break;case"weapon":r="zWeapon".concat(e,"-").concat(i).concat(n,".vl2");break;case"vehicle":r="z".concat(e,"-").concat(i).concat(n,".vl2")}await a(t,r)}}},[f,y,B,u,q,o,G,s]),tw=(0,J.useMemo)(()=>({activeCanvas:R,activeCanvasType:w,setActiveCanvasType:C,backgroundColor:S,setBackgroundColor:T,lockedObjects:O,setLockedObjects:k,brushColor:M,setBrushColor:E,brushSize:D,setBrushSize:j,hueRotate:ti,setHueRotate:tn,saturation:ts,setSaturation:to,brightness:ta,setBrightness:tl,contrast:th,setContrast:tc,opacity:tu,setOpacity:td,layerMode:$,setLayerMode:tt,selectedObjects:F,lockSelection:tf,unlockSelection:tg,bringForward:tp,sendBackward:tm,addImages:tv,duplicate:ty,deleteSelection:tx,undo:U,redo:H,canUndo:X,canRedo:V,copyToMetallic:tb,exportSkin:t_,selectedMaterialIndex:a,setSelectedMaterialIndex:l,textureSize:b,hasMetallic:_,selectedFrameIndex:h,setSelectedFrameIndex:c,hasAnimation:m,frameCount:p,sizeMultiplier:u,setSizeMultiplier:d,selectedExportMaterials:y,setSelectedExportMaterials:x}),[R,w,S,O,M,D,ti,tn,ts,to,ta,tl,th,tc,tu,td,$,F,tf,tg,tp,tm,tv,ty,tx,U,H,X,V,tb,t_,a,b,_,h,m,p,u,y]);return(0,J.useEffect)(()=>{if(N){let t=()=>{L(N.getActiveObjects())};return N.on("selection:cleared",t),N.on("selection:updated",t),N.on("selection:created",t),t(),()=>{N.off("selection:cleared",t),N.off("selection:updated",t),N.off("selection:created",t)}}},[N]),(0,J.useEffect)(()=>{Y&&(Y.freeDrawingBrush||(Y.freeDrawingBrush=new sx(Y)),Y.freeDrawingBrush.width=D)},[Y,D]),(0,J.useEffect)(()=>{Y&&(Y.freeDrawingBrush||(Y.freeDrawingBrush=new sx(Y)),Y.freeDrawingBrush.color="rgb(".concat(M,", ").concat(M,", ").concat(M,")"))},[Y,M]),(0,Q.jsx)(o$.Provider,{value:tw,children:n})}function cS(){let{backgroundColor:t,textureSize:e}=o0(),{canvasPadding:r}=cx();return e?(0,Q.jsx)("div",{className:"CanvasBackdrop",style:{backgroundColor:t,top:r,width:e[0],height:e[1]}}):null}function cT(t){let{children:e}=t,[r,i]=(0,J.useState)({}),n=(0,J.useCallback)((t,e)=>{i(r=>({...r,[t]:e}))},[]),s=(0,J.useCallback)(t=>{i(e=>{let{[t]:r,...i}=e;return i})},[]),o=(0,J.useMemo)(()=>({canvases:r,registerCanvas:n,unregisterCanvas:s}),[r,n,s]);return(0,Q.jsx)(oJ.Provider,{value:o,children:e})}function cO(t){let{children:e}=t,r=(0,J.useRef)(null),{activeCanvas:i,activeCanvasType:n,bringForward:s,sendBackward:o,duplicate:a,deleteSelection:l,addImages:h,undo:c,redo:u}=o0(),{canvas:d,notifyChange:f,setDrawingMode:g}=oZ(i),p=async function(){let{top:t=0,left:e=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(let n of d.getActiveObjects()){var r,i;n.top=(null!=(r=n.top)?r:0)+t,n.left=(null!=(i=n.left)?i:0)+e,n.setCoords()}f()};return(0,Q.jsx)("div",{className:"CanvasInteractions",tabIndex:0,ref:r,onDragOver:t=>{t.preventDefault()},onDrop:async t=>{t.preventDefault(),r.current&&r.current.focus();let{items:e}=t.dataTransfer,i=Array.from(e).filter(t=>"file"===t.kind&&t.type.match(/^image\//)),n=await Promise.all(i.map(async t=>{let e=t.getAsFile();if(!e)throw Error("Not a file.");let r=new FileReader;return await new Promise((t,i)=>{r.onload=async e=>{e.target&&"string"==typeof e.target.result?t(e.target.result):i(Error("Failed to load image data."))},r.readAsDataURL(e)})}).filter(Boolean));await h(n)},onKeyDown:async t=>{let e=t.target;if("INPUT"!==e.nodeName&&"TEXTAREA"!==e.nodeName){if(t.ctrlKey||t.metaKey)switch(t.key){case"z":if(t.altKey)return;if(t.shiftKey){t.preventDefault(),u();return}t.preventDefault(),c();return;case"y":if(t.altKey||t.shiftKey)return;t.preventDefault(),u();return}if(!t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey)switch(t.key){case"Backspace":case"Delete":t.preventDefault(),await l();break;case"ArrowLeft":t.preventDefault(),await p({left:-1});break;case"ArrowRight":t.preventDefault(),await p({left:1});break;case"ArrowUp":t.preventDefault(),await p({top:-1});break;case"ArrowDown":t.preventDefault(),await p({top:1});break;case"d":t.preventDefault(),await a();break;case"f":t.preventDefault(),await s();break;case"b":t.preventDefault(),await o();break;case"p":"metallic"===n&&(t.preventDefault(),g(!0));break;case"s":"metallic"===n&&(t.preventDefault(),g(!1))}}},children:e})}function ck(){let{activeCanvasType:t,setActiveCanvasType:e,hasMetallic:r,hasAnimation:i,frameCount:n,selectedFrameIndex:s,setSelectedFrameIndex:o,sizeMultiplier:a,setSizeMultiplier:l}=o0();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)("div",{className:"CanvasToggle",children:[(0,Q.jsx)("button",{type:"button","data-selected":"color"===t?"":void 0,onClick:()=>{e("color")},children:"Color"}),r?(0,Q.jsx)("button",{type:"button","data-selected":"metallic"===t?"":void 0,onClick:()=>{e("metallic")},children:"Metallic"}):null]}),(0,Q.jsxs)("div",{className:"CanvasToggle",style:{display:"none"},children:[(0,Q.jsx)("button",{type:"button","data-selected":1===a?"":void 0,onClick:()=>{l(1)},children:"1×"}),(0,Q.jsx)("button",{type:"button","data-selected":2===a?"":void 0,onClick:()=>{l(2)},children:"2×"}),(0,Q.jsx)("button",{type:"button","data-selected":4===a?"":void 0,onClick:()=>{l(4)},children:"4×"})]}),i?(0,Q.jsxs)("div",{className:"FrameSelector",children:[(0,Q.jsx)("button",{type:"button",onClick:()=>{o(t=>(n+t-1)%n)},children:(0,Q.jsx)(hP.FaChevronLeft,{})}),(0,Q.jsxs)("span",{className:"FrameInfo",children:[s+1," / ",n]}),(0,Q.jsx)("button",{type:"button",onClick:()=>{o(t=>(t+1)%n)},children:(0,Q.jsx)(hP.FaChevronRight,{})})]}):null]})}var cM=t.i(90106),cE=t.i(53653),cD=t.i(15768);let{defaultSkins:cj,modelDefaults:cA}=cd.default,cP={},cF=new Map;function cL(){var t,e,r,i,n,s;let{selectedModel:o,setSelectedModel:a,selectedModelType:l,setSelectedModelType:h,selectedSkin:c,setSelectedSkin:u,setSelectedSkinType:d,actualModel:f,setSelectedAnimation:g,setAnimationPaused:p,importedSkins:m,addImportedSkins:y}=hV(),{setSelectedMaterialIndex:x}=o0(),[b,_]=(0,J.useState)(cP),[w,C]=(0,J.useState)(cP),[S,T]=(0,J.useState)(null),O=(0,J.useRef)(null),[k,M]=(0,cD.default)(),E=Array.from((null!=(s=m.get(f))?s:cF).values()).filter(t=>t.isComplete);M&&(b!==k.customSkins||w!==k.newSkins)&&(_(k.customSkins),C(k.newSkins));let D=null!=c?c:"";return c&&S&&(D="".concat(S,"/").concat(c)),(0,Q.jsxs)("div",{className:"Toolbar",children:[(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsx)("label",{htmlFor:"ModelSelect",children:"Model"}),(0,Q.jsxs)("select",{id:"ModelSelect",value:o,onChange:t=>{var e,r,i,n;let s=t.target.selectedOptions[0].parentNode,o=t.target.value,l="hfemale"===o?"hmale":o,{modelType:f}=s.dataset;if(!f)throw Error("No data-model-type found");let m=c&&((null==(e=cj[l])?void 0:e.includes(c))||(null==(r=b[l])?void 0:r.includes(c)))||!1,y=!1;c&&"new"===S&&m&&(y=null==(i=w[l])?void 0:i.includes(c)),g(null),p(!1),h(f),a(o),x(0),m||(u(null!=(n=cA[l])?n:null),d("default")),y||T(null)},children:[(0,Q.jsxs)("optgroup",{label:"Players","data-model-type":"player",children:[(0,Q.jsx)("option",{value:"lmale",children:"Human Male • Light"}),(0,Q.jsx)("option",{value:"mmale",children:"Human Male • Medium"}),(0,Q.jsx)("option",{value:"hmale",children:"Human Male • Heavy"}),(0,Q.jsx)("option",{value:"lfemale",children:"Human Female • Light"}),(0,Q.jsx)("option",{value:"mfemale",children:"Human Female • Medium"}),(0,Q.jsx)("option",{value:"hfemale",children:"Human Female • Heavy"}),(0,Q.jsx)("option",{value:"lbioderm",children:"Bioderm • Light"}),(0,Q.jsx)("option",{value:"mbioderm",children:"Bioderm • Medium"}),(0,Q.jsx)("option",{value:"hbioderm",children:"Bioderm • Heavy"})]}),(0,Q.jsxs)("optgroup",{label:"Weapons","data-model-type":"weapon",children:[(0,Q.jsx)("option",{value:"disc",children:"Disc Launcher"}),(0,Q.jsx)("option",{value:"chaingun",children:"Chaingun"}),(0,Q.jsx)("option",{value:"grenade_launcher",children:"Grenade Launcher"}),(0,Q.jsx)("option",{value:"sniper",children:"Laser Rifle"}),(0,Q.jsx)("option",{value:"plasmathrower",children:"Plasma Cannon"}),(0,Q.jsx)("option",{value:"energy",children:"Blaster"}),(0,Q.jsx)("option",{value:"shocklance",children:"Shocklance"}),(0,Q.jsx)("option",{value:"elf",children:"ELF Projector"}),(0,Q.jsx)("option",{value:"missile",children:"Missile Launcher"}),(0,Q.jsx)("option",{value:"mortar",children:"Mortar"}),(0,Q.jsx)("option",{value:"repair",children:"Repair Pack"}),(0,Q.jsx)("option",{value:"targeting",children:"Targeting Laser"}),(0,Q.jsx)("option",{value:"mine",children:"Mine"})]}),(0,Q.jsxs)("optgroup",{label:"Vehicles","data-model-type":"vehicle",children:[(0,Q.jsx)("option",{value:"vehicle_grav_scout",children:"Wildcat Grav Cycle"}),(0,Q.jsx)("option",{value:"vehicle_grav_tank",children:"Beowulf Assault Tank"}),(0,Q.jsx)("option",{value:"vehicle_land_mpbbase",children:"Jericho Mobile Point Base"}),(0,Q.jsx)("option",{value:"vehicle_air_scout",children:"Shrike Scout Fighter"}),(0,Q.jsx)("option",{value:"vehicle_air_bomber",children:"Thundersword Bomber"}),(0,Q.jsx)("option",{value:"vehicle_air_hapc",children:"HAVOC Gunship Transport"})]})]})]}),(0,Q.jsxs)("div",{className:"Field",children:[(0,Q.jsx)("label",{htmlFor:"SkinSelect",children:"Skin"}),(0,Q.jsxs)("div",{className:"Buttons",children:[(0,Q.jsxs)("select",{id:"SkinSelect",value:D,onChange:t=>{var e,r;let i=t.target.selectedOptions[0].parentNode,n=t.target.value&&null!=(e=i.dataset.skinType)?e:null,s=t.target.value.split("/");u(null!=(r=s.slice(-1)[0])?r:null),d(n),s.length>1?T(s[0]):T(null)},children:[(0,Q.jsx)("option",{value:"",children:"Select a skin…"}),"player"===l?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("optgroup",{label:"Default Skins","data-skin-type":"default",children:null==(t=cj[f])?void 0:t.map(t=>(0,Q.jsx)("option",{value:t,children:t},t))}),E.length?(0,Q.jsx)("optgroup",{label:"Imported Skins","data-skin-type":"import",children:E.map(t=>{var e,r;return(0,Q.jsx)("option",{value:"import/".concat(null!=(e=t.name)?e:"__untitled__"),children:t.name||"Untitled Imported Skin"},"import/".concat(null!=(r=t.name)?r:"__untitled__"))})}):null,(null==(e=w[f])?void 0:e.length)?(0,Q.jsx)("optgroup",{label:"New Skins ✨","data-skin-type":"custom",children:null==(r=w[f])?void 0:r.map(t=>(0,Q.jsxs)("option",{value:"new/".concat(t),children:[t," ✨"]},"new/".concat(t)))}):null,(0,Q.jsx)("optgroup",{label:"Custom Skins","data-skin-type":"custom",children:b===cP?(0,Q.jsx)("option",{value:"",children:"Loading…"},"loading"):null==(i=b[f])?void 0:i.map(t=>(0,Q.jsx)("option",{value:t,children:t},t))})]}):null,"weapon"===l||"vehicle"===l?(0,Q.jsxs)(Q.Fragment,{children:[cA[f]?(0,Q.jsx)("optgroup",{label:"Default Skins","data-skin-type":"default",children:(0,Q.jsx)("option",{value:cA[f],children:"Default"})}):null,E.length?(0,Q.jsx)("optgroup",{label:"Imported Skins","data-skin-type":"import",children:E.map(t=>{var e,r;return(0,Q.jsx)("option",{value:"import/".concat(null!=(e=t.name)?e:"__untitled__"),children:t.name||"Untitled Imported Skin"},"import/".concat(null!=(r=t.name)?r:"__untitled__"))})}):null,(null==(n=b[f])?void 0:n.length)?(0,Q.jsx)("optgroup",{label:"Custom Skins","data-skin-type":"custom",children:b[f].map(t=>(0,Q.jsx)("option",{value:t,children:t},t))}):null]}):null]}),(0,Q.jsx)("button",{type:"button","aria-label":"Load Skin",title:"Load a Skin",onClick:()=>{O.current&&O.current.click()},children:(0,Q.jsx)(hP.FaFolderOpen,{style:{fontSize:18}})}),(0,Q.jsx)("input",{ref:O,onChange:async t=>{var e,r,i;let n=await (0,cE.importMultipleFilesToModels)(null!=(e=t.target.files)?e:[]);y(n);let s=n.get(f);if(s){let t=Array.from(s.values()).filter(t=>t.isComplete);if(t.length){let e=t[0];d("import"),T("import"),u(null!=(r=e.name)?r:"__untitled__"),x(0),g(null);return}}for(let[t,e]of Array.from(n.entries()))for(let r of Array.from(e.values()))if(r.isComplete){a(t),h((0,cE.modelToModelType)(t)),d("import"),T("import"),u(null!=(i=r.name)?i:"__untitled__"),x(0),g(null);break}},type:"file",accept:".png, image/png, .vl2, .zip, application/zip, application/zip-compressed",multiple:!0,hidden:!0})]})]}),(0,Q.jsx)("div",{className:"Field GalleryField",children:(0,Q.jsxs)("a",{href:"gallery/",target:"_blank",className:"GalleryLink",title:"Open skin gallery",children:[(0,Q.jsx)("span",{className:"FieldLabel",children:"Gallery"}),(0,Q.jsx)(cM.BsFillGrid3X3GapFill,{})]})})]})}var cR=t.i(18566),cI=t.i(96165);let{materials:cB,modelDefaults:cN,defaultSkins:cW}=cd.default,cU=new Map;function cH(t,e){if(e<2)return[t];let r=t.match(/^(.+)(\d\d)$/);if(r){let t=r[1];return Array(e).fill(null).map((e,r)=>"".concat(t).concat(r.toString().padStart(2,"0")))}throw Error("Did not match expected frame format")}function cX(t){let{basePath:e,actualModel:r,selectedModelType:i,selectedSkin:n,selectedSkinType:s}=t,o=cB[r];if(n&&"import"===s){let t=cU.get(r);if(t){let e="__untitled__"===n?null:n,r=t.get(e);if(r&&r.isComplete)return Object.fromEntries(r.materials)}throw Error("No skin found")}switch(i){case"player":switch(s){case"default":return{base:["".concat(e,"/textures/").concat(n,".").concat(r,".png")]};case"custom":return{base:["".concat(cI.SKIN_ASSET_BASE_URL,"/").concat(n,".").concat(r,".png")]}}break;case"weapon":case"vehicle":return o.reduce((t,r)=>{if(r){var i,o,a,l,h;let c=null!=(i=r.frameCount)?i:1;switch(s){case"default":!1!==r.hasDefault&&(t[null!=(o=r.file)?o:r.name]=cH(null!=(a=r.file)?a:r.name,c).map(t=>"".concat(e,"/textures/").concat(t,".png")));break;case"custom":t[null!=(l=r.file)?l:r.name]=cH(null!=(h=r.file)?h:r.name,c).map(t=>"".concat(cI.SKIN_ASSET_BASE_URL,"/").concat(n,"/").concat(t,".png"))}}return t},{})}return{}}function cV(t){var e,r;let{children:i}=t,n=(0,cR.useRouter)(),s=(0,cR.usePathname)(),o=(0,cR.useSearchParams)(),[a,l]=(0,J.useState)(!1),[h,c]=(0,J.useState)("lmale"),[u,d]=(0,J.useState)("player"),[f,g]=(0,J.useState)("Blood Eagle"),[p,m]=(0,J.useState)("default"),[y,x]=(0,J.useState)(null),[b,_]=(0,J.useState)(!1),[w,C]=(0,J.useState)(!1),{basePath:S}=cx(),T="hfemale"===h?"hmale":h,O="".concat(S,"/").concat(T).concat(y?".anim":"",".glb"),[k,M]=(0,J.useState)(cU),E=(0,J.useCallback)(t=>{let e=new Map(cU.entries());t.forEach((t,r)=>{var i;let n=null!=(i=e.get(r))?i:new Map;t.forEach((t,e)=>{n.set(e,t)}),e.set(r,n)}),M(cU=e)},[]),[D,j]=(0,J.useState)(()=>cX({basePath:S,actualModel:T,selectedModelType:u,selectedSkin:f,selectedSkinType:p})),A=(0,J.useMemo)(()=>cX({basePath:S,actualModel:T,selectedModelType:u,selectedSkin:cN[T],selectedSkinType:"default"}),[T,S,u]),P=(0,J.useMemo)(()=>({selectedModel:h,setSelectedModel:c,selectedModelType:u,setSelectedModelType:d,actualModel:T,selectedModelUrl:O,animationPaused:b,setAnimationPaused:_,selectedSkin:f,setSelectedSkin:g,selectedSkinType:p,setSelectedSkinType:m,selectedAnimation:y,setSelectedAnimation:x,skinImageUrls:D,setSkinImageUrls:j,defaultSkinImageUrls:A,slowModeEnabled:w,setSlowModeEnabled:C,importedSkins:k,addImportedSkins:E}),[h,c,u,d,T,O,b,_,f,g,p,m,y,x,D,j,A,w,k,E]);if(!a){let t=o.get("m"),i=o.get("s");if("string"==typeof t){let n=function(t){switch(t){case"lmale":case"mmale":case"hmale":case"lfemale":case"mfemale":case"hfemale":case"lbioderm":case"mbioderm":case"hbioderm":return"player";case"disc":case"chaingun":case"grenade_launcher":case"sniper":case"plasmathrower":case"energy":case"shocklance":case"elf":case"missile":case"mortar":case"repair":case"targeting":case"mine":return"weapon";case"vehicle_grav_scout":case"vehicle_grav_tank":case"vehicle_land_mpbbase":case"vehicle_air_scout":case"vehicle_air_bomber":case"vehicle_air_hapc":return"vehicle";default:return null}}(t);if(n&&(c(t),d(n),"string"==typeof i)){let n=i===cN[e="hfemale"===t?"hmale":t]||(null==(r=cW[e])?void 0:r.includes(i))?"default":"custom";g(i),m(n)}}l(!0)}return(0,J.useEffect)(()=>{if(!f)return;let t=o.get("m"),e=o.get("s");if(t!==h||e!==f){let t=new URLSearchParams(o);t.set("m",h),t.set("s",f);let e="".concat(s,"?").concat(t);n.replace(e,{scroll:!1})}},[s,n,o,h,f]),(0,J.useEffect)(()=>{if(f)try{let t=cX({basePath:S,actualModel:T,selectedModelType:u,selectedSkin:f,selectedSkinType:p});j(t)}catch(t){m("default"),g(cN[T])}},[T,S,u,f,p]),(0,Q.jsx)(hX.Provider,{value:P,children:i})}var cY=t.i(70703);let cz=J.default.createContext(null);function cG(){let t=(0,J.useContext)(cz);if(!t)throw Error("No EnvironmentContext.Provider");return t}cz.displayName="EnvironmentContext";let cq=J.default.createContext(null);function cK(){let t=(0,J.useContext)(cq);if(!t)throw Error("No SkinContext.Provider");return t}cq.displayName="SkinContext";var cQ=t.i(63871);function cJ(t){let{material:e,materialDef:r,textureType:i,imageUrl:n,frameRef:s,onReady:o}=t,{modelViewer:a}=(0,cQ.default)(),{basePath:l}=cx(),{slowModeEnabled:h}=hV();(0,J.useEffect)(()=>{let t,c=!1;return(async()=>{if(!r||r.hidden)if("metallicRoughnessTexture"===i){o&&o();return}else e.setAlphaMode("BLEND"),e.pbrMetallicRoughness.setBaseColorFactor([0,0,0,0]),o&&o();else{let{alphaMode:u,alphaCutoff:d,baseColorFactor:f,emissiveFactor:g,emissiveTexture:p=!1,metallicFactor:m=1,roughnessFactor:y=1,frameCount:x=1,frameTimings:b}=r,_=null!=n?n:Array(x).fill("".concat(l,"/white.png"));if(_.some(t=>!t))return;switch(i){case"baseColorTexture":f&&e.pbrMetallicRoughness.setBaseColorFactor(f),u&&e.setAlphaMode(u),d&&e.setAlphaCutoff(d),g&&e.setEmissiveFactor(g);break;case"metallicRoughnessTexture":e.pbrMetallicRoughness.setMetallicFactor(m),e.pbrMetallicRoughness.setRoughnessFactor(y),0===m&&1===y&&(_=Array(x).fill("".concat(l,"/green.png")))}let w=await Promise.all(_.map(t=>a.createTexture(t)));if(!c){let r="baseColorTexture"===i,n=s.current,a=()=>{let s=w[n.frameIndex];if(e.pbrMetallicRoughness[i].setTexture(s),r&&p&&e.emissiveTexture.setTexture(s),r&&(n.frameProgress+=h?.05:1),x>1){var o;let e=null!=(o=null==b?void 0:b[n.frameIndex])?o:1;r&&n.frameProgress>=e&&(n.frameIndex=(n.frameIndex+1)%x,n.frameProgress=0),t=requestAnimationFrame(a)}};a(0),o&&o()}}})(),()=>{c=!0,null!=t&&cancelAnimationFrame(t)}},[l,a,e,r,i,n,s,h,o])}function cZ(t){var e,r;let{material:i,materialDef:n,onReady:s}=t,{getSkinImages:o}=cK(),{colorImageUrl:a,metallicImageUrl:l}=null!=(r=o(null!=(e=null==n?void 0:n.file)?e:i.name))?r:{},h=(0,J.useRef)({frameIndex:0,frameProgress:0});return cJ({material:i,materialDef:n,textureType:"baseColorTexture",imageUrl:a,frameRef:h}),cJ({material:i,materialDef:n,textureType:"metallicRoughnessTexture",imageUrl:l,frameRef:h}),null}let{materials:c$}=cd.default;function c0(){let{actualModel:t}=hV(),{model:e}=(0,cQ.default)(),r=c$[t];return(0,Q.jsx)(Q.Fragment,{children:e.materials.map((t,e)=>{let i=r[e];return(0,Q.jsx)(cZ,{material:t,materialDef:i},t.name)})})}let c1=(0,cY.default)(()=>t.A(22143),{loadableGenerated:{modules:[66641]},ssr:!1}),{cameraOverrides:c2}=cd.default;function c5(){var t,e,r,i;let{selectedModel:n,selectedModelUrl:s,selectedModelType:o,selectedAnimation:a,animationPaused:l,slowModeEnabled:h}=hV(),{environmentImageUrl:c,showEnvironment:u,exposure:d}=cG();return(0,Q.jsx)(c1,{modelUrl:s,environmentImageUrl:c,showEnvironment:u,animationName:a,animationPaused:l,timeScale:h?.05:.5,cameraOrbit:null!=(i=null==(t=c2[n])?void 0:t.orbit)?i:"weapon"===o?"315deg 70deg 105%":void 0,cameraTarget:null==(e=c2[n])?void 0:e.target,fieldOfView:null==(r=c2[n])?void 0:r.fov,exposure:d,children:(0,Q.jsx)(c0,{})})}function c4(){let{selectedEnvironment:t,setSelectedEnvironment:e}=cG();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("label",{htmlFor:"EnvMapSelect",children:"Environment"}),(0,Q.jsxs)("select",{id:"EnvMapSelect",value:null!=t?t:"",onChange:t=>{e(t.target.value||null)},children:[(0,Q.jsx)("option",{value:"",children:"Default"}),(0,Q.jsx)("option",{value:"clarens_night_02_1k.hdr",children:"Clarens Night"}),(0,Q.jsx)("option",{value:"dry_cracked_lake_1k.hdr",children:"Dry Cracked Lake"}),(0,Q.jsx)("option",{value:"fouriesburg_mountain_midday_1k.hdr",children:"Fouriesburg Mountain"}),(0,Q.jsx)("option",{value:"goegap_1k.hdr",children:"Goegap"}),(0,Q.jsx)("option",{value:"hilly_terrain_01_1k.hdr",children:"Hilly Terrain"}),(0,Q.jsx)("option",{value:"kloofendal_48d_partly_cloudy_puresky_1k.hdr",children:"Kloofendal Partly Cloudy"}),(0,Q.jsx)("option",{value:"kloppenheim_06_puresky_1k.hdr",children:"Kloppenheim"}),(0,Q.jsx)("option",{value:"lilienstein_1k.hdr",children:"Lilienstein"}),(0,Q.jsx)("option",{value:"spruit_sunrise_1k_HDR.hdr",children:"Spruit Sunrise"}),(0,Q.jsx)("option",{value:"umhlanga_sunrise_1k.hdr",children:"Umhlanga Sunrise"})]})]})}function c3(){let{exposure:t,setExposure:e}=cG();return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)("label",{htmlFor:"EnvExposure",children:(0,Q.jsx)(hU,{size:16})}),(0,Q.jsx)("input",{"aria-label":"Exposure",id:"EnvExposure",type:"range",min:.2,max:2.2,step:.1,value:t,onChange:t=>{e(parseFloat(t.target.value))}})]})}let{animations:c9,animationLabels:c6,animationLabelOverrides:c8}=cd.default;function c7(){let{actualModel:t,selectedModelType:e,selectedAnimation:r,setSelectedAnimation:i,animationPaused:n,setAnimationPaused:s,slowModeEnabled:o,setSlowModeEnabled:a}=hV(),l=(0,J.useMemo)(()=>{var r;return[..."player"===e?c9.global:[],...null!=(r=c9[t])?r:[]]},[t,e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)("div",{className:"LabelWithControls",children:[(0,Q.jsx)("label",{children:"Animation"}),(0,Q.jsxs)("div",{className:"AnimationSpeed",children:[(0,Q.jsx)("input",{type:"checkbox",id:"SlowDownCheckbox",checked:o,onChange:t=>{a(t.target.checked)}})," ",(0,Q.jsx)("label",{htmlFor:"SlowDownCheckbox",children:"Slow?"})]})]}),(0,Q.jsxs)("div",{className:"Buttons",children:[(0,Q.jsxs)("select",{value:null!=r?r:"",onChange:t=>{i(t.target.value||null),s(!1)},children:[(0,Q.jsx)("option",{value:"",children:"None"}),l.map(e=>{var r,i;let n=null!=(i=null==(r=c8[t])?void 0:r[e])?i:c6[e];return(0,Q.jsx)("option",{value:e,children:null!=n?n:e},e)})]}),(0,Q.jsx)("button",{type:"button",disabled:!r,onClick:()=>{s(t=>!t)},children:n||!r?(0,Q.jsx)(hI,{}):(0,Q.jsx)(hR,{})})]})]})}function ut(t){let{children:e}=t,[r,i]=(0,J.useState)(null),[n,s]=(0,J.useState)(!1),[o,a]=(0,J.useState)(1),{basePath:l}=cx(),h=(0,J.useMemo)(()=>{let t=r?"".concat(l,"/").concat(r):null;return{selectedEnvironment:r,setSelectedEnvironment:i,showEnvironment:n,setShowEnvironment:s,exposure:o,setExposure:a,environmentImageUrl:t}},[l,r,n,o]);return(0,Q.jsx)(cz.Provider,{value:h,children:e})}function ue(t){let{children:e}=t,[r,i]=(0,J.useState)({}),n=(0,J.useMemo)(()=>({setSkinImages(t,e){i(r=>({...r,[t]:e}))},setColorImageUrl(t,e,r){i(i=>{var n,s;let o=Array.from(null!=(s=null==(n=i[t])?void 0:n.colorImageUrl)?s:[]);return o[r]=e,{...i,[t]:{...i[t],colorImageUrl:o}}})},setMetallicImageUrl(t,e,r){i(i=>{var n,s;let o=Array.from(null!=(s=null==(n=i[t])?void 0:n.metallicImageUrl)?s:[]);return o[r]=e,{...i,[t]:{...i[t],metallicImageUrl:o}}})}}),[]),s=(0,J.useMemo)(()=>({materialSkins:r,getSkinImages:t=>r[t],getColorImageUrl(t,e){var i;return null==(i=r[t].colorImageUrl)?void 0:i[e]},getMetallicImageUrl(t,e){var i;return null==(i=r[t].metallicImageUrl)?void 0:i[e]},...n}),[r,n]);return(0,Q.jsx)(cq.Provider,{value:s,children:e})}let{materials:ur}=cd.default;function ui(){let{actualModel:t}=hV(),{selectedMaterialIndex:e,setSelectedMaterialIndex:r}=o0(),i=ur[t];return(0,Q.jsx)("select",{value:e,onChange:t=>{r(parseInt(t.target.value,10))},children:i.map((t,e)=>{var r;return t&&!t.hidden&&!1!==t.selectable?(0,Q.jsx)("option",{value:e,children:null!=(r=t.label)?r:t.name},t.name):null})})}function un(t){let{canvasId:e,onChange:r,baseImageUrl:i,textureSize:n,defaultDrawingMode:s=!1}=t,o=(0,J.useRef)(null),[a,l]=(0,J.useState)(null),{activeCanvas:h}=o0(),{canvasPadding:c}=cx(),{registerCanvas:u,unregisterCanvas:d}=oZ(),[f,g]=(0,J.useState)(s),p=(0,J.useRef)(null),m=(0,J.useRef)(!0),[y,x]=(0,J.useState)(()=>[]),[b,_]=(0,J.useState)(()=>[]),w=y.length>1,C=b.length>0,S=(0,J.useCallback)(t=>{let e=p.current;e&&e(t)},[]),T=(0,J.useCallback)(async()=>{if(a&&y.length>1){let[t,e]=y.slice(-2);m.current=!1,a.renderOnAddRemove=!1,a.clear(),a.loadFromJSON(t,()=>{a.renderAll(),m.current=!0,a.renderOnAddRemove=!0}),x(t=>t.slice(0,-1)),_(t=>[e,...t])}},[a,y]),O=(0,J.useCallback)(()=>{if(a&&b.length>0){let t=b[0];m.current=!1,a.renderOnAddRemove=!1,a.clear(),a.loadFromJSON(t,()=>{a.renderAll(),m.current=!0,a.renderOnAddRemove=!0}),x(e=>[...e,t]),_(t=>t.slice(1))}},[a,b]);(0,J.useEffect)(()=>{p.current=r},[r]);let k=h===e;return(0,J.useEffect)(()=>{let t;if(!o.current)return;iB.ownDefaults={...iB.ownDefaults,transparentCorners:!1,borderColor:"#8afff1",cornerSize:9,cornerStyle:"circle",cornerColor:"#8afff1",cornerStrokeColor:"#1c9f7c",strokeWidth:10,perPixelTargetFind:!0};let e=new st(o.current,{preserveObjectStacking:!0,targetFindTolerance:2}),r=!1,i=()=>{S(e)};return e.on("object:modified",i),e.on("object:added",i),e.on("object:removed",i),e.on("after:render",()=>{!r&&m.current&&(clearTimeout(t),t=setTimeout(()=>{let t=(()=>{r=!0;let t=e.toDatalessJSON(["lockMovementX","lockMovementY","lockRotation","lockScalingX","lockScalingY","selectable","hoverCursor","moveCursor"]);return r=!1,t})();x(e=>{if(0===e.length)return[t];let r=e[e.length-1];return JSON.stringify(t)===JSON.stringify(r)?e:[...e.slice(-10),t]}),_([])},250))}),l(e),()=>{clearTimeout(t),l(null),e.dispose()}},[S]),(0,J.useEffect)(()=>{a&&(a.isDrawingMode=f,f&&(a.discardActiveObject(),a.requestRenderAll()))},[a,f]),(0,J.useEffect)(()=>{a&&k&&a.calcOffset()},[a,k]),(0,J.useEffect)(()=>{if(a)return u(e,{canvas:a,notifyChange:()=>{a.renderAll(),S(a)},undo:T,redo:O,canUndo:w,canRedo:C,isDrawingMode:f,setDrawingMode:g}),()=>{d(e)}},[a,u,d,e,S,f,g,T,O,w,C]),(0,J.useEffect)(()=>{x([]),_([])},[a,i,n]),(0,J.useEffect)(()=>{if(a&&n&&(m.current=!1,a.clear(),i)){let t=!1;return(async()=>{let e=await cm(i);if(!t){if(!e.width||!e.height)throw Error("Zero-height image");e.selectable=!1,e.lockMovementX=!0,e.lockMovementY=!0,e.lockScalingX=!0,e.lockScalingY=!0,e.lockRotation=!0,e.hoverCursor="default",e.moveCursor="default";let[t,r]=n,i=e.width===t?1:t/e.width,s=e.height===r?1:r/e.height;(1!==i||1!==s)&&(e.scaleX=i,e.scaleY=s),a.centerObject(e),a.add(e)}m.current=!0,a.requestRenderAll()})(),()=>{t=!0}}},[a,i,n]),(0,Q.jsx)("div",{className:"CanvasContainer","data-active":k?"true":"false",children:(0,Q.jsx)("canvas",{width:n[0]+2*c,height:n[1]+2*c,ref:o})})}let us=J.default.createContext(null);function uo(){let t=(0,J.useContext)(us);if(!t)throw Error("ImageLoaderContext.Provider not found!");return t}us.displayName="ImageLoaderContext";let ua=[512,512];function ul(t){var e,r,i,n;let{materialDef:s,frameIndex:o=0}=t,{skinImageUrls:a,defaultSkinImageUrls:l}=hV(),h=null==(e=a[null!=(i=s.file)?i:s.name])?void 0:e[o],c=null==(r=l[null!=(n=s.file)?n:s.name])?void 0:r[o],{setColorImageUrl:u}=cK(),{canvasPadding:d}=cx(),[f,g]=(0,J.useState)(null),{removeAlphaFromArrayBuffer:p}=cy(),{loadImage:m}=uo(),{sizeMultiplier:y}=o0(),x=(0,J.useMemo)(()=>{var t;let[e,r]=null!=(t=s.size)?t:ua;return[e*y,r*y]},[s.size,y]),b=(0,J.useCallback)(async t=>{var e;let r=t.toDataURL({format:"png",multiplier:1,top:d,left:d,width:x[0],height:x[1]});u(null!=(e=s.file)?e:s.name,r,o)},[x,d,u,s,o]);(0,J.useEffect)(()=>{if(h){let t=!1;return(async()=>{let e;try{e=await m(h)}catch(t){if(!1===s.hasDefault)return;e=await m(c)}let r=await p(e);t||g(r)})(),()=>{t=!0}}g(null)},[s,h,c,p,m]);let _="".concat(s.name,":color:").concat(o,":").concat(y);return x?(0,Q.jsx)(un,{canvasId:_,canvasType:"color",onChange:b,baseImageUrl:f,textureSize:x},_):null}let uh=[512,512];function uc(t){var e,r,i,n;let{materialDef:s,frameIndex:o=0}=t,{skinImageUrls:a,defaultSkinImageUrls:l}=hV(),h=null==(e=a[null!=(i=s.file)?i:s.name])?void 0:e[o],c=null==(r=l[null!=(n=s.file)?n:s.name])?void 0:r[o],{setMetallicImageUrl:u}=cK(),{canvasPadding:d}=cx(),[f,g]=(0,J.useState)(null),p=(0,J.useRef)(0),{convertGrayscaleImageUrlToMetallicRoughness:m,convertArrayBufferAlphaToGrayscale:y}=cy(),{loadImage:x}=uo(),{sizeMultiplier:b}=o0(),_=(0,J.useMemo)(()=>{var t;let[e,r]=null!=(t=s.size)?t:uh;return[e*b,r*b]},[s.size,b]),w=(0,J.useCallback)(async t=>{let e;p.current+=1;let r=t.toDataURL({format:"png",multiplier:1,top:d,left:d,width:_[0],height:_[1]});try{e=await m(r)}finally{p.current-=1}if(0===p.current){var i;u(null!=(i=s.file)?i:s.name,e,o)}},[_,d,u,m,s,o]);(0,J.useEffect)(()=>{if(h){let t=!1;return(async()=>{let e;try{e=await x(h)}catch(t){if(!1===s.hasDefault)return;e=await x(c)}let r=await y(e);t||g(r)})(),()=>{t=!0}}g(null)},[s,h,c,_,y,x]);let C="".concat(s.name,":metallic:").concat(o,":").concat(b);return _?(0,Q.jsx)(un,{canvasId:C,canvasType:"metallic",onChange:w,baseImageUrl:f,textureSize:_,defaultDrawingMode:!0},C):null}let{materials:uu}=cd.default;function ud(){let{actualModel:t}=hV(),e=uu[t];return(0,Q.jsx)(Q.Fragment,{children:e.map(e=>{var r;if(!e)return null;let i=0!==e.metallicFactor||1!==e.roughnessFactor,n=Array(null!=(r=e.frameCount)?r:1).fill(null);return(0,Q.jsxs)(J.default.Fragment,{children:[n.map((t,r)=>(0,Q.jsx)(ul,{materialDef:e,frameIndex:r},"color:".concat(r))),i?n.map((t,r)=>(0,Q.jsx)(uc,{materialDef:e,frameIndex:r},"metallic:".concat(r))):null]},"".concat(t,"-").concat(e.name))})})}var uf=J.createContext(void 0),ug=t=>{let{client:e,children:r}=t;return J.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Q.jsx)(uf.Provider,{value:e,children:r})};function up(t){let{children:e}=t,r=(t=>{let e=J.useContext(uf);if(t)return t;if(!e)throw Error("No QueryClient set, use QueryClientProvider to set one");return e})(),i=(0,J.useMemo)(()=>({loadImage:async t=>t.startsWith("data:")?(0,cb.imageUrlToArrayBuffer)(t):await r.fetchQuery({queryKey:[t]})}),[r]);return(0,Q.jsx)(us.Provider,{value:i,children:e})}function um(t,e,r){if(!e.has(t))throw TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function uv(t,e){var r=um(t,e,"get");return r.get?r.get.call(t):r.value}function uy(t,e){if(e.has(t))throw TypeError("Cannot initialize the same private elements twice on an object")}function ux(t,e,r){uy(t,e),e.set(t,r)}function ub(t,e,r){var i=um(t,e,"set");if(i.set)i.set.call(t,r);else{if(!i.writable)throw TypeError("attempted to set read only private field");i.value=r}return r}function u_(t,e){var r=um(t,e,"update");if(r.set){if(!r.get)throw TypeError("attempted to read set only private field");return"__destrWrapper"in r||(r.__destrWrapper={set value(v){r.set.call(t,v)},get value(){return r.get.call(t)}}),r.__destrWrapper}if(!r.writable)throw TypeError("attempted to set read only private field");return r}var uw={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},uC=new(p=new WeakMap,m=new WeakMap,class{setTimeoutProvider(t){ub(this,p,t)}setTimeout(t,e){return uv(this,p).setTimeout(t,e)}clearTimeout(t){uv(this,p).clearTimeout(t)}setInterval(t,e){return uv(this,p).setInterval(t,e)}clearInterval(t){uv(this,p).clearInterval(t)}constructor(){ux(this,p,{writable:!0,value:uw}),ux(this,m,{writable:!0,value:!1})}}),uS="undefined"==typeof window||"Deno"in globalThis;function uT(){}function uO(t,e){return"function"==typeof t?t(e):t}function uk(t,e){let{type:r="all",exact:i,fetchStatus:n,predicate:s,queryKey:o,stale:a}=t;if(o){if(i){if(e.queryHash!==uE(o,e.options))return!1}else if(!uj(e.queryKey,o))return!1}if("all"!==r){let t=e.isActive();if("active"===r&&!t||"inactive"===r&&t)return!1}return("boolean"!=typeof a||e.isStale()===a)&&(!n||n===e.state.fetchStatus)&&(!s||!!s(e))}function uM(t,e){let{exact:r,status:i,predicate:n,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(r){if(uD(e.options.mutationKey)!==uD(s))return!1}else if(!uj(e.options.mutationKey,s))return!1}return(!i||e.state.status===i)&&(!n||!!n(e))}function uE(t,e){return((null==e?void 0:e.queryKeyHashFn)||uD)(t)}function uD(t){return JSON.stringify(t,(t,e)=>uF(e)?Object.keys(e).sort().reduce((t,r)=>(t[r]=e[r],t),{}):e)}function uj(t,e){return t===e||typeof t==typeof e&&!!t&&!!e&&"object"==typeof t&&"object"==typeof e&&Object.keys(e).every(r=>uj(t[r],e[r]))}var uA=Object.prototype.hasOwnProperty;function uP(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function uF(t){if(!uL(t))return!1;let e=t.constructor;if(void 0===e)return!0;let r=e.prototype;return!!uL(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(t)===Object.prototype}function uL(t){return"[object Object]"===Object.prototype.toString.call(t)}function uR(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=[...t,e];return r&&i.length>r?i.slice(1):i}function uI(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=[e,...t];return r&&i.length>r?i.slice(0,-1):i}var uB=Symbol();function uN(t,e){return!t.queryFn&&(null==e?void 0:e.initialPromise)?()=>e.initialPromise:t.queryFn&&t.queryFn!==uB?t.queryFn:()=>Promise.reject(Error("Missing queryFn: '".concat(t.queryHash,"'")))}function uW(t,e,r){if(!e.has(t))throw TypeError("attempted to get private field on non-instance");return r}function uU(t,e){uy(t,e),e.add(t)}var uH=function(t){setTimeout(t,0)},uX=function(){let t=[],e=0,r=t=>{t()},i=t=>{t()},n=uH,s=i=>{e?t.push(i):n(()=>{r(i)})};return{batch:s=>{let o;e++;try{o=s()}finally{--e||(()=>{let e=t;t=[],e.length&&n(()=>{i(()=>{e.forEach(t=>{r(t)})})})})()}return o},batchCalls:t=>function(){for(var e=arguments.length,r=Array(e),i=0;i<e;i++)r[i]=arguments[i];s(()=>{t(...r)})},schedule:s,setNotifyFunction:t=>{r=t},setBatchNotifyFunction:t=>{i=t},setScheduler:t=>{n=t}}}(),uV=class{subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}},uY=new(y=new WeakMap,x=new WeakMap,b=new WeakMap,class extends uV{onSubscribe(){uv(this,x)||this.setEventListener(uv(this,b))}onUnsubscribe(){var t;this.hasListeners()||(null==(t=uv(this,x))||t.call(this),ub(this,x,void 0))}setEventListener(t){var e;ub(this,b,t),null==(e=uv(this,x))||e.call(this),ub(this,x,t(t=>{"boolean"==typeof t?this.setFocused(t):this.onFocus()}))}setFocused(t){uv(this,y)!==t&&(ub(this,y,t),this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){var t;return"boolean"==typeof uv(this,y)?uv(this,y):(null==(t=globalThis.document)?void 0:t.visibilityState)!=="hidden"}constructor(){super(),ux(this,y,{writable:!0,value:void 0}),ux(this,x,{writable:!0,value:void 0}),ux(this,b,{writable:!0,value:void 0}),ub(this,b,t=>{if(!uS&&window.addEventListener){let e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}})}}),uz=new(_=new WeakMap,w=new WeakMap,C=new WeakMap,class extends uV{onSubscribe(){uv(this,w)||this.setEventListener(uv(this,C))}onUnsubscribe(){var t;this.hasListeners()||(null==(t=uv(this,w))||t.call(this),ub(this,w,void 0))}setEventListener(t){var e;ub(this,C,t),null==(e=uv(this,w))||e.call(this),ub(this,w,t(this.setOnline.bind(this)))}setOnline(t){uv(this,_)!==t&&(ub(this,_,t),this.listeners.forEach(e=>{e(t)}))}isOnline(){return uv(this,_)}constructor(){super(),ux(this,_,{writable:!0,value:!0}),ux(this,w,{writable:!0,value:void 0}),ux(this,C,{writable:!0,value:void 0}),ub(this,C,t=>{if(!uS&&window.addEventListener){let e=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}})}});function uG(t){return Math.min(1e3*2**t,3e4)}function uq(t){return(null!=t?t:"online")!=="online"||uz.isOnline()}var uK=class extends Error{constructor(t){super("CancelledError"),this.revert=null==t?void 0:t.revert,this.silent=null==t?void 0:t.silent}};function uQ(t){let e,r=!1,i=0,n=function(){let t,e,r=new Promise((r,i)=>{t=r,e=i});function i(t){Object.assign(r,t),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=e=>{i({status:"fulfilled",value:e}),t(e)},r.reject=t=>{i({status:"rejected",reason:t}),e(t)},r}(),s=()=>uY.isFocused()&&("always"===t.networkMode||uz.isOnline())&&t.canRun(),o=()=>uq(t.networkMode)&&t.canRun(),a=t=>{"pending"===n.status&&(null==e||e(),n.resolve(t))},l=t=>{"pending"===n.status&&(null==e||e(),n.reject(t))},h=()=>new Promise(r=>{var i;e=t=>{("pending"!==n.status||s())&&r(t)},null==(i=t.onPause)||i.call(t)}).then(()=>{if(e=void 0,"pending"===n.status){var r;null==(r=t.onContinue)||r.call(t)}}),c=()=>{let e;if("pending"!==n.status)return;let o=0===i?t.initialPromise:void 0;try{e=null!=o?o:t.fn()}catch(t){e=Promise.reject(t)}Promise.resolve(e).then(a).catch(e=>{var o,a,u;if("pending"!==n.status)return;let d=null!=(a=t.retry)?a:3*!uS,f=null!=(u=t.retryDelay)?u:uG,g="function"==typeof f?f(i,e):f,p=!0===d||"number"==typeof d&&i<d||"function"==typeof d&&d(i,e);if(r||!p)return void l(e);i++,null==(o=t.onFail)||o.call(t,i,e),new Promise(t=>{uC.setTimeout(t,g)}).then(()=>s()?void 0:h()).then(()=>{r?l(e):c()})})};return{promise:n,status:()=>n.status,cancel:e=>{if("pending"===n.status){var r;let i=new uK(e);l(i),null==(r=t.onCancel)||r.call(t,i)}},continue:()=>(null==e||e(),n),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:o,start:()=>(o()?c():h().then(c),n)}}var uJ=(S=new WeakMap,class{destroy(){this.clearGcTimeout()}scheduleGc(){var t;this.clearGcTimeout(),"number"==typeof(t=this.gcTime)&&t>=0&&t!==1/0&&ub(this,S,uC.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,null!=t?t:uS?1/0:3e5)}clearGcTimeout(){uv(this,S)&&(uC.clearTimeout(uv(this,S)),ub(this,S,void 0))}constructor(){ux(this,S,{writable:!0,value:void 0})}}),uZ=(T=new WeakMap,O=new WeakMap,k=new WeakMap,M=new WeakMap,E=new WeakMap,D=new WeakMap,j=new WeakMap,A=new WeakSet,class extends uJ{get meta(){return this.options.meta}get promise(){var t;return null==(t=uv(this,E))?void 0:t.promise}setOptions(t){if(this.options={...uv(this,D),...t},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let t=u$(this.options);void 0!==t.data&&(this.setData(t.data,{updatedAt:t.dataUpdatedAt,manual:!0}),ub(this,T,t))}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||uv(this,k).remove(this)}setData(t,e){var r,i;let n=(r=this.state.data,"function"==typeof(i=this.options).structuralSharing?i.structuralSharing(r,t):!1!==i.structuralSharing?function t(e,r){if(e===r)return e;let i=uP(e)&&uP(r);if(!i&&!(uF(e)&&uF(r)))return r;let n=(i?e:Object.keys(e)).length,s=i?r:Object.keys(r),o=s.length,a=i?Array(o):{},l=0;for(let h=0;h<o;h++){let o=i?h:s[h],c=e[o],u=r[o];if(c===u){a[o]=c,(i?h<n:uA.call(e,o))&&l++;continue}if(null===c||null===u||"object"!=typeof c||"object"!=typeof u){a[o]=u;continue}let d=t(c,u);a[o]=d,d===c&&l++}return n===o&&l===n?e:a}(r,t):t);return uW(this,A,u0).call(this,{data:n,type:"success",dataUpdatedAt:null==e?void 0:e.updatedAt,manual:null==e?void 0:e.manual}),n}setState(t,e){uW(this,A,u0).call(this,{type:"setState",state:t,setStateOptions:e})}cancel(t){var e,r;let i=null==(e=uv(this,E))?void 0:e.promise;return null==(r=uv(this,E))||r.cancel(t),i?i.then(uT).catch(uT):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(uv(this,T))}isActive(){return this.observers.some(t=>{var e;return!1!==(e=t.options.enabled,"function"==typeof e?e(this):e)})}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===uB||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(t=>"static"===uO(t.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return void 0===this.state.data||"static"!==t&&(!!this.state.isInvalidated||!Math.max(this.state.dataUpdatedAt+(t||0)-Date.now(),0))}onFocus(){var t;let e=this.observers.find(t=>t.shouldFetchOnWindowFocus());null==e||e.refetch({cancelRefetch:!1}),null==(t=uv(this,E))||t.continue()}onOnline(){var t;let e=this.observers.find(t=>t.shouldFetchOnReconnect());null==e||e.refetch({cancelRefetch:!1}),null==(t=uv(this,E))||t.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),uv(this,k).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(uv(this,E)&&(uv(this,j)?uv(this,E).cancel({revert:!0}):uv(this,E).cancelRetry()),this.scheduleGc()),uv(this,k).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||uW(this,A,u0).call(this,{type:"invalidate"})}async fetch(t,e){var r,i,n,s,o,a,l,h,c,u,d,f;if("idle"!==this.state.fetchStatus&&(null==(r=uv(this,E))?void 0:r.status())!=="rejected"){if(void 0!==this.state.data&&(null==e?void 0:e.cancelRefetch))this.cancel({silent:!0});else if(uv(this,E))return uv(this,E).continueRetry(),uv(this,E).promise}if(t&&this.setOptions(t),!this.options.queryFn){let t=this.observers.find(t=>t.options.queryFn);t&&this.setOptions(t.options)}let g=new AbortController,p=t=>{Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(ub(this,j,!0),g.signal)})},m=()=>{let t=uN(this.options,e),r=(()=>{let t={client:uv(this,M),queryKey:this.queryKey,meta:this.meta};return p(t),t})();return(ub(this,j,!1),this.options.persister)?this.options.persister(t,r,this):t(r)},y=(()=>{let t={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:uv(this,M),state:this.state,fetchFn:m};return p(t),t})();null==(i=this.options.behavior)||i.onFetch(y,this),ub(this,O,this.state),("idle"===this.state.fetchStatus||this.state.fetchMeta!==(null==(n=y.fetchOptions)?void 0:n.meta))&&uW(this,A,u0).call(this,{type:"fetch",meta:null==(s=y.fetchOptions)?void 0:s.meta}),ub(this,E,uQ({initialPromise:null==e?void 0:e.initialPromise,fn:y.fetchFn,onCancel:t=>{t instanceof uK&&t.revert&&this.setState({...uv(this,O),fetchStatus:"idle"}),g.abort()},onFail:(t,e)=>{uW(this,A,u0).call(this,{type:"failed",failureCount:t,error:e})},onPause:()=>{uW(this,A,u0).call(this,{type:"pause"})},onContinue:()=>{uW(this,A,u0).call(this,{type:"continue"})},retry:y.options.retry,retryDelay:y.options.retryDelay,networkMode:y.options.networkMode,canRun:()=>!0}));try{let t=await uv(this,E).start();if(void 0===t)throw Error("".concat(this.queryHash," data is undefined"));return this.setData(t),null==(o=(a=uv(this,k).config).onSuccess)||o.call(a,t,this),null==(l=(h=uv(this,k).config).onSettled)||l.call(h,t,this.state.error,this),t}catch(t){if(t instanceof uK){if(t.silent)return uv(this,E).promise;else if(t.revert){if(void 0===this.state.data)throw t;return this.state.data}}throw uW(this,A,u0).call(this,{type:"error",error:t}),null==(c=(u=uv(this,k).config).onError)||c.call(u,t,this),null==(d=(f=uv(this,k).config).onSettled)||d.call(f,this.state.data,t,this),t}finally{this.scheduleGc()}}constructor(t){var e;super(),uU(this,A),ux(this,T,{writable:!0,value:void 0}),ux(this,O,{writable:!0,value:void 0}),ux(this,k,{writable:!0,value:void 0}),ux(this,M,{writable:!0,value:void 0}),ux(this,E,{writable:!0,value:void 0}),ux(this,D,{writable:!0,value:void 0}),ux(this,j,{writable:!0,value:void 0}),ub(this,j,!1),ub(this,D,t.defaultOptions),this.setOptions(t.options),this.observers=[],ub(this,M,t.client),ub(this,k,uv(this,M).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ub(this,T,u$(this.options)),this.state=null!=(e=t.state)?e:uv(this,T),this.scheduleGc()}});function u$(t){let e="function"==typeof t.initialData?t.initialData():t.initialData,r=void 0!==e,i=r?"function"==typeof t.initialDataUpdatedAt?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?null!=i?i:Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}function u0(t){let e=e=>{var r,i,n;switch(t.type){case"failed":return{...e,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...e,fetchStatus:"paused"};case"continue":return{...e,fetchStatus:"fetching"};case"fetch":return{...e,...(n=e.data,{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:uq(this.options.networkMode)?"fetching":"paused",...void 0===n&&{error:null,status:"pending"}}),fetchMeta:null!=(r=t.meta)?r:null};case"success":let s={...e,data:t.data,dataUpdateCount:e.dataUpdateCount+1,dataUpdatedAt:null!=(i=t.dataUpdatedAt)?i:Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ub(this,O,t.manual?s:void 0),s;case"error":let o=t.error;return{...e,error:o,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...e,isInvalidated:!0};case"setState":return{...e,...t.state}}};this.state=e(this.state),uX.batch(()=>{this.observers.forEach(t=>{t.onQueryUpdate()}),uv(this,k).notify({query:this,type:"updated",action:t})})}var u1=(P=new WeakMap,class extends uV{build(t,e,r){var i;let n=e.queryKey,s=null!=(i=e.queryHash)?i:uE(n,e),o=this.get(s);return o||(o=new uZ({client:t,queryKey:n,queryHash:s,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(n)}),this.add(o)),o}add(t){uv(this,P).has(t.queryHash)||(uv(this,P).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=uv(this,P).get(t.queryHash);e&&(t.destroy(),e===t&&uv(this,P).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){uX.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return uv(this,P).get(t)}getAll(){return[...uv(this,P).values()]}find(t){let e={exact:!0,...t};return this.getAll().find(t=>uk(e,t))}findAll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.getAll();return Object.keys(t).length>0?e.filter(e=>uk(t,e)):e}notify(t){uX.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){uX.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){uX.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}constructor(t={}){super(),ux(this,P,{writable:!0,value:void 0}),this.config=t,ub(this,P,new Map)}}),u2=(F=new WeakMap,L=new WeakMap,R=new WeakMap,I=new WeakMap,B=new WeakSet,class extends uJ{setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){uv(this,L).includes(t)||(uv(this,L).push(t),this.clearGcTimeout(),uv(this,R).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ub(this,L,uv(this,L).filter(e=>e!==t)),this.scheduleGc(),uv(this,R).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){uv(this,L).length||("pending"===this.state.status?this.scheduleGc():uv(this,R).remove(this))}continue(){var t,e;return null!=(e=null==(t=uv(this,I))?void 0:t.continue())?e:this.execute(this.state.variables)}async execute(t){var e,r,i,n,s,o,a,l,h,c,u,d,f,g,p,m,y,x,b,_,w;let C=()=>{uW(this,B,u5).call(this,{type:"continue"})},S={client:uv(this,F),meta:this.options.meta,mutationKey:this.options.mutationKey};ub(this,I,uQ({fn:()=>this.options.mutationFn?this.options.mutationFn(t,S):Promise.reject(Error("No mutationFn found")),onFail:(t,e)=>{uW(this,B,u5).call(this,{type:"failed",failureCount:t,error:e})},onPause:()=>{uW(this,B,u5).call(this,{type:"pause"})},onContinue:C,retry:null!=(e=this.options.retry)?e:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>uv(this,R).canRun(this)}));let T="pending"===this.state.status,O=!uv(this,I).canStart();try{if(T)C();else{uW(this,B,u5).call(this,{type:"pending",variables:t,isPaused:O}),await (null==(c=(u=uv(this,R).config).onMutate)?void 0:c.call(u,t,this,S));let e=await (null==(d=(f=this.options).onMutate)?void 0:d.call(f,t,S));e!==this.state.context&&uW(this,B,u5).call(this,{type:"pending",context:e,variables:t,isPaused:O})}let e=await uv(this,I).start();return await (null==(r=(i=uv(this,R).config).onSuccess)?void 0:r.call(i,e,t,this.state.context,this,S)),await (null==(n=(s=this.options).onSuccess)?void 0:n.call(s,e,t,this.state.context,S)),await (null==(o=(a=uv(this,R).config).onSettled)?void 0:o.call(a,e,null,this.state.variables,this.state.context,this,S)),await (null==(l=(h=this.options).onSettled)?void 0:l.call(h,e,null,t,this.state.context,S)),uW(this,B,u5).call(this,{type:"success",data:e}),e}catch(e){try{throw await (null==(g=(p=uv(this,R).config).onError)?void 0:g.call(p,e,t,this.state.context,this,S)),await (null==(m=(y=this.options).onError)?void 0:m.call(y,e,t,this.state.context,S)),await (null==(x=(b=uv(this,R).config).onSettled)?void 0:x.call(b,void 0,e,this.state.variables,this.state.context,this,S)),await (null==(_=(w=this.options).onSettled)?void 0:_.call(w,void 0,e,t,this.state.context,S)),e}finally{uW(this,B,u5).call(this,{type:"error",error:e})}}finally{uv(this,R).runNext(this)}}constructor(t){super(),uU(this,B),ux(this,F,{writable:!0,value:void 0}),ux(this,L,{writable:!0,value:void 0}),ux(this,R,{writable:!0,value:void 0}),ux(this,I,{writable:!0,value:void 0}),ub(this,F,t.client),this.mutationId=t.mutationId,ub(this,R,t.mutationCache),ub(this,L,[]),this.state=t.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(t.options),this.scheduleGc()}});function u5(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"pending":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}})(this.state),uX.batch(()=>{uv(this,L).forEach(e=>{e.onMutationUpdate(t)}),uv(this,R).notify({mutation:this,type:"updated",action:t})})}var u4=(N=new WeakMap,W=new WeakMap,U=new WeakMap,class extends uV{build(t,e,r){let i=new u2({client:t,mutationCache:this,mutationId:++u_(this,U).value,options:t.defaultMutationOptions(e),state:r});return this.add(i),i}add(t){uv(this,N).add(t);let e=u3(t);if("string"==typeof e){let r=uv(this,W).get(e);r?r.push(t):uv(this,W).set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(uv(this,N).delete(t)){let e=u3(t);if("string"==typeof e){let r=uv(this,W).get(e);if(r)if(r.length>1){let e=r.indexOf(t);-1!==e&&r.splice(e,1)}else r[0]===t&&uv(this,W).delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=u3(t);if("string"!=typeof e)return!0;{let r=uv(this,W).get(e),i=null==r?void 0:r.find(t=>"pending"===t.state.status);return!i||i===t}}runNext(t){let e=u3(t);if("string"!=typeof e)return Promise.resolve();{var r,i;let n=null==(r=uv(this,W).get(e))?void 0:r.find(e=>e!==t&&e.state.isPaused);return null!=(i=null==n?void 0:n.continue())?i:Promise.resolve()}}clear(){uX.batch(()=>{uv(this,N).forEach(t=>{this.notify({type:"removed",mutation:t})}),uv(this,N).clear(),uv(this,W).clear()})}getAll(){return Array.from(uv(this,N))}find(t){let e={exact:!0,...t};return this.getAll().find(t=>uM(e,t))}findAll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.getAll().filter(e=>uM(t,e))}notify(t){uX.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(t=>t.state.isPaused);return uX.batch(()=>Promise.all(t.map(t=>t.continue().catch(uT))))}constructor(t={}){super(),ux(this,N,{writable:!0,value:void 0}),ux(this,W,{writable:!0,value:void 0}),ux(this,U,{writable:!0,value:void 0}),this.config=t,ub(this,N,new Set),ub(this,W,new Map),ub(this,U,0)}});function u3(t){var e;return null==(e=t.options.scope)?void 0:e.id}function u9(t){return{onFetch:(e,r)=>{var i,n,s,o,a;let l=e.options,h=null==(s=e.fetchOptions)||null==(n=s.meta)||null==(i=n.fetchMore)?void 0:i.direction,c=(null==(o=e.state.data)?void 0:o.pages)||[],u=(null==(a=e.state.data)?void 0:a.pageParams)||[],d={pages:[],pageParams:[]},f=0,g=async()=>{let r=!1,i=uN(e.options,e.fetchOptions),n=async(t,n,s)=>{if(r)return Promise.reject();if(null==n&&t.pages.length)return Promise.resolve(t);let o=(()=>{let t={client:e.client,queryKey:e.queryKey,pageParam:n,direction:s?"backward":"forward",meta:e.options.meta};return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(e.signal.aborted?r=!0:e.signal.addEventListener("abort",()=>{r=!0}),e.signal)}),t})(),a=await i(o),{maxPages:l}=e.options,h=s?uI:uR;return{pages:h(t.pages,a,l),pageParams:h(t.pageParams,n,l)}};if(h&&c.length){let t="backward"===h,e={pages:c,pageParams:u},r=(t?function(t,e){var r;let{pages:i,pageParams:n}=e;return i.length>0?null==(r=t.getPreviousPageParam)?void 0:r.call(t,i[0],i,n[0],n):void 0}:u6)(l,e);d=await n(e,r,t)}else{let e=null!=t?t:c.length;do{var s;let t=0===f?null!=(s=u[0])?s:l.initialPageParam:u6(l,d);if(f>0&&null==t)break;d=await n(d,t),f++}while(f<e)}return d};e.options.persister?e.fetchFn=()=>{var t,i;return null==(t=(i=e.options).persister)?void 0:t.call(i,g,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=g}}}function u6(t,e){let{pages:r,pageParams:i}=e,n=r.length-1;return r.length>0?t.getNextPageParam(r[n],r,i[n],i):void 0}let u8=new(H=new WeakMap,X=new WeakMap,V=new WeakMap,Y=new WeakMap,z=new WeakMap,G=new WeakMap,q=new WeakMap,K=new WeakMap,class{mount(){u_(this,G).value++,1===uv(this,G)&&(ub(this,q,uY.subscribe(async t=>{t&&(await this.resumePausedMutations(),uv(this,H).onFocus())})),ub(this,K,uz.subscribe(async t=>{t&&(await this.resumePausedMutations(),uv(this,H).onOnline())})))}unmount(){var t,e;u_(this,G).value--,0===uv(this,G)&&(null==(t=uv(this,q))||t.call(this),ub(this,q,void 0),null==(e=uv(this,K))||e.call(this),ub(this,K,void 0))}isFetching(t){return uv(this,H).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return uv(this,X).findAll({...t,status:"pending"}).length}getQueryData(t){var e;let r=this.defaultQueryOptions({queryKey:t});return null==(e=uv(this,H).get(r.queryHash))?void 0:e.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=uv(this,H).build(this,e),i=r.state.data;return void 0===i?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(uO(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(t){return uv(this,H).findAll(t).map(t=>{let{queryKey:e,state:r}=t;return[e,r.data]})}setQueryData(t,e,r){let i=this.defaultQueryOptions({queryKey:t}),n=uv(this,H).get(i.queryHash),s=null==n?void 0:n.state.data,o="function"==typeof e?e(s):e;if(void 0!==o)return uv(this,H).build(this,i).setData(o,{...r,manual:!0})}setQueriesData(t,e,r){return uX.batch(()=>uv(this,H).findAll(t).map(t=>{let{queryKey:i}=t;return[i,this.setQueryData(i,e,r)]}))}getQueryState(t){var e;let r=this.defaultQueryOptions({queryKey:t});return null==(e=uv(this,H).get(r.queryHash))?void 0:e.state}removeQueries(t){let e=uv(this,H);uX.batch(()=>{e.findAll(t).forEach(t=>{e.remove(t)})})}resetQueries(t,e){let r=uv(this,H);return uX.batch(()=>(r.findAll(t).forEach(t=>{t.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={revert:!0,...e};return Promise.all(uX.batch(()=>uv(this,H).findAll(t).map(t=>t.cancel(r)))).then(uT).catch(uT)}invalidateQueries(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return uX.batch(()=>{var r,i;return(uv(this,H).findAll(t).forEach(t=>{t.invalidate()}),(null==t?void 0:t.refetchType)==="none")?Promise.resolve():this.refetchQueries({...t,type:null!=(i=null!=(r=null==t?void 0:t.refetchType)?r:null==t?void 0:t.type)?i:"active"},e)})}refetchQueries(t){var e;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={...r,cancelRefetch:null==(e=r.cancelRefetch)||e};return Promise.all(uX.batch(()=>uv(this,H).findAll(t).filter(t=>!t.isDisabled()&&!t.isStatic()).map(t=>{let e=t.fetch(void 0,i);return i.throwOnError||(e=e.catch(uT)),"paused"===t.state.fetchStatus?Promise.resolve():e}))).then(uT)}fetchQuery(t){let e=this.defaultQueryOptions(t);void 0===e.retry&&(e.retry=!1);let r=uv(this,H).build(this,e);return r.isStaleByTime(uO(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(uT).catch(uT)}fetchInfiniteQuery(t){return t.behavior=u9(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(uT).catch(uT)}ensureInfiniteQueryData(t){return t.behavior=u9(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return uz.isOnline()?uv(this,X).resumePausedMutations():Promise.resolve()}getQueryCache(){return uv(this,H)}getMutationCache(){return uv(this,X)}getDefaultOptions(){return uv(this,V)}setDefaultOptions(t){ub(this,V,t)}setQueryDefaults(t,e){uv(this,Y).set(uD(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...uv(this,Y).values()],r={};return e.forEach(e=>{uj(t,e.queryKey)&&Object.assign(r,e.defaultOptions)}),r}setMutationDefaults(t,e){uv(this,z).set(uD(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...uv(this,z).values()],r={};return e.forEach(e=>{uj(t,e.mutationKey)&&Object.assign(r,e.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...uv(this,V).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=uE(e.queryKey,e)),void 0===e.refetchOnReconnect&&(e.refetchOnReconnect="always"!==e.networkMode),void 0===e.throwOnError&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===uB&&(e.enabled=!1),e}defaultMutationOptions(t){return(null==t?void 0:t._defaulted)?t:{...uv(this,V).mutations,...(null==t?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){uv(this,H).clear(),uv(this,X).clear()}constructor(t={}){ux(this,H,{writable:!0,value:void 0}),ux(this,X,{writable:!0,value:void 0}),ux(this,V,{writable:!0,value:void 0}),ux(this,Y,{writable:!0,value:void 0}),ux(this,z,{writable:!0,value:void 0}),ux(this,G,{writable:!0,value:void 0}),ux(this,q,{writable:!0,value:void 0}),ux(this,K,{writable:!0,value:void 0}),ub(this,H,t.queryCache||new u1),ub(this,X,t.mutationCache||new u4),ub(this,V,t.defaultOptions||{}),ub(this,Y,new Map),ub(this,z,new Map),ub(this,G,0)}})({defaultOptions:{queries:{queryFn:async function(t){let{queryKey:e}=t,[r]=e;return(0,cb.imageUrlToArrayBuffer)(r)},staleTime:1/0,gcTime:6e4,refetchOnWindowFocus:!1,refetchOnReconnect:!1}}});function u7(){return(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(ug,{client:u8,children:(0,Q.jsx)("main",{children:(0,Q.jsx)(up,{children:(0,Q.jsx)(J.Suspense,{children:(0,Q.jsx)(cV,{children:(0,Q.jsx)(ut,{children:(0,Q.jsxs)(ue,{children:[(0,Q.jsxs)("div",{className:"Viewport",children:[(0,Q.jsxs)("div",{className:"ModelTools",children:[(0,Q.jsx)("div",{className:"Field",children:(0,Q.jsx)(c4,{})}),(0,Q.jsx)("div",{className:"Field SliderField",children:(0,Q.jsx)(c3,{})}),(0,Q.jsx)("div",{className:"Field",children:(0,Q.jsx)(c7,{})})]}),(0,Q.jsx)(c5,{})]}),(0,Q.jsx)(cT,{children:(0,Q.jsx)(cC,{children:(0,Q.jsxs)(cO,{children:[(0,Q.jsx)(cL,{}),(0,Q.jsxs)("div",{className:"CanvasViewport",children:[(0,Q.jsxs)("div",{className:"CanvasSelector",children:[(0,Q.jsx)(ck,{}),(0,Q.jsx)(ui,{})]}),(0,Q.jsx)(cS,{}),(0,Q.jsx)(ud,{})]}),(0,Q.jsx)(cg,{}),(0,Q.jsx)(cp,{})]})})})]})})})})})})})})}}]); |