mirror of
https://github.com/exogen/t2-model-skinner.git
synced 2026-01-19 19:24:44 +00:00
1 line
443 KiB
JavaScript
1 line
443 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 a=i.apply(null,n);a&&t.push(a)}}else if("object"===s){if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]")){t.push(n.toString());continue}for(var o in n)r.call(n,o)&&n[o]&&t.push(o)}}}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 o}});let i=t.r(43476),n=t.r(74080),s=t.r(63599),a=t.r(9885);function o(t){let{moduleIds:e}=t;if("undefined"!=typeof window)return null;let r=s.workAsyncStorage.getStore();if(void 0===r)return null;let o=[];if(r.reactLoadableManifest&&e){let t=r.reactLoadableManifest;for(let r of e){if(!t[r])continue;let e=t[r].files;o.push(...e)}}return 0===o.length?null:(0,i.jsx)(i.Fragment,{children:o.map(t=>{let e=r.assetPrefix+"/_next/"+(0,a.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),a=t.r(52157);function o(t){return{default:t&&"default"in t?t.default:t}}let l={loader:()=>Promise.resolve(o(()=>null)),loading:null,ssr:!0},h=function(t){let e={...l,...t},r=(0,n.lazy)(()=>e.loader().then(o)),h=e.loading;function c(t){let o=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)(a.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:o}:{},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,s;t.s(["default",()=>da],52683);var a,o,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,z,Y,G,q,K,Q,J=t.i(43476),Z=t.i(71645);function $(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 tt(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 te(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?tt(Object(r),!0).forEach(function(e){$(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):tt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function tr(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 ti(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}class tn{constructor(){$(this,"browserShadowBlurConstant",1),$(this,"DPI",96),$(this,"devicePixelRatio","undefined"!=typeof window?window.devicePixelRatio:1),$(this,"perfLimitSizeTotal",2097152),$(this,"maxCacheSideLimit",4096),$(this,"minCacheSideLimit",256),$(this,"disableStyleCopyPaste",!1),$(this,"enableGLFiltering",!0),$(this,"textureSize",4096),$(this,"forceGLPutImageData",!1),$(this,"cachesBoundsOfCurve",!1),$(this,"fontPaths",{}),$(this,"NUM_FRACTION_DIGITS",4)}}let ts=new class extends tn{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=te(te({},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 tn,r=(null==t?void 0:t.reduce((t,r)=>(t[r]=e[r],t),{}))||e;this.configure(r)}constructor(t){super(),this.configure(t)}},ta=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 tl extends to{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class th{}class tc extends th{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(),ta("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}let tu={},td=()=>e||(e={document:document,window:window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new tc,dispose(){},copyPasteData:tu}),tf=()=>td().document,tg=()=>td().window,tp=()=>{var t;return Math.max(null!=(t=ts.devicePixelRatio)?t:tg().devicePixelRatio,1)},tm=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}=ts,r=Math.sqrt(e*t);return[Math.floor(r),Math.floor(e/r)]}constructor(){$(this,"charWidthsCache",{}),$(this,"boundsOfCurveCache",{})}},tv="6.7.1";function ty(){}let tx=Math.PI/2,tb=2*Math.PI,t_=Math.PI/180,tw=Object.freeze([1,0,0,1,0,0]),tC="center",tS="left",tT="bottom",tO="right",tk="none",tM=/\r?\n/,tE="moving",tD="scaling",tj="rotating",tA="rotate",tP="skewing",tF="resizing",tL="modifyPoly",tR="changed",tI="scale",tB="scaleX",tN="scaleY",tW="skewX",tU="skewY",tH="fill",tX="stroke",tV="modified",tz="json",tY=new class{has(t){return this[tz].has(t)}getClass(t){let e=this[tz].get(t);if(!e)throw new to("No class registered for ".concat(t));return e}setClass(t,e){e?this[tz].set(e,t):(this[tz].set(t.type,t),this[tz].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[tz]=new Map,this.svg=new Map}},tG=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 tq{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(){$(this,"__eventListeners",{})}}let tK=(t,e)=>{let r=t.indexOf(e);return -1!==r&&t.splice(r,1),t},tQ=t=>{if(0===t)return 1;switch(Math.abs(t)/tx){case 1:case 3:return 0;case 2:return -1}return Math.cos(t)},tJ=t=>{if(0===t)return 0;let e=Math.sign(t);switch(t/tx){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(t)};class tZ{add(t){return new tZ(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new tZ(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new tZ(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new tZ(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new tZ(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new tZ(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new tZ(this.x/t.x,this.y/t.y)}scalarDivide(t){return new tZ(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 tZ(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 tZ(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new tZ(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 tZ(this.x,this.y)}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t$,r=tJ(t),i=tQ(t),n=this.subtract(e);return new tZ(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 tZ(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 t$=new tZ(0,0),t0=t=>!!t&&Array.isArray(t._objects);function t1(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])&&(tK(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),!0)}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1])&&(tK(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 tK(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 tK(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(tK(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]:{},a=[],o=new tZ(e,r),l=o.add(new tZ(i,n));for(let t=this._objects.length-1;t>=0;t--){let e=this._objects[t];e.selectable&&e.visible&&(s&&e.intersectsWithRect(o,l)||e.isContainedWithinRect(o,l)||s&&e.containsPoint(o)||s&&e.containsPoint(l))&&a.push(e)}return a}constructor(){super(...arguments),$(this,"_objects",[])}}return e}class t2 extends tq{_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 t5(t){return tg().requestAnimationFrame(t)}function t4(t){return tg().cancelAnimationFrame(t)}let t3=0,t9=()=>t3++,t6=()=>{let t=tf().createElement("canvas");if(!t||void 0===t.getContext)throw new to("Failed to create `canvas` element");return t},t8=()=>tf().createElement("img"),t7=t=>{let e=t6();return e.width=t.width,e.height=t.height,e},et=(t,e,r)=>t.toDataURL("image/".concat(e),r),ee=(t,e,r)=>new Promise((i,n)=>{t.toBlob(i,"image/".concat(e),r)}),er=t=>t*t_,ei=t=>t/t_,en=t=>t.every((t,e)=>t===tw[e]),es=(t,e,r)=>new tZ(t).transform(e,r),ea=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 tZ(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]],el=(t,e)=>t.reduceRight((t,r)=>r&&t?eo(r,t,e):r||t,void 0)||tw.concat(),eh=t=>{let[e,r]=t;return Math.atan2(r,e)},ec=t=>{let e=eh(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:ei(e),scaleX:i,scaleY:n,skewX:ei(s),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},eu=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function ed(){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=er(t),n=tQ(i),s=tJ(i);return[n,s,-s,n,e?e-(n*e-s*r):0,r?r-(s*e+n*r):0]}let ef=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},eg=t=>Math.tan(er(t)),ep=t=>[1,0,eg(t),1,0,0],em=t=>[1,eg(t),0,1,0,0],ev=t=>{let{scaleX:e=1,scaleY:r=1,flipX:i=!1,flipY:n=!1,skewX:s=0,skewY:a=0}=t,o=ef(i?-e:e,n?-r:r);return s&&(o=eo(o,ep(s),!0)),a&&(o=eo(o,em(a),!0)),o},ey=t=>{let{translateX:e=0,translateY:r=0,angle:i=0}=t,n=eu(e,r);i&&(n=eo(n,ed({angle:i})));let s=ev(t);return en(s)||(n=eo(n,s)),n},ex=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 tl("loadImage"));let a=t8();e&&(s=function(t){a.src="",n(t)},e.addEventListener("abort",s,{once:!0}));let o=function(){a.onload=a.onerror=null,s&&(null==e||e.removeEventListener("abort",s)),i(a)};t?(a.onload=o,a.onerror=function(){s&&(null==e||e.removeEventListener("abort",s)),n(new to("Error loading ".concat(a.src)))},r&&(a.crossOrigin=r),a.src=t):o()})},eb=function(t){let{signal:e,reviver:r=ty}=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)})})},e_=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)?eb([t],{signal:e}).then(t=>{let[e]=t;return n.push(e),e}):t),a=Object.keys(t);Promise.all(s).then(t=>t.reduce((t,e,r)=>(t[a[r]]=e,t),{})).then(r).catch(t=>{n.forEach(t=>{t.dispose&&t.dispose()}),i(t)}).finally(()=>{e&&e.removeEventListener("abort",i)})})},ew=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce((e,r)=>(r in t&&(e[r]=t[r]),e),{})},eC=(t,e)=>Object.keys(t).reduce((r,i)=>(e(t[i],i,t)&&(r[i]=t[i]),r),{}),eS=(t,e)=>parseFloat(Number(t).toFixed(e)),eT=t=>"matrix("+t.map(t=>eS(t,ts.NUM_FRACTION_DIGITS)).join(" ")+")",eO=t=>!!t&&void 0!==t.toLive,ek=t=>!!t&&"function"==typeof t.toObject,eM=t=>!!t&&void 0!==t.offsetX&&"source"in t,eE=t=>!!t&&"multiSelectionStacking"in t;function eD(t){let e=t&&ej(t),r=0,i=0;if(!t||!e)return{left:r,top:i};let n=t,s=e.documentElement,a=e.body||{scrollLeft:0,scrollTop:0};for(;n&&(n.parentNode||n.host)&&((n=n.parentNode||n.host)===e?(r=a.scrollLeft||s.scrollLeft||0,i=a.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 ej=t=>t.ownerDocument||null,eA=t=>{var e;return(null==(e=t.ownerDocument)?void 0:e.defaultView)||null},eP=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))},eF=(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 eL(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=tk,t}class eR{createLowerCanvas(t){let e=t&&void 0!==t.getContext?t:t&&tf().getElementById(t)||t6();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;eP(r,i,t,e)}setCSSDimensions(t){eF(this.lower.el,t)}calcOffset(){return function(t){var e;let r=t&&ej(t),i={left:0,top:0};if(!r)return i;let n=(null==(e=eA(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},a=r.documentElement;void 0!==t.getBoundingClientRect&&(s=t.getBoundingClientRect());let o=eD(t);return{left:s.left+o.left-(a.clientLeft||0)+i.left,top:s.top+o.top-(a.clientTop||0)+i.top}}(this.lower.el)}dispose(){td().dispose(this.lower.el),delete this.lower}constructor(t){$(this,"_originalCanvasStyle",void 0),$(this,"lower",void 0);let e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}}let eI={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...tw]};class eB extends t1(t2){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 eB.ownDefaults}initElements(t){this.elements=new eR(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&&(ta("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?tp():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=te({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=es(t,ea(r));r[0]=e,r[3]=e;let n=es(i,r);r[4]+=t.x-n.x,r[5]+=t.y-n.y,this.setViewportTransform(r)}setZoom(t){this.zoomToPoint(new tZ(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 tZ(-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=t5(()=>this.renderAndReset()))}calcViewportBoundaries(){let t=this.width,e=this.height,r=ea(this.viewportTransform),i=es({x:0,y:0},r),n=es({x:t,y:e},r),s=i.min(n),a=i.max(n);return this.vptCoords={tl:s,tr:new tZ(a.x,s.y),bl:new tZ(s.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(t4(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 a=eO(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=a?r.toLive(t):r,s&&t.transform(...n),a){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 tZ(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new tZ(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new tZ(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 tZ(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new tZ(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return es(this.getCenterPoint(),ea(this.viewportTransform))}_centerObject(t,e){t.setXY(e,tC,tC),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 te(te(te({version:tv},ew(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,a=this.overlayColor;return eO(s)?s.excludeFromExport||(r.background=s.toObject(e)):s&&(r.background=s),eO(a)?a.excludeFromExport||(r.overlay=a.toObject(e)):a&&(r.overlay=a),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=ts.NUM_FRACTION_DIGITS,a=e.viewBox;if(a)r='viewBox="'.concat(a.x," ").concat(a.y," ").concat(a.width," ").concat(a.height,'" ');else if(this.svgViewportTransformation){let t=this.viewportTransform;r='viewBox="'.concat(eS(-t[4]/t[0],s)," ").concat(eS(-t[5]/t[3],s)," ").concat(eS(this.width/t[0],s)," ").concat(eS(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 ",tv,"</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(t9()),'<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(eO(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?eT(i):""})}}).join("")}createSVGFontFacesMarkup(){let t=[],e={},r=ts.fontPaths;this._objects.forEach(function e(r){t.push(r),t0(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(eO(r)){let i=r.repeat||"",n=this.width,s=this.height,a=this["".concat(e,"Vpt")]?eT(ea(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," 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||!eM(r)?n:r.source.width,'" height="').concat("repeat-x"!==i&&"no-repeat"!==i||!eM(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:a,overlayImage:o,overlay:l,clipPath:h}=i,c=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([eb(n,{reviver:e,signal:r}),e_({backgroundImage:s,backgroundColor:a,overlayImage:o,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=t7(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 et(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 ee(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]:{},a=(e||this.width)*t,o=(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=t7({width:a,height:o}),y=s?this._objects.filter(t=>s(t)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=g,this.width=a,this.height=o,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}),tG.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()}}$(eB,"ownDefaults",eI);let eN=["touchstart","touchmove","touchend"],eW=t=>{let e=eD(t.target),r=function(t){let e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new tZ(r.clientX+e.left,r.clientY+e.top)},eU=t=>eN.includes(t.type)||"touch"===t.pointerType,eH=t=>{t.preventDefault(),t.stopPropagation()},eX=t=>{let e=0,r=0,i=0,n=0;for(let s=0,a=t.length;s<a;s++){let{x:a,y:o}=t[s];(a>i||!s)&&(i=a),(a<e||!s)&&(e=a),(o>n||!s)&&(n=o),(o<r||!s)&&(r=o)}return{left:e,top:r,width:i-e,height:n-r}},eV=["translateX","translateY","scaleX","scaleY"],ez=(t,e)=>eY(t,eo(e,t.calcOwnMatrix())),eY=(t,e)=>{let r=ec(e),{translateX:i,translateY:n,scaleX:s,scaleY:a}=r,o=tr(r,eV),l=new tZ(i,n);t.flipX=!1,t.flipY=!1,Object.assign(t,o),t.set({scaleX:s,scaleY:a}),t.setPositionByOrigin(l,tC,tC)},eG=t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},eq=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}),eK=(t,e,r)=>{let i=t/2,n=e/2,s=eX([new tZ(-i,-n),new tZ(i,-n),new tZ(-i,n),new tZ(i,n)].map(t=>t.transform(r)));return new tZ(s.width,s.height)},eQ=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:tw;return eo(ea(arguments.length>1&&void 0!==arguments[1]?arguments[1]:tw),t)},eJ=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tw,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:tw;return t.transform(eQ(e,r))},eZ=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tw,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:tw;return t.transform(eQ(e,r),!0)},e$=(t,e,r)=>{let i=eQ(e,r);return eY(t,eo(i,t.calcOwnMatrix())),i},e0=(t,e)=>{var r;let{transform:{target:i}}=e;null==(r=i.canvas)||r.fire("object:".concat(t),te(te({},e),{},{target:i})),i.fire(t,e)},e1={left:-.5,top:-.5,center:0,bottom:.5,right:.5},e2=t=>"string"==typeof t?e1[t]:t-.5,e5="not-allowed";function e4(t){return e2(t.originX)===e2(tC)&&e2(t.originY)===e2(tC)}let e3=(t,e)=>t[e],e9=(t,e,r,i)=>({e:t,transform:e,pointer:new tZ(r,i)});function e6(t,e){return Math.round((t.getTotalAngle()+ei(Math.atan2(e.y,e.x))+360)%360/45)}function e8(t,e,r,i,n){var s;let{target:a,corner:o}=t,l=a.controls[o],h=(null==(s=a.canvas)?void 0:s.getZoom())||1,c=a.padding/h,u=function(t,e,r,i){let n=t.getRelativeCenterPoint(),s=void 0!==r&&void 0!==i?t.translateToGivenOrigin(n,tC,tC,r,i):new tZ(t.left,t.top);return(t.angle?e.rotate(-er(t.angle),n):e).subtract(s)}(a,new tZ(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 e7=(t,e,r,i)=>{let{target:n,offsetX:s,offsetY:a}=e,o=r-s,l=i-a,h=!e3(n,"lockMovementX")&&n.left!==o,c=!e3(n,"lockMovementY")&&n.top!==l;return h&&n.set(tS,o),c&&n.set("top",l),(h||c)&&e0(tE,e9(t,e,r,i)),h||c},rt={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"},re=(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),rr=(t,e,r,i)=>{let n,s;t/=255;let a=Math.max(t,e/=255,r/=255),o=Math.min(t,e,r),l=(a+o)/2;if(a===o)n=s=0;else{let i=a-o;switch(s=l>.5?i/(2-a-o):i/(a+o),a){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]},ri=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"1";return parseFloat(t)/(t.endsWith("%")?100:1)},rn=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),rs=t=>{let[e,r,i,n=1]=t,s=Math.round(.3*e+.59*r+.11*i);return[s,s,s,n]};class ra{_tryParsingColor(t){return(t=t.toLowerCase())in rt&&(t=rt[t]),"transparent"===t?[255,255,255,0]:ra.sourceFromHex(t)||ra.sourceFromRgb(t)||ra.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]=rr(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(r,"%)")}toHsla(){let[t,e,r,i]=rr(...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(rn(t)).concat(rn(e)).concat(rn(r)).concat(rn(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(rs(this.getSource())),this}toBlackWhite(t){let[e,,,r]=rs(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,r]),this}overlayWith(t){t instanceof ra||(t=new ra(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 ra.fromRgba(t)}static fromRgba(t){return new ra(ra.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,ri(e[4])]}}static fromHsl(t){return ra.fromHsla(t)}static fromHsla(t){return new ra(ra.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=(ra.parseAngletoDegrees(n[1])%360+360)%360/360,a=parseFloat(n[2])/100,o=parseFloat(n[3])/100;if(0===a)e=r=i=o;else{let t=o<=.5?o*(a+1):o+a-o*a,n=2*o-t;e=re(n,t,s+1/3),r=re(n,t,s),i=re(n,t,s-1/3)}return[Math.round(255*e),Math.round(255*r),Math.round(255*i),ri(n[4])]}static fromHex(t){return new ra(ra.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")?ei(r):e.includes("turn")?360*r:r}constructor(t){if($(this,"isUnrecognised",!1),t)if(t instanceof ra)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=ts.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}},rl=t=>{let[e,r]=t.trim().split(" "),[i,n]=e&&e!==tk?[e.slice(1,4),e.slice(5,8)]:e===tk?[e,e]:["Mid","Mid"];return{meetOrSlice:r||"meet",alignX:i,alignY:n}},rh=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 ra(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 rc{getSvgStyles(t){let e=this.fillRule?this.fillRule:"nonzero",r=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):tk,n=this.strokeDashOffset?this.strokeDashOffset:"0",s=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",o=this.strokeMiterLimit?this.strokeMiterLimit:"4",l=void 0!==this.opacity?this.opacity:"1",h=this.visible?"":" visibility: hidden;",c=t?"":this.getSvgFilter(),u=rh(tH,this.fill);return rh(tX,this.stroke)+"stroke-width: "+r+"; stroke-dasharray: "+i+"; stroke-linecap: "+s+"; stroke-dashoffset: "+n+"; stroke-linejoin: "+a+"; stroke-miterlimit: "+o+"; "+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(eT(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]:{},a=r?"":'style="'.concat(this.getSvgStyles(),'" '),o=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(t9()),e='<clipPath id="'.concat(l.clipPathId,'" >\n').concat(l.toClipPathSVG(i),"</clipPath>\n")),c&&g.push("<g ",o,this.getSvgCommons()," >\n"),g.push("<g ",this.getSvgTransform(!1),c?"":o+this.getSvgCommons()," >\n");let m=""+a+h+(r?"":this.addPaintOrder())+" "+(s?'transform="'.concat(s,'" '):"");return t[p]=m,eO(d)&&g.push(d.toSVG(this)),eO(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!==tH?' paint-order="'.concat(this.paintFirst,'" '):""}}function ru(t){return RegExp("^("+t.join("|")+")\\b","i")}let rd="textDecorationThickness",rf=["fontSize","fontWeight","fontFamily","fontStyle"],rg=["underline","overline","linethrough"],rp=[...rf,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],rm=[...rp,...rg,"textBackgroundColor","direction",rd],rv=[...rf,...rg,tX,"strokeWidth",tH,"deltaY","textBackgroundColor",rd],ry="justify",rx="justify-left",rb="justify-right",r_="justify-center",rw=String.raw(a||(a=ti(["[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?"],["[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?"]))),rC=String.raw(o||(o=ti(["(?:s*,?s+|s*,s*)"],["(?:\\s*,?\\s+|\\s*,\\s*)"]))),rS=RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+rw+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+rw+"))?\\s+(.*)"),rT={cx:tS,x:tS,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":rd},rO="font-size",rk="clip-path",rM=(ru(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),ru(["symbol","image","marker","pattern","view","svg"]),ru(["symbol","g","a","svg","clipPath","defs"])),rE=(new RegExp(String.raw(l||(l=ti(["^s*(",")","(",")","(",")","(",")s*$"],["^\\s*(",")","(",")","(",")","(",")\\s*$"])),rw,rC,rw,rC,rw,rC,rw)),new tZ(1,0)),rD=new tZ,rj=(t,e)=>t.rotate(e),rA=(t,e)=>new tZ(e).subtract(t),rP=t=>t.distanceFrom(rD),rF=(t,e)=>Math.atan2(rB(t,e),rN(t,e)),rL=t=>rF(rE,t),rR=t=>t.eq(rD)?t:t.scalarDivide(rP(t)),rI=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return rR(new tZ(-t.y,t.x).scalarMultiply(e?1:-1))},rB=(t,e)=>t.x*e.y-t.y*e.x,rN=(t,e)=>t.x*e.x+t.y*e.y,rW=(t,e,r)=>{if(t.eq(e)||t.eq(r))return!0;let i=rB(e,r),n=rB(e,t),s=rB(r,t);return i>=0?n>=0&&s<=0:!(n<=0&&s>=0)},rU="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",rH=RegExp("(?:\\s|^)"+rU+rU+"("+rw+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class rX{static parseShadow(t){let e=t.trim(),[,r=0,i=0,n=0]=(rH.exec(e)||[]).map(t=>parseFloat(t)||0);return{color:(e.replace(rH,"")||"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=rj(new tZ(this.offsetX,this.offsetY),er(-t.angle)),r=new ra(this.color),i=40,n=40;return t.width&&t.height&&(i=100*eS((Math.abs(e.x)+this.blur)/t.width,ts.NUM_FRACTION_DIGITS)+20,n=100*eS((Math.abs(e.y)+this.blur)/t.height,ts.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(eS(this.blur?this.blur/2:0,ts.NUM_FRACTION_DIGITS),'"></feGaussianBlur>\n <feOffset dx="').concat(eS(e.x,ts.NUM_FRACTION_DIGITS),'" dy="').concat(eS(e.y,ts.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=rX.ownDefaults;return this.includeDefaultValues?t:eC(t,(t,r)=>t!==e[r])}static async fromObject(t){return new this(t)}constructor(t){let e="string"==typeof t?rX.parseShadow(t):t;Object.assign(this,rX.ownDefaults,e),this.id=t9()}}$(rX,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),$(rX,"type","shadow"),tY.setClass(rX,"shadow");let rV=(t,e,r)=>Math.max(t,Math.min(e,r)),rz=["top",tS,tB,tN,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",tW,tU],rY=[tH,tX,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],rG=(t,e,r,i)=>(t<Math.abs(e)?(t=e,i=r/4):i=0===e&&0===t?r/tb*Math.asin(1):r/tb*Math.asin(e/t),{a:t,c:e,p:r,s:i}),rq=(t,e,r,i,n)=>t*Math.pow(2,10*(i-=1))*Math.sin((i*n-e)*tb/r),rK=(t,e,r,i)=>-r*Math.cos(t/i*tx)+r+e,rQ=(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,rJ=(t,e,r,i)=>r-rQ(i-t,0,r,i)+e;var rZ=Object.freeze({__proto__:null,defaultEasing:rK,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:rJ,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:a,p:o}=rG(r,r,n,1.70158);return-rq(s,a,o,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*rJ(2*t,0,r,i)+e:.5*rQ(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:a,p:o,c:l}=rG(r,r,n,1.70158);return t<1?-.5*rq(s,a,o,t,i)+e:s*Math.pow(2,-10*(t-=1))*Math.sin((t*i-a)*tb/o)*.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*tx)+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:rQ,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:a,p:o,c:l}=rG(r,r,n,1.70158);return s*2**(-10*t)*Math.sin((t*i-a)*tb/o)+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*tx)+e});let r$=()=>!1;class r0{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(()=>t5(t),this.delay):t5(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),t5(this.tick)))}register(){tG.push(this)}unregister(){tG.remove(this)}abort(){this._state="aborted",this.unregister()}constructor(t){let{startValue:e,byValue:r,duration:i=500,delay:n=0,easing:s=rK,onStart:a=ty,onChange:o=ty,onComplete:l=ty,abort:h=r$,target:c}=t;$(this,"_state","pending"),$(this,"durationProgress",0),$(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=i,this.delay=n,this.easing=s,this._onStart=a,this._onChange=o,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 r1=["startValue","endValue"];class r2 extends r0{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(te(te({},tr(t,r1)),{},{startValue:e,byValue:r-e}))}}let r5=["startValue","endValue"];class r4 extends r0{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(te(te({},tr(t,r5)),{},{startValue:e,byValue:r.map((t,r)=>t-e[r])}))}}let r3=["startValue","endValue","easing","onChange","onComplete","abort"],r9=(t,e,r,i)=>e+r*(1-Math.cos(t/i*tx)),r6=t=>t&&((e,r,i)=>t(new ra(e).toRgba(),r,i));class r8 extends r0{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),rV(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=r9,onChange:n,onComplete:s,abort:a}=t,o=tr(t,r3),l=new ra(e).getSource();super(te(te({},o),{},{startValue:l,byValue:new ra(r).getSource().map((t,e)=>t-l[e]),easing:i,onChange:r6(n),onComplete:r6(s),abort:r6(a)}))}}function r7(t){let e=Array.isArray(t.startValue)||Array.isArray(t.endValue)?new r4(t):new r2(t);return e.start(),e}function it(t){let e=new r8(t);return e.start(),e}class ie{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=rA(e,r),s=rA(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 tZ(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],a=e.x-t.x,o=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=a*u-o*c,g=h*a-l*o;if(0!==g){let e=d/g,r=f/g;return(n||0<=e&&e<=1)&&(s||0<=r&&r<=1)?new ie("Intersection").append(new tZ(t.x+e*a,t.y+e*o)):new ie}if(0===d||0===f){let a=n||s||ie.isPointContained(t,r,i)||ie.isPointContained(e,r,i)||ie.isPointContained(r,t,e)||ie.isPointContained(i,t,e);return new ie(a?"Coincident":void 0)}return new ie("Parallel")}static intersectSegmentLine(t,e,r,i){return ie.intersectLineLine(t,e,r,i,!1,!0)}static intersectSegmentSegment(t,e,r,i){return ie.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 ie,s=r.length;for(let a,o,l,h=0;h<s;h++){if(a=r[h],o=r[(h+1)%s],"Coincident"===(l=ie.intersectLineLine(t,e,a,o,i,!1)).status)return l;n.append(...l.points)}return n.points.length>0&&(n.status="Intersection"),n}static intersectSegmentPolygon(t,e,r){return ie.intersectLinePolygon(t,e,r,!1)}static intersectPolygonPolygon(t,e){let r=new ie,i=t.length,n=[];for(let s=0;s<i;s++){let a=t[s],o=t[(s+1)%i],l=ie.intersectSegmentPolygon(a,o,e);"Coincident"===l.status?(n.push(l),r.append(a,o)):r.append(...l.points)}return n.length>0&&n.length===t.length?new ie("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 tZ(n.x,i.y),a=new tZ(i.x,n.y);return ie.intersectPolygonPolygon(t,[i,s,n,a])}constructor(t){this.status=t,this.points=[]}}class ir extends t2{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?es(t,this.group.calcTransformMatrix()):t}setXY(t,e,r){this.group&&(t=es(t,ea(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,r)}getRelativeXY(){return new tZ(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=>es(e,t))}return n}intersectsWithRect(t,e){return"Intersection"===ie.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){let e=ie.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 ie.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 eX(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(tB,t),this._set(tN,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?ei(eh(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null==(t=this.canvas)?void 0:t.viewportTransform)||tw.concat()}calcACoords(){let t=ed({angle:this.angle}),{x:e,y:r}=this.getRelativeCenterPoint(),i=eo(eu(e,r),t),n=this._getTransformedDimensions(),s=n.x/2,a=n.y/2;return{tl:es({x:-s,y:-a},i),tr:es({x:s,y:-a},i),bl:es({x:-s,y:a},i),br:es({x:s,y:a},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,e2(this.originX),e2(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=ey({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 tZ(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=te({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,a=e.height+i;return(0===e.skewX&&0===e.skewY?new tZ(s*e.scaleX,a*e.scaleY):eK(s,a,ev(e))).scalarAdd(n)}translateToGivenOrigin(t,e,r,i,n){let s=t.x,a=t.y,o=e2(i)-e2(e),l=e2(n)-e2(r);if(o||l){let t=this._getTransformedDimensions();s+=o*t.x,a+=l*t.y}return new tZ(s,a)}translateToCenterPoint(t,e,r){if(e===tC&&r===tC)return t;let i=this.translateToGivenOrigin(t,e,r,tC,tC);return this.angle?i.rotate(er(this.angle),t):i}translateToOriginPoint(t,e,r){let i=this.translateToGivenOrigin(t,tC,tC,e,r);return this.angle?i.rotate(er(this.angle),t):i}getCenterPoint(){let t=this.getRelativeCenterPoint();return this.group?es(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new tZ(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(),tS,"top")}}let ii=["type"],is=["extraParam"],ia=class t extends ir{static getDefaults(){return t.ownDefaults}get type(){let t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){ta("warn","Setting type has no effect",t)}_createCacheCanvas(){this._cacheCanvas=t6(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){let e=t.width,r=t.height,i=ts.maxCacheSideLimit,n=ts.minCacheSideLimit;if(e<=i&&r<=i&&e*r<=ts.perfLimitSizeTotal)return e<n&&(t.width=n),r<n&&(t.height=n),t;let[s,a]=tm.limitDimsByArea(e/r),o=rV(n,s,i),l=rV(n,a,i);return e>o&&(t.zoomX/=e/o,t.width=o,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:a,y:o}=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=a/2,h=o/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 tZ(Math.abs(this.scaleX),Math.abs(this.scaleY));let t=ec(this.calcTransformMatrix());return new tZ(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!==tB&&t!==tN||(e=this._constrainScale(e)),t===tB&&e<0?(this.flipX=!this.flipX,e*=-1):"scaleY"===t&&e<0?(this.flipY=!this.flipY,e*=-1):"shadow"!==t||!e||e instanceof rX||(e=new rX(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:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:r,cacheTranslationX:i,cacheTranslationY:n,width:s,height:a,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===tX&&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=t7(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=ea(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,eO(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&&(eO(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)||tw,a=n*i,o=s*i,l=e.nonScaling?new tZ(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*ts.browserShadowBlurConstant*(a+o)*(l.x+l.y)/4,t.shadowOffsetX=e.offsetX*a*l.x,t.shadowOffsetY=e.offsetY*o*l.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!eO(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===tX?(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,a=i.y/this.scaleY/n,o=t7({width:Math.ceil(s),height:Math.ceil(a)}),l=o.getContext("2d");l&&(l.beginPath(),l.moveTo(0,0),l.lineTo(s,0),l.lineTo(s,a),l.lineTo(0,a),l.closePath(),l.translate(s/2,a/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(o,"no-repeat"))?r:"")}_findCenterFromElement(){return new tZ(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=eq(this),r=this.group,i=this.shadow,n=Math.abs,s=t.enableRetinaScaling?tp():1,a=(t.multiplier||1)*s,o=t.canvasProvider||(t=>new eB(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&eG(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&e$(this,this.getViewportTransform()),this.setCoords();let l=t6(),h=this.getBoundingRect(),c=this.shadow,u=new tZ;if(c){let t=c.blur,e=c.nonScaling?new tZ(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=o(l);"jpeg"===t.format&&(g.backgroundColor="#fff"),this.setPositionByOrigin(new tZ(g.width/2,g.height/2),tC,tC);let p=this.canvas;g._objects=[this],this.set("canvas",g),this.setCoords();let m=g.toCanvasElement(a||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 et(this.toCanvasElement(t),t.format||"png",t.quality||1)}toBlob(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ee(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=tC,this.originY=tC,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(){tG.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&td().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:a,onChange:o,onComplete:l}=r,h=te(te({},r),{},{target:this,startValue:null!=a?a: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),o&&o(t,e,r)},onComplete:(t,e,r)=>{this.setCoords(),l&&l(t,e,r)}});return n?it(h):r7(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),a=r._objects.indexOf(n);return s>-1&&s>a}toObject(){let e,r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).concat(t.customProperties,this.constructor.customProperties||[]),i=ts.NUM_FRACTION_DIGITS,{clipPath:n,fill:s,stroke:a,shadow:o,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=>eS(t,i),R=te(te({},ew(this,r)),{},{type:this.constructor.type,version:tv,originX:u,originY:d,left:L(h),top:L(c),width:L(f),height:L(g),fill:ek(s)?s.toObject():s,stroke:ek(a)?a.toObject():a,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:o?o.toObject():o,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 eC(t,(t,e)=>{if(e===tS||"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=tr(t,ii),r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{extraParam:i}=r;return e_(e,tr(r,is)).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(),$(this,"_cacheContext",null),Object.assign(this,t.ownDefaults),this.setOptions(e)}};$(ia,"stateProperties",rz),$(ia,"cacheProperties",rY),$(ia,"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:tS,originY:"top",strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:tH,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}),$(ia,"type","FabricObject"),$(ia,"colorProperties",[tH,tX,"backgroundColor"]),$(ia,"customProperties",[]),tY.setClass(ia),tY.setClass(ia,"object");let io=(t,e,r)=>(i,n,s,a)=>{let o=e(i,n,s,a);return o&&e0(t,te(te({},e9(i,n,s,a)),r)),o};function il(t){return(e,r,i,n)=>{let{target:s,originX:a,originY:o}=r,l=s.getRelativeCenterPoint(),h=s.translateToOriginPoint(l,a,o),c=t(e,r,i,n);return s.setPositionByOrigin(h,r.originX,r.originY),c}}let ih=io(tF,il((t,e,r,i)=>{let n=e8(e,e.originX,e.originY,r,i);if(e2(e.originX)===e2(tC)||e2(e.originX)===e2(tO)&&n.x<0||e2(e.originX)===e2(tS)&&n.x>0){let{target:t}=e,r=t.strokeWidth/(t.strokeUniform?t.scaleX:1),i=e4(e)?2:1,s=t.width,a=Math.abs(n.x*i/t.scaleX)-r;return t.set("width",Math.max(a,1)),s!==t.width}return!1}));function ic(t,e,r,i,n){i=i||{};let s=this.sizeX||i.cornerSize||n.cornerSize,a=this.sizeY||i.cornerSize||n.cornerSize,o=void 0!==i.transparentCorners?i.transparentCorners:n.transparentCorners,l=o?tX:tH,h=!o&&(i.cornerStrokeColor||n.cornerStrokeColor),c,u=e,d=r;t.save(),t.fillStyle=i.cornerColor||n.cornerColor||"",t.strokeStyle=i.cornerStrokeColor||n.cornerStrokeColor||"",s>a?(c=s,t.scale(1,a/s),d=r*s/a):a>s?(c=a,t.scale(s/a,1),u=e*a/s):c=s,t.beginPath(),t.arc(u,d,c/2,0,tb,!1),t[l](),h&&t.stroke(),t.restore()}function iu(t,e,r,i,n){i=i||{};let s=this.sizeX||i.cornerSize||n.cornerSize,a=this.sizeY||i.cornerSize||n.cornerSize,o=void 0!==i.transparentCorners?i.transparentCorners:n.transparentCorners,l=o?tX:tH,h=!o&&(i.cornerStrokeColor||n.cornerStrokeColor),c=s/2,u=a/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(er(d)),t["".concat(l,"Rect")](-c,-u,s,a),h&&t.strokeRect(-c,-u,s,a),t.restore()}class id{shouldActivate(t,e,r,i){var n;let{tl:s,tr:a,br:o,bl:l}=i;return(null==(n=e.canvas)?void 0:n.getActiveObject())===e&&e.isControlVisible(t)&&ie.isPointInPolygon(r,[s,a,o,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 tZ(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,r,i,n,s){let a=el([eu(r,i),ed({angle:t}),ef((n?this.touchSizeX:this.sizeX)||e,(n?this.touchSizeY:this.sizeY)||e)]);return{tl:new tZ(-.5,-.5).transform(a),tr:new tZ(.5,-.5).transform(a),br:new tZ(.5,.5).transform(a),bl:new tZ(-.5,.5).transform(a)}}render(t,e,r,i,n){"circle"===((i=i||{}).cornerStyle||n.cornerStyle)?ic.call(this,t,e,r,i,n):iu.call(this,t,e,r,i,n)}constructor(t){$(this,"visible",!0),$(this,"actionName",tI),$(this,"angle",0),$(this,"x",0),$(this,"y",0),$(this,"offsetX",0),$(this,"offsetY",0),$(this,"sizeX",0),$(this,"sizeY",0),$(this,"touchSizeX",0),$(this,"touchSizeY",0),$(this,"cursorStyle","crosshair"),$(this,"withConnection",!1),Object.assign(this,t)}}let ig=(t,e,r)=>r.lockRotation?e5:e.cursorStyle,ip=io(tj,il((t,e,r,i)=>{let{target:n,ex:s,ey:a,theta:o,originX:l,originY:h}=e,c=n.translateToOriginPoint(n.getRelativeCenterPoint(),l,h);if(e3(n,"lockRotation"))return!1;let u=Math.atan2(a-c.y,s-c.x),d=ei(Math.atan2(i-c.y,r-c.x)-u+o);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 im(t,e){let r=e.canvas,i=t[r.uniScaleKey];return r.uniformScaling&&!i||!r.uniformScaling&&i}function iv(t,e,r){let i=e3(t,"lockScalingX"),n=e3(t,"lockScalingY");if(i&&n||!e&&(i||n)&&r||i&&"x"===e||n&&"y"===e)return!0;let{width:s,height:a,strokeWidth:o}=t;return 0===s&&0===o&&"y"!==e||0===a&&0===o&&"x"!==e}let iy=["e","se","s","sw","w","nw","n","ne","e"],ix=(t,e,r)=>{let i=im(t,r);if(iv(r,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",i))return e5;let n=e6(r,e);return"".concat(iy[n],"-resize")};function ib(t,e,r,i){let n,s,a,o,l,h,c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},u=e.target,d=c.by,f=im(t,u);if(iv(u,d,f))return!1;if(e.gestureScale)s=e.scaleX*e.gestureScale,a=e.scaleY*e.gestureScale;else{if(n=e8(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),e3(u,"lockScalingFlip")&&(e.signX!==l||e.signY!==h))return!1;if(o=u._getTransformedDimensions(),f&&!d){let t=Math.abs(n.x)+Math.abs(n.y),{original:r}=e,i=t/(Math.abs(o.x*r.scaleX/u.scaleX)+Math.abs(o.y*r.scaleY/u.scaleY));s=r.scaleX*i,a=r.scaleY*i}else s=Math.abs(n.x*u.scaleX/o.x),a=Math.abs(n.y*u.scaleY/o.y);e4(e)&&(s*=2,a*=2),e.signX!==l&&"y"!==d&&(e.originX=.5-e2(e.originX),s*=-1,e.signX=l),e.signY!==h&&"x"!==d&&(e.originY=.5-e2(e.originY),a*=-1,e.signY=h)}let g=u.scaleX,p=u.scaleY;return d?("x"===d&&u.set(tB,s),"y"===d&&u.set(tN,a)):(e3(u,"lockScalingX")||u.set(tB,s),e3(u,"lockScalingY")||u.set(tN,a)),g!==u.scaleX||p!==u.scaleY}let i_=io(tD,il((t,e,r,i)=>ib(t,e,r,i))),iw=io(tD,il((t,e,r,i)=>ib(t,e,r,i,{by:"x"}))),iC=io(tD,il((t,e,r,i)=>ib(t,e,r,i,{by:"y"}))),iS=["target","ex","ey","skewingSide"],iT={x:{counterAxis:"y",scale:tB,skew:tW,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:tN,skew:tU,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},iO=["ns","nesw","ew","nwse"],ik=(t,e,r)=>{if(0!==e.x&&e3(r,"lockSkewingY")||0!==e.y&&e3(r,"lockSkewingX"))return e5;let i=e6(r,e)%4;return"".concat(iO[i],"-resize")};function iM(t,e,r,i,n){let{target:s}=r,{counterAxis:a,origin:o,lockSkewing:l,skew:h,flip:c}=iT[t];if(e3(s,l))return!1;let{origin:u,flip:d}=iT[a],f=-Math.sign(e2(r[u])*(s[d]?-1:1))*(s[c]?-1:1),g=-(.5*((0===s[h]&&e8(r,tC,tC,i,n)[t]>0||s[h]>0?1:-1)*f))+.5;return io(tP,il((e,r,i,n)=>(function(t,e,r){let{target:i,ex:n,ey:s,skewingSide:a}=e,o=tr(e,iS),{skew:l}=iT[t],h=r.subtract(new tZ(n,s)).divide(new tZ(i.scaleX,i.scaleY))[t],c=i[l],u=Math.tan(er(o[l])),d=ei(Math.atan(2*h*a/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(tB,s*e)}return f})(t,r,new tZ(i,n))))(e,te(te({},r),{},{[o]:g,skewingSide:f}),i,n)}let iE=(t,e,r,i)=>iM("x",t,e,r,i),iD=(t,e,r,i)=>iM("y",t,e,r,i);function ij(t,e){return t[e.canvas.altActionKey]}let iA=(t,e,r)=>{let i=ij(t,r);return 0===e.x?i?tW:tN:0===e.y?i?tU:tB:""},iP=(t,e,r)=>ij(t,r)?ik(0,e,r):ix(t,e,r),iF=(t,e,r,i)=>ij(t,e.target)?iD(t,e,r,i):iw(t,e,r,i),iL=(t,e,r,i)=>ij(t,e.target)?iE(t,e,r,i):iC(t,e,r,i),iR=()=>({ml:new id({x:-.5,y:0,cursorStyleHandler:iP,actionHandler:iF,getActionName:iA}),mr:new id({x:.5,y:0,cursorStyleHandler:iP,actionHandler:iF,getActionName:iA}),mb:new id({x:0,y:.5,cursorStyleHandler:iP,actionHandler:iL,getActionName:iA}),mt:new id({x:0,y:-.5,cursorStyleHandler:iP,actionHandler:iL,getActionName:iA}),tl:new id({x:-.5,y:-.5,cursorStyleHandler:ix,actionHandler:i_}),tr:new id({x:.5,y:-.5,cursorStyleHandler:ix,actionHandler:i_}),bl:new id({x:-.5,y:.5,cursorStyleHandler:ix,actionHandler:i_}),br:new id({x:.5,y:.5,cursorStyleHandler:ix,actionHandler:i_}),mtr:new id({x:0,y:-.5,actionHandler:ip,cursorStyleHandler:ig,offsetY:-40,withConnection:!0,actionName:tA})}),iI=()=>({mr:new id({x:.5,y:0,actionHandler:ih,cursorStyleHandler:iP,actionName:tF}),ml:new id({x:-.5,y:0,actionHandler:ih,cursorStyleHandler:iP,actionName:tF})}),iB=()=>te(te({},iR()),iI());class iN extends ia{static getDefaults(){return te(te({},super.getDefaults()),iN.ownDefaults)}static createControls(){return{controls:iR()}}_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(tI))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],a=this.controls[n];if(a.shouldActivate(n,this,t,e?s.touchCorner:s.corner))return this.__corner=n,{key:n,control:a,coord:this.oCoords[n]}}}calcOCoords(){let t=this.getViewportTransform(),e=this.getCenterPoint(),r=eo(eu(e.x,e.y),ed({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?ec(this.calcTransformMatrix()):void 0;s&&(s.scaleX=Math.abs(s.scaleX),s.scaleY=Math.abs(s.scaleY));let a=this._calculateCurrentDimensions(s),o={};return this.forEachControl((t,e)=>{let r=t.positionHandler(a,n,this,t);o[e]=Object.assign(r,this._calcCornerCoords(t,r))}),o}_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(er(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=te({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=te({hasBorders:r,hasControls:i},e),s=this.getViewportTransform(),a=n.hasBorders,o=n.hasControls,l=ec(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(er(this.group?l.angle:this.angle)),a&&this.drawBorders(t,l,e),o&&this.drawControls(t,e),t.restore()}drawBorders(t,e,r){let i;if(r&&r.forActiveSelection||this.group){let t=eK(this.width,this.height,ev(e)),r=this.isStrokeAccountedForInDimensions()?t$:(this.strokeUniform?(new tZ).scalarAdd(this.canvas?this.canvas.getZoom():1):new tZ(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,a=te({cornerStrokeColor:i,cornerDashArray:n,cornerColor:s},e);t.setTransform(r,0,0,r,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl((e,r)=>{if(e.getVisibility(this,r)){let i=this.oCoords[r];e.render(t,i.x,i.y,a,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(),iN.ownDefaults),this.setOptions(t)}}function iW(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}$(iN,"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 iU extends iN{}iW(iU,[rc]),tY.setClass(iU),tY.setClass(iU,"object");let iH=(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 iX{createSideVector(t,e){let r=rA(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 tZ(t);return e.y+=e.x*Math.tan(er(this.options.skewY)),e.x+=e.y*Math.tan(er(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 tZ(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new tZ(1/this.options.scaleX,1/this.options.scaleY):new tZ(1,1)}}let iV=new tZ;class iz extends iX{static getOrthogonalRotationFactor(t,e){return Math.abs(e?rF(t,e):rL(t))<tx?-1:1}calcOrthogonalProjection(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude,i=rI(this.createSideVector(t,e)),n=iz.getOrthogonalRotationFactor(i,this.bisector);return this.scaleUnitVector(i,r*n)}projectBevel(){let t=[];return(this.alpha%tb==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?rP(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return rP(r)/this.strokeProjectionMagnitude<=i&&t.push(this.applySkew(this.A.add(r))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){let r=[],i=new tZ(iz.getOrthogonalRotationFactor(this.bisector),iz.getOrthogonalRotationFactor(new tZ(this.bisector.y,this.bisector.x)));return[new tZ(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new tZ(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach(i=>{rW(i,t,e)&&r.push(this.A.add(i))}),r}projectRoundWithSkew(t,e){let r=[],{skewX:i,skewY:n,scaleX:s,scaleY:a,strokeUniform:o}=this.options,l=new tZ(Math.tan(er(i)),Math.tan(er(n))),h=this.strokeProjectionMagnitude,c=o?h/a/Math.sqrt(1/a**2+1/s**2*l.y**2):h/Math.sqrt(1+l.y**2),u=new tZ(Math.sqrt(Math.max(h**2-c**2,0)),c),d=o?h/Math.sqrt(1+l.x**2*(1/a)**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 tZ(d,Math.sqrt(Math.max(h**2-d**2,0)));return[f,f.scalarMultiply(-1),u,u.scalarMultiply(-1)].map(t=>this.applySkew(o?t.multiply(this.strokeUniformScalar):t)).forEach(i=>{rW(i,t,e)&&r.push(this.applySkew(this.A).add(i))}),r}projectRound(){let t=[];t.push(...this.projectBevel());let e=this.alpha%tb==0,r=this.applySkew(this.A),i=t[2*!e].subtract(r),n=t[+!!e].subtract(r),s=rB(i,e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)))>0,a=s?i:n,o=s?n:i;return this.isSkewed()?t.push(...this.projectRoundWithSkew(a,o)):t.push(...this.projectRoundNoSkew(a,o)),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),$(this,"AB",void 0),$(this,"AC",void 0),$(this,"alpha",void 0),$(this,"bisector",void 0),this.A=new tZ(t),this.B=new tZ(e),this.C=new tZ(r),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=rF(this.AB,this.AC),this.bisector=rR(rj(this.AB.eq(iV)?this.AC:this.AB,this.alpha/2))}}class iY extends iX{calcOrthogonalProjection(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude,i=this.createSideVector(t,e);return this.scaleUnitVector(rI(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 tZ(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 iz(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){let t=[];if(this.A.eq(this.T)){let e=new tZ(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(rR(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 tZ(t),this.T=new tZ(e)}}let iG=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 tZ(e)),t),[new tZ(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 a,o;0===n?(o=s[1],a=r?t:s[s.length-1]):n===s.length-1?(a=s[n-1],o=r?t:s[0]):(a=s[n-1],o=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?o:a,e).project()):i.push(...new iz(t,a,o,e).project())}),i},iq=t=>{let e={};return Object.keys(t).forEach(r=>{e[r]={},Object.keys(t[r]).forEach(i=>{e[r][i]=te({},t[r][i])})}),e},iK=t=>t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),iQ=t=>(r||r||(r="Intl"in tg()&&"Segmenter"in Intl&&new Intl.Segmenter(void 0,{granularity:"grapheme"})),r)?Array.from(r.segment(t)).map(t=>{let{segment:e}=t;return e}):iJ(t),iJ=t=>{let e=[];for(let r,i=0;i<t.length;i++)!1!==(r=iZ(t,i))&&e.push(r);return e},iZ=(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 i$=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:iK,graphemeSplit:iQ});let i0=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)},i1=(t,e)=>{let r=e.split("\n"),i=[],n=-1,s={};t=iq(t);for(let e=0;e<r.length;e++){let a=iQ(r[e]);if(t[e])for(let r=0;r<a.length;r++){n++;let a=t[e][r];a&&Object.keys(a).length>0&&(i0(s,a,!0)?i.push({start:n,end:n+1,style:a}):i[i.length-1].end++),s=a||{}}else n+=a.length,s={}}return i},i2=(t,e)=>{if(!Array.isArray(t))return iq(t);let r=e.split(tM),i={},n=-1,s=0;for(let e=0;e<r.length;e++){let a=iQ(r[e]);for(let r=0;r<a.length;r++)n++,t[s]&&t[s].start<=n&&n<t[s].end&&(i[e]=i[e]||{},i[e][r]=te({},t[s].style),n===t[s].end-1&&s++)}return i},i5=["display","transform",tH,"fill-opacity","fill-rule","opacity",tX,"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 i4(t,e){let r,i=t.nodeName,n=t.getAttribute("class"),s=t.getAttribute("id"),a="(?![a-zA-Z\\-]+)";if(r=RegExp("^"+i,"i"),e=e.replace(r,""),s&&e.length&&(r=RegExp("#"+s+a,"i"),e=e.replace(r,"")),n&&e.length){let t=n.split(" ");for(let i=t.length;i--;)r=RegExp("\\."+t[i]+a,"i"),e=e.replace(r,"")}return 0===e.length}let i3=t=>{var e;return null!=(e=rT[t])?e:t},i9=RegExp("(".concat(rw,")"),"gi"),i6="(".concat(rw,")"),i8=String.raw(h||(h=ti(["(skewX)(",")"],["(skewX)\\(","\\)"])),i6),i7=String.raw(c||(c=ti(["(skewY)(",")"],["(skewY)\\(","\\)"])),i6),nt=String.raw(u||(u=ti(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),i6,i6,i6),ne=String.raw(d||(d=ti(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),i6,i6),nr=String.raw(f||(f=ti(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),i6,i6),ni=String.raw(g||(g=ti(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),i6,i6,i6,i6,i6,i6),nn="(?:".concat(ni,"|").concat(nr,"|").concat(nt,"|").concat(ne,"|").concat(i8,"|").concat(i7,")"),ns=new RegExp(String.raw(p||(p=ti(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),"(?:".concat(nn,"*)"))),na=new RegExp(nn),no=RegExp(nn,"g");function nl(t){let e=[];if(!(t=t.replace(i9," $1 ").replace(/,/gi," ").replace(/\s+/gi," ").replace(/\s*([()])\s*/gi,"$1"))||t&&!ns.test(t))return[...tw];for(let r of t.matchAll(no)){let t=na.exec(r[0]);if(!t)continue;let i=tw,[,n,...s]=t.filter(t=>!!t),[a,o,l,h,c,u]=s.map(t=>parseFloat(t));switch(n){case"translate":i=eu(a,o);break;case tA:i=ed({angle:a},{x:o,y:l});break;case tI:i=ef(a,o);break;case tW:i=ep(a);break;case tU:i=em(a);break;case"matrix":i=[a,o,l,h,c,u]}e.push(i)}return el(e)}let nh={stroke:"strokeOpacity",fill:"fillOpacity"};function nc(t,e,r){if(!t)return{};let i,n={},s=16;t.parentNode&&rM.test(t.parentNode.nodeName)&&(n=nc(t.parentElement,e,r)).fontSize&&(i=s=ro(n.fontSize));let a=te(te(te({},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=i4(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=i4(t=t.parentElement,r);return 0===e.length}(t,e)),i&&r&&0===e.length})(t,i.split(" "))&&(r=te(te({},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));a[rk]&&t.setAttribute(rk,a[rk]),a[rO]&&(i=ro(a[rO],s),a[rO]="".concat(i));let o={};for(let t in a){let e=i3(t),r=function(t,e,r,i){let n=Array.isArray(e),s,a=e;if(t!==tH&&t!==tX||e!==tk){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)a=e===tk?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)a=r&&r.transformMatrix?eo(r.transformMatrix,nl(e)):nl(e);else if("visible"===t)a=e!==tk&&"hidden"!==e,r&&!1===r.visible&&(a=!1);else if("opacity"===t)a=parseFloat(e),r&&void 0!==r.opacity&&(a*=r.opacity);else if("textAnchor"===t)a="start"===e?tS:"end"===e?tO:tC;else if("charSpacing"===t||t===rd)s=ro(e,i)/i*1e3;else if("paintFirst"===t){let t=e.indexOf(tH),r=e.indexOf(tX);a=tH,(t>-1&&r>-1&&r<t||-1===t&&r>-1)&&(a=tX)}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 a="";return!n&&isNaN(s)?a:s}(e,a[t],n,i);o[e]=r}o&&o.font&&function(t,e){let r=t.match(rS);if(!r)return;let i=r[1],n=r[3],s=r[4],a=r[5],o=r[6];i&&(e.fontStyle=i),n&&(e.fontWeight=isNaN(parseFloat(n))?n:parseFloat(n)),s&&(e.fontSize=ro(s)),o&&(e.fontFamily=o),a&&(e.lineHeight="normal"===a?1:a)}(o.font,o);let l=te(te({},n),o);return rM.test(t.nodeName)?l:function(t){let e=iU.getDefaults();return Object.entries(nh).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 ra(t[i]);t[i]=s.setAlpha(eS(s.getAlpha()*t[n],2)).toRgba()}),t}(l)}let nu=["left","top","width","height","visible"],nd=["rx","ry"];class nf extends iU{static getDefaults(){return te(te({},super.getDefaults()),nf.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,a=this.ry?Math.min(this.ry,r/2):0,o=0!==s||0!==a;t.beginPath(),t.moveTo(i+s,n),t.lineTo(i+e-s,n),o&&t.bezierCurveTo(i+e-.4477152502*s,n,i+e,n+.4477152502*a,i+e,n+a),t.lineTo(i+e,n+r-a),o&&t.bezierCurveTo(i+e,n+r-.4477152502*a,i+e-.4477152502*s,n+r,i+e-s,n+r),t.lineTo(i+s,n+r),o&&t.bezierCurveTo(i+.4477152502*s,n+r,i,n+r-.4477152502*a,i,n+r-a),t.lineTo(i,n+a),o&&t.bezierCurveTo(i,n+.4477152502*a,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([...nd,...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=nc(t,this.ATTRIBUTE_NAMES,r),{left:n=0,top:s=0,width:a=0,height:o=0,visible:l=!0}=i,h=tr(i,nu);return new this(te(te(te({},e),h),{},{left:n,top:s,width:a,height:o,visible:!!(l&&a&&o)}))}constructor(t){super(),Object.assign(this,nf.ownDefaults),this.setOptions(t),this._initRxRy()}}$(nf,"type","Rect"),$(nf,"cacheProperties",[...rY,...nd]),$(nf,"ownDefaults",{rx:0,ry:0}),$(nf,"ATTRIBUTE_NAMES",[...i5,"x","y","rx","ry","width","height"]),tY.setClass(nf),tY.setSVGClass(nf);let ng="initialization",np="added",nm="removed",nv="imperative",ny=(t,e)=>{let{strokeUniform:r,strokeWidth:i,width:n,height:s,group:a}=e,o=a&&a!==t?eQ(a.calcTransformMatrix(),t.calcTransformMatrix()):null,l=o?e.getRelativeCenterPoint().transform(o):e.getRelativeCenterPoint(),h=!e.isStrokeAccountedForInDimensions(),c=r&&h?eZ(new tZ(i,i),void 0,t.calcTransformMatrix()):t$,u=!r&&h?i:0,d=eK(n+u,s+u,el([o,e.calcOwnMatrix()],!0)).add(c).scalarDivide(2);return[l.subtract(d),l.add(d)]};class nx{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:r,strategy:i}=t;return e===ng||e===nv||!!r&&i!==r}shouldLayoutClipPath(t){let{type:e,target:{clipPath:r}}=t;return e!==ng&&r&&!r.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){let{type:r,target:i}=e;if(r===nv&&e.overrides)return e.overrides;if(0===t.length)return;let{left:n,top:s,width:a,height:o}=eX(t.map(t=>ny(i,t)).reduce((t,e)=>t.concat(e),[])),l=new tZ(a,o),h=new tZ(n,s).add(l.scalarDivide(2));if(r===ng){let t=this.getInitialSize(e,{size:l,center:h});return{center:h,relativeCorrection:new tZ(0,0),size:t}}return{center:h.transform(i.calcOwnMatrix()),size:l}}}$(nx,"type","strategy");class nb extends nx{shouldPerformLayout(t){return!0}}$(nb,"type","fit-content"),tY.setClass(nb);let n_=["strategy"],nw=["target","strategy","bubbles","prevStrategy"],nC="layoutManager";class nS{performLayout(t){let e=te(te({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[tV,tE,tF,tj,tD,tP,tR,tL,"modifyPath"].map(e=>t.on(e,t=>this.performLayout(e===tV?{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===ng||r===np?this.subscribeTargets(t):r===nm&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),i&&i.fire("object:layout:before",{target:e,context:t}),r===nv&&t.deep){let r=tr(t,n_);e.forEachObject(t=>t.layoutManager&&t.layoutManager.performLayout(te(te({},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===ng?new tZ:e.getRelativeCenterPoint(),{center:a,correction:o=new tZ,relativeCorrection:l=new tZ}=n,h=s.subtract(a).add(o).transform(i===ng?tw:ea(e.calcOwnMatrix()),!0).add(l);return{result:n,prevCenter:s,nextCenter:a,offset:h}}commitLayout(t,e){var r,i;let{target:n}=t,{result:{size:s},nextCenter:a}=e;(n.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===ng)?n.set({left:null!=(r=t.x)?r:a.x+s.x*e2(n.originX),top:null!=(i=t.y)?i:a.y+s.y*e2(n.originY)}):(n.setPositionByOrigin(a,tC,tC),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,a=tr(t,nw),{canvas:o}=r;r.fire("layout:after",{context:t,result:e}),o&&o.fire("object:layout:after",{context:t,result:e,target:r});let l=r.parent;n&&null!=l&&l.layoutManager&&((a.path||(a.path=[])).push(r),l.layoutManager.performLayout(te(te({},a),{},{target:l}))),r.set("dirty",!0)}dispose(){let{_subscriptions:t}=this;t.forEach(t=>t.forEach(t=>t())),t.clear()}toObject(){return{type:nC,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new nb;$(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}}tY.setClass(nS,nC);let nT=["type","objects","layoutManager"];class nO extends nS{performLayout(){}}class nk extends t1(iU){static getDefaults(){return te(te({},super.getDefaults()),nk.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 nS,this.layoutManager.performLayout({type:ng,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(ta("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(ta("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(np,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(np,n),s}remove(){let t=super.remove(...arguments);return this._onAfterObjectsChange(nm,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(ea(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=iU.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(...ea(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(te({target:this,type:nv},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 te(te(te({},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=nf.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=tr(t,nT);return Promise.all([eb(i,e),e_(s,e)]).then(t=>{let[e,r]=t,i=new this(e,te(te(te({},s),r),{},{layoutManager:new nO}));return n?i.layoutManager=new(tY.getClass(n.type))(new(tY.getClass(n.strategy))):i.layoutManager=new nS,i.layoutManager.subscribeTargets({type:ng,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(),$(this,"_activeObjects",[]),$(this,"__objectSelectionTracker",void 0),$(this,"__objectSelectionDisposer",void 0),Object.assign(this,nk.ownDefaults),this.setOptions(e),this.groupInit(t,e)}}$(nk,"type","Group"),$(nk,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),tY.setClass(nk);let nM=(t,e)=>Math.min(e.width/t.width,e.height/t.height),nE=(t,e)=>Math.max(e.width/t.width,e.height/t.height),nD="\\s*,?\\s*",nj="".concat(nD,"(").concat(rw,")"),nA="".concat(nj).concat(nj).concat(nj).concat(nD,"([01])").concat(nD,"([01])").concat(nj).concat(nj),nP={m:"l",M:"L"},nF=(t,e,r,i,n,s,a,o,l,h,c)=>{let u=tQ(t),d=tJ(t),f=tQ(e),g=tJ(e),p=r*n*f-i*s*g+a,m=i*n*f+r*s*g+o;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]},nL=(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 nR(t,e,r,i,n,s,a,o){let l;if(ts.cachesBoundsOfCurve&&(l=[...arguments].join(),tm.boundsOfCurveCache[l]))return tm.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*a,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*o,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),a=(-f+n)/(2*g);0<a&&a<1&&u.push(a);let l=(-f-n)/(2*g);0<l&&l<1&&u.push(l)}let m=u.length,y=m,x=nW(t,e,r,i,n,s,a,o);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]=a,d[1][y+1]=o;let b=[new tZ(Math.min(...d[0]),Math.min(...d[1])),new tZ(Math.max(...d[0]),Math.max(...d[1]))];return ts.cachesBoundsOfCurve&&(tm.boundsOfCurveCache[l]=b),b}let nI=(t,e,r)=>{let[i,n,s,a,o,l,h,c]=r,u=((t,e,r,i,n,s,a)=>{if(0===r||0===i)return[];let o=0,l=0,h=0,c=Math.PI,u=a*t_,d=tJ(u),f=tQ(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=nL(1,0,(g-S)/w,(p-T)/C),E=nL((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]=nF(M,F,f,d,w,C,O,k,P,o,l),o=j[t][5],l=j[t][6],M=F,F+=A;return j})(h-t,c-e,n,s,o,l,a);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},nB=t=>{let e=0,r=0,i=0,n=0,s=[],a,o=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":o=c[3],l=c[4],e=c[5],r=c[6],t=["C",c[1],c[2],o,l,e,r];break;case"s":c[1]+=e,c[2]+=r,c[3]+=e,c[4]+=r;case"S":"C"===a?(o=2*e-o,l=2*r-l):(o=e,l=r),e=c[3],r=c[4],o=(t=["C",o,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":o=c[1],l=c[2],t=["Q",o,l,e=c[3],r=c[4]];break;case"t":c[1]+=e,c[2]+=r;case"T":"Q"===a?(o=2*e-o,l=2*r-l):(o=e,l=r),t=["Q",o,l,e=c[1],r=c[2]];break;case"a":c[6]+=e,c[7]+=r;case"A":nI(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),a=t[0]):a=""}return s},nN=(t,e,r,i)=>Math.sqrt((r-t)**2+(i-e)**2),nW=(t,e,r,i,n,s,a,o)=>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 tZ(a*h+n*c+r*u+t*d,o*h+s*c+i*u+e*d)},nU=t=>2*t*(1-t),nH=(t,e,r,i,n,s,a,o)=>l=>{let h=l**2,c=nU(l),u=(1-l)**2;return Math.atan2(3*(u*(i-e)+c*(s-i)+h*(o-s)),3*(u*(r-t)+c*(n-r)+h*(a-n)))},nX=(t,e,r,i,n,s)=>a=>{let o=a**2,l=nU(a),h=(1-a)**2;return new tZ(n*o+r*l+t*h,s*o+i*l+e*h)},nV=(t,e,r,i,n,s)=>a=>{let o=1-a;return Math.atan2(2*(o*(i-e)+a*(s-i)),2*(o*(r-t)+a*(n-r)))},nz=(t,e,r)=>{let i=new tZ(e,r),n=0;for(let e=1;e<=100;e+=1){let r=t(e/100);n+=nN(i.x,i.y,r.x,r.y),i=r}return n},nY=t=>{let e,r,i=0,n=0,s=0,a=0,o=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=a=n=h[1],r.y=o=s=h[2];break;case"L":(r=t).length=nN(n,s,h[1],h[2]),n=h[1],s=h[2];break;case"C":e=nW(n,s,h[1],h[2],h[3],h[4],h[5],h[6]),(r=t).iterator=e,r.angleFinder=nH(n,s,h[1],h[2],h[3],h[4],h[5],h[6]),r.length=nz(e,n,s),n=h[5],s=h[6];break;case"Q":e=nX(n,s,h[1],h[2],h[3],h[4]),(r=t).iterator=e,r.angleFinder=nV(n,s,h[1],h[2],h[3],h[4]),r.length=nz(e,n,s),n=h[3],s=h[4];break;case"Z":(r=t).destX=a,r.destY=o,r.length=nN(n,s,a,o),n=a,s=o}i+=r.length,l.push(r)}return l.push({length:i,x:n,y:s}),l},nG=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,a=t[i];switch(n.command){case"M":return{x:n.x,y:n.y,angle:0};case"Z":return te(te({},new tZ(n.x,n.y).lerp(new tZ(n.destX,n.destY),s)),{},{angle:Math.atan2(n.destY-n.y,n.destX-n.x)});case"L":return te(te({},new tZ(n.x,n.y).lerp(new tZ(a[1],a[2]),s)),{},{angle:Math.atan2(a[2]-n.y,a[1]-n.x)});case"C":case"Q":return((t,e)=>{let r,i=0,n=0,s={x:t.x,y:t.y},a=te({},s),o=.01,l=0,h=t.iterator,c=t.angleFinder;for(;n<e&&o>1e-4;)a=h(i),l=i,(r=nN(s.x,s.y,a.x,a.y))+n>e?(i-=o,o/=2):(s=a,i+=o,n+=r);return te(te({},a),{},{angle:c(l)})})(n,e)}},nq=RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),nK=RegExp(nA,"g"),nQ=RegExp(rw,"gi"),nJ={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},nZ=t=>{var e;let r=[];for(let i of null!=(e=t.match(nq))?e:[]){let t=i[0];if("z"===t||"Z"===t){r.push([t]);continue}let e=nJ[t.toLowerCase()],n=[];if("a"===t||"A"===t){nK.lastIndex=0;for(let t=null;t=nK.exec(i);)n.push(...t.slice(1))}else n=i.match(nQ)||[];for(let i=0;i<n.length;i+=e){let s=Array(e),a=nP[t];s[0]=i>0&&a?a:t;for(let t=0;t<e;t++)s[t+1]=parseFloat(n[i+t]);r.push(s)}}return r},n$=function(t){let e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=new tZ(t[0]),n=new tZ(t[1]),s=1,a=0,o=[],l=t.length,h=l>2;for(h&&(s=t[2].x<n.x?-1:+(t[2].x!==n.x),a=t[2].y<n.y?-1:+(t[2].y!==n.y)),o.push(["M",i.x-s*r,i.y-a*r]),e=1;e<l;e++){if(!i.eq(n)){let t=i.midPointFrom(n);o.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,a=i.y>t[e-2].y?1:i.y===t[e-2].y?0:-1),o.push(["L",i.x+s*r,i.y+a*r]),o},n0=(t,e)=>t.map(t=>t.map((t,r)=>0===r||void 0===e?t:eS(t,e)).join(" ")).join(" ");function n1(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:ez,animate:r7,animateColor:it,applyTransformToObject:eY,calcAngleBetweenVectors:rF,calcDimensionsMatrix:ev,calcPlaneChangeMatrix:eQ,calcVectorRotation:rL,cancelAnimFrame:t4,capValue:rV,composeMatrix:ey,copyCanvasElement:t=>{var e;let r=t7(t);return null==(e=r.getContext("2d"))||e.drawImage(t,0,0),r},cos:tQ,createCanvasElement:t6,createImage:t8,createRotateMatrix:ed,createScaleMatrix:ef,createSkewXMatrix:ep,createSkewYMatrix:em,createTranslateMatrix:eu,createVector:rA,crossProduct:rB,degreesToRadians:er,dotProduct:rN,ease:rZ,enlivenObjectEnlivables:e_,enlivenObjects:eb,findScaleToCover:nE,findScaleToFit:nM,getBoundsOfCurve:nR,getOrthonormalVector:rI,getPathSegmentsInfo:nY,getPointOnPath:nG,getPointer:eW,getRandomInt:(t,e)=>Math.floor(Math.random()*(e-t+1))+t,getRegularPolygonPath:(t,e)=>{let r=2*Math.PI/t,i=-tx;t%2==0&&(i+=r/2);let n=Array(t+1);for(let s=0;s<t;s++){let t=s*r+i,{x:a,y:o}=new tZ(tQ(t),tJ(t)).scalarMultiply(e);n[s]=[0===s?"M":"L",a,o]}return n[t]=["Z"],n},getSmoothPathFromPoints:n$,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:rR,groupSVGElements:(t,e)=>t&&1===t.length?t[0]:new nk(t,e),hasStyleChanged:i0,invertTransform:ea,isBetweenVectors:rW,isIdentityMatrix:en,isTouchEvent:eU,isTransparent:iH,joinPath:n0,loadImage:ex,magnitude:rP,makeBoundingBoxFromPoints:eX,makePathSimpler:nB,matrixToSVG:eT,mergeClipPaths:(t,e)=>{var r;let i=t,n=e;i.inverted&&!n.inverted&&(i=e,n=t),e$(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 nk([i],{clipPath:n,inverted:s})},multiplyTransformMatrices:eo,multiplyTransformMatrixArray:el,parsePath:nZ,parsePreserveAspectRatioAttribute:rl,parseUnit:ro,pick:ew,projectStrokeOnPoints:iG,qrDecompose:ec,radiansToDegrees:ei,removeFromArray:tK,removeTransformFromObject:(t,e)=>{let r=eo(ea(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}=ec(t.transformMatrix);t.flipX=!1,t.flipY=!1,t.set(tB,e),t.set(tN,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,tC,tC)},request:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.onComplete||ty,i=new(tg()).XMLHttpRequest,n=e.signal,s=function(){i.abort()},a=function(){n&&n.removeEventListener("abort",s),i.onerror=i.ontimeout=ty};if(n&&n.aborted)throw new tl("request");return n&&n.addEventListener("abort",s,{once:!0}),i.onreadystatechange=function(){4===i.readyState&&(a(),r(i),i.onreadystatechange=ty)},i.onerror=i.ontimeout=a,i.open("get",t,!0),i.send(),i},requestAnimFrame:t5,resetObjectTransform:eG,rotatePoint:(t,e,r)=>t.rotate(r,e),rotateVector:rj,saveObjectTransform:eq,sendObjectToPlane:e$,sendPointToPlane:eJ,sendVectorToPlane:eZ,setStyle:n1,sin:tJ,sizeAfterTransform:eK,string:i$,stylesFromArray:i2,stylesToArray:i1,toBlob:ee,toDataURL:et,toFixed:eS,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}=es({x:t[i],y:t[i+1]},e);r[i]=n,r[i+1]=s}return r})),transformPoint:es});class n2 extends eR{createUpperCanvas(){let{el:t}=this.lower,e=t6();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=tf().createElement("div");return t.setAttribute("data-fabric","wrapper"),n1(t,{position:"relative"}),eL(t),t}applyCanvasStyle(t,e){let{styles:r,allowTouchScrolling:i}=e;n1(t,te(te({},r),{},{"touch-action":i?"manipulation":tk})),eL(t)}setDimensions(t,e){super.setDimensions(t,e);let{el:r,ctx:i}=this.upper;eP(r,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),eF(this.upper.el,t),eF(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(),td().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),$(this,"upper",void 0),$(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 n5 extends eB{static getDefaults(){return te(te({},super.getDefaults()),n5.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 n2(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 a=Math.round(i*this.getRetinaScaling());return iH(n,a,a,a)}_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===tI||e===tB||e===tN||e===tF?i=this.centeredScaling||t.centeredScaling:e===tA&&(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=tO:["mr","tr","br"].includes(e)&&(r.x=tS),["tl","mt","tr"].includes(e)?r.y=tT:["bl","mb","br"].includes(e)&&(r.y="top")),r}_setupCurrentTransform(t,e,r){var i;let n=e.group?eJ(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:s="",control:a}=e.getActiveControl()||{},o=r&&a?null==(i=a.getActionHandler(t,e,a))?void 0:i.bind(a):e7,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:tC,y:tC}:this._getOriginFromCorner(e,s),u={target:e,action:l,actionHandler:o,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:er(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:te(te({},eq(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 tZ(e,r).transform(this.viewportTransform),a=new tZ(e+i,r+n).transform(this.viewportTransform),o=this.selectionLineWidth/2,l=Math.min(s.x,a.x),h=Math.min(s.y,a.y),c=Math.max(s.x,a.x),u=Math.max(s.y,a.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+=o,h+=o,c-=o,u-=o,iU.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,eU(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,a=Math.atan2(e.y-t.y,e.x-t.x),o=tQ(a)*n,l=tJ(a)*n,h=o+l,c=o-l;r=[new tZ(t.x-c,t.y-h),new tZ(e.x+h,e.y-c),new tZ(i.x+c,i.y+h),new tZ(s.x-h,s.y+c)]}return ie.isPointInPolygon(e,r)}_checkTarget(t,e){return!(!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,eJ(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(t0(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&&t0(r)&&r.interactive&&this.targets[0]){let t=this.targets;for(let e=t.length-1;e>0;e--){let r=t[e];if(!t0(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=eW(t),s=i.width||0,a=i.height||0;s&&a||("top"in i&&tT in i&&(a=Math.abs(i.top-i.bottom)),tO in i&&tS 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=eJ(n,void 0,this.viewportTransform));let o=this.getRetinaScaling();1!==o&&(n.x/=o,n.y/=o);let l=0===s||0===a?new tZ(1,1):new tZ(r.width/s,r.height/a);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=t6(),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 eE(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let r=!1,i=!1,n=this.getActiveObjects(),s=[],a=[];t.forEach(t=>{n.includes(t)||(r=!0,t.fire("deselected",{e:e,target:t}),a.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:a})):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:a})),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,eE(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),eE(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(tV,i))}setViewportTransform(t){super.setViewportTransform(t);let e=this._activeObject;e&&e.setCoords()}destroy(){let t=this._activeObject;eE(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&&eE(e)&&this._activeObject===e){let r=ew(t,["angle","flipX","flipY",tS,tB,tN,tW,tU,"top"]);return ez(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),$(this,"targets",[]),$(this,"_hoveredTargets",[]),$(this,"_objectsToRender",void 0),$(this,"_currentTransform",null),$(this,"_groupSelector",null),$(this,"contextTopDirty",!1)}}$(n5,"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 n4{exitTextEditing(){this.target=void 0,this.targets.forEach(t=>{t.isEditing&&t.exitEditing()})}add(t){this.targets.push(t)}remove(t){this.unregister(t),tK(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){$(this,"targets",[]),$(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 n3=["target","oldTarget","fireCanvas","e"],n9={passive:!1},n6=(t,e)=>{let r=t.getViewportPoint(e),i=t.getScenePoint(e);return{viewportPoint:r,scenePoint:i,pointer:r,absolutePointer:i}},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.addEventListener(...r)},n7=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)},st={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 se extends n5{_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){let r=this.upperCanvasEl,i=this._getEventPrefix();t(eA(r),"resize",this._onResize),t(r,i+"down",this._onMouseDown),t(r,"".concat(i,"move"),this._onMouseMove,n9),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,n9)}removeListeners(){this.addOrRemove(n7,"remove");let t=this._getEventPrefix(),e=ej(this.upperCanvasEl);n7(e,"".concat(t,"up"),this._onMouseUp),n7(e,"touchend",this._onTouchEnd,n9),n7(e,"".concat(t,"move"),this._onMouseMove,n9),n7(e,"touchmove",this._onMouseMove,n9),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){let e=this._hoveredTarget,r=te({e:t},n6(this,t));this.fire("mouse:out",te(te({},r),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",te({},r)),this._hoveredTargets.forEach(t=>{this.fire("mouse:out",te(te({},r),{},{target:t})),t&&t.fire("mouseout",te({},r))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",te({e:t},n6(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 n8(this.upperCanvasEl,"drag",this._onDragProgress)}eH(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!==tk,r=e?this._activeObject:void 0,i={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:r};n7(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,a={e:t,target:i,subTargets:n,dragSource:s,canDrop:!1,dropTarget:void 0};this.fire(r,a),this._fireEnterLeaveEvents(i,a),i&&(i.canDrop(t)&&(e=i),i.fire(r,a));for(let i=0;i<n.length;i++){let s=n[i];s.canDrop(t)&&(e=s),s.fire(r,a)}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",te({e:t,target:e,subTargets:r,dragSource:this._dragSource},n6(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&&eH(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=ej(i);n8(s,"touchend",this._onTouchEnd,n9),e&&n8(s,"touchmove",this._onMouseMove,n9),n7(i,"".concat(n,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();let e=this.upperCanvasEl,r=this._getEventPrefix();n7(e,"".concat(r,"move"),this._onMouseMove,n9);let i=ej(e);n8(i,"".concat(r,"up"),this._onMouseUp),n8(i,"".concat(r,"move"),this._onMouseMove,n9)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;let e=this._getEventPrefix(),r=ej(this.upperCanvasEl);n7(r,"touchend",this._onTouchEnd,n9),n7(r,"touchmove",this._onMouseMove,n9),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{n8(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=ej(this.upperCanvasEl);n7(t,"".concat(r,"up"),this._onMouseUp),n7(t,"".concat(r,"move"),this._onMouseMove,n9),n8(e,"".concat(r,"move"),this._onMouseMove,n9)}}_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 a,o,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),eU(t))||{};if(o=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&&(a=this.getScenePoint(t),e.call(i,t,r,a.x,a.y))}n.isMoving=!1}if(r&&(r.target!==n||r.corner!==o)){let e=r.target&&r.target.controls[r.corner],i=e&&e.getMouseUpHandler(t,r.target,e);a=a||this.getScenePoint(t),i&&i.call(e,t,r,a.x,a.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=te(te(te({e:t,target:i,subTargets:n},n6(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),eU(t));if(e===this._activeObject&&(i||!s)){this._setupCurrentTransform(t,e,r);let n=i?i.control:void 0,s=this.getScenePoint(t),a=n&&n.getMouseDownHandler(t,e,n);a&&a.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=eJ(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",te(te({},e),{},{target:t,oldTarget:r,fireCanvas:!0}));for(let t=0;t<s;t++)this.fireSyntheticInOutEvents("drag",te(te({},e),{},{target:n[t],oldTarget:i[t]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:r,oldTarget:i,fireCanvas:n,e:s}=e,a=tr(e,n3),{targetIn:o,targetOut:l,canvasIn:h,canvasOut:c}=st[t],u=i!==r;if(i&&u){let t=te(te({},a),{},{e:s,target:i,nextTarget:r},n6(this,s));n&&this.fire(c,t),i.fire(l,t)}if(r&&u){let t=te(te({},a),{},{e:s,target:r,previousTarget:i},n6(this,s));n&&this.fire(h,t),r.fire(o,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?eJ(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,a=!!n&&n(t,e,r.x,r.y);a&&s.setCoords(),"drag"===i&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let r=e.hoverCursor||this.hoverCursor,i=eE(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=eE(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 tZ(e,r),a=s.add(new tZ(i,n)),o=s.min(a),l=s.max(a).subtract(o),h=this.collectObjects({left:o.x,top:o.y,width:l.x,height:l.y},{includeIntersecting:!this.selectionFullyContained}),c=s.eq(a)?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]:{}),$(this,"_isClick",void 0),$(this,"textEditingManager",new n4(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(n8,"add")}}let sr={x1:0,y1:0,x2:0,y2:0},si=te(te({},sr),{},{r1:0,r2:0}),sn=(t,e)=>isNaN(t)&&"number"==typeof e?e:t,ss=/^(\d+\.\d+)%|(\d+)%$/;function sa(t){return t&&ss.test(t)}function so(t,e){return rV(0,sn("number"==typeof t?t:"string"==typeof t?parseFloat(t)/(sa(t)?100:1):NaN,e),1)}let sl=/\s*;\s*/,sh=/\s*:\s*/;function sc(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function su(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function sd(t,e){return t.getAttribute(e)}class sf{addColorStop(t){for(let e in t){let r=new ra(t[e]);this.colorStops.push({offset:parseFloat(e),color:r.toRgb(),opacity:r.getAlpha()})}return this}toObject(t){return te(te({},ew(this,t)),{},{type:this.type,coords:te({},this.coords),colorStops:this.colorStops.map(t=>te({},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():tw.concat(),n="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",s=this.colorStops.map(t=>te({},t)).sort((t,e)=>t.offset-e.offset),a=-this.offsetX,o=-this.offsetY;"objectBoundingBox"===n?(a/=t.width,o/=t.height):(a+=t.width/2,o+=t.height/2),t&&"function"==typeof t._renderPathCommands&&"percentage"!==this.gradientUnits&&(a-=t.pathOffset.x,o-=t.pathOffset.y),i[4]-=a,i[5]-=o;let l=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(eT(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:a,r2:o}=this.coords,h=a>o;r.push("<radialGradient ",l,' cx="',h?t:i,'" cy="',h?e:n,'" r="',h?a:o,'" fx="',h?i:t,'" fy="',h?n:e,'">\n'),h&&(s.reverse(),s.forEach(t=>{t.offset=1-t.offset}));let c=Math.min(a,o);if(c>0){let t=c/Math.max(a,o);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:a}=this.coords,o="linear"===this.type?t.createLinearGradient(e,r,i,n):t.createRadialGradient(e,r,s,i,n,a);return this.colorStops.forEach(t=>{let{color:e,opacity:r,offset:i}=t;o.addColorStop(i,void 0!==r?new ra(e).setAlpha(r).toRgba():e)}),o}static async fromObject(t){let{colorStops:e,gradientTransform:r}=t;return new this(te(te({},t),{},{colorStops:e?e.map(t=>te({},t)):void 0,gradientTransform:r?[...r]:void 0}))}static fromElement(t,e,r){var i;let n=su(t),s=e._findCenterFromElement();return new this(te({id:t.getAttribute("id")||void 0,type:sc(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,a)=>{let o=t[a];return"Infinity"===o?r=1:"-Infinity"===o?r=0:(r="string"==typeof o?parseFloat(o):o,"string"==typeof o&&sa(o)&&(r*=.01,"pixels"===s&&("x1"!==a&&"x2"!==a&&"r2"!==a||(r*=i),"y1"!==a&&"y2"!==a||(r*=n)))),e[a]=r,e},{})}("linear"===sc(t)?{x1:sd(t,"x1")||0,y1:sd(t,"y1")||0,x2:sd(t,"x2")||"100%",y2:sd(t,"y2")||0}:{x1:sd(t,"fx")||sd(t,"cx")||"50%",y1:sd(t,"fy")||sd(t,"cy")||"50%",r1:0,x2:sd(t,"cx")||"50%",y2:sd(t,"cy")||"50%",r2:sd(t,"r")||"50%"},te(te({},i),{},{gradientUnits:su(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(sl);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){let[n,s]=t[e].split(sh).map(t=>t.trim());"stop-color"===n?r=s:"stop-opacity"===n&&(i=s)}}let s=new ra(r||t.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:so(t.getAttribute("offset"),0),color:s.toRgb(),opacity:sn(parseFloat(i||t.getAttribute("stop-opacity")||""),1)*s.getAlpha()*e}}(i[t],n));return r}(t,r.opacity),gradientUnits:n,gradientTransform:nl(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:a=0,gradientTransform:o,id:l}=t||{};Object.assign(this,{type:e,gradientUnits:r,coords:te(te({},"radial"===e?si:sr),i),colorStops:n,offsetX:s,offsetY:a,gradientTransform:o,id:l?"".concat(l,"_").concat(t9()):t9()})}}$(sf,"type","Gradient"),tY.setClass(sf,"gradient"),tY.setClass(sf,"linear"),tY.setClass(sf,"radial");let sg=["type","source","patternTransform"];class sp{get type(){return"pattern"}set type(t){ta("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 te(te({},ew(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:r,offsetX:eS(this.offsetX,ts.NUM_FRACTION_DIGITS),offsetY:eS(this.offsetY,ts.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:r}=t,{source:i,repeat:n,id:s}=this,a=sn(this.offsetX/e,0),o=sn(this.offsetY/r,0),l="repeat-y"===n||"no-repeat"===n?1+Math.abs(a||0):sn(i.width/e,0),h="repeat-x"===n||"no-repeat"===n?1+Math.abs(o||0):sn(i.height/r,0);return['<pattern id="SVGID_'.concat(s,'" x="').concat(a,'" y="').concat(o,'" 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=tr(t,sg),a=await ex(i,te(te({},e),{},{crossOrigin:s.crossOrigin}));return new this(te(te({},s),{},{patternTransform:n&&n.slice(0),source:a}))}constructor(t){$(this,"repeat","repeat"),$(this,"offsetX",0),$(this,"offsetY",0),$(this,"crossOrigin",""),this.id=t9(),Object.assign(this,t)}}$(sp,"type","Pattern"),tY.setClass(sp),tY.setClass(sp,"pattern");class sm{_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 ra(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){$(this,"color","rgb(0, 0, 0)"),$(this,"width",1),$(this,"shadow",null),$(this,"strokeLineCap","round"),$(this,"strokeLineJoin","round"),$(this,"strokeMiterLimit",10),$(this,"strokeDashArray",null),$(this,"limitedToCanvasSize",!1),this.canvas=t}}let sv=["path","left","top"],sy=["d"];class sx extends iU{_setPath(t,e){this.path=nB(Array.isArray(t)?t:nZ(t)),this.setBoundingBox(e)}_findCenterFromElement(){let t=this._calcBoundsFromPath();return new tZ(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 te(te({},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=n0(this.path,ts.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,'" stroke-linecap="round" />\n')]}_getOffsetTransform(){let t=ts.NUM_FRACTION_DIGITS;return" translate(".concat(eS(-this.pathOffset.x,t),", ").concat(eS(-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,tC,tC)}_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(...nR(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(...nR(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 eX(t)}_calcDimensions(){let t=this._calcBoundsFromPath();return te(te({},t),{},{pathOffset:new tZ(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=nc(t,this.ATTRIBUTE_NAMES,r),{d:n}=i;return new this(n,te(te(te({},tr(i,sy)),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=tr(e,sv);super(),Object.assign(this,sx.ownDefaults),this.setOptions(s),this._setPath(t||[],!0),"number"==typeof i&&this.set(tS,i),"number"==typeof n&&this.set("top",n)}}$(sx,"type","Path"),$(sx,"cacheProperties",[...rY,"path","fillRule"]),$(sx,"ATTRIBUTE_NAMES",[...i5,"d"]),tY.setClass(sx),tY.setSVGClass(sx);class sb extends sm{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=sb.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++)sb.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 n$(t,this.width/1e3)}createPath(t){let e=new sx(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 rX(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"===n0(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),$(this,"decimate",.4),$(this,"drawStraightLine",!1),$(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}}let s_=["left","top","radius"],sw=["radius","startAngle","endAngle","counterClockwise"];class sC extends iU{static getDefaults(){return te(te({},super.getDefaults()),sC.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,er(this.startAngle),er(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(tB)}getRadiusY(){return this.get("radius")*this.get(tN)}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([...sw,...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=er(this.startAngle),i=er(this.endAngle),n=tQ(r)*e,s=tJ(r)*e,a=tQ(i)*e,o=tJ(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(a," ").concat(o,'" '),"COMMON_PARTS"," />\n"]}}static async fromElement(t,e,r){let i=nc(t,this.ATTRIBUTE_NAMES,r),{left:n=0,top:s=0,radius:a=0}=i;return new this(te(te({},tr(i,s_)),{},{radius:a,left:n-a,top:s-a}))}static fromObject(t){return super._fromObject(t)}constructor(t){super(),Object.assign(this,sC.ownDefaults),this.setOptions(t)}}$(sC,"type","Circle"),$(sC,"cacheProperties",[...rY,...sw]),$(sC,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),$(sC,"ATTRIBUTE_NAMES",["cx","cy","r",...i5]),tY.setClass(sC),tY.setSVGClass(sC);let sS=["x1","y1","x2","y2"],sT=["x1","y1","x2","y2"],sO=["x1","x2","y1","y2"];class sk extends iU{_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:a,height:o}=eX([{x:t,y:e},{x:r,y:i}]),l=new tZ(n+a/2,s+o/2);this.setPositionByOrigin(l,tC,tC)}_set(t,e){return super._set(t,e),sO.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;eO(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 tZ((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return te(te({},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,a=t<=e?-1:1,o=r<=i?-1:1;return{x1:a*n/2,x2:-(a*n)/2,y1:o*s/2,y2:-(o*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=nc(t,this.ATTRIBUTE_NAMES,r),{x1:n=0,y1:s=0,x2:a=0,y2:o=0}=i;return new this([n,s,a,o],tr(i,sS))}static fromObject(t){let{x1:e,y1:r,x2:i,y2:n}=t,s=tr(t,sT);return this._fromObject(te(te({},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,sk.ownDefaults),this.setOptions(n),this.x1=t,this.x2=r,this.y1=e,this.y2=i,this._setWidthHeight();let{left:s,top:a}=n;"number"==typeof s&&this.set(tS,s),"number"==typeof a&&this.set("top",a)}}$(sk,"type","Line"),$(sk,"cacheProperties",[...rY,...sO]),$(sk,"ATTRIBUTE_NAMES",i5.concat(sO)),tY.setClass(sk),tY.setSVGClass(sk);class sM extends iU{static getDefaults(){return te(te({},super.getDefaults()),sM.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,sM.ownDefaults),this.setOptions(t)}}$(sM,"type","Triangle"),$(sM,"ownDefaults",{width:100,height:100}),tY.setClass(sM),tY.setSVGClass(sM);let sE=["rx","ry"];class sD extends iU{static getDefaults(){return te(te({},super.getDefaults()),sD.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(tB)}getRy(){return this.get("ry")*this.get(tN)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...sE,...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,tb,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,r){let i=nc(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,sD.ownDefaults),this.setOptions(t)}}$(sD,"type","Ellipse"),$(sD,"cacheProperties",[...rY,...sE]),$(sD,"ownDefaults",{rx:0,ry:0}),$(sD,"ATTRIBUTE_NAMES",[...i5,"cx","cy","rx","ry"]),tY.setClass(sD),tY.setSVGClass(sD);let sj=["left","top"],sA={exactBoundingBox:!1};class sP extends iU{static getDefaults(){return te(te({},super.getDefaults()),sP.ownDefaults)}isOpen(){return!0}_projectStrokeOnPoints(t){return iG(this.points,t,this.isOpen())}_calcDimensions(t){t=te({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 tZ,strokeOffset:new tZ,strokeDiff:new tZ};let r=eX(e),i=ev(te(te({},t),{},{scaleX:1,scaleY:1})),n=eX(this.points.map(t=>es(t,i,!0))),s=new tZ(this.scaleX,this.scaleY),a=r.left+r.width/2,o=r.top+r.height/2;return this.exactBoundingBox&&(a-=o*Math.tan(er(this.skewX)),o-=a*Math.tan(er(this.skewY))),te(te({},r),{},{pathOffset:new tZ(a,o),strokeOffset:new tZ(n.left,n.top).subtract(new tZ(r.left,r.top)).multiply(s),strokeDiff:new tZ(r.width,r.height).subtract(new tZ(n.width,n.height)).multiply(s)})}_findCenterFromElement(){let t=eX(this.points);return new tZ(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:a,strokeDiff:o}=this._calcDimensions();this.set({width:i,height:n,pathOffset:s,strokeOffset:a,strokeDiff:o}),t&&this.setPositionByOrigin(new tZ(e+i/2,r+n/2),tC,tC)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new tZ(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 tZ(null!=(e=t.width)?e:i,null!=(r=t.height)?r:n)}else s=new tZ(null!=(i=t.width)?i:this.width,null!=(n=t.height)?n:this.height);return s.multiply(new tZ(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===tB||t===tN)&&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 te(te({},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=ts.NUM_FRACTION_DIGITS;for(let n=0,s=this.points.length;n<s;n++)t.push(eS(this.points[n].x-e,i),",",eS(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")),te(te({},tr(nc(t,this.ATTRIBUTE_NAMES,r),sj)),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(),$(this,"strokeDiff",void 0),Object.assign(this,sP.ownDefaults),this.setOptions(e),this.points=t;let{left:r,top:i}=e;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof r&&this.set(tS,r),"number"==typeof i&&this.set("top",i)}}$(sP,"ownDefaults",sA),$(sP,"type","Polyline"),$(sP,"layoutProperties",[tW,tU,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),$(sP,"cacheProperties",[...rY,"points"]),$(sP,"ATTRIBUTE_NAMES",[...i5]),tY.setClass(sP),tY.setSVGClass(sP);class sF extends sP{isOpen(){return!1}}$(sF,"ownDefaults",sA),$(sF,"type","Polygon"),tY.setClass(sF),tY.setSVGClass(sF);class sL extends iU{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,a=0;for(let a in e){for(let o in r=0,e[a]){let l=e[a][o]||{};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[a][o]}0===r&&delete e[a]}for(let t=0;t<this._textLines.length;t++)a+=this._textLines[t].length;s&&n===a&&(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=eC(te(te({},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 te(te({},ew(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]}}$(sL,"_styleProperties",rv);let sR=/ +/g,sI=/"/g;function sB(t,e,r,i,n){return" ".concat(function(t,e){let{left:r,top:i,width:n,height:s}=e,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ts.NUM_FRACTION_DIGITS,o=rh(tH,t,!1),[l,h,c,u]=[r,i,n,s].map(t=>eS(t,a));return"<rect ".concat(o,' x="').concat(l,'" y="').concat(h,'" width="').concat(c,'" height="').concat(u,'"></rect>')}(t,{left:e,top:r,width:i,height:n}),"\n")}let sN=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];class sW extends sL{static getDefaults(){return te(te({},super.getDefaults()),sW.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(ry)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,r,i,n,s,a;for(let o=0,l=this._textLines.length;o<l;o++)if((this.textAlign===ry||o!==l-1&&!this.isEndOfWrapping(o))&&(i=0,n=this._textLines[o],(e=this.getLineWidth(o))<this.width&&(a=this.textLines[o].match(this._reSpacesAndTabs)))){r=a.length,t=(this.width-e)/r;for(let e=0;e<=n.length;e++)s=this.__charBounds[o][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===tX?(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 tC:t.textBaseline="middle";break;case"ascender":t.textBaseline="top";break;case"descender":t.textBaseline=tT}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,a=this._getLineLeftOffset(e),o,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?(o=r+a+c,"rtl"===this.direction&&(o=this.width-o-h),t.fillStyle=u,u&&t.fillRect(o,i,h,n/this.lineHeight),c=s.left,h=s.width,u=l):h+=s.kernedWidth}l&&!this.path&&(o=r+a+c,"rtl"===this.direction&&(o=this.width-o-h),t.fillStyle=l,t.fillRect(o,i,h,n/this.lineHeight)),i+=n}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,r,n){let s,a,o,l,h=tm.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]&&(o=h[r]),void 0!==h[t]&&(l=s=h[t]),d&&void 0!==h[u]&&(l=(a=h[u])-o),void 0===s||void 0===o||void 0===a){let n=(i||(i=t7({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===o&&d&&r&&(o=n.measureText(r).width,h[r]=o),d&&void 0===a&&(a=n.measureText(u).width,h[u]=a,l=a-o)}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===tO,s=this.path,a=this._textLines[t],o=a.length,l=Array(o);this.__charBounds[t]=l;for(let n=0;n<o;n++){let s=a[n];r=this._getGraphemeBox(s,t,n,e),l[n]=r,i+=r.kernedWidth,e=s}if(l[o]={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 tS:t=n?e-i:0;break;case tC:t=(e-i)/2;break;case tO:t=n?0:e-i}t+=this.pathStartOffset*(n?-1:1);for(let i=n?o-1:0;n?i>=0:i<o;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=nG(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===tO?Math.PI:0)}_getGraphemeBox(t,e,r,i,n){let s=this.getCompleteStyleDeclaration(e,r),a=i?this.getCompleteStyleDeclaration(e,r-1):{},o=this._measureChar(t,s,i,a),l,h=o.kernedWidth,c=o.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+o.kernedWidth-o.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,a=this._textLines.length;s<a;s++){let a=this.getHeightOfLine(s),o=a/this.lineHeight,l=this._getLineLeftOffset(s);this._renderTextLine(e,t,this._textLines[s],i+l,n+r+o,s),r+=a}t.restore()}_renderTextFill(t){(this.fill||this.styleHas(tH))&&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 a=this.getHeightOfLine(s),o=this.textAlign.includes(ry),l=this.path,h=!o&&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?tS:tO),n-=a*this._fontSizeFraction/this.lineHeight,h)return this._renderChar(t,e,s,0,r.join(""),i,n),void e.restore();for(let a=0,h=r.length-1;a<=h;a++)m=a===h||this.charSpacing||l,x+=r[a],p=this.__charBounds[s][a],0===b?(i+=u*(p.kernedWidth-p.width),b+=p.width):b+=p.kernedWidth,o&&!m&&this._reSpaceAndTab.test(r[a])&&(m=!0),m||(m=i0(f=f||this.getCompleteStyleDeclaration(s,a),g=this.getCompleteStyleDeclaration(s,a+1),!1)),m&&(l?(e.save(),e.translate(p.renderLeft,p.renderTop),e.rotate(p.angle),this._renderChar(t,e,s,a,x,-b/2,0),e.restore()):(y=i,this._renderChar(t,e,s,a,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=t7({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 eO(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,a){let o=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),o.textBackgroundColor&&this._removeShadow(e),o.deltaY&&(a+=o.deltaY),h){let t=this._setFillStyles(e,l);e.fillText(n,s-t.offsetX,a-t.offsetY)}if(c){let t=this._setStrokeStyles(e,l);e.strokeText(n,s-t.offsetX,a-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"),a={fontSize:n*r.size,deltaY:s+n*r.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){let e=this.getLineWidth(t),r=this.width-e,i=this.textAlign,n=this.direction,s=this.isEndOfWrapping(t),a=0;return i!==ry&&(i!==r_||s)&&(i!==rb||s)&&(i!==rx||s)?(i===tC&&(a=r/2),i===tO&&(a=r),i===r_&&(a=r/2),i===rb&&(a=r),"rtl"===n&&(i===tO||i===ry||i===rb?a=0:i===tS||i===rx?a=-r:i!==tC&&i!==r_||(a=-r/2)),a):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(),a="linethrough"===e?.5:+("overline"===e),o=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,tH),y=this.getValueOfPropertyAt(l,0,rd),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,tH),_=this.getValueOfPropertyAt(l,r,rd);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,o*h+c-a*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+o*C+S-a*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+o*C+S-a*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(",")||sW.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 iQ(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 te(te({},super.toObject([...rm,...t])),{},{styles:i1(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=nc(t,sW.ATTRIBUTE_NAMES,r),n=te(te({},e),i),{textAnchor:s=tS,textDecoration:a="",dx:o=0,dy:l=0,top:h=0,left:c=0,fontSize:u=16,strokeWidth:d=1}=n,f=tr(n,sN),g=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),te({left:c+o,top:h+l,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.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===tC&&(x=g.getScaledWidth()/2),s===tO&&(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(te(te({},t),{},{styles:i2(t.styles||{},t.text)}),{extraParam:"text"})}constructor(t,e){super(),$(this,"__charBounds",[]),Object.assign(this,sW.ownDefaults),this.setOptions(e),this.styles||(this.styles={}),this.text=t,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}}$(sW,"textLayoutProperties",rp),$(sW,"cacheProperties",[...rY,...rm]),$(sW,"ownDefaults",{_reNewline:tM,_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:tS,fontStyle:"normal",lineHeight:1.16,textBackgroundColor:"",stroke:null,shadow:null,path:void 0,pathStartOffset:0,pathSide:tS,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,[rd]:66.667}),$(sW,"type","Text"),$(sW,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),$(sW,"ATTRIBUTE_NAMES",i5.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),iW(sW,[class extends rc{_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:eT(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(sI,"'"),'" '),'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(...sB(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let t=0,a=this._textLines.length;t<a;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=ts.NUM_FRACTION_DIGITS,a=this.getSvgSpanStyles(e,t!==t.trim()||!!t.match(sR)),o=e.deltaY,l=o?' dy="'.concat(eS(o,s),'" '):"",{angle:h,renderLeft:c,renderTop:u,width:d}=n,f="";if(void 0!==c){h&&(f=' rotate="'.concat(eS(ei(h),s),'"'));let t=ed({angle:ei(h)});t[4]=c,t[5]=u;let e=new tZ(-(d/2),0).transform(t);r=e.x,i=e.y}return'<tspan x="'.concat(eS(r,s),'" y="').concat(eS(i,s),'" ').concat(l).concat(f).concat(a?'style="'.concat(a,'"'):"",">").concat(iK(t),"</tspan>")}_setSVGTextLineText(t,e,r,i){let n=this.getHeightOfLine(e),s=this.textAlign.includes(ry),a=this._textLines[e],o,l,h,c,u,d="",f=0;i+=n*(1-this._fontSizeFraction)/this.lineHeight;for(let n=0,g=a.length-1;n<=g;n++)u=n===g||this.charSpacing||this.path,d+=a[n],h=this.__charBounds[e][n],0===f?(r+=h.kernedWidth-h.width,f+=h.width):f+=h.kernedWidth,s&&!u&&this._reSpaceAndTab.test(a[n])&&(u=!0),u||(u=i0(o=o||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="",o=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,a,o=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];(a=this.getValueOfPropertyAt(e,c,"textBackgroundColor"))!==h?(h&&t.push(...sB(h,r+l,i,o,s)),l=n,o=u,h=a):o+=d}a&&t.push(...sB(h,r+l,i,o,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(eS(this.textDecorationThickness*this.getObjectScaling().y/10,ts.NUM_FRACTION_DIGITS),"%; white-space: pre;")}getSvgSpanStyles(t,e){let{fontFamily:r,strokeWidth:i,stroke:n,fill:s,fontSize:a,fontStyle:o,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?rh(tX,n):"",i?"stroke-width: ".concat(i,"; "):"",r?"font-family: ".concat(r.includes("'")||r.includes('"')?r:"'".concat(r,"'"),"; "):"",a?"font-size: ".concat(a,"px; "):"",o?"font-style: ".concat(o,"; "):"",l?"font-weight: ".concat(l,"; "):"",g?"text-decoration: ".concat(g,"; text-decoration-thickness: ").concat(eS(p*this.getObjectScaling().y/10,ts.NUM_FRACTION_DIGITS),"%; "):"",s?rh(tH,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(sW),tY.setSVGClass(sW);class sU{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,a=s.canvas,o=new tZ(s.flipX?-1:1,s.flipY?-1:1),l=s._getCursorBoundaries(i),h=new tZ(l.left+l.leftOffset,l.top+l.topOffset).multiply(o).transform(s.calcTransformMatrix()),c=a.getScenePoint(t).subtract(h),u=s.getCanvasRetinaScaling(),d=s.getBoundingRect(),f=h.subtract(new tZ(d.left,d.top)),g=a.viewportTransform,p=f.add(c).transform(g,!0),m=s.backgroundColor,y=iq(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:a.enableRetinaScaling,viewportTransform:!0});s.backgroundColor=m,s.styles=y,s.dirty=!0,n1(b,{position:"fixed",left:"".concat(-b.width,"px"),border:tk,width:"".concat(b.width/u,"px"),height:"".concat(b.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{b.remove()},ej(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=te({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:a}=r.dataTransfer.types.includes("application/fabric")?JSON.parse(r.dataTransfer.getData("application/fabric")):{},o=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(o)&&(e._reNewline.test(e._text[s])||s===e._text.length)&&(n=n.trimEnd()),t.didDrop=!0,t.dropTarget=e,e.insertChars(n,a,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(tR,{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,a=(null==(r=e.dataTransfer)?void 0:r.dropEffect)||tk;a===tk?(t.selectionStart=n,t.selectionEnd=s,t._updateTextarea(),t.hiddenTextarea.focus()):(t.clearContextTop(),"move"===a&&(t.removeChars(n,s),t.selectionStart=t.selectionEnd=n,t.hiddenTextarea&&(t.hiddenTextarea.value=t.text),t._updateTextarea(),t.fire(tR,{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){$(this,"target",void 0),$(this,"__mouseDownInPlace",!1),$(this,"__dragStartFired",!1),$(this,"__isDraggingOver",!1),$(this,"__dragStartSelection",void 0),$(this,"__dragImageDisposer",void 0),$(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 sH=/[ \n\.,;!\?\-]/;class sX extends sW{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 r7({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||!tM.test(r[t-1]))?t-1:t,n=r[i];for(;i>0&&i<r.length&&!sH.test(n);)i+=e,n=r[i];return -1===e&&sH.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;ej(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,a=e.leftOffset,o=this.getCanvasRetinaScaling(),l=this.canvas.upperCanvasEl,h=l.width/o,c=l.height/o,u=h-s,d=c-s,f=new tZ(e.left+a,e.top+e.topOffset+s).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new tZ(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(tV),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,a=s===e,o=!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&&(o=!0,n[i-e]=this.styles[t][r],a&&0===e||delete this.styles[t][r])}let h=!1;for(o&&!a&&(this.styles[t+r]=n,h=!0),(h||s>e)&&r--;r>0;)i&&i[r-1]?this.styles[t+r]={0:te({},i[r-1])}:l?this.styles[t+r]={0:te({},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?te({},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]=te({},i[r]));return}if(!n)return;let a=n[e?e-1:1];for(;a&&r--;)this.styles[t][e+r]=te({},a)}insertNewStyleBlock(t,e,r){let i=this.get2DCursorLocation(e,!0),n=[0],s,a=0;for(let e=0;e<t.length;e++)"\n"===t[e]?n[++a]=0:n[a]++;for(n[0]>0&&(this.insertCharStyleObject(i.lineIndex,i.charIndex,n[0],r),r=r&&r.slice(n[0]+1)),a&&this.insertNewlineStyleObject(i.lineIndex,i.charIndex+n[0],a),s=1;s<a;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=tS:this._selectionDirection===tO&&(this._selectionDirection=tS,this.selectionEnd=t),this.selectionStart=r):r>t&&r<e?this._selectionDirection===tO?this.selectionEnd=r:this.selectionStart=r:(e===t?this._selectionDirection=tO:this._selectionDirection===tS&&(this._selectionDirection=tO,this.selectionStart=e),this.selectionEnd=r)}constructor(){super(...arguments),$(this,"_currentCursorOpacity",1)}}class sV extends sX{initHiddenTextarea(){let t=this.canvas&&ej(this.canvas.getElement())||tf(),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(tR),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void s();let a=this._splitTextIntoLines(r).graphemeText,o=this._text.length,l=a.length,h=this.selectionStart,c=this.selectionEnd,u=h!==c,d,f,g,p,m=l-o,y=this.fromStringToGraphemeSelection(i,n,r),x=h>y.selectionStart;u?(f=this._text.slice(h,c),m+=c-h):l<o&&(f=x?this._text.slice(c+m,c):this._text.slice(h,h-m));let b=a.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}=td();e&&b.join("")===t.copiedText&&!ts.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}=td();t.copiedText=this.getSelectedText(),ts.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,a=this._getWidthBeforeCursor(n,s),o=this._getIndexOnLine(n+1,a);return this._textLines[n].slice(s).length+o+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,a=this._getWidthBeforeCursor(n,s),o=this._getIndexOnLine(n-1,a),l=this._textLines[n].slice(0,s),h=this.missingNewlineOffset(n-1);return-this._textLines[n-1].length+o-l.length+(1-h)}_getIndexOnLine(t,e){let r=this._textLines[t],i,n,s=this._getLineLeftOffset(t),a=0;for(let o=0,l=r.length;o<l;o++)if((s+=i=this.__charBounds[t][o].width)>e){n=!0;let t=Math.abs(s-i-e);a=Math.abs(s-e)<t?o:o-1;break}return n||(a=r.length-1),a}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===tO);if(e.shiftKey?this.moveCursorWithShift(r):this.moveCursorWithoutShift(r),0!==r){let t=this.text.length;this.selectionStart=rV(0,this.selectionStart,t),this.selectionEnd=rV(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){let e=this._selectionDirection===tS?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=tS,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===tO&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection=tS,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===tS&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=tO,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=tO,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}class sz extends sV{initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("mousetripleclick",this.tripleClickHandler),this.draggableTextDelegate=new sU(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(ea(this.calcTransformMatrix())).add(new tZ(-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)),a=this._textLines[n].length,o=this.__charBounds[n];for(let t=0;t<a;t++){let r=s+o[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?a-i:i,this._text.length)}constructor(){super(...arguments),$(this,"draggableTextDelegate",void 0)}}let sY="moveCursorUp",sG="moveCursorDown",sq="moveCursorLeft",sK="moveCursorRight",sQ="exitEditing",sJ=(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])},sZ=te({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:sQ,27:sQ,33:sY,34:sG,35:sK,36:sq,37:sq,38:sY,39:sK,40:sG},keysMapRtl:{9:sQ,27:sQ,33:sY,34:sG,35:sq,36:sK,37:sK,38:sY,39:sq,40:sG},ctrlKeysMapDown:{65:"cmdAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class s$ extends sz{static getDefaults(){return te(te({},super.getDefaults()),s$.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 se&&this.canvas.textEditingManager.remove(this),e instanceof se&&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){sJ(s=(n=t7(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=t7(t.canvas),n=i.getContext("2d");if(sJ(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),a=this.__charBounds[n][i];a&&(r=a.left),0!==this.charSpacing&&i===this._textLines[n].length&&(r-=this._getWidthOfCharSpacing());let o={top:e,left:s+(r>0?r:0)};return"rtl"===this.direction&&(this.textAlign===tO||this.textAlign===ry||this.textAlign===rb?o.left*=-1:this.textAlign===tS||this.textAlign===rx?o.left=s-(r>0?r:0):this.textAlign!==tC&&this.textAlign!==r_||(o.left=s-(r>0?r:0))),o}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"),a=this.getObjectScaling().x*this.canvas.getZoom(),o=this.cursorWidth/a,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-o/2,top:h+e.top+l,width:o,height:s}}_renderCursor(t,e,r){let{color:i,opacity:n,left:s,top:a,width:o,height:l}=this.getCursorRenderingData(r,e);t.fillStyle=i,t.globalAlpha=n,t.fillRect(s,a,o,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(ry),a=this.get2DCursorLocation(i),o=this.get2DCursorLocation(n),l=a.lineIndex,h=o.lineIndex,c=a.charIndex<0?0:a.charIndex,u=o.charIndex<0?0:o.charIndex;for(let e=l;e<=h;e++){let i=this._getLineLeftOffset(e)||0,n=this.getHeightOfLine(e),a=0,o=0,d=0;if(e===l&&(o=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}a=n,(this.lineHeight<1||e===h&&this.lineHeight>1)&&(n/=this.lineHeight);let f=r.left+i+o,g=n,p=0,m=d-o;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",g=1,p=n):t.fillStyle=this.selectionColor,"rtl"===this.direction&&(this.textAlign===tO||this.textAlign===ry||this.textAlign===rb?f=this.width-f-m:this.textAlign===tS||this.textAlign===rx?f=r.left+i-d:this.textAlign!==tC&&this.textAlign!==r_||(f=r.left+i-d)),t.fillRect(f,r.top+r.topOffset+p,m,g),r.topOffset+=a}}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,tH)}_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,te(te({},s$.ownDefaults),e)),this.initBehavior()}}$(s$,"ownDefaults",sZ),$(s$,"type","IText"),tY.setClass(s$),tY.setClass(s$,"i-text");class s0 extends s${static getDefaults(){return te(te({},super.getDefaults()),s0.ownDefaults)}static createControls(){return{controls:iB()}}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(ry)&&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 a=void 0===t?this.styles:{line:this.styles[t]};for(let t in a)for(let n in a[t]){let s=parseInt(n,10);if(s>=r&&(!i||s<e))for(let e in a[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,a=e?this.graphemeSplit(t):this.wordSplit(t);return 0===a.length?[{word:[],width:0}]:a.map(t=>{let a=e?[t]:this.graphemeSplit(t),o=this._measureWord(a,n,s);return i=Math.max(o,i),s+=a.length+r.length,{word:a,width:o}})}),largestWordWidth:i}}_measureWord(t,e){let r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=0;for(let s=0,a=t.length;s<a;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,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,h=[],c=l?"":" ",u=0,d=[],f=0,g=0,p=!0,m=Math.max(e-=a,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-o)>m&&!p?(h.push(d),d=[],u=r,p=!0):u+=o,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+a>this.dynamicMinWidth&&(this.dynamicMinWidth=n-o+a),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,te(te({},s0.ownDefaults),e))}}$(s0,"type","Textbox"),$(s0,"textLayoutProperties",[...s$.textLayoutProperties,"width"]),$(s0,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),tY.setClass(s0);class s1 extends nx{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:a}=eX(ny(r,i)),o=new tZ(s,a);if(i.absolutePositioned)return{center:eJ(i.getRelativeCenterPoint(),void 0,n?n.calcTransformMatrix():void 0),size:o};{let n=i.getRelativeCenterPoint().transform(r.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){let{center:r=new tZ,correction:i=new tZ}=this.calcBoundingBox(e,t)||{};return{center:r.add(n),correction:i.subtract(n),size:o}}return{center:r.getRelativeCenterPoint().add(n),size:o}}}}$(s1,"type","clip-path"),tY.setClass(s1);class s2 extends nx{getInitialSize(t,e){let{target:r}=t,{size:i}=e;return new tZ(r.width||i.x,r.height||i.y)}}$(s2,"type","fixed"),tY.setClass(s2);class s5 extends nS{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 s4 extends nk{static getDefaults(){return te(te({},super.getDefaults()),s4.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))?(ta("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===nm?r.forEach(t=>{t._onAfterObjectsChange(np,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=te(te({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,s4.ownDefaults),this.setOptions(e);let{left:r,top:i,layoutManager:n}=e;this.groupInit(t,{left:r,top:i,layoutManager:null!=n?n:new s5})}}$(s4,"type","ActiveSelection"),$(s4,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),tY.setClass(s4),tY.setClass(s4,"activeSelection");class s3{applyFilters(t,e,r,i,n){let s=n.getContext("2d");if(!s)return;s.drawImage(e,0,0,r,i);let a={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(a)});let{imageData:o}=a;return o.width===r&&o.height===i||(n.width=o.width,n.height=o.height),s.putImageData(o,0,0),a}constructor(){$(this,"resources",{})}}class s9{setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){let r=t7({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 a,o=this.gl,l=n.getContext("2d");if(!o||!l)return;s&&(a=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:o,sourceTexture:this.createTexture(o,r,i,a?void 0:e),targetTexture:this.createTexture(o,r,i),originalTexture:a||this.createTexture(o,r,i,a?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:n},c=o.createFramebuffer();return o.bindFramebuffer(o.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(o,h),o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(h.sourceTexture),o.deleteTexture(h.targetTexture),o.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:a,RGBA:o,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(a,g),t.texParameteri(a,c,n||s),t.texParameteri(a,u,n||s),t.texParameteri(a,d,h),t.texParameteri(a,f,h),i?t.texImage2D(a,0,o,o,l,i):t.texImage2D(a,0,o,e,r,0,o,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 a=new Uint8Array(this.imageBuffer,0,s),o=new Uint8ClampedArray(this.imageBuffer,0,s);t.readPixels(0,0,i,n,t.RGBA,t.UNSIGNED_BYTE,a);let l=new ImageData(o,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=ts.textureSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};$(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),$(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}}function s6(){return n||arguments.length>0&&void 0!==arguments[0]&&!arguments[0]||(n=function(){let{WebGLProbe:t}=td();return t.queryWebGL(t6()),ts.enableGLFiltering&&t.isSupported(ts.textureSize)?new s9({tileSize:ts.textureSize}):new s3}()),n}let s8=["filters","resizeFilter","src","crossOrigin","type"],s7=["cropX","cropY"];class at extends iU{static getDefaults(){return te(te({},super.getDefaults()),at.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(at.CSS_CANVAS),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){let e=s6(!1);e instanceof s9&&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&&td().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())}),te(te({},super.toObject([...s7,...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=[],a="",o="";if(!e)return[];if(this.hasCrop()){let t=t9();n.push('<clipPath id="imageCrop_'+t+'">\n',' <rect x="'+r+'" y="'+i+'" width="'+this.width+'" height="'+this.height+'" />\n',"</clipPath>\n"),a=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(o=' 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(o).concat(a,"></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!==tH?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 ex(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 a=t7(s),{width:o,height:l}=s;this._element=a,this._lastScaleX=t.scaleX=i,this._lastScaleY=t.scaleY=n,s6().applyFilters([t],s,o,l,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.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=t7({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);s6().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,a=Math.max(this.cropX,0),o=Math.max(this.cropY,0),l=e.naturalWidth||e.width,h=e.naturalHeight||e.height,c=a*r,u=o*i,d=Math.min(n*r,l-c),f=Math.min(s*i,h-u),g=Math.min(n,l/r-a),p=Math.min(s,h/i-o);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=rl(this.preserveAspectRatio||""),e=this.width,r=this.height,i={width:e,height:r},n,s=this._element.width,a=this._element.height,o=1,l=1,h=0,c=0,u=0,d=0;return t&&(t.alignX!==tk||t.alignY!==tk)?("meet"===t.meetOrSlice&&(n=(e-s*(o=l=nM(this._element,i)))/2,"Min"===t.alignX&&(h=-n),"Max"===t.alignX&&(h=n),n=(r-a*l)/2,"Min"===t.alignY&&(c=-n),"Max"===t.alignY&&(c=n)),"slice"===t.meetOrSlice&&(n=s-e/(o=l=nE(this._element,i)),"Mid"===t.alignX&&(u=n/2),"Max"===t.alignX&&(u=n),n=a-r/l,"Mid"===t.alignY&&(d=n/2),"Max"===t.alignY&&(d=n),s=e/o,a=r/l)):(o=e/s,l=r/a),{width:s,height:a,scaleX:o,scaleY:l,offsetLeft:h,offsetTop:c,cropX:u,cropY:d}}static fromObject(t,e){let{filters:r,resizeFilter:i,src:n,crossOrigin:s,type:a}=t,o=tr(t,s8);return Promise.all([ex(n,te(te({},e),{},{crossOrigin:s})),r&&eb(r,e),i&&eb([i],e),e_(o,e)]).then(t=>{let[e,r=[],[i]=[],s={}]=t;return new this(e,te(te({},o),{},{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 ex(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=nc(t,this.ATTRIBUTE_NAMES,r);return this.fromURL(i["xlink:href"]||i.href,e,i).catch(t=>(ta("log","Unable to parse Image",t),null))}constructor(t,e){super(),$(this,"_lastScaleX",1),$(this,"_lastScaleY",1),$(this,"_filterScalingX",1),$(this,"_filterScalingY",1),this.filters=[],Object.assign(this,at.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(t9()),this.setElement("string"==typeof t?(this.canvas&&ej(this.canvas.getElement())||tf()).getElementById(t):t,e)}}$(at,"type","Image"),$(at,"cacheProperties",[...rY,...s7]),$(at,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),$(at,"CSS_CANVAS","canvas-img"),$(at,"ATTRIBUTE_NAMES",[...i5,"x","y","width","height","preserveAspectRatio","xlink:href","href","crossOrigin","image-rendering"]),tY.setClass(at),tY.setSVGClass(at),ru(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);let ae=t=>function(e,r,i){let{points:n,pathOffset:s}=i;return new tZ(n[t]).subtract(s).transform(eo(i.getViewportTransform(),i.calcTransformMatrix()))},ar=(t,e,r,i)=>{let{target:n,pointIndex:s}=e,a=eJ(new tZ(r,i),void 0,n.calcOwnMatrix());return n.points[s]=a.add(n.pathOffset),n.setDimensions(),n.set("dirty",!0),!0},ai=(t,e)=>function(r,i,n,s){let a=i.target,o=new tZ(a.points[(t>0?t:a.points.length)-1]),l=o.subtract(a.pathOffset).transform(a.calcOwnMatrix()),h=e(r,te(te({},i),{},{pointIndex:t}),n,s),c=o.subtract(a.pathOffset).transform(a.calcOwnMatrix()).subtract(l);return a.left-=c.x,a.top-=c.y,h},an=t=>io(tL,ai(t,ar)),as=(t,e,r)=>{let{path:i,pathOffset:n}=t,s=i[e];return new tZ(s[r]-n.x,s[r+1]-n.y).transform(eo(t.getViewportTransform(),t.calcTransformMatrix()))};function aa(t,e,r){let{commandIndex:i,pointIndex:n}=this;return as(r,i,n)}function ao(t,e,r,i){let{target:n}=e,{commandIndex:s,pointIndex:a}=this,o=((t,e,r,i,n)=>{let{path:s,pathOffset:a}=t,o=s[(i>0?i:s.length)-1],l=new tZ(o[n],o[n+1]),h=l.subtract(a).transform(t.calcOwnMatrix()),c=eJ(new tZ(e,r),void 0,t.calcOwnMatrix());s[i][n]=c.x+a.x,s[i][n+1]=c.y+a.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,a);return e0(this.actionName,te(te({},e9(t,e,r,i)),{},{commandIndex:s,pointIndex:a})),o}class al extends id{render(t,e,r,i,n){let s=te(te({},i),{},{cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill});super.render(t,e,r,s,n)}constructor(t){super(t)}}class ah extends al{render(t,e,r,i,n){let{path:s}=n,{commandIndex:a,pointIndex:o,connectToCommandIndex:l,connectToPointIndex:h}=this;t.save(),t.strokeStyle=this.controlStroke,this.connectionDashArray&&t.setLineDash(this.connectionDashArray);let[c]=s[a],u=as(n,l,h);if("Q"===c){let i=as(n,a,o+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 ac=(t,e,r,i,n,s)=>new(r?ah:al)(te(te({commandIndex:t,pointIndex:e,actionName:"modifyPath",positionHandler:aa,actionHandler:ao,connectToCommandIndex:n,connectToPointIndex:s},i),r?i.controlPointStyle:i.pointStyle));Object.freeze({__proto__:null,changeWidth:ih,createObjectDefaultControls:iR,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)]=ac(n,t.length-2,!1,e)),s){case"C":let a;r["c_".concat(n,"_C_CP_1")]=ac(n,1,!0,e,n-1,"C"===(a=i)?5:"Q"===a?3:1),r["c_".concat(n,"_C_CP_2")]=ac(n,3,!0,e,n,5);break;case"Q":r["c_".concat(n,"_Q_CP_1")]=ac(n,1,!0,e,n,3)}i=s}),r},createPolyActionHandler:an,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 id(te({actionName:tL,positionHandler:ae(i),actionHandler:an(i)},e));return r},createPolyPositionHandler:ae,createResizeControls:iI,createTextboxDefaultControls:iB,dragHandler:e7,factoryPolyActionHandler:ai,getLocalPoint:e8,polyActionHandler:ar,renderCircleControl:ic,renderSquareControl:iu,rotationStyleHandler:ig,rotationWithSnapping:ip,scaleCursorStyleHandler:ix,scaleOrSkewActionName:iA,scaleSkewCursorStyleHandler:iP,scalingEqually:i_,scalingX:iw,scalingXOrSkewingY:iF,scalingY:iC,scalingYOrSkewingX:iL,skewCursorStyleHandler:ik,skewHandlerX:iE,skewHandlerY:iD,wrapWithFireEvent:io,wrapWithFixedAnchor:il});let au="precision highp float",ad="\n ".concat(au,";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }"),af=["type"],ag=["type"],ap=RegExp(au,"g");class am{get type(){return this.constructor.type}getFragmentSource(){return ad}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"}}=td();"highp"!==i&&(e=e.replace(ap,au.replace("highp",i)));let n=t.createShader(t.VERTEX_SHADER),s=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!n||!s||!a)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(a,n),t.attachShader(a,s),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new to('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(a)));let o=this.getUniformLocations(t,a)||{};return o.uStepW=t.getUniformLocation(a,"uStepW"),o.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:o}}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=t7({width:e,height:r})}}toObject(){let t=Object.keys(this.constructor.defaults||{});return te({type:this.type},t.reduce((t,e)=>(t[e]=this[e],t),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(tr(t,ag))}constructor(){let t=tr(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},af);Object.assign(this,this.constructor.defaults,t)}}$(am,"type","BaseFilter"),$(am,"uniformLocations",[]);let av={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 ay extends am{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(av[this.mode],"\n }\n }\n ")}applyTo2d(t){let{imageData:{data:e}}=t,r=new ra(this.color).getSource(),i=this.alpha,n=r[0]*i,s=r[1]*i,a=r[2]*i,o=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*a/255;break;case"screen":r=255-(255-h)*(255-n)/255,i=255-(255-c)*(255-s)/255,l=255-(255-u)*(255-a)/255;break;case"add":r=h+n,i=c+s,l=u+a;break;case"difference":r=Math.abs(h-n),i=Math.abs(c-s),l=Math.abs(u-a);break;case"subtract":r=h-n,i=c-s,l=u-a;break;case"darken":r=Math.min(h,n),i=Math.min(c,s),l=Math.min(u,a);break;case"lighten":r=Math.max(h,n),i=Math.max(c,s),l=Math.max(u,a);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=a<128?2*u*a/255:255-2*(255-u)*(255-a)/255;break;case"exclusion":r=n+h-2*n*h/255,i=s+c-2*s*c/255,l=a+u-2*a*u/255;break;case"tint":r=n+h*o,i=s+c*o,l=a+u*o}e[t]=r,e[t+1]=i,e[t+2]=l}}sendUniformData(t,e){let r=new ra(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)}}$(ay,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),$(ay,"type","BlendColor"),$(ay,"uniformLocations",["uColor"]),tY.setClass(ay);let ax={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 "},ab=["type","image"];class a_ extends am{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return ax[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=t6());let a=n.blendImage,o=a.getContext("2d");a.width!==r||a.height!==i?(a.width=r,a.height=i):o.clearRect(0,0,r,i),o.setTransform(s.scaleX,0,0,s.scaleY,s.left,s.top),o.drawImage(s.getElement(),0,0,r,i);let l=o.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],a=l[t],o=l[t+1],h=l[t+2],c=l[t+3];switch(this.mode){case"multiply":e[t]=r*a/255,e[t+1]=i*o/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 te(te({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:r,image:i}=t,n=tr(t,ab);return at.fromObject(i,e).then(t=>new this(te(te({},n),{},{image:t})))}}$(a_,"type","BlendImage"),$(a_,"defaults",{mode:"multiply",alpha:1}),$(a_,"uniformLocations",["uTransformMatrix","uImage"]),tY.setClass(a_);class aw extends am{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),a=4*r;for(let t=0;t<e.length;t+=4){let r=0,i=0,o=0,l=0,h=0,c=t-t%a,u=c+a;for(let s=-14;s<15;s++){let a=s/15,d=4*Math.floor(n*a),f=1-Math.abs(a),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,o+=e[g+2]*p,l+=p,h+=f}s[t]=r/l,s[t+1]=i/l,s[t+2]=o/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,o=0,l=0,h=0,c=t%a,u=s.length-a+c;for(let e=-14;e<15;e++){let d=e/15,f=Math.floor(n*d)*a,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,o+=s[p+2]*m,l+=m,h+=g}e[t]=r/l,e[t+1]=i/l,e[t+2]=o/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]}}$(aw,"type","Blur"),$(aw,"defaults",{blur:0}),$(aw,"uniformLocations",["uDelta"]),tY.setClass(aw);class aC extends am{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)}}$(aC,"type","Brightness"),$(aC,"defaults",{brightness:0}),$(aC,"uniformLocations",["uBrightness"]),tY.setClass(aC);let aS={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class aT extends am{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],a=e[t+2];if(e[t]=n*r[0]+s*r[1]+a*r[2]+255*r[4],e[t+1]=n*r[5]+s*r[6]+a*r[7]+255*r[9],e[t+2]=n*r[10]+s*r[11]+a*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]+a*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 te(te({},super.toObject()),{},{matrix:[...this.matrix]})}}function aO(t,e){var r;let i=($(r=class extends aT{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",t),$(r,"defaults",{colorsOnly:!1,matrix:e}),r);return tY.setClass(i,t),i}$(aT,"type","ColorMatrix"),$(aT,"defaults",aS),$(aT,"uniformLocations",["uColorMatrix","uConstants"]),tY.setClass(aT);let ak=aO("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]),aM=aO("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]),aE=aO("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]),aD=aO("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]),aj=aO("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]),aA=aO("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]),aP=aO("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 aF extends am{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||[]}}$(aF,"type","Composed"),tY.setClass(aF);class aL extends am{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)}}$(aL,"type","Contrast"),$(aL,"defaults",{contrast:0}),$(aL,"uniformLocations",["uContrast"]),tY.setClass(aL);let aR={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 aI extends am{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(+!!this.opaque)}getFragmentSource(){return aR[this.getCacheKey()]}applyTo2d(t){let e,r,i,n,s,a,o,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++)o=u+f-x,a=c+d-x,o<0||o>=_||a<0||a>=b||(l=4*(o*b+a),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 te(te({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}$(aI,"type","Convolute"),$(aI,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),$(aI,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),tY.setClass(aI);let aB="Gamma";class aN extends am{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 a=this.rgbValues;for(let t=0;t<256;t++)a.r[t]=255*Math.pow(t/255,i),a.g[t]=255*Math.pow(t/255,n),a.b[t]=255*Math.pow(t/255,s);for(let t=0;t<e.length;t+=4)e[t]=a.r[e[t]],e[t+1]=a.g[e[t+1]],e[t+2]=a.b[e[t+2]]}sendUniformData(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:aB,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()}}$(aN,"type",aB),$(aN,"defaults",{gamma:[1,1,1]}),$(aN,"uniformLocations",["uGamma"]),tY.setClass(aN);let aW={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 aU extends am{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 aW[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}$(aU,"type","Grayscale"),$(aU,"defaults",{mode:"average"}),$(aU,"uniformLocations",["uMode"]),tY.setClass(aU);let aH=te(te({},aS),{},{rotation:0});class aX extends aT{calculateMatrix(){let t=this.rotation*Math.PI,e=tQ(t),r=tJ(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}}}$(aX,"type","HueRotation"),$(aX,"defaults",aH),tY.setClass(aX);class aV extends am{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))}}$(aV,"type","Invert"),$(aV,"defaults",{alpha:!1,invert:!0}),$(aV,"uniformLocations",["uInvert","uAlpha"]),tY.setClass(aV);class az extends am{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}}$(az,"type","Noise"),$(az,"defaults",{noise:0}),$(az,"uniformLocations",["uNoise","uSeed"]),tY.setClass(az);class aY extends am{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,a=e[s],o=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]=a,e[i+1]=o,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)}}$(aY,"type","Pixelate"),$(aY,"defaults",{blocksize:4}),$(aY,"uniformLocations",["uBlocksize"]),tY.setClass(aY);class aG extends am{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 ra(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],a=e[t+2];r>n[0]&&i>n[1]&&a>n[2]&&r<s[0]&&i<s[1]&&a<s[2]&&(e[t+3]=0)}}sendUniformData(t,e){let r=new ra(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)}}$(aG,"type","RemoveColor"),$(aG,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),$(aG,"uniformLocations",["uLow","uHigh"]),tY.setClass(aG);class aq extends am{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,a=r.height,o=Math.round(s*i),l=Math.round(a*n);e="sliceHack"===this.resizeType?this.sliceByTwo(t,s,a,o,l):"hermite"===this.resizeType?this.hermiteFastResize(t,s,a,o,l):"bilinear"===this.resizeType?this.bilinearFiltering(t,s,a,o,l):"lanczos"===this.resizeType?this.lanczosResize(t,s,a,o,l):new ImageData(o,l),t.imageData=e}sliceByTwo(t,e,r,i,n){let s=t.imageData,a=!1,o=!1,l=.5*e,h=.5*r,c=t.filterBackend.resources,u=0,d=0,f=e,g=0;c.sliceByTwo||(c.sliceByTwo=t6());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);!a||!o;)e=l,r=h,i<Math.floor(.5*l)?l=Math.floor(.5*l):(l=i,a=!0),n<Math.floor(.5*h)?h=Math.floor(.5*h):(h=n,o=!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,a=t.ctx.createImageData(i,n),o=a.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]))}o[C=4*(b*i+x)]=T/S,o[C+1]=O/S,o[C+2]=k/S,o[C+3]=M/S}return++x<i?t(x):a}(0)}bilinearFiltering(t,e,r,i,n){let s,a,o,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(o=Math.floor(y*c),l=Math.floor(x*h),u=y*c-o,d=x*h-l,p=4*(l*e+o),f=0;f<4;f++)s=_[p+f],a=_[p+4+f],g=s*(1-u)*(1-d)+a*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,a=this.rcpScaleY,o=Math.ceil(s/2),l=Math.ceil(a/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)*a;for(let i=Math.floor(t*a);i<(t+1)*a;i++){let t=Math.abs(x-(i+.5))/l,n=(r+.5)*s,a=t*t;for(let t=Math.floor(r*s);t<(r+1)*s;t++){let r=Math.abs(n-(t+.5))/o,s=Math.sqrt(a+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}}$(aq,"type","Resize"),$(aq,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),$(aq,"uniformLocations",["uDelta","uTaps"]),tY.setClass(aq);class aK extends am{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],a=Math.max(i,n,s);e[t]+=a!==i?(a-i)*r:0,e[t+1]+=a!==n?(a-n)*r:0,e[t+2]+=a!==s?(a-s)*r:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return 0===this.saturation}}$(aK,"type","Saturation"),$(aK,"defaults",{saturation:0}),$(aK,"uniformLocations",["uSaturation"]),tY.setClass(aK);class aQ extends am{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],a=Math.max(i,n,s),o=2*Math.abs(a-(i+n+s)/3)/255*r;e[t]+=a!==i?(a-i)*o:0,e[t+1]+=a!==n?(a-n)*o:0,e[t+2]+=a!==s?(a-s)*o:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return 0===this.vibrance}}$(aQ,"type","Vibrance"),$(aQ,"defaults",{vibrance:0}),$(aQ,"uniformLocations",["uVibrance"]),tY.setClass(aQ);var aJ=Object.freeze({__proto__:null,BaseFilter:am,BlackWhite:aP,BlendColor:ay,BlendImage:a_,Blur:aw,Brightness:aC,Brownie:ak,ColorMatrix:aT,Composed:aF,Contrast:aL,Convolute:aI,Gamma:aN,Grayscale:aU,HueRotation:aX,Invert:aV,Kodachrome:aE,Noise:az,Pixelate:aY,Polaroid:aj,RemoveColor:aG,Resize:aq,Saturation:aK,Sepia:aA,Technicolor:aD,Vibrance:aQ,Vintage:aM});let aZ=Z.default.createContext(null);aZ.displayName="CanvasContext";let a$=function(t){var e;let r=(0,Z.useContext)(aZ);if(!r)throw Error("No CanvasContext.Provider");return void 0===t?r:null==t?{}:null!=(e=r.canvases[t])?e:{}},a0=Z.default.createContext(null);function a1(){let t=(0,Z.useContext)(a0);if(!t)throw Error("No ToolsContext.Provider");return t}a0.displayName="ToolsContext";let a2=Math.min,a5=Math.max,a4=Math.round,a3=Math.floor,a9=t=>({x:t,y:t}),a6={left:"right",right:"left",bottom:"top",top:"bottom"},a8={start:"end",end:"start"};function a7(t,e){return"function"==typeof t?t(e):t}function ot(t){return t.split("-")[0]}function oe(t){return t.split("-")[1]}function or(t){return"y"===t?"height":"width"}let oi=new Set(["top","bottom"]);function on(t){return oi.has(ot(t))?"y":"x"}function os(t){return"x"===on(t)?"y":"x"}function oa(t){return t.replace(/start|end/g,t=>a8[t])}let oo=["left","right"],ol=["right","left"],oh=["top","bottom"],oc=["bottom","top"];function ou(t){return t.replace(/left|right|bottom|top/g,t=>a6[t])}function od(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 of(t,e,r){let i,{reference:n,floating:s}=t,a=on(e),o=os(e),l=or(o),h=ot(e),c="y"===a,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(oe(e)){case"start":i[o]-=f*(r&&c?-1:1);break;case"end":i[o]+=f*(r&&c?-1:1)}return i}let og=async(t,e,r)=>{let{placement:i="bottom",strategy:n="absolute",middleware:s=[],platform:a}=r,o=s.filter(Boolean),l=await (null==a.isRTL?void 0:a.isRTL(e)),h=await a.getElementRects({reference:t,floating:e,strategy:n}),{x:c,y:u}=of(h,i,l),d=i,f={},g=0;for(let r=0;r<o.length;r++){let{name:s,fn:p}=o[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:a,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 a.getElementRects({reference:t,floating:e,strategy:n}):b.rects),{x:c,y:u}=of(h,d,l)),r=-1)}return{x:c,y:u,placement:d,strategy:n,middlewareData:f}};async function op(t,e){var r,i;void 0===e&&(e={});let{x:n,y:s,platform:a,rects:o,elements:l,strategy:h}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:g=0}=a7(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=od(await a.getClippingRect({element:null==(r=await (null==a.isElement?void 0:a.isElement(m)))||r?m:m.contextElement||await (null==a.getDocumentElement?void 0:a.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:h})),x="floating"===d?{x:n,y:s,width:o.floating.width,height:o.floating.height}:o.reference,b=await (null==a.getOffsetParent?void 0:a.getOffsetParent(l.floating)),_=await (null==a.isElement?void 0:a.isElement(b))&&await (null==a.getScale?void 0:a.getScale(b))||{x:1,y:1},w=od(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.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 om=new Set(["left","top"]);async function ov(t,e){let{placement:r,platform:i,elements:n}=t,s=await (null==i.isRTL?void 0:i.isRTL(n.floating)),a=ot(r),o=oe(r),l="y"===on(r),h=om.has(a)?-1:1,c=s&&l?-1:1,u=a7(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 o&&"number"==typeof g&&(f="end"===o?-1*g:g),l?{x:f*c,y:d*h}:{x:d*h,y:f*c}}function oy(){return"undefined"!=typeof window}function ox(t){return ow(t)?(t.nodeName||"").toLowerCase():"#document"}function ob(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function o_(t){var e;return null==(e=(ow(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function ow(t){return!!oy()&&(t instanceof Node||t instanceof ob(t).Node)}function oC(t){return!!oy()&&(t instanceof Element||t instanceof ob(t).Element)}function oS(t){return!!oy()&&(t instanceof HTMLElement||t instanceof ob(t).HTMLElement)}function oT(t){return!!oy()&&"undefined"!=typeof ShadowRoot&&(t instanceof ShadowRoot||t instanceof ob(t).ShadowRoot)}let oO=new Set(["inline","contents"]);function ok(t){let{overflow:e,overflowX:r,overflowY:i,display:n}=oB(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+r)&&!oO.has(n)}let oM=new Set(["table","td","th"]),oE=[":popover-open",":modal"];function oD(t){return oE.some(e=>{try{return t.matches(e)}catch(t){return!1}})}let oj=["transform","translate","scale","rotate","perspective"],oA=["transform","translate","scale","rotate","perspective","filter"],oP=["paint","layout","strict","content"];function oF(t){let e=oL(),r=oC(t)?oB(t):t;return oj.some(t=>!!r[t]&&"none"!==r[t])||!!r.containerType&&"normal"!==r.containerType||!e&&!!r.backdropFilter&&"none"!==r.backdropFilter||!e&&!!r.filter&&"none"!==r.filter||oA.some(t=>(r.willChange||"").includes(t))||oP.some(t=>(r.contain||"").includes(t))}function oL(){return"undefined"!=typeof CSS&&!!CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")}let oR=new Set(["html","body","#document"]);function oI(t){return oR.has(ox(t))}function oB(t){return ob(t).getComputedStyle(t)}function oN(t){return oC(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function oW(t){if("html"===ox(t))return t;let e=t.assignedSlot||t.parentNode||oT(t)&&t.host||o_(t);return oT(e)?e.host:e}function oU(t,e,r){var i;void 0===e&&(e=[]),void 0===r&&(r=!0);let n=function t(e){let r=oW(e);return oI(r)?e.ownerDocument?e.ownerDocument.body:e.body:oS(r)&&ok(r)?r:t(r)}(t),s=n===(null==(i=t.ownerDocument)?void 0:i.body),a=ob(n);if(s){let t=oH(a);return e.concat(a,a.visualViewport||[],ok(n)?n:[],t&&r?oU(t):[])}return e.concat(n,oU(n,[],r))}function oH(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function oX(t){let e=oB(t),r=parseFloat(e.width)||0,i=parseFloat(e.height)||0,n=oS(t),s=n?t.offsetWidth:r,a=n?t.offsetHeight:i,o=a4(r)!==s||a4(i)!==a;return o&&(r=s,i=a),{width:r,height:i,$:o}}function oV(t){return oC(t)?t:t.contextElement}function oz(t){let e=oV(t);if(!oS(e))return a9(1);let r=e.getBoundingClientRect(),{width:i,height:n,$:s}=oX(e),a=(s?a4(r.width):r.width)/i,o=(s?a4(r.height):r.height)/n;return a&&Number.isFinite(a)||(a=1),o&&Number.isFinite(o)||(o=1),{x:a,y:o}}let oY=a9(0);function oG(t){let e=ob(t);return oL()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:oY}function oq(t,e,r,i){var n;void 0===e&&(e=!1),void 0===r&&(r=!1);let s=t.getBoundingClientRect(),a=oV(t),o=a9(1);e&&(i?oC(i)&&(o=oz(i)):o=oz(t));let l=(void 0===(n=r)&&(n=!1),i&&(!n||i===ob(a))&&n)?oG(a):a9(0),h=(s.left+l.x)/o.x,c=(s.top+l.y)/o.y,u=s.width/o.x,d=s.height/o.y;if(a){let t=ob(a),e=i&&oC(i)?ob(i):i,r=t,n=oH(r);for(;n&&i&&e!==r;){let t=oz(n),e=n.getBoundingClientRect(),i=oB(n),s=e.left+(n.clientLeft+parseFloat(i.paddingLeft))*t.x,a=e.top+(n.clientTop+parseFloat(i.paddingTop))*t.y;h*=t.x,c*=t.y,u*=t.x,d*=t.y,h+=s,c+=a,n=oH(r=ob(n))}}return od({width:u,height:d,x:h,y:c})}function oK(t,e){let r=oN(t).scrollLeft;return e?e.left+r:oq(o_(t)).left+r}function oQ(t,e){let r=t.getBoundingClientRect();return{x:r.left+e.scrollLeft-oK(t,r),y:r.top+e.scrollTop}}let oJ=new Set(["absolute","fixed"]);function oZ(t,e,r){let i;if("viewport"===e)i=function(t,e){let r=ob(t),i=o_(t),n=r.visualViewport,s=i.clientWidth,a=i.clientHeight,o=0,l=0;if(n){s=n.width,a=n.height;let t=oL();(!t||t&&"fixed"===e)&&(o=n.offsetLeft,l=n.offsetTop)}let h=oK(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,a=Math.abs(i.clientWidth-e.clientWidth-n);a<=25&&(s-=a)}else h<=25&&(s+=h);return{width:s,height:a,x:o,y:l}}(t,r);else if("document"===e)i=function(t){let e=o_(t),r=oN(t),i=t.ownerDocument.body,n=a5(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=a5(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),a=-r.scrollLeft+oK(t),o=-r.scrollTop;return"rtl"===oB(i).direction&&(a+=a5(e.clientWidth,i.clientWidth)-n),{width:n,height:s,x:a,y:o}}(o_(t));else if(oC(e))i=function(t,e){let r=oq(t,!0,"fixed"===e),i=r.top+t.clientTop,n=r.left+t.clientLeft,s=oS(t)?oz(t):a9(1),a=t.clientWidth*s.x,o=t.clientHeight*s.y;return{width:a,height:o,x:n*s.x,y:i*s.y}}(e,r);else{let r=oG(t);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return od(i)}function o$(t){return"static"===oB(t).position}function o0(t,e){if(!oS(t)||"fixed"===oB(t).position)return null;if(e)return e(t);let r=t.offsetParent;return o_(t)===r&&(r=r.ownerDocument.body),r}function o1(t,e){var r;let i=ob(t);if(oD(t))return i;if(!oS(t)){let e=oW(t);for(;e&&!oI(e);){if(oC(e)&&!o$(e))return e;e=oW(e)}return i}let n=o0(t,e);for(;n&&(r=n,oM.has(ox(r)))&&o$(n);)n=o0(n,e);return n&&oI(n)&&o$(n)&&!oF(n)?i:n||function(t){let e=oW(t);for(;oS(e)&&!oI(e);){if(oF(e))return e;if(oD(e))break;e=oW(e)}return null}(t)||i}let o2=async function(t){let e=this.getOffsetParent||o1,r=this.getDimensions,i=await r(t.floating);return{reference:function(t,e,r){let i=oS(e),n=o_(e),s="fixed"===r,a=oq(t,!0,s,e),o={scrollLeft:0,scrollTop:0},l=a9(0);if(i||!i&&!s)if(("body"!==ox(e)||ok(n))&&(o=oN(e)),i){let t=oq(e,!0,s,e);l.x=t.x+e.clientLeft,l.y=t.y+e.clientTop}else n&&(l.x=oK(n));s&&!i&&n&&(l.x=oK(n));let h=!n||i||s?a9(0):oQ(n,o);return{x:a.left+o.scrollLeft-l.x-h.x,y:a.top+o.scrollTop-l.y-h.y,width:a.width,height:a.height}}(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},o5={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:r,offsetParent:i,strategy:n}=t,s="fixed"===n,a=o_(i),o=!!e&&oD(e.floating);if(i===a||o&&s)return r;let l={scrollLeft:0,scrollTop:0},h=a9(1),c=a9(0),u=oS(i);if((u||!u&&!s)&&(("body"!==ox(i)||ok(a))&&(l=oN(i)),oS(i))){let t=oq(i);h=oz(i),c.x=t.x+i.clientLeft,c.y=t.y+i.clientTop}let d=!a||u||s?a9(0):oQ(a,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:o_,getClippingRect:function(t){let{element:e,boundary:r,rootBoundary:i,strategy:n}=t,s=[..."clippingAncestors"===r?oD(e)?[]:function(t,e){let r=e.get(t);if(r)return r;let i=oU(t,[],!1).filter(t=>oC(t)&&"body"!==ox(t)),n=null,s="fixed"===oB(t).position,a=s?oW(t):t;for(;oC(a)&&!oI(a);){let e=oB(a),r=oF(a);r||"fixed"!==e.position||(n=null),(s?!r&&!n:!r&&"static"===e.position&&!!n&&oJ.has(n.position)||ok(a)&&!r&&function t(e,r){let i=oW(e);return!(i===r||!oC(i)||oI(i))&&("fixed"===oB(i).position||t(i,r))}(t,a))?i=i.filter(t=>t!==a):n=e,a=oW(a)}return e.set(t,i),i}(e,this._c):[].concat(r),i],a=s[0],o=s.reduce((t,r)=>{let i=oZ(e,r,n);return t.top=a5(i.top,t.top),t.right=a2(i.right,t.right),t.bottom=a2(i.bottom,t.bottom),t.left=a5(i.left,t.left),t},oZ(e,a,n));return{width:o.right-o.left,height:o.bottom-o.top,x:o.left,y:o.top}},getOffsetParent:o1,getElementRects:o2,getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){let{width:e,height:r}=oX(t);return{width:e,height:r}},getScale:oz,isElement:oC,isRTL:function(t){return"rtl"===oB(t).direction}};function o4(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function o3(t,e,r,i){let n;void 0===i&&(i={});let{ancestorScroll:s=!0,ancestorResize:a=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:h=!1}=i,c=oV(t),u=s||a?[...c?oU(c):[],...oU(e)]:[];u.forEach(t=>{s&&t.addEventListener("scroll",r,{passive:!0}),a&&t.addEventListener("resize",r)});let d=c&&l?function(t,e){let r,i=null,n=o_(t);function s(){var t;clearTimeout(r),null==(t=i)||t.disconnect(),i=null}return!function a(o,l){void 0===o&&(o=!1),void 0===l&&(l=1),s();let h=t.getBoundingClientRect(),{left:c,top:u,width:d,height:f}=h;if(o||e(),!d||!f)return;let g=a3(u),p=a3(n.clientWidth-(c+d)),m={rootMargin:-g+"px "+-p+"px "+-a3(n.clientHeight-(u+f))+"px "+-a3(c)+"px",threshold:a5(0,a2(1,l))||1},y=!0;function x(e){let i=e[0].intersectionRatio;if(i!==l){if(!y)return a();i?a(!1,i):r=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==i||o4(h,t.getBoundingClientRect())||a(),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;o&&(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?oq(t):null;return h&&function e(){let i=oq(t);p&&!o4(p,i)&&r(),p=i,n=requestAnimationFrame(e)}(),r(),()=>{var t;u.forEach(t=>{s&&t.removeEventListener("scroll",r),a&&t.removeEventListener("resize",r)}),null==d||d(),null==(t=g)||t.disconnect(),g=null,h&&cancelAnimationFrame(n)}}var o9=t.i(74080),o6="undefined"!=typeof document?Z.useLayoutEffect:function(){};function o8(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(!o8(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)&&!o8(t[r],e[r]))return!1}return!0}return t!=t&&e!=e}function o7(t){return"undefined"==typeof window?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function lt(t,e){let r=o7(t);return Math.round(e*r)/r}function le(t){let e=Z.useRef(t);return o6(()=>{e.current=t}),e}let lr=(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:a,middlewareData:o}=e,l=await ov(e,t);return a===(null==(r=o.offset)?void 0:r.placement)&&null!=(i=o.arrow)&&i.alignmentOffset?{}:{x:n+l.x,y:s+l.y,data:{...l,placement:a}}}}}(t),options:[t,e]}),li=(t,e)=>({...function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var r,i,n,s,a;let{placement:o,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}=a7(t,e);if(null!=(r=l.arrow)&&r.alignmentOffset)return{};let _=ot(o),w=on(c),C=ot(c)===c,S=await (null==u.isRTL?void 0:u.isRTL(d.floating)),T=p||(C||!x?[ou(c)]:function(t){let e=ou(t);return[oa(t),e,oa(e)]}(c)),O="none"!==y;!p&&O&&T.push(...function(t,e,r,i){let n=oe(t),s=function(t,e,r){switch(t){case"top":case"bottom":if(r)return e?ol:oo;return e?oo:ol;case"left":case"right":return e?oh:oc;default:return[]}}(ot(t),"start"===r,i);return n&&(s=s.map(t=>t+"-"+n),e&&(s=s.concat(s.map(oa)))),s}(c,x,y,S));let k=[c,...T],M=await op(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=oe(t),n=os(t),s=or(n),a="x"===n?i===(r?"end":"start")?"right":"left":"start"===i?"bottom":"top";return e.reference[s]>e.floating[s]&&(a=ou(a)),[a,ou(a)]}(o,h,S);E.push(M[t[0]],M[t[1]])}if(D=[...D,{placement:o,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===on(e)||D.every(t=>on(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==(a=D.filter(t=>{if(O){let e=on(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:a[0];t&&(r=t);break}case"initialPlacement":r=c}if(o!==r)return{reset:{placement:r}}}return{}}}}(t),options:[t,e]});t.i(47167);var ln='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])',ls="undefined"==typeof Element,la=ls?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,lo=!ls&&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},ll=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)},lh=function(t){var e,r=null==t||null==(e=t.getAttribute)?void 0:e.call(t,"contenteditable");return""===r||"true"===r},lc=function(t,e,r){if(ll(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(ln));return e&&la.call(t,ln)&&i.unshift(t),i=i.filter(r)},lu=function t(e,r,i){for(var n=[],s=Array.from(e);s.length;){var a=s.shift();if(!ll(a,!1))if("SLOT"===a.tagName){var o=a.assignedElements(),l=t(o.length?o:a.children,!0,i);i.flatten?n.push.apply(n,l):n.push({scopeParent:a,candidates:l})}else{la.call(a,ln)&&i.filter(a)&&(r||!e.includes(a))&&n.push(a);var h=a.shadowRoot||"function"==typeof i.getShadowRoot&&i.getShadowRoot(a),c=!ll(h,!1)&&(!i.shadowRootFilter||i.shadowRootFilter(a));if(h&&c){var u=t(!0===h?a.children:h.children,!0,i);i.flatten?n.push.apply(n,u):n.push({scopeParent:a,candidates:u})}else s.unshift.apply(s,a.children)}}return n},ld=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},lf=function(t){if(!t)throw Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||lh(t))&&!ld(t)?0:t.tabIndex},lg=function(t,e){var r=lf(t);return r<0&&e&&!ld(t)?0:r},lp=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},lm=function(t){return"INPUT"===t.tagName},lv=function(t,e){for(var r=0;r<t.length;r++)if(t[r].checked&&t[r].form===e)return t[r]},ly=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=lv(e,t.form);return!n||n===t},lx=function(t){return lm(t)&&"radio"===t.type&&!ly(t)},lb=function(t){var e,r,i,n,s,a,o,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!=(a=h=null==(s=l=lo(h))?void 0:s.host)&&null!=(o=a.ownerDocument)&&o.contains(h));return c},l_=function(t){var e=t.getBoundingClientRect(),r=e.width,i=e.height;return 0===r&&0===i},lw=function(t,e){var r=e.displayCheck,i=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var n=la.call(t,"details>summary:first-of-type")?t.parentElement:t;if(la.call(n,"details:not([open]) *"))return!0;if(r&&"full"!==r&&"legacy-full"!==r){if("non-zero-area"===r)return l_(t)}else{if("function"==typeof i){for(var s=t;t;){var a=t.parentElement,o=lo(t);if(a&&!a.shadowRoot&&!0===i(a))return l_(t);t=t.assignedSlot?t.assignedSlot:a||o===t.ownerDocument?a:o.host}t=s}if(lb(t))return!t.getClientRects().length;if("legacy-full"!==r)return!0}return!1},lC=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!!la.call(e,"fieldset[disabled] *")||!i.contains(t)}return!0}e=e.parentElement}return!1},lS=function(t,e){return!(e.disabled||ll(e)||lm(e)&&"hidden"===e.type||lw(e,t)||"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(t){return"SUMMARY"===t.tagName})||lC(e))},lT=function(t,e){return!(lx(e)||0>lf(e))&&!!lS(t,e)},lO=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!isNaN(e)||!!(e>=0)},lk=function t(e){var r=[],i=[];return e.forEach(function(e,n){var s=!!e.scopeParent,a=s?e.scopeParent:e,o=lg(a,s),l=s?t(e.candidates):a;0===o?s?r.push.apply(r,l):r.push(a):i.push({documentOrder:n,tabIndex:o,item:e,isScope:s,content:l})}),i.sort(lp).reduce(function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t},[]).concat(r)},lM=function(t,e){return lk((e=e||{}).getShadowRoot?lu([t],e.includeContainer,{filter:lT.bind(null,e),flatten:!1,getShadowRoot:e.getShadowRoot,shadowRootFilter:lO}):lc(t,e.includeContainer,lT.bind(null,e)))},lE=function(t,e){return(e=e||{}).getShadowRoot?lu([t],e.includeContainer,{filter:lS.bind(null,e),flatten:!0,getShadowRoot:e.getShadowRoot}):lc(t,e.includeContainer,lS.bind(null,e))},lD=function(t,e){if(e=e||{},!t)throw Error("No node provided");return!1!==la.call(t,ln)&&lT(e,t)};function lj(){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 lA(){let t=/android/i;return t.test(function(){let t=navigator.userAgentData;return null!=t&&t.platform?t.platform:navigator.platform}())||t.test(lj())}let lP="data-floating-ui-focusable";function lF(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 lL(t,e){if(!t||!e)return!1;let r=null==e.getRootNode?void 0:e.getRootNode();if(t.contains(e))return!0;if(r&&oT(r)){let r=e;for(;r;){if(t===r)return!0;r=r.parentNode||r.host}}return!1}function lR(t){return"composedPath"in t?t.composedPath()[0]:t.target}function lI(t,e){return null!=e&&("composedPath"in t?t.composedPath().includes(e):null!=t.target&&e.contains(t.target))}function lB(t){return(null==t?void 0:t.ownerDocument)||document}function lN(t){return oS(t)&&t.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function lW(t){return!!t&&"combobox"===t.getAttribute("role")&&lN(t)}function lU(t){return t?t.hasAttribute(lP)?t:t.querySelector("["+lP+"]")||t:null}function lH(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,...lH(t,e.id,r)])}function lX(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 lV(t){t.preventDefault(),t.stopPropagation()}function lz(t,e){let r=["mouse","pen"];return e||r.push("",void 0),r.includes(t)}var lY="undefined"!=typeof document?Z.useLayoutEffect:function(){};function lG(t){let e=Z.useRef(t);return lY(()=>{e.current=t}),e}let lq={...Z}.useInsertionEffect||(t=>t());function lK(t){let e=Z.useRef(()=>{});return lq(()=>{e.current=t}),Z.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 lQ=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function lJ(t,e){let r=lM(t,lQ()),i=r.length;if(0===i)return;let n=lF(lB(t)),s=r.indexOf(n);return r[-1===s?1===e?0:i-1:s+e]}function lZ(t,e){let r=e||t.currentTarget,i=t.relatedTarget;return!i||!lL(r,i)}let l$="active",l0="selected",l1={...Z},l2=!1,l5=0,l4=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+l5++,l3=l1.useId||function(){let[t,e]=Z.useState(()=>l2?l4():void 0);return lY(()=>{null==t&&e(l4())},[]),Z.useEffect(()=>{l2=!0},[]),t},l9=Z.createContext(null),l6=Z.createContext(null),l8=()=>{var t;return(null==(t=Z.useContext(l9))?void 0:t.id)||null},l7=()=>Z.useContext(l6);function ht(t){return"data-floating-ui-"+t}let he=0;function hr(t,e){void 0===e&&(e={});let{preventScroll:r=!1,cancelPrevious:i=!0,sync:n=!1}=e;i&&cancelAnimationFrame(he);let s=()=>null==t?void 0:t.focus({preventScroll:r});n?s():he=requestAnimationFrame(s)}let hi={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function hn(t){return"inert"===t?hi.inert:"aria-hidden"===t?hi["aria-hidden"]:hi.none}let hs=new WeakSet,ha={},ho=0,hl=t=>t&&(t.host||hl(t.parentNode));function hh(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,a=t.map(t=>{if(e.contains(t))return t;let r=hl(t);return e.contains(r)?r:null}).filter(t=>null!=t),o=new Set,l=new Set(a),h=[];ha[n]||(ha[n]=new WeakMap);let c=ha[n];return a.forEach(function t(e){!(!e||o.has(e))&&(o.add(e),e.parentNode&&t(e.parentNode))}),function t(e){!e||l.has(e)||[].forEach.call(e.children,e=>{if("script"!==ox(e))if(o.has(e))t(e);else{let t=s?e.getAttribute(s):null,r=null!==t&&"false"!==t,i=hn(s),a=(i.get(e)||0)+1,o=(c.get(e)||0)+1;i.set(e,a),c.set(e,o),h.push(e),1===a&&r&&hs.add(e),1===o&&e.setAttribute(n,""),!r&&s&&e.setAttribute(s,"inert"===s?"":"true")}})}(e),o.clear(),ho++,()=>{h.forEach(t=>{let e=hn(s),r=(e.get(t)||0)-1,i=(c.get(t)||0)-1;e.set(t,r),c.set(t,i),r||(!hs.has(t)&&s&&t.removeAttribute(s),hs.delete(t)),i||t.removeAttribute(n)}),--ho||(hi.inert=new WeakMap,hi["aria-hidden"]=new WeakMap,hi.none=new WeakMap,hs=new WeakSet,ha={})}}(t.concat(Array.from(n.querySelectorAll('[aria-live],[role="status"],output'))),n,e,r)}let hc={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},hu=Z.forwardRef(function(t,e){let[r,i]=Z.useState();lY(()=>{/apple/i.test(navigator.vendor)&&i("button")},[]);let n={ref:e,tabIndex:0,role:r,"aria-hidden":!r||void 0,[ht("focus-guard")]:"",style:hc};return(0,J.jsx)("span",{...t,...n})}),hd=Z.createContext(null);function hf(t){return Z.useMemo(()=>e=>{t.forEach(t=>{t&&(t.current=e)})},t)}let hg=[];function hp(){hg=hg.filter(t=>t.isConnected)}function hm(){return hp(),hg[hg.length-1]}function hv(t,e){var r;if(!e.current.includes("floating")&&!(null!=(r=t.getAttribute("role"))&&r.includes("dialog")))return;let i=lQ(),n=lE(t,i).filter(t=>{let e=t.getAttribute("data-tabindex")||"";return lD(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 hy=Z.forwardRef(function(t,e){return(0,J.jsx)("button",{...t,type:"button",ref:e,tabIndex:-1,style:hc})});function hx(t){let{context:e,children:r,disabled:i=!1,order:n=["content"],guards:s=!0,initialFocus:a=0,returnFocus:o=!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,_=lK(()=>{var t;return null==(t=y.current.floatingContext)?void 0:t.nodeId}),w=lK(f),C="number"==typeof a&&a<0,S=lW(x)&&C,T="undefined"!=typeof HTMLElement&&"inert"in HTMLElement.prototype,O=!T||s,k=!O||T&&d,M=lG(n),E=lG(a),D=lG(o),j=l7(),A=Z.useContext(hd),P=Z.useRef(null),F=Z.useRef(null),L=Z.useRef(!1),R=Z.useRef(!1),I=Z.useRef(-1),B=Z.useRef(-1),N=null!=A,W=lU(b),U=lK(function(t){return void 0===t&&(t=W),t?lM(t,lQ()):[]}),H=lK(t=>{let e=U(t);return M.current.map(t=>x&&"reference"===t?x:W&&"floating"===t?W:e).filter(Boolean).flat()});Z.useEffect(()=>{if(i||!h)return;function t(t){if("Tab"===t.key){lL(W,lF(lB(W)))&&0===U().length&&!S&&lV(t);let e=H(),r=lR(t);"reference"===M.current[0]&&r===x&&(lV(t),t.shiftKey?hr(e[e.length-1]):hr(e[1])),"floating"===M.current[1]&&r===W&&t.shiftKey&&(lV(t),hr(e[0]))}}let e=lB(W);return e.addEventListener("keydown",t),()=>{e.removeEventListener("keydown",t)}},[i,x,W,h,M,S,U,H]),Z.useEffect(()=>{if(!i&&b)return b.addEventListener("focusin",t),()=>{b.removeEventListener("focusin",t)};function t(t){let e=lR(t),r=U().indexOf(e);-1!==r&&(I.current=r)}},[i,b,U]),Z.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=lR(t);queueMicrotask(()=>{let n=_(),s=!(lL(x,e)||lL(b,e)||lL(e,b)||lL(null==A?void 0:A.portalNode,e)||null!=e&&e.hasAttribute(ht("focus-guard"))||j&&(lH(j.nodesRef.current,n).find(t=>{var r,i;return lL(null==(r=t.context)?void 0:r.elements.floating,e)||lL(null==(i=t.context)?void 0:i.elements.domReference,e)})||lX(j.nodesRef.current,n).find(t=>{var r,i,n;return[null==(r=t.context)?void 0:r.elements.floating,lU(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&&hv(W,M),l&&r!==x&&!(null!=i&&i.isConnected)&&lF(lB(W))===lB(W).body){oS(W)&&W.focus();let t=I.current,e=U(),r=e[t]||e[e.length-1]||W;oS(r)&&r.focus()}if(y.current.insideReactTree){y.current.insideReactTree=!1;return}(S||!h)&&e&&s&&!R.current&&e!==hm()&&(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&&oS(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=Z.useRef(null),V=Z.useRef(null),z=hf([X,null==A?void 0:A.beforeInsideRef]),Y=hf([V,null==A?void 0:A.afterInsideRef]);function G(t){return!i&&c&&h?(0,J.jsx)(hy,{ref:"start"===t?P:F,onClick:t=>p(!1,t.nativeEvent),children:"string"==typeof c?c:"Dismiss"}):null}Z.useEffect(()=>{var t,e;if(i||!b)return;let r=Array.from((null==A||null==(t=A.portalNode)?void 0:t.querySelectorAll("["+ht("portal")+"]"))||[]),n=[b,null==(e=(j?lX(j.nodesRef.current,_()):[]).find(t=>{var e;return lW((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?hh(n,!k,k):hh(n);return()=>{s()}},[i,x,b,h,M,A,S,O,k,j,_,w]),lY(()=>{if(i||!oS(W))return;let t=lF(lB(W));queueMicrotask(()=>{let e=H(W),r=E.current,i=("number"==typeof r?e[r]:r.current)||W,n=lL(W,t);C||n||!g||hr(i,{preventScroll:i===W})})},[i,g,W,C,H,E]),lY(()=>{var t;if(i||!W)return;let e=lB(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||(lA()&&r.pointerType?"click"===r.type&&1===r.buttons:0===r.detail&&!r.pointerType)||!lj().includes("jsdom/")&&(!lA()&&0===r.width&&0===r.height||lA()&&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=lF(e),hp(),t&&"body"!==ox(t)&&(hg.push(t),hg.length>20&&(hg=hg.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,hc),N&&x&&x.insertAdjacentElement("afterend",n),()=>{m.off("openchange",r);let t=lF(e),i=lL(b,t)||j&&lH(j.nodesRef.current,_(),!1).some(e=>{var r;return lL(null==(r=e.context)?void 0:r.elements.floating,t)}),s=function(){if("boolean"==typeof D.current){let t=x||hm();return t&&t.isConnected?t:n}return D.current.current||n}();queueMicrotask(()=>{let r=function(t){let e=lQ();return lD(t,e)?t:lM(t,e)[0]||t}(s);D.current&&!L.current&&oS(r)&&(r===t||t===e.body||i)&&r.focus({preventScroll:!0}),n.remove()})}},[i,b,W,D,y,m,j,N,x,_]),Z.useEffect(()=>(queueMicrotask(()=>{L.current=!1}),()=>{queueMicrotask(hp)}),[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&&hv(W,M)},[i,W,M]);let q=!i&&O&&(!h||!S)&&(N||h);return(0,J.jsxs)(J.Fragment,{children:[q&&(0,J.jsx)(hu,{"data-type":"inside",ref:z,onFocus:t=>{var e;if(h){let t=H();hr("reference"===n[0]?t[0]:t[t.length-1])}else if(null!=A&&A.preserveTabOrder&&A.portalNode)if(L.current=!1,lZ(t,A.portalNode)){let t=lJ(lB(x).body,1)||x;null==t||t.focus()}else null==(e=A.beforeOutsideRef.current)||e.focus()}}),!S&&G("start"),r,G("end"),q&&(0,J.jsx)(hu,{"data-type":"inside",ref:Y,onFocus:t=>{var e;if(h)hr(H()[0]);else if(null!=A&&A.preserveTabOrder&&A.portalNode)if(u&&(L.current=!0),lZ(t,A.portalNode)){let t=lJ(lB(x).body,-1)||x;null==t||t.focus()}else null==(e=A.afterOutsideRef.current)||e.focus()}})]})}function hb(t){return oS(t.target)&&"BUTTON"===t.target.tagName}function h_(t,e){void 0===e&&(e={});let{open:r,onOpenChange:i,dataRef:n,elements:{domReference:s}}=t,{enabled:a=!0,event:o="click",toggle:l=!0,ignoreMouse:h=!1,keyboardHandlers:c=!0,stickIfOpen:u=!0}=e,d=Z.useRef(),f=Z.useRef(!1),g=Z.useMemo(()=>({onPointerDown(t){d.current=t.pointerType},onMouseDown(t){let e=d.current;0===t.button&&"click"!==o&&(lz(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"===o&&d.current){d.current=void 0;return}lz(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||hb(t))&&(" "!==t.key||lN(s)||(t.preventDefault(),f.current=!0),oS(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||hb(t)||lN(s))&&" "===t.key&&f.current&&(f.current=!1,r&&l?i(!1,t.nativeEvent,"click"):i(!0,t.nativeEvent,"click"))}}),[n,s,o,h,c,i,r,u,l]);return Z.useMemo(()=>a?{reference:g}:{},[a,g])}let hw={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},hC={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},hS=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 hT(t,e){void 0===e&&(e={});let{open:r,onOpenChange:i,elements:n,dataRef:s}=t,{enabled:a=!0,escapeKey:o=!0,outsidePress:l=!0,outsidePressEvent:h="pointerdown",referencePress:c=!1,referencePressEvent:u="pointerdown",ancestorScroll:d=!1,bubbles:f,capture:g}=e,p=l7(),m=lK("function"==typeof l?l:()=>!1),y="function"==typeof l?m:l,x=Z.useRef(!1),{escapeKey:b,outsidePress:_}=hS(f),{escapeKey:w,outsidePress:C}=hS(g),S=Z.useRef(!1),T=lK(t=>{var e;if(!r||!a||!o||"Escape"!==t.key||S.current)return;let n=null==(e=s.current.floatingContext)?void 0:e.nodeId,l=p?lH(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=lK(t=>{var e;let r=()=>{var e;T(t),null==(e=lR(t))||e.removeEventListener("keydown",r)};null==(e=lR(t))||e.addEventListener("keydown",r)}),k=lK(t=>{var e;let r=s.current.insideReactTree;s.current.insideReactTree=!1;let a=x.current;if(x.current=!1,"click"===h&&a||r||"function"==typeof y&&!y(t))return;let o=lR(t),l="["+ht("inert")+"]",c=lB(n.floating).querySelectorAll(l),u=oC(o)?o:null;for(;u&&!oI(u);){let t=oW(u);if(oI(t)||!oC(t))break;u=t}if(c.length&&oC(o)&&!o.matches("html,body")&&!lL(o,n.floating)&&Array.from(c).every(t=>!lL(u,t)))return;if(oS(o)&&D){let e=oI(o),r=oB(o),i=/auto|scroll/,n=e||i.test(r.overflowX),s=e||i.test(r.overflowY),a=n&&o.clientWidth>0&&o.scrollWidth>o.clientWidth,l=s&&o.clientHeight>0&&o.scrollHeight>o.clientHeight,h="rtl"===r.direction,c=l&&(h?t.offsetX<=o.offsetWidth-o.clientWidth:t.offsetX>o.clientWidth),u=a&&t.offsetY>o.clientHeight;if(c||u)return}let d=null==(e=s.current.floatingContext)?void 0:e.nodeId,f=p&&lH(p.nodesRef.current,d).some(e=>{var r;return lI(t,null==(r=e.context)?void 0:r.elements.floating)});if(lI(t,n.floating)||lI(t,n.domReference)||f)return;let g=p?lH(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=lK(t=>{var e;let r=()=>{var e;k(t),null==(e=lR(t))||e.removeEventListener(h,r)};null==(e=lR(t))||e.addEventListener(h,r)});Z.useEffect(()=>{if(!r||!a)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*!!oL())}let u=lB(n.floating);o&&(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&&(oC(n.domReference)&&(f=oU(n.domReference)),oC(n.floating)&&(f=f.concat(oU(n.floating))),!oC(n.reference)&&n.reference&&n.reference.contextElement&&(f=f.concat(oU(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})}),()=>{o&&(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,o,y,h,r,i,d,a,b,_,T,w,O,k,C,M]),Z.useEffect(()=>{s.current.insideReactTree=!1},[s,y,h]);let E=Z.useMemo(()=>({onKeyDown:T,...c&&{[hw[u]]:t=>{i(!1,t.nativeEvent,"reference-press")},..."click"!==u&&{onClick(t){i(!1,t.nativeEvent,"reference-press")}}}}),[T,i,c,u]),D=Z.useMemo(()=>({onKeyDown:T,onMouseDown(){x.current=!0},onMouseUp(){x.current=!0},[hC[h]]:()=>{s.current.insideReactTree=!0}}),[T,h,s]);return Z.useMemo(()=>a?{reference:E,floating:D}:{},[a,E,D])}function hO(t){void 0===t&&(t={});let{nodeId:e}=t,r=function(t){let{open:e=!1,onOpenChange:r,elements:i}=t,n=l3(),s=Z.useRef({}),[a]=Z.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)}}})()),o=null!=l8(),[l,h]=Z.useState(i.reference),c=lK((t,e,i)=>{s.current.openEvent=t?e:void 0,a.emit("openchange",{open:t,event:e,reason:i,nested:o}),null==r||r(t,e,i)}),u=Z.useMemo(()=>({setPositionReference:h}),[]),d=Z.useMemo(()=>({reference:l||i.reference||null,floating:i.floating||null,domReference:i.reference}),[l,i.reference,i.floating]);return Z.useMemo(()=>({dataRef:s,open:e,onOpenChange:c,elements:d,events:a,floatingId:n,refs:u}),[e,c,d,a,n,u])}({...t,elements:{reference:null,floating:null,...t.elements}}),i=t.rootContext||r,n=i.elements,[s,a]=Z.useState(null),[o,l]=Z.useState(null),h=(null==n?void 0:n.domReference)||s,c=Z.useRef(null),u=l7();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:a}={},transform:o=!0,whileElementsMounted:l,open:h}=t,[c,u]=Z.useState({x:0,y:0,strategy:r,placement:e,middlewareData:{},isPositioned:!1}),[d,f]=Z.useState(i);o8(d,i)||f(i);let[g,p]=Z.useState(null),[m,y]=Z.useState(null),x=Z.useCallback(t=>{t!==C.current&&(C.current=t,p(t))},[]),b=Z.useCallback(t=>{t!==S.current&&(S.current=t,y(t))},[]),_=s||g,w=a||m,C=Z.useRef(null),S=Z.useRef(null),T=Z.useRef(c),O=null!=l,k=le(l),M=le(n),E=le(h),D=Z.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:o5,...r},s={...n.platform,_c:i};return og(t,e,{...n,platform:s})})(C.current,S.current,t).then(t=>{let e={...t,isPositioned:!1!==E.current};j.current&&!o8(T.current,e)&&(T.current=e,o9.flushSync(()=>{u(e)}))})},[d,e,r,M,E]);o6(()=>{!1===h&&T.current.isPositioned&&(T.current.isPositioned=!1,u(t=>({...t,isPositioned:!1})))},[h]);let j=Z.useRef(!1);o6(()=>(j.current=!0,()=>{j.current=!1}),[]),o6(()=>{if(_&&(C.current=_),w&&(S.current=w),_&&w){if(k.current)return k.current(_,w,D);D()}},[_,w,D,k,O]);let A=Z.useMemo(()=>({reference:C,floating:S,setReference:x,setFloating:b}),[x,b]),P=Z.useMemo(()=>({reference:_,floating:w}),[_,w]),F=Z.useMemo(()=>{let t={position:r,left:0,top:0};if(!P.floating)return t;let e=lt(P.floating,c.x),i=lt(P.floating,c.y);return o?{...t,transform:"translate("+e+"px, "+i+"px)",...o7(P.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:e,top:i}},[r,o,P.floating,c.x,c.y]);return Z.useMemo(()=>({...c,update:D,refs:A,elements:P,floatingStyles:F}),[c,D,A,P,F])}({...t,elements:{...n,...o&&{reference:o}}}),f=Z.useCallback(t=>{let e=oC(t)?{getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>t.getClientRects(),contextElement:t}:t;l(e),d.refs.setReference(e)},[d.refs]),g=Z.useCallback(t=>{(oC(t)||null===t)&&(c.current=t,a(t)),(oC(d.refs.reference.current)||null===d.refs.reference.current||null!==t&&!oC(t))&&d.refs.setReference(t)},[d.refs]),p=Z.useMemo(()=>({...d.refs,setReference:g,setPositionReference:f,domReference:c}),[d.refs,g,f]),m=Z.useMemo(()=>({...d.elements,domReference:h}),[d.elements,h]),y=Z.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)}),Z.useMemo(()=>({...d,context:y,refs:p,elements:m}),[d,p,m,y])}function hk(t,e,r){let i=new Map,n="item"===r,s=t;if(n&&t){let{[l$]:e,[l0]: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&&[l$,l0].includes(r)))if(0===r.indexOf("on")){if(i.has(r)||i.set(r,[]),"function"==typeof s){var a;null==(a=i.get(r))||a.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 hM(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=Z.useCallback(e=>hk(e,t,"reference"),e),s=Z.useCallback(e=>hk(e,t,"floating"),r),a=Z.useCallback(e=>hk(e,t,"item"),i);return Z.useMemo(()=>({getReferenceProps:n,getFloatingProps:s,getItemProps:a}),[n,s,a])}let hE=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function hD(t,e){var r,i;void 0===e&&(e={});let{open:n,elements:s,floatingId:a}=t,{enabled:o=!0,role:l="dialog"}=e,h=l3(),c=(null==(r=s.domReference)?void 0:r.id)||h,u=Z.useMemo(()=>{var t;return(null==(t=lU(s.floating))?void 0:t.id)||a},[s.floating,a]),d=null!=(i=hE.get(l))?i:l,f=null!=l8(),g=Z.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=Z.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=Z.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 Z.useMemo(()=>o?{reference:g,floating:p,item:m}:{},[o,g,p,m])}var hj=t.i(40141);function hA(t){return(0,hj.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 hP(t){return(0,hj.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 hF=t.i(11152);function hL(t){return(0,hj.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 hR(t){return(0,hj.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 hI(t){return(0,hj.GenIcon)({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M96 448h106.7V64H96v384zM309.3 64v384H416V64H309.3z"},child:[]}]})(t)}function hB(t){return(0,hj.GenIcon)({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M96 52v408l320-204L96 52z"},child:[]}]})(t)}function hN(t){return(0,hj.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 hW(t){return(0,hj.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 hU(t){return(0,hj.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 hH(t){return(0,hj.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 hX(t){return(0,hj.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 hV=Z.default.createContext(null);function hz(){let t=(0,Z.useContext)(hV);if(!t)throw Error("No WarriorContext.Provider");return t}hV.displayName="WarriorContext";let hY="undefined"!=typeof window&&window.document&&window.document.createElement?Z.useLayoutEffect:Z.useEffect,hG=(t,e)=>{let r=Z.useRef(!0);hY(()=>t(r.current),e),hY(()=>(r.current=!1,()=>{r.current=!0}),[])},hq=function(t){let e=Z.useRef();return e.current=t,Z.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)},[])},hK={},hQ=[];function hJ(t,e){}function hZ(t,e){}function h$(t,e,r){e||hK[r]||(t(!1,r),hK[r]=!0)}function h0(t,e){h$(hJ,t,e)}h0.preMessage=t=>{hQ.push(t)},h0.resetWarned=function(){hK={}},h0.noteOnce=function(t,e){h$(hZ,t,e)};let h1=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,a=i.has(e);if(h0(!a,"Warning: There may be circular references"),a)return!1;if(e===n)return!0;if(r&&s>1)return!1;i.add(e);let o=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],o))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],o))}return!1}(t,e)};var h2=t.i(43794);function h5(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 h4(t,e){return Array.isArray(t)?t[e]:t}let h3={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>=h3.F1&&e<=h3.F12)return!1;switch(e){case h3.ALT:case h3.CAPS_LOCK:case h3.CONTEXT_MENU:case h3.CTRL:case h3.DOWN:case h3.END:case h3.ESC:case h3.HOME:case h3.INSERT:case h3.LEFT:case h3.MAC_FF_META:case h3.META:case h3.NUMLOCK:case h3.NUM_CENTER:case h3.PAGE_DOWN:case h3.PAGE_UP:case h3.PAUSE:case h3.PRINT_SCREEN:case h3.RIGHT:case h3.SHIFT:case h3.UP:case h3.WIN_KEY:case h3.WIN_KEY_RIGHT:return!1;default:return!0}},isCharacterKey:function(t){if(t>=h3.ZERO&&t<=h3.NINE||t>=h3.NUM_ZERO&&t<=h3.NUM_MULTIPLY||t>=h3.A&&t<=h3.Z||-1!==window.navigator.userAgent.indexOf("WebKit")&&0===t)return!0;switch(t){case h3.SPACE:case h3.QUESTION_MARK:case h3.NUM_PLUS:case h3.NUM_MINUS:case h3.NUM_PERIOD:case h3.NUM_DIVISION:case h3.SEMICOLON:case h3.DASH:case h3.EQUALS:case h3.COMMA:case h3.PERIOD:case h3.SLASH:case h3.APOSTROPHE:case h3.SINGLE_QUOTE:case h3.OPEN_SQUARE_BRACKET:case h3.BACKSLASH:case h3.CLOSE_SQUARE_BRACKET:return!0;default:return!1}}},h9=Z.createContext({min:0,max:0,direction:"ltr",step:1,includedStart:0,includedEnd:0,tabIndex:0,keyboard:!0,styles:{},classNames:{}}),h6=Z.createContext({});function h8(){return(h8=Object.assign.bind()).apply(this,arguments)}let h7=Z.forwardRef((t,e)=>{let{prefixCls:r,value:i,valueIndex:n,onStartMove:s,onDelete:a,style:o,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}=Z.useContext(h9),D="".concat(r,"-handle"),j=t=>{b||s(t,n)},A=h5(x,i,m,y),P={};if(null!==n){var F;P={tabIndex:b?null:h4(C,n),role:"slider","aria-valuemin":m,"aria-valuemax":y,"aria-valuenow":i,"aria-disabled":b,"aria-label":h4(S,n),"aria-labelledby":h4(T,n),"aria-required":h4(O,n),"aria-valuetext":null==(F=h4(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 h3.LEFT:e="ltr"===x||"btt"===x?-1:1;break;case h3.RIGHT:e="ltr"===x||"btt"===x?1:-1;break;case h3.UP:e="ttb"!==x?1:-1;break;case h3.DOWN:e="ttb"!==x?-1:1;break;case h3.HOME:e="min";break;case h3.END:e="max";break;case h3.PAGE_UP:e=2;break;case h3.PAGE_DOWN:e=-2;break;case h3.BACKSPACE:case h3.DELETE:null==a||a(n)}null!==e&&(t.preventDefault(),u(e,n))}},onKeyUp:t=>{switch(t.which||t.keyCode){case h3.LEFT:case h3.RIGHT:case h3.UP:case h3.DOWN:case h3.HOME:case h3.END:case h3.PAGE_UP:case h3.PAGE_DOWN:null==d||d()}}}}let L=Z.createElement("div",h8({ref:e,className:(0,h2.default)(D,{["".concat(D,"-").concat(n+1)]:null!==n&&w,["".concat(D,"-dragging")]:h,["".concat(D,"-dragging-delete")]:c},E.handle),style:{...A,...o,...M.handle}},P,p));return l&&(L=l(L,{index:n,prefixCls:r,value:i,dragging:h,draggingDelete:c})),L});function ct(){return(ct=Object.assign.bind()).apply(this,arguments)}let ce=Z.forwardRef((t,e)=>{let{prefixCls:r,style:i,onStartMove:n,onOffsetChange:s,values:a,handleRender:o,activeHandleRender:l,draggingIndex:h,draggingDelete:c,onFocus:u,...d}=t,f=Z.useRef({}),[g,p]=Z.useState(!1),[m,y]=Z.useState(-1),x=t=>{y(t),p(!0)};Z.useImperativeHandle(e,()=>({focus:t=>{var e;null==(e=f.current[t])||e.focus()},hideHelp:()=>{(0,o9.flushSync)(()=>{p(!1)})}}));let b={prefixCls:r,onStartMove:n,onOffsetChange:s,render:o,onFocus:(t,e)=>{x(e),null==u||u(t)},onMouseEnter:(t,e)=>{x(e)},...d};return Z.createElement(Z.Fragment,null,a.map((t,e)=>{let r=h===e;return Z.createElement(h7,ct({ref:t=>{t?f.current[e]=t:delete f.current[e]},dragging:r,draggingDelete:r&&c,style:h4(i,e),key:e,value:t,valueIndex:e},b))}),l&&g&&Z.createElement(h7,ct({key:"a11y"},b,{value:a[m],valueIndex:null,dragging:-1!==h,draggingDelete:c,render:l,style:{pointerEvents:"none"},tabIndex:null,"aria-hidden":!0})))}),cr=t=>{let{prefixCls:e,style:r,children:i,value:n,onClick:s}=t,{min:a,max:o,direction:l,includedStart:h,includedEnd:c,included:u}=Z.useContext(h9),d="".concat(e,"-text"),f=h5(l,n,a,o);return Z.createElement("span",{className:(0,h2.default)(d,{["".concat(d,"-active")]:u&&h<=n&&n<=c}),style:{...f,...r},onMouseDown:t=>{t.stopPropagation()},onClick:()=>{s(n)}},i)},ci=t=>{let{prefixCls:e,marks:r,onClick:i}=t,n="".concat(e,"-mark");return r.length?Z.createElement("div",{className:n},r.map(t=>{let{value:e,style:r,label:s}=t;return Z.createElement(cr,{key:e,prefixCls:n,style:r,value:e,onClick:i},s)})):null},cn=t=>{let{prefixCls:e,value:r,style:i,activeStyle:n}=t,{min:s,max:a,direction:o,included:l,includedStart:h,includedEnd:c}=Z.useContext(h9),u="".concat(e,"-dot"),d=l&&h<=r&&r<=c,f={...h5(o,r,s,a),..."function"==typeof i?i(r):i};return d&&(f={...f,..."function"==typeof n?n(r):n}),Z.createElement("span",{className:(0,h2.default)(u,{["".concat(u,"-active")]:d}),style:f})},cs=t=>{let{prefixCls:e,marks:r,dots:i,style:n,activeStyle:s}=t,{min:a,max:o,step:l}=Z.useContext(h9),h=Z.useMemo(()=>{let t=new Set;if(r.forEach(e=>{t.add(e.value)}),i&&null!==l){let e=a;for(;e<=o;)t.add(e),e+=l}return Array.from(t)},[a,o,l,i,r]);return Z.createElement("div",{className:"".concat(e,"-step")},h.map(t=>Z.createElement(cn,{prefixCls:e,key:t,value:t,style:n,activeStyle:s})))},ca=t=>{let{prefixCls:e,style:r,start:i,end:n,index:s,onStartMove:a,replaceCls:o}=t,{direction:l,min:h,max:c,disabled:u,range:d,classNames:f}=Z.useContext(h9),g="".concat(e,"-track"),p=(i-h)/(c-h),m=(n-h)/(c-h),y=t=>{!u&&a&&a(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=o||(0,h2.default)(g,{["".concat(g,"-").concat(s+1)]:null!==s&&d,["".concat(e,"-track-draggable")]:a},f.track);return Z.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:a,range:o,min:l,styles:h,classNames:c}=Z.useContext(h9),u=Z.useMemo(()=>{if(!o){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,o,n,l]);if(!a)return null;let d=(null==u?void 0:u.length)&&(c.tracks||h.tracks)?Z.createElement(ca,{index:null,prefixCls:e,start:u[0].start,end:u[u.length-1].end,replaceCls:(0,h2.default)(c.tracks,"".concat(e,"-tracks")),style:h.tracks}):null;return Z.createElement(Z.Fragment,null,d,u.map((t,i)=>{let{start:n,end:a}=t;return Z.createElement(ca,{index:i,prefixCls:e,style:{...h4(r,i),...h.track},start:n,end:a,key:i,onStartMove:s})}))};function cl(t){let e="targetTouches"in t?t.targetTouches[0]:t;return{pageX:e.pageX,pageY:e.pageY}}let ch=function(t,e,r,i,n,s,a,o,l,h,c){let[u,d]=Z.useState(null),[f,g]=Z.useState(-1),[p,m]=Z.useState(!1),[y,x]=Z.useState(r),[b,_]=Z.useState(r),w=Z.useRef(null),C=Z.useRef(null),S=Z.useRef(null),{onDragStart:T,onDragChange:O}=Z.useContext(h6);hG(()=>{-1===f&&x(r)},[r,f]),Z.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)),a(i),O&&O({rawValues:t,deleteIndex:r?f:-1,draggingIndex:f,draggingValue:e})},M=hq((t,e,r)=>{if(-1===t){let t=b[0],r=b[b.length-1],a=e*(n-i);a=Math.min(a=Math.max(a,i-t),n-r),a=s(t+a)-t,k(b.map(t=>t+a))}else{let s=[...y];s[t]=b[t];let a=l(s,(n-i)*e,t,"dist");k(a.values,a.value,r)}});return[f,u,p,Z.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 a=s||r,l=a[n];g(n),d(l),_(a),x(a),m(!1);let{pageX:u,pageY:f}=cl(i),p=!1;T&&T({rawValues:a,draggingIndex:n,draggingValue:l});let b=r=>{let i,s;r.preventDefault();let{pageX:a,pageY:o}=cl(r),l=a-u,d=o-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,o(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}]},cc=Z.forwardRef((t,e)=>{let{prefixCls:r="rc-slider",className:i,style:n,classNames:s,styles:a,id:o,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:z}=t,Y=Z.useRef(null),G=Z.useRef(null),q=Z.useMemo(()=>M?k?"ttb":"btt":k?"rtl":"ltr",[k,M]),[K,Q,J,$,tt]=function(t){return(0,Z.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=Z.useMemo(()=>isFinite(f)?f:0,[f]),tr=Z.useMemo(()=>isFinite(g)?g:100,[g]),ti=Z.useMemo(()=>null!==p&&p<=0?1:p,[p]),tn=Z.useMemo(()=>"boolean"==typeof O?!!O&&ti:O>=0&&O,[O,ti]),ts=Z.useMemo(()=>Object.keys(R||{}).map(t=>{let e=R[t],r={value:Number(t)};return e&&"object"==typeof e&&!Z.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]),[ta,to]=function(t,e,r,i,n,s){let a=Z.useCallback(r=>Math.max(t,Math.min(e,r)),[t,e]),o=Z.useCallback(i=>{if(null!==r){let n=t+Math.round((a(i)-t)/r)*r,s=t=>(String(t).split(".")[1]||"").length,o=Math.max(s(r),s(e),s(t)),l=Number(n.toFixed(o));return t<=l&&l<=e?l:null}return null},[r,t,e,a]),l=Z.useCallback(n=>{let s=a(n),l=i.map(t=>t.value);null!==r&&l.push(o(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,a,o]),h=function(n,s,a){let l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit";if("number"==typeof s){let c,u=n[a],d=u+s,f=[];i.forEach(t=>{f.push(t.value)}),f.push(t,e),f.push(o(u));let g=s>0?1:-1;"unit"===l?f.push(o(u+g*r)):f.push(o(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[a]=c,h(t,s-g,a,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",a=t.map(l),o=a[r],d=h(a,e,r,i);if(a[r]=d,!1===n){let t=s||0;r>0&&a[r-1]!==o&&(a[r]=Math.max(a[r],a[r-1]+t)),r<a.length-1&&a[r+1]!==o&&(a[r]=Math.min(a[r],a[r+1]-t))}else if("number"==typeof s||null===s){for(let t=r+1;t<a.length;t+=1){let e=!0;for(;u(a[t]-a[t-1])&&e;)({value:a[t],changed:e}=c(a,1,t))}for(let t=r;t>0;t-=1){let e=!0;for(;u(a[t]-a[t-1])&&e;)({value:a[t-1],changed:e}=c(a,-1,t-1))}for(let t=a.length-1;t>0;t-=1){let e=!0;for(;u(a[t]-a[t-1])&&e;)({value:a[t-1],changed:e}=c(a,-1,t-1))}for(let t=0;t<a.length-1;t+=1){let e=!0;for(;u(a[t+1]-a[t])&&e;)({value:a[t+1],changed:e}=c(a,1,t+1))}}return{value:a[r],values:a}}]}(te,tr,ti,ts,T,tn),[tl,th]=function(t,e){let[r,i]=(0,Z.useState)(t),n=void 0!==e?e:r;return hG(t=>{t||i(e)},[e]),[n,i]}(y,m),tc=Z.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]=ta(t)}),r},[tl,K,te,b,ta]),tu=t=>K?t:t[0],td=hq(t=>{let e=[...t].sort((t,e)=>t-e);_&&!h1(e,tc,!0)&&_(tu(e)),th(e)}),tf=hq(t=>{t&&Y.current.hideHelp();let e=tu(tc);null==C||C(e),h0(!C,"[rc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead."),null==S||S(e)}),[tg,tp,tm,tv,ty]=ch(G,q,tc,te,tr,ta,td,tf,to,Q,$),tx=(t,e)=>{if(!l){let n=[...tc],s=0,a=0,o=tr-te;tc.forEach((e,r)=>{let i=Math.abs(t-e);i<=o&&(o=i,s=r),e<t&&(a=r)});let l=s;Q&&0!==o&&(!tt||tc.length<tt)?(n.splice(a+1,0,t),l=a+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),Y.current.focus(l),ty(e,l,n)}else null==C||C(h),h0(!C,"[rc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead."),null==S||S(h)}},[tb,t_]=Z.useState(null);Z.useEffect(()=>{if(null!==tb){let t=tc.indexOf(tb);t>=0&&Y.current.focus(t)}t_(null)},[tb]);let tw=Z.useMemo(()=>(!J||null!==ti)&&J,[J,ti]),tC=hq((t,e)=>{ty(t,e),null==w||w(tu(tc))}),tS=-1!==tg;Z.useEffect(()=>{if(!tS){let t=tc.lastIndexOf(tp);Y.current.focus(t)}},[tS]);let tT=Z.useMemo(()=>[...tv].sort((t,e)=>t-e),[tv]),[tO,tk]=Z.useMemo(()=>K?[tT[0],tT[tT.length-1]]:[te,tT[0]],[tT,K,te]);Z.useImperativeHandle(e,()=>({focus:()=>{Y.current.focus(0)},blur:()=>{var t;let{activeElement:e}=document;(null==(t=G.current)?void 0:t.contains(e))&&(null==e||e.blur())}})),Z.useEffect(()=>{c&&Y.current.focus(0)},[]);let tM=Z.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:z,styles:a||{},classNames:s||{}}),[te,tr,q,l,h,ti,E,tO,tk,K,U,H,X,V,z,a,s]);return Z.createElement(h9.Provider,{value:tM},Z.createElement("div",{ref:G,className:(0,h2.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:a,right:o}=G.current.getBoundingClientRect(),{clientX:l,clientY:h}=t;switch(q){case"btt":e=(a-h)/i;break;case"ttb":e=(h-s)/i;break;case"rtl":e=(o-l)/r;break;default:e=(l-n)/r}tx(ta(te+e*(tr-te)),t)},id:o},Z.createElement("div",{className:(0,h2.default)("".concat(r,"-rail"),null==s?void 0:s.rail),style:{...P,...null==a?void 0:a.rail}}),!1!==W&&Z.createElement(co,{prefixCls:r,style:j,values:tc,startPoint:D,onStartMove:tw?tC:void 0}),Z.createElement(cs,{prefixCls:r,marks:ts,dots:I,style:F,activeStyle:L}),Z.createElement(ce,{ref:Y,prefixCls:r,style:A,values:tv,draggingIndex:tg,draggingDelete:tm,onStartMove:tC,onOffsetChange:(t,e)=>{if(!l){let r=to(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);Y.current.hideHelp(),Y.current.focus(r)}:void 0}),Z.createElement(ci,{prefixCls:r,marks:ts,onClick:tx})))}),cu={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 cd(t){return(0,J.jsx)(cc,{...t,styles:{...cu,...t.styles}})}let cf=t.i(29947).default,{materials:cg}=cf;function cp(){var t;let e=(0,Z.useRef)(null),r=(0,Z.useRef)(null),[i,n]=(0,Z.useState)("vl2"),{activeCanvas:s,backgroundColor:a,setBackgroundColor:o,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}=a1(),{actualModel:X}=hz(),V=cg[X],{canvas:z,isDrawingMode:Y,setDrawingMode:G}=a$(s),[q,K]=(0,Z.useState)(!1),Q=q?"⌘":"Ctrl ",[$,tt]=(0,Z.useState)(!1),{refs:te,floatingStyles:tr,context:ti}=hO({open:$,onOpenChange:tt,placement:"bottom-end",middleware:[li(),lr(10)],whileElementsMounted:o3}),tn=h_(ti),ts=hT(ti),ta=hD(ti);(0,Z.useEffect)(()=>{$&&G(!0)},[$,G]);let{getReferenceProps:to,getFloatingProps:tl}=hM([tn,ts,ta]),[th,tc]=(0,Z.useState)(!1),{refs:tu,floatingStyles:td,context:tf}=hO({open:th,onOpenChange:tc,placement:"bottom-end",middleware:[li(),lr(10)],whileElementsMounted:o3}),tg=h_(tf),{getReferenceProps:tp,getFloatingProps:tm}=hM([tg,hT(tf),hD(tf)]),[tv,ty]=(0,Z.useState)(!1),{refs:tx,floatingStyles:tb,context:t_}=hO({open:tv,onOpenChange:ty,placement:"bottom-end",middleware:[li(),lr(10)],whileElementsMounted:o3}),tw=h_(t_),{getReferenceProps:tC,getFloatingProps:tS}=hM([tw,hT(t_),hD(t_)]),tT=!!l.length&&l.every(t=>h.has(t)),tO=l.length>0,tk=l.filter(t=>t instanceof at).length>0,tM=t=>{o(t.target.value)};return(0,Z.useEffect)(()=>{try{let t=localStorage.getItem("exportFileType");switch(t){case"vl2":case"png":n(t)}}catch(t){}},[]),(0,Z.useEffect)(()=>{navigator.platform&&navigator.platform.startsWith("Mac")?K(!0):navigator.userAgent.match(/\(Macintosh;/)&&K(!0)},[]),(0,J.jsxs)("div",{className:"CanvasTools",children:[(0,J.jsxs)("div",{className:"CanvasBackgroundColor",children:[(0,J.jsx)("input",{className:"ColorSwatch",type:"radio",name:"backgroundColor",id:"canvasBackgroundColorBlack",value:"black",checked:"black"===a,onChange:tM}),(0,J.jsx)("label",{htmlFor:"canvasBackgroundColorBlack",children:(0,J.jsx)("span",{className:"HiddenLabel",children:"Black"})}),(0,J.jsx)("input",{className:"ColorSwatch",type:"radio",name:"backgroundColor",id:"canvasBackgroundColorMagenta",value:"magenta",checked:"magenta"===a,onChange:tM}),(0,J.jsx)("label",{htmlFor:"canvasBackgroundColorMagenta",children:(0,J.jsx)("span",{className:"HiddenLabel",children:"Magenta"})}),(0,J.jsx)("input",{className:"ColorSwatch",type:"radio",name:"backgroundColor",id:"canvasBackgroundColorWhite",value:"white",checked:"white"===a,onChange:tM}),(0,J.jsx)("label",{htmlFor:"canvasBackgroundColorWhite",children:(0,J.jsx)("span",{className:"HiddenLabel",children:"White"})})]}),(0,J.jsxs)("div",{className:"Buttons",children:["metallic"===B?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("div",{className:"ButtonGroup",children:[(0,J.jsx)("button",{className:"ButtonGroup",type:"button","data-active":Y?void 0:"","aria-label":"Select Mode",title:"Select Mode (S)",onClick:()=>{G(!1)},children:(0,J.jsx)(hL,{})}),(0,J.jsx)("button",{className:"ButtonGroup",type:"button","data-active":Y?"":void 0,"aria-label":"Paint Mode",title:"Paint Mode (P)",ref:te.setReference,...to(),children:(0,J.jsx)(hR,{})})]}),$?(0,J.jsx)(hx,{context:ti,modal:!1,children:(0,J.jsx)("div",{className:"BrushToolsPopup",ref:te.setFloating,style:tr,...tl(),children:(0,J.jsxs)("div",{className:"Fields",children:[(0,J.jsxs)("div",{className:"Field",children:[(0,J.jsx)("label",{children:"Metallic Amount"}),(0,J.jsx)("div",{className:"SliderContainer",children:(0,J.jsx)(cd,{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,J.jsxs)("div",{className:"Field",children:[(0,J.jsx)("label",{children:"Brush Size"}),(0,J.jsx)("div",{className:"SliderContainer",children:(0,J.jsx)(cd,{min:1,max:50,value:S,onChange:t=>{Array.isArray(t)&&(t=t[0]),T(t)}})})]})]})})}):null]}):null,(0,J.jsxs)(J.Fragment,{children:[(0,J.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,J.jsx)("button",{type:"button","aria-label":"Add Image",title:"Add Image",onClick:()=>{r.current&&r.current.click()},children:(0,J.jsx)(hX,{style:{fontSize:14}})}),(0,J.jsx)("button",{type:"button","data-active":th?"":void 0,"aria-label":"Filters",title:"Filters",disabled:tO&&!tk,ref:tu.setReference,...tp(),children:(0,J.jsx)(hU,{})}),th?(0,J.jsx)(hx,{context:tf,modal:!1,children:(0,J.jsx)("div",{className:"BrushToolsPopup",ref:tu.setFloating,style:td,...tm(),children:(0,J.jsxs)("div",{className:"Fields",children:[(0,J.jsxs)("div",{className:"Field ApplyTo",children:[(0,J.jsx)("label",{children:"Layer:"}),(0,J.jsx)("ul",{children:l.length?(0,J.jsxs)("li",{children:[(0,J.jsx)("input",{type:"radio",name:"FilterLayer",value:"SelectedLayer",id:"FilterLayer-SelectedLayer",checked:"SelectedLayer"===R,onChange:()=>{I("SelectedLayer")}}),(0,J.jsxs)("label",{htmlFor:"FilterLayer-SelectedLayer",children:["selected (",l.length.toLocaleString(),")"]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("li",{children:[(0,J.jsx)("input",{type:"radio",name:"FilterLayer",value:"BaseLayer",id:"FilterLayer-BaseLayer",checked:"BaseLayer"===R,onChange:()=>{I("BaseLayer")}})," ",(0,J.jsx)("label",{htmlFor:"FilterLayer-BaseLayer",children:"base"})]}),(0,J.jsxs)("li",{children:[(0,J.jsx)("input",{type:"radio",name:"FilterLayer",value:"AllLayers",id:"FilterLayer-AllLayers",checked:"AllLayers"===R,onChange:()=>{I("AllLayers")}}),(0,J.jsxs)("label",{htmlFor:"FilterLayer-AllLayers",children:["all (",null!=(t=null==z?void 0:z._objects.filter(t=>t instanceof at).length.toLocaleString())?t:0,")"]})]})]})})]}),"color"===B?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("div",{className:"Field",children:[(0,J.jsxs)("label",{children:["Hue:"," ",(0,J.jsx)("strong",{children:null==O?"MULTIPLE VALUES":(0,J.jsxs)(J.Fragment,{children:[Math.round(180*O),"°"]})})]}),(0,J.jsx)("div",{className:"SliderContainer",children:(0,J.jsx)(cd,{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,J.jsxs)("div",{className:"Field",children:[(0,J.jsxs)("label",{children:["Saturation:"," ",(0,J.jsx)("strong",{children:null==M?"MULTIPLE VALUES":"".concat(Math.round(100*M+100),"%")})]}),(0,J.jsx)("div",{className:"SliderContainer",children:(0,J.jsx)(cd,{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,J.jsxs)("div",{className:"Field",children:[(0,J.jsxs)("label",{children:["Brightness:"," ",(0,J.jsx)("strong",{children:null==D?"MULTIPLE VALUES":"".concat(Math.round(100*D+100),"%")})]}),(0,J.jsx)("div",{className:"SliderContainer",children:(0,J.jsx)(cd,{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,J.jsxs)("div",{className:"Field",children:[(0,J.jsxs)("label",{children:["Contrast:"," ",(0,J.jsx)("strong",{children:null==A?"MULTIPLE VALUES":"".concat(Math.round(100*A+100),"%")})]}),(0,J.jsx)("div",{className:"SliderContainer",children:(0,J.jsx)(cd,{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,J.jsxs)("div",{className:"Field",children:[(0,J.jsxs)("label",{children:["Opacity:"," ",(0,J.jsx)("strong",{children:null==F?"MULTIPLE VALUES":"".concat(Math.round((null!=F?F:1)*100),"%")})]}),(0,J.jsx)("div",{className:"SliderContainer",children:(0,J.jsx)(cd,{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,J.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,J.jsx)(hF.FaUnlock,{style:{fontSize:14}}):(0,J.jsx)(hF.FaLock,{style:{fontSize:14}})}),(0,J.jsxs)("div",{className:"ButtonGroup",children:[(0,J.jsx)("button",{type:"button","aria-label":"Bring Forward",title:"Bring Forward (F)",onClick:d,disabled:!tO,children:(0,J.jsx)(hF.FaArrowUp,{})}),(0,J.jsx)("button",{type:"button","aria-label":"Send Backward",title:"Send Backward (B)",onClick:f,disabled:!tO,children:(0,J.jsx)(hF.FaArrowDown,{})})]}),(0,J.jsx)("button",{type:"button","aria-label":"Duplicate",title:"Duplicate (D)",onClick:g,disabled:!tO,children:(0,J.jsx)(hA,{})}),(0,J.jsx)("button",{type:"button","aria-label":"Delete",title:"Delete (Backspace)",onClick:p,disabled:tT||!tO,children:(0,J.jsx)(hF.FaTrashAlt,{})}),(0,J.jsxs)("div",{className:"ButtonGroup",children:[(0,J.jsx)("button",{type:"button","aria-label":"Undo",title:"Undo (".concat(Q,"Z)"),onClick:m,disabled:!x,children:(0,J.jsx)(hN,{})}),(0,J.jsx)("button",{type:"button","aria-label":"Redo",title:"Redo (".concat(q?"".concat("⇧").concat(Q,"Z)"):"".concat(Q," Y"),")"),onClick:y,disabled:!b,children:(0,J.jsx)(hW,{})})]}),"color"===B?(0,J.jsxs)("button",{type:"button",className:"MetallicButton","aria-label":"Copy to Metallic",title:"Copy to Metallic",onClick:_,children:[(0,J.jsx)(hP,{})," ",(0,J.jsx)("span",{className:"ButtonLabel",children:"Metal"})]}):null]})]}),(0,J.jsxs)("div",{className:"Export",children:[(0,J.jsx)("input",{ref:e,type:"text",name:"CustomSkinName",placeholder:"Skin Name",size:12}),(0,J.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,J.jsx)(hF.FaAngleDown,{})]}),tv?(0,J.jsx)(hx,{context:t_,modal:!1,children:(0,J.jsx)("div",{className:"ExportOptionsPopup",ref:tx.setFloating,style:tb,...tS(),children:(0,J.jsxs)("div",{className:"Fields",children:[(0,J.jsxs)("div",{className:"Field",children:[(0,J.jsx)("label",{children:"Export Materials"}),(0,J.jsx)("ul",{className:"ExportOptionsList",children:V.map((t,e)=>t&&!1!==t.selectable&&!t.hidden?(0,J.jsxs)("li",{children:[(0,J.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,J.jsx)("label",{htmlFor:"MaterialSelect-".concat(t.name),children:t.label})]},t.name):null)})]}),(0,J.jsxs)("div",{className:"Field",children:[(0,J.jsx)("label",{htmlFor:"ExportFormat",children:"Export Format"}),(0,J.jsxs)("select",{id:"ExportFormat",value:i,onChange:t=>{n(t.target.value);try{localStorage.setItem("exportFileType",t.target.value)}catch(t){}},children:[(0,J.jsx)("option",{value:"png",children:".png"}),(0,J.jsx)("option",{value:"vl2",children:".vl2"})]})]})]})})}):null,(0,J.jsx)("button",{type:"button",onClick:()=>{W({name:e.current?e.current.value:"",format:i})},children:"Export"})]})]})}function cm(){return(0,J.jsxs)("footer",{className:"AppFooter",children:[(0,J.jsx)("a",{href:"https://github.com/exogen/t2-model-skinner",className:"IconLink",children:(0,J.jsx)(hF.FaGithub,{size:24})}),(0,J.jsxs)("div",{className:"Sponsor",children:[(0,J.jsx)("a",{href:"https://github.com/sponsors/exogen",target:"_blank",rel:"noreferrer",children:"Support this project"})," ",(0,J.jsx)("span",{className:"Separator",children:"or"})," ",(0,J.jsx)("a",{href:"https://www.buymeacoffee.com/mosswood",target:"_blank",rel:"noreferrer",children:(0,J.jsx)("img",{src:"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png",alt:"Buy Me A Coffee",width:109,height:31})})]})]})}async function cv(t){return await at.fromURL(t,{crossOrigin:"anonymous"})}var cy=t.i(55519);function cx(){let e=(0,Z.useRef)(null),r=(0,Z.useRef)(null),i=(0,Z.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,Z.useEffect)(()=>{let i=new Worker(t.r(79702)),n=cy.wrap(i);return e.current=i,r.current=n,()=>{n[cy.releaseProxy](),r.current=null,i.terminate()}},[]),i}function cb(){return{canvasPadding:64,basePath:"/t2-model-skinner"}}var c_=t.i(54826);let{materials:cw}=cf,cC=[512,512];function cS(e){var r,i;let{children:n}=e,{actualModel:s,selectedModelType:a}=hz(),[o,l]=(0,Z.useState)(0),[h,c]=(0,Z.useState)(0),[u,d]=(0,Z.useState)(1),f=cw[s],g=null!=(r=f[o])?r:null,p=null!=(i=g.frameCount)?i:1,m=p>1,[y,x]=(0,Z.useState)([]),b=(0,Z.useMemo)(()=>{var t;let[e,r]=null!=(t=g.size)?t:cC;return[e*u,r*u]},[g.size,u]),_=0!==g.metallicFactor||1!==g.roughnessFactor,[w,C]=(0,Z.useState)("color");_||"metallic"!==w||C("color"),h>=p&&c(0),(0,Z.useEffect)(()=>{try{let t=localStorage.getItem("sizeMultiplier");switch(t){case"1":case"2":case"4":d(+t)}}catch(t){}},[]),(0,Z.useEffect)(()=>{x(f.map(t=>!!(t&&!1!==t.selectable&&!t.hidden)))},[f]),(0,Z.useEffect)(()=>{c(0)},[g]);let[S,T]=(0,Z.useState)("black"),[O,k]=(0,Z.useState)(()=>new Set),[M,E]=(0,Z.useState)(200),[D,j]=(0,Z.useState)(10),[A,P]=(0,Z.useState)(()=>new Map),[F,L]=(0,Z.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}=a$(),{canvas:N,notifyChange:W,undo:U,redo:H,canUndo:X,canRedo:V}=a$(R),{canvas:z,setDrawingMode:Y}=a$(I),{combineColorAndAlphaImageUrls:G}=cx(),{canvasPadding:q}=cb(),[K,Q]=(0,Z.useState)(()=>[]),[$,tt]=(0,Z.useState)("BaseLayer");F.length?"SelectedLayer"!==$&&tt("SelectedLayer"):"SelectedLayer"===$&&tt("BaseLayer");let te=(0,Z.useCallback)((t,e)=>{var r,i,n;let s=[],a=new Map(A),o=F;for(let l of("AllLayers"===$?o=null!=(r=null==N?void 0:N._objects)?r:[]:"BaseLayer"===$&&(o=null!=(i=null==N?void 0:N._objects.slice(0,1))?i:[]),o))if(l instanceof at){let r={...null!=(n=A.get(l))?n:{},[t]:e};a.set(l,r),s.push([l,r])}P(a),Q(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 at)).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,ta]=tr("Saturation"),[to,tl]=tr("Brightness"),[th,tc]=tr("Contrast"),[tu,td]=tr("Opacity");(0,Z.useEffect)(()=>{if(K.length){for(let[t,e]of K)if(t instanceof at){if(t.filters=[],"metallic"===w){let e=new aJ.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 aJ.HueRotation({rotation:i}));break;case"Saturation":t.filters.push(new aJ.Saturation({saturation:i}));break;case"Brightness":t.filters.push(new aJ.Brightness({brightness:i}));break;case"Contrast":t.filters.push(new aJ.Contrast({contrast:i}));break;case"Opacity":t.opacity=i}}t.applyFilters()}Q([]),W&&W()}},[K,w,W]);let tf=(0,Z.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,Z.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,Z.useCallback)(async()=>{let t=N.getActiveObject();t&&(N.bringObjectForward(t,!0),W())},[N,W]),tm=(0,Z.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,Z.useCallback)(async t=>{let e;for(let r of t){let t=await cv(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 aJ.Grayscale;t.filters.push(e),t.applyFilters()}z&&Y(!1),N.centerObject(t),N.add(t),e=t}e&&(N.setActiveObject(e),N.requestRenderAll())},[b,w,z,N,Y]),ty=(0,Z.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,Z.useCallback)(async()=>{let t=N.getActiveObjects();N.discardActiveObject(),N.remove(...t),N.requestRenderAll()},[N]),tb=(0,Z.useCallback)(async()=>{if("color"===w&&z){let t=N.toDataURL({format:"png",multiplier:1,top:q,left:q,width:b[0],height:b[1]}),e=await cv(t);e.filters||(e.filters=[]);let r=new aJ.Grayscale;e.filters.push(r),e.applyFilters(),z.centerObject(e),z.add(e),z.setActiveObject(e),Y(!1),C("metallic")}},[z,N,w,q,Y,b]),t_=(0,Z.useCallback)(async e=>{let{format:r,name:i=""}=e,{savePngFile:n,saveZipFile:o,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 o,l,h,c;let d,f,g=null==(o=B["".concat(t.name,":color:").concat(n,":").concat(u)])?void 0:o.canvas,p=null==(l=B["".concat(t.name,":metallic:").concat(n,":").concat(u)])?void 0:l.canvas,m=null!=(h=t.size)?h:cC,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(a){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"===a?"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,c_.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(a){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 o(t,r)}}},[f,y,B,u,q,a,G,s]),tw=(0,Z.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:ta,brightness:to,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:o,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,ta,to,tl,th,tc,tu,td,$,F,tf,tg,tp,tm,tv,ty,tx,U,H,X,V,tb,t_,o,b,_,h,m,p,u,y]);return(0,Z.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,Z.useEffect)(()=>{z&&(z.freeDrawingBrush||(z.freeDrawingBrush=new sb(z)),z.freeDrawingBrush.width=D)},[z,D]),(0,Z.useEffect)(()=>{z&&(z.freeDrawingBrush||(z.freeDrawingBrush=new sb(z)),z.freeDrawingBrush.color="rgb(".concat(M,", ").concat(M,", ").concat(M,")"))},[z,M]),(0,J.jsx)(a0.Provider,{value:tw,children:n})}function cT(){let{backgroundColor:t,textureSize:e}=a1(),{canvasPadding:r}=cb();return e?(0,J.jsx)("div",{className:"CanvasBackdrop",style:{backgroundColor:t,top:r,width:e[0],height:e[1]}}):null}function cO(t){let{children:e}=t,[r,i]=(0,Z.useState)({}),n=(0,Z.useCallback)((t,e)=>{i(r=>({...r,[t]:e}))},[]),s=(0,Z.useCallback)(t=>{i(e=>{let{[t]:r,...i}=e;return i})},[]),a=(0,Z.useMemo)(()=>({canvases:r,registerCanvas:n,unregisterCanvas:s}),[r,n,s]);return(0,J.jsx)(aZ.Provider,{value:a,children:e})}function ck(t){let{children:e}=t,r=(0,Z.useRef)(null),{activeCanvas:i,activeCanvasType:n,bringForward:s,sendBackward:a,duplicate:o,deleteSelection:l,addImages:h,undo:c,redo:u}=a1(),{canvas:d,notifyChange:f,setDrawingMode:g}=a$(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,J.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 o();break;case"f":t.preventDefault(),await s();break;case"b":t.preventDefault(),await a();break;case"p":"metallic"===n&&(t.preventDefault(),g(!0));break;case"s":"metallic"===n&&(t.preventDefault(),g(!1))}}},children:e})}function cM(){let{activeCanvasType:t,setActiveCanvasType:e,hasMetallic:r,hasAnimation:i,frameCount:n,selectedFrameIndex:s,setSelectedFrameIndex:a,sizeMultiplier:o,setSizeMultiplier:l}=a1();return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("div",{className:"CanvasToggle",children:[(0,J.jsx)("button",{type:"button","data-selected":"color"===t?"":void 0,onClick:()=>{e("color")},children:"Color"}),r?(0,J.jsx)("button",{type:"button","data-selected":"metallic"===t?"":void 0,onClick:()=>{e("metallic")},children:"Metallic"}):null]}),(0,J.jsxs)("div",{className:"CanvasToggle",style:{display:"none"},children:[(0,J.jsx)("button",{type:"button","data-selected":1===o?"":void 0,onClick:()=>{l(1)},children:"1×"}),(0,J.jsx)("button",{type:"button","data-selected":2===o?"":void 0,onClick:()=>{l(2)},children:"2×"}),(0,J.jsx)("button",{type:"button","data-selected":4===o?"":void 0,onClick:()=>{l(4)},children:"4×"})]}),i?(0,J.jsxs)("div",{className:"FrameSelector",children:[(0,J.jsx)("button",{type:"button",onClick:()=>{a(t=>(n+t-1)%n)},children:(0,J.jsx)(hF.FaChevronLeft,{})}),(0,J.jsxs)("span",{className:"FrameInfo",children:[s+1," / ",n]}),(0,J.jsx)("button",{type:"button",onClick:()=>{a(t=>(t+1)%n)},children:(0,J.jsx)(hF.FaChevronRight,{})})]}):null]})}function cE(t){return(0,hj.GenIcon)({tag:"svg",attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M1 2a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1zM1 7a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1zM1 12a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1zm5 0a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1z"},child:[]}]})(t)}var cD=t.i(71315);let cj=cf.materials,cA=/^(\.|__MACOSX)/;async function cP(t){let e=await cD.default.loadAsync(t);return(await Promise.all(Object.entries(e.files).map(async t=>{let[e,r]=t;if(!cA.test(e)&&/\.png$/i.exec(e)){let t=await r.async("base64");return{path:e,imageUrl:"data:image/png;base64,".concat(t)}}}))).filter(t=>!!t)}async function cF(t){return new Promise((e,r)=>{let i=new FileReader;i.addEventListener("load",t=>{var i;"string"==typeof(null==(i=t.target)?void 0:i.result)?e(t.target.result):r()}),i.addEventListener("error",t=>{r()}),i.readAsDataURL(t)})}async function cL(t){return(await Promise.all(Array.from(t).map(async t=>{var e;if(cA.test(t.name))return null;switch((e=t).name.match(/\.png$/i)?"png":e.name.match(/\.zip$/i)?"zip":e.name.match(/\.vl2$/i)?"vl2":void 0){case"zip":case"vl2":{let e=t.name.match(/^(.+)\.(zip|vl2)$/i),r=e?e[1]:t.name;return(await cP(t)).map(e=>({...e,path:"".concat(t.name,"/").concat(e.path),name:r}))}case"png":return{path:t.name,imageUrl:await cF(t),name:null};default:return null}}))).flat().filter(t=>!!t)}async function cR(t){var e=await cL(t);let r=new Map;return e.forEach(t=>{let e=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;s||(s=function(){let t=new Map;for(let e in cj)cj[e].forEach((r,i)=>{let n;if(r.fileSuffix?n=r.fileSuffix:!1!==r.selectable&&!0!==r.hidden&&(r.file||r.name)&&(n=r.file||r.name),n){var s;let a=null!=(s=t.get(n))?s:[];a.push({modelName:e,material:r,index:i}),t.set(n,a)}});return t}());let r=t.split("/").slice(-1)[0],i=r.match(/^(.+)\.(PNG|png)$/);if(i){let n=i[1],a=n.split(".");if(a.length>1){let e=".".concat(a[a.length-1]),o=s.get(e);if(o)return{path:t,basename:r,nameWithoutExtension:n,extension:i[2],skinName:a.slice(0,a.length-1).join("."),models:o}}else{let o=function(t){let e=/^(.+[^\d])(\d{2,})$/.exec(t);if(e){var r;let t=e[1],i=e[2],n=parseInt(i,10),a="".concat(t).concat("0".padStart(i.length,"0"));return(null!=(r=s.get(a))?r:[]).filter(t=>"number"==typeof t.material.frameCount).map(t=>({...t,frameIndex:n}))}return[]}(a[0]);if(o.length)return{path:t,basename:r,nameWithoutExtension:n,extension:i[2],skinName:e,models:o};{let o=s.get(a[0]);if(o)return{path:t,basename:r,nameWithoutExtension:n,extension:i[2],skinName:e,models:o}}}}return null}(t.path,t.name);e&&e.models.forEach(i=>{var n,s,a,o,l;let h=null!=(n=r.get(i.modelName))?n:new Map,c=null!=(s=h.get(e.skinName))?s:{name:e.skinName,isComplete:null,materials:new Map},u=null!=(a=i.material.file)?a:i.material.name,d=null!=(o=c.materials.get(u))?o:[];d[null!=(l=i.frameIndex)?l:0]=t.imageUrl,c.materials.set(u,d),h.set(e.skinName,c),r.set(i.modelName,h)})}),r.forEach((t,e)=>{let r=cj[e].filter(t=>!1!==t.selectable&&!0!==t.hidden&&!0!==t.optional);t.forEach(t=>{t.isComplete=r.every(e=>{var r;return t.materials.has(null!=(r=e.file)?r:e.name)})})}),r}var cI=t.i(15768);let{defaultSkins:cB,modelDefaults:cN}=cf,cW={},cU=new Map;function cH(){var t,e,r,i,n,s;let{selectedModel:a,setSelectedModel:o,selectedModelType:l,setSelectedModelType:h,selectedSkin:c,setSelectedSkin:u,setSelectedSkinType:d,actualModel:f,setSelectedAnimation:g,setAnimationPaused:p,importedSkins:m,addImportedSkins:y}=hz(),{setSelectedMaterialIndex:x}=a1(),[b,_]=(0,Z.useState)(cW),[w,C]=(0,Z.useState)(cW),[S,T]=(0,Z.useState)(null),O=(0,Z.useRef)(null),[k,M]=(0,cI.default)(),E=Array.from((null!=(s=m.get(f))?s:cU).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,J.jsxs)("div",{className:"Toolbar",children:[(0,J.jsxs)("div",{className:"Field",children:[(0,J.jsx)("label",{htmlFor:"ModelSelect",children:"Model"}),(0,J.jsxs)("select",{id:"ModelSelect",value:a,onChange:t=>{var e,r,i,n;let s=t.target.selectedOptions[0].parentNode,a=t.target.value,l="hfemale"===a?"hmale":a,{modelType:f}=s.dataset;if(!f)throw Error("No data-model-type found");let m=c&&((null==(e=cB[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),o(a),x(0),m||(u(null!=(n=cN[l])?n:null),d("default")),y||T(null)},children:[(0,J.jsxs)("optgroup",{label:"Players","data-model-type":"player",children:[(0,J.jsx)("option",{value:"lmale",children:"Human Male • Light"}),(0,J.jsx)("option",{value:"mmale",children:"Human Male • Medium"}),(0,J.jsx)("option",{value:"hmale",children:"Human Male • Heavy"}),(0,J.jsx)("option",{value:"lfemale",children:"Human Female • Light"}),(0,J.jsx)("option",{value:"mfemale",children:"Human Female • Medium"}),(0,J.jsx)("option",{value:"hfemale",children:"Human Female • Heavy"}),(0,J.jsx)("option",{value:"lbioderm",children:"Bioderm • Light"}),(0,J.jsx)("option",{value:"mbioderm",children:"Bioderm • Medium"}),(0,J.jsx)("option",{value:"hbioderm",children:"Bioderm • Heavy"})]}),(0,J.jsxs)("optgroup",{label:"Weapons","data-model-type":"weapon",children:[(0,J.jsx)("option",{value:"disc",children:"Disc Launcher"}),(0,J.jsx)("option",{value:"chaingun",children:"Chaingun"}),(0,J.jsx)("option",{value:"grenade_launcher",children:"Grenade Launcher"}),(0,J.jsx)("option",{value:"sniper",children:"Laser Rifle"}),(0,J.jsx)("option",{value:"plasmathrower",children:"Plasma Cannon"}),(0,J.jsx)("option",{value:"energy",children:"Blaster"}),(0,J.jsx)("option",{value:"shocklance",children:"Shocklance"}),(0,J.jsx)("option",{value:"elf",children:"ELF Projector"}),(0,J.jsx)("option",{value:"missile",children:"Missile Launcher"}),(0,J.jsx)("option",{value:"mortar",children:"Mortar"}),(0,J.jsx)("option",{value:"repair",children:"Repair Pack"}),(0,J.jsx)("option",{value:"targeting",children:"Targeting Laser"}),(0,J.jsx)("option",{value:"mine",children:"Mine"})]}),(0,J.jsxs)("optgroup",{label:"Vehicles","data-model-type":"vehicle",children:[(0,J.jsx)("option",{value:"vehicle_grav_scout",children:"Wildcat Grav Cycle"}),(0,J.jsx)("option",{value:"vehicle_grav_tank",children:"Beowulf Assault Tank"}),(0,J.jsx)("option",{value:"vehicle_land_mpbbase",children:"Jericho Mobile Point Base"}),(0,J.jsx)("option",{value:"vehicle_air_scout",children:"Shrike Scout Fighter"}),(0,J.jsx)("option",{value:"vehicle_air_bomber",children:"Thundersword Bomber"}),(0,J.jsx)("option",{value:"vehicle_air_hapc",children:"HAVOC Gunship Transport"})]})]})]}),(0,J.jsxs)("div",{className:"Field",children:[(0,J.jsx)("label",{htmlFor:"SkinSelect",children:"Skin"}),(0,J.jsxs)("div",{className:"Buttons",children:[(0,J.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,J.jsx)("option",{value:"",children:"Select a skin…"}),"player"===l?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("optgroup",{label:"Default Skins","data-skin-type":"default",children:null==(t=cB[f])?void 0:t.map(t=>(0,J.jsx)("option",{value:t,children:t},t))}),E.length?(0,J.jsx)("optgroup",{label:"Imported Skins","data-skin-type":"import",children:E.map(t=>{var e,r;return(0,J.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,J.jsx)("optgroup",{label:"New Skins ✨","data-skin-type":"custom",children:null==(r=w[f])?void 0:r.map(t=>(0,J.jsxs)("option",{value:"new/".concat(t),children:[t," ✨"]},"new/".concat(t)))}):null,(0,J.jsx)("optgroup",{label:"Custom Skins","data-skin-type":"custom",children:b===cW?(0,J.jsx)("option",{value:"",children:"Loading…"},"loading"):null==(i=b[f])?void 0:i.map(t=>(0,J.jsx)("option",{value:t,children:t},t))})]}):null,"weapon"===l||"vehicle"===l?(0,J.jsxs)(J.Fragment,{children:[cN[f]?(0,J.jsx)("optgroup",{label:"Default Skins","data-skin-type":"default",children:(0,J.jsx)("option",{value:cN[f],children:"Default"})}):null,E.length?(0,J.jsx)("optgroup",{label:"Imported Skins","data-skin-type":"import",children:E.map(t=>{var e,r;return(0,J.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,J.jsx)("optgroup",{label:"Custom Skins","data-skin-type":"custom",children:b[f].map(t=>(0,J.jsx)("option",{value:t,children:t},t))}):null]}):null]}),(0,J.jsx)("button",{type:"button","aria-label":"Load Skin",title:"Load a Skin",onClick:()=>{O.current&&O.current.click()},children:(0,J.jsx)(hF.FaFolderOpen,{style:{fontSize:18}})}),(0,J.jsx)("input",{ref:O,onChange:async t=>{var e,r,i;let n=await cR(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){o(t),h(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":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:throw Error("Unknown model")}}(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,J.jsx)("div",{className:"Field GalleryField",children:(0,J.jsxs)("a",{href:"gallery/",target:"_blank",className:"GalleryLink",title:"Open skin gallery",children:[(0,J.jsx)("span",{className:"FieldLabel",children:"Gallery"}),(0,J.jsx)(cE,{})]})})]})}var cX=t.i(18566);let{materials:cV,modelDefaults:cz,defaultSkins:cY}=cf,cG="https://exogen.github.io/t2-skins/skins",cq=new Map;function cK(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 cQ(t){let{basePath:e,actualModel:r,selectedModelType:i,selectedSkin:n,selectedSkinType:s}=t,a=cV[r];if(n&&"import"===s){let t=cq.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(cG,"/").concat(n,".").concat(r,".png")]}}break;case"weapon":case"vehicle":return a.reduce((t,r)=>{if(r){var i,a,o,l,h;let c=null!=(i=r.frameCount)?i:1;switch(s){case"default":!1!==r.hasDefault&&(t[null!=(a=r.file)?a:r.name]=cK(null!=(o=r.file)?o:r.name,c).map(t=>"".concat(e,"/textures/").concat(t,".png")));break;case"custom":t[null!=(l=r.file)?l:r.name]=cK(null!=(h=r.file)?h:r.name,c).map(t=>"".concat(cG,"/").concat(n,"/").concat(t,".png"))}}return t},{})}return{}}function cJ(t){var e,r;let{children:i}=t,n=(0,cX.useRouter)(),s=(0,cX.usePathname)(),a=(0,cX.useSearchParams)(),[o,l]=(0,Z.useState)(!1),[h,c]=(0,Z.useState)("lmale"),[u,d]=(0,Z.useState)("player"),[f,g]=(0,Z.useState)("Blood Eagle"),[p,m]=(0,Z.useState)("default"),[y,x]=(0,Z.useState)(null),[b,_]=(0,Z.useState)(!1),[w,C]=(0,Z.useState)(!1),{basePath:S}=cb(),T="hfemale"===h?"hmale":h,O="".concat(S,"/").concat(T).concat(y?".anim":"",".glb"),[k,M]=(0,Z.useState)(cq),E=(0,Z.useCallback)(t=>{let e=new Map(cq.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(cq=e)},[]),[D,j]=(0,Z.useState)(()=>cQ({basePath:S,actualModel:T,selectedModelType:u,selectedSkin:f,selectedSkinType:p})),A=(0,Z.useMemo)(()=>cQ({basePath:S,actualModel:T,selectedModelType:u,selectedSkin:cz[T],selectedSkinType:"default"}),[T,S,u]),P=(0,Z.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(!o){let t=a.get("m"),i=a.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===cz[e="hfemale"===t?"hmale":t]||(null==(r=cY[e])?void 0:r.includes(i))?"default":"custom";g(i),m(n)}}l(!0)}return(0,Z.useEffect)(()=>{if(!f)return;let t=a.get("m"),e=a.get("s");if(t!==h||e!==f){let t=new URLSearchParams(a);t.set("m",h),t.set("s",f);let e="".concat(s,"?").concat(t);n.replace(e,{scroll:!1})}},[s,n,a,h,f]),(0,Z.useEffect)(()=>{if(f)try{let t=cQ({basePath:S,actualModel:T,selectedModelType:u,selectedSkin:f,selectedSkinType:p});j(t)}catch(t){m("default"),g(cz[T])}},[T,S,u,f,p]),(0,J.jsx)(hV.Provider,{value:P,children:i})}var cZ=t.i(70703);let c$=Z.default.createContext(null);function c0(){let t=(0,Z.useContext)(c$);if(!t)throw Error("No EnvironmentContext.Provider");return t}c$.displayName="EnvironmentContext";let c1=Z.default.createContext(null);function c2(){let t=(0,Z.useContext)(c1);if(!t)throw Error("No SkinContext.Provider");return t}c1.displayName="SkinContext";var c5=t.i(63871);function c4(t){let{material:e,materialDef:r,textureType:i,imageUrl:n,frameRef:s,onReady:a}=t,{modelViewer:o}=(0,c5.default)(),{basePath:l}=cb(),{slowModeEnabled:h}=hz();(0,Z.useEffect)(()=>{let t,c=!1;return(async()=>{if(!r||r.hidden)if("metallicRoughnessTexture"===i){a&&a();return}else e.setAlphaMode("BLEND"),e.pbrMetallicRoughness.setBaseColorFactor([0,0,0,0]),a&&a();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=>o.createTexture(t)));if(!c){let r="baseColorTexture"===i,n=s.current,o=()=>{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 a;let e=null!=(a=null==b?void 0:b[n.frameIndex])?a:1;r&&n.frameProgress>=e&&(n.frameIndex=(n.frameIndex+1)%x,n.frameProgress=0),t=requestAnimationFrame(o)}};o(0),a&&a()}}})(),()=>{c=!0,null!=t&&cancelAnimationFrame(t)}},[l,o,e,r,i,n,s,h,a])}function c3(t){var e,r;let{material:i,materialDef:n,onReady:s}=t,{getSkinImages:a}=c2(),{colorImageUrl:o,metallicImageUrl:l}=null!=(r=a(null!=(e=null==n?void 0:n.file)?e:i.name))?r:{},h=(0,Z.useRef)({frameIndex:0,frameProgress:0});return c4({material:i,materialDef:n,textureType:"baseColorTexture",imageUrl:o,frameRef:h}),c4({material:i,materialDef:n,textureType:"metallicRoughnessTexture",imageUrl:l,frameRef:h}),null}let{materials:c9}=cf;function c6(){let{actualModel:t}=hz(),{model:e}=(0,c5.default)(),r=c9[t];return(0,J.jsx)(J.Fragment,{children:e.materials.map((t,e)=>{let i=r[e];return(0,J.jsx)(c3,{material:t,materialDef:i},t.name)})})}let c8=(0,cZ.default)(()=>t.A(22143),{loadableGenerated:{modules:[66641]},ssr:!1}),{cameraOverrides:c7}=cf;function ut(){var t,e,r,i;let{selectedModel:n,selectedModelUrl:s,selectedModelType:a,selectedAnimation:o,animationPaused:l,slowModeEnabled:h}=hz(),{environmentImageUrl:c,showEnvironment:u,exposure:d}=c0();return(0,J.jsx)(c8,{modelUrl:s,environmentImageUrl:c,showEnvironment:u,animationName:o,animationPaused:l,timeScale:h?.05:.5,cameraOrbit:null!=(i=null==(t=c7[n])?void 0:t.orbit)?i:"weapon"===a?"315deg 70deg 105%":void 0,cameraTarget:null==(e=c7[n])?void 0:e.target,fieldOfView:null==(r=c7[n])?void 0:r.fov,exposure:d,children:(0,J.jsx)(c6,{})})}function ue(){let{selectedEnvironment:t,setSelectedEnvironment:e}=c0();return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("label",{htmlFor:"EnvMapSelect",children:"Environment"}),(0,J.jsxs)("select",{id:"EnvMapSelect",value:null!=t?t:"",onChange:t=>{e(t.target.value||null)},children:[(0,J.jsx)("option",{value:"",children:"Default"}),(0,J.jsx)("option",{value:"clarens_night_02_1k.hdr",children:"Clarens Night"}),(0,J.jsx)("option",{value:"dry_cracked_lake_1k.hdr",children:"Dry Cracked Lake"}),(0,J.jsx)("option",{value:"fouriesburg_mountain_midday_1k.hdr",children:"Fouriesburg Mountain"}),(0,J.jsx)("option",{value:"goegap_1k.hdr",children:"Goegap"}),(0,J.jsx)("option",{value:"hilly_terrain_01_1k.hdr",children:"Hilly Terrain"}),(0,J.jsx)("option",{value:"kloofendal_48d_partly_cloudy_puresky_1k.hdr",children:"Kloofendal Partly Cloudy"}),(0,J.jsx)("option",{value:"kloppenheim_06_puresky_1k.hdr",children:"Kloppenheim"}),(0,J.jsx)("option",{value:"lilienstein_1k.hdr",children:"Lilienstein"}),(0,J.jsx)("option",{value:"spruit_sunrise_1k_HDR.hdr",children:"Spruit Sunrise"}),(0,J.jsx)("option",{value:"umhlanga_sunrise_1k.hdr",children:"Umhlanga Sunrise"})]})]})}function ur(){let{exposure:t,setExposure:e}=c0();return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)("label",{htmlFor:"EnvExposure",children:(0,J.jsx)(hH,{size:16})}),(0,J.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:ui,animationLabels:un,animationLabelOverrides:us}=cf;function ua(){let{actualModel:t,selectedModelType:e,selectedAnimation:r,setSelectedAnimation:i,animationPaused:n,setAnimationPaused:s,slowModeEnabled:a,setSlowModeEnabled:o}=hz(),l=(0,Z.useMemo)(()=>{var r;return[..."player"===e?ui.global:[],...null!=(r=ui[t])?r:[]]},[t,e]);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)("div",{className:"LabelWithControls",children:[(0,J.jsx)("label",{children:"Animation"}),(0,J.jsxs)("div",{className:"AnimationSpeed",children:[(0,J.jsx)("input",{type:"checkbox",id:"SlowDownCheckbox",checked:a,onChange:t=>{o(t.target.checked)}})," ",(0,J.jsx)("label",{htmlFor:"SlowDownCheckbox",children:"Slow?"})]})]}),(0,J.jsxs)("div",{className:"Buttons",children:[(0,J.jsxs)("select",{value:null!=r?r:"",onChange:t=>{i(t.target.value||null),s(!1)},children:[(0,J.jsx)("option",{value:"",children:"None"}),l.map(e=>{var r,i;let n=null!=(i=null==(r=us[t])?void 0:r[e])?i:un[e];return(0,J.jsx)("option",{value:e,children:null!=n?n:e},e)})]}),(0,J.jsx)("button",{type:"button",disabled:!r,onClick:()=>{s(t=>!t)},children:n||!r?(0,J.jsx)(hB,{}):(0,J.jsx)(hI,{})})]})]})}function uo(t){let{children:e}=t,[r,i]=(0,Z.useState)(null),[n,s]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(1),{basePath:l}=cb(),h=(0,Z.useMemo)(()=>{let t=r?"".concat(l,"/").concat(r):null;return{selectedEnvironment:r,setSelectedEnvironment:i,showEnvironment:n,setShowEnvironment:s,exposure:a,setExposure:o,environmentImageUrl:t}},[l,r,n,a]);return(0,J.jsx)(c$.Provider,{value:h,children:e})}function ul(t){let{children:e}=t,[r,i]=(0,Z.useState)({}),n=(0,Z.useMemo)(()=>({setSkinImages(t,e){i(r=>({...r,[t]:e}))},setColorImageUrl(t,e,r){i(i=>{var n,s;let a=Array.from(null!=(s=null==(n=i[t])?void 0:n.colorImageUrl)?s:[]);return a[r]=e,{...i,[t]:{...i[t],colorImageUrl:a}}})},setMetallicImageUrl(t,e,r){i(i=>{var n,s;let a=Array.from(null!=(s=null==(n=i[t])?void 0:n.metallicImageUrl)?s:[]);return a[r]=e,{...i,[t]:{...i[t],metallicImageUrl:a}}})}}),[]),s=(0,Z.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,J.jsx)(c1.Provider,{value:s,children:e})}let{materials:uh}=cf;function uc(){let{actualModel:t}=hz(),{selectedMaterialIndex:e,setSelectedMaterialIndex:r}=a1(),i=uh[t];return(0,J.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,J.jsx)("option",{value:e,children:null!=(r=t.label)?r:t.name},t.name):null})})}function uu(t){let{canvasId:e,onChange:r,baseImageUrl:i,textureSize:n,defaultDrawingMode:s=!1}=t,a=(0,Z.useRef)(null),[o,l]=(0,Z.useState)(null),{activeCanvas:h}=a1(),{canvasPadding:c}=cb(),{registerCanvas:u,unregisterCanvas:d}=a$(),[f,g]=(0,Z.useState)(s),p=(0,Z.useRef)(null),m=(0,Z.useRef)(!0),[y,x]=(0,Z.useState)(()=>[]),[b,_]=(0,Z.useState)(()=>[]),w=y.length>1,C=b.length>0,S=(0,Z.useCallback)(t=>{let e=p.current;e&&e(t)},[]),T=(0,Z.useCallback)(async()=>{if(o&&y.length>1){let[t,e]=y.slice(-2);m.current=!1,o.renderOnAddRemove=!1,o.clear(),o.loadFromJSON(t,()=>{o.renderAll(),m.current=!0,o.renderOnAddRemove=!0}),x(t=>t.slice(0,-1)),_(t=>[e,...t])}},[o,y]),O=(0,Z.useCallback)(()=>{if(o&&b.length>0){let t=b[0];m.current=!1,o.renderOnAddRemove=!1,o.clear(),o.loadFromJSON(t,()=>{o.renderAll(),m.current=!0,o.renderOnAddRemove=!0}),x(e=>[...e,t]),_(t=>t.slice(1))}},[o,b]);(0,Z.useEffect)(()=>{p.current=r},[r]);let k=h===e;return(0,Z.useEffect)(()=>{let t;if(!a.current)return;iN.ownDefaults={...iN.ownDefaults,transparentCorners:!1,borderColor:"#8afff1",cornerSize:9,cornerStyle:"circle",cornerColor:"#8afff1",cornerStrokeColor:"#1c9f7c",strokeWidth:10,perPixelTargetFind:!0};let e=new se(a.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,Z.useEffect)(()=>{o&&(o.isDrawingMode=f,f&&(o.discardActiveObject(),o.requestRenderAll()))},[o,f]),(0,Z.useEffect)(()=>{o&&k&&o.calcOffset()},[o,k]),(0,Z.useEffect)(()=>{if(o)return u(e,{canvas:o,notifyChange:()=>{o.renderAll(),S(o)},undo:T,redo:O,canUndo:w,canRedo:C,isDrawingMode:f,setDrawingMode:g}),()=>{d(e)}},[o,u,d,e,S,f,g,T,O,w,C]),(0,Z.useEffect)(()=>{x([]),_([])},[o,i,n]),(0,Z.useEffect)(()=>{if(o&&n&&(m.current=!1,o.clear(),i)){let t=!1;return(async()=>{let e=await cv(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),o.centerObject(e),o.add(e)}m.current=!0,o.requestRenderAll()})(),()=>{t=!0}}},[o,i,n]),(0,J.jsx)("div",{className:"CanvasContainer","data-active":k?"true":"false",children:(0,J.jsx)("canvas",{width:n[0]+2*c,height:n[1]+2*c,ref:a})})}let ud=Z.default.createContext(null);function uf(){let t=(0,Z.useContext)(ud);if(!t)throw Error("ImageLoaderContext.Provider not found!");return t}ud.displayName="ImageLoaderContext";let ug=[512,512];function up(t){var e,r,i,n;let{materialDef:s,frameIndex:a=0}=t,{skinImageUrls:o,defaultSkinImageUrls:l}=hz(),h=null==(e=o[null!=(i=s.file)?i:s.name])?void 0:e[a],c=null==(r=l[null!=(n=s.file)?n:s.name])?void 0:r[a],{setColorImageUrl:u}=c2(),{canvasPadding:d}=cb(),[f,g]=(0,Z.useState)(null),{removeAlphaFromArrayBuffer:p}=cx(),{loadImage:m}=uf(),{sizeMultiplier:y}=a1(),x=(0,Z.useMemo)(()=>{var t;let[e,r]=null!=(t=s.size)?t:ug;return[e*y,r*y]},[s.size,y]),b=(0,Z.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,a)},[x,d,u,s,a]);(0,Z.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(a,":").concat(y);return x?(0,J.jsx)(uu,{canvasId:_,canvasType:"color",onChange:b,baseImageUrl:f,textureSize:x},_):null}let um=[512,512];function uv(t){var e,r,i,n;let{materialDef:s,frameIndex:a=0}=t,{skinImageUrls:o,defaultSkinImageUrls:l}=hz(),h=null==(e=o[null!=(i=s.file)?i:s.name])?void 0:e[a],c=null==(r=l[null!=(n=s.file)?n:s.name])?void 0:r[a],{setMetallicImageUrl:u}=c2(),{canvasPadding:d}=cb(),[f,g]=(0,Z.useState)(null),p=(0,Z.useRef)(0),{convertGrayscaleImageUrlToMetallicRoughness:m,convertArrayBufferAlphaToGrayscale:y}=cx(),{loadImage:x}=uf(),{sizeMultiplier:b}=a1(),_=(0,Z.useMemo)(()=>{var t;let[e,r]=null!=(t=s.size)?t:um;return[e*b,r*b]},[s.size,b]),w=(0,Z.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,a)}},[_,d,u,m,s,a]);(0,Z.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(a,":").concat(b);return _?(0,J.jsx)(uu,{canvasId:C,canvasType:"metallic",onChange:w,baseImageUrl:f,textureSize:_,defaultDrawingMode:!0},C):null}let{materials:uy}=cf;function ux(){let{actualModel:t}=hz(),e=uy[t];return(0,J.jsx)(J.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,J.jsxs)(Z.default.Fragment,{children:[n.map((t,r)=>(0,J.jsx)(up,{materialDef:e,frameIndex:r},"color:".concat(r))),i?n.map((t,r)=>(0,J.jsx)(uv,{materialDef:e,frameIndex:r},"metallic:".concat(r))):null]},"".concat(t,"-").concat(e.name))})})}var ub=Z.createContext(void 0),u_=t=>{let{client:e,children:r}=t;return Z.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,J.jsx)(ub.Provider,{value:e,children:r})};function uw(t){let{children:e}=t,r=(t=>{let e=Z.useContext(ub);if(t)return t;if(!e)throw Error("No QueryClient set, use QueryClientProvider to set one");return e})(),i=(0,Z.useMemo)(()=>({loadImage:async t=>t.startsWith("data:")?(0,c_.imageUrlToArrayBuffer)(t):await r.fetchQuery({queryKey:[t]})}),[r]);return(0,J.jsx)(ud.Provider,{value:i,children:e})}function uC(t,e,r){if(!e.has(t))throw TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function uS(t,e){var r=uC(t,e,"get");return r.get?r.get.call(t):r.value}function uT(t,e){if(e.has(t))throw TypeError("Cannot initialize the same private elements twice on an object")}function uO(t,e,r){uT(t,e),e.set(t,r)}function uk(t,e,r){var i=uC(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 uM(t,e){var r=uC(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 uE={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},uD=new(m=new WeakMap,y=new WeakMap,class{setTimeoutProvider(t){uk(this,m,t)}setTimeout(t,e){return uS(this,m).setTimeout(t,e)}clearTimeout(t){uS(this,m).clearTimeout(t)}setInterval(t,e){return uS(this,m).setInterval(t,e)}clearInterval(t){uS(this,m).clearInterval(t)}constructor(){uO(this,m,{writable:!0,value:uE}),uO(this,y,{writable:!0,value:!1})}}),uj="undefined"==typeof window||"Deno"in globalThis;function uA(){}function uP(t,e){return"function"==typeof t?t(e):t}function uF(t,e){let{type:r="all",exact:i,fetchStatus:n,predicate:s,queryKey:a,stale:o}=t;if(a){if(i){if(e.queryHash!==uR(a,e.options))return!1}else if(!uB(e.queryKey,a))return!1}if("all"!==r){let t=e.isActive();if("active"===r&&!t||"inactive"===r&&t)return!1}return("boolean"!=typeof o||e.isStale()===o)&&(!n||n===e.state.fetchStatus)&&(!s||!!s(e))}function uL(t,e){let{exact:r,status:i,predicate:n,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(r){if(uI(e.options.mutationKey)!==uI(s))return!1}else if(!uB(e.options.mutationKey,s))return!1}return(!i||e.state.status===i)&&(!n||!!n(e))}function uR(t,e){return((null==e?void 0:e.queryKeyHashFn)||uI)(t)}function uI(t){return JSON.stringify(t,(t,e)=>uU(e)?Object.keys(e).sort().reduce((t,r)=>(t[r]=e[r],t),{}):e)}function uB(t,e){return t===e||typeof t==typeof e&&!!t&&!!e&&"object"==typeof t&&"object"==typeof e&&Object.keys(e).every(r=>uB(t[r],e[r]))}var uN=Object.prototype.hasOwnProperty;function uW(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function uU(t){if(!uH(t))return!1;let e=t.constructor;if(void 0===e)return!0;let r=e.prototype;return!!uH(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(t)===Object.prototype}function uH(t){return"[object Object]"===Object.prototype.toString.call(t)}function uX(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 uV(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 uz=Symbol();function uY(t,e){return!t.queryFn&&(null==e?void 0:e.initialPromise)?()=>e.initialPromise:t.queryFn&&t.queryFn!==uz?t.queryFn:()=>Promise.reject(Error("Missing queryFn: '".concat(t.queryHash,"'")))}function uG(t,e,r){if(!e.has(t))throw TypeError("attempted to get private field on non-instance");return r}function uq(t,e){uT(t,e),e.add(t)}var uK=function(t){setTimeout(t,0)},uQ=function(){let t=[],e=0,r=t=>{t()},i=t=>{t()},n=uK,s=i=>{e?t.push(i):n(()=>{r(i)})};return{batch:s=>{let a;e++;try{a=s()}finally{--e||(()=>{let e=t;t=[],e.length&&n(()=>{i(()=>{e.forEach(t=>{r(t)})})})})()}return a},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}}}(),uJ=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)}},uZ=new(x=new WeakMap,b=new WeakMap,_=new WeakMap,class extends uJ{onSubscribe(){uS(this,b)||this.setEventListener(uS(this,_))}onUnsubscribe(){var t;this.hasListeners()||(null==(t=uS(this,b))||t.call(this),uk(this,b,void 0))}setEventListener(t){var e;uk(this,_,t),null==(e=uS(this,b))||e.call(this),uk(this,b,t(t=>{"boolean"==typeof t?this.setFocused(t):this.onFocus()}))}setFocused(t){uS(this,x)!==t&&(uk(this,x,t),this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){var t;return"boolean"==typeof uS(this,x)?uS(this,x):(null==(t=globalThis.document)?void 0:t.visibilityState)!=="hidden"}constructor(){super(),uO(this,x,{writable:!0,value:void 0}),uO(this,b,{writable:!0,value:void 0}),uO(this,_,{writable:!0,value:void 0}),uk(this,_,t=>{if(!uj&&window.addEventListener){let e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}})}}),u$=new(w=new WeakMap,C=new WeakMap,S=new WeakMap,class extends uJ{onSubscribe(){uS(this,C)||this.setEventListener(uS(this,S))}onUnsubscribe(){var t;this.hasListeners()||(null==(t=uS(this,C))||t.call(this),uk(this,C,void 0))}setEventListener(t){var e;uk(this,S,t),null==(e=uS(this,C))||e.call(this),uk(this,C,t(this.setOnline.bind(this)))}setOnline(t){uS(this,w)!==t&&(uk(this,w,t),this.listeners.forEach(e=>{e(t)}))}isOnline(){return uS(this,w)}constructor(){super(),uO(this,w,{writable:!0,value:!0}),uO(this,C,{writable:!0,value:void 0}),uO(this,S,{writable:!0,value:void 0}),uk(this,S,t=>{if(!uj&&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 u0(t){return Math.min(1e3*2**t,3e4)}function u1(t){return(null!=t?t:"online")!=="online"||u$.isOnline()}var u2=class extends Error{constructor(t){super("CancelledError"),this.revert=null==t?void 0:t.revert,this.silent=null==t?void 0:t.silent}};function u5(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=()=>uZ.isFocused()&&("always"===t.networkMode||u$.isOnline())&&t.canRun(),a=()=>u1(t.networkMode)&&t.canRun(),o=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 a=0===i?t.initialPromise:void 0;try{e=null!=a?a:t.fn()}catch(t){e=Promise.reject(t)}Promise.resolve(e).then(o).catch(e=>{var a,o,u;if("pending"!==n.status)return;let d=null!=(o=t.retry)?o:3*!uj,f=null!=(u=t.retryDelay)?u:u0,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==(a=t.onFail)||a.call(t,i,e),new Promise(t=>{uD.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 u2(e);l(i),null==(r=t.onCancel)||r.call(t,i)}},continue:()=>(null==e||e(),n),cancelRetry:()=>{r=!0},continueRetry:()=>{r=!1},canStart:a,start:()=>(a()?c():h().then(c),n)}}var u4=(T=new WeakMap,class{destroy(){this.clearGcTimeout()}scheduleGc(){var t;this.clearGcTimeout(),"number"==typeof(t=this.gcTime)&&t>=0&&t!==1/0&&uk(this,T,uD.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,null!=t?t:uj?1/0:3e5)}clearGcTimeout(){uS(this,T)&&(uD.clearTimeout(uS(this,T)),uk(this,T,void 0))}constructor(){uO(this,T,{writable:!0,value:void 0})}}),u3=(O=new WeakMap,k=new WeakMap,M=new WeakMap,E=new WeakMap,D=new WeakMap,j=new WeakMap,A=new WeakMap,P=new WeakSet,class extends u4{get meta(){return this.options.meta}get promise(){var t;return null==(t=uS(this,D))?void 0:t.promise}setOptions(t){if(this.options={...uS(this,j),...t},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let t=u9(this.options);void 0!==t.data&&(this.setData(t.data,{updatedAt:t.dataUpdatedAt,manual:!0}),uk(this,O,t))}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||uS(this,M).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=uW(e)&&uW(r);if(!i&&!(uU(e)&&uU(r)))return r;let n=(i?e:Object.keys(e)).length,s=i?r:Object.keys(r),a=s.length,o=i?Array(a):{},l=0;for(let h=0;h<a;h++){let a=i?h:s[h],c=e[a],u=r[a];if(c===u){o[a]=c,(i?h<n:uN.call(e,a))&&l++;continue}if(null===c||null===u||"object"!=typeof c||"object"!=typeof u){o[a]=u;continue}let d=t(c,u);o[a]=d,d===c&&l++}return n===a&&l===n?e:o}(r,t):t);return uG(this,P,u6).call(this,{data:n,type:"success",dataUpdatedAt:null==e?void 0:e.updatedAt,manual:null==e?void 0:e.manual}),n}setState(t,e){uG(this,P,u6).call(this,{type:"setState",state:t,setStateOptions:e})}cancel(t){var e,r;let i=null==(e=uS(this,D))?void 0:e.promise;return null==(r=uS(this,D))||r.cancel(t),i?i.then(uA).catch(uA):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(uS(this,O))}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===uz||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(t=>"static"===uP(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=uS(this,D))||t.continue()}onOnline(){var t;let e=this.observers.find(t=>t.shouldFetchOnReconnect());null==e||e.refetch({cancelRefetch:!1}),null==(t=uS(this,D))||t.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),uS(this,M).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(uS(this,D)&&(uS(this,A)?uS(this,D).cancel({revert:!0}):uS(this,D).cancelRetry()),this.scheduleGc()),uS(this,M).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||uG(this,P,u6).call(this,{type:"invalidate"})}async fetch(t,e){var r,i,n,s,a,o,l,h,c,u,d,f;if("idle"!==this.state.fetchStatus&&(null==(r=uS(this,D))?void 0:r.status())!=="rejected"){if(void 0!==this.state.data&&(null==e?void 0:e.cancelRefetch))this.cancel({silent:!0});else if(uS(this,D))return uS(this,D).continueRetry(),uS(this,D).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:()=>(uk(this,A,!0),g.signal)})},m=()=>{let t=uY(this.options,e),r=(()=>{let t={client:uS(this,E),queryKey:this.queryKey,meta:this.meta};return p(t),t})();return(uk(this,A,!1),this.options.persister)?this.options.persister(t,r,this):t(r)},y=(()=>{let t={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:uS(this,E),state:this.state,fetchFn:m};return p(t),t})();null==(i=this.options.behavior)||i.onFetch(y,this),uk(this,k,this.state),("idle"===this.state.fetchStatus||this.state.fetchMeta!==(null==(n=y.fetchOptions)?void 0:n.meta))&&uG(this,P,u6).call(this,{type:"fetch",meta:null==(s=y.fetchOptions)?void 0:s.meta}),uk(this,D,u5({initialPromise:null==e?void 0:e.initialPromise,fn:y.fetchFn,onCancel:t=>{t instanceof u2&&t.revert&&this.setState({...uS(this,k),fetchStatus:"idle"}),g.abort()},onFail:(t,e)=>{uG(this,P,u6).call(this,{type:"failed",failureCount:t,error:e})},onPause:()=>{uG(this,P,u6).call(this,{type:"pause"})},onContinue:()=>{uG(this,P,u6).call(this,{type:"continue"})},retry:y.options.retry,retryDelay:y.options.retryDelay,networkMode:y.options.networkMode,canRun:()=>!0}));try{let t=await uS(this,D).start();if(void 0===t)throw Error("".concat(this.queryHash," data is undefined"));return this.setData(t),null==(a=(o=uS(this,M).config).onSuccess)||a.call(o,t,this),null==(l=(h=uS(this,M).config).onSettled)||l.call(h,t,this.state.error,this),t}catch(t){if(t instanceof u2){if(t.silent)return uS(this,D).promise;else if(t.revert){if(void 0===this.state.data)throw t;return this.state.data}}throw uG(this,P,u6).call(this,{type:"error",error:t}),null==(c=(u=uS(this,M).config).onError)||c.call(u,t,this),null==(d=(f=uS(this,M).config).onSettled)||d.call(f,this.state.data,t,this),t}finally{this.scheduleGc()}}constructor(t){var e;super(),uq(this,P),uO(this,O,{writable:!0,value:void 0}),uO(this,k,{writable:!0,value:void 0}),uO(this,M,{writable:!0,value:void 0}),uO(this,E,{writable:!0,value:void 0}),uO(this,D,{writable:!0,value:void 0}),uO(this,j,{writable:!0,value:void 0}),uO(this,A,{writable:!0,value:void 0}),uk(this,A,!1),uk(this,j,t.defaultOptions),this.setOptions(t.options),this.observers=[],uk(this,E,t.client),uk(this,M,uS(this,E).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,uk(this,O,u9(this.options)),this.state=null!=(e=t.state)?e:uS(this,O),this.scheduleGc()}});function u9(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 u6(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:u1(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 uk(this,k,t.manual?s:void 0),s;case"error":let a=t.error;return{...e,error:a,errorUpdateCount:e.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:e.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...e,isInvalidated:!0};case"setState":return{...e,...t.state}}};this.state=e(this.state),uQ.batch(()=>{this.observers.forEach(t=>{t.onQueryUpdate()}),uS(this,M).notify({query:this,type:"updated",action:t})})}var u8=(F=new WeakMap,class extends uJ{build(t,e,r){var i;let n=e.queryKey,s=null!=(i=e.queryHash)?i:uR(n,e),a=this.get(s);return a||(a=new u3({client:t,queryKey:n,queryHash:s,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(n)}),this.add(a)),a}add(t){uS(this,F).has(t.queryHash)||(uS(this,F).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=uS(this,F).get(t.queryHash);e&&(t.destroy(),e===t&&uS(this,F).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){uQ.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return uS(this,F).get(t)}getAll(){return[...uS(this,F).values()]}find(t){let e={exact:!0,...t};return this.getAll().find(t=>uF(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=>uF(t,e)):e}notify(t){uQ.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){uQ.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){uQ.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}constructor(t={}){super(),uO(this,F,{writable:!0,value:void 0}),this.config=t,uk(this,F,new Map)}}),u7=(L=new WeakMap,R=new WeakMap,I=new WeakMap,B=new WeakMap,N=new WeakSet,class extends u4{setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){uS(this,R).includes(t)||(uS(this,R).push(t),this.clearGcTimeout(),uS(this,I).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){uk(this,R,uS(this,R).filter(e=>e!==t)),this.scheduleGc(),uS(this,I).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){uS(this,R).length||("pending"===this.state.status?this.scheduleGc():uS(this,I).remove(this))}continue(){var t,e;return null!=(e=null==(t=uS(this,B))?void 0:t.continue())?e:this.execute(this.state.variables)}async execute(t){var e,r,i,n,s,a,o,l,h,c,u,d,f,g,p,m,y,x,b,_,w;let C=()=>{uG(this,N,dt).call(this,{type:"continue"})},S={client:uS(this,L),meta:this.options.meta,mutationKey:this.options.mutationKey};uk(this,B,u5({fn:()=>this.options.mutationFn?this.options.mutationFn(t,S):Promise.reject(Error("No mutationFn found")),onFail:(t,e)=>{uG(this,N,dt).call(this,{type:"failed",failureCount:t,error:e})},onPause:()=>{uG(this,N,dt).call(this,{type:"pause"})},onContinue:C,retry:null!=(e=this.options.retry)?e:0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>uS(this,I).canRun(this)}));let T="pending"===this.state.status,O=!uS(this,B).canStart();try{if(T)C();else{uG(this,N,dt).call(this,{type:"pending",variables:t,isPaused:O}),await (null==(c=(u=uS(this,I).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&&uG(this,N,dt).call(this,{type:"pending",context:e,variables:t,isPaused:O})}let e=await uS(this,B).start();return await (null==(r=(i=uS(this,I).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==(a=(o=uS(this,I).config).onSettled)?void 0:a.call(o,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)),uG(this,N,dt).call(this,{type:"success",data:e}),e}catch(e){try{throw await (null==(g=(p=uS(this,I).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=uS(this,I).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{uG(this,N,dt).call(this,{type:"error",error:e})}}finally{uS(this,I).runNext(this)}}constructor(t){super(),uq(this,N),uO(this,L,{writable:!0,value:void 0}),uO(this,R,{writable:!0,value:void 0}),uO(this,I,{writable:!0,value:void 0}),uO(this,B,{writable:!0,value:void 0}),uk(this,L,t.client),this.mutationId=t.mutationId,uk(this,I,t.mutationCache),uk(this,R,[]),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 dt(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),uQ.batch(()=>{uS(this,R).forEach(e=>{e.onMutationUpdate(t)}),uS(this,I).notify({mutation:this,type:"updated",action:t})})}var de=(W=new WeakMap,U=new WeakMap,H=new WeakMap,class extends uJ{build(t,e,r){let i=new u7({client:t,mutationCache:this,mutationId:++uM(this,H).value,options:t.defaultMutationOptions(e),state:r});return this.add(i),i}add(t){uS(this,W).add(t);let e=dr(t);if("string"==typeof e){let r=uS(this,U).get(e);r?r.push(t):uS(this,U).set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(uS(this,W).delete(t)){let e=dr(t);if("string"==typeof e){let r=uS(this,U).get(e);if(r)if(r.length>1){let e=r.indexOf(t);-1!==e&&r.splice(e,1)}else r[0]===t&&uS(this,U).delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=dr(t);if("string"!=typeof e)return!0;{let r=uS(this,U).get(e),i=null==r?void 0:r.find(t=>"pending"===t.state.status);return!i||i===t}}runNext(t){let e=dr(t);if("string"!=typeof e)return Promise.resolve();{var r,i;let n=null==(r=uS(this,U).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(){uQ.batch(()=>{uS(this,W).forEach(t=>{this.notify({type:"removed",mutation:t})}),uS(this,W).clear(),uS(this,U).clear()})}getAll(){return Array.from(uS(this,W))}find(t){let e={exact:!0,...t};return this.getAll().find(t=>uL(e,t))}findAll(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.getAll().filter(e=>uL(t,e))}notify(t){uQ.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(t=>t.state.isPaused);return uQ.batch(()=>Promise.all(t.map(t=>t.continue().catch(uA))))}constructor(t={}){super(),uO(this,W,{writable:!0,value:void 0}),uO(this,U,{writable:!0,value:void 0}),uO(this,H,{writable:!0,value:void 0}),this.config=t,uk(this,W,new Set),uk(this,U,new Map),uk(this,H,0)}});function dr(t){var e;return null==(e=t.options.scope)?void 0:e.id}function di(t){return{onFetch:(e,r)=>{var i,n,s,a,o;let l=e.options,h=null==(s=e.fetchOptions)||null==(n=s.meta)||null==(i=n.fetchMore)?void 0:i.direction,c=(null==(a=e.state.data)?void 0:a.pages)||[],u=(null==(o=e.state.data)?void 0:o.pageParams)||[],d={pages:[],pageParams:[]},f=0,g=async()=>{let r=!1,i=uY(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 a=(()=>{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})(),o=await i(a),{maxPages:l}=e.options,h=s?uV:uX;return{pages:h(t.pages,o,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}:dn)(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:dn(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 dn(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 ds=new(X=new WeakMap,V=new WeakMap,z=new WeakMap,Y=new WeakMap,G=new WeakMap,q=new WeakMap,K=new WeakMap,Q=new WeakMap,class{mount(){uM(this,q).value++,1===uS(this,q)&&(uk(this,K,uZ.subscribe(async t=>{t&&(await this.resumePausedMutations(),uS(this,X).onFocus())})),uk(this,Q,u$.subscribe(async t=>{t&&(await this.resumePausedMutations(),uS(this,X).onOnline())})))}unmount(){var t,e;uM(this,q).value--,0===uS(this,q)&&(null==(t=uS(this,K))||t.call(this),uk(this,K,void 0),null==(e=uS(this,Q))||e.call(this),uk(this,Q,void 0))}isFetching(t){return uS(this,X).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return uS(this,V).findAll({...t,status:"pending"}).length}getQueryData(t){var e;let r=this.defaultQueryOptions({queryKey:t});return null==(e=uS(this,X).get(r.queryHash))?void 0:e.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=uS(this,X).build(this,e),i=r.state.data;return void 0===i?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(uP(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(t){return uS(this,X).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=uS(this,X).get(i.queryHash),s=null==n?void 0:n.state.data,a="function"==typeof e?e(s):e;if(void 0!==a)return uS(this,X).build(this,i).setData(a,{...r,manual:!0})}setQueriesData(t,e,r){return uQ.batch(()=>uS(this,X).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=uS(this,X).get(r.queryHash))?void 0:e.state}removeQueries(t){let e=uS(this,X);uQ.batch(()=>{e.findAll(t).forEach(t=>{e.remove(t)})})}resetQueries(t,e){let r=uS(this,X);return uQ.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(uQ.batch(()=>uS(this,X).findAll(t).map(t=>t.cancel(r)))).then(uA).catch(uA)}invalidateQueries(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return uQ.batch(()=>{var r,i;return(uS(this,X).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(uQ.batch(()=>uS(this,X).findAll(t).filter(t=>!t.isDisabled()&&!t.isStatic()).map(t=>{let e=t.fetch(void 0,i);return i.throwOnError||(e=e.catch(uA)),"paused"===t.state.fetchStatus?Promise.resolve():e}))).then(uA)}fetchQuery(t){let e=this.defaultQueryOptions(t);void 0===e.retry&&(e.retry=!1);let r=uS(this,X).build(this,e);return r.isStaleByTime(uP(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(uA).catch(uA)}fetchInfiniteQuery(t){return t.behavior=di(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(uA).catch(uA)}ensureInfiniteQueryData(t){return t.behavior=di(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return u$.isOnline()?uS(this,V).resumePausedMutations():Promise.resolve()}getQueryCache(){return uS(this,X)}getMutationCache(){return uS(this,V)}getDefaultOptions(){return uS(this,z)}setDefaultOptions(t){uk(this,z,t)}setQueryDefaults(t,e){uS(this,Y).set(uI(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...uS(this,Y).values()],r={};return e.forEach(e=>{uB(t,e.queryKey)&&Object.assign(r,e.defaultOptions)}),r}setMutationDefaults(t,e){uS(this,G).set(uI(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...uS(this,G).values()],r={};return e.forEach(e=>{uB(t,e.mutationKey)&&Object.assign(r,e.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...uS(this,z).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=uR(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===uz&&(e.enabled=!1),e}defaultMutationOptions(t){return(null==t?void 0:t._defaulted)?t:{...uS(this,z).mutations,...(null==t?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){uS(this,X).clear(),uS(this,V).clear()}constructor(t={}){uO(this,X,{writable:!0,value:void 0}),uO(this,V,{writable:!0,value:void 0}),uO(this,z,{writable:!0,value:void 0}),uO(this,Y,{writable:!0,value:void 0}),uO(this,G,{writable:!0,value:void 0}),uO(this,q,{writable:!0,value:void 0}),uO(this,K,{writable:!0,value:void 0}),uO(this,Q,{writable:!0,value:void 0}),uk(this,X,t.queryCache||new u8),uk(this,V,t.mutationCache||new de),uk(this,z,t.defaultOptions||{}),uk(this,Y,new Map),uk(this,G,new Map),uk(this,q,0)}})({defaultOptions:{queries:{queryFn:async function(t){let{queryKey:e}=t,[r]=e;return(0,c_.imageUrlToArrayBuffer)(r)},staleTime:1/0,gcTime:6e4,refetchOnWindowFocus:!1,refetchOnReconnect:!1}}});function da(){return(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(u_,{client:ds,children:(0,J.jsx)("main",{children:(0,J.jsx)(uw,{children:(0,J.jsx)(Z.Suspense,{children:(0,J.jsx)(cJ,{children:(0,J.jsx)(uo,{children:(0,J.jsxs)(ul,{children:[(0,J.jsxs)("div",{className:"Viewport",children:[(0,J.jsxs)("div",{className:"ModelTools",children:[(0,J.jsx)("div",{className:"Field",children:(0,J.jsx)(ue,{})}),(0,J.jsx)("div",{className:"Field SliderField",children:(0,J.jsx)(ur,{})}),(0,J.jsx)("div",{className:"Field",children:(0,J.jsx)(ua,{})})]}),(0,J.jsx)(ut,{})]}),(0,J.jsx)(cO,{children:(0,J.jsx)(cS,{children:(0,J.jsxs)(ck,{children:[(0,J.jsx)(cH,{}),(0,J.jsxs)("div",{className:"CanvasViewport",children:[(0,J.jsxs)("div",{className:"CanvasSelector",children:[(0,J.jsx)(cM,{}),(0,J.jsx)(uc,{})]}),(0,J.jsx)(cT,{}),(0,J.jsx)(ux,{})]}),(0,J.jsx)(cp,{}),(0,J.jsx)(cm,{})]})})})]})})})})})})})})}}]); |