modern-canvas 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- (function(u,Tr){typeof exports=="object"&&typeof module<"u"?Tr(exports):typeof define=="function"&&define.amd?define(["exports"],Tr):(u=typeof globalThis<"u"?globalThis:u||self,Tr(u.modernCanvas={}))})(this,(function(u){"use strict";var Tr={grad:.9,turn:360,rad:360/(2*Math.PI)},xt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},pe=function(s,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*s)/t+0},He=function(s,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),s>t?t:s>e?s:e},Zn=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Jn=function(s){return{r:He(s.r,0,255),g:He(s.g,0,255),b:He(s.b,0,255),a:He(s.a)}},cs=function(s){return{r:pe(s.r),g:pe(s.g),b:pe(s.b),a:pe(s.a,3)}},mc=/^#([0-9a-f]{3,8})$/i,mi=function(s){var e=s.toString(16);return e.length<2?"0"+e:e},Qn=function(s){var e=s.r,t=s.g,r=s.b,i=s.a,n=Math.max(e,t,r),o=n-Math.min(e,t,r),a=o?n===e?(t-r)/o:n===t?2+(r-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},eo=function(s){var e=s.h,t=s.s,r=s.v,i=s.a;e=e/360*6,t/=100,r/=100;var n=Math.floor(e),o=r*(1-t),a=r*(1-(e-n)*t),l=r*(1-(1-e+n)*t),c=n%6;return{r:255*[r,a,o,o,l,r][c],g:255*[l,r,r,a,o,o][c],b:255*[o,o,l,r,r,a][c],a:i}},to=function(s){return{h:Zn(s.h),s:He(s.s,0,100),l:He(s.l,0,100),a:He(s.a)}},ro=function(s){return{h:pe(s.h),s:pe(s.s),l:pe(s.l),a:pe(s.a,3)}},io=function(s){return eo((t=(e=s).s,{h:e.h,s:(t*=((r=e.l)<50?r:100-r)/100)>0?2*t/(r+t)*100:0,v:r+t,a:e.a}));var e,t,r},Er=function(s){return{h:(e=Qn(s)).h,s:(i=(200-(t=e.s))*(r=e.v)/100)>0&&i<200?t*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,t,r,i},yc=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,_c=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hs={string:[[function(s){var e=mc.exec(s);return e?(s=e[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?pe(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?pe(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var e=vc.exec(s)||bc.exec(s);return e?e[2]!==e[4]||e[4]!==e[6]?null:Jn({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(s){var e=yc.exec(s)||_c.exec(s);if(!e)return null;var t,r,i=to({h:(t=e[1],r=e[2],r===void 0&&(r="deg"),Number(t)*(Tr[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return io(i)},"hsl"]],object:[[function(s){var e=s.r,t=s.g,r=s.b,i=s.a,n=i===void 0?1:i;return xt(e)&&xt(t)&&xt(r)?Jn({r:Number(e),g:Number(t),b:Number(r),a:Number(n)}):null},"rgb"],[function(s){var e=s.h,t=s.s,r=s.l,i=s.a,n=i===void 0?1:i;if(!xt(e)||!xt(t)||!xt(r))return null;var o=to({h:Number(e),s:Number(t),l:Number(r),a:Number(n)});return io(o)},"hsl"],[function(s){var e=s.h,t=s.s,r=s.v,i=s.a,n=i===void 0?1:i;if(!xt(e)||!xt(t)||!xt(r))return null;var o=(function(a){return{h:Zn(a.h),s:He(a.s,0,100),v:He(a.v,0,100),a:He(a.a)}})({h:Number(e),s:Number(t),v:Number(r),a:Number(n)});return eo(o)},"hsv"]]},so=function(s,e){for(var t=0;t<e.length;t++){var r=e[t][0](s);if(r)return[r,e[t][1]]}return[null,void 0]},wc=function(s){return typeof s=="string"?so(s.trim(),hs.string):typeof s=="object"&&s!==null?so(s,hs.object):[null,void 0]},us=function(s,e){var t=Er(s);return{h:t.h,s:He(t.s+100*e,0,100),l:t.l,a:t.a}},fs=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},no=function(s,e){var t=Er(s);return{h:t.h,s:t.s,l:He(t.l+100*e,0,100),a:t.a}},ds=(function(){function s(e){this.parsed=wc(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return pe(fs(this.rgba),2)},s.prototype.isDark=function(){return fs(this.rgba)<.5},s.prototype.isLight=function(){return fs(this.rgba)>=.5},s.prototype.toHex=function(){return e=cs(this.rgba),t=e.r,r=e.g,i=e.b,o=(n=e.a)<1?mi(pe(255*n)):"","#"+mi(t)+mi(r)+mi(i)+o;var e,t,r,i,n,o},s.prototype.toRgb=function(){return cs(this.rgba)},s.prototype.toRgbString=function(){return e=cs(this.rgba),t=e.r,r=e.g,i=e.b,(n=e.a)<1?"rgba("+t+", "+r+", "+i+", "+n+")":"rgb("+t+", "+r+", "+i+")";var e,t,r,i,n},s.prototype.toHsl=function(){return ro(Er(this.rgba))},s.prototype.toHslString=function(){return e=ro(Er(this.rgba)),t=e.h,r=e.s,i=e.l,(n=e.a)<1?"hsla("+t+", "+r+"%, "+i+"%, "+n+")":"hsl("+t+", "+r+"%, "+i+"%)";var e,t,r,i,n},s.prototype.toHsv=function(){return e=Qn(this.rgba),{h:pe(e.h),s:pe(e.s),v:pe(e.v),a:pe(e.a,3)};var e},s.prototype.invert=function(){return lt({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},s.prototype.saturate=function(e){return e===void 0&&(e=.1),lt(us(this.rgba,e))},s.prototype.desaturate=function(e){return e===void 0&&(e=.1),lt(us(this.rgba,-e))},s.prototype.grayscale=function(){return lt(us(this.rgba,-1))},s.prototype.lighten=function(e){return e===void 0&&(e=.1),lt(no(this.rgba,e))},s.prototype.darken=function(e){return e===void 0&&(e=.1),lt(no(this.rgba,-e))},s.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},s.prototype.alpha=function(e){return typeof e=="number"?lt({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):pe(this.rgba.a,3);var t},s.prototype.hue=function(e){var t=Er(this.rgba);return typeof e=="number"?lt({h:e,s:t.s,l:t.l,a:t.a}):pe(t.h)},s.prototype.isEqual=function(e){return this.toHex()===lt(e).toHex()},s})(),lt=function(s){return s instanceof ds?s:new ds(s)},oo=[],xc=function(s){s.forEach(function(e){oo.indexOf(e)<0&&(e(ds,hs),oo.push(e))})};const Pc="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Sc=(s=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(s|=0));for(;s--;)e+=Pc[t[s]&63];return e};function K(s){return s==null||s==="none"}function or(s,e=0,t=10**e){return Math.round(t*s)/t+0}function Ve(s,e=!1){if(typeof s!="object"||!s)return s;if(Array.isArray(s))return e?s.map(r=>Ve(r,e)):s;const t={};for(const r in s){const i=s[r];i!=null&&(e?t[r]=Ve(i,e):t[r]=i)}return t}function ar(s,e){const t={};return e.forEach(r=>{r in s&&(t[r]=s[r])}),t}function ps(s,e){if(s===e)return!0;if(s&&e&&typeof s=="object"&&typeof e=="object"){const t=Array.from(new Set([...Object.keys(s),...Object.keys(e)]));return!t.length||t.every(r=>s[r]===e[r])}return!1}function Cc(s,e,t){const r=e.length-1;if(r<0)return s===void 0?t:s;for(let i=0;i<r;i++){if(s==null)return t;s=s[e[i]]}return s==null||s[e[r]]===void 0?t:s[e[r]]}function Tc(s,e,t){const r=e.length-1;for(let i=0;i<r;i++)typeof s[e[i]]!="object"&&(s[e[i]]={}),s=s[e[i]];s[e[r]]=t}function Ec(s,e,t){return s==null||!e||typeof e!="string"?t:s[e]!==void 0?s[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Cc(s,e.split("."),t))}function Mc(s,e,t){if(!(typeof s!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Tc(s,e.split("."),t)}class Dt{_observers=new Map;on(e,t){let r=this._observers.get(e);return r===void 0&&this._observers.set(e,r=new Set),r.add(t),this}once(e,t){const r=(...i)=>{this.off(e,r),t(...i)};return this.on(e,r),this}off(e,t){const r=this._observers.get(e);return r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e)),this}emit(e,...t){return Array.from((this._observers.get(e)||new Map).values()).forEach(r=>r(...t)),this}destroy(){this._observers=new Map}}let ao=class{_map=new WeakMap;_toRaw(e){if(e&&typeof e=="object"){const t=e.__v_raw;t&&(e=this._toRaw(t))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,t){return this._map.set(this._toRaw(e),this._toRaw(t)),this}};const gs=Symbol("properties"),lo=Symbol("inited");function ms(s){let e;if(Object.hasOwn(s,gs))e=s[gs];else{const t=Object.getPrototypeOf(s);e=new Map(t?ms(t):void 0),s[gs]=e}return e}function co(s,e,t,r){const{alias:i,internalKey:n}=r,o=s[e];i?Mc(s,i,t):s[n]=t,s.onUpdateProperty?.(e,t,o)}function ho(s,e,t){const{alias:r,internalKey:i}=t;let n;return r?n=Ec(s,r):n=s[i],n=n??uo(s,e,t),n}function uo(s,e,t){const{default:r,fallback:i}=t;let n;if(r!==void 0&&!s[lo]){s[lo]=!0;const o=typeof r=="function"?r():r;o!==void 0&&(s[e]=o,n=o)}return n=n??(typeof i=="function"?i():i),n}function Ac(s,e){function t(){return typeof this.getProperty<"u"?this.getProperty(s):ho(this,s,e)}function r(i){typeof this.setProperty<"u"?this.setProperty(s,i):co(this,s,i,e)}return{get:t,set:r}}function yi(s,e,t={}){const r={...t,internalKey:Symbol(e)};ms(s).set(e,r);const i=Ac(e,r);Object.defineProperty(s.prototype,e,{get(){return i.get.call(this)},set(n){i.set.call(this,n)},configurable:!0,enumerable:!0})}function w(s){return function(e,t){if(typeof t!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");yi(e.constructor,t,s)}}class fo extends Dt{_propertyAccessor;_properties=new Map;_updatedProperties=new Map;_changedProperties=new Set;_updatingPromise=Promise.resolve();_updating=!1;constructor(e){super(),this.setProperties(e)}isDirty(e){return e?this._updatedProperties.has(e):this._updatedProperties.size>0}getProperty(e){const t=this.getPropertyDeclaration(e);if(t){if(t.internal||t.alias)return ho(this,e,t);{let r;return this._propertyAccessor?.getProperty?r=this._propertyAccessor.getProperty(e):r=this._properties.get(e),r??uo(this,e,t)}}}setProperty(e,t){const r=this.getPropertyDeclaration(e);if(r)if(r.internal||r.alias)co(this,e,t,r);else{const i=this.getProperty(e);this._propertyAccessor?.setProperty?.(e,t),this._properties.set(e,t),this.onUpdateProperty?.(e,t,i)}}getProperties(e){const t={};for(const[r,i]of this.getPropertyDeclarations())!i.internal&&!i.alias&&(!e||e.includes(r))&&(t[r]=this.getProperty(r));return t}setProperties(e){if(e&&typeof e=="object")for(const t in e)this.setProperty(t,e[t]);return this}resetProperties(){for(const[e,t]of this.getPropertyDeclarations())this.setProperty(e,typeof t.default=="function"?t.default():t.default);return this}getPropertyDeclarations(){return ms(this.constructor)}getPropertyDeclaration(e){return this.getPropertyDeclarations().get(e)}setPropertyAccessor(e){const t=this.getPropertyDeclarations();this._propertyAccessor=void 0;const r={};return t.forEach((i,n)=>{r[n]=this.getProperty(n)}),this._propertyAccessor=e,t.forEach((i,n)=>{const o=this.getProperty(n),a=r[n];o!==void 0&&!Object.is(o,a)&&(this.setProperty(n,o),!i.internal&&!i.alias&&this.requestUpdate(n,o,a))}),this}async _nextTick(){return"requestAnimationFrame"in globalThis?new Promise(e=>globalThis.requestAnimationFrame(e)):Promise.resolve()}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await this._nextTick(),this._updating&&(this.onUpdate(),this._updating=!1)}onUpdate(){this._update(this._updatedProperties),this._updatedProperties=new Map}onUpdateProperty(e,t,r){Object.is(t,r)||this.requestUpdate(e,t,r)}requestUpdate(e,t,r){e!==void 0&&(this._updatedProperties.set(e,r),this._changedProperties.add(e),this._updateProperty(e,t,r),this.emit("updateProperty",e,t,r)),this._updating||(this._updatingPromise=this._enqueueUpdate())}_update(e){}_updateProperty(e,t,r){}toJSON(){const e={};return this._properties.forEach((t,r)=>{t!==void 0&&(t&&typeof t=="object"?"toJSON"in t&&typeof t.toJSON=="function"?e[r]=t.toJSON():Array.isArray(t)?e[r]=[...t]:e[r]={...t}:e[r]=t)}),e}clone(){return new this.constructor(this.toJSON())}}function ys(s){let e;return typeof s=="number"?e={r:s>>24&255,g:s>>16&255,b:s>>8&255,a:(s&255)/255}:e=s,lt(e)}function Oc(s){return{r:or(s.r),g:or(s.g),b:or(s.b),a:or(s.a,3)}}function _i(s){const e=s.toString(16);return e.length<2?`0${e}`:e}const po="#000000FF";function kc(s){return ys(s).isValid()}function Le(s,e=!1){const t=ys(s);if(!t.isValid()){if(typeof s=="string")return s;const a=`Failed to normalizeColor ${s}`;if(e)throw new Error(a);return console.warn(a),po}const{r,g:i,b:n,a:o}=Oc(t.rgba);return`#${_i(r)}${_i(i)}${_i(n)}${_i(or(o*255))}`}var vi=vi||{};vi.parse=(function(){const s={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let e="";function t(A){const M=new Error(`${e}: ${A}`);throw M.source=e,M}function r(){const A=i();return e.length>0&&t("Invalid input not EOF"),A}function i(){return x(n)}function n(){return o("linear-gradient",s.linearGradient,l)||o("repeating-linear-gradient",s.repeatingLinearGradient,l)||o("radial-gradient",s.radialGradient,f)||o("repeating-radial-gradient",s.repeatingRadialGradient,f)}function o(A,M,F){return a(M,z=>{const Y=F();return Y&&(O(s.comma)||t("Missing comma before color stops")),{type:A,orientation:Y,colorStops:x(S)}})}function a(A,M){const F=O(A);if(F){O(s.startCall)||t("Missing (");const z=M(F);return O(s.endCall)||t("Missing )"),z}}function l(){const A=c();if(A)return A;const M=$("position-keyword",s.positionKeywords,1);return M?{type:"directional",value:M.value}:h()}function c(){return $("directional",s.sideOrCorner,1)}function h(){return $("angular",s.angleValue,1)||$("angular",s.radianValue,1)}function f(){let A,M=d(),F;return M&&(A=[],A.push(M),F=e,O(s.comma)&&(M=d(),M?A.push(M):e=F)),A}function d(){let A=g()||p();if(A)A.at=m();else{const M=y();if(M){A=M;const F=m();F&&(A.at=F)}else{const F=m();if(F)A={type:"default-radial",at:F};else{const z=P();z&&(A={type:"default-radial",at:z})}}}return A}function g(){const A=$("shape",/^(circle)/i,0);return A&&(A.style=N()||y()),A}function p(){const A=$("shape",/^(ellipse)/i,0);return A&&(A.style=P()||D()||y()),A}function y(){return $("extent-keyword",s.extentKeywords,1)}function m(){if($("position",/^at/,0)){const A=P();return A||t("Missing positioning value"),A}}function P(){const A=E();if(A.x||A.y)return{type:"position",value:A}}function E(){return{x:D(),y:D()}}function x(A){let M=A();const F=[];if(M)for(F.push(M);O(s.comma);)M=A(),M?F.push(M):t("One extra comma");return F}function S(){const A=_();return A||t("Expected color definition"),A.length=D(),A}function _(){return C()||U()||R()||B()||T()||G()||b()}function b(){return $("literal",s.literalColor,0)}function C(){return $("hex",s.hexColor,1)}function T(){return a(s.rgbColor,()=>({type:"rgb",value:x(L)}))}function B(){return a(s.rgbaColor,()=>({type:"rgba",value:x(L)}))}function G(){return a(s.varColor,()=>({type:"var",value:V()}))}function R(){return a(s.hslColor,()=>{O(s.percentageValue)&&t("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const M=L();O(s.comma);let F=O(s.percentageValue);const z=F?F[1]:null;O(s.comma),F=O(s.percentageValue);const Y=F?F[1]:null;return(!z||!Y)&&t("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[M,z,Y]}})}function U(){return a(s.hslaColor,()=>{const A=L();O(s.comma);let M=O(s.percentageValue);const F=M?M[1]:null;O(s.comma),M=O(s.percentageValue);const z=M?M[1]:null;O(s.comma);const Y=L();return(!F||!z)&&t("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[A,F,z,Y]}})}function V(){return O(s.variableName)[1]}function L(){return O(s.number)[1]}function D(){return $("%",s.percentageValue,1)||H()||I()||N()}function H(){return $("position-keyword",s.positionKeywords,1)}function I(){return a(s.calcValue,()=>{let A=1,M=0;for(;A>0&&M<e.length;){const z=e.charAt(M);z==="("?A++:z===")"&&A--,M++}A>0&&t("Missing closing parenthesis in calc() expression");const F=e.substring(0,M-1);return j(M-1),{type:"calc",value:F}})}function N(){return $("px",s.pixelValue,1)||$("em",s.emValue,1)}function $(A,M,F){const z=O(M);if(z)return{type:A,value:z[F]}}function O(A){let M,F;return F=/^\s+/.exec(e),F&&j(F[0].length),M=A.exec(e),M&&j(M[0].length),M}function j(A){e=e.substr(A)}return function(A){return e=A.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}})();const Dc=vi.parse.bind(vi);var bi=bi||{};bi.stringify=(function(){var s={"visit_linear-gradient":function(e){return s.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return s.visit_gradient(e)},"visit_radial-gradient":function(e){return s.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return s.visit_gradient(e)},visit_gradient:function(e){var t=s.visit(e.orientation);return t&&(t+=", "),e.type+"("+t+s.visit(e.colorStops)+")"},visit_shape:function(e){var t=e.value,r=s.visit(e.at),i=s.visit(e.style);return i&&(t+=" "+i),r&&(t+=" at "+r),t},"visit_default-radial":function(e){var t="",r=s.visit(e.at);return r&&(t+=r),t},"visit_extent-keyword":function(e){var t=e.value,r=s.visit(e.at);return r&&(t+=" at "+r),t},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return s.visit(e.value.x)+" "+s.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_calc:function(e){return"calc("+e.value+")"},visit_literal:function(e){return s.visit_color(e.value,e)},visit_hex:function(e){return s.visit_color("#"+e.value,e)},visit_rgb:function(e){return s.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return s.visit_color("rgba("+e.value.join(", ")+")",e)},visit_hsl:function(e){return s.visit_color("hsl("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%)",e)},visit_hsla:function(e){return s.visit_color("hsla("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%, "+e.value[3]+")",e)},visit_var:function(e){return s.visit_color("var("+e.value+")",e)},visit_color:function(e,t){var r=e,i=s.visit(t.length);return i&&(r+=" "+i),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var t="",r=e.length;return e.forEach(function(i,n){t+=s.visit(i),n<r-1&&(t+=", ")}),t},visit_object:function(e){return e.width&&e.height?s.visit(e.width)+" "+s.visit(e.height):""},visit:function(e){if(!e)return"";if(e instanceof Array)return s.visit_array(e);if(typeof e=="object"&&!e.type)return s.visit_object(e);if(e.type){var t=s["visit_"+e.type];if(t)return t(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return s.visit(e)}})(),bi.stringify.bind(bi);function go(s){const e=s.length-1;return s.map((t,r)=>{const i=t.value;let n=or(r/e,3),o="#00000000";switch(t.type){case"rgb":o=Le({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":o=Le({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":o=Le(t.value);break;case"hex":o=Le(`#${t.value}`);break}switch(t.length?.type){case"%":n=Number(t.length.value)/100;break}return{offset:n,color:o}})}function mo(s){let e=0;switch(s.orientation?.type){case"angular":e=Number(s.orientation.value);break}return{type:"linear-gradient",angle:e,stops:go(s.colorStops)}}function yo(s){return s.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:go(s.colorStops)}}function Mr(s){return s.startsWith("linear-gradient(")||s.startsWith("radial-gradient(")}function Ic(s){return Dc(s).map(e=>{switch(e?.type){case"linear-gradient":return mo(e);case"repeating-linear-gradient":return{...mo(e),repeat:!0};case"radial-gradient":return yo(e);case"repeating-radial-gradient":return{...yo(e),repeat:!0};default:return}}).filter(Boolean)}function Rc(s){let e;return typeof s=="string"?e={color:s}:e={...s},{color:Le(e.color)}}function Uc(s){let e;if(typeof s=="string"?e={image:s}:e={...s},e.image){const{type:t,...r}=Ic(e.image)[0]??{};switch(t){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return ar(e,["linearGradient","radialGradient","rotateWithShape"])}function Bc(s){let e;return typeof s=="string"?e={image:s}:e={...s},ar(e,["image","cropRect","stretchRect","tile","dpi","opacity","rotateWithShape"])}function Lc(s){let e;return typeof s=="string"?e={preset:s}:e={...s},K(e.foregroundColor)?delete e.foregroundColor:e.foregroundColor=Le(e.foregroundColor),K(e.backgroundColor)?delete e.backgroundColor:e.backgroundColor=Le(e.backgroundColor),ar(e,["preset","foregroundColor","backgroundColor"])}function _s(s){return!K(s.color)}function Nc(s){return typeof s=="string"?kc(s):_s(s)}function Fc(s){return!K(s.image)&&Mr(s.image)||!!s.linearGradient||!!s.radialGradient}function $c(s){return typeof s=="string"?Mr(s):Fc(s)}function zc(s){return!K(s.image)&&!Mr(s.image)}function Vc(s){return typeof s=="string"?!Mr(s):zc(s)}function Gc(s){return!K(s.preset)}function jc(s){return typeof s=="string"?!1:Gc(s)}function ct(s){const e=s&&typeof s=="object"?s.enabled:void 0;return Nc(s)?Ve({enabled:e,...Rc(s)}):$c(s)?Ve({enabled:e,...Uc(s)}):Vc(s)?Ve({enabled:e,...Bc(s)}):jc(s)?Ve({enabled:e,...Lc(s)}):{}}function Wc(s){return typeof s=="string"?{...ct(s)}:{...ct(s),...ar(s,["fillWithShape"])}}function qc(s){return typeof s=="string"?{...ct(s)}:{...ct(s),...ar(s,["fillWithShape"])}}const _o=()=>Sc(10);function wi(s){return typeof s=="string"?{...ct(s)}:{...ct(s),...ar(s,["width","style","lineCap","lineJoin","headEnd","tailEnd"])}}function Xc(s){return typeof s=="string"?{color:Le(s)}:{...s,color:K(s.color)?po:Le(s.color)}}function Hc(){return{boxShadow:"none"}}function Yc(s){return typeof s=="string"?s.startsWith("<svg")?{svg:s}:{paths:[{data:s}]}:Array.isArray(s)?{paths:s.map(e=>typeof e=="string"?{data:e}:e)}:s}function Kc(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function Zc(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Jc(){return{...Kc(),...Zc(),...Hc(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function Qc(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function eh(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function th(){return{...Qc(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function rh(){return{...eh(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function ih(){return{...rh(),...th(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function xi(s){return Ve({...s,color:K(s.color)?void 0:Le(s.color),backgroundColor:K(s.backgroundColor)?void 0:Le(s.backgroundColor),borderColor:K(s.borderColor)?void 0:Le(s.borderColor),outlineColor:K(s.outlineColor)?void 0:Le(s.outlineColor),shadowColor:K(s.shadowColor)?void 0:Le(s.shadowColor)})}function vo(){return{...Jc(),...ih()}}const sh=/\r\n|\n\r|\n|\r/,nh=new RegExp(`^(${sh.source})$`),oh=`
2
- `;function ah(s){return nh.test(s)}function vs(s){const e=[];function t(){return e[e.length-1]}function r(a,l,c){const h=a?xi(a):{},f=l?ct(l):void 0,d=c?wi(c):void 0,g=Ve({...h,fill:f,outline:d,fragments:[]});return e[e.length-1]?.fragments.length===0?e[e.length-1]=g:e.push(g),g}function i(a="",l,c,h){const f=l?xi(l):{},d=c?ct(c):void 0,g=h?wi(h):void 0;Array.from(a).forEach(p=>{if(ah(p)){const{fragments:y,fill:m,outline:P,...E}=t()||r();y.length||y.push(Ve({...f,fill:d,outline:g,content:oh})),r(E,m,P)}else{const y=t()||r(),m=y.fragments[y.fragments.length-1];if(m){const{content:P,fill:E,outline:x,...S}=m;if(ps(d,E)&&ps(g,x)&&ps(f,S)){m.content=`${P}${p}`;return}}y.fragments.push(Ve({...f,fill:d,outline:g,content:p}))}})}(Array.isArray(s)?s:[s]).forEach(a=>{if(typeof a=="string")r(),i(a);else if(bo(a)){const{content:l,fill:c,outline:h,...f}=a;r(f,c,h),i(l)}else if(lh(a)){const{fragments:l,fill:c,outline:h,...f}=a;r(f,c,h),l.forEach(d=>{const{content:g,fill:p,outline:y,...m}=d;i(g,m,p,y)})}else Array.isArray(a)?(r(),a.forEach(l=>{if(typeof l=="string")i(l);else if(bo(l)){const{content:c,fill:h,outline:f,...d}=l;i(c,d,h,f)}})):console.warn("Failed to parse text content",a)});const o=t();return o&&!o.fragments.length&&o.fragments.push({content:""}),e}function lh(s){return s&&typeof s=="object"&&"fragments"in s&&Array.isArray(s.fragments)}function bo(s){return s&&typeof s=="object"&&"content"in s&&typeof s.content=="string"}function wo(s){return typeof s=="string"||Array.isArray(s)?{content:vs(s)}:Ve({...s,content:vs(s.content??""),style:s.style?xi(s.style):void 0,effects:s.effects?s.effects.map(e=>xi(e)):void 0,measureDom:s.measureDom,fonts:s.fonts,fill:s.fill?ct(s.fill):void 0,outline:s.outline?wi(s.outline):void 0})}const Pi=new Map;function W(s,e){return function(t){Object.defineProperty(t.prototype,"is",{value:s,enumerable:!0,configurable:!0}),e&&Object.keys(e).forEach(r=>{yi(t,r,{fallback:e[r]})}),Pi.set(s,t)}}function ch(s="node",e={}){const t=Pi.get(s);if(!t)throw new Error(`Failed to createNode, tag: ${s}`);return new t().setProperties(e)}class Ce{static _queue=[];static _currentTime=0;static _elapsed=0;static _requestId;static get currentTime(){return this._currentTime}static get elapsed(){return this._elapsed}static on(e,t={}){const{sort:r=0,once:i=!1}=t;this._queue[r]||(this._queue[r]=[]),this._queue[r].push({cb:e,once:i})}static off(e,t={}){const{sort:r=0}=t,i=this._queue[r];if(!i)return;const n=[];for(let o=i.length,a=0;a<o;a++){const l=i[a];l.cb!==e&&n.push(l)}n.length?this._queue[r]=n:this._queue.splice(r,1)}static start(){"requestAnimationFrame"in globalThis&&(this._currentTime=performance.now(),this._requestId=requestAnimationFrame(e=>this._update(e)))}static stop(){this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=void 0)}static _update(e){this._elapsed=e-this._currentTime,this._currentTime=e,this._requestId=requestAnimationFrame(t=>this._update(t)),this._performUpdate()}static _performUpdate(){const e=this._queue,t=[];for(let r=e.length,i=r;i>=0;i--){const n=e[i];if(!n)continue;const o=[];for(let a=n.length,l=0;l<a;l++){const c=n[l];try{c.cb()}catch(h){console.warn(h)}c.once||o.push(c)}o.length&&(t[i]=o)}this._queue=t}}Ce.start();async function bs(s){return new Promise(e=>{Ce.on(()=>{s?.(),e()},{sort:1,once:!0})})}const Si=Math.PI,Ne=Si*2;let hh=0;function xo(s){return s?.__SPECTOR_Object_TAG?.id??++hh}function ws(s){return!(s&s-1)&&!!s}const uh=/([\w-]+)\((.+?)\)/g,fh=/[^,]+/g,dh=/([-e.\d]+)(.*)/;function xs(s){return Array.isArray(s)?s.map(e=>({name:e.name,args:e.args.map(t=>({...t,normalizedIntValue:t.normalizedDefaultIntValue}))})):{...s,normalizedIntValue:s.normalizedDefaultIntValue}}function Ar(s,e,t={}){const r=Or(e,t);return r.length?r:Po(s,e,t)}function Or(s,e={}){const t=[];let r;for(;(r=uh.exec(s))!==null;){const[,i,n]=r;i&&t.push({name:i,args:ph(i,n,e)})}return t}function ph(s,e,t={}){const r=[];let i,n=0;for(;(i=fh.exec(e))!==null;)r.push(Po(s,i[0],{...t,index:n++}));return r}function Po(s,e,t={}){const{width:r=1,height:i=1,index:n=0}=t,o=e.match(dh),a={unit:o?.[2]??null,value:e,intValue:Number(o?.[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(s){case"scale":case"scaleX":case"scaleY":case"scale3d":a.normalizedDefaultIntValue=1;break}switch(a.unit){case"%":a.normalizedIntValue=a.intValue/100;break;case"rad":a.normalizedIntValue=a.intValue/Ne;break;case"deg":a.normalizedIntValue=a.intValue/360;break;case"px":switch(n){case 0:a.normalizedIntValue=a.intValue/r;break;case 1:a.normalizedIntValue=a.intValue/i;break}break;case"turn":case"em":case"rem":default:a.normalizedIntValue=a.intValue;break}return a}const So="WebGL2RenderingContext"in globalThis,Co="ImageBitmap"in globalThis,To="ResizeObserver"in globalThis,lr="PointerEvent"in globalThis,Eo="WheelEvent"in globalThis,gh="MouseEvent"in globalThis,Pt="ontouchstart"in globalThis,Mo="onclick"in globalThis,Ps="createImageBitmap"in globalThis,Ss="AudioContext"in globalThis,Cs="webkitAudioContext"in globalThis,Ts="OfflineAudioContext"in globalThis,Ao="webkitOfflineAudioContext"in globalThis,Oo=Ss||Cs,kr=typeof window<"u",Es=globalThis.devicePixelRatio||1,Ms=s=>s!==null&&typeof s=="object"&&s.nodeType===1,ko=s=>Ms(s)&&s.tagName==="VIDEO",mh=s=>Ms(s)&&s.tagName==="IMG";function Do(s){return typeof s=="object"&&s!==null&&s.nodeType===1&&s.tagName==="CANVAS"}function Io(s){return So&&s instanceof globalThis.WebGL2RenderingContext}function Ro(){if(kr)return globalThis.document.createElement("canvas")}function Uo(s,e=globalThis.location){if(s.startsWith("data:"))return"";e=e||globalThis.location;const t=new URL(s,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}function Bo(s,e,t){t===null&&!e.startsWith("data:")?s.crossOrigin=Uo(e):t!==!1&&(s.crossOrigin=typeof t=="string"?t:"anonymous")}class As{_map=new WeakMap;_toRaw(e){if(e&&typeof e=="object"){const t=e.__v_raw;t&&(e=this._toRaw(t))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,t){return this._map.set(this._toRaw(e),this._toRaw(t)),this}}class Dr{cursor;bubbles=!1;cancelBubble=!1;cancelable=!1;composed=!1;defaultPrevented=!1;eventPhase=Dr.prototype.NONE;isTrusted=!1;timeStamp=0;type="";composedPath(){return this.path}initEvent(...e){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){"preventDefault"in this.nativeEvent&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}propagationImmediatelyStopped=!1;stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}propagationStopped=!1;stopPropagation(){"stopPropagation"in this.nativeEvent&&this.nativeEvent.stopPropagation(),this.propagationStopped=!0}NONE=0;CAPTURING_PHASE=1;AT_TARGET=2;BUBBLING_PHASE=3;initUIEvent(...e){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}}class Lo extends Dr{getModifierState(...e){throw new Error("getModifierState() is a legacy DOM API. It is not implemented in the Federated Events API.")}initKeyboardEvent(...e){throw new Error("initKeyboardEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}}class Os extends Dr{client={x:0,y:0};get clientX(){return this.client.x}get clientY(){return this.client.y}layer={x:0,y:0};get layerX(){return this.layer.x}get layerY(){return this.layer.y}movement={x:0,y:0};get movementX(){return this.movement.x}get movementY(){return this.movement.y}offset={x:0,y:0};get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}page={x:0,y:0};get pageX(){return this.page.x}get pageY(){return this.page.y}screen={x:0,y:0};get screenX(){return this.screen.x}get screenY(){return this.screen.y}get x(){return this.clientX}get y(){return this.clientY}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(...e){throw new Error("Method not implemented.")}global={x:0,y:0};get globalX(){return this.global.x}get globalY(){return this.global.y}}class No extends Os{width=0;height=0;isPrimary=!1;getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Fo extends Os{static DOM_DELTA_PIXEL=0;DOM_DELTA_PIXEL=0;static DOM_DELTA_LINE=1;DOM_DELTA_LINE=1;static DOM_DELTA_PAGE=2;DOM_DELTA_PAGE=2}const yh={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class $o extends Dt{event;target;cursor="default";cursorStyles={default:"inherit",pointer:"pointer"};setuped=!1;enableMoveEvent=!0;enableWheelEvent=!0;enableClickEvent=!0;setTarget(e){this.removeEventListeners(),this.target=e,this.addEventListeners()}removeEventListeners(){if(!this.setuped||!this.target)return;const e=this.target.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):lr&&(e.touchAction=""),lr?(this.target.removeEventListener("pointerdown",this._onPointerDown),this.target.removeEventListener("pointerleave",this._onPointerOver),this.target.removeEventListener("pointerover",this._onPointerOver),this.target.removeEventListener("pointermove",this._onPointerMove),this.target.removeEventListener("pointerup",this._onPointerUp)):(this.target.removeEventListener("mousedown",this._onPointerDown),this.target.removeEventListener("mouseout",this._onPointerOver),this.target.removeEventListener("mouseover",this._onPointerOver),this.target.removeEventListener("mousemove",this._onPointerMove),this.target.removeEventListener("mouseup",this._onPointerUp)),Pt&&(this.target.removeEventListener("touchstart",this._onPointerDown),this.target.removeEventListener("touchmove",this._onPointerMove),this.target.removeEventListener("touchend",this._onPointerUp)),this.target.removeEventListener("wheel",this._onWheel),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keypress",this._onKeyPress),document.removeEventListener("keyup",this._onKeyUp),this.target=void 0,this.setuped=!1}addEventListeners(){if(this.setuped||!this.target)return;const e=this.target.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):lr&&(e.touchAction="none")),lr?(this.target.addEventListener("pointerdown",this._onPointerDown),this.target.addEventListener("pointerleave",this._onPointerOver),this.target.addEventListener("pointerover",this._onPointerOver),this.target.addEventListener("pointermove",this._onPointerMove),this.target.addEventListener("pointerup",this._onPointerUp)):(this.target.addEventListener("mousedown",this._onPointerDown),this.target.addEventListener("mouseout",this._onPointerOver),this.target.addEventListener("mouseover",this._onPointerOver),this.target.addEventListener("mousemove",this._onPointerMove),this.target.addEventListener("mouseup",this._onPointerUp)),Pt&&(this.target.addEventListener("touchstart",this._onPointerDown),this.target.addEventListener("touchmove",this._onPointerMove),this.target.addEventListener("touchend",this._onPointerUp)),this.target.addEventListener("wheel",this._onWheel),document.addEventListener("keydown",this._onKeyDown),document.addEventListener("keypress",this._onKeyPress),document.addEventListener("keyup",this._onKeyUp),this.setuped=!0}normalize(e){const t=[];if(Pt&&e instanceof globalThis.TouchEvent)for(let r=0,i=e.changedTouches.length;r<i;r++){const n=e.changedTouches[r];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.type=e.type,t.push(n)}else if(Eo&&e instanceof globalThis.WheelEvent)t.push(e);else if(lr&&e instanceof globalThis.PointerEvent)t.push(e);else{const r=e;typeof r.isPrimary>"u"&&(r.isPrimary=!0),typeof r.width>"u"&&(r.width=1),typeof r.height>"u"&&(r.height=1),typeof r.tiltX>"u"&&(r.tiltX=0),typeof r.tiltY>"u"&&(r.tiltY=0),typeof r.pointerType>"u"&&(r.pointerType="mouse"),typeof r.pointerId>"u"&&(r.pointerId=1),typeof r.pressure>"u"&&(r.pressure=.5),typeof r.twist>"u"&&(r.twist=0),typeof r.tangentialPressure>"u"&&(r.tangentialPressure=0),t.push(r)}return t}_clonePointerEvent(e){const t=new No;return t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,t.isTrusted=e.isTrusted,this._copyMouseEvent(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.x=t.screen.x,t.global.y=t.screen.y,t.offset.x=t.screen.x,t.offset.y=t.screen.y,t.type==="pointerleave"?t.type="pointerout":t.type.startsWith("mouse")?t.type=t.type.replace("mouse","pointer"):t.type.startsWith("touch")&&(t.type=yh[t.type]||t.type),t}_copyInputEvent(e,t){e.nativeEvent=t,e.bubbles=t.bubbles,e.cancelBubble=t.cancelBubble,e.cancelable=t.cancelable,e.composed=t.composed,e.currentTarget=t.currentTarget,e.defaultPrevented=t.defaultPrevented,e.eventPhase=t.eventPhase,e.isTrusted=t.isTrusted,e.returnValue=t.returnValue,e.srcElement=t.srcElement,e.timeStamp=t.timeStamp,e.type=t.type}_copyMouseEvent(e,t){this._copyInputEvent(e,t),e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}_cloneWheelEvent(e){const t=new Fo;return this._copyMouseEvent(t,e),t.wheelDeltaY=e.wheelDeltaY,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.x=t.screen.x,t.global.y=t.screen.y,t.offset.x=t.screen.x,t.offset.y=t.screen.y,t}_cloneKeyboardEvent(e){const t=new Lo;return this._copyInputEvent(t,e),t.altKey=e.altKey,t.charCode=e.charCode,t.code=e.code,t.ctrlKey=e.ctrlKey,t.isComposing=e.isComposing,t.key=e.key,t.keyCode=e.keyCode,t.location=e.location,t.metaKey=e.metaKey,t.repeat=e.repeat,t.shiftKey=e.shiftKey,t}setCursor(e="default"){if(!this.target||this.cursor===e)return;this.cursor=e;const t=!(globalThis.OffscreenCanvas&&this.target instanceof OffscreenCanvas),r=this.cursorStyles[e];if(r)switch(typeof r){case"string":t&&(this.target.style.cursor=r);break;case"function":r(e);break;case"object":t&&Object.assign(this.target.style,r);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.target.style.cursor=e)}mapPositionToPoint(e,t,r){if(!this.target)return;const i=this.target.isConnected?this.target.getBoundingClientRect():void 0,n=Number(this.target.getAttribute("data-pixel-ratio"))||1,o=Number(this.target.getAttribute("width"))||(i?i.width*n:0),a=Number(this.target.getAttribute("height"))||(i?i.height*n:0),l=i??{width:o,height:a,left:0,top:0},c=1/n;e.x=(t-l.left)*(o/l.width)*c,e.y=(r-l.top)*(a/l.height)*c}_onKeyDown=e=>{const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("keydown",this.event=this._cloneKeyboardEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onKeyPress=e=>{const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("keypress",this.event=this._cloneKeyboardEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onKeyUp=e=>{const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("keyup",this.event=this._cloneKeyboardEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerDown=e=>{if(Pt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("pointerdown",this.event=this._clonePointerEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerOver=e=>{if(!this.enableClickEvent||Pt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("pointerover",this.event=this._clonePointerEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerMove=e=>{if(!this.enableMoveEvent||Pt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("pointermove",this.event=this._clonePointerEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerUp=e=>{if(!this.enableClickEvent||Pt&&e.pointerType==="touch")return;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const r=t!==this.target?"outside":"",i=this.normalize(e);for(let n=0,o=i.length;n<o;n++){const a=this._clonePointerEvent(i[n]);a.type+=r,this.emit("pointerup",this.event=a)}this.event?.cursor&&this.setCursor(this.event.cursor)};_onWheel=e=>{if(!this.enableWheelEvent)return;const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("wheel",this.event=this._cloneWheelEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)}}let _h=0;class It extends fo{instanceId=++_h;get json(){return this.toJSON()}set json(e){this.setProperties(e)}_nextTick(){return bs()}equal(e){return!!(e&&this.instanceId===e.instanceId)}}class zo extends It{}class St extends zo{}function vh(s,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var i in t)r[t[i]]=i;var n={};s.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,c=r[this.toHex()];if(c)return c;if(o?.closest){var h=this.toRgb(),f=1/0,d="black";if(!n.length)for(var g in t)n[g]=new s(t[g]).toRgb();for(var p in t){var y=(a=h,l=n[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));y<f&&(f=y,d=p)}return d}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new s(l).toRgb():null},"name"])}xc([vh]);class Qe{get value(){return this._value}set value(e){this._colord=ys(e??"none")}get r8(){return this._colord.rgba.r}get g8(){return this._colord.rgba.g}get b8(){return this._colord.rgba.b}get a8(){return this._colord.rgba.a*255&255}get r(){return this.r8/255}get g(){return this.g8/255}get b(){return this.b8/255}get a(){return this._colord.rgba.a}get rgb(){return(this.r8<<16)+(this.g8<<8)+this.b8}get bgr(){return(this.b8<<16)+(this.g8<<8)+this.r8}get abgr(){return(this.a8<<24)+this.bgr}constructor(e=0){this.value=e}toHex(){return this._colord.toHex()}toRgb(){return this._colord.toRgb()}toRgbString(){return this._colord.toRgbString()}toHsl(){return this._colord.toHsl()}toHslString(){return this._colord.toHslString()}toHsv(){return this._colord.toHsv()}toArgb(e=this.a,t=!0){if(e===1)return(255<<24)+this.rgb;if(e===0)return t?0:this.rgb;let r=this.r8,i=this.g8,n=this.b8;return t&&(r=r*e+.5|0,i=i*e+.5|0,n=n*e+.5|0),(e*255<<24)+(r<<16)+(i<<8)+n}toInt8Array(){return[this.r8,this.g8,this.b8,this.a8]}toArray(){return[this.r,this.g,this.b,this.a]}}class et extends Dt{constructor(e){super(),this.dim=e}_array=[];get length(){return this.dim}operate(e,t,r){const{dim:i,_array:n}=this;let o;typeof t=="number"?o=Array.from({length:i},()=>t):t instanceof ht||t instanceof et?o=t.toArray():o=t;let a,l=[];if(r?r instanceof et?a=r:l=r:a=this,t instanceof ht){const{cols:c}=t;switch(e){case"*":for(let h=0;h<i;h++){let f=0;for(let d=0;d<i;d++)f+=n[h]*o[d*c+h];l[h]=f}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"+":for(let c=0;c<i;c++)l[c]=n[c]+o[c];break;case"-":for(let c=0;c<i;c++)l[c]=n[c]-o[c];break;case"*":for(let c=0;c<i;c++)l[c]=n[c]*o[c];break;case"/":for(let c=0;c<i;c++)l[c]=n[c]/o[c];break;case"rot":{const c=Math.cos(o[0]),h=Math.sin(o[0]);l[0]=n[0]*c-n[1]*h,l[1]=n[1]*c+n[0]*h;break}case"==":{let c=!0;for(let h=0;h<i;h++)c=c&&n[h]===o[h];return c}case"=":for(let c=0;c<i;c++){const h=o[c];h!==void 0&&(n[c]=h)}return this._onUpdate(n),this.emit("update",n),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Vector'`)}return a?.set(l)??l}add(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this.operate("+",e)}sub(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this.operate("-",e)}multiply(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this.operate("*",e)}divide(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this.operate("/",e)}rotate(e){return this.operate("rot",e)}set(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this.operate("=",e)}equals(e){return this.operate("==",e)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}_onUpdate(e){}toName(){return`Vector${this.dim}`}toArray(){return this._array.slice()}toJSON(){return this.toArray()}}class ht extends Dt{constructor(e,t,r){super(),this.rows=e,this.cols=t,r?this.set(r):this.identity()}_array=[];dirtyId=0;get length(){return this.cols*this.rows}operate(e,t,r){const{cols:i,rows:n,length:o,_array:a}=this;let l;typeof t=="number"?l=Array.from({length:o},()=>t):t instanceof et||t instanceof ht?l=t.toArray():l=t;let c,h=[];if(r?r instanceof et||r instanceof ht?c=r:h=r:t instanceof et?c=new t.constructor:c=this,t instanceof et){const{dim:f}=t;switch(e){case"*":for(let d=0;d<f;d++){let g=0;for(let p=0;p<i;p++)p<f&&(g+=a[d*i+p]*(l[p]??0));h[d]=g}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let f=0;f<i;f++)for(let d=0;d<n;d++){const g=d*i;let p=0;for(let y=0;y<n;y++){const m=g+y,P=y*i+f;p+=a[m]*(l[P]??0)}h[g+f]=p}break;case"=":for(let f=0;f<o;f++){const d=l[f];d!==void 0&&(a[f]=d)}return this._onUpdate(a),this.emit("update",a),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Matrix2'`)}return c?.set(h)??h}identity(){const{cols:e,rows:t}=this,r=[];for(let i=0;i<e;i++)for(let n=0;n<t;n++){const o=n*e,a=i+o;r[a]=n+o===a?1:0}return this.set(r)}set(e){return this.operate("=",e)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}multiply(e,t){return this.operate("*",e,t)}_onUpdate(e){this.dirtyId++}toArray(e=!1){const{cols:t,rows:r,_array:i}=this;if(e){const n=[];for(let o=0;o<r;o++)for(let a=0;a<t;a++)n[o+a*t]=i[a+o*t];return n}return i.slice()}toName(){return`Matrix${this.rows}(${this.rows}x${this.cols})`}toJSON(){return this._array.slice()}}class Vo extends ht{constructor(e){super(4,4,e)}}const Go=Si/180,bh=180/Si;function Ge(s,e,t){return Math.max(e,Math.min(s,t))}function he(s,e,t){return(1-t)*s+t*e}const wh={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(s,e=20){if(!this.adaptive||!s||Number.isNaN(s))return e;let t=Math.ceil(s/this.maxLength);return t<this.minSegments?t=this.minSegments:t>this.maxSegments&&(t=this.maxSegments),t}};class jo extends et{constructor(e=0,t=0,r=0,i=0){super(4),this.set(e,t,r,i)}}class ks extends ht{constructor(e){super(4,5,e)}hueRotate(e=0){const t=Math.sin(e),r=Math.cos(e),i=.213,n=.715,o=.072;return this.multiply([i+r*(1-i)+t*-i,n+r*-n+t*-n,o+r*-o+t*(1-o),0,0,i+r*-i+t*.143,n+r*(1-n)+t*.14,o+r*-o+t*-.283,0,0,i+r*-i+t*-.787,n+r*-n+t*n,o+r*(1-o)+t*o,0,0,0,0,0,1,0])}saturate(e=1){const t=(e-1)*2/3+1,r=(t-1)*-.5;return this.multiply([t,r,r,0,0,r,t,r,0,0,r,r,t,0,0,0,0,0,1,0])}brightness(e=1){const t=e;return this.multiply([t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0])}contrast(e=1){const t=e,r=-128*(t-1);return this.multiply([t,0,0,0,r,0,t,0,0,r,0,0,t,0,r,0,0,0,1,0])}invert(e=1){const t=he(1,-1,e),r=he(0,255,e);return this.multiply([t,0,0,0,r,0,t,0,0,r,0,0,t,0,r,0,0,0,1,0])}sepia(e=1){const t=Ge(e,0,1);return this.multiply([he(1,.393,t),he(0,.7689999,t),he(0,.18899999,t),0,0,he(0,.349,t),he(1,.6859999,t),he(0,.16799999,t),0,0,he(0,.272,t),he(0,.5339999,t),he(1,.13099999,t),0,0,0,0,0,1,0])}opacity(e=1){return this.multiply([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,e,0])}grayscale(e=1){const t=Ge(e,0,1),r=he(1,.3,t),i=he(0,.3,t),n=he(1,.59,t),o=he(0,.59,t),a=he(1,.11,t),l=he(0,.11,t);return this.multiply([r,o,l,0,0,i,n,l,0,0,i,o,a,0,0,0,0,0,1,0])}multiply(e){const t=e,r=this._array;return this.set([r[0]*t[0]+r[1]*t[5]+r[2]*t[10]+r[3]*t[15],r[0]*t[1]+r[1]*t[6]+r[2]*t[11]+r[3]*t[16],r[0]*t[2]+r[1]*t[7]+r[2]*t[12]+r[3]*t[17],r[0]*t[3]+r[1]*t[8]+r[2]*t[13]+r[3]*t[18],r[0]*t[4]+r[1]*t[9]+r[2]*t[14]+r[3]*t[19]+r[4],r[5]*t[0]+r[6]*t[5]+r[7]*t[10]+r[8]*t[15],r[5]*t[1]+r[6]*t[6]+r[7]*t[11]+r[8]*t[16],r[5]*t[2]+r[6]*t[7]+r[7]*t[12]+r[8]*t[17],r[5]*t[3]+r[6]*t[8]+r[7]*t[13]+r[8]*t[18],r[5]*t[4]+r[6]*t[9]+r[7]*t[14]+r[8]*t[19]+r[9],r[10]*t[0]+r[11]*t[5]+r[12]*t[10]+r[13]*t[15],r[10]*t[1]+r[11]*t[6]+r[12]*t[11]+r[13]*t[16],r[10]*t[2]+r[11]*t[7]+r[12]*t[12]+r[13]*t[17],r[10]*t[3]+r[11]*t[8]+r[12]*t[13]+r[13]*t[18],r[10]*t[4]+r[11]*t[9]+r[12]*t[14]+r[13]*t[19]+r[14],r[15]*t[0]+r[16]*t[5]+r[17]*t[10]+r[18]*t[15],r[15]*t[1]+r[16]*t[6]+r[17]*t[11]+r[18]*t[16],r[15]*t[2]+r[16]*t[7]+r[17]*t[12]+r[18]*t[17],r[15]*t[3]+r[16]*t[8]+r[17]*t[13]+r[18]*t[18],r[15]*t[4]+r[16]*t[9]+r[17]*t[14]+r[18]*t[19]+r[19]])}toMatrix4(){const e=this._array;return new Vo([e[0],e[1],e[2],e[3],e[5],e[6],e[7],e[8],e[10],e[11],e[12],e[13],e[15],e[16],e[17],e[18]])}toVector4(){const e=this._array;return new jo(e[4]/255,e[9]/255,e[14]/255,e[19]/255)}}class xh extends ht{constructor(e){super(2,2,e)}}let Ds=class extends ht{constructor(e){super(3,3,e)}affineInvert(){const[e,t,r,i,n,o,a,l,c]=this._array,h=c*n-o*l,f=o*a-c*i,d=l*i-n*a,g=e*h+t*f+r*d;if(g===0)return this.set([0,0,0,0,0,0,0,0,0]);const p=1/g;return this.set([h*p,(r*l-c*t)*p,(o*t-r*n)*p,f*p,(c*e-r*a)*p,(r*i-o*e)*p,d*p,(t*a-l*e)*p,(n*e-t*i)*p])}};class Wo extends Ds{constructor(e=0,t=0,r=0,i=0,n=!1){super(),this._x=e,this._y=t,this._width=r,this._height=i,this._flipY=n,this._performUpdateArray()}flipY(e){return this._flipY!==e&&(this._flipY=e,this._performUpdateArray()),this}translate(e,t){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._performUpdateArray()),this}resize(e,t){return(this._width!==e||this._height!==t)&&(this._width=e,this._height=t,this._performUpdateArray()),this}_performUpdateArray(){const e=this._width,t=this._height;if(!e||!t)return;const r=this._x,i=this._y,n=this._flipY?-1:1,o=1/e*2,a=n*(1/t*2),l=-1-r*o,c=-n-i*a;this.set([o,0,l,0,a,c,0,0,1])}}let de=class hc extends et{get x(){return this._array[0]}set x(e){const[t,r]=this._array;t!==e&&this.set(e,r)}get y(){return this._array[1]}set y(e){const[t,r]=this._array;r!==e&&this.set(t,e)}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}get left(){return this.x}set left(e){this.x=e}get top(){return this.y}set top(e){this.y=e}constructor(e=0,t){super(2),this.set(typeof e=="number"?[e,t??e]:e)}update(e,t){const[r,i]=this._array;return(r!==e||i!==t)&&this.set(e,t),this}getLength(){const[e,t]=this._array;return Math.sqrt(e*e+t*t)}getAngle(){const[e,t]=this._array;return Math.atan2(-e,-t)+Math.PI}distanceTo(e){return Math.hypot(e.x-this.x,e.y-this.y)}normalize(){const[e,t]=this._array,r=1/(this.getLength()||1);return this.set(e*r,t*r),this}static lerp(e,t,r){return new hc(t).clone().sub(e).multiply(r).add(e)}};class Rt{get x(){return this.position.x}get y(){return this.position.y}get left(){return this.position.x}get top(){return this.position.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get width(){return this.size.x}get height(){return this.size.y}end=new de;position;size;constructor(...e){const t=new de,r=new de;switch(e.length){case 0:break;case 1:{const i=e[0];if(i instanceof Rt)t.set(i.position),r.set(i.size);else{const n=i.map(f=>f.x),o=i.map(f=>f.y),a=Math.min(...n),l=Math.max(...n),c=Math.min(...o),h=Math.max(...o);t.set(a,c),r.set(l-a,h-c)}break}case 2:t.set(e[0]),r.set(e[1]);break;default:t.set(e[0],e[1]),r.set(e[2],e[3]);break}this.update=this.update.bind(this),this.position=t.on("update",this.update),this.size=r.on("update",this.update),this.update()}update(){return this.end.set(this.position.x+this.size.x,this.position.y+this.size.y),this}toMinmax(){return{minX:this.position.x,minY:this.position.y,maxX:this.end.x,maxY:this.end.y}}toArray(){return[this.x,this.y,this.width,this.height]}toJSON(){return{x:this.x,y:this.y,width:this.width,height:this.height}}}class ve extends Ds{static _t2d=new ve;premultiply(e){return e.multiply(this,this)}skewX(e){return this.skew(e,0)}skewY(e){return this.skew(0,e)}skew(e,t){return this.premultiply(ve._t2d.makeSkew(e,t))}makeSkew(e,t){const r=Math.tan(e),i=Math.tan(t);return this.set([1,i,0,r,1,0,0,0,1]),this}translateX(e){return this.translate(e,0)}translateY(e){return this.translate(0,e)}translateZ(e){return this.translate(0,0,e)}translate3d(e,t,r){return this.translate(e,t,r)}translate(e,t,r=0){return this.premultiply(ve._t2d.makeTranslation(e,t,r))}makeTranslation(e,t,r=0){return this.set([1,0,e,0,1,t,0,0,1]),this}scaleX(e){return this.scale(e,1)}scaleY(e){return this.scale(1,e)}scale3d(e,t,r=1){return this.scale(e,t,r)}scale(e,t,r=1){return this.premultiply(ve._t2d.makeScale(e,t,r))}makeScale(e,t,r=1){return this.set([e,0,0,0,t,0,0,0,1]),this}rotateX(e){return this.scaleY(this._rotateToScale(e))}rotateY(e){return this.scaleX(this._rotateToScale(e))}rotateZ(e){return this.rotate(e)}rotate(e){return this.premultiply(ve._t2d.makeRotation(e))}rotate3d(e,t,r,i){const[n,o,a]=this._rotate3d(e,t,r,i);return n&&this.rotateX(n),o&&this.rotateY(o),a&&this.rotateZ(a),this}_rotateToScale(e){const t=e/Ne;return t<=.5?t*-4+1:(t-1)*4+1}_rotate3d(e,t,r,i){if(e===1&&t===0&&r===0)return[i,0,0];if(e===0&&t===1&&r===0)return[0,i,0];if(e===0&&t===0)return[0,0,i];{const n=Math.cos(i),o=Math.sin(i),a=n+e*e*(1-n),l=e*t*(1-n)-r*o,c=e*r*(1-n)+t*o,h=n+t*t*(1-n),f=t*r*(1-n)-e*o,d=n+r*r*(1-n),g=-Math.atan2(-f,h),p=-Math.atan2(c,Math.sqrt(f*f+d*d)),y=-Math.atan2(-l,a);return[g,p,y]}}makeRotation(e){const t=Math.cos(e),r=Math.sin(e);return this.set([t,-r,0,r,t,0,0,0,1]),this}decompose(e={x:0,y:0},t={position:{x:0,y:0},scale:{x:0,y:0},skew:{x:0,y:0},rotation:0}){const{a:r,b:i,c:n,d:o,tx:a,ty:l}=this.toObject(),c=-Math.atan2(-n,o),h=Math.atan2(i,r),f=Math.abs(c+h);return f<1e-5||Math.abs(Ne-f)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=c,t.skew.y=h),t.scale.x=Math.sqrt(r*r+i*i),t.scale.y=Math.sqrt(n*n+o*o),t.position.x=a+(e.x*r+e.y*n),t.position.y=l+(e.x*i+e.y*o),t}apply(e,t){t=t||new de;const{a:r,c:i,tx:n,b:o,d:a,ty:l}=this.toObject(),c=e.x,h=e.y;return t.x=r*c+i*h+n,t.y=o*c+a*h+l,t}affineInverse(){return this.clone().affineInvert()}applyAffineInverse(e,t){t=t||new de;const{a:r,b:i,c:n,d:o,tx:a,ty:l}=this.toObject(),c=1/(r*o+n*-i),h=e.x,f=e.y;return t.x=o*c*h+-n*c*f+(l*n-a*o)*c,t.y=r*c*f+-i*c*h+(-l*r+a*i)*c,t}isIdentity(){const{a:e,b:t,c:r,d:i,tx:n,ty:o}=this.toObject();return e===1&&t===0&&r===0&&i===1&&n===0&&o===0}toObject(){const[e,t,r,i,n,o,,,a]=this._array;return{a:e,c:t,tx:r,b:i,d:n,ty:o,tz:a}}}class Ph extends et{constructor(){super(3)}}var Sh=Object.defineProperty,qo=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Sh(e,t,i),i};class Ci extends It{_starting=!1;_nextDeltaTime=0;_startedProcess;get starting(){return this._starting}get spf(){return this.fps?Math.floor(1e3/this.fps):0}constructor(){super(),this._onNextTick=this._onNextTick.bind(this)}start(e){this._starting||(this._starting=!0,this._startedProcess&&this.off("process",this._startedProcess),this._startedProcess=e,this.on("process",e),Ce.on(this._onNextTick,{sort:0}))}stop(){this._starting&&(this._starting=!1,Ce.off(this._onNextTick,{sort:0}))}_onNextTick(){const e=Ce.elapsed*this.speed;if((this._nextDeltaTime-=e)<=0){const r=(this._nextDeltaTime=this.spf)||e;this.emit("process",r)}}destroy(){super.destroy(),this.stop()}}qo([w({fallback:60})],Ci.prototype,"fps"),qo([w({fallback:1})],Ci.prototype,"speed");class Xo{view;pixelRatio=Es;screen={x:0,y:0,width:0,height:0};related=new As;getRelated(e,t){let r=this.related.get(e);return r||(t?(this.related.set(e,r=t()),r):(console.warn("Failed to get related",e),null))}resize(e,t,r=!0){this.view&&(this.view.width=Math.floor(e*this.pixelRatio),this.view.height=Math.floor(t*this.pixelRatio)),this.screen.width=e,this.screen.height=t,r&&this.view&&(this.view.style.width=`${e}px`,this.view.style.height=`${t}px`)}}var cr=(s=>(s.NORMAL="normal",s.ADD="add",s.MULTIPLY="multiply",s.SCREEN="screen",s.NONE="none",s.NORMAL_NPM="normal_npm",s.ADD_NPM="add_npm",s.SCREEN_NPM="screen_npm",s.SRC_IN="src_in",s.SRC_OUT="src_out",s.SRC_ATOP="src_atop",s.DST_OVER="dst_over",s.DST_IN="dst_in",s.DST_OUT="dst_out",s.DST_ATOP="dst_atop",s.XOR="xor",s.SUBTRACT="subtract",s))(cr||{});function Ho(s){return{normal:[s.ONE,s.ONE_MINUS_SRC_ALPHA],add:[s.ONE,s.ONE],multiply:[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],screen:[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],none:[0,0],normal_npm:[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],add_npm:[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],screen_npm:[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],src_in:[s.DST_ALPHA,s.ZERO],src_out:[s.ONE_MINUS_DST_ALPHA,s.ZERO],src_atop:[s.DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],dst_over:[s.ONE_MINUS_DST_ALPHA,s.ONE],dst_in:[s.ZERO,s.SRC_ALPHA],dst_out:[s.ZERO,s.ONE_MINUS_SRC_ALPHA],dst_atop:[s.ONE_MINUS_DST_ALPHA,s.SRC_ALPHA],xor:[s.ONE_MINUS_DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],subtract:[s.ONE,s.ONE,s.ONE,s.ONE,s.FUNC_REVERSE_SUBTRACT,s.FUNC_ADD]}}class Ye{get gl(){return this._renderer.gl}install(e){this._renderer=e}onUpdateContext(){}flush(){}reset(){}destroy(){}}class Xt{static _properties=["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"];static _init(){this._properties.forEach((e,t)=>{Object.defineProperty(this.prototype,e,{get(){return!!(this.bitmap&1<<t)},set(r){!!(this.bitmap&1<<t)!==r&&(this.bitmap^=1<<t)},enumerable:!0,configurable:!0})})}static for2D(){const e=new Xt;return e.depthTest=!1,e.blend=!0,e}_blendMode=cr.NORMAL;_polygonOffset=0;bitmap=0;get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!==cr.NONE,this._blendMode=e}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}constructor(e){if(e)for(const t in e)this[t]=e[t]}}Xt._init();class Yo extends Ye{install(e){super.install(e),e.state=this}_blendEq=!1;_setters=Xt._properties.map(e=>this[`set${e.replace(/^\S/,t=>t.toUpperCase())}`]);boundStateBitmap=0;boundBlendMode;blendModes;defaultState=new Xt({blend:!0});onUpdateContext(){super.onUpdateContext(),this.blendModes=Ho(this._renderer.gl)}toggle(e,t){this._renderer.gl[t?"enable":"disable"](e)}setBlend(e){this.toggle(this._renderer.gl.BLEND,e)}setOffsets(e){this.toggle(this._renderer.gl.POLYGON_OFFSET_FILL,e)}setCulling(e){this.toggle(this._renderer.gl.CULL_FACE,e)}setDepthTest(e){this.toggle(this._renderer.gl.DEPTH_TEST,e)}setDepthMask(e){this._renderer.gl.depthMask(e)}setClockwiseFrontFace(e){const t=this._renderer.gl;t.frontFace(t[e?"CW":"CCW"])}setBlendMode(e){if(e===this.boundBlendMode)return;this.boundBlendMode=e;const t=this.blendModes[e],r=this._renderer.gl;t.length===2?r.blendFunc(t[0],t[1]):r.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,r.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.FUNC_ADD))}setPolygonOffset(e,t){this._renderer.gl.polygonOffset(e,t)}bind(e){if(this.boundStateBitmap!==e.bitmap){let t=this.boundStateBitmap^e.bitmap,r=0;for(;t;)t&1&&this._setters[r]?.call(this,!!(e.bitmap&1<<r)),t=t>>1,r++;this.boundStateBitmap=e.bitmap}e.blend&&this.setBlendMode(e.blendMode),e.offsets&&this.setPolygonOffset(1,e.polygonOffset)}reset(){super.reset();const e=this._renderer.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),this.bind(this.defaultState),this._blendEq=!0,this.setBlendMode(cr.NORMAL)}}class Ko extends Ye{install(e){super.install(e),e.batch2D=this}_state=Xt.for2D();_batchSize=4096*4;_drawCallUid=0;_defaultModulate=[255,255,255,255];_defaultBackgroundColor=[0,0,0,0];_batchables=[];_vertexCount=0;_indexCount=0;_attributeBuffer=[];_indexBuffers=[];_shaders=new Map;_attributes={aTextureId:{size:1,normalized:!0,type:"float"},aPosition:{size:2,normalized:!1,type:"float"},aUv:{size:2,normalized:!1,type:"float"},aModulate:{size:4,normalized:!0,type:"unsigned_byte"},aBackgroundColor:{size:4,normalized:!0,type:"unsigned_byte"},aDisableWrapMode:{size:1,normalized:!0,type:"float"}};_vertexSize=8;_getShader(e){let t=this._shaders.get(e);return t||this._shaders.set(e,t=this._createShader(e)),t}_createShader(e){const t=this._renderer,r=t.program.create({vert:`precision highp float;
1
+ (function(u,Tr){typeof exports=="object"&&typeof module<"u"?Tr(exports):typeof define=="function"&&define.amd?define(["exports"],Tr):(u=typeof globalThis<"u"?globalThis:u||self,Tr(u.modernCanvas={}))})(this,(function(u){"use strict";var Tr={grad:.9,turn:360,rad:360/(2*Math.PI)},xt=function(s){return typeof s=="string"?s.length>0:typeof s=="number"},pe=function(s,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*s)/t+0},He=function(s,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),s>t?t:s>e?s:e},Zn=function(s){return(s=isFinite(s)?s%360:0)>0?s:s+360},Jn=function(s){return{r:He(s.r,0,255),g:He(s.g,0,255),b:He(s.b,0,255),a:He(s.a)}},cs=function(s){return{r:pe(s.r),g:pe(s.g),b:pe(s.b),a:pe(s.a,3)}},mc=/^#([0-9a-f]{3,8})$/i,mi=function(s){var e=s.toString(16);return e.length<2?"0"+e:e},Qn=function(s){var e=s.r,t=s.g,r=s.b,i=s.a,n=Math.max(e,t,r),o=n-Math.min(e,t,r),a=o?n===e?(t-r)/o:n===t?2+(r-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:i}},eo=function(s){var e=s.h,t=s.s,r=s.v,i=s.a;e=e/360*6,t/=100,r/=100;var n=Math.floor(e),o=r*(1-t),a=r*(1-(e-n)*t),l=r*(1-(1-e+n)*t),c=n%6;return{r:255*[r,a,o,o,l,r][c],g:255*[l,r,r,a,o,o][c],b:255*[o,o,l,r,r,a][c],a:i}},to=function(s){return{h:Zn(s.h),s:He(s.s,0,100),l:He(s.l,0,100),a:He(s.a)}},ro=function(s){return{h:pe(s.h),s:pe(s.s),l:pe(s.l),a:pe(s.a,3)}},io=function(s){return eo((t=(e=s).s,{h:e.h,s:(t*=((r=e.l)<50?r:100-r)/100)>0?2*t/(r+t)*100:0,v:r+t,a:e.a}));var e,t,r},Er=function(s){return{h:(e=Qn(s)).h,s:(i=(200-(t=e.s))*(r=e.v)/100)>0&&i<200?t*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,t,r,i},yc=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,_c=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bc=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hs={string:[[function(s){var e=mc.exec(s);return e?(s=e[1]).length<=4?{r:parseInt(s[0]+s[0],16),g:parseInt(s[1]+s[1],16),b:parseInt(s[2]+s[2],16),a:s.length===4?pe(parseInt(s[3]+s[3],16)/255,2):1}:s.length===6||s.length===8?{r:parseInt(s.substr(0,2),16),g:parseInt(s.substr(2,2),16),b:parseInt(s.substr(4,2),16),a:s.length===8?pe(parseInt(s.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(s){var e=vc.exec(s)||bc.exec(s);return e?e[2]!==e[4]||e[4]!==e[6]?null:Jn({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(s){var e=yc.exec(s)||_c.exec(s);if(!e)return null;var t,r,i=to({h:(t=e[1],r=e[2],r===void 0&&(r="deg"),Number(t)*(Tr[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return io(i)},"hsl"]],object:[[function(s){var e=s.r,t=s.g,r=s.b,i=s.a,n=i===void 0?1:i;return xt(e)&&xt(t)&&xt(r)?Jn({r:Number(e),g:Number(t),b:Number(r),a:Number(n)}):null},"rgb"],[function(s){var e=s.h,t=s.s,r=s.l,i=s.a,n=i===void 0?1:i;if(!xt(e)||!xt(t)||!xt(r))return null;var o=to({h:Number(e),s:Number(t),l:Number(r),a:Number(n)});return io(o)},"hsl"],[function(s){var e=s.h,t=s.s,r=s.v,i=s.a,n=i===void 0?1:i;if(!xt(e)||!xt(t)||!xt(r))return null;var o=(function(a){return{h:Zn(a.h),s:He(a.s,0,100),v:He(a.v,0,100),a:He(a.a)}})({h:Number(e),s:Number(t),v:Number(r),a:Number(n)});return eo(o)},"hsv"]]},so=function(s,e){for(var t=0;t<e.length;t++){var r=e[t][0](s);if(r)return[r,e[t][1]]}return[null,void 0]},wc=function(s){return typeof s=="string"?so(s.trim(),hs.string):typeof s=="object"&&s!==null?so(s,hs.object):[null,void 0]},us=function(s,e){var t=Er(s);return{h:t.h,s:He(t.s+100*e,0,100),l:t.l,a:t.a}},fs=function(s){return(299*s.r+587*s.g+114*s.b)/1e3/255},no=function(s,e){var t=Er(s);return{h:t.h,s:t.s,l:He(t.l+100*e,0,100),a:t.a}},ds=(function(){function s(e){this.parsed=wc(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return s.prototype.isValid=function(){return this.parsed!==null},s.prototype.brightness=function(){return pe(fs(this.rgba),2)},s.prototype.isDark=function(){return fs(this.rgba)<.5},s.prototype.isLight=function(){return fs(this.rgba)>=.5},s.prototype.toHex=function(){return e=cs(this.rgba),t=e.r,r=e.g,i=e.b,o=(n=e.a)<1?mi(pe(255*n)):"","#"+mi(t)+mi(r)+mi(i)+o;var e,t,r,i,n,o},s.prototype.toRgb=function(){return cs(this.rgba)},s.prototype.toRgbString=function(){return e=cs(this.rgba),t=e.r,r=e.g,i=e.b,(n=e.a)<1?"rgba("+t+", "+r+", "+i+", "+n+")":"rgb("+t+", "+r+", "+i+")";var e,t,r,i,n},s.prototype.toHsl=function(){return ro(Er(this.rgba))},s.prototype.toHslString=function(){return e=ro(Er(this.rgba)),t=e.h,r=e.s,i=e.l,(n=e.a)<1?"hsla("+t+", "+r+"%, "+i+"%, "+n+")":"hsl("+t+", "+r+"%, "+i+"%)";var e,t,r,i,n},s.prototype.toHsv=function(){return e=Qn(this.rgba),{h:pe(e.h),s:pe(e.s),v:pe(e.v),a:pe(e.a,3)};var e},s.prototype.invert=function(){return ct({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},s.prototype.saturate=function(e){return e===void 0&&(e=.1),ct(us(this.rgba,e))},s.prototype.desaturate=function(e){return e===void 0&&(e=.1),ct(us(this.rgba,-e))},s.prototype.grayscale=function(){return ct(us(this.rgba,-1))},s.prototype.lighten=function(e){return e===void 0&&(e=.1),ct(no(this.rgba,e))},s.prototype.darken=function(e){return e===void 0&&(e=.1),ct(no(this.rgba,-e))},s.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},s.prototype.alpha=function(e){return typeof e=="number"?ct({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):pe(this.rgba.a,3);var t},s.prototype.hue=function(e){var t=Er(this.rgba);return typeof e=="number"?ct({h:e,s:t.s,l:t.l,a:t.a}):pe(t.h)},s.prototype.isEqual=function(e){return this.toHex()===ct(e).toHex()},s})(),ct=function(s){return s instanceof ds?s:new ds(s)},oo=[],xc=function(s){s.forEach(function(e){oo.indexOf(e)<0&&(e(ds,hs),oo.push(e))})};const Pc="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Sc=(s=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(s|=0));for(;s--;)e+=Pc[t[s]&63];return e};function K(s){return s==null||s==="none"}function or(s,e=0,t=10**e){return Math.round(t*s)/t+0}function Ve(s,e=!1){if(typeof s!="object"||!s)return s;if(Array.isArray(s))return e?s.map(r=>Ve(r,e)):s;const t={};for(const r in s){const i=s[r];i!=null&&(e?t[r]=Ve(i,e):t[r]=i)}return t}function ar(s,e){const t={};return e.forEach(r=>{r in s&&(t[r]=s[r])}),t}function ps(s,e){if(s===e)return!0;if(s&&e&&typeof s=="object"&&typeof e=="object"){const t=Array.from(new Set([...Object.keys(s),...Object.keys(e)]));return!t.length||t.every(r=>s[r]===e[r])}return!1}function Cc(s,e,t){const r=e.length-1;if(r<0)return s===void 0?t:s;for(let i=0;i<r;i++){if(s==null)return t;s=s[e[i]]}return s==null||s[e[r]]===void 0?t:s[e[r]]}function Tc(s,e,t){const r=e.length-1;for(let i=0;i<r;i++)typeof s[e[i]]!="object"&&(s[e[i]]={}),s=s[e[i]];s[e[r]]=t}function Ec(s,e,t){return s==null||!e||typeof e!="string"?t:s[e]!==void 0?s[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Cc(s,e.split("."),t))}function Mc(s,e,t){if(!(typeof s!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),Tc(s,e.split("."),t)}class Dt{_observers=new Map;on(e,t){let r=this._observers.get(e);return r===void 0&&this._observers.set(e,r=new Set),r.add(t),this}once(e,t){const r=(...i)=>{this.off(e,r),t(...i)};return this.on(e,r),this}off(e,t){const r=this._observers.get(e);return r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e)),this}emit(e,...t){return Array.from((this._observers.get(e)||new Map).values()).forEach(r=>r(...t)),this}destroy(){this._observers=new Map}}let ao=class{_map=new WeakMap;_toRaw(e){if(e&&typeof e=="object"){const t=e.__v_raw;t&&(e=this._toRaw(t))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,t){return this._map.set(this._toRaw(e),this._toRaw(t)),this}};const gs=Symbol("properties"),lo=Symbol("inited");function ms(s){let e;if(Object.hasOwn(s,gs))e=s[gs];else{const t=Object.getPrototypeOf(s);e=new Map(t?ms(t):void 0),s[gs]=e}return e}function co(s,e,t,r){const{alias:i,internalKey:n}=r,o=s[e];i?Mc(s,i,t):s[n]=t,s.onUpdateProperty?.(e,t,o)}function ho(s,e,t){const{alias:r,internalKey:i}=t;let n;return r?n=Ec(s,r):n=s[i],n=n??uo(s,e,t),n}function uo(s,e,t){const{default:r,fallback:i}=t;let n;if(r!==void 0&&!s[lo]){s[lo]=!0;const o=typeof r=="function"?r():r;o!==void 0&&(s[e]=o,n=o)}return n=n??(typeof i=="function"?i():i),n}function Ac(s,e){function t(){return typeof this.getProperty<"u"?this.getProperty(s):ho(this,s,e)}function r(i){typeof this.setProperty<"u"?this.setProperty(s,i):co(this,s,i,e)}return{get:t,set:r}}function yi(s,e,t={}){const r={...t,internalKey:Symbol(e)};ms(s).set(e,r);const i=Ac(e,r);Object.defineProperty(s.prototype,e,{get(){return i.get.call(this)},set(n){i.set.call(this,n)},configurable:!0,enumerable:!0})}function w(s){return function(e,t){if(typeof t!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");yi(e.constructor,t,s)}}class fo extends Dt{_propertyAccessor;_properties=new Map;_updatedProperties=new Map;_changedProperties=new Set;_updatingPromise=Promise.resolve();_updating=!1;constructor(e){super(),this.setProperties(e)}isDirty(e){return e?this._updatedProperties.has(e):this._updatedProperties.size>0}getProperty(e){const t=this.getPropertyDeclaration(e);if(t){if(t.internal||t.alias)return ho(this,e,t);{let r;return this._propertyAccessor?.getProperty?r=this._propertyAccessor.getProperty(e):r=this._properties.get(e),r??uo(this,e,t)}}}setProperty(e,t){const r=this.getPropertyDeclaration(e);if(r)if(r.internal||r.alias)co(this,e,t,r);else{const i=this.getProperty(e);this._propertyAccessor?.setProperty?.(e,t),this._properties.set(e,t),this.onUpdateProperty?.(e,t,i)}}getProperties(e){const t={};for(const[r,i]of this.getPropertyDeclarations())!i.internal&&!i.alias&&(!e||e.includes(r))&&(t[r]=this.getProperty(r));return t}setProperties(e){if(e&&typeof e=="object")for(const t in e)this.setProperty(t,e[t]);return this}resetProperties(){for(const[e,t]of this.getPropertyDeclarations())this.setProperty(e,typeof t.default=="function"?t.default():t.default);return this}getPropertyDeclarations(){return ms(this.constructor)}getPropertyDeclaration(e){return this.getPropertyDeclarations().get(e)}setPropertyAccessor(e){const t=this.getPropertyDeclarations();this._propertyAccessor=void 0;const r={};return t.forEach((i,n)=>{r[n]=this.getProperty(n)}),this._propertyAccessor=e,t.forEach((i,n)=>{const o=this.getProperty(n),a=r[n];o!==void 0&&!Object.is(o,a)&&(this.setProperty(n,o),!i.internal&&!i.alias&&this.requestUpdate(n,o,a))}),this}async _nextTick(){return"requestAnimationFrame"in globalThis?new Promise(e=>globalThis.requestAnimationFrame(e)):Promise.resolve()}async _enqueueUpdate(){this._updating=!0;try{await this._updatingPromise}catch(e){Promise.reject(e)}await this._nextTick(),this._updating&&(this.onUpdate(),this._updating=!1)}onUpdate(){this._update(this._updatedProperties),this._updatedProperties=new Map}onUpdateProperty(e,t,r){Object.is(t,r)||this.requestUpdate(e,t,r)}requestUpdate(e,t,r){e!==void 0&&(this._updatedProperties.set(e,r),this._changedProperties.add(e),this._updateProperty(e,t,r),this.emit("updateProperty",e,t,r)),this._updating||(this._updatingPromise=this._enqueueUpdate())}_update(e){}_updateProperty(e,t,r){}toJSON(){const e={};return this._properties.forEach((t,r)=>{t!==void 0&&(t&&typeof t=="object"?"toJSON"in t&&typeof t.toJSON=="function"?e[r]=t.toJSON():Array.isArray(t)?e[r]=[...t]:e[r]={...t}:e[r]=t)}),e}clone(){return new this.constructor(this.toJSON())}}function ys(s){let e;return typeof s=="number"?e={r:s>>24&255,g:s>>16&255,b:s>>8&255,a:(s&255)/255}:e=s,ct(e)}function Oc(s){return{r:or(s.r),g:or(s.g),b:or(s.b),a:or(s.a,3)}}function _i(s){const e=s.toString(16);return e.length<2?`0${e}`:e}const po="#000000FF";function kc(s){return ys(s).isValid()}function Le(s,e=!1){const t=ys(s);if(!t.isValid()){if(typeof s=="string")return s;const a=`Failed to normalizeColor ${s}`;if(e)throw new Error(a);return console.warn(a),po}const{r,g:i,b:n,a:o}=Oc(t.rgba);return`#${_i(r)}${_i(i)}${_i(n)}${_i(or(o*255))}`}var vi=vi||{};vi.parse=(function(){const s={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let e="";function t(A){const M=new Error(`${e}: ${A}`);throw M.source=e,M}function r(){const A=i();return e.length>0&&t("Invalid input not EOF"),A}function i(){return x(n)}function n(){return o("linear-gradient",s.linearGradient,l)||o("repeating-linear-gradient",s.repeatingLinearGradient,l)||o("radial-gradient",s.radialGradient,f)||o("repeating-radial-gradient",s.repeatingRadialGradient,f)}function o(A,M,F){return a(M,z=>{const Y=F();return Y&&(O(s.comma)||t("Missing comma before color stops")),{type:A,orientation:Y,colorStops:x(S)}})}function a(A,M){const F=O(A);if(F){O(s.startCall)||t("Missing (");const z=M(F);return O(s.endCall)||t("Missing )"),z}}function l(){const A=c();if(A)return A;const M=$("position-keyword",s.positionKeywords,1);return M?{type:"directional",value:M.value}:h()}function c(){return $("directional",s.sideOrCorner,1)}function h(){return $("angular",s.angleValue,1)||$("angular",s.radianValue,1)}function f(){let A,M=d(),F;return M&&(A=[],A.push(M),F=e,O(s.comma)&&(M=d(),M?A.push(M):e=F)),A}function d(){let A=g()||p();if(A)A.at=m();else{const M=y();if(M){A=M;const F=m();F&&(A.at=F)}else{const F=m();if(F)A={type:"default-radial",at:F};else{const z=P();z&&(A={type:"default-radial",at:z})}}}return A}function g(){const A=$("shape",/^(circle)/i,0);return A&&(A.style=N()||y()),A}function p(){const A=$("shape",/^(ellipse)/i,0);return A&&(A.style=P()||D()||y()),A}function y(){return $("extent-keyword",s.extentKeywords,1)}function m(){if($("position",/^at/,0)){const A=P();return A||t("Missing positioning value"),A}}function P(){const A=E();if(A.x||A.y)return{type:"position",value:A}}function E(){return{x:D(),y:D()}}function x(A){let M=A();const F=[];if(M)for(F.push(M);O(s.comma);)M=A(),M?F.push(M):t("One extra comma");return F}function S(){const A=_();return A||t("Expected color definition"),A.length=D(),A}function _(){return C()||U()||R()||B()||T()||G()||b()}function b(){return $("literal",s.literalColor,0)}function C(){return $("hex",s.hexColor,1)}function T(){return a(s.rgbColor,()=>({type:"rgb",value:x(L)}))}function B(){return a(s.rgbaColor,()=>({type:"rgba",value:x(L)}))}function G(){return a(s.varColor,()=>({type:"var",value:V()}))}function R(){return a(s.hslColor,()=>{O(s.percentageValue)&&t("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const M=L();O(s.comma);let F=O(s.percentageValue);const z=F?F[1]:null;O(s.comma),F=O(s.percentageValue);const Y=F?F[1]:null;return(!z||!Y)&&t("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[M,z,Y]}})}function U(){return a(s.hslaColor,()=>{const A=L();O(s.comma);let M=O(s.percentageValue);const F=M?M[1]:null;O(s.comma),M=O(s.percentageValue);const z=M?M[1]:null;O(s.comma);const Y=L();return(!F||!z)&&t("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[A,F,z,Y]}})}function V(){return O(s.variableName)[1]}function L(){return O(s.number)[1]}function D(){return $("%",s.percentageValue,1)||H()||I()||N()}function H(){return $("position-keyword",s.positionKeywords,1)}function I(){return a(s.calcValue,()=>{let A=1,M=0;for(;A>0&&M<e.length;){const z=e.charAt(M);z==="("?A++:z===")"&&A--,M++}A>0&&t("Missing closing parenthesis in calc() expression");const F=e.substring(0,M-1);return j(M-1),{type:"calc",value:F}})}function N(){return $("px",s.pixelValue,1)||$("em",s.emValue,1)}function $(A,M,F){const z=O(M);if(z)return{type:A,value:z[F]}}function O(A){let M,F;return F=/^\s+/.exec(e),F&&j(F[0].length),M=A.exec(e),M&&j(M[0].length),M}function j(A){e=e.substr(A)}return function(A){return e=A.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}})();const Dc=vi.parse.bind(vi);var bi=bi||{};bi.stringify=(function(){var s={"visit_linear-gradient":function(e){return s.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return s.visit_gradient(e)},"visit_radial-gradient":function(e){return s.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return s.visit_gradient(e)},visit_gradient:function(e){var t=s.visit(e.orientation);return t&&(t+=", "),e.type+"("+t+s.visit(e.colorStops)+")"},visit_shape:function(e){var t=e.value,r=s.visit(e.at),i=s.visit(e.style);return i&&(t+=" "+i),r&&(t+=" at "+r),t},"visit_default-radial":function(e){var t="",r=s.visit(e.at);return r&&(t+=r),t},"visit_extent-keyword":function(e){var t=e.value,r=s.visit(e.at);return r&&(t+=" at "+r),t},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return s.visit(e.value.x)+" "+s.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_calc:function(e){return"calc("+e.value+")"},visit_literal:function(e){return s.visit_color(e.value,e)},visit_hex:function(e){return s.visit_color("#"+e.value,e)},visit_rgb:function(e){return s.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return s.visit_color("rgba("+e.value.join(", ")+")",e)},visit_hsl:function(e){return s.visit_color("hsl("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%)",e)},visit_hsla:function(e){return s.visit_color("hsla("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%, "+e.value[3]+")",e)},visit_var:function(e){return s.visit_color("var("+e.value+")",e)},visit_color:function(e,t){var r=e,i=s.visit(t.length);return i&&(r+=" "+i),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var t="",r=e.length;return e.forEach(function(i,n){t+=s.visit(i),n<r-1&&(t+=", ")}),t},visit_object:function(e){return e.width&&e.height?s.visit(e.width)+" "+s.visit(e.height):""},visit:function(e){if(!e)return"";if(e instanceof Array)return s.visit_array(e);if(typeof e=="object"&&!e.type)return s.visit_object(e);if(e.type){var t=s["visit_"+e.type];if(t)return t(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return s.visit(e)}})(),bi.stringify.bind(bi);function go(s){const e=s.length-1;return s.map((t,r)=>{const i=t.value;let n=or(r/e,3),o="#00000000";switch(t.type){case"rgb":o=Le({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":o=Le({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":o=Le(t.value);break;case"hex":o=Le(`#${t.value}`);break}switch(t.length?.type){case"%":n=Number(t.length.value)/100;break}return{offset:n,color:o}})}function mo(s){let e=0;switch(s.orientation?.type){case"angular":e=Number(s.orientation.value);break}return{type:"linear-gradient",angle:e,stops:go(s.colorStops)}}function yo(s){return s.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:go(s.colorStops)}}function Mr(s){return s.startsWith("linear-gradient(")||s.startsWith("radial-gradient(")}function Ic(s){return Dc(s).map(e=>{switch(e?.type){case"linear-gradient":return mo(e);case"repeating-linear-gradient":return{...mo(e),repeat:!0};case"radial-gradient":return yo(e);case"repeating-radial-gradient":return{...yo(e),repeat:!0};default:return}}).filter(Boolean)}function Rc(s){let e;return typeof s=="string"?e={color:s}:e={...s},{color:Le(e.color)}}function Uc(s){let e;if(typeof s=="string"?e={image:s}:e={...s},e.image){const{type:t,...r}=Ic(e.image)[0]??{};switch(t){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return ar(e,["linearGradient","radialGradient","rotateWithShape"])}function Bc(s){let e;return typeof s=="string"?e={image:s}:e={...s},ar(e,["image","cropRect","stretchRect","tile","dpi","opacity","rotateWithShape"])}function Lc(s){let e;return typeof s=="string"?e={preset:s}:e={...s},K(e.foregroundColor)?delete e.foregroundColor:e.foregroundColor=Le(e.foregroundColor),K(e.backgroundColor)?delete e.backgroundColor:e.backgroundColor=Le(e.backgroundColor),ar(e,["preset","foregroundColor","backgroundColor"])}function _s(s){return!K(s.color)}function Nc(s){return typeof s=="string"?kc(s):_s(s)}function Fc(s){return!K(s.image)&&Mr(s.image)||!!s.linearGradient||!!s.radialGradient}function $c(s){return typeof s=="string"?Mr(s):Fc(s)}function zc(s){return!K(s.image)&&!Mr(s.image)}function Vc(s){return typeof s=="string"?!Mr(s):zc(s)}function Gc(s){return!K(s.preset)}function jc(s){return typeof s=="string"?!1:Gc(s)}function ht(s){const e=s&&typeof s=="object"?s.enabled:void 0;return Nc(s)?Ve({enabled:e,...Rc(s)}):$c(s)?Ve({enabled:e,...Uc(s)}):Vc(s)?Ve({enabled:e,...Bc(s)}):jc(s)?Ve({enabled:e,...Lc(s)}):{}}function Wc(s){return typeof s=="string"?{...ht(s)}:{...ht(s),...ar(s,["fillWithShape"])}}function qc(s){return typeof s=="string"?{...ht(s)}:{...ht(s),...ar(s,["fillWithShape"])}}const _o=()=>Sc(10);function wi(s){return typeof s=="string"?{...ht(s)}:{...ht(s),...ar(s,["width","style","lineCap","lineJoin","headEnd","tailEnd"])}}function Xc(s){return typeof s=="string"?{color:Le(s)}:{...s,color:K(s.color)?po:Le(s.color)}}function Hc(){return{boxShadow:"none"}}function Yc(s){return typeof s=="string"?s.startsWith("<svg")?{svg:s}:{paths:[{data:s}]}:Array.isArray(s)?{paths:s.map(e=>typeof e=="string"?{data:e}:e)}:s}function Kc(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function Zc(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Jc(){return{...Kc(),...Zc(),...Hc(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function Qc(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function eh(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function th(){return{...Qc(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function rh(){return{...eh(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function ih(){return{...rh(),...th(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function xi(s){return Ve({...s,color:K(s.color)?void 0:Le(s.color),backgroundColor:K(s.backgroundColor)?void 0:Le(s.backgroundColor),borderColor:K(s.borderColor)?void 0:Le(s.borderColor),outlineColor:K(s.outlineColor)?void 0:Le(s.outlineColor),shadowColor:K(s.shadowColor)?void 0:Le(s.shadowColor)})}function vo(){return{...Jc(),...ih()}}const sh=/\r\n|\n\r|\n|\r/,nh=new RegExp(`^(${sh.source})$`),oh=`
2
+ `;function ah(s){return nh.test(s)}function vs(s){const e=[];function t(){return e[e.length-1]}function r(a,l,c){const h=a?xi(a):{},f=l?ht(l):void 0,d=c?wi(c):void 0,g=Ve({...h,fill:f,outline:d,fragments:[]});return e[e.length-1]?.fragments.length===0?e[e.length-1]=g:e.push(g),g}function i(a="",l,c,h){const f=l?xi(l):{},d=c?ht(c):void 0,g=h?wi(h):void 0;Array.from(a).forEach(p=>{if(ah(p)){const{fragments:y,fill:m,outline:P,...E}=t()||r();y.length||y.push(Ve({...f,fill:d,outline:g,content:oh})),r(E,m,P)}else{const y=t()||r(),m=y.fragments[y.fragments.length-1];if(m){const{content:P,fill:E,outline:x,...S}=m;if(ps(d,E)&&ps(g,x)&&ps(f,S)){m.content=`${P}${p}`;return}}y.fragments.push(Ve({...f,fill:d,outline:g,content:p}))}})}(Array.isArray(s)?s:[s]).forEach(a=>{if(typeof a=="string")r(),i(a);else if(bo(a)){const{content:l,fill:c,outline:h,...f}=a;r(f,c,h),i(l)}else if(lh(a)){const{fragments:l,fill:c,outline:h,...f}=a;r(f,c,h),l.forEach(d=>{const{content:g,fill:p,outline:y,...m}=d;i(g,m,p,y)})}else Array.isArray(a)?(r(),a.forEach(l=>{if(typeof l=="string")i(l);else if(bo(l)){const{content:c,fill:h,outline:f,...d}=l;i(c,d,h,f)}})):console.warn("Failed to parse text content",a)});const o=t();return o&&!o.fragments.length&&o.fragments.push({content:""}),e}function lh(s){return s&&typeof s=="object"&&"fragments"in s&&Array.isArray(s.fragments)}function bo(s){return s&&typeof s=="object"&&"content"in s&&typeof s.content=="string"}function wo(s){return typeof s=="string"||Array.isArray(s)?{content:vs(s)}:Ve({...s,content:vs(s.content??""),style:s.style?xi(s.style):void 0,effects:s.effects?s.effects.map(e=>xi(e)):void 0,measureDom:s.measureDom,fonts:s.fonts,fill:s.fill?ht(s.fill):void 0,outline:s.outline?wi(s.outline):void 0})}const Pi=new Map;function W(s,e){return function(t){Object.defineProperty(t.prototype,"is",{value:s,enumerable:!0,configurable:!0}),e&&Object.keys(e).forEach(r=>{yi(t,r,{fallback:e[r]})}),Pi.set(s,t)}}function ch(s="node",e={}){const t=Pi.get(s);if(!t)throw new Error(`Failed to createNode, tag: ${s}`);return new t().setProperties(e)}class Ce{static _queue=[];static _currentTime=0;static _elapsed=0;static _requestId;static get currentTime(){return this._currentTime}static get elapsed(){return this._elapsed}static on(e,t={}){const{sort:r=0,once:i=!1}=t;this._queue[r]||(this._queue[r]=[]),this._queue[r].push({cb:e,once:i})}static off(e,t={}){const{sort:r=0}=t,i=this._queue[r];if(!i)return;const n=[];for(let o=i.length,a=0;a<o;a++){const l=i[a];l.cb!==e&&n.push(l)}n.length?this._queue[r]=n:this._queue.splice(r,1)}static start(){"requestAnimationFrame"in globalThis&&(this._currentTime=performance.now(),this._requestId=requestAnimationFrame(e=>this._update(e)))}static stop(){this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=void 0)}static _update(e){this._elapsed=e-this._currentTime,this._currentTime=e,this._requestId=requestAnimationFrame(t=>this._update(t)),this._performUpdate()}static _performUpdate(){const e=this._queue,t=[];for(let r=e.length,i=r;i>=0;i--){const n=e[i];if(!n)continue;const o=[];for(let a=n.length,l=0;l<a;l++){const c=n[l];try{c.cb()}catch(h){console.warn(h)}c.once||o.push(c)}o.length&&(t[i]=o)}this._queue=t}}Ce.start();async function bs(s){return new Promise(e=>{Ce.on(()=>{s?.(),e()},{sort:1,once:!0})})}const Si=Math.PI,Ne=Si*2;let hh=0;function xo(s){return s?.__SPECTOR_Object_TAG?.id??++hh}function ws(s){return!(s&s-1)&&!!s}const uh=/([\w-]+)\((.+?)\)/g,fh=/[^,]+/g,dh=/([-e.\d]+)(.*)/;function xs(s){return Array.isArray(s)?s.map(e=>({name:e.name,args:e.args.map(t=>({...t,normalizedIntValue:t.normalizedDefaultIntValue}))})):{...s,normalizedIntValue:s.normalizedDefaultIntValue}}function Ar(s,e,t={}){const r=Or(e,t);return r.length?r:Po(s,e,t)}function Or(s,e={}){const t=[];let r;for(;(r=uh.exec(s))!==null;){const[,i,n]=r;i&&t.push({name:i,args:ph(i,n,e)})}return t}function ph(s,e,t={}){const r=[];let i,n=0;for(;(i=fh.exec(e))!==null;)r.push(Po(s,i[0],{...t,index:n++}));return r}function Po(s,e,t={}){const{width:r=1,height:i=1,index:n=0}=t,o=e.match(dh),a={unit:o?.[2]??null,value:e,intValue:Number(o?.[1]),normalizedIntValue:0,normalizedDefaultIntValue:0};switch(s){case"scale":case"scaleX":case"scaleY":case"scale3d":a.normalizedDefaultIntValue=1;break}switch(a.unit){case"%":a.normalizedIntValue=a.intValue/100;break;case"rad":a.normalizedIntValue=a.intValue/Ne;break;case"deg":a.normalizedIntValue=a.intValue/360;break;case"px":switch(n){case 0:a.normalizedIntValue=a.intValue/r;break;case 1:a.normalizedIntValue=a.intValue/i;break}break;case"turn":case"em":case"rem":default:a.normalizedIntValue=a.intValue;break}return a}const So="WebGL2RenderingContext"in globalThis,Co="ImageBitmap"in globalThis,To="ResizeObserver"in globalThis,lr="PointerEvent"in globalThis,Eo="WheelEvent"in globalThis,gh="MouseEvent"in globalThis,Pt="ontouchstart"in globalThis,Mo="onclick"in globalThis,Ps="createImageBitmap"in globalThis,Ss="AudioContext"in globalThis,Cs="webkitAudioContext"in globalThis,Ts="OfflineAudioContext"in globalThis,Ao="webkitOfflineAudioContext"in globalThis,Oo=Ss||Cs,kr=typeof window<"u",Es=globalThis.devicePixelRatio||1,Ms=s=>s!==null&&typeof s=="object"&&s.nodeType===1,ko=s=>Ms(s)&&s.tagName==="VIDEO",mh=s=>Ms(s)&&s.tagName==="IMG";function Do(s){return typeof s=="object"&&s!==null&&s.nodeType===1&&s.tagName==="CANVAS"}function Io(s){return So&&s instanceof globalThis.WebGL2RenderingContext}function Ro(){if(kr)return globalThis.document.createElement("canvas")}function Uo(s,e=globalThis.location){if(s.startsWith("data:"))return"";e=e||globalThis.location;const t=new URL(s,document.baseURI);return t.hostname!==e.hostname||t.port!==e.port||t.protocol!==e.protocol?"anonymous":""}function Bo(s,e,t){t===null&&!e.startsWith("data:")?s.crossOrigin=Uo(e):t!==!1&&(s.crossOrigin=typeof t=="string"?t:"anonymous")}class As{_map=new WeakMap;_toRaw(e){if(e&&typeof e=="object"){const t=e.__v_raw;t&&(e=this._toRaw(t))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,t){return this._map.set(this._toRaw(e),this._toRaw(t)),this}}class Dr{cursor;bubbles=!1;cancelBubble=!1;cancelable=!1;composed=!1;defaultPrevented=!1;eventPhase=Dr.prototype.NONE;isTrusted=!1;timeStamp=0;type="";composedPath(){return this.path}initEvent(...e){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){"preventDefault"in this.nativeEvent&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}propagationImmediatelyStopped=!1;stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}propagationStopped=!1;stopPropagation(){"stopPropagation"in this.nativeEvent&&this.nativeEvent.stopPropagation(),this.propagationStopped=!0}NONE=0;CAPTURING_PHASE=1;AT_TARGET=2;BUBBLING_PHASE=3;initUIEvent(...e){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}}class Lo extends Dr{getModifierState(...e){throw new Error("getModifierState() is a legacy DOM API. It is not implemented in the Federated Events API.")}initKeyboardEvent(...e){throw new Error("initKeyboardEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}}class Os extends Dr{client={x:0,y:0};get clientX(){return this.client.x}get clientY(){return this.client.y}layer={x:0,y:0};get layerX(){return this.layer.x}get layerY(){return this.layer.y}movement={x:0,y:0};get movementX(){return this.movement.x}get movementY(){return this.movement.y}offset={x:0,y:0};get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}page={x:0,y:0};get pageX(){return this.page.x}get pageY(){return this.page.y}screen={x:0,y:0};get screenX(){return this.screen.x}get screenY(){return this.screen.y}get x(){return this.clientX}get y(){return this.clientY}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(...e){throw new Error("Method not implemented.")}global={x:0,y:0};get globalX(){return this.global.x}get globalY(){return this.global.y}}class No extends Os{width=0;height=0;isPrimary=!1;getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class Fo extends Os{static DOM_DELTA_PIXEL=0;DOM_DELTA_PIXEL=0;static DOM_DELTA_LINE=1;DOM_DELTA_LINE=1;static DOM_DELTA_PAGE=2;DOM_DELTA_PAGE=2}const yh={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"};class $o extends Dt{event;target;cursor="default";cursorStyles={default:"inherit",pointer:"pointer"};setuped=!1;enableMoveEvent=!0;enableWheelEvent=!0;enableClickEvent=!0;setTarget(e){this.removeEventListeners(),this.target=e,this.addEventListeners()}removeEventListeners(){if(!this.setuped||!this.target)return;const e=this.target.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):lr&&(e.touchAction=""),lr?(this.target.removeEventListener("pointerdown",this._onPointerDown),this.target.removeEventListener("pointerleave",this._onPointerOver),this.target.removeEventListener("pointerover",this._onPointerOver),this.target.removeEventListener("pointermove",this._onPointerMove),this.target.removeEventListener("pointerup",this._onPointerUp)):(this.target.removeEventListener("mousedown",this._onPointerDown),this.target.removeEventListener("mouseout",this._onPointerOver),this.target.removeEventListener("mouseover",this._onPointerOver),this.target.removeEventListener("mousemove",this._onPointerMove),this.target.removeEventListener("mouseup",this._onPointerUp)),Pt&&(this.target.removeEventListener("touchstart",this._onPointerDown),this.target.removeEventListener("touchmove",this._onPointerMove),this.target.removeEventListener("touchend",this._onPointerUp)),this.target.removeEventListener("wheel",this._onWheel),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keypress",this._onKeyPress),document.removeEventListener("keyup",this._onKeyUp),this.target=void 0,this.setuped=!1}addEventListeners(){if(this.setuped||!this.target)return;const e=this.target.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):lr&&(e.touchAction="none")),lr?(this.target.addEventListener("pointerdown",this._onPointerDown),this.target.addEventListener("pointerleave",this._onPointerOver),this.target.addEventListener("pointerover",this._onPointerOver),this.target.addEventListener("pointermove",this._onPointerMove),this.target.addEventListener("pointerup",this._onPointerUp)):(this.target.addEventListener("mousedown",this._onPointerDown),this.target.addEventListener("mouseout",this._onPointerOver),this.target.addEventListener("mouseover",this._onPointerOver),this.target.addEventListener("mousemove",this._onPointerMove),this.target.addEventListener("mouseup",this._onPointerUp)),Pt&&(this.target.addEventListener("touchstart",this._onPointerDown),this.target.addEventListener("touchmove",this._onPointerMove),this.target.addEventListener("touchend",this._onPointerUp)),this.target.addEventListener("wheel",this._onWheel),document.addEventListener("keydown",this._onKeyDown),document.addEventListener("keypress",this._onKeyPress),document.addEventListener("keyup",this._onKeyUp),this.setuped=!0}normalize(e){const t=[];if(Pt&&e instanceof globalThis.TouchEvent)for(let r=0,i=e.changedTouches.length;r<i;r++){const n=e.changedTouches[r];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.type=e.type,t.push(n)}else if(Eo&&e instanceof globalThis.WheelEvent)t.push(e);else if(lr&&e instanceof globalThis.PointerEvent)t.push(e);else{const r=e;typeof r.isPrimary>"u"&&(r.isPrimary=!0),typeof r.width>"u"&&(r.width=1),typeof r.height>"u"&&(r.height=1),typeof r.tiltX>"u"&&(r.tiltX=0),typeof r.tiltY>"u"&&(r.tiltY=0),typeof r.pointerType>"u"&&(r.pointerType="mouse"),typeof r.pointerId>"u"&&(r.pointerId=1),typeof r.pressure>"u"&&(r.pressure=.5),typeof r.twist>"u"&&(r.twist=0),typeof r.tangentialPressure>"u"&&(r.tangentialPressure=0),t.push(r)}return t}_clonePointerEvent(e){const t=new No;return t.nativeEvent=e,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,t.isTrusted=e.isTrusted,this._copyMouseEvent(t,e),this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.x=t.screen.x,t.global.y=t.screen.y,t.offset.x=t.screen.x,t.offset.y=t.screen.y,t.type==="pointerleave"?t.type="pointerout":t.type.startsWith("mouse")?t.type=t.type.replace("mouse","pointer"):t.type.startsWith("touch")&&(t.type=yh[t.type]||t.type),t}_copyInputEvent(e,t){e.nativeEvent=t,e.bubbles=t.bubbles,e.cancelBubble=t.cancelBubble,e.cancelable=t.cancelable,e.composed=t.composed,e.currentTarget=t.currentTarget,e.defaultPrevented=t.defaultPrevented,e.eventPhase=t.eventPhase,e.isTrusted=t.isTrusted,e.returnValue=t.returnValue,e.srcElement=t.srcElement,e.timeStamp=t.timeStamp,e.type=t.type}_copyMouseEvent(e,t){this._copyInputEvent(e,t),e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}_cloneWheelEvent(e){const t=new Fo;return this._copyMouseEvent(t,e),t.wheelDeltaY=e.wheelDeltaY,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.x=t.screen.x,t.global.y=t.screen.y,t.offset.x=t.screen.x,t.offset.y=t.screen.y,t}_cloneKeyboardEvent(e){const t=new Lo;return this._copyInputEvent(t,e),t.altKey=e.altKey,t.charCode=e.charCode,t.code=e.code,t.ctrlKey=e.ctrlKey,t.isComposing=e.isComposing,t.key=e.key,t.keyCode=e.keyCode,t.location=e.location,t.metaKey=e.metaKey,t.repeat=e.repeat,t.shiftKey=e.shiftKey,t}setCursor(e="default"){if(!this.target||this.cursor===e)return;this.cursor=e;const t=!(globalThis.OffscreenCanvas&&this.target instanceof OffscreenCanvas),r=this.cursorStyles[e];if(r)switch(typeof r){case"string":t&&(this.target.style.cursor=r);break;case"function":r(e);break;case"object":t&&Object.assign(this.target.style,r);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.target.style.cursor=e)}mapPositionToPoint(e,t,r){if(!this.target)return;const i=this.target.isConnected?this.target.getBoundingClientRect():void 0,n=Number(this.target.getAttribute("data-pixel-ratio"))||1,o=Number(this.target.getAttribute("width"))||(i?i.width*n:0),a=Number(this.target.getAttribute("height"))||(i?i.height*n:0),l=i??{width:o,height:a,left:0,top:0},c=1/n;e.x=(t-l.left)*(o/l.width)*c,e.y=(r-l.top)*(a/l.height)*c}_onKeyDown=e=>{const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("keydown",this.event=this._cloneKeyboardEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onKeyPress=e=>{const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("keypress",this.event=this._cloneKeyboardEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onKeyUp=e=>{const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("keyup",this.event=this._cloneKeyboardEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerDown=e=>{if(Pt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("pointerdown",this.event=this._clonePointerEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerOver=e=>{if(!this.enableClickEvent||Pt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("pointerover",this.event=this._clonePointerEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerMove=e=>{if(!this.enableMoveEvent||Pt&&e.pointerType==="touch")return;const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("pointermove",this.event=this._clonePointerEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)};_onPointerUp=e=>{if(!this.enableClickEvent||Pt&&e.pointerType==="touch")return;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const r=t!==this.target?"outside":"",i=this.normalize(e);for(let n=0,o=i.length;n<o;n++){const a=this._clonePointerEvent(i[n]);a.type+=r,this.emit("pointerup",this.event=a)}this.event?.cursor&&this.setCursor(this.event.cursor)};_onWheel=e=>{if(!this.enableWheelEvent)return;const t=this.normalize(e);for(let r=0,i=t.length;r<i;r++)this.emit("wheel",this.event=this._cloneWheelEvent(t[r]));this.event?.cursor&&this.setCursor(this.event.cursor)}}let _h=0;class It extends fo{instanceId=++_h;get json(){return this.toJSON()}set json(e){this.setProperties(e)}_nextTick(){return bs()}equal(e){return!!(e&&this.instanceId===e.instanceId)}}class zo extends It{}class St extends zo{}function vh(s,e){var t={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var i in t)r[t[i]]=i;var n={};s.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,c=r[this.toHex()];if(c)return c;if(o?.closest){var h=this.toRgb(),f=1/0,d="black";if(!n.length)for(var g in t)n[g]=new s(t[g]).toRgb();for(var p in t){var y=(a=h,l=n[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));y<f&&(f=y,d=p)}return d}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new s(l).toRgb():null},"name"])}xc([vh]);class Qe{get value(){return this._value}set value(e){this._colord=ys(e??"none")}get r8(){return this._colord.rgba.r}get g8(){return this._colord.rgba.g}get b8(){return this._colord.rgba.b}get a8(){return this._colord.rgba.a*255&255}get r(){return this.r8/255}get g(){return this.g8/255}get b(){return this.b8/255}get a(){return this._colord.rgba.a}get rgb(){return(this.r8<<16)+(this.g8<<8)+this.b8}get bgr(){return(this.b8<<16)+(this.g8<<8)+this.r8}get abgr(){return(this.a8<<24)+this.bgr}constructor(e=0){this.value=e}toHex(){return this._colord.toHex()}toRgb(){return this._colord.toRgb()}toRgbString(){return this._colord.toRgbString()}toHsl(){return this._colord.toHsl()}toHslString(){return this._colord.toHslString()}toHsv(){return this._colord.toHsv()}toArgb(e=this.a,t=!0){if(e===1)return(255<<24)+this.rgb;if(e===0)return t?0:this.rgb;let r=this.r8,i=this.g8,n=this.b8;return t&&(r=r*e+.5|0,i=i*e+.5|0,n=n*e+.5|0),(e*255<<24)+(r<<16)+(i<<8)+n}toInt8Array(){return[this.r8,this.g8,this.b8,this.a8]}toArray(){return[this.r,this.g,this.b,this.a]}}class et extends Dt{constructor(e){super(),this.dim=e}_array=[];get length(){return this.dim}operate(e,t,r){const{dim:i,_array:n}=this;let o;typeof t=="number"?o=Array.from({length:i},()=>t):t instanceof ut||t instanceof et?o=t.toArray():o=t;let a,l=[];if(r?r instanceof et?a=r:l=r:a=this,t instanceof ut){const{cols:c}=t;switch(e){case"*":for(let h=0;h<i;h++){let f=0;for(let d=0;d<i;d++)f+=n[h]*o[d*c+h];l[h]=f}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"+":for(let c=0;c<i;c++)l[c]=n[c]+o[c];break;case"-":for(let c=0;c<i;c++)l[c]=n[c]-o[c];break;case"*":for(let c=0;c<i;c++)l[c]=n[c]*o[c];break;case"/":for(let c=0;c<i;c++)l[c]=n[c]/o[c];break;case"rot":{const c=Math.cos(o[0]),h=Math.sin(o[0]);l[0]=n[0]*c-n[1]*h,l[1]=n[1]*c+n[0]*h;break}case"==":{let c=!0;for(let h=0;h<i;h++)c=c&&n[h]===o[h];return c}case"=":for(let c=0;c<i;c++){const h=o[c];h!==void 0&&(n[c]=h)}return this._onUpdate(n),this.emit("update",n),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Vector'`)}return a?.set(l)??l}add(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this.operate("+",e)}sub(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this.operate("-",e)}multiply(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this.operate("*",e)}divide(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this.operate("/",e)}rotate(e){return this.operate("rot",e)}set(e,...t){return t.length&&typeof e=="number"&&(e=[e,...t]),this.operate("=",e)}equals(e){return this.operate("==",e)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}_onUpdate(e){}toName(){return`Vector${this.dim}`}toArray(){return this._array.slice()}toJSON(){return this.toArray()}}class ut extends Dt{constructor(e,t,r){super(),this.rows=e,this.cols=t,r?this.set(r):this.identity()}_array=[];dirtyId=0;get length(){return this.cols*this.rows}operate(e,t,r){const{cols:i,rows:n,length:o,_array:a}=this;let l;typeof t=="number"?l=Array.from({length:o},()=>t):t instanceof et||t instanceof ut?l=t.toArray():l=t;let c,h=[];if(r?r instanceof et||r instanceof ut?c=r:h=r:t instanceof et?c=new t.constructor:c=this,t instanceof et){const{dim:f}=t;switch(e){case"*":for(let d=0;d<f;d++){let g=0;for(let p=0;p<i;p++)p<f&&(g+=a[d*i+p]*(l[p]??0));h[d]=g}break;default:throw new Error(`Not support operator in '${this.toName()} ${e} ${t.toName()}'`)}}else switch(e){case"*":for(let f=0;f<i;f++)for(let d=0;d<n;d++){const g=d*i;let p=0;for(let y=0;y<n;y++){const m=g+y,P=y*i+f;p+=a[m]*(l[P]??0)}h[g+f]=p}break;case"=":for(let f=0;f<o;f++){const d=l[f];d!==void 0&&(a[f]=d)}return this._onUpdate(a),this.emit("update",a),this;default:throw new Error(`Not support operator in '${this.toName()} ${e} Matrix2'`)}return c?.set(h)??h}identity(){const{cols:e,rows:t}=this,r=[];for(let i=0;i<e;i++)for(let n=0;n<t;n++){const o=n*e,a=i+o;r[a]=n+o===a?1:0}return this.set(r)}set(e){return this.operate("=",e)}copy(e){return this.set(e)}clone(){const e=new this.constructor;return e.set(this.toArray()),e}multiply(e,t){return this.operate("*",e,t)}_onUpdate(e){this.dirtyId++}toArray(e=!1){const{cols:t,rows:r,_array:i}=this;if(e){const n=[];for(let o=0;o<r;o++)for(let a=0;a<t;a++)n[o+a*t]=i[a+o*t];return n}return i.slice()}toName(){return`Matrix${this.rows}(${this.rows}x${this.cols})`}toJSON(){return this._array.slice()}}class Vo extends ut{constructor(e){super(4,4,e)}}const Go=Si/180,bh=180/Si;function Ge(s,e,t){return Math.max(e,Math.min(s,t))}function he(s,e,t){return(1-t)*s+t*e}const wh={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount(s,e=20){if(!this.adaptive||!s||Number.isNaN(s))return e;let t=Math.ceil(s/this.maxLength);return t<this.minSegments?t=this.minSegments:t>this.maxSegments&&(t=this.maxSegments),t}};class jo extends et{constructor(e=0,t=0,r=0,i=0){super(4),this.set(e,t,r,i)}}class ks extends ut{constructor(e){super(4,5,e)}hueRotate(e=0){const t=Math.sin(e),r=Math.cos(e),i=.213,n=.715,o=.072;return this.multiply([i+r*(1-i)+t*-i,n+r*-n+t*-n,o+r*-o+t*(1-o),0,0,i+r*-i+t*.143,n+r*(1-n)+t*.14,o+r*-o+t*-.283,0,0,i+r*-i+t*-.787,n+r*-n+t*n,o+r*(1-o)+t*o,0,0,0,0,0,1,0])}saturate(e=1){const t=(e-1)*2/3+1,r=(t-1)*-.5;return this.multiply([t,r,r,0,0,r,t,r,0,0,r,r,t,0,0,0,0,0,1,0])}brightness(e=1){const t=e;return this.multiply([t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0])}contrast(e=1){const t=e,r=-128*(t-1);return this.multiply([t,0,0,0,r,0,t,0,0,r,0,0,t,0,r,0,0,0,1,0])}invert(e=1){const t=he(1,-1,e),r=he(0,255,e);return this.multiply([t,0,0,0,r,0,t,0,0,r,0,0,t,0,r,0,0,0,1,0])}sepia(e=1){const t=Ge(e,0,1);return this.multiply([he(1,.393,t),he(0,.7689999,t),he(0,.18899999,t),0,0,he(0,.349,t),he(1,.6859999,t),he(0,.16799999,t),0,0,he(0,.272,t),he(0,.5339999,t),he(1,.13099999,t),0,0,0,0,0,1,0])}opacity(e=1){return this.multiply([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,e,0])}grayscale(e=1){const t=Ge(e,0,1),r=he(1,.3,t),i=he(0,.3,t),n=he(1,.59,t),o=he(0,.59,t),a=he(1,.11,t),l=he(0,.11,t);return this.multiply([r,o,l,0,0,i,n,l,0,0,i,o,a,0,0,0,0,0,1,0])}multiply(e){const t=e,r=this._array;return this.set([r[0]*t[0]+r[1]*t[5]+r[2]*t[10]+r[3]*t[15],r[0]*t[1]+r[1]*t[6]+r[2]*t[11]+r[3]*t[16],r[0]*t[2]+r[1]*t[7]+r[2]*t[12]+r[3]*t[17],r[0]*t[3]+r[1]*t[8]+r[2]*t[13]+r[3]*t[18],r[0]*t[4]+r[1]*t[9]+r[2]*t[14]+r[3]*t[19]+r[4],r[5]*t[0]+r[6]*t[5]+r[7]*t[10]+r[8]*t[15],r[5]*t[1]+r[6]*t[6]+r[7]*t[11]+r[8]*t[16],r[5]*t[2]+r[6]*t[7]+r[7]*t[12]+r[8]*t[17],r[5]*t[3]+r[6]*t[8]+r[7]*t[13]+r[8]*t[18],r[5]*t[4]+r[6]*t[9]+r[7]*t[14]+r[8]*t[19]+r[9],r[10]*t[0]+r[11]*t[5]+r[12]*t[10]+r[13]*t[15],r[10]*t[1]+r[11]*t[6]+r[12]*t[11]+r[13]*t[16],r[10]*t[2]+r[11]*t[7]+r[12]*t[12]+r[13]*t[17],r[10]*t[3]+r[11]*t[8]+r[12]*t[13]+r[13]*t[18],r[10]*t[4]+r[11]*t[9]+r[12]*t[14]+r[13]*t[19]+r[14],r[15]*t[0]+r[16]*t[5]+r[17]*t[10]+r[18]*t[15],r[15]*t[1]+r[16]*t[6]+r[17]*t[11]+r[18]*t[16],r[15]*t[2]+r[16]*t[7]+r[17]*t[12]+r[18]*t[17],r[15]*t[3]+r[16]*t[8]+r[17]*t[13]+r[18]*t[18],r[15]*t[4]+r[16]*t[9]+r[17]*t[14]+r[18]*t[19]+r[19]])}toMatrix4(){const e=this._array;return new Vo([e[0],e[1],e[2],e[3],e[5],e[6],e[7],e[8],e[10],e[11],e[12],e[13],e[15],e[16],e[17],e[18]])}toVector4(){const e=this._array;return new jo(e[4]/255,e[9]/255,e[14]/255,e[19]/255)}}class xh extends ut{constructor(e){super(2,2,e)}}let Ds=class extends ut{constructor(e){super(3,3,e)}affineInvert(){const[e,t,r,i,n,o,a,l,c]=this._array,h=c*n-o*l,f=o*a-c*i,d=l*i-n*a,g=e*h+t*f+r*d;if(g===0)return this.set([0,0,0,0,0,0,0,0,0]);const p=1/g;return this.set([h*p,(r*l-c*t)*p,(o*t-r*n)*p,f*p,(c*e-r*a)*p,(r*i-o*e)*p,d*p,(t*a-l*e)*p,(n*e-t*i)*p])}};class Wo extends Ds{constructor(e=0,t=0,r=0,i=0,n=!1){super(),this._x=e,this._y=t,this._width=r,this._height=i,this._flipY=n,this._performUpdateArray()}flipY(e){return this._flipY!==e&&(this._flipY=e,this._performUpdateArray()),this}translate(e,t){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._performUpdateArray()),this}resize(e,t){return(this._width!==e||this._height!==t)&&(this._width=e,this._height=t,this._performUpdateArray()),this}_performUpdateArray(){const e=this._width,t=this._height;if(!e||!t)return;const r=this._x,i=this._y,n=this._flipY?-1:1,o=1/e*2,a=n*(1/t*2),l=-1-r*o,c=-n-i*a;this.set([o,0,l,0,a,c,0,0,1])}}let de=class hc extends et{get x(){return this._array[0]}set x(e){const[t,r]=this._array;t!==e&&this.set(e,r)}get y(){return this._array[1]}set y(e){const[t,r]=this._array;r!==e&&this.set(t,e)}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}get left(){return this.x}set left(e){this.x=e}get top(){return this.y}set top(e){this.y=e}constructor(e=0,t){super(2),this.set(typeof e=="number"?[e,t??e]:e)}update(e,t){const[r,i]=this._array;return(r!==e||i!==t)&&this.set(e,t),this}getLength(){const[e,t]=this._array;return Math.sqrt(e*e+t*t)}getAngle(){const[e,t]=this._array;return Math.atan2(-e,-t)+Math.PI}distanceTo(e){return Math.hypot(e.x-this.x,e.y-this.y)}normalize(){const[e,t]=this._array,r=1/(this.getLength()||1);return this.set(e*r,t*r),this}static lerp(e,t,r){return new hc(t).clone().sub(e).multiply(r).add(e)}};class Rt{get x(){return this.position.x}get y(){return this.position.y}get left(){return this.position.x}get top(){return this.position.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get width(){return this.size.x}get height(){return this.size.y}end=new de;position;size;constructor(...e){const t=new de,r=new de;switch(e.length){case 0:break;case 1:{const i=e[0];if(i instanceof Rt)t.set(i.position),r.set(i.size);else{const n=i.map(f=>f.x),o=i.map(f=>f.y),a=Math.min(...n),l=Math.max(...n),c=Math.min(...o),h=Math.max(...o);t.set(a,c),r.set(l-a,h-c)}break}case 2:t.set(e[0]),r.set(e[1]);break;default:t.set(e[0],e[1]),r.set(e[2],e[3]);break}this.update=this.update.bind(this),this.position=t.on("update",this.update),this.size=r.on("update",this.update),this.update()}update(){return this.end.set(this.position.x+this.size.x,this.position.y+this.size.y),this}toMinmax(){return{minX:this.position.x,minY:this.position.y,maxX:this.end.x,maxY:this.end.y}}toArray(){return[this.x,this.y,this.width,this.height]}toJSON(){return{x:this.x,y:this.y,width:this.width,height:this.height}}}class ve extends Ds{static _t2d=new ve;premultiply(e){return e.multiply(this,this)}skewX(e){return this.skew(e,0)}skewY(e){return this.skew(0,e)}skew(e,t){return this.premultiply(ve._t2d.makeSkew(e,t))}makeSkew(e,t){const r=Math.tan(e),i=Math.tan(t);return this.set([1,i,0,r,1,0,0,0,1]),this}translateX(e){return this.translate(e,0)}translateY(e){return this.translate(0,e)}translateZ(e){return this.translate(0,0,e)}translate3d(e,t,r){return this.translate(e,t,r)}translate(e,t,r=0){return this.premultiply(ve._t2d.makeTranslation(e,t,r))}makeTranslation(e,t,r=0){return this.set([1,0,e,0,1,t,0,0,1]),this}scaleX(e){return this.scale(e,1)}scaleY(e){return this.scale(1,e)}scale3d(e,t,r=1){return this.scale(e,t,r)}scale(e,t,r=1){return this.premultiply(ve._t2d.makeScale(e,t,r))}makeScale(e,t,r=1){return this.set([e,0,0,0,t,0,0,0,1]),this}rotateX(e){return this.scaleY(this._rotateToScale(e))}rotateY(e){return this.scaleX(this._rotateToScale(e))}rotateZ(e){return this.rotate(e)}rotate(e){return this.premultiply(ve._t2d.makeRotation(e))}rotate3d(e,t,r,i){const[n,o,a]=this._rotate3d(e,t,r,i);return n&&this.rotateX(n),o&&this.rotateY(o),a&&this.rotateZ(a),this}_rotateToScale(e){const t=e/Ne;return t<=.5?t*-4+1:(t-1)*4+1}_rotate3d(e,t,r,i){if(e===1&&t===0&&r===0)return[i,0,0];if(e===0&&t===1&&r===0)return[0,i,0];if(e===0&&t===0)return[0,0,i];{const n=Math.cos(i),o=Math.sin(i),a=n+e*e*(1-n),l=e*t*(1-n)-r*o,c=e*r*(1-n)+t*o,h=n+t*t*(1-n),f=t*r*(1-n)-e*o,d=n+r*r*(1-n),g=-Math.atan2(-f,h),p=-Math.atan2(c,Math.sqrt(f*f+d*d)),y=-Math.atan2(-l,a);return[g,p,y]}}makeRotation(e){const t=Math.cos(e),r=Math.sin(e);return this.set([t,-r,0,r,t,0,0,0,1]),this}decompose(e={x:0,y:0},t={position:{x:0,y:0},scale:{x:0,y:0},skew:{x:0,y:0},rotation:0}){const{a:r,b:i,c:n,d:o,tx:a,ty:l}=this.toObject(),c=-Math.atan2(-n,o),h=Math.atan2(i,r),f=Math.abs(c+h);return f<1e-5||Math.abs(Ne-f)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=c,t.skew.y=h),t.scale.x=Math.sqrt(r*r+i*i),t.scale.y=Math.sqrt(n*n+o*o),t.position.x=a+(e.x*r+e.y*n),t.position.y=l+(e.x*i+e.y*o),t}apply(e,t){t=t||new de;const{a:r,c:i,tx:n,b:o,d:a,ty:l}=this.toObject(),c=e.x,h=e.y;return t.x=r*c+i*h+n,t.y=o*c+a*h+l,t}affineInverse(){return this.clone().affineInvert()}applyAffineInverse(e,t){t=t||new de;const{a:r,b:i,c:n,d:o,tx:a,ty:l}=this.toObject(),c=1/(r*o+n*-i),h=e.x,f=e.y;return t.x=o*c*h+-n*c*f+(l*n-a*o)*c,t.y=r*c*f+-i*c*h+(-l*r+a*i)*c,t}isIdentity(){const{a:e,b:t,c:r,d:i,tx:n,ty:o}=this.toObject();return e===1&&t===0&&r===0&&i===1&&n===0&&o===0}toObject(){const[e,t,r,i,n,o,,,a]=this._array;return{a:e,c:t,tx:r,b:i,d:n,ty:o,tz:a}}}class Ph extends et{constructor(){super(3)}}var Sh=Object.defineProperty,qo=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Sh(e,t,i),i};class Ci extends It{_starting=!1;_nextDeltaTime=0;_startedProcess;get starting(){return this._starting}get spf(){return this.fps?Math.floor(1e3/this.fps):0}constructor(){super(),this._onNextTick=this._onNextTick.bind(this)}start(e){this._starting||(this._starting=!0,this._startedProcess&&this.off("process",this._startedProcess),this._startedProcess=e,this.on("process",e),Ce.on(this._onNextTick,{sort:0}))}stop(){this._starting&&(this._starting=!1,Ce.off(this._onNextTick,{sort:0}))}_onNextTick(){const e=Ce.elapsed*this.speed;if((this._nextDeltaTime-=e)<=0){const r=(this._nextDeltaTime=this.spf)||e;this.emit("process",r)}}destroy(){super.destroy(),this.stop()}}qo([w({fallback:60})],Ci.prototype,"fps"),qo([w({fallback:1})],Ci.prototype,"speed");class Xo{view;pixelRatio=Es;screen={x:0,y:0,width:0,height:0};related=new As;getRelated(e,t){let r=this.related.get(e);return r||(t?(this.related.set(e,r=t()),r):(console.warn("Failed to get related",e),null))}resize(e,t,r=!0){this.view&&(this.view.width=Math.floor(e*this.pixelRatio),this.view.height=Math.floor(t*this.pixelRatio)),this.screen.width=e,this.screen.height=t,r&&this.view&&(this.view.style.width=`${e}px`,this.view.style.height=`${t}px`)}}var cr=(s=>(s.NORMAL="normal",s.ADD="add",s.MULTIPLY="multiply",s.SCREEN="screen",s.NONE="none",s.NORMAL_NPM="normal_npm",s.ADD_NPM="add_npm",s.SCREEN_NPM="screen_npm",s.SRC_IN="src_in",s.SRC_OUT="src_out",s.SRC_ATOP="src_atop",s.DST_OVER="dst_over",s.DST_IN="dst_in",s.DST_OUT="dst_out",s.DST_ATOP="dst_atop",s.XOR="xor",s.SUBTRACT="subtract",s))(cr||{});function Ho(s){return{normal:[s.ONE,s.ONE_MINUS_SRC_ALPHA],add:[s.ONE,s.ONE],multiply:[s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],screen:[s.ONE,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],none:[0,0],normal_npm:[s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA],add_npm:[s.SRC_ALPHA,s.ONE,s.ONE,s.ONE],screen_npm:[s.SRC_ALPHA,s.ONE_MINUS_SRC_COLOR,s.ONE,s.ONE_MINUS_SRC_ALPHA],src_in:[s.DST_ALPHA,s.ZERO],src_out:[s.ONE_MINUS_DST_ALPHA,s.ZERO],src_atop:[s.DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],dst_over:[s.ONE_MINUS_DST_ALPHA,s.ONE],dst_in:[s.ZERO,s.SRC_ALPHA],dst_out:[s.ZERO,s.ONE_MINUS_SRC_ALPHA],dst_atop:[s.ONE_MINUS_DST_ALPHA,s.SRC_ALPHA],xor:[s.ONE_MINUS_DST_ALPHA,s.ONE_MINUS_SRC_ALPHA],subtract:[s.ONE,s.ONE,s.ONE,s.ONE,s.FUNC_REVERSE_SUBTRACT,s.FUNC_ADD]}}class Ye{get gl(){return this._renderer.gl}install(e){this._renderer=e}onUpdateContext(){}flush(){}reset(){}destroy(){}}class Xt{static _properties=["blend","offsets","culling","depthTest","clockwiseFrontFace","depthMask"];static _init(){this._properties.forEach((e,t)=>{Object.defineProperty(this.prototype,e,{get(){return!!(this.bitmap&1<<t)},set(r){!!(this.bitmap&1<<t)!==r&&(this.bitmap^=1<<t)},enumerable:!0,configurable:!0})})}static for2D(){const e=new Xt;return e.depthTest=!1,e.blend=!0,e}_blendMode=cr.NORMAL;_polygonOffset=0;bitmap=0;get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!==cr.NONE,this._blendMode=e}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}constructor(e){if(e)for(const t in e)this[t]=e[t]}}Xt._init();class Yo extends Ye{install(e){super.install(e),e.state=this}_blendEq=!1;_setters=Xt._properties.map(e=>this[`set${e.replace(/^\S/,t=>t.toUpperCase())}`]);boundStateBitmap=0;boundBlendMode;blendModes;defaultState=new Xt({blend:!0});onUpdateContext(){super.onUpdateContext(),this.blendModes=Ho(this._renderer.gl)}toggle(e,t){this._renderer.gl[t?"enable":"disable"](e)}setBlend(e){this.toggle(this._renderer.gl.BLEND,e)}setOffsets(e){this.toggle(this._renderer.gl.POLYGON_OFFSET_FILL,e)}setCulling(e){this.toggle(this._renderer.gl.CULL_FACE,e)}setDepthTest(e){this.toggle(this._renderer.gl.DEPTH_TEST,e)}setDepthMask(e){this._renderer.gl.depthMask(e)}setClockwiseFrontFace(e){const t=this._renderer.gl;t.frontFace(t[e?"CW":"CCW"])}setBlendMode(e){if(e===this.boundBlendMode)return;this.boundBlendMode=e;const t=this.blendModes[e],r=this._renderer.gl;t.length===2?r.blendFunc(t[0],t[1]):r.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,r.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.FUNC_ADD))}setPolygonOffset(e,t){this._renderer.gl.polygonOffset(e,t)}bind(e){if(this.boundStateBitmap!==e.bitmap){let t=this.boundStateBitmap^e.bitmap,r=0;for(;t;)t&1&&this._setters[r]?.call(this,!!(e.bitmap&1<<r)),t=t>>1,r++;this.boundStateBitmap=e.bitmap}e.blend&&this.setBlendMode(e.blendMode),e.offsets&&this.setPolygonOffset(1,e.polygonOffset)}reset(){super.reset();const e=this._renderer.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),this.bind(this.defaultState),this._blendEq=!0,this.setBlendMode(cr.NORMAL)}}class Ko extends Ye{install(e){super.install(e),e.batch2D=this}_state=Xt.for2D();_batchSize=4096*4;_drawCallUid=0;_defaultModulate=[255,255,255,255];_defaultBackgroundColor=[0,0,0,0];_batchables=[];_vertexCount=0;_indexCount=0;_attributeBuffer=[];_indexBuffers=[];_shaders=new Map;_attributes={aTextureId:{size:1,normalized:!0,type:"float"},aPosition:{size:2,normalized:!1,type:"float"},aUv:{size:2,normalized:!1,type:"float"},aModulate:{size:4,normalized:!0,type:"unsigned_byte"},aBackgroundColor:{size:4,normalized:!0,type:"unsigned_byte"},aDisableWrapMode:{size:1,normalized:!0,type:"float"}};_vertexSize=8;_getShader(e){let t=this._shaders.get(e);return t||this._shaders.set(e,t=this._createShader(e)),t}_createShader(e){const t=this._renderer,r=t.program.create({vert:`precision highp float;
3
3
  attribute float aTextureId;
4
4
  attribute vec2 aPosition;
5
5
  attribute vec2 aUv;
@@ -71,8 +71,8 @@ void main(void) {
71
71
  gl_FragColor = color;
72
72
  }`}),i=t.buffer.create({target:"array_buffer",data:new Float32Array(1),usage:"dynamic_draw"}),n=t.buffer.create({target:"element_array_buffer",data:new Uint16Array(1),usage:"dynamic_draw"}),o={attributes:Object.fromEntries(Object.entries(this._attributes).map(([c,h])=>[c,{...h,buffer:i}])),elementArrayBuffer:n},a=t.vertexArray.create(r,o),l=new Int32Array(Array.from({length:e},(c,h)=>h));return{update:(c,h)=>{t.vertexArray.bind(a??o),t.buffer.update(i,{target:"array_buffer",data:c}),t.buffer.update(n,{target:"element_array_buffer",data:h})},draw:c=>{const h=this._renderer;h.program.bind(r),h.program.updateUniforms(r,{samplers:l,modulate:[1,1,1,1],canvasWidth:h.gl.drawingBufferWidth,canvasHeight:h.gl.drawingBufferHeight,...h.program.uniforms}),h.vertexArray.bind(a??o),h.draw(c)}}}render(e){const{vertices:t,indices:r}=e,i=t.length/2;this._vertexCount+i>this._batchSize&&this.flush(),this._vertexCount+=i,this._indexCount+=r.length,this._batchables.push(e)}flush(){if(super.flush(),this._vertexCount===0)return;const e=this._vertexCount,t=this._indexCount,r=this._batchables;this._batchables=[],this._vertexCount=0,this._indexCount=0;const i=this._renderer.texture.maxUnits,n=this._getAttributeBuffer(e),o=new Float32Array(n),a=new Uint8Array(n),l=this._getIndexBuffer(t);let c=0,h=0;const f=[];for(let g=r.length,p={id:++this._drawCallUid},y=[],m=new Map,P=0,E=0,x=0;x<g;x++){const S=r[x].texture,_=x===g-1;if(!S||m.has(S)){if(!_)continue}else y.push(S),m.set(S,P++);if(_||P>=i){p.textures=y,p.textureLocationMap=m,P=0,p.first=h;for(let b=E;b<=x;b++){const{indices:C,vertices:T,uvs:B=[],texture:G,modulate:R=this._defaultModulate,backgroundColor:U=this._defaultBackgroundColor,blendMode:V=cr.NORMAL,disableWrapMode:L=!1}=r[b];E<b&&p.blendMode!==V&&(p.count=h-p.first,f.push(p),E=b,p={id:++this._drawCallUid},p.textures=y,p.first=h);const D=c/this._vertexSize,H=(G?m.get(G):-1)??-1,I=L?1:0;for(let N=T.length,$=0;$<N;$+=2){if(o[c++]=H,o[c++]=T[$],o[c++]=T[$+1],o[c++]=B[$],o[c++]=B[$+1],R){const O=c*4;a[O]=R[0],a[O+1]=R[1],a[O+2]=R[2],a[O+3]=R[3]}if(c++,U){const O=c*4;a[O]=U[0],a[O+1]=U[1],a[O+2]=U[2],a[O+3]=U[3]}c++,o[c++]=I}for(let N=C.length,$=0;$<N;$++)l[h++]=D+C[$];p.blendMode=V}E=x+1,p.count=h-p.first,f.push(p),p={id:++this._drawCallUid},y=[],m=new Map}}const d=this._getShader(i);d.update(n,l);for(let g=f.length,p=0;p<g;p++){const y=f[p],{first:m=0,textures:P,textureLocationMap:E}=y;for(let x=P.length,S=0;S<x;S++){const _=P[S],b=E.get(_);b!==void 0&&this._renderer.texture.bind({target:"texture_2d",location:b,value:_})}this._state.blendMode=y.blendMode,this._renderer.state.bind(this._state),d.draw({mode:"triangles",count:y.count,first:m,bytesPerElement:2})}}_getAttributeBuffer(e){const t=Is(Math.ceil(e/8)),r=Rs(t),i=t*8;this._attributeBuffer.length<=r&&(this._indexBuffers.length=r+1);let n=this._attributeBuffer[i];return n||(this._attributeBuffer[i]=n=new ArrayBuffer(i*this._vertexSize*4)),n}_getIndexBuffer(e){const t=Is(Math.ceil(e/12)),r=Rs(t),i=t*12;this._indexBuffers.length<=r&&(this._indexBuffers.length=r+1);let n=this._indexBuffers[r];return n||(this._indexBuffers[r]=n=new Uint16Array(i)),n}}function Is(s){return s+=s===0?1:0,--s,s|=s>>>1,s|=s>>>2,s|=s>>>4,s|=s>>>8,s|=s>>>16,s+1}function Rs(s){let e=(s>65535?1:0)<<4;s>>>=e;let t=(s>255?1:0)<<3;return s>>>=t,e|=t,t=(s>15?1:0)<<2,s>>>=t,e|=t,t=(s>3?1:0)<<1,s>>>=t,e|=t,e|s>>1}class Zo extends Ye{install(e){super.install(e),e.buffer=this}boundArrayBuffer=null;boundTarget="array_buffer";create(e){const t=this.gl.createBuffer();if(!t)throw new Error("failed to create");return e&&(this.bind({target:e.target,value:t}),this.update(e)),t}getMeta(e){return this._renderer.getRelated(e,()=>({id:xo(e),length:0,byteLength:0,bytesPerElement:0}))}update(...e){if(e.length>1){this.bind({target:e[1].target,value:e[0]}),this.update(e[1]);return}const t=e[0],r=(t.target??this.boundTarget)==="array_buffer"?this.boundArrayBuffer:this._renderer.vertexArray.boundVertexArray.elementArrayBuffer;if(!r)return;const i=this.getMeta(r);Object.assign(i,{target:t.target,usage:t.usage});const n=i.target??this.boundTarget,o=i.usage??"static_draw",a=t.data,l=this.gl;let c;Array.isArray(a)?n==="array_buffer"?c=new Float32Array(a):c=new Uint32Array(a):c=a;const h=this._renderer.getBindPoint(n);c&&c.byteLength<=i.byteLength?l.bufferSubData(h,0,c):(l.bufferData(h,c,this._renderer.getBindPoint(o)),i.length=c?.length??0,i.byteLength=c?.byteLength??0,i.bytesPerElement=i.length?i.byteLength/i.length:0)}bind(e){let{target:t,value:r}=e;if(r){const n=this.getMeta(r);t??=n.target??this.boundTarget,n.target=t}else t??=this.boundTarget;const i=this._renderer.getBindPoint(t);this._renderer.gl.bindBuffer(i,r),t==="array_buffer"?this.boundArrayBuffer=r:this._renderer.vertexArray.boundVertexArray.elementArrayBuffer=r,this.boundTarget=t}unbind(e){return this.bind({target:e,value:null})}reset(){super.reset(),this.boundArrayBuffer=null,this.boundTarget="array_buffer"}}class Jo extends Ye{install(e){super.install(e),e.framebuffer=this}boundFramebuffer=null;_msaaSamples=[];_hasMRT=!0;_writeDepthTexture=!0;onUpdateContext(){if(this._hasMRT=!0,this._writeDepthTexture=!0,this._renderer.version===1){const e=this._renderer.gl,t=this._renderer.extensions.drawBuffers,r=this._renderer.extensions.depthTexture;t?e.drawBuffers=i=>t.drawBuffersWEBGL(i):(this._hasMRT=!1,e.drawBuffers=()=>{}),r||(this._writeDepthTexture=!1)}else{const e=this._renderer.gl;this._msaaSamples=e.getInternalformatParameter(e.RENDERBUFFER,e.RGBA8,e.SAMPLES)}}create(e){const t=this._renderer.gl.createFramebuffer();if(!t)throw new Error("Unable to create framebuffer");return e&&(this.bind(t),this.update(e)),t}getMeta(e){return this._renderer.getRelated(e,()=>({width:0,height:0,mipLevel:0,stencil:!1,depth:!1,depthTexture:null,colorTextures:[],multisample:0}))}update(...e){if(e.length>1)return this.bind(e[0]),this.update(e[1]);const t=this.boundFramebuffer;if(!t)return;const r=e[0],i=this.getMeta(t);Object.assign(i,{...r});const n=this._renderer.gl;let o=i.colorTextures.length;"drawBuffers"in n||(o=Math.min(o,1));for(let a=0;a<o;a++){const l=i.colorTextures[a];this._renderer.texture.bind({location:0,target:"texture_2d",value:l,forceUpdateLocation:!0}),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+a,n.TEXTURE_2D,l,i.mipLevel),this._renderer.texture.unbind(l)}if(o>1&&n.drawBuffers(i.colorTextures.map((a,l)=>n.COLOR_ATTACHMENT0+l)),i.depthTexture&&(this._renderer.version>1||this._renderer.extensions.depthTexture)&&(this._renderer.texture.bind({location:0,target:"texture_2d",value:i.depthTexture,forceUpdateLocation:!0}),n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,i.depthTexture,i.mipLevel),this._renderer.texture.unbind(i.depthTexture)),(i.stencilBuffer||i.stencil||i.depth)&&!(i.depthTexture&&this._writeDepthTexture)){i.stencilBuffer??=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,i.stencilBuffer);const{attachment:a,format:l}=this._getAttachmentAndFormat(i);i.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,i.multisample,l,i.width,i.height):n.renderbufferStorage(n.RENDERBUFFER,l,i.width*this._renderer.pixelRatio,i.height*this._renderer.pixelRatio),n.framebufferRenderbuffer(n.FRAMEBUFFER,a,n.RENDERBUFFER,i.stencilBuffer)}else i.stencilBuffer&&(n.deleteRenderbuffer(i.stencilBuffer),i.stencilBuffer=null)}_getAttachmentAndFormat(e){const t=this.gl;let r,i;return this._renderer.version===1?(r=t.DEPTH_STENCIL_ATTACHMENT,i=t.DEPTH_STENCIL):e.depth&&e.stencil?(r=t.DEPTH_STENCIL_ATTACHMENT,i=t.DEPTH24_STENCIL8):e.depth?(r=t.DEPTH_ATTACHMENT,i=t.DEPTH_COMPONENT24):(r=t.STENCIL_ATTACHMENT,i=t.STENCIL_INDEX8),{attachment:r,format:i}}resize(e,t,r){const i=this.gl,n=this.getMeta(e);if(Object.assign(n,{width:t,height:r}),n.stencil){const{format:a}=this._getAttachmentAndFormat(n);i.bindRenderbuffer(i.RENDERBUFFER,n.stencil),n.msaaBuffer?i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,a,n.width,n.height):i.renderbufferStorage(i.RENDERBUFFER,a,n.width,n.height)}let o=n.colorTextures.length;i.drawBuffers||(o=Math.min(o,1));for(let a=0;a<o;a++){const l=n.colorTextures[a];this._renderer.texture.update(l,{value:{pixels:null,width:n.width,height:n.height}}),a===0&&n.msaaBuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,n.msaaBuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,n.multisample,i.RGBA,n.width,n.height))}n.depthTexture&&this._renderer.texture.update(n.depthTexture,{value:{pixels:null,width:n.width,height:n.height}})}bind(e){const t=this._renderer.gl,r=e;if({value:this.boundFramebuffer!==r}.value&&(t.bindFramebuffer(t.FRAMEBUFFER,r),this.boundFramebuffer=r),r){const o=this.getMeta(r);for(let c=0;c<o.colorTextures.length;c++)this._renderer.texture.unbind(o.colorTextures[c]);o.depthTexture&&this._renderer.texture.unbind(o.depthTexture);const a=o.width>>o.mipLevel,l=o.height>>o.mipLevel;this._renderer.viewport.bind({x:0,y:0,width:a*this._renderer.pixelRatio,height:l*this._renderer.pixelRatio})}else this._renderer.viewport.bind({x:0,y:0,width:this._renderer.screen.width*this._renderer.pixelRatio,height:this._renderer.screen.height*this._renderer.pixelRatio})}forceStencil(){const e=this.boundFramebuffer;if(!e)return;const t=this.getMeta(e);if(!t||t.stencilBuffer)return;const r=this._renderer.gl;t.stencilBuffer=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,t.stencilBuffer);let i,n;this._renderer.version===1?(i=r.DEPTH_STENCIL_ATTACHMENT,n=r.DEPTH_STENCIL):t.depth?(i=r.DEPTH_STENCIL_ATTACHMENT,n=r.DEPTH24_STENCIL8):(i=r.STENCIL_ATTACHMENT,n=r.STENCIL_INDEX8),t.msaaBuffer?r.renderbufferStorageMultisample(r.RENDERBUFFER,t.multisample,n,t.width*this._renderer.pixelRatio,t.height*this._renderer.pixelRatio):r.renderbufferStorage(r.RENDERBUFFER,n,t.width*this._renderer.pixelRatio,t.height*this._renderer.pixelRatio),r.framebufferRenderbuffer(r.FRAMEBUFFER,i,r.RENDERBUFFER,t.stencilBuffer)}reset(){super.reset(),this.boundFramebuffer=null}}class Qo extends Ye{install(e){super.install(e),e.mask=this}stack=[];get length(){return this.stack.length}get last(){return this.stack[this.length-1]}push(e,t){const r={source:e,mask:t};this.stack.push(r),typeof r.mask=="number"?this.pushColorMask(r):"render"in r.mask?this._renderer.stencil.push(r):this._renderer.scissor.push(r)}pop(e){const t=this.stack.pop();!t||t.source!==e||(typeof t.mask=="number"?this.popColorMask(t):"render"in t.mask?this._renderer.stencil.pop(t):this._renderer.scissor.pop(t))}pushColorMask(e){const t=e.preComputedColor??15,r=e.preComputedColor=t&e.mask;r!==t&&this.useColorMask(r)}popColorMask(e){const t=e.preComputedColor??15,r=this.length>0?this.last.preComputedColor??15:15;r!==t&&this.useColorMask(r)}useColorMask(e){this._renderer.gl.colorMask((e&1)!==0,(e&2)!==0,(e&4)!==0,(e&8)!==0)}}class ea extends Ye{install(e){super.install(e),e.program=this}boundProgram=null;uniforms={projectionMatrix:[1,0,0,0,1,0,0,0,1],viewMatrix:[1,0,0,0,1,0,0,0,1]};create(e){const t=this.gl.createProgram();if(!t)throw new Error("Unable to create program");return e&&this.update(t,e),t}getMeta(e){return this._renderer.getRelated(e,()=>({attributes:new Map,uniforms:new Map,boundUniforms:new ao}))}update(...e){if(e.length>1){const l=this.boundProgram;this.boundProgram=e[0],this.update(e[1]),this.boundProgram=l;return}const t=e[0],r=this.boundProgram;if(!r)return;const i=this.gl,n=this.getMeta(r),o=this.createShader(t.vert,"vertex_shader"),a=this.createShader(t.frag,"fragment_shader");if(i.attachShader(r,o),i.attachShader(r,a),i.linkProgram(r),i.deleteShader(o),i.deleteShader(a),!i.getProgramParameter(r,i.LINK_STATUS))throw new Error(`Unable to link program: ${i.getProgramInfoLog(r)}`);n.attributes.clear(),n.uniforms.clear();for(let l=i.getProgramParameter(r,i.ACTIVE_ATTRIBUTES),c=0;c<l;c++){const h=i.getActiveAttrib(r,c);if(!h||h.name.startsWith("gl_"))continue;const f=this._renderer.bindPoints.get(h.type)??String(h.type);n.attributes.set(h.name,{type:f,name:h.name,size:Ch(f),location:i.getAttribLocation(r,h.name)})}for(let l=i.getProgramParameter(r,i.ACTIVE_UNIFORMS),c=0;c<l;c++){const h=i.getActiveUniform(r,c);if(!h)continue;const f=h.name.replace(/\[.*?\]$/,"");let d=i.getUniformLocation(r,f);d||(d=i.getUniformLocation(r,h.name)),n.uniforms.set(f,{name:f,index:c,type:this._renderer.bindPoints.get(h.type)??String(h.type),size:h.size,isArray:f!==h.name,location:d})}}bind(e){const t=this.gl;({value:this.boundProgram!==e}).value&&(t.useProgram(e),this.boundProgram=e)}createShader(e,t){const r=this.gl,i=r.createShader(this._renderer.getBindPoint(t));if(!i)throw new Error("Unable to create shader");if(r.shaderSource(i,e),r.compileShader(i),!r.getShaderParameter(i,r.COMPILE_STATUS))throw new Error(`Unable to compiling shader :
73
73
  ${e}
74
- ${r.getShaderInfoLog(i)}`);return i}updateUniforms(...e){if(e.length>1){this.bind(e[0]),this.updateUniforms(e[1]);return}const t=this.boundProgram;if(!t)return;const r=this.gl,i=e[0],{uniforms:n,boundUniforms:o}=this.getMeta(t);for(const a in i){const l=i[a],c=n.get(a);if(!c)continue;const{type:h,isArray:f,location:d}=c;if(!(!d||o.get(d)===l))switch(o.set(d,l),h){case"float":f?r.uniform1fv(d,l):r.uniform1f(d,l);break;case"unsigned_int":f?r.uniform1uiv(d,l):r.uniform1ui(d,l);break;case"bool":case"int":case"sampler_2d":case"sampler_cube":case"sampler_2d_array":f?r.uniform1iv(d,l):r.uniform1i(d,l);break;case"bool_vec2":case"int_vec2":r.uniform2iv(d,l);break;case"unsigned_int_vec2":r.uniform2uiv(d,l);break;case"float_vec2":r.uniform2fv(d,l);break;case"bool_vec3":case"int_vec3":r.uniform3iv(d,l);break;case"unsigned_int_vec3":r.uniform3uiv(d,l);break;case"float_vec3":r.uniform3fv(d,l);break;case"bool_vec4":case"int_vec4":r.uniform4iv(d,l);break;case"unsigned_int_vec4":r.uniform4uiv(d,l);break;case"float_vec4":r.uniform4fv(d,l);break;case"float_mat2":r.uniformMatrix2fv(d,!1,l);break;case"float_mat3":r.uniformMatrix3fv(d,!1,l);break;case"float_mat4":r.uniformMatrix4fv(d,!1,l);break}}}reset(){super.reset(),this.boundProgram=null,this.uniforms={projectionMatrix:[1,0,0,0,1,0,0,0,1],viewMatrix:[1,0,0,0,1,0,0,0,1]}}destroy(){super.destroy(),this.bind(null)}}function Ch(s){switch(s){case"float":case"int":case"unsigned_int":case"bool":case"sampler_2d":return 1;case"float_vec2":case"int_vec2":case"unsigned_int_vec2":case"bool_vec2":return 2;case"float_vec3":case"int_vec3":case"unsigned_int_vec3":case"bool_vec3":return 3;case"float_vec4":case"int_vec4":case"unsigned_int_vec4":case"bool_vec4":case"float_mat2":return 4;case"float_mat3":return 9;case"float_mat4":return 16;default:return 1}}function Ti(s,e,t){const[r,i,n,o,a,l,c,h,f]=s,d=r*e+o*t+c,g=i*e+a*t+h,p=n*e+l*t+f;return{x:d/p,y:g/p}}function Th(s,e){const{x:t,y:r,width:i,height:n}=e,o=Ti(s,t,r),a=Ti(s,t+i,r),l=Ti(s,t+i,r+n),c=Ti(s,t,r+n),h=[o,a,l,c],f=h.map(P=>P.x),d=h.map(P=>P.y),g=Math.min(...f),p=Math.max(...f),y=Math.min(...d),m=Math.max(...d);return{x:g,y,width:p-g,height:m-y}}class ta extends Ye{install(e){super.install(e),e.scissor=this}get length(){return this._renderer.mask.last?.scissorCounter??0}push(e){const t=this._renderer.gl;t.enable(t.SCISSOR_TEST),e.scissorCounter??=0,e.scissorCounter++,this.use()}pop(e){if(this.length>0)this.use();else{const t=this._renderer.gl;t.disable(t.SCISSOR_TEST)}}use(){const e=this._renderer,{pixelRatio:t,mask:r,viewport:i,screen:n,gl:o,program:a}=e,{viewMatrix:l}=a.uniforms,c=Th(l,r.last.mask),{x:h,y:f,width:d,height:g}=c;let p;i.boundViewport?p=i.boundViewport.height-(g+f)*t:p=(n.height-(g+f))*t,o.scissor(h*t,p,d*t,g*t)}}class ra extends Ye{install(e){super.install(e),e.stencil=this}get length(){return this._renderer.mask.last?.stencilCounter??0}push(e){const t=this._renderer.gl,r=e.mask,i=e.stencilCounter??=0;e.stencilCounter===0&&(this._renderer.framebuffer.forceStencil(),t.clearStencil(0),t.clear(t.STENCIL_BUFFER_BIT),t.enable(t.STENCIL_TEST)),e.stencilCounter++;const n=e.color;n&&(e.color=0,t.colorMask(!1,!1,!1,!1)),t.stencilFunc(t.EQUAL,i,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.INCR),r.render(this._renderer),this._renderer.flush(),n&&(e.color=n,t.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this.use()}pop(e){const t=this._renderer.gl,r=e.mask;if(!this.length)t.disable(t.STENCIL_TEST);else{const i=this._renderer.mask.last,n=i?.color??15;n!==0&&(i.color=0,t.colorMask(!1,!1,!1,!1)),t.stencilOp(t.KEEP,t.KEEP,t.DECR),r.render(this._renderer),this._renderer.flush(),n!==0&&(i.color=n,t.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this.use()}}use(){const e=this._renderer.gl;e.stencilFunc(e.EQUAL,this.length,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)}}function Eh(s,e){const t=new Set([...Object.keys(s),...Object.keys(e)]),r={};return t.forEach(i=>{r[i]=s[i]!==e[i]}),r}class ia extends Ye{install(e){super.install(e),e.texture=this}maxUnits=0;boundLocation=0;boundTarget="texture_2d";boundTextures=[];emptyTextures={texture_2d:null,texture_cube_map:null};onUpdateContext(){super.onUpdateContext();const e=this.gl;this.maxUnits=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);for(let i=0;i<this.maxUnits;i++)this.boundTextures[i]={texture_2d:null,texture_cube_map:null};const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(4));const r=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,r);for(let i=0;i<6;i++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR),this.emptyTextures={texture_2d:t,texture_cube_map:r};for(let i=this.boundTextures.length,n=0;n<i;n++)this.unbind(n)}create(e){const t=this.gl.createTexture();if(!t)throw new Error("Unable to create texture");return e&&(this.bind({location:e.location,target:e.target,value:t,forceUpdateLocation:!0}),this.update({filterMode:"linear",wrapMode:"repeat",...e})),t}getMeta(e){return this._renderer.getRelated(e,()=>({}))}update(...e){if(e.length>1){this.bind({location:e[1].location,target:e[1].target,value:e[0],forceUpdateLocation:!0}),this.update(e[1]);return}const t=e[0],{value:r,...i}=t,n=this.boundTextures[this.boundLocation][t.target??this.boundTarget];if(!n)return;const o=this.gl,a=this.getMeta(n),l=Eh(a,i);Object.assign(a,i);const c=this._renderer.getBindPoint(a.target??this.boundTarget);if(r!==void 0&&(r===null?o.texImage2D(c,0,o.RGBA,1,1,0,o.RGBA,o.UNSIGNED_BYTE,null):"pixels"in r?o.texImage2D(c,0,o.RGBA,r.width,r.height,0,o.RGBA,o.UNSIGNED_BYTE,r.pixels):o.texImage2D(c,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,r)),l.wrapMode&&a.wrapMode){const f=this._renderer.getBindPoint(a.wrapMode);o.texParameteri(c,o.TEXTURE_WRAP_S,f),o.texParameteri(c,o.TEXTURE_WRAP_T,f)}const h=a.filterMode;if(l.filterMode&&h){const f=this._renderer.getBindPoint(h.split("_")[0]);h.includes("_")?o.texParameteri(c,o.TEXTURE_MIN_FILTER,this._renderer.getBindPoint(h)):o.texParameteri(c,o.TEXTURE_MIN_FILTER,f),o.texParameteri(c,o.TEXTURE_MAG_FILTER,f)}if(a.anisoLevel&&h==="linear"&&this._renderer.extensions.anisotropicFiltering&&l.anisoLevel){const{MAX_TEXTURE_MAX_ANISOTROPY_EXT:f,TEXTURE_MAX_ANISOTROPY_EXT:d}=this._renderer.extensions.anisotropicFiltering;o.texParameterf(c,d,Math.min(a.anisoLevel,o.getParameter(f)))}}bind(e){const t=this.gl;let r,i,n,o;if(e&&"value"in e?{target:i,value:r,location:n,forceUpdateLocation:o}=e:r=e,r){const g=this.getMeta(r);g.target=i??=g.target??"texture_2d",g.location=n??=g.location??0}else i??="texture_2d",n??=0;let a=this.boundTextures[n];a||(this.boundTextures[n]=a={texture_2d:null,texture_cube_map:null});const l=a[i]??null,c=this.boundLocation,h=r!==l,f={location:n!==c&&(h||o),texture:h},d=this._renderer.getBindPoint(i);f.location&&(t.activeTexture(t.TEXTURE0+n),this.boundLocation=n),f.texture&&(t.bindTexture(d,r??this.emptyTextures[i]),a[i]=r),this.boundTarget=i}unbind(e,t="texture_2d"){const r=this._renderer.gl;if(typeof e=="number")this.bind({value:null,target:t,location:e});else{const i=this.getMeta(e),{target:n=this.boundTarget}=i,o=this._renderer.getBindPoint(n);for(let a=0;a<this.boundTextures.length;a++)this.boundTextures[a][n]===e&&(this.boundLocation!==a&&(r.activeTexture(r.TEXTURE0+a),this.boundLocation=a),r.bindTexture(o,this.emptyTextures[n]),this.boundTextures[a][n]=null)}}reset(){super.reset(),this.boundLocation=0,this.boundTarget="texture_2d",this.boundTextures=[],this.maxUnits=0}}class sa extends Ye{install(e){super.install(e),e.vertexArray=this}boundVertexArrayNull={attributes:{},elementArrayBuffer:null};boundVertexArrayObject=null;boundVertexArray=this.boundVertexArrayNull;enableVertexAttrib(e,t,r,i=1){const{buffer:n,size:o=0,type:a="float",normalized:l=!1,stride:c=0,offset:h=0,divisor:f}=r,d=this._renderer.gl;this._renderer.buffer.bind({target:"array_buffer",value:n});for(let g=0;g<i;g++)d.enableVertexAttribArray(t+g),d.vertexAttribPointer(t+g,o,this._renderer.getBindPoint(a),l,c,h+(c-h)/i*g);f&&("vertexAttribDivisor"in d?d.vertexAttribDivisor(t,f):console.warn("Failed to active vertex array object, GPU Instancing is not supported on this device")),this.boundVertexArray.attributes[e]={enable:!0,...r}}create(...e){const t=this._renderer.gl;if(!("createVertexArray"in t))return null;const r=t.createVertexArray();if(!r)throw new Error("Unable to create vertex array");return e.length===2?this.update(e[0],r,e[1]):e.length===1&&this.update(r,e[0]),r}getVertexArrayMeta(e){return this._renderer.getRelated(e,()=>({attributes:{},elementArrayBuffer:null}))}update(...e){if(e.length>2){this._renderer.program.bind(e[0]),this.update(e[1],e[2]);return}else if(e.length===2)if(e[0]){const n=e[0],o=e[1],a=this.getVertexArrayMeta(n);this.bind(n),this.update(o),a.attributes=this.boundVertexArray.attributes,a.elementArrayBuffer=this.boundVertexArray.elementArrayBuffer,this.unbind(),this._renderer.buffer.unbind("array_buffer");return}else return this.update(e[1]);const t=this._renderer.program.boundProgram;if(!t)return;const r=e[0];if(r.attributes){const n=this._renderer.program.getMeta(t),o={},a={};for(const c in r.attributes){const h=r.attributes[c],f=n.attributes.get(c);let d;"buffer"in h?d={...h}:d={buffer:h},d.size=d.size||f?.size||0;const g=this._renderer.buffer.getMeta(d.buffer),p=Number(f?.type.match(/mat(\d)/)?.[1]??1);let y;switch(d.type){case"unsigned_byte":y=d.size;break;case"unsigned_short":y=d.size*2;break;case"float":default:y=d.size*4;break}y*=p,o[g.id]??=0,o[g.id]+=y,a[c]={attrib:d,meta:g,info:f,byteLength:y,dimension:p}}const l={};for(const c in a){const{attrib:h,meta:f,info:d,byteLength:g,dimension:p}=a[c];d?.location!==void 0&&(l[f.id]??=0,h.offset??=l[f.id],h.stride??=o[f.id]===g?0:o[f.id],this.enableVertexAttrib(c,d.location,h,p),l[f.id]+=g)}}const i=r.elementArrayBuffer??null;this._renderer.buffer.bind({target:"element_array_buffer",value:i}),this.boundVertexArray.elementArrayBuffer=i}bind(e){const t=this._renderer.gl;if(e&&"attributes"in e)this.update(e);else if("bindVertexArray"in t){const r=this.boundVertexArrayObject;({value:e!==r}).value&&(t.bindVertexArray(e),this.boundVertexArrayObject=e,e?this.boundVertexArray={...this.getVertexArrayMeta(e)}:this.boundVertexArray=this.boundVertexArrayNull)}}unbind(){return this.bind(null)}reset(){super.reset(),this.boundVertexArrayNull={attributes:{},elementArrayBuffer:null},this.boundVertexArray=this.boundVertexArrayNull,this.boundVertexArrayObject=null}}class na extends Ye{install(e){super.install(e),e.viewport=this}boundViewport={x:0,y:0,width:0,height:0};bind(e){const t=this.boundViewport,r=Math.floor(e.x),i=Math.floor(e.y),n=Math.floor(e.width),o=Math.floor(e.height);t.x===r&&t.y===i&&t.width===n&&t.height===o||(this._renderer.gl.viewport(r,i,n,o),t.x=r,t.y=i,t.width=n,t.height=o)}reset(){super.reset(),this.boundViewport={x:0,y:0,width:0,height:0}}}class oa extends Xo{_modules=[new ia,new Zo,new Jo,new ea,new sa,new na,new Yo,new Qo,new ta,new ra,new Ko];bindPoints=new Map;constructor(e=Ro(),t){if(super(),!e)throw new Error("Failed to createHTMLCanvas");Do(e)?this._setupContext(e,t):(this.gl=e,this.version=Io(this.gl)?2:1),this._setupBindPoints()._setupExtensions()._setupPolyfill(),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this._modules.forEach(r=>r.install(this)),this._modules.forEach(r=>r.onUpdateContext())}_setupContext(e,t){this.view=e;let r=e.getContext("webgl2",t)||e.getContext("experimental-webgl2",t),i=2;if(r||(r=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),i=1),!r)throw new Error("Unable to getContext");return this.gl=r,this.version=i,this._onContextLost=this._onContextLost.bind(this),this._onContextRestored=this._onContextRestored.bind(this),e.addEventListener("webglcontextlost",this._onContextLost,!1),e.addEventListener("webglcontextrestored",this._onContextRestored,!1),this}_setupExtensions(){const e=this.gl,t={loseContext:e.getExtension("WEBGL_lose_context"),anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tcSRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc")};return this.version===1?(t.instancedArrays=e.getExtension("ANGLE_instanced_arrays"),t.drawBuffers=e.getExtension("WEBGL_draw_buffers"),t.depthTexture=e.getExtension("WEBGL_depth_texture"),t.vertexArrayObject=e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),t.uint32ElementIndex=e.getExtension("OES_element_index_uint"),t.floatTexture=e.getExtension("OES_texture_float"),t.textureHalfFloat=e.getExtension("OES_texture_half_float"),t.textureHalfFloatLinear=e.getExtension("OES_texture_half_float_linear")):this.version===2&&(t.colorBufferFloat=e.getExtension("EXT_color_buffer_float")),this.extensions=t,this}_setupBindPoints(){for(const e in this.gl)if(e===e.toUpperCase()){const t=this.gl[e];typeof t=="number"&&this.bindPoints.set(t,e.toLowerCase())}return this}_setupPolyfill(){if(this.version===1){const{instancedArrays:e,vertexArrayObject:t,drawBuffers:r}=this.extensions,i=this.gl;t&&(i.createVertexArray=()=>t.createVertexArrayOES(),i.bindVertexArray=n=>t.bindVertexArrayOES(n),i.deleteVertexArray=n=>t.deleteVertexArrayOES(n)),e&&(i.vertexAttribDivisor=(n,o)=>e.vertexAttribDivisorANGLE(n,o),i.drawElementsInstanced=(n,o,a,l,c)=>e.drawElementsInstancedANGLE(n,o,a,l,c),i.drawArraysInstanced=(n,o,a,l)=>e.drawArraysInstancedANGLE(n,o,a,l)),r&&(i.drawBuffers=n=>r.drawBuffersWEBGL(n))}return this}_onContextLost(e){e.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0)}_onContextRestored(){}getBindPoint(e){return this.gl[e.toUpperCase()]}clear(e=this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT){this.gl.clear(e)}draw(e={}){const{mode:t="triangles",first:r=0,instanceCount:i}=e;let{count:n=0,bytesPerElement:o=0}=e;if(!n||!o){const l=this.vertexArray.boundVertexArray.elementArrayBuffer??Object.values(this.vertexArray.boundVertexArray.attributes)[0];if(l){const c=this.buffer.getMeta(l);n||(n=c.length),o||(o=c.bytesPerElement)}}const a=this.getBindPoint(t);if(o)if(o===2||o===4&&this.extensions.uint32ElementIndex){const l=o===2?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT;i&&"drawElementsInstanced"in this.gl?this.gl.drawElementsInstanced(a,n,l,r*o,i):this.gl.drawElements(a,n,l,r*o)}else console.warn("Unsupported index buffer type: uint32");else i&&"drawArraysInstanced"in this.gl?this.gl.drawArraysInstanced(a,r,n,i):this.gl.drawArrays(a,r,n)}reset(){this._modules.forEach(e=>e.reset())}flush(){this._modules.forEach(e=>e.flush())}destroy(){this._modules.forEach(e=>e.destroy()),this.view?.removeEventListener("webglcontextlost",this._onContextLost,!1),this.view?.removeEventListener("webglcontextrestored",this._onContextRestored,!1),this.extensions.loseContext?.loseContext()}toPixels(e=0,t=0,r=this.gl.drawingBufferWidth,i=this.gl.drawingBufferHeight){const n=r*i*4,o=r*4,a=(i-1)*o,l=new Uint8Array(n),c=new Uint8ClampedArray(n);this.gl.readPixels(e,t,r,i,this.gl.RGBA,this.gl.UNSIGNED_BYTE,l);for(let h=0;h<n;h+=o)c.set(l.subarray(h,h+o),a-h);return c}}class Ut{}class aa extends Ut{install(e){const t=async r=>{const{parseFont:i}=await Promise.resolve().then(()=>eg);return await e.fetch(r).then(n=>n.arrayBuffer()).then(n=>i(n))};return this.load=r=>e.loadBy(r,()=>t(r)),["woff","ttf","otf"].forEach(r=>{e.register(r,t)}),e.font=this,this}}function Mh(s,e,t=2){const r=e&&e.length,i=r?e[0]*t:s.length;let n=la(s,0,i,t,!0);const o=[];if(!n||n.next===n.prev)return o;let a,l,c;if(r&&(n=Ih(s,e,n,t)),s.length>80*t){a=s[0],l=s[1];let h=a,f=l;for(let d=t;d<i;d+=t){const g=s[d],p=s[d+1];g<a&&(a=g),p<l&&(l=p),g>h&&(h=g),p>f&&(f=p)}c=Math.max(h-a,f-l),c=c!==0?32767/c:0}return Ir(n,o,t,a,l,c,0),o}function la(s,e,t,r,i){let n;if(i===jh(s,e,t,r)>0)for(let o=e;o<t;o+=r)n=fa(o/r|0,s[o],s[o+1],n);else for(let o=t-r;o>=e;o-=r)n=fa(o/r|0,s[o],s[o+1],n);return n&&hr(n,n.next)&&(Br(n),n=n.next),n}function Ht(s,e){if(!s)return s;e||(e=s);let t=s,r;do if(r=!1,!t.steiner&&(hr(t,t.next)||ie(t.prev,t,t.next)===0)){if(Br(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function Ir(s,e,t,r,i,n,o){if(!s)return;!o&&n&&Nh(s,r,i,n);let a=s;for(;s.prev!==s.next;){const l=s.prev,c=s.next;if(n?Oh(s,r,i,n):Ah(s)){e.push(l.i,s.i,c.i),Br(s),s=c.next,a=c.next;continue}if(s=c,s===a){o?o===1?(s=kh(Ht(s),e),Ir(s,e,t,r,i,n,2)):o===2&&Dh(s,e,t,r,i,n):Ir(Ht(s),e,t,r,i,n,1);break}}}function Ah(s){const e=s.prev,t=s,r=s.next;if(ie(e,t,r)>=0)return!1;const i=e.x,n=t.x,o=r.x,a=e.y,l=t.y,c=r.y,h=Math.min(i,n,o),f=Math.min(a,l,c),d=Math.max(i,n,o),g=Math.max(a,l,c);let p=r.next;for(;p!==e;){if(p.x>=h&&p.x<=d&&p.y>=f&&p.y<=g&&Rr(i,a,n,l,o,c,p.x,p.y)&&ie(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Oh(s,e,t,r){const i=s.prev,n=s,o=s.next;if(ie(i,n,o)>=0)return!1;const a=i.x,l=n.x,c=o.x,h=i.y,f=n.y,d=o.y,g=Math.min(a,l,c),p=Math.min(h,f,d),y=Math.max(a,l,c),m=Math.max(h,f,d),P=Us(g,p,e,t,r),E=Us(y,m,e,t,r);let x=s.prevZ,S=s.nextZ;for(;x&&x.z>=P&&S&&S.z<=E;){if(x.x>=g&&x.x<=y&&x.y>=p&&x.y<=m&&x!==i&&x!==o&&Rr(a,h,l,f,c,d,x.x,x.y)&&ie(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=g&&S.x<=y&&S.y>=p&&S.y<=m&&S!==i&&S!==o&&Rr(a,h,l,f,c,d,S.x,S.y)&&ie(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=P;){if(x.x>=g&&x.x<=y&&x.y>=p&&x.y<=m&&x!==i&&x!==o&&Rr(a,h,l,f,c,d,x.x,x.y)&&ie(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=E;){if(S.x>=g&&S.x<=y&&S.y>=p&&S.y<=m&&S!==i&&S!==o&&Rr(a,h,l,f,c,d,S.x,S.y)&&ie(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function kh(s,e){let t=s;do{const r=t.prev,i=t.next.next;!hr(r,i)&&ha(r,t,t.next,i)&&Ur(r,i)&&Ur(i,r)&&(e.push(r.i,t.i,i.i),Br(t),Br(t.next),t=s=i),t=t.next}while(t!==s);return Ht(t)}function Dh(s,e,t,r,i,n){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&zh(o,a)){let l=ua(o,a);o=Ht(o,o.next),l=Ht(l,l.next),Ir(o,e,t,r,i,n,0),Ir(l,e,t,r,i,n,0);return}a=a.next}o=o.next}while(o!==s)}function Ih(s,e,t,r){const i=[];for(let n=0,o=e.length;n<o;n++){const a=e[n]*r,l=n<o-1?e[n+1]*r:s.length,c=la(s,a,l,r,!1);c===c.next&&(c.steiner=!0),i.push($h(c))}i.sort(Rh);for(let n=0;n<i.length;n++)t=Uh(i[n],t);return t}function Rh(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const r=(s.next.y-s.y)/(s.next.x-s.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=r-i}return t}function Uh(s,e){const t=Bh(s,e);if(!t)return e;const r=ua(t,s);return Ht(r,r.next),Ht(t,t.next)}function Bh(s,e){let t=e;const r=s.x,i=s.y;let n=-1/0,o;if(hr(s,t))return t;do{if(hr(s,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=r&&f>n&&(n=f,o=t.x<t.next.x?t:t.next,f===r))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;t=o;do{if(r>=t.x&&t.x>=l&&r!==t.x&&ca(i<c?r:n,i,l,c,i<c?n:r,i,t.x,t.y)){const f=Math.abs(i-t.y)/(r-t.x);Ur(t,s)&&(f<h||f===h&&(t.x>o.x||t.x===o.x&&Lh(o,t)))&&(o=t,h=f)}t=t.next}while(t!==a);return o}function Lh(s,e){return ie(s.prev,s,e.prev)<0&&ie(e.next,s,s.next)<0}function Nh(s,e,t,r){let i=s;do i.z===0&&(i.z=Us(i.x,i.y,e,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,Fh(i)}function Fh(s){let e,t=1;do{let r=s,i;s=null;let n=null;for(e=0;r;){e++;let o=r,a=0;for(let c=0;c<t&&(a++,o=o.nextZ,!!o);c++);let l=t;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),n?n.nextZ=i:s=i,i.prevZ=n,n=i;r=o}n.nextZ=null,t*=2}while(e>1);return s}function Us(s,e,t,r,i){return s=(s-t)*i|0,e=(e-r)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function $h(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function ca(s,e,t,r,i,n,o,a){return(i-o)*(e-a)>=(s-o)*(n-a)&&(s-o)*(r-a)>=(t-o)*(e-a)&&(t-o)*(n-a)>=(i-o)*(r-a)}function Rr(s,e,t,r,i,n,o,a){return!(s===o&&e===a)&&ca(s,e,t,r,i,n,o,a)}function zh(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!Vh(s,e)&&(Ur(s,e)&&Ur(e,s)&&Gh(s,e)&&(ie(s.prev,s,e.prev)||ie(s,e.prev,e))||hr(s,e)&&ie(s.prev,s,s.next)>0&&ie(e.prev,e,e.next)>0)}function ie(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function hr(s,e){return s.x===e.x&&s.y===e.y}function ha(s,e,t,r){const i=Mi(ie(s,e,t)),n=Mi(ie(s,e,r)),o=Mi(ie(t,r,s)),a=Mi(ie(t,r,e));return!!(i!==n&&o!==a||i===0&&Ei(s,t,e)||n===0&&Ei(s,r,e)||o===0&&Ei(t,s,r)||a===0&&Ei(t,e,r))}function Ei(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function Mi(s){return s>0?1:s<0?-1:0}function Vh(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&ha(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Ur(s,e){return ie(s.prev,s,s.next)<0?ie(s,e,s.next)>=0&&ie(s,s.prev,e)>=0:ie(s,e,s.prev)<0||ie(s,s.next,e)<0}function Gh(s,e){let t=s,r=!1;const i=(s.x+e.x)/2,n=(s.y+e.y)/2;do t.y>n!=t.next.y>n&&t.next.y!==t.y&&i<(t.next.x-t.x)*(n-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==s);return r}function ua(s,e){const t=Bs(s.i,s.x,s.y),r=Bs(e.i,e.x,e.y),i=s.next,n=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,r.next=t,t.prev=r,n.next=r,r.prev=n,r}function fa(s,e,t,r){const i=Bs(s,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Br(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Bs(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function jh(s,e,t,r){let i=0;for(let n=e,o=t-r;n<t;n+=r)i+=(s[o]-s[n])*(s[n+1]+s[o+1]),o=n;return i}function Wh(s,e,t,r={}){const{radius:i=1}=r;s.moveTo(e,t),s.arc(e,t,i,0,Math.PI*2)}const qh={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Ls(s,e){const{fill:t="#000",stroke:r="none",strokeWidth:i=r==="none"?0:1,strokeLinecap:n="round",strokeLinejoin:o="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:c=0,shadowOffsetX:h=0,shadowOffsetY:f=0,shadowBlur:d=0,shadowColor:g="rgba(0, 0, 0, 0)"}=e;s.fillStyle=t,s.strokeStyle=r,s.lineWidth=i,s.lineCap=n,s.lineJoin=qh[o],s.miterLimit=a,s.setLineDash(l),s.lineDashOffset=c,s.shadowOffsetX=h,s.shadowOffsetY=f,s.shadowBlur=d,s.shadowColor=g}class k{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new k(1/0,1/0)}static get MIN(){return new k(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const r=-e/180*Math.PI,i=this.x-t.x,n=-(this.y-t.y),o=Math.sin(r),a=Math.cos(r);return this.set(t.x+(i*a-n*o),t.y-(i*o+n*a)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,r={x:0,y:0}){const i=e<0?r.x-this.x+r.x:this.x,n=t<0?r.y-this.y+r.y:this.y;return this.x=i*Math.abs(e),this.y=n*Math.abs(t),this}skew(e,t=0,r={x:0,y:0}){const i=this.x-r.x,n=this.y-r.y;return this.x=r.x+(i+Math.tan(e)*n),this.y=r.y+(n+Math.tan(t)*i),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new k(this.x,this.y)}}class Z{constructor(e=0,t=0,r=0,i=0){this.left=e,this.top=t,this.width=r,this.height=i}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new k((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...e){if(e.length===0)return new Z;if(e.length===1)return e[0].clone();const t=e[0],r=e.slice(1).reduce((i,n)=>(i.left=Math.min(i.left,n.left),i.top=Math.min(i.top,n.top),i.right=Math.max(i.right,n.right),i.bottom=Math.max(i.bottom,n.bottom),i),{left:t?.left??0,top:t?.top??0,right:t?.right??0,bottom:t?.bottom??0});return new Z(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new Z(this.left,this.top,this.width,this.height)}}class be{elements=[];constructor(e=1,t=0,r=0,i=0,n=1,o=0,a=0,l=0,c=1){this.set(e,t,r,i,n,o,a,l,c)}set(e,t,r,i,n,o,a,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=n,h[5]=l,h[6]=r,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,n=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],h=r[4],f=r[7],d=r[2],g=r[5],p=r[8],y=i[0],m=i[3],P=i[6],E=i[1],x=i[4],S=i[7],_=i[2],b=i[5],C=i[8];return n[0]=o*y+a*E+l*_,n[3]=o*m+a*x+l*b,n[6]=o*P+a*S+l*C,n[1]=c*y+h*E+f*_,n[4]=c*m+h*x+f*b,n[7]=c*P+h*S+f*C,n[2]=d*y+g*E+p*_,n[5]=d*m+g*x+p*b,n[8]=d*P+g*S+p*C,this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],f=h*o-a*c,d=a*l-h*n,g=c*n-o*l,p=t*f+r*d+i*g;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/p;return e[0]=f*y,e[1]=(i*c-h*r)*y,e[2]=(a*r-i*o)*y,e[3]=d*y,e[4]=(h*t-i*l)*y,e[5]=(i*n-a*t)*y,e[6]=g*y,e[7]=(r*l-c*t)*y,e[8]=(o*t-r*n)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(Ns.makeScale(e,t)),this}rotate(e){return this.premultiply(Ns.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ns.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,r,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const Ns=new be;function da(s,e,t,r){const i=s*t+e*r,n=Math.sqrt(s*s+e*e)*Math.sqrt(t*t+r*r);let o=Math.acos(Math.max(-1,Math.min(1,i/n)));return s*r-e*t<0&&(o=-o),o}function Xh(s,e,t,r,i,n,o,a){if(e===0||t===0){s.lineTo(a.x,a.y);return}r=r*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const l=(o.x-a.x)/2,c=(o.y-a.y)/2,h=Math.cos(r)*l+Math.sin(r)*c,f=-Math.sin(r)*l+Math.cos(r)*c;let d=e*e,g=t*t;const p=h*h,y=f*f,m=p/d+y/g;if(m>1){const G=Math.sqrt(m);e=G*e,t=G*t,d=e*e,g=t*t}const P=d*y+g*p,E=(d*g-P)/P;let x=Math.sqrt(Math.max(0,E));i===n&&(x=-x);const S=x*e*f/t,_=-x*t*h/e,b=Math.cos(r)*S-Math.sin(r)*_+(o.x+a.x)/2,C=Math.sin(r)*S+Math.cos(r)*_+(o.y+a.y)/2,T=da(1,0,(h-S)/e,(f-_)/t),B=da((h-S)/e,(f-_)/t,(-h-S)/e,(-f-_)/t)%(Math.PI*2);s.ellipse(b,C,e,t,r,T,T+B,n===0)}const ae={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function ut(s,e,t=0){let a=0,l=!0,c="",h="";const f=[];function d(m,P,E){const x=new SyntaxError(`Unexpected character "${m}" at index ${P}.`);throw x.partial=E,x}function g(){c!==""&&(h===""?f.push(Number(c)):f.push(Number(c)*10**Number(h))),c="",h=""}let p;const y=s.length;for(let m=0;m<y;m++){if(p=s[m],Array.isArray(e)&&e.includes(f.length%t)&&ae.FLAGS.test(p)){a=1,c=p,g();continue}if(a===0){if(ae.WHITESPACE.test(p))continue;if(ae.DIGIT.test(p)||ae.SIGN.test(p)){a=1,c=p;continue}if(ae.POINT.test(p)){a=2,c=p;continue}ae.COMMA.test(p)&&(l&&d(p,m,f),l=!0)}if(a===1){if(ae.DIGIT.test(p)){c+=p;continue}if(ae.POINT.test(p)){c+=p,a=2;continue}if(ae.EXP.test(p)){a=3;continue}ae.SIGN.test(p)&&c.length===1&&ae.SIGN.test(c[0])&&d(p,m,f)}if(a===2){if(ae.DIGIT.test(p)){c+=p;continue}if(ae.EXP.test(p)){a=3;continue}ae.POINT.test(p)&&c[c.length-1]==="."&&d(p,m,f)}if(a===3){if(ae.DIGIT.test(p)){h+=p;continue}if(ae.SIGN.test(p)){if(h===""){h+=p;continue}h.length===1&&ae.SIGN.test(h)&&d(p,m,f)}}ae.WHITESPACE.test(p)?(g(),a=0,l=!1):ae.COMMA.test(p)?(g(),a=0,l=!0):ae.SIGN.test(p)?(g(),a=1,c=p):ae.POINT.test(p)?(g(),a=2,c=p):d(p,m,f)}return g(),f}function ur(s,e){return s-(e-s)}function pa(s,e){const t=new k,r=new k;for(let i=0,n=s.length;i<n;i++){const o=s[i];if(o.type==="m"||o.type==="M")o.type==="m"?t.add(o):t.copy(o),e.moveTo(t.x,t.y),r.copy(t);else if(o.type==="h"||o.type==="H")o.type==="h"?t.x+=o.x:t.x=o.x,e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="v"||o.type==="V")o.type==="v"?t.y+=o.y:t.y=o.y,e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="l"||o.type==="L")o.type==="l"?t.add(o):t.copy(o),e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="c"||o.type==="C")o.type==="c"?(e.bezierCurveTo(t.x+o.x1,t.y+o.y1,t.x+o.x2,t.y+o.y2,t.x+o.x,t.y+o.y),r.x=t.x+o.x2,r.y=t.y+o.y2,t.add(o)):(e.bezierCurveTo(o.x1,o.y1,o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,t.copy(o));else if(o.type==="s"||o.type==="S")o.type==="s"?(e.bezierCurveTo(ur(t.x,r.x),ur(t.y,r.y),t.x+o.x2,t.y+o.y2,t.x+o.x,t.y+o.y),r.x=t.x+o.x2,r.y=t.y+o.y2,t.add(o)):(e.bezierCurveTo(ur(t.x,r.x),ur(t.y,r.y),o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,t.copy(o));else if(o.type==="q"||o.type==="Q")o.type==="q"?(e.quadraticCurveTo(t.x+o.x1,t.y+o.y1,t.x+o.x,t.y+o.y),r.x=t.x+o.x1,r.y=t.y+o.y1,t.add(o)):(e.quadraticCurveTo(o.x1,o.y1,o.x,o.y),r.x=o.x1,r.y=o.y1,t.copy(o));else if(o.type==="t"||o.type==="T"){const a=ur(t.x,r.x),l=ur(t.y,r.y);r.x=a,r.y=l,o.type==="t"?(e.quadraticCurveTo(a,l,t.x+o.x,t.y+o.y),t.add(o)):(e.quadraticCurveTo(a,l,o.x,o.y),t.copy(o))}else if(o.type==="a"||o.type==="A"){const a=t.clone();if(o.type==="a"){if(o.x===0&&o.y===0)continue;t.add(o)}else{if(t.equals(o))continue;t.copy(o)}r.copy(t),Xh(e,o.rx,o.ry,o.angle,o.largeArcFlag,o.sweepFlag,a,t)}else o.type==="z"||o.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",o)}}function Hh(s){let e,t;const r=[];for(let i=0,n=s.length;i<n;i++){const o=s[i];switch(o.type){case"m":case"M":if(o.x.toFixed(4)===t?.x.toFixed(4)&&o.y.toFixed(4)===t?.y.toFixed(4))continue;r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y},e={x:o.x,y:o.y};break;case"h":case"H":r.push(`${o.type} ${o.x}`),t={x:o.x,y:t?.y??0};break;case"v":case"V":r.push(`${o.type} ${o.y}`),t={x:t?.x??0,y:o.y};break;case"l":case"L":r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"c":case"C":r.push(`${o.type} ${o.x1} ${o.y1} ${o.x2} ${o.y2} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"s":case"S":r.push(`${o.type} ${o.x2} ${o.y2} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"q":case"Q":r.push(`${o.type} ${o.x1} ${o.y1} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"t":case"T":r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"a":case"A":r.push(`${o.type} ${o.rx} ${o.ry} ${o.angle} ${o.largeArcFlag} ${o.sweepFlag} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"z":case"Z":r.push(o.type),e&&(t={x:e.x,y:e.y});break}}return r.join(" ")}const Yh=/[a-df-z][^a-df-z]*/gi;function ga(s){const e=[],t=s.match(Yh);if(!t)return e;for(let r=0,i=t.length;r<i;r++){const n=t[r],o=n.charAt(0),a=n.slice(1).trim();let l;switch(o){case"m":case"M":l=ut(a);for(let c=0,h=l.length;c<h;c+=2)c===0?e.push({type:o,x:l[c],y:l[c+1]}):e.push({type:o==="m"?"l":"L",x:l[c],y:l[c+1]});break;case"h":case"H":l=ut(a);for(let c=0,h=l.length;c<h;c++)e.push({type:o,x:l[c]});break;case"v":case"V":l=ut(a);for(let c=0,h=l.length;c<h;c++)e.push({type:o,y:l[c]});break;case"l":case"L":l=ut(a);for(let c=0,h=l.length;c<h;c+=2)e.push({type:o,x:l[c],y:l[c+1]});break;case"c":case"C":l=ut(a);for(let c=0,h=l.length;c<h;c+=6)e.push({type:o,x1:l[c],y1:l[c+1],x2:l[c+2],y2:l[c+3],x:l[c+4],y:l[c+5]});break;case"s":case"S":l=ut(a);for(let c=0,h=l.length;c<h;c+=4)e.push({type:o,x2:l[c],y2:l[c+1],x:l[c+2],y:l[c+3]});break;case"q":case"Q":l=ut(a);for(let c=0,h=l.length;c<h;c+=4)e.push({type:o,x1:l[c],y1:l[c+1],x:l[c+2],y:l[c+3]});break;case"t":case"T":l=ut(a);for(let c=0,h=l.length;c<h;c+=2)e.push({type:o,x:l[c],y:l[c+1]});break;case"a":case"A":l=ut(a,[3,4],7);for(let c=0,h=l.length;c<h;c+=7)e.push({type:o,rx:l[c],ry:l[c+1],angle:l[c+2],largeArcFlag:l[c+3],sweepFlag:l[c+4],x:l[c+5],y:l[c+6]});break;case"z":case"Z":e.push({type:o});break;default:console.warn(n)}}return e}const ma="data:image/svg+xml;",ya=`${ma}base64,`,_a=`${ma}charset=utf8,`;function Fs(s){if(typeof s=="string"){let e;s.startsWith(ya)?(s=s.substring(ya.length,s.length),e=atob(s)):s.startsWith(_a)?(s=s.substring(_a.length,s.length),e=decodeURIComponent(s)):e=s;const t=new DOMParser().parseFromString(e,"text/xml"),r=t.querySelector("parsererror");if(r)throw new Error(`${r.textContent??"parser error"}
75
- ${e}`);return t.documentElement}else return s}const Kh="px",Zh=90,va=["mm","cm","in","pt","pc","px"],ba={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function ee(s){let e="px";if(typeof s=="string")for(let r=0,i=va.length;r<i;r++){const n=va[r];if(s.endsWith(n)){e=n,s=s.substring(0,s.length-n.length);break}}let t;return t=ba[e][Kh],t<0&&(t=ba[e].in*Zh),t*Number.parseFloat(s)}const Jh=new be,Ai=new be,wa=new be,xa=new be;function Qh(s,e,t){if(!(s.hasAttribute("transform")||s.nodeName==="use"&&(s.hasAttribute("x")||s.hasAttribute("y"))))return null;const r=eu(s);return t.length>0&&r.premultiply(t[t.length-1]),e.copy(r),t.push(r),r}function eu(s){const e=new be,t=Jh;if(s.nodeName==="use"&&(s.hasAttribute("x")||s.hasAttribute("y"))&&e.translate(ee(s.getAttribute("x")),ee(s.getAttribute("y"))),s.hasAttribute("transform")){const r=s.getAttribute("transform").split(")");for(let i=r.length-1;i>=0;i--){const n=r[i].trim();if(n==="")continue;const o=n.indexOf("("),a=n.length;if(o>0&&o<a){const l=n.slice(0,o),c=ut(n.slice(o+1));switch(t.identity(),l){case"translate":if(c.length>=1){const h=c[0];let f=0;c.length>=2&&(f=c[1]),t.translate(h,f)}break;case"rotate":if(c.length>=1){let h=0,f=0,d=0;h=c[0]*Math.PI/180,c.length>=3&&(f=c[1],d=c[2]),Ai.makeTranslation(-f,-d),wa.makeRotation(h),xa.multiplyMatrices(wa,Ai),Ai.makeTranslation(f,d),t.multiplyMatrices(Ai,xa)}break;case"scale":c.length>=1&&t.scale(c[0],c[1]??c[0]);break;case"skewX":c.length===1&&t.set(1,Math.tan(c[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":c.length===1&&t.set(1,0,0,Math.tan(c[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":c.length===6&&t.set(c[0],c[2],c[4],c[1],c[3],c[5],0,0,1);break}}e.premultiply(t)}}return e}function tu(s){return new ge().arc(ee(s.getAttribute("cx")||0),ee(s.getAttribute("cy")||0),ee(s.getAttribute("r")||0),0,Math.PI*2)}function ru(s,e){if(!(!s.sheet||!s.sheet.cssRules||!s.sheet.cssRules.length))for(let t=0;t<s.sheet.cssRules.length;t++){const r=s.sheet.cssRules[t];if(r.type!==1)continue;const i=r.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim()),n={};for(let o=r.style.length,a=0;a<o;a++){const l=r.style.item(a);n[l]=r.style.getPropertyValue(l)}for(let o=0;o<i.length;o++)e[i[o]]=Object.assign(e[i[o]]||{},{...n})}}function iu(s){return new ge().ellipse(ee(s.getAttribute("cx")||0),ee(s.getAttribute("cy")||0),ee(s.getAttribute("rx")||0),ee(s.getAttribute("ry")||0),0,0,Math.PI*2)}function su(s){return new ge().moveTo(ee(s.getAttribute("x1")||0),ee(s.getAttribute("y1")||0)).lineTo(ee(s.getAttribute("x2")||0),ee(s.getAttribute("y2")||0))}function nu(s){const e=new ge,t=s.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const ou=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function au(s){const e=new ge;let t=0;return s.getAttribute("points")?.replace(ou,(r,i,n)=>{const o=ee(i),a=ee(n);return t===0?e.moveTo(o,a):e.lineTo(o,a),t++,r}),e.currentCurve.autoClose=!0,e}const lu=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function cu(s){const e=new ge;let t=0;return s.getAttribute("points")?.replace(lu,(r,i,n)=>{const o=ee(i),a=ee(n);return t===0?e.moveTo(o,a):e.lineTo(o,a),t++,r}),e.currentCurve.autoClose=!1,e}function hu(s){const e=ee(s.getAttribute("x")||0),t=ee(s.getAttribute("y")||0),r=ee(s.getAttribute("rx")||s.getAttribute("ry")||0),i=ee(s.getAttribute("ry")||s.getAttribute("rx")||0),n=ee(s.getAttribute("width")),o=ee(s.getAttribute("height")),a=1-.551915024494,l=new ge;return l.moveTo(e+r,t),l.lineTo(e+n-r,t),(r!==0||i!==0)&&l.bezierCurveTo(e+n-r*a,t,e+n,t+i*a,e+n,t+i),l.lineTo(e+n,t+o-i),(r!==0||i!==0)&&l.bezierCurveTo(e+n,t+o-i*a,e+n-r*a,t+o,e+n-r,t+o),l.lineTo(e+r,t+o),(r!==0||i!==0)&&l.bezierCurveTo(e+r*a,t+o,e,t+o-i*a,e,t+o-i),l.lineTo(e,t+i),(r!==0||i!==0)&&l.bezierCurveTo(e,t+i*a,e+r*a,t,e+r,t),l}function ft(s,e,t){e=Object.assign({},e);let r={};if(s.hasAttribute("class")){const c=s.getAttribute("class").split(/\s/).filter(Boolean).map(h=>h.trim());for(let h=0;h<c.length;h++)r=Object.assign(r,t[`.${c[h]}`])}s.hasAttribute("id")&&(r=Object.assign(r,t[`#${s.getAttribute("id")}`]));for(let c=s.style.length,h=0;h<c;h++){const f=s.style.item(h),d=s.style.getPropertyValue(f);e[f]=d,r[f]=d}function i(c,h,f=n){s.hasAttribute(c)&&(e[h]=f(s.getAttribute(c))),r[c]&&(e[h]=f(r[c]))}function n(c){return c.startsWith("url")&&console.warn("url access in attributes is not implemented."),c}function o(c){return Math.max(0,Math.min(1,ee(c)))}function a(c){return Math.max(0,ee(c))}function l(c){return c.split(" ").filter(h=>h!=="").map(h=>ee(h))}return i("fill","fill"),i("fill-opacity","fillOpacity",o),i("fill-rule","fillRule"),i("opacity","opacity",o),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",o),i("stroke-width","strokeWidth",a),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",a),i("stroke-dasharray","strokeDasharray",l),i("stroke-dashoffset","strokeDashoffset",ee),i("visibility","visibility"),e}function $s(s,e,t=[],r={}){if(s.nodeType!==1)return t;let i=!1,n=null,o={...e};switch(s.nodeName){case"svg":o=ft(s,o,r);break;case"style":ru(s,r);break;case"g":o=ft(s,o,r);break;case"path":o=ft(s,o,r),s.hasAttribute("d")&&(n=nu(s));break;case"rect":o=ft(s,o,r),n=hu(s);break;case"polygon":o=ft(s,o,r),n=au(s);break;case"polyline":o=ft(s,o,r),n=cu(s);break;case"circle":o=ft(s,o,r),n=tu(s);break;case"ellipse":o=ft(s,o,r),n=iu(s);break;case"line":o=ft(s,o,r),n=su(s);break;case"defs":i=!0;break;case"use":{o=ft(s,o,r);const d=(s.getAttributeNS("http://www.w3.org/1999/xlink","href")||s.getAttribute("href")||"").substring(1),g=s.viewportElement?.getElementById(d);g?$s(g,o,t,r):console.warn(`'use node' references non-existent node id: ${d}`);break}default:console.warn(s);break}if(o.display==="none")return t;const a=new be,l=[],c=Qh(s,a,l);n&&(n.applyTransform(a),t.push(n),n.style={...o});const h=s.childNodes;for(let f=0,d=h.length;f<d;f++){const g=h[f];i&&g.nodeName!=="style"&&g.nodeName!=="defs"||$s(g,o,t,r)}return c&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),t}function zs(s){const e=Fs(s);return new Tt($s(e,{}),e.getAttribute("viewBox")?.trim().split(" ").map(t=>Number(t)))}function Pa(s,e,t,r,i){const n=(r-e)*.5,o=(i-t)*.5,a=s*s,l=s*a;return(2*t-2*r+n+o)*l+(-3*t+3*r-2*n-o)*a+n*s+t}function uu(s,e){const t=1-s;return t*t*t*e}function fu(s,e){const t=1-s;return 3*t*t*s*e}function du(s,e){return 3*(1-s)*s*s*e}function pu(s,e){return s*s*s*e}function Sa(s,e,t,r,i){return uu(s,e)+fu(s,t)+du(s,r)+pu(s,i)}function Ca(s,e={}){let{vertices:t=[],indices:r=[],holes:i=[],verticesStride:n=2,verticesOffset:o=t.length/n,indicesOffset:a=r.length}=e;const l=Mh(s,i,2);if(l.length){for(let h=0;h<l.length;h+=3)r[a++]=l[h]+o,r[a++]=l[h+1]+o,r[a++]=l[h+2]+o;let c=o*n;for(let h=0;h<s.length;h+=2)t[c]=s[h],t[c+1]=s[h+1],c+=n}return{vertices:t,indices:r}}const gu=8,Oi=11920929e-14,mu=1;function yu(s,e,t,r,i,n,o,a,l=.5,c=[]){const f=Math.min(.99,Math.max(0,l));let d=(mu-f)/1;return d*=d,Vs(s,e,t,r,i,n,o,a,c,d,0),c.push(o,a),c}function Vs(s,e,t,r,i,n,o,a,l,c,h){if(h>gu)return;const f=(s+t)/2,d=(e+r)/2,g=(t+i)/2,p=(r+n)/2,y=(i+o)/2,m=(n+a)/2,P=(f+g)/2,E=(d+p)/2,x=(g+y)/2,S=(p+m)/2,_=(P+x)/2,b=(E+S)/2;if(h>0){let C=o-s,T=a-e;const B=Math.abs((t-o)*T-(r-a)*C),G=Math.abs((i-o)*T-(n-a)*C);if(B>Oi&&G>Oi){if((B+G)*(B+G)<=c*(C*C+T*T)){l.push(_,b);return}}else if(B>Oi){if(B*B<=c*(C*C+T*T)){l.push(_,b);return}}else if(G>Oi){if(G*G<=c*(C*C+T*T)){l.push(_,b);return}}else if(C=_-(s+o)/2,T=b-(e+a)/2,C*C+T*T<=c){l.push(_,b);return}}Vs(s,e,f,d,P,E,_,b,l,c,h+1),Vs(_,b,x,S,y,m,o,a,l,c,h+1)}const _u=8,vu=11920929e-14,bu=1;function wu(s,e,t,r,i,n,o=.5,a=[]){const c=Math.min(.99,Math.max(0,o));let h=(bu-c)/1;return h*=h,Gs(a,s,e,t,r,i,n,h,0),a.push(i,n),a}function Gs(s,e,t,r,i,n,o,a,l){if(l>_u)return;const c=(e+r)/2,h=(t+i)/2,f=(r+n)/2,d=(i+o)/2,g=(c+f)/2,p=(h+d)/2;let y=n-e,m=o-t;const P=Math.abs((r-n)*m-(i-o)*y);if(P>vu){if(P*P<=a*(y*y+m*m)){s.push(g,p);return}}else if(y=g-(e+n)/2,m=p-(t+o)/2,y*y+m*m<=a){s.push(g,p);return}Gs(s,e,t,c,h,g,p,a,l+1),Gs(s,g,p,f,d,n,o,a,l+1)}function xu(s){return s.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Pu(s,e,t,r){const i=e.clone().sub(s),n=r.clone().sub(t),o=t.clone().sub(s),a=i.cross(n);if(a===0)return new k((s.x+t.x)/2,(s.y+t.y)/2);const l=o.cross(n)/a;return Math.abs(l)>1?new k((s.x+t.x)/2,(s.y+t.y)/2):new k(s.x+l*i.x,s.y+l*i.y)}function Su(s){let e=0;const t=s.length/2;for(let r=0;r<t;r++){const i=s[2*r],n=s[2*r+1],o=(r+1)%t,a=s[2*o],l=s[2*o+1];e+=(a-i)*(l+n)}return e}function Ta(s,e,t,r,i,n){return(t-s)*(n-e)-(i-s)*(r-e)}function Cu(s,e,t){const r=t.length;let i=0;for(let n=0,o=r-2;n<r;o=n,n+=2){const a=t[n],l=t[n+1],c=t[o],h=t[o+1];l<=e?h>e&&Ta(c,h,a,l,s,e)>0&&i++:h<=e&&Ta(c,h,a,l,s,e)<0&&i--}return i}function Tu(s){const e=s.length,t=s.map((r,i)=>({index:i,parentIndex:null,wn:0}));for(let r=0;r<e;r++){let i=null;if(Su(s[r])<0)continue;const n=[s[r][0],s[r][1]];for(let o=0;o<e;o++){if(r===o)continue;let a=0;for(let c=0;c<n.length&&(a=a||Cu(n[c],n[c+1],s[o]),!a);c+=2);const l=Math.abs(a);l!==0&&(!i||l>Math.abs(i.wn))&&(i={idx:o,wn:a})}i&&(t[r].parentIndex=i.idx,t[r].wn=i.wn)}return t}function Eu(s,e){const t=1-s;return t*t*e}function Mu(s,e){return 2*(1-s)*s*e}function Au(s,e){return s*s*e}function Ea(s,e,t,r){return Eu(s,e)+Mu(s,t)+Au(s,r)}const Ou=1e-4,Ma=1e-4;function ku(s,e={}){const{vertices:t=[],indices:r=[],lineStyle:i={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:n=!1,closed:o=!0}=e,a=Ou;if(s.length===0)return{vertices:t,indices:r};const l=i;let c=l.alignment;if(i.alignment!==.5){let O=Du(s);n&&(O*=-1),c=(c-.5)*O+.5}const h={x:s[0],y:s[1]},f={x:s[s.length-2],y:s[s.length-1]},d=o,g=Math.abs(h.x-f.x)<a&&Math.abs(h.y-f.y)<a;if(d){s=s.slice(),g&&(s.pop(),s.pop(),f.x=s[s.length-2],f.y=s[s.length-1]);const O=(h.x+f.x)*.5,j=(f.y+h.y)*.5;s.unshift(O,j),s.push(O,j)}const p=t,y=s.length/2;let m=s.length;const P=p.length/2,E=l.width/2,x=E*E,S=l.miterLimit*l.miterLimit;let _=s[0],b=s[1],C=s[2],T=s[3],B=0,G=0,R=-(b-T),U=_-C,V=0,L=0,D=Math.sqrt(R*R+U*U);R/=D,U/=D,R*=E,U*=E;const H=c,I=(1-H)*2,N=H*2;d||(l.cap==="round"?m+=Yt(_-R*(I-N)*.5,b-U*(I-N)*.5,_-R*I,b-U*I,_+R*N,b+U*N,p,!0)+2:l.cap==="square"&&(m+=Aa(_,b,R,U,I,N,!0,p))),p.push(_-R*I,b-U*I),p.push(_+R*N,b+U*N);for(let O=1;O<y-1;++O){_=s[(O-1)*2],b=s[(O-1)*2+1],C=s[O*2],T=s[O*2+1],B=s[(O+1)*2],G=s[(O+1)*2+1],R=-(b-T),U=_-C,D=Math.sqrt(R*R+U*U),R/=D,U/=D,R*=E,U*=E,V=-(T-G),L=C-B,D=Math.sqrt(V*V+L*L),V/=D,L/=D,V*=E,L*=E;const j=C-_,A=b-T,M=C-B,F=G-T,z=j*M+A*F,Y=A*M-F*j,J=Y<0;if(Math.abs(Y)<.001*Math.abs(z)){p.push(C-R*I,T-U*I),p.push(C+R*N,T+U*N),z>=0&&(l.join==="round"?m+=Yt(C,T,C-R*I,T-U*I,C-V*I,T-L*I,p,!1)+4:m+=2,p.push(C-V*N,T-L*N),p.push(C+V*I,T+L*I));continue}const oe=(-R+_)*(-U+T)-(-R+C)*(-U+b),wt=(-V+B)*(-L+T)-(-V+C)*(-L+G),Ze=(j*wt-M*oe)/Y,Be=(F*oe-A*wt)/Y,$e=(Ze-C)*(Ze-C)+(Be-T)*(Be-T),Se=C+(Ze-C)*I,ze=T+(Be-T)*I,ot=C-(Ze-C)*N,at=T-(Be-T)*N,Je=Math.min(j*j+A*A,M*M+F*F),cc=J?I:N,Um=Je+cc*cc*x;$e<=Um?l.join==="bevel"||$e/x>S?(J?(p.push(Se,ze),p.push(C+R*N,T+U*N),p.push(Se,ze),p.push(C+V*N,T+L*N)):(p.push(C-R*I,T-U*I),p.push(ot,at),p.push(C-V*I,T-L*I),p.push(ot,at)),m+=2):l.join==="round"?J?(p.push(Se,ze),p.push(C+R*N,T+U*N),m+=Yt(C,T,C+R*N,T+U*N,C+V*N,T+L*N,p,!0)+4,p.push(Se,ze),p.push(C+V*N,T+L*N)):(p.push(C-R*I,T-U*I),p.push(ot,at),m+=Yt(C,T,C-R*I,T-U*I,C-V*I,T-L*I,p,!1)+4,p.push(C-V*I,T-L*I),p.push(ot,at)):(p.push(Se,ze),p.push(ot,at)):(p.push(C-R*I,T-U*I),p.push(C+R*N,T+U*N),l.join==="round"?J?m+=Yt(C,T,C+R*N,T+U*N,C+V*N,T+L*N,p,!0)+2:m+=Yt(C,T,C-R*I,T-U*I,C-V*I,T-L*I,p,!1)+2:l.join==="miter"&&$e/x<=S&&(J?(p.push(ot,at),p.push(ot,at)):(p.push(Se,ze),p.push(Se,ze)),m+=2),p.push(C-V*I,T-L*I),p.push(C+V*N,T+L*N),m+=2)}_=s[(y-2)*2],b=s[(y-2)*2+1],C=s[(y-1)*2],T=s[(y-1)*2+1],R=-(b-T),U=_-C,D=Math.sqrt(R*R+U*U),R/=D,U/=D,R*=E,U*=E,p.push(C-R*I,T-U*I),p.push(C+R*N,T+U*N),d||(l.cap==="round"?m+=Yt(C-R*(I-N)*.5,T-U*(I-N)*.5,C-R*I,T-U*I,C+R*N,T+U*N,p,!1)+2:l.cap==="square"&&(m+=Aa(C,T,R,U,I,N,!1,p)));const $=Ma*Ma;for(let O=P;O<m+P-2;++O)_=p[O*2],b=p[O*2+1],C=p[(O+1)*2],T=p[(O+1)*2+1],B=p[(O+2)*2],G=p[(O+2)*2+1],!(Math.abs(_*(T-G)+C*(G-b)+B*(b-T))<$)&&r.push(O,O+1,O+2);return{vertices:t,indices:r}}function Du(s){const e=s.length;if(e<6)return 1;let t=0;for(let r=0,i=s[e-2],n=s[e-1];r<e;r+=2){const o=s[r],a=s[r+1];t+=(o-i)*(a+n),i=o,n=a}return t<0?-1:1}function Aa(s,e,t,r,i,n,o,a){const l=s-t*i,c=e-r*i,h=s+t*n,f=e+r*n;let d,g;o?(d=r,g=-t):(d=-r,g=t);const p=l+d,y=c+g,m=h+d,P=f+g;return a.push(p,y),a.push(m,P),2}function Yt(s,e,t,r,i,n,o,a){const l=t-s,c=r-e;let h=Math.atan2(l,c),f=Math.atan2(i-s,n-e);a&&h<f?h+=Math.PI*2:!a&&h>f&&(f+=Math.PI*2);let d=h;const g=f-h,p=Math.abs(g),y=Math.sqrt(l*l+c*c),m=(15*p*Math.sqrt(y)/Math.PI>>0)+1,P=g/m;if(d+=P,a){o.push(s,e),o.push(t,r);for(let E=1,x=d;E<m;E++,x+=P)o.push(s,e),o.push(s+Math.sin(x)*y,e+Math.cos(x)*y);o.push(s,e),o.push(i,n)}else{o.push(t,r),o.push(s,e);for(let E=1,x=d;E<m;E++,x+=P)o.push(s+Math.sin(x)*y,e+Math.cos(x)*y),o.push(s,e);o.push(i,n),o.push(s,e)}return m*2}class fr{arcLengthDivision=200;_arcLengths;getPointAt(e,t=new k){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){return!1}getControlPointRefs(){return[]}applyTransform(e){const t=typeof e=="function";return this.getControlPointRefs().forEach(r=>{t?e(r):r.applyMatrix3(e)}),this}getUnevenVertices(e=5,t=[]){const r=new k;for(let i=0,n=Math.max(1,e)-1;i<=n;i++)this.getPoint(i/n,r),t.push(r.x,r.y);return t}getSpacedVertices(e=5,t=[]){const r=new k;for(let i=0,n=Math.max(1,e)-1;i<=n;i++)this.getPointAt(i/n,r),t.push(r.x,r.y);return t}getAdaptiveVertices(e=[]){return this.getUnevenVertices(5,e)}_verticesToPoints(e,t=[]){for(let r=0,i=e.length;r<i;r+=2){const n=e[r],o=e[r+1];t.push(new k(n,o))}return t}getSpacedPoints(e,t=[]){const r=this.getSpacedVertices(e);return this._verticesToPoints(r,t),t}getUnevenPoints(e,t=[]){const r=this.getUnevenVertices(e);return this._verticesToPoints(r,t),t}getAdaptivePoints(e=[]){const t=this.getAdaptiveVertices();return this._verticesToPoints(t,e),e}getPoints(e,t=[]){let r;return e?r=this.getUnevenVertices(e):r=this.getAdaptiveVertices(),this._verticesToPoints(r,t),t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const e=this.arcLengthDivision,t=[0];for(let r=0,i=this.getPoint(0),n=1;n<=e;n++){const o=this.getPoint(n/e);r+=o.distanceTo(i),t.push(r),i=o}this._arcLengths=t}getUToTMapping(e,t){const r=this.getLengths(),i=r.length,n=t??e*r[i-1];if(i<2)return n/r[0];let o=0,a=0,l=i-1,c;for(;a<=l;)if(o=Math.floor(a+(l-a)/2),c=r[o]-n,c<0)a=o+1;else if(c>0)l=o-1;else{l=o;break}if(o=l,r[o]===n)return o/(i-1);const h=r[o],d=r[o+1]-h,g=(n-h)/d;return(o+g)/(i-1)}getTangent(e,t=new k){const i=Math.max(0,e-1e-4),n=Math.min(1,e+1e-4);return t.copy(this.getPoint(n).sub(this.getPoint(i)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new k){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let r=0,i=1,n=(r+i)/2;for(;i-r>t;){n=(r+i)/2;const o=this.getPoint(n);if(o.distanceTo(e)<t)return n;o.x<e.x?r=n:i=n}return n}getMinMax(e=k.MAX,t=k.MIN){const r=this.getPoints();for(let i=0,n=r.length;i<n;i++){const o=r[i];e.min(o),t.max(o)}return{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new Z(e.x,e.y,t.x-e.x,t.y-e.y)}getFillVertices(e){return this.getAdaptiveVertices()}fillTriangulate(e){return Ca(this.getFillVertices(e),e)}strokeTriangulate(e){return ku(this.getAdaptiveVertices(),e)}toCommands(){const e=[],t=this.getPoints();for(let r=0,i=t.length;r<i;r++){const n=t[r];r===0?e.push({type:"M",x:n.x,y:n.y}):e.push({type:"L",x:n.x,y:n.y})}return e}toData(){return Hh(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const Iu=new be,Oa=new be,ka=new be,ki=new k;class js extends fr{constructor(e=new k,t=new k,r=new k,i=0,n=0,o=Math.PI*2,a=!1){super(),this._center=e,this._radius=t,this._diff=r,this.rotate=i,this.startAngle=n,this.endAngle=o,this.clockwise=a}get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}isClockwise(){return this.clockwise}_getDeltaAngle(){const e=Math.PI*2;let t=this.endAngle-this.startAngle;const r=Math.abs(t)<Number.EPSILON;return t=(t%e+e)%e,r?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new k){const r=this._getDeltaAngle(),i=this.startAngle+e*r;let n=this.cx+this.rx*Math.cos(i),o=this.cy+this.ry*Math.sin(i);if(this.rotate!==0){const a=Math.cos(this.rotate),l=Math.sin(this.rotate),c=n-this.cx,h=o-this.cy;n=c*a-h*l+this.cx,o=c*l+h*a+this.cy}return t.set(n,o)}toCommands(){const{cx:e,cy:t,rx:r,ry:i,startAngle:n,endAngle:o,clockwise:a,rotate:l}=this,c=e+r*Math.cos(n)*Math.cos(l)-i*Math.sin(n)*Math.sin(l),h=t+r*Math.cos(n)*Math.sin(l)+i*Math.sin(n)*Math.cos(l),f=Math.abs(n-o),d=f>Math.PI?1:0,g=a?1:0,p=l*180/Math.PI;if(f>=2*Math.PI){const y=n+Math.PI,m=e+r*Math.cos(y)*Math.cos(l)-i*Math.sin(y)*Math.sin(l),P=t+r*Math.cos(y)*Math.sin(l)+i*Math.sin(y)*Math.cos(l);return[{type:"M",x:c,y:h},{type:"A",rx:r,ry:i,angle:p,largeArcFlag:0,sweepFlag:g,x:m,y:P},{type:"A",rx:r,ry:i,angle:p,largeArcFlag:0,sweepFlag:g,x:c,y:h}]}else{const y=e+r*Math.cos(o)*Math.cos(l)-i*Math.sin(o)*Math.sin(l),m=t+r*Math.cos(o)*Math.sin(l)+i*Math.sin(o)*Math.cos(l);return[{type:"M",x:c,y:h},{type:"A",rx:r,ry:i,angle:p,largeArcFlag:d,sweepFlag:g,x:y,y:m}]}}drawTo(e){const{cx:t,cy:r,rx:i,ry:n,rotate:o,startAngle:a,endAngle:l,clockwise:c}=this;return e.ellipse(t,r,i,n,o,a,l,!c),this}applyTransform(e){return ki.set(this.cx,this.cy),ki.applyMatrix3(e),this.cx=ki.x,this.cy=ki.y,Bu(e)?Ru(this,e):Uu(this,e),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(e=[]){const{cx:t,cy:r,rx:i,ry:n,dx:o,dy:a,startAngle:l,endAngle:c,clockwise:h,rotate:f}=this,d=!h;let g=Math.abs(l-c);(!d&&l>c||d&&c>l)&&(g=2*Math.PI-g);const p=Math.max(12,Math.floor(12*i**(1/3)*(g/Math.PI)));let y=g/p,m=l;y*=d?-1:1;const P=Math.cos(d?f:-f),E=Math.sin(d?f:-f);for(let x=0;x<p+1;x++){const S=o+Math.cos(m)*i,_=a+Math.sin(m)*n,b=S*P-_*E,C=S*E+_*P;e.push(t+b,r+C),m+=y}return e}_getAdaptiveVerticesByCircle(e=[]){const{cx:t,cy:r,rx:i,ry:n,dx:o,dy:a,rotate:l,clockwise:c}=this;if(!(i>=0&&n>=0&&o>=0&&a>=0))return e;const h=Math.ceil(2.3*Math.sqrt(i+n)),f=h*8+(o?4:0)+(a?4:0),d=[];if(f===0)return e;{const y=d.length;if(h===0)d[y]=d[y+6]=t+o,d[y+1]=d[y+3]=r+a,d[y+2]=d[y+4]=t-o,d[y+5]=d[y+7]=r-a;else{let m=y,P=y+h*4+(o?2:0)+2,E=P,x=f,S=o+i,_=a,b=t+S,C=t-S,T=r+_;if(d[m++]=b,d[m++]=T,d[--P]=T,d[--P]=C,a){const G=r-_;d[E++]=C,d[E++]=G,d[--x]=G,d[--x]=b}for(let G=1;G<h;G++){const R=Math.PI/2*(G/h),U=o+Math.cos(R)*i,V=a+Math.sin(R)*n,L=t+U,D=t-U,H=r+V,I=r-V;d[m++]=L,d[m++]=H,d[--P]=H,d[--P]=D,d[E++]=D,d[E++]=I,d[--x]=I,d[--x]=L}S=o,_=a+n,b=t+S,C=t-S,T=r+_;const B=r-_;d[m++]=b,d[m++]=T,d[--x]=B,d[--x]=b,o&&(d[m++]=C,d[m++]=T,d[--x]=B,d[--x]=C)}}const g=Math.cos(c?-l:l),p=Math.sin(c?-l:l);for(let y=0;y<d.length;y+=2){const m=d[y],P=d[y+1],E=m-t,x=P-r,S=E*g-x*p,_=E*p+x*g;e.push(t+S,r+_)}return e}getAdaptiveVertices(e=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(e):this._getAdaptiveVerticesByArc(e)}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}}function Ru(s,e){const t=s.rx,r=s.ry,i=Math.cos(s.rotate),n=Math.sin(s.rotate),o=new k(t*i,t*n),a=new k(-r*n,r*i),l=o.applyMatrix3(e),c=a.applyMatrix3(e),h=Iu.set(l.x,c.x,0,l.y,c.y,0,0,0,1),f=Oa.copy(h).invert(),p=ka.copy(f).transpose().multiply(f).elements,y=Lu(p[0],p[1],p[4]),m=Math.sqrt(y.rt1),P=Math.sqrt(y.rt2);if(s.rx=1/m,s.ry=1/P,s.rotate=Math.atan2(y.sn,y.cs),!((s.endAngle-s.startAngle)%(2*Math.PI)<Number.EPSILON)){const x=Oa.set(m,0,0,0,P,0,0,0,1),S=ka.set(y.cs,y.sn,0,-y.sn,y.cs,0,0,0,1),_=x.multiply(S).multiply(h),b=C=>{const{x:T,y:B}=new k(Math.cos(C),Math.sin(C)).applyMatrix3(_);return Math.atan2(B,T)};s.startAngle=b(s.startAngle),s.endAngle=b(s.endAngle),Da(e)&&(s.clockwise=!s.clockwise)}}function Uu(s,e){const t=Ia(e),r=Ra(e);s.rx*=t,s.ry*=r;const i=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);s.rotate+=i,Da(e)&&(s.startAngle*=-1,s.endAngle*=-1,s.clockwise=!s.clockwise)}function Da(s){const e=s.elements;return e[0]*e[4]-e[1]*e[3]<0}function Bu(s){const e=s.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const r=Ia(s),i=Ra(s);return Math.abs(t/(r*i))>Number.EPSILON}function Ia(s){const e=s.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Ra(s){const e=s.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function Lu(s,e,t){let r,i,n,o,a;const l=s+t,c=s-t,h=Math.sqrt(c*c+4*e*e);return l>0?(r=.5*(l+h),a=1/r,i=s*a*t-e*a*e):l<0?i=.5*(l-h):(r=.5*h,i=-.5*h),c>0?n=c+h:n=c-h,Math.abs(n)>2*Math.abs(e)?(a=-2*e/n,o=1/Math.sqrt(1+a*a),n=a*o):Math.abs(e)===0?(n=1,o=0):(a=-.5*n/e,n=1/Math.sqrt(1+a*a),o=a*n),c>0&&(a=n,n=-o,o=a),{rt1:r,rt2:i,cs:n,sn:o}}class Nu extends js{constructor(e=0,t=0,r=1,i=0,n=Math.PI*2,o=!1){super(new k(e,t),new k(r,r),new k,0,i,n,o)}drawTo(e){const{cx:t,cy:r,rx:i,startAngle:n,endAngle:o,clockwise:a}=this;return e.arc(t,r,i,n,o,!a),this}}class Ct extends fr{constructor(e=new k,t=new k){super(),this.p1=e,this.p2=t}static from(e,t,r,i){return new Ct(new k(e,t),new k(r,i))}getPoint(e,t=new k){return e===1?t.copy(this.p2):t.copy(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new k){return this.getPoint(e,t)}getTangent(e,t=new k){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new k){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=k.MAX,t=k.MIN){const{p1:r,p2:i}=this;return e.x=Math.min(e.x,r.x,i.x),e.y=Math.min(e.y,r.y,i.y),t.x=Math.max(t.x,r.x,i.x),t.y=Math.max(t.y,r.y,i.y),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,p2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}getFillVertices(e={}){const t=Math.min(this.p1.x,this.p2.x),r=Math.max(this.p1.x,this.p2.x),i=Math.min(this.p1.y,this.p2.y),n=Math.max(this.p1.y,this.p2.y),o=t,a=i,l=r-t||e.style?.strokeWidth||0,c=n-i||e.style?.strokeWidth||0;return[o,a,o+l,a,o+l,a+c,o,a+c]}drawTo(e){const{p1:t,p2:r}=this;return e.lineTo(t.x,t.y),e.lineTo(r.x,r.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.p2.copy(e.p2),this}}class Lr extends fr{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(e=>e instanceof Lr?e.getFlatCurves():e)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new k){const r=e*this.getLength(),i=this.getLengths();let n=0;for(;n<i.length;){if(i[n]>=r){const o=i[n]-r,a=this.curves[n],l=a.getLength();return a.getPointAt(l===0?0:1-o/l,t)}n++}return t}updateLengths(){const e=[];for(let t=0,r=0,i=this.curves.length;t<i;t++)r+=this.curves[t].getLength(),e.push(r);this._arcLengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){const r=[e[t-1],e[t]],i=[e[t+1],e[t+2]];return r[0]===i[0]&&r[1]===i[1]&&e.splice(t+1,2),e}getSpacedVertices(e=5,t=[]){let r;return this.curves.forEach(i=>{i.getSpacedVertices(e,t),r&&this._removeNextPointIfEqualPrevPoint(t,r),r=t.length-1}),t}getAdaptiveVertices(e=[]){let t;return this.curves.forEach(r=>{r.getAdaptiveVertices(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}strokeTriangulate(e){return this.curves.length===1?this.curves[0].strokeTriangulate(e):super.strokeTriangulate(e)}getFillVertices(e){if(this.curves.length===1)return this.curves[0].getFillVertices(e);{const t=[];let r;return this.curves.forEach(i=>{let n;i instanceof Ct?n=i.getAdaptiveVertices():n=i.getFillVertices(e),t.push(...n),r&&this._removeNextPointIfEqualPrevPoint(t,r),r=t.length-1}),t}}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=k.MAX,t=k.MIN){return this.curves.forEach(r=>r.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new Z(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){const t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this}copy(e){return super.copy(e),this.curves=e.curves.map(t=>t.clone()),this}}class Ws extends fr{constructor(e=new k,t=new k,r=new k,i=new k){super(),this.p1=e,this.cp1=t,this.cp2=r,this.p2=i}static from(e,t,r,i,n,o,a,l){return new Ws(new k(e,t),new k(r,i),new k(n,o),new k(a,l))}getPoint(e,t=new k){const{p1:r,cp1:i,cp2:n,p2:o}=this;return t.set(Sa(e,r.x,i.x,n.x,o.x),Sa(e,r.y,i.y,n.y,o.y))}getAdaptiveVertices(e=[]){return yu(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(e,t,r){const i=t*t-4*e*r;if(i<0)return[];const n=Math.sqrt(i),o=(-t+n)/(2*e),a=(-t-n)/(2*e);return[o,a].filter(l=>l>=0&&l<=1)}getMinMax(e=k.MAX,t=k.MIN){const{p1:r,cp1:i,cp2:n,p2:o}=this,a=this._solveQuadratic(3*(i.x-r.x),6*(n.x-i.x),3*(o.x-n.x)),l=this._solveQuadratic(3*(i.y-r.y),6*(n.y-i.y),3*(o.y-n.y)),c=[0,1,...a,...l];return((f,d)=>{for(const g of f)for(let p=0;p<=d;p++){const y=p/d-.5,m=Math.min(1,Math.max(0,g+y)),P=this.getPoint(m);e.x=Math.min(e.x,P.x),e.y=Math.min(e.y,P.y),t.x=Math.max(t.x,P.x),t.y=Math.max(t.y,P.y)}})(c,10),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,cp1:t,cp2:r,p2:i}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:r.x,y2:r.y,x:i.x,y:i.y}]}drawTo(e){const{p1:t,cp1:r,cp2:i,p2:n}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(r.x,r.y,i.x,i.y,n.x,n.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp1.copy(e.cp1),this.cp2.copy(e.cp2),this.p2.copy(e.p2),this}}class Fu extends js{constructor(e=0,t=0,r=1,i=1,n=0,o=0,a=Math.PI*2,l=!1){super(new k(e,t),new k(r,i),new k,n,o,a,l)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class $u extends Lr{}class qs extends fr{constructor(e=new k,t=new k,r=new k){super(),this.p1=e,this.cp=t,this.p2=r}static from(e,t,r,i,n,o){return new qs(new k(e,t),new k(r,i),new k(n,o))}getPoint(e,t=new k){const{p1:r,cp:i,p2:n}=this;return t.set(Ea(e,r.x,i.x,n.x),Ea(e,r.y,i.y,n.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(e=[]){return wu(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=k.MAX,t=k.MIN){const{p1:r,cp:i,p2:n}=this,o=.5*(r.x+i.x),a=.5*(r.y+i.y),l=.5*(r.x+n.x),c=.5*(r.y+n.y);return e.x=Math.min(e.x,r.x,n.x,o,l),e.y=Math.min(e.y,r.y,n.y,a,c),t.x=Math.max(t.x,r.x,n.x,o,l),t.y=Math.max(t.y,r.y,n.y,a,c),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,cp:t,p2:r}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:r.x,y:r.y}]}drawTo(e){const{p1:t,cp:r,p2:i}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(r.x,r.y,i.x,i.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp.copy(e.cp),this.p2.copy(e.p2),this}}class zu extends $u{constructor(e=0,t=0,r=0,i=0){super(),this.x=e,this.y=t,this.width=r,this.height=i,this.update()}update(){const{x:e,y:t,width:r,height:i}=this,n=[new k(e,t),new k(e+r,t),new k(e+r,t+i),new k(e,t+i)];return this.curves=[new Ct(n[0],n[1]),new Ct(n[1],n[2]),new Ct(n[2],n[3]),new Ct(n[3],n[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}getFillVertices(e={}){const{x:t,y:r,width:i,height:n}=this;return[t,r,t+i,r,t+i,r+n,t,r+n]}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}}class Vu extends js{constructor(e=0,t=0,r=1,i=1,n=1){super(),this.x=e,this.y=t,this.width=r,this.height=i,this.radius=n,this.update()}update(){const{x:e,y:t,width:r,height:i,radius:n}=this,o=r/2,a=i/2,l=e+o,c=t+a,h=Math.max(0,Math.min(n,Math.min(o,a))),f=h;return this._center=new k(l,c),this._radius=new k(h,f),this._diff=new k(o-h,a-f),this}drawTo(e){const{x:t,y:r,width:i,height:n,radius:o}=this;return e.roundRect(t,r,i,n,o),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}}class Gu extends fr{constructor(e=[]){super(),this.points=e}getPoint(e,t=new k){const{points:r}=this,i=(r.length-1)*e,n=Math.floor(i),o=i-n,a=r[n===0?n:n-1],l=r[n],c=r[n>r.length-2?r.length-1:n+1],h=r[n>r.length-3?r.length-1:n+2];return t.set(Pa(o,a.x,l.x,c.x,h.x),Pa(o,a.y,l.y,c.y,h.y)),t}getControlPointRefs(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++)this.points.push(e.points[t].clone());return this}}class Di extends Lr{startPoint;currentPoint;autoClose=!1;constructor(e){super(),e&&this.addPoints(e)}addPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,r=e.length;t<r;t++){const{x:i,y:n}=e[t];this.lineTo(i,n)}return this}addCommands(e){return pa(e,this),this}addData(e){return this.addCommands(ga(e)),this}_closeVertices(e){return this.autoClose&&e.length>=4&&e[0]!==e[e.length-2]&&e[1]!==e[e.length-1]&&e.push(e[0],e[1]),e}getUnevenVertices(e=40,t=[]){return this._closeVertices(super.getUnevenVertices(e,t))}getSpacedVertices(e=40,t=[]){return this._closeVertices(super.getSpacedVertices(e,t))}getAdaptiveVertices(e=[]){return this._closeVertices(super.getAdaptiveVertices(e))}getFillVertices(e){return this._closeVertices(super.getFillVertices(e))}_setCurrentPoint(e){return this.currentPoint=new k(e.x,e.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(e){if(this.curves.length>0){const t=e.getPoint(0);(!this.currentPoint||!t.equals(this.currentPoint))&&this.lineTo(t.x,t.y)}return this}closePath(){const e=this.startPoint;if(e){const t=this.currentPoint;t&&!e.equals(t)&&(this.curves.push(new Ct(t.clone(),e.clone())),t.copy(e)),this.startPoint=void 0}return this}moveTo(e,t){return this.currentPoint=new k(e,t),this.startPoint=this.currentPoint.clone(),this}lineTo(e,t){const r=this.currentPoint;return r?.equals({x:e,y:t})||this.curves.push(Ct.from(r?.x??0,r?.y??0,e,t)),this._setCurrentPoint({x:e,y:t}),this}bezierCurveTo(e,t,r,i,n,o){const a=this.currentPoint;return a?.equals({x:n,y:o})||this.curves.push(Ws.from(a?.x??0,a?.y??0,e,t,r,i,n,o)),this._setCurrentPoint({x:n,y:o}),this}quadraticCurveTo(e,t,r,i){const n=this.currentPoint;return n?.equals({x:r,y:i})||this.curves.push(qs.from(n?.x??0,n?.y??0,e,t,r,i)),this._setCurrentPoint({x:r,y:i}),this}arc(e,t,r,i,n,o){const a=new Nu(e,t,r,i,n,!o);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint(a.getPoint(1)),this}relativeArc(e,t,r,i,n,o){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.arc(e,t,r,i,n,o),this}arcTo(e,t,r,i,n){return console.warn("Method arcTo not supported yet"),this}ellipse(e,t,r,i,n,o,a,l=!0){const c=new Fu(e,t,r,i,n,o,a,!l);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(e,t,r,i,n,o,a,l){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.ellipse(e,t,r,i,n,o,a,l),this}rect(e,t,r,i){const n=new zu(e,t,r,i);return this._connetLineTo(n),this.curves.push(n),this._setCurrentPoint({x:e,y:t}),this}roundRect(e,t,r,i,n){const o=new Vu(e,t,r,i,n);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint({x:e,y:t}),this}splineThru(e){const t=this.currentPoint??new k;return this.curves.push(new Gu([t].concat(e))),this._setCurrentPoint(e[e.length-1]),this}drawTo(e){const t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this.autoClose&&e.closePath(),this}copy(e){return super.copy(e),this.autoClose=e.autoClose,this.currentPoint=e.currentPoint?.clone(),this}}class ge extends Lr{_meta;currentCurve=new Di;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}constructor(e,t={}){super(),this.curves.push(this.currentCurve),this.style=t,e&&(e instanceof ge?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}getMeta(){return this._meta}setMeta(e){return this._meta=e,this}addPath(e){const t=this.curves.findIndex(r=>r===this.currentCurve);return t>-1&&this.curves.splice(t,1),e instanceof ge?this.curves.push(...e.curves.filter(r=>r.curves.length).map(r=>r.clone())):e.curves.length&&this.curves.push(e),this.curves.push(this.currentCurve),this}closePath(){const e=this.startPoint;return e&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new Di().moveTo(e.x,e.y),this.curves.push(this.currentCurve))),this}moveTo(e,t){return this.currentCurve.currentPoint?.equals({x:e,y:t})||(this.currentCurve.curves.length&&(this.currentCurve=new Di,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(e,t)),this}lineTo(e,t){return this.currentCurve.lineTo(e,t),this}bezierCurveTo(e,t,r,i,n,o){return this.currentCurve.bezierCurveTo(e,t,r,i,n,o),this}quadraticCurveTo(e,t,r,i){return this.currentCurve.quadraticCurveTo(e,t,r,i),this}arc(e,t,r,i,n,o){return this.currentCurve.arc(e,t,r,i,n,o),this}arcTo(e,t,r,i,n){return this.currentCurve.arcTo(e,t,r,i,n),this}ellipse(e,t,r,i,n,o,a,l){return this.currentCurve.ellipse(e,t,r,i,n,o,a,l),this}rect(e,t,r,i){return this.currentCurve.rect(e,t,r,i),this}roundRect(e,t,r,i,n){return this.currentCurve.roundRect(e,t,r,i,n),this}reset(){return this.currentCurve=new Di,this.curves=[this.currentCurve],this.style={},this}addCommands(e){return pa(e,this),this}addData(e){return this.addCommands(ga(e)),this}splineThru(e){return this.currentCurve.splineThru(e),this}scale(e,t=e,r={x:0,y:0}){return this.getControlPointRefs().forEach(i=>{i.scale(e,t,r)}),this}skew(e,t=0,r={x:0,y:0}){return this.getControlPointRefs().forEach(i=>{i.skew(e,t,r)}),this}rotate(e,t={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.rotate(e,t)}),this}bold(e){if(e===0)return this;const t=this.getFlatCurves(),r=[],i=[],n=[];t.forEach((a,l)=>{const c=a.getControlPointRefs(),h=a.isClockwise();n[l]=c,i[l]=h;const f=c[0],d=c[c.length-1]??f;r.push({start:h?d:f,end:h?f:d,index:l})});const o=[];return r.forEach((a,l)=>{o[l]=[],r.forEach((c,h)=>{c.start&&a.end&&h!==l&&c.start?.equals(a.end)&&o[l].push(c.index)})}),t.forEach((a,l)=>{const c=i[l];n[l].forEach(h=>{h.add(a.getNormal(a.getTForPoint(h)).scale(c?e:-e))})}),o.forEach((a,l)=>{const c=n[l];a.forEach(h=>{const f=n[h],d=Pu(c[c.length-1],c[c.length-2]??c[c.length-1],f[0],f[1]??f[0]);d&&(c[c.length-1].copy(d),f[0].copy(d))})}),this}getMinMax(e=k.MAX,t=k.MIN,r=!0){const i=this.strokeWidth;return this.curves.forEach(n=>{if(n.getMinMax(e,t),r&&i>1){const o=i/2,a=n.isClockwise(),l=[];for(let c=0;c<=1;c+=1/n.arcLengthDivision){const h=n.getPoint(c),f=n.getNormal(c),d=f.clone().scale(a?o:-o),g=f.clone().scale(a?-o:o);l.push(h.clone().add(d),h.clone().add(g),h.clone().add({x:o,y:0}),h.clone().add({x:-o,y:0}),h.clone().add({x:0,y:o}),h.clone().add({x:0,y:-o}),h.clone().add({x:o,y:o}),h.clone().add({x:-o,y:-o}))}e.min(...l),t.max(...l)}}),{min:e.finite(),max:t.finite()}}strokeTriangulate(e){const t=e?.indices??[],r=e?.vertices??[];return this.curves.forEach(i=>{i.strokeTriangulate({...e,indices:t,vertices:r,style:{...this.style}})}),{indices:t,vertices:r}}fillTriangulate(e){const t={...e,style:{...this.style,...e?.style}},r=t.indices??[],i=t.vertices??[];if((t.style.fillRule??"nonzero")==="nonzero"){const o=this.curves.map(c=>c.getFillVertices(t)),a=Tu(o),l=a.length;for(let c=0;c<l;c++){const h=a[c],f=o[c];if(h.wn||!f.length)continue;const d=f.slice(),g=[];for(let p=0;p<l;p++){const y=a[p];y.parentIndex===c&&(g.push(d.length/2),d.push(...o[y.index]))}Ca(d,{...e,indices:r,vertices:i,holes:g,style:{...this.style}})}}else this.curves.forEach(o=>{o.fillTriangulate({...e,indices:r,vertices:i,style:{...this.style}})});return{indices:r,vertices:i}}getBoundingBox(e=!0){const{min:t,max:r}=this.getMinMax(void 0,void 0,e);return new Z(t.x,t.y,r.x-t.x,r.y-t.y)}drawTo(e,t={}){t={...this.style,...t};const{fill:r="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),Ls(e,t),this.curves.forEach(n=>{n.drawTo(e)}),r!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};const{fill:r="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),Ls(e,t),this.getControlPointRefs().forEach(n=>{Wh(e,n.x,n.y,{radius:4})}),r!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}toCommands(){return this.curves.flatMap(e=>e.toCommands())}toData(){return this.curves.filter(e=>e.curves.length).map(e=>e.toData()).join(" ")}toSvgPathString(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const i in e)e[i]!==void 0&&(t[xu(i)]=e[i]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const i in t)t[i]!==void 0&&(r+=`${i}:${t[i]};`);return`<path d="${this.toData()}" style="${r}"></path>`}copy(e){return super.copy(e),this.currentCurve=e.currentCurve.clone(),this.style={...e.style},this}}class Tt{constructor(e=[],t){this.paths=e,this.viewBox=t}getBoundingBox(e=!0){if(!this.paths.length)return;const t=k.MAX,r=k.MIN;return this.paths.forEach(i=>i.getMinMax(t,r,e)),new Z(t.x,t.y,r.x-t.x,r.y-t.y)}toTriangulatedSvgString(e=this.paths.map(r=>r.fillTriangulate()),t=0){let r="";const i={x:-t,y:-t},n={x:t,y:t};(Array.isArray(e)?e:[e]).forEach(({vertices:l,indices:c})=>{const h=f=>{const d=l[f*2],g=l[f*2+1];return i.x=Math.min(i.x,d+t),n.x=Math.max(n.x,d+t),i.y=Math.min(i.y,g+t),n.y=Math.max(n.y,g+t),[d,g]};for(let f=0,d=c.length;f<d;f+=3){const g=h(c[f]),p=h(c[f+1]),y=h(c[f+2]);r+=`<polygon points="${g.join(",")} ${p.join(",")} ${y.join(",")}" stroke="none" fill="black" />`}});const a=[i.x,i.y,n.x-i.x,n.y-i.y];return`<svg width="${a[2]}" height="${a[3]}" viewBox="${a.join(" ")}" xmlns="http://www.w3.org/2000/svg">${r}</svg>`}toTriangulatedSvg(e,t){return new DOMParser().parseFromString(this.toTriangulatedSvgString(e,t),"image/svg+xml").documentElement}toSvgString(){const{x:e,y:t,width:r,height:i}=this.getBoundingBox(),n=this.paths.map(o=>o.toSvgPathString()).join("");return`<svg viewBox="${e} ${t} ${r} ${i}" width="${r}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${n}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...r}=e,{left:i,top:n,width:o,height:a}=this.getBoundingBox(),l=document.createElement("canvas");l.width=o*t,l.height=a*t,l.style.width=`${o}px`,l.style.height=`${a}px`;const c=l.getContext("2d");return c&&(c.scale(t,t),c.translate(-i,-n),this.paths.forEach(h=>{h.drawTo(c,r)})),l}}class Ii extends St{vertexAttributes;indexBuffer;instanceCount;mode;_materialWeakMap=new As;constructor(e={}){super(),this.vertexAttributes=new Map(Object.entries(e?.vertexAttributes??{})),this.indexBuffer=e?.indexBuffer,this.instanceCount=e?.instanceCount,this.mode=e?.mode??"triangles"}_glVertexArray(e){return{attributes:Object.fromEntries(Array.from(this.vertexAttributes).map(([t,r])=>[t,{buffer:r.buffer._glBuffer(e),size:r.size,type:r.type,normalized:r.normalized,stride:r.stride,offset:r.offset,divisor:r.divisor}])),elementArrayBuffer:this.indexBuffer?._glBuffer(e)}}_glVertexArrayObject(e,t){let r=this._materialWeakMap.get(t);return r||(r={material:t.instanceId,geometry:this.instanceId},this._materialWeakMap.set(t,r)),e.getRelated(r,()=>e.vertexArray.create(t._glProgram(e),this._glVertexArray(e)))}draw(e,t,r){e.flush(),t.activate(e,r);const i=this._glVertexArrayObject(e,t);let n=!1,o;this.vertexAttributes.forEach(a=>{o?.instanceId!==a.buffer.instanceId&&(o=a.buffer,o.upload(e)&&(n=!0)),a.upload()&&(n=!0)}),this.indexBuffer?.upload(e)&&(n=!0),n&&i&&e.vertexArray.update(t._glProgram(e),i,this._glVertexArray(e)),e.vertexArray.bind(i??this._glVertexArray(e)),e.draw({mode:this.mode,instanceCount:this.instanceCount}),e.vertexArray.unbind()}}var ju=Object.defineProperty,Ua=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ju(e,t,i),i};class dr extends St{needsUpload=!1;constructor(e){super(),this.setProperties(e)}_glBufferOptions(){return{target:"element_array_buffer",data:this.data,usage:this.dynamic?"dynamic_draw":"static_draw"}}_glBuffer(e){return e.getRelated(this,()=>e.buffer.create(this._glBufferOptions()))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"data":case"dynamic":this.needsUpload=!0;break}}upload(e){const t=this.needsUpload;return t&&(this.needsUpload=!1,e.buffer.update(this._glBuffer(e),this._glBufferOptions())),t}}Ua([w({internal:!0,fallback:null})],dr.prototype,"data"),Ua([w({internal:!0,fallback:!1})],dr.prototype,"dynamic");var Wu=Object.defineProperty,Ba=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Wu(e,t,i),i};class Et extends St{needsUpload=!1;constructor(e){super(),this.setProperties(e)}_glBufferOptions(){return{target:"array_buffer",data:this.data,usage:this.dynamic?"dynamic_draw":"static_draw"}}_glBuffer(e){return e.getRelated(this,()=>e.buffer.create(this._glBufferOptions()))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"data":case"dynamic":this.needsUpload=!0;break}}upload(e){const t=this.needsUpload;return t&&(this.needsUpload=!1,e.buffer.update(this._glBuffer(e),this._glBufferOptions())),t}}Ba([w({internal:!0,default:null})],Et.prototype,"data"),Ba([w({internal:!0,fallback:!1})],Et.prototype,"dynamic");var qu=Object.defineProperty,Kt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&qu(e,t,i),i};class je extends St{needsUpload=!1;constructor(e){super(),this.setProperties({buffer:new Et,...e})}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"buffer":case"size":case"normalized":case"type":case"stride":case"offset":case"divisor":this.needsUpload=!0;break}}upload(){const e=this.needsUpload;return e&&(this.needsUpload=!1),e}}Kt([w({protected:!0})],je.prototype,"buffer"),Kt([w({fallback:0})],je.prototype,"size"),Kt([w({fallback:!1})],je.prototype,"normalized"),Kt([w({fallback:"float"})],je.prototype,"type"),Kt([w()],je.prototype,"stride"),Kt([w()],je.prototype,"offset"),Kt([w()],je.prototype,"divisor");class Xu extends Ii{constructor(){super({vertexAttributes:{position:new je({buffer:new Et({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new dr({data:new Uint16Array([0,1,3,2]),dynamic:!1}),mode:"triangle_strip"})}}class se extends St{static instance=new this;vert;frag;uniforms;constructor(e={}){super(),this.vert=e.vert??`precision highp float;
74
+ ${r.getShaderInfoLog(i)}`);return i}updateUniforms(...e){if(e.length>1){this.bind(e[0]),this.updateUniforms(e[1]);return}const t=this.boundProgram;if(!t)return;const r=this.gl,i=e[0],{uniforms:n,boundUniforms:o}=this.getMeta(t);for(const a in i){const l=i[a],c=n.get(a);if(!c)continue;const{type:h,isArray:f,location:d}=c;if(!(!d||o.get(d)===l))switch(o.set(d,l),h){case"float":f?r.uniform1fv(d,l):r.uniform1f(d,l);break;case"unsigned_int":f?r.uniform1uiv(d,l):r.uniform1ui(d,l);break;case"bool":case"int":case"sampler_2d":case"sampler_cube":case"sampler_2d_array":f?r.uniform1iv(d,l):r.uniform1i(d,l);break;case"bool_vec2":case"int_vec2":r.uniform2iv(d,l);break;case"unsigned_int_vec2":r.uniform2uiv(d,l);break;case"float_vec2":r.uniform2fv(d,l);break;case"bool_vec3":case"int_vec3":r.uniform3iv(d,l);break;case"unsigned_int_vec3":r.uniform3uiv(d,l);break;case"float_vec3":r.uniform3fv(d,l);break;case"bool_vec4":case"int_vec4":r.uniform4iv(d,l);break;case"unsigned_int_vec4":r.uniform4uiv(d,l);break;case"float_vec4":r.uniform4fv(d,l);break;case"float_mat2":r.uniformMatrix2fv(d,!1,l);break;case"float_mat3":r.uniformMatrix3fv(d,!1,l);break;case"float_mat4":r.uniformMatrix4fv(d,!1,l);break}}}reset(){super.reset(),this.boundProgram=null,this.uniforms={projectionMatrix:[1,0,0,0,1,0,0,0,1],viewMatrix:[1,0,0,0,1,0,0,0,1]}}destroy(){super.destroy(),this.bind(null)}}function Ch(s){switch(s){case"float":case"int":case"unsigned_int":case"bool":case"sampler_2d":return 1;case"float_vec2":case"int_vec2":case"unsigned_int_vec2":case"bool_vec2":return 2;case"float_vec3":case"int_vec3":case"unsigned_int_vec3":case"bool_vec3":return 3;case"float_vec4":case"int_vec4":case"unsigned_int_vec4":case"bool_vec4":case"float_mat2":return 4;case"float_mat3":return 9;case"float_mat4":return 16;default:return 1}}function Ti(s,e,t){const[r,i,n,o,a,l,c,h,f]=s,d=r*e+o*t+c,g=i*e+a*t+h,p=n*e+l*t+f;return{x:d/p,y:g/p}}function Th(s,e){const{x:t,y:r,width:i,height:n}=e,o=Ti(s,t,r),a=Ti(s,t+i,r),l=Ti(s,t+i,r+n),c=Ti(s,t,r+n),h=[o,a,l,c],f=h.map(P=>P.x),d=h.map(P=>P.y),g=Math.min(...f),p=Math.max(...f),y=Math.min(...d),m=Math.max(...d);return{x:g,y,width:p-g,height:m-y}}class ta extends Ye{install(e){super.install(e),e.scissor=this}get length(){return this._renderer.mask.last?.scissorCounter??0}push(e){const t=this._renderer.gl;t.enable(t.SCISSOR_TEST),e.scissorCounter??=0,e.scissorCounter++,this.use()}pop(e){if(this.length>0)this.use();else{const t=this._renderer.gl;t.disable(t.SCISSOR_TEST)}}use(){const e=this._renderer,{pixelRatio:t,mask:r,viewport:i,screen:n,gl:o,program:a}=e,{viewMatrix:l}=a.uniforms,c=Th(l,r.last.mask),{x:h,y:f,width:d,height:g}=c;let p;i.boundViewport?p=i.boundViewport.height-(g+f)*t:p=(n.height-(g+f))*t,o.scissor(h*t,p,d*t,g*t)}}class ra extends Ye{install(e){super.install(e),e.stencil=this}get length(){return this._renderer.mask.last?.stencilCounter??0}push(e){const t=this._renderer.gl,r=e.mask,i=e.stencilCounter??=0;e.stencilCounter===0&&(this._renderer.framebuffer.forceStencil(),t.clearStencil(0),t.clear(t.STENCIL_BUFFER_BIT),t.enable(t.STENCIL_TEST)),e.stencilCounter++;const n=e.color;n&&(e.color=0,t.colorMask(!1,!1,!1,!1)),t.stencilFunc(t.EQUAL,i,4294967295),t.stencilOp(t.KEEP,t.KEEP,t.INCR),r.render(this._renderer),this._renderer.flush(),n&&(e.color=n,t.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this.use()}pop(e){const t=this._renderer.gl,r=e.mask;if(!this.length)t.disable(t.STENCIL_TEST);else{const i=this._renderer.mask.last,n=i?.color??15;n!==0&&(i.color=0,t.colorMask(!1,!1,!1,!1)),t.stencilOp(t.KEEP,t.KEEP,t.DECR),r.render(this._renderer),this._renderer.flush(),n!==0&&(i.color=n,t.colorMask((n&1)!==0,(n&2)!==0,(n&4)!==0,(n&8)!==0)),this.use()}}use(){const e=this._renderer.gl;e.stencilFunc(e.EQUAL,this.length,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)}}function Eh(s,e){const t=new Set([...Object.keys(s),...Object.keys(e)]),r={};return t.forEach(i=>{r[i]=s[i]!==e[i]}),r}class ia extends Ye{install(e){super.install(e),e.texture=this}maxUnits=0;boundLocation=0;boundTarget="texture_2d";boundTextures=[];emptyTextures={texture_2d:null,texture_cube_map:null};onUpdateContext(){super.onUpdateContext();const e=this.gl;this.maxUnits=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);for(let i=0;i<this.maxUnits;i++)this.boundTextures[i]={texture_2d:null,texture_cube_map:null};const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array(4));const r=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,r);for(let i=0;i<6;i++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR),this.emptyTextures={texture_2d:t,texture_cube_map:r};for(let i=this.boundTextures.length,n=0;n<i;n++)this.unbind(n)}create(e){const t=this.gl.createTexture();if(!t)throw new Error("Unable to create texture");return e&&(this.bind({location:e.location,target:e.target,value:t,forceUpdateLocation:!0}),this.update({filterMode:"linear",wrapMode:"repeat",...e})),t}getMeta(e){return this._renderer.getRelated(e,()=>({}))}update(...e){if(e.length>1){this.bind({location:e[1].location,target:e[1].target,value:e[0],forceUpdateLocation:!0}),this.update(e[1]);return}const t=e[0],{value:r,...i}=t,n=this.boundTextures[this.boundLocation][t.target??this.boundTarget];if(!n)return;const o=this.gl,a=this.getMeta(n),l=Eh(a,i);Object.assign(a,i);const c=this._renderer.getBindPoint(a.target??this.boundTarget);if(r!==void 0&&(r===null?o.texImage2D(c,0,o.RGBA,1,1,0,o.RGBA,o.UNSIGNED_BYTE,null):"pixels"in r?o.texImage2D(c,0,o.RGBA,r.width,r.height,0,o.RGBA,o.UNSIGNED_BYTE,r.pixels):o.texImage2D(c,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,r)),l.wrapMode&&a.wrapMode){const f=this._renderer.getBindPoint(a.wrapMode);o.texParameteri(c,o.TEXTURE_WRAP_S,f),o.texParameteri(c,o.TEXTURE_WRAP_T,f)}const h=a.filterMode;if(l.filterMode&&h){const f=this._renderer.getBindPoint(h.split("_")[0]);h.includes("_")?o.texParameteri(c,o.TEXTURE_MIN_FILTER,this._renderer.getBindPoint(h)):o.texParameteri(c,o.TEXTURE_MIN_FILTER,f),o.texParameteri(c,o.TEXTURE_MAG_FILTER,f)}if(a.anisoLevel&&h==="linear"&&this._renderer.extensions.anisotropicFiltering&&l.anisoLevel){const{MAX_TEXTURE_MAX_ANISOTROPY_EXT:f,TEXTURE_MAX_ANISOTROPY_EXT:d}=this._renderer.extensions.anisotropicFiltering;o.texParameterf(c,d,Math.min(a.anisoLevel,o.getParameter(f)))}}bind(e){const t=this.gl;let r,i,n,o;if(e&&"value"in e?{target:i,value:r,location:n,forceUpdateLocation:o}=e:r=e,r){const g=this.getMeta(r);g.target=i??=g.target??"texture_2d",g.location=n??=g.location??0}else i??="texture_2d",n??=0;let a=this.boundTextures[n];a||(this.boundTextures[n]=a={texture_2d:null,texture_cube_map:null});const l=a[i]??null,c=this.boundLocation,h=r!==l,f={location:n!==c&&(h||o),texture:h},d=this._renderer.getBindPoint(i);f.location&&(t.activeTexture(t.TEXTURE0+n),this.boundLocation=n),f.texture&&(t.bindTexture(d,r??this.emptyTextures[i]),a[i]=r),this.boundTarget=i}unbind(e,t="texture_2d"){const r=this._renderer.gl;if(typeof e=="number")this.bind({value:null,target:t,location:e});else{const i=this.getMeta(e),{target:n=this.boundTarget}=i,o=this._renderer.getBindPoint(n);for(let a=0;a<this.boundTextures.length;a++)this.boundTextures[a][n]===e&&(this.boundLocation!==a&&(r.activeTexture(r.TEXTURE0+a),this.boundLocation=a),r.bindTexture(o,this.emptyTextures[n]),this.boundTextures[a][n]=null)}}reset(){super.reset(),this.boundLocation=0,this.boundTarget="texture_2d",this.boundTextures=[],this.maxUnits=0}}class sa extends Ye{install(e){super.install(e),e.vertexArray=this}boundVertexArrayNull={attributes:{},elementArrayBuffer:null};boundVertexArrayObject=null;boundVertexArray=this.boundVertexArrayNull;enableVertexAttrib(e,t,r,i=1){const{buffer:n,size:o=0,type:a="float",normalized:l=!1,stride:c=0,offset:h=0,divisor:f}=r,d=this._renderer.gl;this._renderer.buffer.bind({target:"array_buffer",value:n});for(let g=0;g<i;g++)d.enableVertexAttribArray(t+g),d.vertexAttribPointer(t+g,o,this._renderer.getBindPoint(a),l,c,h+(c-h)/i*g);f&&("vertexAttribDivisor"in d?d.vertexAttribDivisor(t,f):console.warn("Failed to active vertex array object, GPU Instancing is not supported on this device")),this.boundVertexArray.attributes[e]={enable:!0,...r}}create(...e){const t=this._renderer.gl;if(!("createVertexArray"in t))return null;const r=t.createVertexArray();if(!r)throw new Error("Unable to create vertex array");return e.length===2?this.update(e[0],r,e[1]):e.length===1&&this.update(r,e[0]),r}getVertexArrayMeta(e){return this._renderer.getRelated(e,()=>({attributes:{},elementArrayBuffer:null}))}update(...e){if(e.length>2){this._renderer.program.bind(e[0]),this.update(e[1],e[2]);return}else if(e.length===2)if(e[0]){const n=e[0],o=e[1],a=this.getVertexArrayMeta(n);this.bind(n),this.update(o),a.attributes=this.boundVertexArray.attributes,a.elementArrayBuffer=this.boundVertexArray.elementArrayBuffer,this.unbind(),this._renderer.buffer.unbind("array_buffer");return}else return this.update(e[1]);const t=this._renderer.program.boundProgram;if(!t)return;const r=e[0];if(r.attributes){const n=this._renderer.program.getMeta(t),o={},a={};for(const c in r.attributes){const h=r.attributes[c],f=n.attributes.get(c);let d;"buffer"in h?d={...h}:d={buffer:h},d.size=d.size||f?.size||0;const g=this._renderer.buffer.getMeta(d.buffer),p=Number(f?.type.match(/mat(\d)/)?.[1]??1);let y;switch(d.type){case"unsigned_byte":y=d.size;break;case"unsigned_short":y=d.size*2;break;case"float":default:y=d.size*4;break}y*=p,o[g.id]??=0,o[g.id]+=y,a[c]={attrib:d,meta:g,info:f,byteLength:y,dimension:p}}const l={};for(const c in a){const{attrib:h,meta:f,info:d,byteLength:g,dimension:p}=a[c];d?.location!==void 0&&(l[f.id]??=0,h.offset??=l[f.id],h.stride??=o[f.id]===g?0:o[f.id],this.enableVertexAttrib(c,d.location,h,p),l[f.id]+=g)}}const i=r.elementArrayBuffer??null;this._renderer.buffer.bind({target:"element_array_buffer",value:i}),this.boundVertexArray.elementArrayBuffer=i}bind(e){const t=this._renderer.gl;if(e&&"attributes"in e)this.update(e);else if("bindVertexArray"in t){const r=this.boundVertexArrayObject;({value:e!==r}).value&&(t.bindVertexArray(e),this.boundVertexArrayObject=e,e?this.boundVertexArray={...this.getVertexArrayMeta(e)}:this.boundVertexArray=this.boundVertexArrayNull)}}unbind(){return this.bind(null)}reset(){super.reset(),this.boundVertexArrayNull={attributes:{},elementArrayBuffer:null},this.boundVertexArray=this.boundVertexArrayNull,this.boundVertexArrayObject=null}}class na extends Ye{install(e){super.install(e),e.viewport=this}boundViewport={x:0,y:0,width:0,height:0};bind(e){const t=this.boundViewport,r=Math.floor(e.x),i=Math.floor(e.y),n=Math.floor(e.width),o=Math.floor(e.height);t.x===r&&t.y===i&&t.width===n&&t.height===o||(this._renderer.gl.viewport(r,i,n,o),t.x=r,t.y=i,t.width=n,t.height=o)}reset(){super.reset(),this.boundViewport={x:0,y:0,width:0,height:0}}}class oa extends Xo{_modules=[new ia,new Zo,new Jo,new ea,new sa,new na,new Yo,new Qo,new ta,new ra,new Ko];bindPoints=new Map;constructor(e=Ro(),t){if(super(),!e)throw new Error("Failed to createHTMLCanvas");Do(e)?this._setupContext(e,t):(this.gl=e,this.version=Io(this.gl)?2:1),this._setupBindPoints()._setupExtensions()._setupPolyfill(),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this._modules.forEach(r=>r.install(this)),this._modules.forEach(r=>r.onUpdateContext())}_setupContext(e,t){this.view=e;let r=e.getContext("webgl2",t)||e.getContext("experimental-webgl2",t),i=2;if(r||(r=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),i=1),!r)throw new Error("Unable to getContext");return this.gl=r,this.version=i,this._onContextLost=this._onContextLost.bind(this),this._onContextRestored=this._onContextRestored.bind(this),e.addEventListener("webglcontextlost",this._onContextLost,!1),e.addEventListener("webglcontextrestored",this._onContextRestored,!1),this}_setupExtensions(){const e=this.gl,t={loseContext:e.getExtension("WEBGL_lose_context"),anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tcSRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc")};return this.version===1?(t.instancedArrays=e.getExtension("ANGLE_instanced_arrays"),t.drawBuffers=e.getExtension("WEBGL_draw_buffers"),t.depthTexture=e.getExtension("WEBGL_depth_texture"),t.vertexArrayObject=e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),t.uint32ElementIndex=e.getExtension("OES_element_index_uint"),t.floatTexture=e.getExtension("OES_texture_float"),t.textureHalfFloat=e.getExtension("OES_texture_half_float"),t.textureHalfFloatLinear=e.getExtension("OES_texture_half_float_linear")):this.version===2&&(t.colorBufferFloat=e.getExtension("EXT_color_buffer_float")),this.extensions=t,this}_setupBindPoints(){for(const e in this.gl)if(e===e.toUpperCase()){const t=this.gl[e];typeof t=="number"&&this.bindPoints.set(t,e.toLowerCase())}return this}_setupPolyfill(){if(this.version===1){const{instancedArrays:e,vertexArrayObject:t,drawBuffers:r}=this.extensions,i=this.gl;t&&(i.createVertexArray=()=>t.createVertexArrayOES(),i.bindVertexArray=n=>t.bindVertexArrayOES(n),i.deleteVertexArray=n=>t.deleteVertexArrayOES(n)),e&&(i.vertexAttribDivisor=(n,o)=>e.vertexAttribDivisorANGLE(n,o),i.drawElementsInstanced=(n,o,a,l,c)=>e.drawElementsInstancedANGLE(n,o,a,l,c),i.drawArraysInstanced=(n,o,a,l)=>e.drawArraysInstancedANGLE(n,o,a,l)),r&&(i.drawBuffers=n=>r.drawBuffersWEBGL(n))}return this}_onContextLost(e){e.preventDefault(),setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0)}_onContextRestored(){}getBindPoint(e){return this.gl[e.toUpperCase()]}clear(e=this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT){this.gl.clear(e)}draw(e={}){const{mode:t="triangles",first:r=0,instanceCount:i}=e;let{count:n=0,bytesPerElement:o=0}=e;if(!n||!o){const l=this.vertexArray.boundVertexArray.elementArrayBuffer??Object.values(this.vertexArray.boundVertexArray.attributes)[0];if(l){const c=this.buffer.getMeta(l);n||(n=c.length),o||(o=c.bytesPerElement)}}const a=this.getBindPoint(t);if(o)if(o===2||o===4&&this.extensions.uint32ElementIndex){const l=o===2?this.gl.UNSIGNED_SHORT:this.gl.UNSIGNED_INT;i&&"drawElementsInstanced"in this.gl?this.gl.drawElementsInstanced(a,n,l,r*o,i):this.gl.drawElements(a,n,l,r*o)}else console.warn("Unsupported index buffer type: uint32");else i&&"drawArraysInstanced"in this.gl?this.gl.drawArraysInstanced(a,r,n,i):this.gl.drawArrays(a,r,n)}reset(){this._modules.forEach(e=>e.reset())}flush(){this._modules.forEach(e=>e.flush())}destroy(){this._modules.forEach(e=>e.destroy()),this.view?.removeEventListener("webglcontextlost",this._onContextLost,!1),this.view?.removeEventListener("webglcontextrestored",this._onContextRestored,!1),this.extensions.loseContext?.loseContext()}toPixels(e=0,t=0,r=this.gl.drawingBufferWidth,i=this.gl.drawingBufferHeight){const n=r*i*4,o=r*4,a=(i-1)*o,l=new Uint8Array(n),c=new Uint8ClampedArray(n);this.gl.readPixels(e,t,r,i,this.gl.RGBA,this.gl.UNSIGNED_BYTE,l);for(let h=0;h<n;h+=o)c.set(l.subarray(h,h+o),a-h);return c}}class Ut{}class aa extends Ut{install(e){const t=async r=>{const{parseFont:i}=await Promise.resolve().then(()=>eg);return await e.fetch(r).then(n=>n.arrayBuffer()).then(n=>i(n))};return this.load=r=>e.loadBy(r,()=>t(r)),["woff","ttf","otf"].forEach(r=>{e.register(r,t)}),e.font=this,this}}function Mh(s,e,t=2){const r=e&&e.length,i=r?e[0]*t:s.length;let n=la(s,0,i,t,!0);const o=[];if(!n||n.next===n.prev)return o;let a,l,c;if(r&&(n=Ih(s,e,n,t)),s.length>80*t){a=s[0],l=s[1];let h=a,f=l;for(let d=t;d<i;d+=t){const g=s[d],p=s[d+1];g<a&&(a=g),p<l&&(l=p),g>h&&(h=g),p>f&&(f=p)}c=Math.max(h-a,f-l),c=c!==0?32767/c:0}return Ir(n,o,t,a,l,c,0),o}function la(s,e,t,r,i){let n;if(i===jh(s,e,t,r)>0)for(let o=e;o<t;o+=r)n=fa(o/r|0,s[o],s[o+1],n);else for(let o=t-r;o>=e;o-=r)n=fa(o/r|0,s[o],s[o+1],n);return n&&hr(n,n.next)&&(Br(n),n=n.next),n}function Ht(s,e){if(!s)return s;e||(e=s);let t=s,r;do if(r=!1,!t.steiner&&(hr(t,t.next)||ie(t.prev,t,t.next)===0)){if(Br(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function Ir(s,e,t,r,i,n,o){if(!s)return;!o&&n&&Nh(s,r,i,n);let a=s;for(;s.prev!==s.next;){const l=s.prev,c=s.next;if(n?Oh(s,r,i,n):Ah(s)){e.push(l.i,s.i,c.i),Br(s),s=c.next,a=c.next;continue}if(s=c,s===a){o?o===1?(s=kh(Ht(s),e),Ir(s,e,t,r,i,n,2)):o===2&&Dh(s,e,t,r,i,n):Ir(Ht(s),e,t,r,i,n,1);break}}}function Ah(s){const e=s.prev,t=s,r=s.next;if(ie(e,t,r)>=0)return!1;const i=e.x,n=t.x,o=r.x,a=e.y,l=t.y,c=r.y,h=Math.min(i,n,o),f=Math.min(a,l,c),d=Math.max(i,n,o),g=Math.max(a,l,c);let p=r.next;for(;p!==e;){if(p.x>=h&&p.x<=d&&p.y>=f&&p.y<=g&&Rr(i,a,n,l,o,c,p.x,p.y)&&ie(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Oh(s,e,t,r){const i=s.prev,n=s,o=s.next;if(ie(i,n,o)>=0)return!1;const a=i.x,l=n.x,c=o.x,h=i.y,f=n.y,d=o.y,g=Math.min(a,l,c),p=Math.min(h,f,d),y=Math.max(a,l,c),m=Math.max(h,f,d),P=Us(g,p,e,t,r),E=Us(y,m,e,t,r);let x=s.prevZ,S=s.nextZ;for(;x&&x.z>=P&&S&&S.z<=E;){if(x.x>=g&&x.x<=y&&x.y>=p&&x.y<=m&&x!==i&&x!==o&&Rr(a,h,l,f,c,d,x.x,x.y)&&ie(x.prev,x,x.next)>=0||(x=x.prevZ,S.x>=g&&S.x<=y&&S.y>=p&&S.y<=m&&S!==i&&S!==o&&Rr(a,h,l,f,c,d,S.x,S.y)&&ie(S.prev,S,S.next)>=0))return!1;S=S.nextZ}for(;x&&x.z>=P;){if(x.x>=g&&x.x<=y&&x.y>=p&&x.y<=m&&x!==i&&x!==o&&Rr(a,h,l,f,c,d,x.x,x.y)&&ie(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;S&&S.z<=E;){if(S.x>=g&&S.x<=y&&S.y>=p&&S.y<=m&&S!==i&&S!==o&&Rr(a,h,l,f,c,d,S.x,S.y)&&ie(S.prev,S,S.next)>=0)return!1;S=S.nextZ}return!0}function kh(s,e){let t=s;do{const r=t.prev,i=t.next.next;!hr(r,i)&&ha(r,t,t.next,i)&&Ur(r,i)&&Ur(i,r)&&(e.push(r.i,t.i,i.i),Br(t),Br(t.next),t=s=i),t=t.next}while(t!==s);return Ht(t)}function Dh(s,e,t,r,i,n){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&zh(o,a)){let l=ua(o,a);o=Ht(o,o.next),l=Ht(l,l.next),Ir(o,e,t,r,i,n,0),Ir(l,e,t,r,i,n,0);return}a=a.next}o=o.next}while(o!==s)}function Ih(s,e,t,r){const i=[];for(let n=0,o=e.length;n<o;n++){const a=e[n]*r,l=n<o-1?e[n+1]*r:s.length,c=la(s,a,l,r,!1);c===c.next&&(c.steiner=!0),i.push($h(c))}i.sort(Rh);for(let n=0;n<i.length;n++)t=Uh(i[n],t);return t}function Rh(s,e){let t=s.x-e.x;if(t===0&&(t=s.y-e.y,t===0)){const r=(s.next.y-s.y)/(s.next.x-s.x),i=(e.next.y-e.y)/(e.next.x-e.x);t=r-i}return t}function Uh(s,e){const t=Bh(s,e);if(!t)return e;const r=ua(t,s);return Ht(r,r.next),Ht(t,t.next)}function Bh(s,e){let t=e;const r=s.x,i=s.y;let n=-1/0,o;if(hr(s,t))return t;do{if(hr(s,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const f=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=r&&f>n&&(n=f,o=t.x<t.next.x?t:t.next,f===r))return o}t=t.next}while(t!==e);if(!o)return null;const a=o,l=o.x,c=o.y;let h=1/0;t=o;do{if(r>=t.x&&t.x>=l&&r!==t.x&&ca(i<c?r:n,i,l,c,i<c?n:r,i,t.x,t.y)){const f=Math.abs(i-t.y)/(r-t.x);Ur(t,s)&&(f<h||f===h&&(t.x>o.x||t.x===o.x&&Lh(o,t)))&&(o=t,h=f)}t=t.next}while(t!==a);return o}function Lh(s,e){return ie(s.prev,s,e.prev)<0&&ie(e.next,s,s.next)<0}function Nh(s,e,t,r){let i=s;do i.z===0&&(i.z=Us(i.x,i.y,e,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,Fh(i)}function Fh(s){let e,t=1;do{let r=s,i;s=null;let n=null;for(e=0;r;){e++;let o=r,a=0;for(let c=0;c<t&&(a++,o=o.nextZ,!!o);c++);let l=t;for(;a>0||l>0&&o;)a!==0&&(l===0||!o||r.z<=o.z)?(i=r,r=r.nextZ,a--):(i=o,o=o.nextZ,l--),n?n.nextZ=i:s=i,i.prevZ=n,n=i;r=o}n.nextZ=null,t*=2}while(e>1);return s}function Us(s,e,t,r,i){return s=(s-t)*i|0,e=(e-r)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,s|e<<1}function $h(s){let e=s,t=s;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==s);return t}function ca(s,e,t,r,i,n,o,a){return(i-o)*(e-a)>=(s-o)*(n-a)&&(s-o)*(r-a)>=(t-o)*(e-a)&&(t-o)*(n-a)>=(i-o)*(r-a)}function Rr(s,e,t,r,i,n,o,a){return!(s===o&&e===a)&&ca(s,e,t,r,i,n,o,a)}function zh(s,e){return s.next.i!==e.i&&s.prev.i!==e.i&&!Vh(s,e)&&(Ur(s,e)&&Ur(e,s)&&Gh(s,e)&&(ie(s.prev,s,e.prev)||ie(s,e.prev,e))||hr(s,e)&&ie(s.prev,s,s.next)>0&&ie(e.prev,e,e.next)>0)}function ie(s,e,t){return(e.y-s.y)*(t.x-e.x)-(e.x-s.x)*(t.y-e.y)}function hr(s,e){return s.x===e.x&&s.y===e.y}function ha(s,e,t,r){const i=Mi(ie(s,e,t)),n=Mi(ie(s,e,r)),o=Mi(ie(t,r,s)),a=Mi(ie(t,r,e));return!!(i!==n&&o!==a||i===0&&Ei(s,t,e)||n===0&&Ei(s,r,e)||o===0&&Ei(t,s,r)||a===0&&Ei(t,e,r))}function Ei(s,e,t){return e.x<=Math.max(s.x,t.x)&&e.x>=Math.min(s.x,t.x)&&e.y<=Math.max(s.y,t.y)&&e.y>=Math.min(s.y,t.y)}function Mi(s){return s>0?1:s<0?-1:0}function Vh(s,e){let t=s;do{if(t.i!==s.i&&t.next.i!==s.i&&t.i!==e.i&&t.next.i!==e.i&&ha(t,t.next,s,e))return!0;t=t.next}while(t!==s);return!1}function Ur(s,e){return ie(s.prev,s,s.next)<0?ie(s,e,s.next)>=0&&ie(s,s.prev,e)>=0:ie(s,e,s.prev)<0||ie(s,s.next,e)<0}function Gh(s,e){let t=s,r=!1;const i=(s.x+e.x)/2,n=(s.y+e.y)/2;do t.y>n!=t.next.y>n&&t.next.y!==t.y&&i<(t.next.x-t.x)*(n-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==s);return r}function ua(s,e){const t=Bs(s.i,s.x,s.y),r=Bs(e.i,e.x,e.y),i=s.next,n=e.prev;return s.next=e,e.prev=s,t.next=i,i.prev=t,r.next=t,t.prev=r,n.next=r,r.prev=n,r}function fa(s,e,t,r){const i=Bs(s,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Br(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Bs(s,e,t){return{i:s,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function jh(s,e,t,r){let i=0;for(let n=e,o=t-r;n<t;n+=r)i+=(s[o]-s[n])*(s[n+1]+s[o+1]),o=n;return i}function Wh(s,e,t,r={}){const{radius:i=1}=r;s.moveTo(e,t),s.arc(e,t,i,0,Math.PI*2)}const qh={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Ls(s,e){const{fill:t="#000",stroke:r="none",strokeWidth:i=r==="none"?0:1,strokeLinecap:n="round",strokeLinejoin:o="miter",strokeMiterlimit:a=0,strokeDasharray:l=[],strokeDashoffset:c=0,shadowOffsetX:h=0,shadowOffsetY:f=0,shadowBlur:d=0,shadowColor:g="rgba(0, 0, 0, 0)"}=e;s.fillStyle=t,s.strokeStyle=r,s.lineWidth=i,s.lineCap=n,s.lineJoin=qh[o],s.miterLimit=a,s.setLineDash(l),s.lineDashOffset=c,s.shadowOffsetX=h,s.shadowOffsetY=f,s.shadowBlur=d,s.shadowColor=g}class k{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new k(1/0,1/0)}static get MIN(){return new k(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const r=-e/180*Math.PI,i=this.x-t.x,n=-(this.y-t.y),o=Math.sin(r),a=Math.cos(r);return this.set(t.x+(i*a-n*o),t.y-(i*o+n*a)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,r={x:0,y:0}){const i=e<0?r.x-this.x+r.x:this.x,n=t<0?r.y-this.y+r.y:this.y;return this.x=i*Math.abs(e),this.y=n*Math.abs(t),this}skew(e,t=0,r={x:0,y:0}){const i=this.x-r.x,n=this.y-r.y;return this.x=r.x+(i+Math.tan(e)*n),this.y=r.y+(n+Math.tan(t)*i),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new k(this.x,this.y)}}class Z{constructor(e=0,t=0,r=0,i=0){this.left=e,this.top=t,this.width=r,this.height=i}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new k((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...e){if(e.length===0)return new Z;if(e.length===1)return e[0].clone();const t=e[0],r=e.slice(1).reduce((i,n)=>(i.left=Math.min(i.left,n.left),i.top=Math.min(i.top,n.top),i.right=Math.max(i.right,n.right),i.bottom=Math.max(i.bottom,n.bottom),i),{left:t?.left??0,top:t?.top??0,right:t?.right??0,bottom:t?.bottom??0});return new Z(r.left,r.top,r.right-r.left,r.bottom-r.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new Z(this.left,this.top,this.width,this.height)}}class be{elements=[];constructor(e=1,t=0,r=0,i=0,n=1,o=0,a=0,l=0,c=1){this.set(e,t,r,i,n,o,a,l,c)}set(e,t,r,i,n,o,a,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=a,h[3]=t,h[4]=n,h[5]=l,h[6]=r,h[7]=o,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,i=t.elements,n=this.elements,o=r[0],a=r[3],l=r[6],c=r[1],h=r[4],f=r[7],d=r[2],g=r[5],p=r[8],y=i[0],m=i[3],P=i[6],E=i[1],x=i[4],S=i[7],_=i[2],b=i[5],C=i[8];return n[0]=o*y+a*E+l*_,n[3]=o*m+a*x+l*b,n[6]=o*P+a*S+l*C,n[1]=c*y+h*E+f*_,n[4]=c*m+h*x+f*b,n[7]=c*P+h*S+f*C,n[2]=d*y+g*E+p*_,n[5]=d*m+g*x+p*b,n[8]=d*P+g*S+p*C,this}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5],l=e[6],c=e[7],h=e[8],f=h*o-a*c,d=a*l-h*n,g=c*n-o*l,p=t*f+r*d+i*g;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/p;return e[0]=f*y,e[1]=(i*c-h*r)*y,e[2]=(a*r-i*o)*y,e[3]=d*y,e[4]=(h*t-i*l)*y,e[5]=(i*n-a*t)*y,e[6]=g*y,e[7]=(r*l-c*t)*y,e[8]=(o*t-r*n)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(Ns.makeScale(e,t)),this}rotate(e){return this.premultiply(Ns.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ns.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,r,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const Ns=new be;function da(s,e,t,r){const i=s*t+e*r,n=Math.sqrt(s*s+e*e)*Math.sqrt(t*t+r*r);let o=Math.acos(Math.max(-1,Math.min(1,i/n)));return s*r-e*t<0&&(o=-o),o}function Xh(s,e,t,r,i,n,o,a){if(e===0||t===0){s.lineTo(a.x,a.y);return}r=r*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const l=(o.x-a.x)/2,c=(o.y-a.y)/2,h=Math.cos(r)*l+Math.sin(r)*c,f=-Math.sin(r)*l+Math.cos(r)*c;let d=e*e,g=t*t;const p=h*h,y=f*f,m=p/d+y/g;if(m>1){const G=Math.sqrt(m);e=G*e,t=G*t,d=e*e,g=t*t}const P=d*y+g*p,E=(d*g-P)/P;let x=Math.sqrt(Math.max(0,E));i===n&&(x=-x);const S=x*e*f/t,_=-x*t*h/e,b=Math.cos(r)*S-Math.sin(r)*_+(o.x+a.x)/2,C=Math.sin(r)*S+Math.cos(r)*_+(o.y+a.y)/2,T=da(1,0,(h-S)/e,(f-_)/t),B=da((h-S)/e,(f-_)/t,(-h-S)/e,(-f-_)/t)%(Math.PI*2);s.ellipse(b,C,e,t,r,T,T+B,n===0)}const ae={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function ft(s,e,t=0){let a=0,l=!0,c="",h="";const f=[];function d(m,P,E){const x=new SyntaxError(`Unexpected character "${m}" at index ${P}.`);throw x.partial=E,x}function g(){c!==""&&(h===""?f.push(Number(c)):f.push(Number(c)*10**Number(h))),c="",h=""}let p;const y=s.length;for(let m=0;m<y;m++){if(p=s[m],Array.isArray(e)&&e.includes(f.length%t)&&ae.FLAGS.test(p)){a=1,c=p,g();continue}if(a===0){if(ae.WHITESPACE.test(p))continue;if(ae.DIGIT.test(p)||ae.SIGN.test(p)){a=1,c=p;continue}if(ae.POINT.test(p)){a=2,c=p;continue}ae.COMMA.test(p)&&(l&&d(p,m,f),l=!0)}if(a===1){if(ae.DIGIT.test(p)){c+=p;continue}if(ae.POINT.test(p)){c+=p,a=2;continue}if(ae.EXP.test(p)){a=3;continue}ae.SIGN.test(p)&&c.length===1&&ae.SIGN.test(c[0])&&d(p,m,f)}if(a===2){if(ae.DIGIT.test(p)){c+=p;continue}if(ae.EXP.test(p)){a=3;continue}ae.POINT.test(p)&&c[c.length-1]==="."&&d(p,m,f)}if(a===3){if(ae.DIGIT.test(p)){h+=p;continue}if(ae.SIGN.test(p)){if(h===""){h+=p;continue}h.length===1&&ae.SIGN.test(h)&&d(p,m,f)}}ae.WHITESPACE.test(p)?(g(),a=0,l=!1):ae.COMMA.test(p)?(g(),a=0,l=!0):ae.SIGN.test(p)?(g(),a=1,c=p):ae.POINT.test(p)?(g(),a=2,c=p):d(p,m,f)}return g(),f}function ur(s,e){return s-(e-s)}function pa(s,e){const t=new k,r=new k;for(let i=0,n=s.length;i<n;i++){const o=s[i];if(o.type==="m"||o.type==="M")o.type==="m"?t.add(o):t.copy(o),e.moveTo(t.x,t.y),r.copy(t);else if(o.type==="h"||o.type==="H")o.type==="h"?t.x+=o.x:t.x=o.x,e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="v"||o.type==="V")o.type==="v"?t.y+=o.y:t.y=o.y,e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="l"||o.type==="L")o.type==="l"?t.add(o):t.copy(o),e.lineTo(t.x,t.y),r.copy(t);else if(o.type==="c"||o.type==="C")o.type==="c"?(e.bezierCurveTo(t.x+o.x1,t.y+o.y1,t.x+o.x2,t.y+o.y2,t.x+o.x,t.y+o.y),r.x=t.x+o.x2,r.y=t.y+o.y2,t.add(o)):(e.bezierCurveTo(o.x1,o.y1,o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,t.copy(o));else if(o.type==="s"||o.type==="S")o.type==="s"?(e.bezierCurveTo(ur(t.x,r.x),ur(t.y,r.y),t.x+o.x2,t.y+o.y2,t.x+o.x,t.y+o.y),r.x=t.x+o.x2,r.y=t.y+o.y2,t.add(o)):(e.bezierCurveTo(ur(t.x,r.x),ur(t.y,r.y),o.x2,o.y2,o.x,o.y),r.x=o.x2,r.y=o.y2,t.copy(o));else if(o.type==="q"||o.type==="Q")o.type==="q"?(e.quadraticCurveTo(t.x+o.x1,t.y+o.y1,t.x+o.x,t.y+o.y),r.x=t.x+o.x1,r.y=t.y+o.y1,t.add(o)):(e.quadraticCurveTo(o.x1,o.y1,o.x,o.y),r.x=o.x1,r.y=o.y1,t.copy(o));else if(o.type==="t"||o.type==="T"){const a=ur(t.x,r.x),l=ur(t.y,r.y);r.x=a,r.y=l,o.type==="t"?(e.quadraticCurveTo(a,l,t.x+o.x,t.y+o.y),t.add(o)):(e.quadraticCurveTo(a,l,o.x,o.y),t.copy(o))}else if(o.type==="a"||o.type==="A"){const a=t.clone();if(o.type==="a"){if(o.x===0&&o.y===0)continue;t.add(o)}else{if(t.equals(o))continue;t.copy(o)}r.copy(t),Xh(e,o.rx,o.ry,o.angle,o.largeArcFlag,o.sweepFlag,a,t)}else o.type==="z"||o.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",o)}}function Hh(s){let e,t;const r=[];for(let i=0,n=s.length;i<n;i++){const o=s[i];switch(o.type){case"m":case"M":if(o.x.toFixed(4)===t?.x.toFixed(4)&&o.y.toFixed(4)===t?.y.toFixed(4))continue;r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y},e={x:o.x,y:o.y};break;case"h":case"H":r.push(`${o.type} ${o.x}`),t={x:o.x,y:t?.y??0};break;case"v":case"V":r.push(`${o.type} ${o.y}`),t={x:t?.x??0,y:o.y};break;case"l":case"L":r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"c":case"C":r.push(`${o.type} ${o.x1} ${o.y1} ${o.x2} ${o.y2} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"s":case"S":r.push(`${o.type} ${o.x2} ${o.y2} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"q":case"Q":r.push(`${o.type} ${o.x1} ${o.y1} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"t":case"T":r.push(`${o.type} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"a":case"A":r.push(`${o.type} ${o.rx} ${o.ry} ${o.angle} ${o.largeArcFlag} ${o.sweepFlag} ${o.x} ${o.y}`),t={x:o.x,y:o.y};break;case"z":case"Z":r.push(o.type),e&&(t={x:e.x,y:e.y});break}}return r.join(" ")}const Yh=/[a-df-z][^a-df-z]*/gi;function ga(s){const e=[],t=s.match(Yh);if(!t)return e;for(let r=0,i=t.length;r<i;r++){const n=t[r],o=n.charAt(0),a=n.slice(1).trim();let l;switch(o){case"m":case"M":l=ft(a);for(let c=0,h=l.length;c<h;c+=2)c===0?e.push({type:o,x:l[c],y:l[c+1]}):e.push({type:o==="m"?"l":"L",x:l[c],y:l[c+1]});break;case"h":case"H":l=ft(a);for(let c=0,h=l.length;c<h;c++)e.push({type:o,x:l[c]});break;case"v":case"V":l=ft(a);for(let c=0,h=l.length;c<h;c++)e.push({type:o,y:l[c]});break;case"l":case"L":l=ft(a);for(let c=0,h=l.length;c<h;c+=2)e.push({type:o,x:l[c],y:l[c+1]});break;case"c":case"C":l=ft(a);for(let c=0,h=l.length;c<h;c+=6)e.push({type:o,x1:l[c],y1:l[c+1],x2:l[c+2],y2:l[c+3],x:l[c+4],y:l[c+5]});break;case"s":case"S":l=ft(a);for(let c=0,h=l.length;c<h;c+=4)e.push({type:o,x2:l[c],y2:l[c+1],x:l[c+2],y:l[c+3]});break;case"q":case"Q":l=ft(a);for(let c=0,h=l.length;c<h;c+=4)e.push({type:o,x1:l[c],y1:l[c+1],x:l[c+2],y:l[c+3]});break;case"t":case"T":l=ft(a);for(let c=0,h=l.length;c<h;c+=2)e.push({type:o,x:l[c],y:l[c+1]});break;case"a":case"A":l=ft(a,[3,4],7);for(let c=0,h=l.length;c<h;c+=7)e.push({type:o,rx:l[c],ry:l[c+1],angle:l[c+2],largeArcFlag:l[c+3],sweepFlag:l[c+4],x:l[c+5],y:l[c+6]});break;case"z":case"Z":e.push({type:o});break;default:console.warn(n)}}return e}const ma="data:image/svg+xml;",ya=`${ma}base64,`,_a=`${ma}charset=utf8,`;function Fs(s){if(typeof s=="string"){let e;s.startsWith(ya)?(s=s.substring(ya.length,s.length),e=atob(s)):s.startsWith(_a)?(s=s.substring(_a.length,s.length),e=decodeURIComponent(s)):e=s;const t=new DOMParser().parseFromString(e,"text/xml"),r=t.querySelector("parsererror");if(r)throw new Error(`${r.textContent??"parser error"}
75
+ ${e}`);return t.documentElement}else return s}const Kh="px",Zh=90,va=["mm","cm","in","pt","pc","px"],ba={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function ee(s){let e="px";if(typeof s=="string")for(let r=0,i=va.length;r<i;r++){const n=va[r];if(s.endsWith(n)){e=n,s=s.substring(0,s.length-n.length);break}}let t;return t=ba[e][Kh],t<0&&(t=ba[e].in*Zh),t*Number.parseFloat(s)}const Jh=new be,Ai=new be,wa=new be,xa=new be;function Qh(s,e,t){if(!(s.hasAttribute("transform")||s.nodeName==="use"&&(s.hasAttribute("x")||s.hasAttribute("y"))))return null;const r=eu(s);return t.length>0&&r.premultiply(t[t.length-1]),e.copy(r),t.push(r),r}function eu(s){const e=new be,t=Jh;if(s.nodeName==="use"&&(s.hasAttribute("x")||s.hasAttribute("y"))&&e.translate(ee(s.getAttribute("x")),ee(s.getAttribute("y"))),s.hasAttribute("transform")){const r=s.getAttribute("transform").split(")");for(let i=r.length-1;i>=0;i--){const n=r[i].trim();if(n==="")continue;const o=n.indexOf("("),a=n.length;if(o>0&&o<a){const l=n.slice(0,o),c=ft(n.slice(o+1));switch(t.identity(),l){case"translate":if(c.length>=1){const h=c[0];let f=0;c.length>=2&&(f=c[1]),t.translate(h,f)}break;case"rotate":if(c.length>=1){let h=0,f=0,d=0;h=c[0]*Math.PI/180,c.length>=3&&(f=c[1],d=c[2]),Ai.makeTranslation(-f,-d),wa.makeRotation(h),xa.multiplyMatrices(wa,Ai),Ai.makeTranslation(f,d),t.multiplyMatrices(Ai,xa)}break;case"scale":c.length>=1&&t.scale(c[0],c[1]??c[0]);break;case"skewX":c.length===1&&t.set(1,Math.tan(c[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":c.length===1&&t.set(1,0,0,Math.tan(c[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":c.length===6&&t.set(c[0],c[2],c[4],c[1],c[3],c[5],0,0,1);break}}e.premultiply(t)}}return e}function tu(s){return new ge().arc(ee(s.getAttribute("cx")||0),ee(s.getAttribute("cy")||0),ee(s.getAttribute("r")||0),0,Math.PI*2)}function ru(s,e){if(!(!s.sheet||!s.sheet.cssRules||!s.sheet.cssRules.length))for(let t=0;t<s.sheet.cssRules.length;t++){const r=s.sheet.cssRules[t];if(r.type!==1)continue;const i=r.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim()),n={};for(let o=r.style.length,a=0;a<o;a++){const l=r.style.item(a);n[l]=r.style.getPropertyValue(l)}for(let o=0;o<i.length;o++)e[i[o]]=Object.assign(e[i[o]]||{},{...n})}}function iu(s){return new ge().ellipse(ee(s.getAttribute("cx")||0),ee(s.getAttribute("cy")||0),ee(s.getAttribute("rx")||0),ee(s.getAttribute("ry")||0),0,0,Math.PI*2)}function su(s){return new ge().moveTo(ee(s.getAttribute("x1")||0),ee(s.getAttribute("y1")||0)).lineTo(ee(s.getAttribute("x2")||0),ee(s.getAttribute("y2")||0))}function nu(s){const e=new ge,t=s.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const ou=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function au(s){const e=new ge;let t=0;return s.getAttribute("points")?.replace(ou,(r,i,n)=>{const o=ee(i),a=ee(n);return t===0?e.moveTo(o,a):e.lineTo(o,a),t++,r}),e.currentCurve.autoClose=!0,e}const lu=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function cu(s){const e=new ge;let t=0;return s.getAttribute("points")?.replace(lu,(r,i,n)=>{const o=ee(i),a=ee(n);return t===0?e.moveTo(o,a):e.lineTo(o,a),t++,r}),e.currentCurve.autoClose=!1,e}function hu(s){const e=ee(s.getAttribute("x")||0),t=ee(s.getAttribute("y")||0),r=ee(s.getAttribute("rx")||s.getAttribute("ry")||0),i=ee(s.getAttribute("ry")||s.getAttribute("rx")||0),n=ee(s.getAttribute("width")),o=ee(s.getAttribute("height")),a=1-.551915024494,l=new ge;return l.moveTo(e+r,t),l.lineTo(e+n-r,t),(r!==0||i!==0)&&l.bezierCurveTo(e+n-r*a,t,e+n,t+i*a,e+n,t+i),l.lineTo(e+n,t+o-i),(r!==0||i!==0)&&l.bezierCurveTo(e+n,t+o-i*a,e+n-r*a,t+o,e+n-r,t+o),l.lineTo(e+r,t+o),(r!==0||i!==0)&&l.bezierCurveTo(e+r*a,t+o,e,t+o-i*a,e,t+o-i),l.lineTo(e,t+i),(r!==0||i!==0)&&l.bezierCurveTo(e,t+i*a,e+r*a,t,e+r,t),l}function dt(s,e,t){e=Object.assign({},e);let r={};if(s.hasAttribute("class")){const c=s.getAttribute("class").split(/\s/).filter(Boolean).map(h=>h.trim());for(let h=0;h<c.length;h++)r=Object.assign(r,t[`.${c[h]}`])}s.hasAttribute("id")&&(r=Object.assign(r,t[`#${s.getAttribute("id")}`]));for(let c=s.style.length,h=0;h<c;h++){const f=s.style.item(h),d=s.style.getPropertyValue(f);e[f]=d,r[f]=d}function i(c,h,f=n){s.hasAttribute(c)&&(e[h]=f(s.getAttribute(c))),r[c]&&(e[h]=f(r[c]))}function n(c){return c.startsWith("url")&&console.warn("url access in attributes is not implemented."),c}function o(c){return Math.max(0,Math.min(1,ee(c)))}function a(c){return Math.max(0,ee(c))}function l(c){return c.split(" ").filter(h=>h!=="").map(h=>ee(h))}return i("fill","fill"),i("fill-opacity","fillOpacity",o),i("fill-rule","fillRule"),i("opacity","opacity",o),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",o),i("stroke-width","strokeWidth",a),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",a),i("stroke-dasharray","strokeDasharray",l),i("stroke-dashoffset","strokeDashoffset",ee),i("visibility","visibility"),e}function $s(s,e,t=[],r={}){if(s.nodeType!==1)return t;let i=!1,n=null,o={...e};switch(s.nodeName){case"svg":o=dt(s,o,r);break;case"style":ru(s,r);break;case"g":o=dt(s,o,r);break;case"path":o=dt(s,o,r),s.hasAttribute("d")&&(n=nu(s));break;case"rect":o=dt(s,o,r),n=hu(s);break;case"polygon":o=dt(s,o,r),n=au(s);break;case"polyline":o=dt(s,o,r),n=cu(s);break;case"circle":o=dt(s,o,r),n=tu(s);break;case"ellipse":o=dt(s,o,r),n=iu(s);break;case"line":o=dt(s,o,r),n=su(s);break;case"defs":i=!0;break;case"use":{o=dt(s,o,r);const d=(s.getAttributeNS("http://www.w3.org/1999/xlink","href")||s.getAttribute("href")||"").substring(1),g=s.viewportElement?.getElementById(d);g?$s(g,o,t,r):console.warn(`'use node' references non-existent node id: ${d}`);break}default:console.warn(s);break}if(o.display==="none")return t;const a=new be,l=[],c=Qh(s,a,l);n&&(n.applyTransform(a),t.push(n),n.style={...o});const h=s.childNodes;for(let f=0,d=h.length;f<d;f++){const g=h[f];i&&g.nodeName!=="style"&&g.nodeName!=="defs"||$s(g,o,t,r)}return c&&(l.pop(),l.length>0?a.copy(l[l.length-1]):a.identity()),t}function zs(s){const e=Fs(s);return new Tt($s(e,{}),e.getAttribute("viewBox")?.trim().split(" ").map(t=>Number(t)))}function Pa(s,e,t,r,i){const n=(r-e)*.5,o=(i-t)*.5,a=s*s,l=s*a;return(2*t-2*r+n+o)*l+(-3*t+3*r-2*n-o)*a+n*s+t}function uu(s,e){const t=1-s;return t*t*t*e}function fu(s,e){const t=1-s;return 3*t*t*s*e}function du(s,e){return 3*(1-s)*s*s*e}function pu(s,e){return s*s*s*e}function Sa(s,e,t,r,i){return uu(s,e)+fu(s,t)+du(s,r)+pu(s,i)}function Ca(s,e={}){let{vertices:t=[],indices:r=[],holes:i=[],verticesStride:n=2,verticesOffset:o=t.length/n,indicesOffset:a=r.length}=e;const l=Mh(s,i,2);if(l.length){for(let h=0;h<l.length;h+=3)r[a++]=l[h]+o,r[a++]=l[h+1]+o,r[a++]=l[h+2]+o;let c=o*n;for(let h=0;h<s.length;h+=2)t[c]=s[h],t[c+1]=s[h+1],c+=n}return{vertices:t,indices:r}}const gu=8,Oi=11920929e-14,mu=1;function yu(s,e,t,r,i,n,o,a,l=.5,c=[]){const f=Math.min(.99,Math.max(0,l));let d=(mu-f)/1;return d*=d,Vs(s,e,t,r,i,n,o,a,c,d,0),c.push(o,a),c}function Vs(s,e,t,r,i,n,o,a,l,c,h){if(h>gu)return;const f=(s+t)/2,d=(e+r)/2,g=(t+i)/2,p=(r+n)/2,y=(i+o)/2,m=(n+a)/2,P=(f+g)/2,E=(d+p)/2,x=(g+y)/2,S=(p+m)/2,_=(P+x)/2,b=(E+S)/2;if(h>0){let C=o-s,T=a-e;const B=Math.abs((t-o)*T-(r-a)*C),G=Math.abs((i-o)*T-(n-a)*C);if(B>Oi&&G>Oi){if((B+G)*(B+G)<=c*(C*C+T*T)){l.push(_,b);return}}else if(B>Oi){if(B*B<=c*(C*C+T*T)){l.push(_,b);return}}else if(G>Oi){if(G*G<=c*(C*C+T*T)){l.push(_,b);return}}else if(C=_-(s+o)/2,T=b-(e+a)/2,C*C+T*T<=c){l.push(_,b);return}}Vs(s,e,f,d,P,E,_,b,l,c,h+1),Vs(_,b,x,S,y,m,o,a,l,c,h+1)}const _u=8,vu=11920929e-14,bu=1;function wu(s,e,t,r,i,n,o=.5,a=[]){const c=Math.min(.99,Math.max(0,o));let h=(bu-c)/1;return h*=h,Gs(a,s,e,t,r,i,n,h,0),a.push(i,n),a}function Gs(s,e,t,r,i,n,o,a,l){if(l>_u)return;const c=(e+r)/2,h=(t+i)/2,f=(r+n)/2,d=(i+o)/2,g=(c+f)/2,p=(h+d)/2;let y=n-e,m=o-t;const P=Math.abs((r-n)*m-(i-o)*y);if(P>vu){if(P*P<=a*(y*y+m*m)){s.push(g,p);return}}else if(y=g-(e+n)/2,m=p-(t+o)/2,y*y+m*m<=a){s.push(g,p);return}Gs(s,e,t,c,h,g,p,a,l+1),Gs(s,g,p,f,d,n,o,a,l+1)}function xu(s){return s.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Pu(s,e,t,r){const i=e.clone().sub(s),n=r.clone().sub(t),o=t.clone().sub(s),a=i.cross(n);if(a===0)return new k((s.x+t.x)/2,(s.y+t.y)/2);const l=o.cross(n)/a;return Math.abs(l)>1?new k((s.x+t.x)/2,(s.y+t.y)/2):new k(s.x+l*i.x,s.y+l*i.y)}function Su(s){let e=0;const t=s.length/2;for(let r=0;r<t;r++){const i=s[2*r],n=s[2*r+1],o=(r+1)%t,a=s[2*o],l=s[2*o+1];e+=(a-i)*(l+n)}return e}function Ta(s,e,t,r,i,n){return(t-s)*(n-e)-(i-s)*(r-e)}function Cu(s,e,t){const r=t.length;let i=0;for(let n=0,o=r-2;n<r;o=n,n+=2){const a=t[n],l=t[n+1],c=t[o],h=t[o+1];l<=e?h>e&&Ta(c,h,a,l,s,e)>0&&i++:h<=e&&Ta(c,h,a,l,s,e)<0&&i--}return i}function Tu(s){const e=s.length,t=s.map((r,i)=>({index:i,parentIndex:null,wn:0}));for(let r=0;r<e;r++){let i=null;if(Su(s[r])<0)continue;const n=[s[r][0],s[r][1]];for(let o=0;o<e;o++){if(r===o)continue;let a=0;for(let c=0;c<n.length&&(a=a||Cu(n[c],n[c+1],s[o]),!a);c+=2);const l=Math.abs(a);l!==0&&(!i||l>Math.abs(i.wn))&&(i={idx:o,wn:a})}i&&(t[r].parentIndex=i.idx,t[r].wn=i.wn)}return t}function Eu(s,e){const t=1-s;return t*t*e}function Mu(s,e){return 2*(1-s)*s*e}function Au(s,e){return s*s*e}function Ea(s,e,t,r){return Eu(s,e)+Mu(s,t)+Au(s,r)}const Ou=1e-4,Ma=1e-4;function ku(s,e={}){const{vertices:t=[],indices:r=[],lineStyle:i={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:n=!1,closed:o=!0}=e,a=Ou;if(s.length===0)return{vertices:t,indices:r};const l=i;let c=l.alignment;if(i.alignment!==.5){let O=Du(s);n&&(O*=-1),c=(c-.5)*O+.5}const h={x:s[0],y:s[1]},f={x:s[s.length-2],y:s[s.length-1]},d=o,g=Math.abs(h.x-f.x)<a&&Math.abs(h.y-f.y)<a;if(d){s=s.slice(),g&&(s.pop(),s.pop(),f.x=s[s.length-2],f.y=s[s.length-1]);const O=(h.x+f.x)*.5,j=(f.y+h.y)*.5;s.unshift(O,j),s.push(O,j)}const p=t,y=s.length/2;let m=s.length;const P=p.length/2,E=l.width/2,x=E*E,S=l.miterLimit*l.miterLimit;let _=s[0],b=s[1],C=s[2],T=s[3],B=0,G=0,R=-(b-T),U=_-C,V=0,L=0,D=Math.sqrt(R*R+U*U);R/=D,U/=D,R*=E,U*=E;const H=c,I=(1-H)*2,N=H*2;d||(l.cap==="round"?m+=Yt(_-R*(I-N)*.5,b-U*(I-N)*.5,_-R*I,b-U*I,_+R*N,b+U*N,p,!0)+2:l.cap==="square"&&(m+=Aa(_,b,R,U,I,N,!0,p))),p.push(_-R*I,b-U*I),p.push(_+R*N,b+U*N);for(let O=1;O<y-1;++O){_=s[(O-1)*2],b=s[(O-1)*2+1],C=s[O*2],T=s[O*2+1],B=s[(O+1)*2],G=s[(O+1)*2+1],R=-(b-T),U=_-C,D=Math.sqrt(R*R+U*U),R/=D,U/=D,R*=E,U*=E,V=-(T-G),L=C-B,D=Math.sqrt(V*V+L*L),V/=D,L/=D,V*=E,L*=E;const j=C-_,A=b-T,M=C-B,F=G-T,z=j*M+A*F,Y=A*M-F*j,J=Y<0;if(Math.abs(Y)<.001*Math.abs(z)){p.push(C-R*I,T-U*I),p.push(C+R*N,T+U*N),z>=0&&(l.join==="round"?m+=Yt(C,T,C-R*I,T-U*I,C-V*I,T-L*I,p,!1)+4:m+=2,p.push(C-V*N,T-L*N),p.push(C+V*I,T+L*I));continue}const oe=(-R+_)*(-U+T)-(-R+C)*(-U+b),wt=(-V+B)*(-L+T)-(-V+C)*(-L+G),Ze=(j*wt-M*oe)/Y,Be=(F*oe-A*wt)/Y,$e=(Ze-C)*(Ze-C)+(Be-T)*(Be-T),Se=C+(Ze-C)*I,ze=T+(Be-T)*I,at=C-(Ze-C)*N,lt=T-(Be-T)*N,Je=Math.min(j*j+A*A,M*M+F*F),cc=J?I:N,Um=Je+cc*cc*x;$e<=Um?l.join==="bevel"||$e/x>S?(J?(p.push(Se,ze),p.push(C+R*N,T+U*N),p.push(Se,ze),p.push(C+V*N,T+L*N)):(p.push(C-R*I,T-U*I),p.push(at,lt),p.push(C-V*I,T-L*I),p.push(at,lt)),m+=2):l.join==="round"?J?(p.push(Se,ze),p.push(C+R*N,T+U*N),m+=Yt(C,T,C+R*N,T+U*N,C+V*N,T+L*N,p,!0)+4,p.push(Se,ze),p.push(C+V*N,T+L*N)):(p.push(C-R*I,T-U*I),p.push(at,lt),m+=Yt(C,T,C-R*I,T-U*I,C-V*I,T-L*I,p,!1)+4,p.push(C-V*I,T-L*I),p.push(at,lt)):(p.push(Se,ze),p.push(at,lt)):(p.push(C-R*I,T-U*I),p.push(C+R*N,T+U*N),l.join==="round"?J?m+=Yt(C,T,C+R*N,T+U*N,C+V*N,T+L*N,p,!0)+2:m+=Yt(C,T,C-R*I,T-U*I,C-V*I,T-L*I,p,!1)+2:l.join==="miter"&&$e/x<=S&&(J?(p.push(at,lt),p.push(at,lt)):(p.push(Se,ze),p.push(Se,ze)),m+=2),p.push(C-V*I,T-L*I),p.push(C+V*N,T+L*N),m+=2)}_=s[(y-2)*2],b=s[(y-2)*2+1],C=s[(y-1)*2],T=s[(y-1)*2+1],R=-(b-T),U=_-C,D=Math.sqrt(R*R+U*U),R/=D,U/=D,R*=E,U*=E,p.push(C-R*I,T-U*I),p.push(C+R*N,T+U*N),d||(l.cap==="round"?m+=Yt(C-R*(I-N)*.5,T-U*(I-N)*.5,C-R*I,T-U*I,C+R*N,T+U*N,p,!1)+2:l.cap==="square"&&(m+=Aa(C,T,R,U,I,N,!1,p)));const $=Ma*Ma;for(let O=P;O<m+P-2;++O)_=p[O*2],b=p[O*2+1],C=p[(O+1)*2],T=p[(O+1)*2+1],B=p[(O+2)*2],G=p[(O+2)*2+1],!(Math.abs(_*(T-G)+C*(G-b)+B*(b-T))<$)&&r.push(O,O+1,O+2);return{vertices:t,indices:r}}function Du(s){const e=s.length;if(e<6)return 1;let t=0;for(let r=0,i=s[e-2],n=s[e-1];r<e;r+=2){const o=s[r],a=s[r+1];t+=(o-i)*(a+n),i=o,n=a}return t<0?-1:1}function Aa(s,e,t,r,i,n,o,a){const l=s-t*i,c=e-r*i,h=s+t*n,f=e+r*n;let d,g;o?(d=r,g=-t):(d=-r,g=t);const p=l+d,y=c+g,m=h+d,P=f+g;return a.push(p,y),a.push(m,P),2}function Yt(s,e,t,r,i,n,o,a){const l=t-s,c=r-e;let h=Math.atan2(l,c),f=Math.atan2(i-s,n-e);a&&h<f?h+=Math.PI*2:!a&&h>f&&(f+=Math.PI*2);let d=h;const g=f-h,p=Math.abs(g),y=Math.sqrt(l*l+c*c),m=(15*p*Math.sqrt(y)/Math.PI>>0)+1,P=g/m;if(d+=P,a){o.push(s,e),o.push(t,r);for(let E=1,x=d;E<m;E++,x+=P)o.push(s,e),o.push(s+Math.sin(x)*y,e+Math.cos(x)*y);o.push(s,e),o.push(i,n)}else{o.push(t,r),o.push(s,e);for(let E=1,x=d;E<m;E++,x+=P)o.push(s+Math.sin(x)*y,e+Math.cos(x)*y),o.push(s,e);o.push(i,n),o.push(s,e)}return m*2}class fr{arcLengthDivision=200;_arcLengths;getPointAt(e,t=new k){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){return!1}getControlPointRefs(){return[]}applyTransform(e){const t=typeof e=="function";return this.getControlPointRefs().forEach(r=>{t?e(r):r.applyMatrix3(e)}),this}getUnevenVertices(e=5,t=[]){const r=new k;for(let i=0,n=Math.max(1,e)-1;i<=n;i++)this.getPoint(i/n,r),t.push(r.x,r.y);return t}getSpacedVertices(e=5,t=[]){const r=new k;for(let i=0,n=Math.max(1,e)-1;i<=n;i++)this.getPointAt(i/n,r),t.push(r.x,r.y);return t}getAdaptiveVertices(e=[]){return this.getUnevenVertices(5,e)}_verticesToPoints(e,t=[]){for(let r=0,i=e.length;r<i;r+=2){const n=e[r],o=e[r+1];t.push(new k(n,o))}return t}getSpacedPoints(e,t=[]){const r=this.getSpacedVertices(e);return this._verticesToPoints(r,t),t}getUnevenPoints(e,t=[]){const r=this.getUnevenVertices(e);return this._verticesToPoints(r,t),t}getAdaptivePoints(e=[]){const t=this.getAdaptiveVertices();return this._verticesToPoints(t,e),e}getPoints(e,t=[]){let r;return e?r=this.getUnevenVertices(e):r=this.getAdaptiveVertices(),this._verticesToPoints(r,t),t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const e=this.arcLengthDivision,t=[0];for(let r=0,i=this.getPoint(0),n=1;n<=e;n++){const o=this.getPoint(n/e);r+=o.distanceTo(i),t.push(r),i=o}this._arcLengths=t}getUToTMapping(e,t){const r=this.getLengths(),i=r.length,n=t??e*r[i-1];if(i<2)return n/r[0];let o=0,a=0,l=i-1,c;for(;a<=l;)if(o=Math.floor(a+(l-a)/2),c=r[o]-n,c<0)a=o+1;else if(c>0)l=o-1;else{l=o;break}if(o=l,r[o]===n)return o/(i-1);const h=r[o],d=r[o+1]-h,g=(n-h)/d;return(o+g)/(i-1)}getTangent(e,t=new k){const i=Math.max(0,e-1e-4),n=Math.min(1,e+1e-4);return t.copy(this.getPoint(n).sub(this.getPoint(i)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new k){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let r=0,i=1,n=(r+i)/2;for(;i-r>t;){n=(r+i)/2;const o=this.getPoint(n);if(o.distanceTo(e)<t)return n;o.x<e.x?r=n:i=n}return n}getMinMax(e=k.MAX,t=k.MIN){const r=this.getPoints();for(let i=0,n=r.length;i<n;i++){const o=r[i];e.min(o),t.max(o)}return{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new Z(e.x,e.y,t.x-e.x,t.y-e.y)}getFillVertices(e){return this.getAdaptiveVertices()}fillTriangulate(e){return Ca(this.getFillVertices(e),e)}strokeTriangulate(e){return ku(this.getAdaptiveVertices(),e)}toCommands(){const e=[],t=this.getPoints();for(let r=0,i=t.length;r<i;r++){const n=t[r];r===0?e.push({type:"M",x:n.x,y:n.y}):e.push({type:"L",x:n.x,y:n.y})}return e}toData(){return Hh(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const Iu=new be,Oa=new be,ka=new be,ki=new k;class js extends fr{constructor(e=new k,t=new k,r=new k,i=0,n=0,o=Math.PI*2,a=!1){super(),this._center=e,this._radius=t,this._diff=r,this.rotate=i,this.startAngle=n,this.endAngle=o,this.clockwise=a}get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}isClockwise(){return this.clockwise}_getDeltaAngle(){const e=Math.PI*2;let t=this.endAngle-this.startAngle;const r=Math.abs(t)<Number.EPSILON;return t=(t%e+e)%e,r?t=0:this.clockwise||(t=t===0?-e:t-e),t}getPoint(e,t=new k){const r=this._getDeltaAngle(),i=this.startAngle+e*r;let n=this.cx+this.rx*Math.cos(i),o=this.cy+this.ry*Math.sin(i);if(this.rotate!==0){const a=Math.cos(this.rotate),l=Math.sin(this.rotate),c=n-this.cx,h=o-this.cy;n=c*a-h*l+this.cx,o=c*l+h*a+this.cy}return t.set(n,o)}toCommands(){const{cx:e,cy:t,rx:r,ry:i,startAngle:n,endAngle:o,clockwise:a,rotate:l}=this,c=e+r*Math.cos(n)*Math.cos(l)-i*Math.sin(n)*Math.sin(l),h=t+r*Math.cos(n)*Math.sin(l)+i*Math.sin(n)*Math.cos(l),f=Math.abs(n-o),d=f>Math.PI?1:0,g=a?1:0,p=l*180/Math.PI;if(f>=2*Math.PI){const y=n+Math.PI,m=e+r*Math.cos(y)*Math.cos(l)-i*Math.sin(y)*Math.sin(l),P=t+r*Math.cos(y)*Math.sin(l)+i*Math.sin(y)*Math.cos(l);return[{type:"M",x:c,y:h},{type:"A",rx:r,ry:i,angle:p,largeArcFlag:0,sweepFlag:g,x:m,y:P},{type:"A",rx:r,ry:i,angle:p,largeArcFlag:0,sweepFlag:g,x:c,y:h}]}else{const y=e+r*Math.cos(o)*Math.cos(l)-i*Math.sin(o)*Math.sin(l),m=t+r*Math.cos(o)*Math.sin(l)+i*Math.sin(o)*Math.cos(l);return[{type:"M",x:c,y:h},{type:"A",rx:r,ry:i,angle:p,largeArcFlag:d,sweepFlag:g,x:y,y:m}]}}drawTo(e){const{cx:t,cy:r,rx:i,ry:n,rotate:o,startAngle:a,endAngle:l,clockwise:c}=this;return e.ellipse(t,r,i,n,o,a,l,!c),this}applyTransform(e){return ki.set(this.cx,this.cy),ki.applyMatrix3(e),this.cx=ki.x,this.cy=ki.y,Bu(e)?Ru(this,e):Uu(this,e),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(e=[]){const{cx:t,cy:r,rx:i,ry:n,dx:o,dy:a,startAngle:l,endAngle:c,clockwise:h,rotate:f}=this,d=!h;let g=Math.abs(l-c);(!d&&l>c||d&&c>l)&&(g=2*Math.PI-g);const p=Math.max(12,Math.floor(12*i**(1/3)*(g/Math.PI)));let y=g/p,m=l;y*=d?-1:1;const P=Math.cos(d?f:-f),E=Math.sin(d?f:-f);for(let x=0;x<p+1;x++){const S=o+Math.cos(m)*i,_=a+Math.sin(m)*n,b=S*P-_*E,C=S*E+_*P;e.push(t+b,r+C),m+=y}return e}_getAdaptiveVerticesByCircle(e=[]){const{cx:t,cy:r,rx:i,ry:n,dx:o,dy:a,rotate:l,clockwise:c}=this;if(!(i>=0&&n>=0&&o>=0&&a>=0))return e;const h=Math.ceil(2.3*Math.sqrt(i+n)),f=h*8+(o?4:0)+(a?4:0),d=[];if(f===0)return e;{const y=d.length;if(h===0)d[y]=d[y+6]=t+o,d[y+1]=d[y+3]=r+a,d[y+2]=d[y+4]=t-o,d[y+5]=d[y+7]=r-a;else{let m=y,P=y+h*4+(o?2:0)+2,E=P,x=f,S=o+i,_=a,b=t+S,C=t-S,T=r+_;if(d[m++]=b,d[m++]=T,d[--P]=T,d[--P]=C,a){const G=r-_;d[E++]=C,d[E++]=G,d[--x]=G,d[--x]=b}for(let G=1;G<h;G++){const R=Math.PI/2*(G/h),U=o+Math.cos(R)*i,V=a+Math.sin(R)*n,L=t+U,D=t-U,H=r+V,I=r-V;d[m++]=L,d[m++]=H,d[--P]=H,d[--P]=D,d[E++]=D,d[E++]=I,d[--x]=I,d[--x]=L}S=o,_=a+n,b=t+S,C=t-S,T=r+_;const B=r-_;d[m++]=b,d[m++]=T,d[--x]=B,d[--x]=b,o&&(d[m++]=C,d[m++]=T,d[--x]=B,d[--x]=C)}}const g=Math.cos(c?-l:l),p=Math.sin(c?-l:l);for(let y=0;y<d.length;y+=2){const m=d[y],P=d[y+1],E=m-t,x=P-r,S=E*g-x*p,_=E*p+x*g;e.push(t+S,r+_)}return e}getAdaptiveVertices(e=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(e):this._getAdaptiveVerticesByArc(e)}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}}function Ru(s,e){const t=s.rx,r=s.ry,i=Math.cos(s.rotate),n=Math.sin(s.rotate),o=new k(t*i,t*n),a=new k(-r*n,r*i),l=o.applyMatrix3(e),c=a.applyMatrix3(e),h=Iu.set(l.x,c.x,0,l.y,c.y,0,0,0,1),f=Oa.copy(h).invert(),p=ka.copy(f).transpose().multiply(f).elements,y=Lu(p[0],p[1],p[4]),m=Math.sqrt(y.rt1),P=Math.sqrt(y.rt2);if(s.rx=1/m,s.ry=1/P,s.rotate=Math.atan2(y.sn,y.cs),!((s.endAngle-s.startAngle)%(2*Math.PI)<Number.EPSILON)){const x=Oa.set(m,0,0,0,P,0,0,0,1),S=ka.set(y.cs,y.sn,0,-y.sn,y.cs,0,0,0,1),_=x.multiply(S).multiply(h),b=C=>{const{x:T,y:B}=new k(Math.cos(C),Math.sin(C)).applyMatrix3(_);return Math.atan2(B,T)};s.startAngle=b(s.startAngle),s.endAngle=b(s.endAngle),Da(e)&&(s.clockwise=!s.clockwise)}}function Uu(s,e){const t=Ia(e),r=Ra(e);s.rx*=t,s.ry*=r;const i=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);s.rotate+=i,Da(e)&&(s.startAngle*=-1,s.endAngle*=-1,s.clockwise=!s.clockwise)}function Da(s){const e=s.elements;return e[0]*e[4]-e[1]*e[3]<0}function Bu(s){const e=s.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const r=Ia(s),i=Ra(s);return Math.abs(t/(r*i))>Number.EPSILON}function Ia(s){const e=s.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Ra(s){const e=s.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function Lu(s,e,t){let r,i,n,o,a;const l=s+t,c=s-t,h=Math.sqrt(c*c+4*e*e);return l>0?(r=.5*(l+h),a=1/r,i=s*a*t-e*a*e):l<0?i=.5*(l-h):(r=.5*h,i=-.5*h),c>0?n=c+h:n=c-h,Math.abs(n)>2*Math.abs(e)?(a=-2*e/n,o=1/Math.sqrt(1+a*a),n=a*o):Math.abs(e)===0?(n=1,o=0):(a=-.5*n/e,n=1/Math.sqrt(1+a*a),o=a*n),c>0&&(a=n,n=-o,o=a),{rt1:r,rt2:i,cs:n,sn:o}}class Nu extends js{constructor(e=0,t=0,r=1,i=0,n=Math.PI*2,o=!1){super(new k(e,t),new k(r,r),new k,0,i,n,o)}drawTo(e){const{cx:t,cy:r,rx:i,startAngle:n,endAngle:o,clockwise:a}=this;return e.arc(t,r,i,n,o,!a),this}}class Ct extends fr{constructor(e=new k,t=new k){super(),this.p1=e,this.p2=t}static from(e,t,r,i){return new Ct(new k(e,t),new k(r,i))}getPoint(e,t=new k){return e===1?t.copy(this.p2):t.copy(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new k){return this.getPoint(e,t)}getTangent(e,t=new k){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new k){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=k.MAX,t=k.MIN){const{p1:r,p2:i}=this;return e.x=Math.min(e.x,r.x,i.x),e.y=Math.min(e.y,r.y,i.y),t.x=Math.max(t.x,r.x,i.x),t.y=Math.max(t.y,r.y,i.y),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,p2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}getFillVertices(e={}){const t=Math.min(this.p1.x,this.p2.x),r=Math.max(this.p1.x,this.p2.x),i=Math.min(this.p1.y,this.p2.y),n=Math.max(this.p1.y,this.p2.y),o=t,a=i,l=r-t||e.style?.strokeWidth||0,c=n-i||e.style?.strokeWidth||0;return[o,a,o+l,a,o+l,a+c,o,a+c]}drawTo(e){const{p1:t,p2:r}=this;return e.lineTo(t.x,t.y),e.lineTo(r.x,r.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.p2.copy(e.p2),this}}class Lr extends fr{constructor(e=[]){super(),this.curves=e}getFlatCurves(){return this.curves.flatMap(e=>e instanceof Lr?e.getFlatCurves():e)}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new k){const r=e*this.getLength(),i=this.getLengths();let n=0;for(;n<i.length;){if(i[n]>=r){const o=i[n]-r,a=this.curves[n],l=a.getLength();return a.getPointAt(l===0?0:1-o/l,t)}n++}return t}updateLengths(){const e=[];for(let t=0,r=0,i=this.curves.length;t<i;t++)r+=this.curves[t].getLength(),e.push(r);this._arcLengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(e,t){const r=[e[t-1],e[t]],i=[e[t+1],e[t+2]];return r[0]===i[0]&&r[1]===i[1]&&e.splice(t+1,2),e}getSpacedVertices(e=5,t=[]){let r;return this.curves.forEach(i=>{i.getSpacedVertices(e,t),r&&this._removeNextPointIfEqualPrevPoint(t,r),r=t.length-1}),t}getAdaptiveVertices(e=[]){let t;return this.curves.forEach(r=>{r.getAdaptiveVertices(e),t&&this._removeNextPointIfEqualPrevPoint(e,t),t=e.length-1}),e}strokeTriangulate(e){return this.curves.length===1?this.curves[0].strokeTriangulate(e):super.strokeTriangulate(e)}getFillVertices(e){if(this.curves.length===1)return this.curves[0].getFillVertices(e);{const t=[];let r;return this.curves.forEach(i=>{let n;i instanceof Ct?n=i.getAdaptiveVertices():n=i.getFillVertices(e),t.push(...n),r&&this._removeNextPointIfEqualPrevPoint(t,r),r=t.length-1}),t}}applyTransform(e){return this.curves.forEach(t=>t.applyTransform(e)),this}getMinMax(e=k.MAX,t=k.MIN){return this.curves.forEach(r=>r.getMinMax(e,t)),{min:e.finite(),max:t.finite()}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new Z(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){const t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this}copy(e){return super.copy(e),this.curves=e.curves.map(t=>t.clone()),this}}class Ws extends fr{constructor(e=new k,t=new k,r=new k,i=new k){super(),this.p1=e,this.cp1=t,this.cp2=r,this.p2=i}static from(e,t,r,i,n,o,a,l){return new Ws(new k(e,t),new k(r,i),new k(n,o),new k(a,l))}getPoint(e,t=new k){const{p1:r,cp1:i,cp2:n,p2:o}=this;return t.set(Sa(e,r.x,i.x,n.x,o.x),Sa(e,r.y,i.y,n.y,o.y))}getAdaptiveVertices(e=[]){return yu(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(e,t,r){const i=t*t-4*e*r;if(i<0)return[];const n=Math.sqrt(i),o=(-t+n)/(2*e),a=(-t-n)/(2*e);return[o,a].filter(l=>l>=0&&l<=1)}getMinMax(e=k.MAX,t=k.MIN){const{p1:r,cp1:i,cp2:n,p2:o}=this,a=this._solveQuadratic(3*(i.x-r.x),6*(n.x-i.x),3*(o.x-n.x)),l=this._solveQuadratic(3*(i.y-r.y),6*(n.y-i.y),3*(o.y-n.y)),c=[0,1,...a,...l];return((f,d)=>{for(const g of f)for(let p=0;p<=d;p++){const y=p/d-.5,m=Math.min(1,Math.max(0,g+y)),P=this.getPoint(m);e.x=Math.min(e.x,P.x),e.y=Math.min(e.y,P.y),t.x=Math.max(t.x,P.x),t.y=Math.max(t.y,P.y)}})(c,10),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,cp1:t,cp2:r,p2:i}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:r.x,y2:r.y,x:i.x,y:i.y}]}drawTo(e){const{p1:t,cp1:r,cp2:i,p2:n}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(r.x,r.y,i.x,i.y,n.x,n.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp1.copy(e.cp1),this.cp2.copy(e.cp2),this.p2.copy(e.p2),this}}class Fu extends js{constructor(e=0,t=0,r=1,i=1,n=0,o=0,a=Math.PI*2,l=!1){super(new k(e,t),new k(r,i),new k,n,o,a,l)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class $u extends Lr{}class qs extends fr{constructor(e=new k,t=new k,r=new k){super(),this.p1=e,this.cp=t,this.p2=r}static from(e,t,r,i,n,o){return new qs(new k(e,t),new k(r,i),new k(n,o))}getPoint(e,t=new k){const{p1:r,cp:i,p2:n}=this;return t.set(Ea(e,r.x,i.x,n.x),Ea(e,r.y,i.y,n.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(e=[]){return wu(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=k.MAX,t=k.MIN){const{p1:r,cp:i,p2:n}=this,o=.5*(r.x+i.x),a=.5*(r.y+i.y),l=.5*(r.x+n.x),c=.5*(r.y+n.y);return e.x=Math.min(e.x,r.x,n.x,o,l),e.y=Math.min(e.y,r.y,n.y,a,c),t.x=Math.max(t.x,r.x,n.x,o,l),t.y=Math.max(t.y,r.y,n.y,a,c),{min:e.finite(),max:t.finite()}}toCommands(){const{p1:e,cp:t,p2:r}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:r.x,y:r.y}]}drawTo(e){const{p1:t,cp:r,p2:i}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(r.x,r.y,i.x,i.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp.copy(e.cp),this.p2.copy(e.p2),this}}class zu extends $u{constructor(e=0,t=0,r=0,i=0){super(),this.x=e,this.y=t,this.width=r,this.height=i,this.update()}update(){const{x:e,y:t,width:r,height:i}=this,n=[new k(e,t),new k(e+r,t),new k(e+r,t+i),new k(e,t+i)];return this.curves=[new Ct(n[0],n[1]),new Ct(n[1],n[2]),new Ct(n[2],n[3]),new Ct(n[3],n[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}getFillVertices(e={}){const{x:t,y:r,width:i,height:n}=this;return[t,r,t+i,r,t+i,r+n,t,r+n]}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}}class Vu extends js{constructor(e=0,t=0,r=1,i=1,n=1){super(),this.x=e,this.y=t,this.width=r,this.height=i,this.radius=n,this.update()}update(){const{x:e,y:t,width:r,height:i,radius:n}=this,o=r/2,a=i/2,l=e+o,c=t+a,h=Math.max(0,Math.min(n,Math.min(o,a))),f=h;return this._center=new k(l,c),this._radius=new k(h,f),this._diff=new k(o-h,a-f),this}drawTo(e){const{x:t,y:r,width:i,height:n,radius:o}=this;return e.roundRect(t,r,i,n,o),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}}class Gu extends fr{constructor(e=[]){super(),this.points=e}getPoint(e,t=new k){const{points:r}=this,i=(r.length-1)*e,n=Math.floor(i),o=i-n,a=r[n===0?n:n-1],l=r[n],c=r[n>r.length-2?r.length-1:n+1],h=r[n>r.length-3?r.length-1:n+2];return t.set(Pa(o,a.x,l.x,c.x,h.x),Pa(o,a.y,l.y,c.y,h.y)),t}getControlPointRefs(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t<r;t++)this.points.push(e.points[t].clone());return this}}class Di extends Lr{startPoint;currentPoint;autoClose=!1;constructor(e){super(),e&&this.addPoints(e)}addPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,r=e.length;t<r;t++){const{x:i,y:n}=e[t];this.lineTo(i,n)}return this}addCommands(e){return pa(e,this),this}addData(e){return this.addCommands(ga(e)),this}_closeVertices(e){return this.autoClose&&e.length>=4&&e[0]!==e[e.length-2]&&e[1]!==e[e.length-1]&&e.push(e[0],e[1]),e}getUnevenVertices(e=40,t=[]){return this._closeVertices(super.getUnevenVertices(e,t))}getSpacedVertices(e=40,t=[]){return this._closeVertices(super.getSpacedVertices(e,t))}getAdaptiveVertices(e=[]){return this._closeVertices(super.getAdaptiveVertices(e))}getFillVertices(e){return this._closeVertices(super.getFillVertices(e))}_setCurrentPoint(e){return this.currentPoint=new k(e.x,e.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(e){if(this.curves.length>0){const t=e.getPoint(0);(!this.currentPoint||!t.equals(this.currentPoint))&&this.lineTo(t.x,t.y)}return this}closePath(){const e=this.startPoint;if(e){const t=this.currentPoint;t&&!e.equals(t)&&(this.curves.push(new Ct(t.clone(),e.clone())),t.copy(e)),this.startPoint=void 0}return this}moveTo(e,t){return this.currentPoint=new k(e,t),this.startPoint=this.currentPoint.clone(),this}lineTo(e,t){const r=this.currentPoint;return r?.equals({x:e,y:t})||this.curves.push(Ct.from(r?.x??0,r?.y??0,e,t)),this._setCurrentPoint({x:e,y:t}),this}bezierCurveTo(e,t,r,i,n,o){const a=this.currentPoint;return a?.equals({x:n,y:o})||this.curves.push(Ws.from(a?.x??0,a?.y??0,e,t,r,i,n,o)),this._setCurrentPoint({x:n,y:o}),this}quadraticCurveTo(e,t,r,i){const n=this.currentPoint;return n?.equals({x:r,y:i})||this.curves.push(qs.from(n?.x??0,n?.y??0,e,t,r,i)),this._setCurrentPoint({x:r,y:i}),this}arc(e,t,r,i,n,o){const a=new Nu(e,t,r,i,n,!o);return this._connetLineTo(a),this.curves.push(a),this._setCurrentPoint(a.getPoint(1)),this}relativeArc(e,t,r,i,n,o){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.arc(e,t,r,i,n,o),this}arcTo(e,t,r,i,n){return console.warn("Method arcTo not supported yet"),this}ellipse(e,t,r,i,n,o,a,l=!0){const c=new Fu(e,t,r,i,n,o,a,!l);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeEllipse(e,t,r,i,n,o,a,l){return e+=this.currentPoint?.x??0,t+=this.currentPoint?.y??0,this.ellipse(e,t,r,i,n,o,a,l),this}rect(e,t,r,i){const n=new zu(e,t,r,i);return this._connetLineTo(n),this.curves.push(n),this._setCurrentPoint({x:e,y:t}),this}roundRect(e,t,r,i,n){const o=new Vu(e,t,r,i,n);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint({x:e,y:t}),this}splineThru(e){const t=this.currentPoint??new k;return this.curves.push(new Gu([t].concat(e))),this._setCurrentPoint(e[e.length-1]),this}drawTo(e){const t=this.curves[0]?.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this.autoClose&&e.closePath(),this}copy(e){return super.copy(e),this.autoClose=e.autoClose,this.currentPoint=e.currentPoint?.clone(),this}}class ge extends Lr{_meta;currentCurve=new Di;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}constructor(e,t={}){super(),this.curves.push(this.currentCurve),this.style=t,e&&(e instanceof ge?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}getMeta(){return this._meta}setMeta(e){return this._meta=e,this}addPath(e){const t=this.curves.findIndex(r=>r===this.currentCurve);return t>-1&&this.curves.splice(t,1),e instanceof ge?this.curves.push(...e.curves.filter(r=>r.curves.length).map(r=>r.clone())):e.curves.length&&this.curves.push(e),this.curves.push(this.currentCurve),this}closePath(){const e=this.startPoint;return e&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new Di().moveTo(e.x,e.y),this.curves.push(this.currentCurve))),this}moveTo(e,t){return this.currentCurve.currentPoint?.equals({x:e,y:t})||(this.currentCurve.curves.length&&(this.currentCurve=new Di,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(e,t)),this}lineTo(e,t){return this.currentCurve.lineTo(e,t),this}bezierCurveTo(e,t,r,i,n,o){return this.currentCurve.bezierCurveTo(e,t,r,i,n,o),this}quadraticCurveTo(e,t,r,i){return this.currentCurve.quadraticCurveTo(e,t,r,i),this}arc(e,t,r,i,n,o){return this.currentCurve.arc(e,t,r,i,n,o),this}arcTo(e,t,r,i,n){return this.currentCurve.arcTo(e,t,r,i,n),this}ellipse(e,t,r,i,n,o,a,l){return this.currentCurve.ellipse(e,t,r,i,n,o,a,l),this}rect(e,t,r,i){return this.currentCurve.rect(e,t,r,i),this}roundRect(e,t,r,i,n){return this.currentCurve.roundRect(e,t,r,i,n),this}reset(){return this.currentCurve=new Di,this.curves=[this.currentCurve],this.style={},this}addCommands(e){return pa(e,this),this}addData(e){return this.addCommands(ga(e)),this}splineThru(e){return this.currentCurve.splineThru(e),this}scale(e,t=e,r={x:0,y:0}){return this.getControlPointRefs().forEach(i=>{i.scale(e,t,r)}),this}skew(e,t=0,r={x:0,y:0}){return this.getControlPointRefs().forEach(i=>{i.skew(e,t,r)}),this}rotate(e,t={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.rotate(e,t)}),this}bold(e){if(e===0)return this;const t=this.getFlatCurves(),r=[],i=[],n=[];t.forEach((a,l)=>{const c=a.getControlPointRefs(),h=a.isClockwise();n[l]=c,i[l]=h;const f=c[0],d=c[c.length-1]??f;r.push({start:h?d:f,end:h?f:d,index:l})});const o=[];return r.forEach((a,l)=>{o[l]=[],r.forEach((c,h)=>{c.start&&a.end&&h!==l&&c.start?.equals(a.end)&&o[l].push(c.index)})}),t.forEach((a,l)=>{const c=i[l];n[l].forEach(h=>{h.add(a.getNormal(a.getTForPoint(h)).scale(c?e:-e))})}),o.forEach((a,l)=>{const c=n[l];a.forEach(h=>{const f=n[h],d=Pu(c[c.length-1],c[c.length-2]??c[c.length-1],f[0],f[1]??f[0]);d&&(c[c.length-1].copy(d),f[0].copy(d))})}),this}getMinMax(e=k.MAX,t=k.MIN,r=!0){const i=this.strokeWidth;return this.curves.forEach(n=>{if(n.getMinMax(e,t),r&&i>1){const o=i/2,a=n.isClockwise(),l=[];for(let c=0;c<=1;c+=1/n.arcLengthDivision){const h=n.getPoint(c),f=n.getNormal(c),d=f.clone().scale(a?o:-o),g=f.clone().scale(a?-o:o);l.push(h.clone().add(d),h.clone().add(g),h.clone().add({x:o,y:0}),h.clone().add({x:-o,y:0}),h.clone().add({x:0,y:o}),h.clone().add({x:0,y:-o}),h.clone().add({x:o,y:o}),h.clone().add({x:-o,y:-o}))}e.min(...l),t.max(...l)}}),{min:e.finite(),max:t.finite()}}strokeTriangulate(e){const t=e?.indices??[],r=e?.vertices??[];return this.curves.forEach(i=>{i.strokeTriangulate({...e,indices:t,vertices:r,style:{...this.style}})}),{indices:t,vertices:r}}fillTriangulate(e){const t={...e,style:{...this.style,...e?.style}},r=t.indices??[],i=t.vertices??[];if((t.style.fillRule??"nonzero")==="nonzero"){const o=this.curves.map(c=>c.getFillVertices(t)),a=Tu(o),l=a.length;for(let c=0;c<l;c++){const h=a[c],f=o[c];if(h.wn||!f.length)continue;const d=f.slice(),g=[];for(let p=0;p<l;p++){const y=a[p];y.parentIndex===c&&(g.push(d.length/2),d.push(...o[y.index]))}Ca(d,{...e,indices:r,vertices:i,holes:g,style:{...this.style}})}}else this.curves.forEach(o=>{o.fillTriangulate({...e,indices:r,vertices:i,style:{...this.style}})});return{indices:r,vertices:i}}getBoundingBox(e=!0){const{min:t,max:r}=this.getMinMax(void 0,void 0,e);return new Z(t.x,t.y,r.x-t.x,r.y-t.y)}drawTo(e,t={}){t={...this.style,...t};const{fill:r="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),Ls(e,t),this.curves.forEach(n=>{n.drawTo(e)}),r!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};const{fill:r="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),Ls(e,t),this.getControlPointRefs().forEach(n=>{Wh(e,n.x,n.y,{radius:4})}),r!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}toCommands(){return this.curves.flatMap(e=>e.toCommands())}toData(){return this.curves.filter(e=>e.curves.length).map(e=>e.toData()).join(" ")}toSvgPathString(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const i in e)e[i]!==void 0&&(t[xu(i)]=e[i]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const i in t)t[i]!==void 0&&(r+=`${i}:${t[i]};`);return`<path d="${this.toData()}" style="${r}"></path>`}copy(e){return super.copy(e),this.currentCurve=e.currentCurve.clone(),this.style={...e.style},this}}class Tt{constructor(e=[],t){this.paths=e,this.viewBox=t}getBoundingBox(e=!0){if(!this.paths.length)return;const t=k.MAX,r=k.MIN;return this.paths.forEach(i=>i.getMinMax(t,r,e)),new Z(t.x,t.y,r.x-t.x,r.y-t.y)}toTriangulatedSvgString(e=this.paths.map(r=>r.fillTriangulate()),t=0){let r="";const i={x:-t,y:-t},n={x:t,y:t};(Array.isArray(e)?e:[e]).forEach(({vertices:l,indices:c})=>{const h=f=>{const d=l[f*2],g=l[f*2+1];return i.x=Math.min(i.x,d+t),n.x=Math.max(n.x,d+t),i.y=Math.min(i.y,g+t),n.y=Math.max(n.y,g+t),[d,g]};for(let f=0,d=c.length;f<d;f+=3){const g=h(c[f]),p=h(c[f+1]),y=h(c[f+2]);r+=`<polygon points="${g.join(",")} ${p.join(",")} ${y.join(",")}" stroke="none" fill="black" />`}});const a=[i.x,i.y,n.x-i.x,n.y-i.y];return`<svg width="${a[2]}" height="${a[3]}" viewBox="${a.join(" ")}" xmlns="http://www.w3.org/2000/svg">${r}</svg>`}toTriangulatedSvg(e,t){return new DOMParser().parseFromString(this.toTriangulatedSvgString(e,t),"image/svg+xml").documentElement}toSvgString(){const{x:e,y:t,width:r,height:i}=this.getBoundingBox(),n=this.paths.map(o=>o.toSvgPathString()).join("");return`<svg viewBox="${e} ${t} ${r} ${i}" width="${r}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${n}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...r}=e,{left:i,top:n,width:o,height:a}=this.getBoundingBox(),l=document.createElement("canvas");l.width=o*t,l.height=a*t,l.style.width=`${o}px`,l.style.height=`${a}px`;const c=l.getContext("2d");return c&&(c.scale(t,t),c.translate(-i,-n),this.paths.forEach(h=>{h.drawTo(c,r)})),l}}class Ii extends St{vertexAttributes;indexBuffer;instanceCount;mode;_materialWeakMap=new As;constructor(e={}){super(),this.vertexAttributes=new Map(Object.entries(e?.vertexAttributes??{})),this.indexBuffer=e?.indexBuffer,this.instanceCount=e?.instanceCount,this.mode=e?.mode??"triangles"}_glVertexArray(e){return{attributes:Object.fromEntries(Array.from(this.vertexAttributes).map(([t,r])=>[t,{buffer:r.buffer._glBuffer(e),size:r.size,type:r.type,normalized:r.normalized,stride:r.stride,offset:r.offset,divisor:r.divisor}])),elementArrayBuffer:this.indexBuffer?._glBuffer(e)}}_glVertexArrayObject(e,t){let r=this._materialWeakMap.get(t);return r||(r={material:t.instanceId,geometry:this.instanceId},this._materialWeakMap.set(t,r)),e.getRelated(r,()=>e.vertexArray.create(t._glProgram(e),this._glVertexArray(e)))}draw(e,t,r){e.flush(),t.activate(e,r);const i=this._glVertexArrayObject(e,t);let n=!1,o;this.vertexAttributes.forEach(a=>{o?.instanceId!==a.buffer.instanceId&&(o=a.buffer,o.upload(e)&&(n=!0)),a.upload()&&(n=!0)}),this.indexBuffer?.upload(e)&&(n=!0),n&&i&&e.vertexArray.update(t._glProgram(e),i,this._glVertexArray(e)),e.vertexArray.bind(i??this._glVertexArray(e)),e.draw({mode:this.mode,instanceCount:this.instanceCount}),e.vertexArray.unbind()}}var ju=Object.defineProperty,Ua=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ju(e,t,i),i};class dr extends St{needsUpload=!1;constructor(e){super(),this.setProperties(e)}_glBufferOptions(){return{target:"element_array_buffer",data:this.data,usage:this.dynamic?"dynamic_draw":"static_draw"}}_glBuffer(e){return e.getRelated(this,()=>e.buffer.create(this._glBufferOptions()))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"data":case"dynamic":this.needsUpload=!0;break}}upload(e){const t=this.needsUpload;return t&&(this.needsUpload=!1,e.buffer.update(this._glBuffer(e),this._glBufferOptions())),t}}Ua([w({internal:!0,fallback:null})],dr.prototype,"data"),Ua([w({internal:!0,fallback:!1})],dr.prototype,"dynamic");var Wu=Object.defineProperty,Ba=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Wu(e,t,i),i};class Et extends St{needsUpload=!1;constructor(e){super(),this.setProperties(e)}_glBufferOptions(){return{target:"array_buffer",data:this.data,usage:this.dynamic?"dynamic_draw":"static_draw"}}_glBuffer(e){return e.getRelated(this,()=>e.buffer.create(this._glBufferOptions()))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"data":case"dynamic":this.needsUpload=!0;break}}upload(e){const t=this.needsUpload;return t&&(this.needsUpload=!1,e.buffer.update(this._glBuffer(e),this._glBufferOptions())),t}}Ba([w({internal:!0,default:null})],Et.prototype,"data"),Ba([w({internal:!0,fallback:!1})],Et.prototype,"dynamic");var qu=Object.defineProperty,Kt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&qu(e,t,i),i};class je extends St{needsUpload=!1;constructor(e){super(),this.setProperties({buffer:new Et,...e})}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"buffer":case"size":case"normalized":case"type":case"stride":case"offset":case"divisor":this.needsUpload=!0;break}}upload(){const e=this.needsUpload;return e&&(this.needsUpload=!1),e}}Kt([w({internal:!0})],je.prototype,"buffer"),Kt([w({fallback:0})],je.prototype,"size"),Kt([w({fallback:!1})],je.prototype,"normalized"),Kt([w({fallback:"float"})],je.prototype,"type"),Kt([w()],je.prototype,"stride"),Kt([w()],je.prototype,"offset"),Kt([w()],je.prototype,"divisor");class Xu extends Ii{constructor(){super({vertexAttributes:{position:new je({buffer:new Et({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new dr({data:new Uint16Array([0,1,3,2]),dynamic:!1}),mode:"triangle_strip"})}}class se extends St{static instance=new this;vert;frag;uniforms;constructor(e={}){super(),this.vert=e.vert??`precision highp float;
76
76
  attribute vec2 position;
77
77
  uniform mat3 projectionMatrix;
78
78
  uniform mat3 modelViewMatrix;
@@ -116,7 +116,7 @@ uniform sampler2D sampler;
116
116
  uniform vec4 tint;
117
117
  void main(void) {
118
118
  gl_FragColor = texture2D(sampler, vUv) * tint;
119
- }`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}class Q extends Ii{static _instance;static get instance(){return this._instance??=new this}static draw(e,t=Fr.instance,r){this.instance.draw(e,t,r)}constructor(){super({vertexAttributes:{position:new je({buffer:new Et({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new je({buffer:new Et({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new dr({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}class Zu extends Ii{positionBuffer;uvBuffer;constructor(){const e=new Et({data:new Float32Array,dynamic:!0}),t=new Et({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new je({buffer:e,size:2,normalized:!1,type:"float"}),uv:new je({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new dr({data:new Uint16Array,dynamic:!0})}),this.positionBuffer=e,this.uvBuffer=t}}var Ju=Object.defineProperty,pr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Ju(e,t,i),i};class le extends St{static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}_isPowerOfTwo=!1;_needsUpload=!1;get valid(){return!!(this.width&&this.height)}get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}constructor(e){super(),this.source=e,this._updateSize()}_glTextureOptions(e,t){let r=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(r="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:r,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=ws(this.realWidth)&&ws(this.realHeight),this.requestUpload()}_updateSize(){const e=this.source;"pixels"in e?(this.width=e.width/this.pixelRatio,this.height=e.height/this.pixelRatio):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0)/this.pixelRatio,this.height=Number(e.naturalHeight||e.videoHeight||e.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(e,t){return this._needsUpload&&this.valid?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){return this.valid?(e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t}),!0):!1}inactivate(e){e.texture.unbind(this._glTexture(e))}destroy(){Co&&this.source instanceof ImageBitmap&&this.source.close()}}pr([w({protected:!0})],le.prototype,"source"),pr([w({fallback:0})],le.prototype,"width"),pr([w({fallback:0})],le.prototype,"height"),pr([w({fallback:"linear"})],le.prototype,"filterMode"),pr([w({fallback:"clamp_to_edge"})],le.prototype,"wrapMode"),pr([w({fallback:1})],le.prototype,"pixelRatio");class Ri extends St{frames;constructor(e){super();let t;if(Array.isArray(e))t=e;else if(e instanceof le)t=[{texture:e,duration:0}];else throw new TypeError("Failed new AnimatedTexture");this.frames=t,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((e,t)=>t.duration+e,0),this}destroy(){this.frames.forEach(e=>{e.texture.destroy()})}}var Qu=Object.defineProperty,ef=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Qu(e,t,i),i};class Ui extends le{constructor(e=document.createElement("canvas")){super(e)}_updateProperty(e,t,r){switch(e){case"width":this.source.width=Math.max(1,Math.ceil(t*this.pixelRatio));break;case"height":this.source.height=Math.max(1,Math.ceil(t*this.pixelRatio));break}super._updateProperty(e,t,r)}}ef([w({fallback:2})],Ui.prototype,"pixelRatio");class tf extends le{static _cached=new Map;static get(e){const t=new Qe(e),r=t.toHex();let i=this._cached.get(r);return i||(i=new le({width:1,height:1,pixels:new Uint8Array([t.r8,t.g8,t.b8,t.a8])}),this._cached.set(r,i)),i}constructor(e){const t=new Qe(e);super({width:1,height:1,pixels:new Uint8Array([t.r8,t.g8,t.b8,t.a8])})}}class $r extends le{static test(e){return Mr(e)}static linearGradient(e,t,r){t=t||1,r=r||1;const i=document.createElement("canvas");i.width=t,i.height=r;const n=i.getContext("2d");if(!n)throw new Error("Failed to parse linear gradient, get canvas context is null.");const{angle:o=0,stops:a}=e,l=t,c=r,h=l/2,f=c/2,d=(o+90)*Math.PI/180,g=Math.sin(d),p=-Math.cos(d),y=Math.abs(l*Math.sin(d))+Math.abs(c*Math.cos(d)),m=h-g*(y/2),P=f-p*(y/2),E=h+g*(y/2),x=f+p*(y/2),S=n.createLinearGradient(m,P,E,x);for(const b of a)S.addColorStop(b.offset,b.color);n.fillStyle=S,n.fillRect(0,0,l,c);const _=n.getImageData(0,0,i.width,i.height);return{width:_.width,height:_.height,pixels:new Uint8Array(_.data.buffer)}}constructor(e,t,r){super($r.linearGradient(e,t,r))}}function rf(s){return{autoLoad:!!(s?.autoLoad??!0),useBitmap:!!(s?.useBitmap??!0)&&Ps,crossorigin:s?.crossorigin??null}}class sf extends le{bitmap;useBitmap;preserveBitmap=!1;_loadSource;_loadBitmap;constructor(e,t){const r=rf(t);super(e);const i=e.src,n=i.includes(".svg")||i.startsWith("data:image/svg+xml");this.useBitmap=r.useBitmap&&!n,r.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,r=()=>{t.onload=null,t.onerror=null},i=()=>{r(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},n=o=>{r(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,o),this.emit("error",o),e(this)};t.complete&&t.src?i():(t.onload=i,t.onerror=n)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!Ps)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(r=>r.blob()).then(r=>createImageBitmap(r,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(r=>(this.bitmap=r,this.requestUpload(),this._loadBitmap=void 0,this)).catch(r=>(console.warn("Failed to genBitmap",r),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const r=this.source;if(kr&&r instanceof HTMLImageElement&&(!r.complete||r.naturalWidth===0))return!1}const t=super.upload(e);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),t}}class Xs extends le{constructor(e,t=1,r=1){const i={width:t,height:r,pixels:null};e&&(ArrayBuffer.isView(e)?i.pixels=new Uint8Array(e.buffer):i.pixels=new Uint8Array(e)),super(i)}_updateProperty(e,t,r){switch(e){case"width":this.source.width=Math.round(this.width*this.pixelRatio);break;case"height":this.source.height=Math.round(this.height*this.pixelRatio);break;case"pixelRatio":this.source.width=Math.round(this.width*this.pixelRatio),this.source.height=Math.round(this.height*this.pixelRatio);break}super._updateProperty(e,t,r)}}var nf=Object.defineProperty,La=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&nf(e,t,i),i};function of(s){return{autoLoad:!!(s?.autoLoad??!0),autoPlay:!!(s?.autoPlay??!1),fps:Number(s?.fps??0),crossorigin:s?.crossorigin??null,loop:!!(s?.loop??!1),muted:!!(s?.muted??!1),playsinline:!!(s?.playsinline??!0)}}const Hs=class uc extends le{static mimeTypes=new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}));get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(e){this.source.currentTime=e}_spf=0;_autoPlay=!1;_sourceLoad;_nextTime=0;_connected=!1;_requestId;_resolve;_reject;constructor(e,t){const r=of(t);if(!ko(e)){typeof e=="string"&&(e=[e]);const i=e[0].src||e[0],n=document.createElement("video");r.autoLoad&&n.setAttribute("preload","auto"),r.playsinline&&(n.setAttribute("webkit-playsinline",""),n.setAttribute("playsinline","")),r.muted&&(n.setAttribute("muted",""),n.muted=!0),r.loop&&n.setAttribute("loop",""),r.autoPlay&&n.setAttribute("autoplay",""),Bo(n,i,r.crossorigin);for(let o=0;o<e.length;++o){let{src:a,mime:l}=e[o];if(a=a||e[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),f=h.slice(h.lastIndexOf(".")+1);l=l||uc.mimeTypes.get(f)||`video/${f}`}const c=document.createElement("source");c.src=a,l&&(c.type=l),n.appendChild(c)}e=n}super(e),this.fps=r.fps,this._autoPlay=r.autoPlay,r.autoPlay&&this.load(),this._setupAutoUpdate()}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"fps":this._spf=t?Math.floor(1e3/t):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_onPlayStart=()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()};_onPlayStop=()=>{this._setupAutoUpdate()};_onCanPlay=()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._nextTime=0,this._updateSize(),this.requestUpload(),this._nextTime=0,!t&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&e.play()};_onError=e=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=void 0,this._resolve=void 0)};_onSeeked=()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)};_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(Ce.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(Ce.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(Ce.off(this.requestUpload),this._connected=!1,this._nextTime=0))}_videoFrameRequestCallback=()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)};requestUpload=()=>{const e=Math.floor(Ce.elapsed*this.source.playbackRate);this._nextTime-=e,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)};async load(){if(!this._sourceLoad){const e=this.source;(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((t,r)=>{this.valid?(this._sourceLoad=void 0,t(this)):(this._resolve=t,this._reject=r,e.load())})}return this._sourceLoad}destroy(){this._setupAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load())}};La([w({internal:!0,fallback:!0})],Hs.prototype,"autoUpdate"),La([w({internal:!0,fallback:0})],Hs.prototype,"fps");let Na=Hs;class Ys extends Xs{}class Fa extends ge{fillStyle;strokeStyle;strokeAlignment;lineCap;lineJoin;lineWidth;miterLimit;uvTransform;vertTransform;_draws=[];_parseDrawStyle(e){return e?e instanceof le?{texture:e}:{backgroundColor:new Qe(e).toInt8Array()}:{}}stroke(e){if(!this.curves.length)return;let t=this.strokeStyle;if(!t&&this.style.stroke)switch(typeof this.style.stroke){case"string":t=this.style.stroke;break;case"object":_s(this.style.stroke)&&(t=this.style.stroke.color);break}this._draws.push({...e,...this._parseDrawStyle(t),type:"stroke",path:new ge(this),uvTransform:this.uvTransform,vertTransform:this.vertTransform,lineStyle:{alignment:this.strokeAlignment??.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),this.resetStatus()}fillRect(e,t,r,i){this.rect(e,t,r,i).fill()}strokeRect(e,t,r,i){this.rect(e,t,r,i).stroke()}fill(e){if(!this.curves.length)return;let t=this.fillStyle;if(!t&&this.style.fill)switch(typeof this.style.fill){case"string":t=this.style.fill;break;case"object":_s(this.style.fill)&&(t=this.style.fill.color);break}this._draws.push({...e,...this._parseDrawStyle(t),type:"fill",path:new ge(this),uvTransform:this.uvTransform,vertTransform:this.vertTransform}),this.resetStatus()}copy(e){return super.copy(e),this.strokeStyle=e.strokeStyle,this.fillStyle=e.fillStyle,this.uvTransform=e.uvTransform,this.vertTransform=e.vertTransform,this.strokeAlignment=e.strokeAlignment,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineWidth=e.lineWidth,this.miterLimit=e.miterLimit,this._draws=e._draws.slice(),this}resetStatus(){super.reset(),this.strokeStyle=void 0,this.fillStyle=void 0,this.uvTransform=void 0,this.vertTransform=void 0,this.strokeAlignment=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0}reset(){return this.resetStatus(),this._draws.length=0,this}buildUvs(e,t,r,i,n){if(i){const o=n&&(typeof n=="function"?n:(c,h)=>n.apply({x:c,y:h}).toArray()),a=i.width,l=i.height;for(let c=t.length,h=e;h<c;h+=2){const f=t[h],d=t[h+1];let g,p;o?[g,p]=o(f,d):[g,p]=[f/a,d/l],r.push(g,p)}}else for(let o=t.length,a=e;a<o;a+=2)r.push(0,0)}toBatchables(){const e=[];for(let t=this._draws.length,r=0;r<t;r++){const i=this._draws[r],n=[],o=[],a=[];i.type==="fill"?i.path.fillTriangulate({vertices:n,indices:o}):i.path.strokeTriangulate({vertices:n,indices:o,lineStyle:i.lineStyle,flipAlignment:!1,closed:!0}),i.texture&&this.buildUvs(0,n,a,i.texture,i.uvTransform),e.push({vertices:new Float32Array(n),indices:new Float32Array(o),uvs:new Float32Array(a),texture:i.texture,backgroundColor:i.backgroundColor,type:i.type,disableWrapMode:i.disableWrapMode,vertTransform:i.vertTransform})}return e}}class af{front=[];default=[];back=[];get internal(){return this.getInternal()}constructor(...e){this.set(e)}set(e){return this.front.length=0,this.default.length=0,this.back.length=0,e.forEach(t=>{switch(t.internalMode){case"front":this.front.push(t);break;case"default":this.default.push(t);break;case"back":this.back.push(t);break}}),this}getInternal(e){if(e)switch(e){case"front":return this.front;case"default":return this.default;case"back":return this.back;default:throw new Error(`Unknown internal mode: ${e}`)}else return[...this.front,...this.default,...this.back]}toJSON(){return[...this.default]}}var lf=Object.defineProperty,cf=Object.getOwnPropertyDescriptor,dt=(s,e,t,r)=>{for(var i=r>1?void 0:r?cf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&lf(e,t,i),i};const $a={};function hf(s){let e=$a[s]??0;return e++,$a[s]=e,e}u.Node=class extends It{_readyed=!1;constructor(e,t=[]){super(),this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties({name:`${this.is}:${hf(this.is)}`,...e}).append(t),this.on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}setProperties(e){if(e){const{meta:t,...r}=e;if(t)for(const i in t)this.meta[i]=t[i];super.setProperties(r)}return this}getName(){return this.name}setName(e){return this.name=e,this}_tree;get tree(){return this.getTree()}set tree(e){this.setTree(e)}getTree(){return this._tree}getViewport(){return this.parent?.getViewport()??this.getWindow()}getWindow(){return this._tree?.root}isInsideTree(){return!!this._tree}setTree(e){const t=this._tree;if(!e?.equal(t)){t&&this.emit("treeExit",t),this._tree=e,e&&this.emit("treeEnter",e);const r=this._children.internal;for(let i=r.length,n=0;n<i;n++){const o=r[n];!e&&this.emit("childExitingTree",o),o.setTree(e),e&&this.emit("childEnteredTree",o)}e&&(this.emit("treePostEnter",e),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}log(...e){this._tree?.log(...e)}_parent;get parent(){return this._parent}set parent(e){this.setParent(e)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(e){if(!this._parent?.equal(e)){const t=this._parent;t&&this.emit("unparented",t),this._parent=e,e&&this.emit("parented",e),this.setTree(e?._tree)}return this}_children=new af;get children(){return this._children.default}set children(e){this._children.set(e)}getChildren(e="default"){return this._children.getInternal(e===!0?void 0:e)}getChild(e=0){return this.children[e]}get siblingIndex(){return this.getIndex()}set siblingIndex(e){this._parent?.moveChild(this,e)}get previousSibling(){return this._parent?.children[this.getIndex()-1]}get nextSibling(){return this._parent?.children[this.getIndex()+1]}get firstSibling(){return this._parent?.children[0]}get lastSibling(){const e=this._parent?.children;return e?e[e.length-1]:void 0}canProcess(){if(!this._tree)return!1;switch(this.processMode){case"inherit":return this._parent?.canProcess()??!0;case"pausable":return!this._tree.processPaused;case"when_paused":return this._tree.processPaused;case"always":return!0;case"disabled":default:return!1}}canInput(){if(!this._tree)return!1;switch(this.inputMode){case"inherit":return this._parent?.canInput()??!0;case"always":return!0;case"disabled":default:return!1}}canRender(){if(!this._tree)return!1;switch(this.renderMode){case"inherit":return this._parent?.canRender()??!0;case"always":return!0;case"disabled":default:return!1}}_onTreeEnter(e){this._treeEnter(e),this.emit("treeEntered",e)}_onTreeExit(e){this.emit("treeExiting",e),this._treeExit(e),this.emit("treeExited",e)}_onParented(e){this._parented(e)}_onUnparented(e){this._unparented(e)}_onReady(){this._ready()}_onProcess(e=0){const t=this._tree,r=this.canRender(),i=this.canProcess(),n=[],o=[];this._children.internal.forEach(l=>{switch(l.processSortMode){case"default":o.push(l);break;case"parent_before":n.push(l);break}}),n.forEach(l=>{l.emit("process",e)}),i&&(t?.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let a;if(r){const l=t.renderStack.push(this);a=t.renderStack.currentCall,t.renderStack.currentCall=l}if(this.mask instanceof u.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.appendChild(this.mask,"front"));else{const l=this.getNode("__$mask");l&&this.removeChild(l)}o.forEach(l=>{l.emit("process",e)}),r&&(t.renderStack.currentCall=a),i&&(this.emit("processed",e),t?.emit("nodeProcessed",this))}render(e,t){const r=this.mask;r&&(e.flush(),e.mask.push(this,r)),this._render(e),t?.(),r&&(e.flush(),e.mask.pop(this))}input(e,t){if(e.propagationStopped)return;const r=this._children.internal;for(let i=r.length-1;i>=0;i--)r[i].input(e,t);e.propagationStopped||this.canInput()&&this._input(e,t)}getIndex(){return this._parent?.getChildren(this.internalMode).indexOf(this)??0}getNode(e){return this._children.internal.find(t=>t.name===e)}removeNode(e){this.getNode(e)?.remove()}addSibling(e){return this.equal(e)||!this.hasParent()||e.hasParent()?this:(e.internalMode=this.internalMode,this._parent.moveChild(e,this.getIndex()+1),this)}prepend(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this.moveChild(r,0)})}append(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this.appendChild(r)})}before(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this._parent?.moveChild(r,this.getIndex())})}after(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this._parent?.moveChild(r,this.getIndex()+1)})}insertBefore(e,t){return!t.hasParent()||!this.equal(t.parent)||this.moveChild(e,t.getIndex()),e}appendChild(e,t=e.internalMode){if(this.equal(e)||e.hasParent())return e;switch(t){case"front":this._children.front.push(e);break;case"default":this._children.default.push(e);break;case"back":this._children.back.push(e);break}return e.internalMode!==t&&(e.internalMode=t),e.setParent(this),this.emit("appendChild",e),e}moveChild(e,t,r=e.internalMode){if(this.equal(e)||e.hasParent()&&!this.equal(e.parent))return this;const i=this._children.getInternal(e.internalMode),n=i.indexOf(e),o=this._children.getInternal(r);return(e.internalMode!==r||t!==n)&&(n>-1&&i.splice(n,1),e.setParent(this),t>-1&&t<o.length?o.splice(t,0,e):o.push(e),n>-1?this.emit("moveChild",e,t,n):this.emit("appendChild",e)),e.internalMode!==r&&(e.internalMode=r),this}removeChild(e){const t=e.getIndex();return this.equal(e.parent)&&t>-1&&(this.getChildren(e.internalMode).splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),e}removeChildren(){this.children.forEach(e=>this.removeChild(e))}remove(){this._parent?.removeChild(this)}forEachChild(e){return this.children.forEach(e),this}forEachDescendant(e){return this.children.forEach(t=>{e(t),t.forEachDescendant(e)}),this}forEachAncestor(e){const t=this.parent;return t&&(e(t),t.forEachAncestor(e)),this}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}destroy(){super.destroy(),this._children.internal.forEach(e=>this.removeChild(e))}clone(){return new this.constructor(this.toJSON(),this._children.internal)}toJSON(){return Ve({...super.toJSON(),children:this.children.length?[...this.children.map(e=>e.toJSON())]:void 0,meta:{...this.meta,inCanvasIs:this.is}})}static parse(e){if(Array.isArray(e))return e.map(l=>this.parse(l));const{meta:t={},children:r,...i}=e,{inCanvasIs:n="Node"}=t,o=Pi.get(n)??u.Node,a=new o({...i,meta:t});return r?.forEach(l=>a.appendChild(this.parse(l))),a}},dt([w({fallback:_o()})],u.Node.prototype,"id",2),dt([w({fallback:_o()})],u.Node.prototype,"name",2),dt([w({default:()=>({})})],u.Node.prototype,"meta",2),dt([w({internal:!0,fallback:"inherit"})],u.Node.prototype,"processMode",2),dt([w({internal:!0,fallback:"default"})],u.Node.prototype,"processSortMode",2),dt([w({internal:!0,fallback:"inherit"})],u.Node.prototype,"renderMode",2),dt([w({internal:!0,fallback:"inherit"})],u.Node.prototype,"inputMode",2),dt([w({internal:!0,fallback:"default"})],u.Node.prototype,"internalMode",2),dt([w({protected:!0})],u.Node.prototype,"mask",2),u.Node=dt([W("Node")],u.Node);var uf=Object.defineProperty,ff=Object.getOwnPropertyDescriptor,zr=(s,e,t,r)=>{for(var i=r>1?void 0:r?ff(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&uf(e,t,i),i};u.TimelineNode=class extends u.Node{constructor(e,t=[]){super(),this.setProperties(e).append(t)}computedDuration=0;_currentTime=0;_startTime=0;get timeline(){return this._tree?.timeline}get timelineCurrentTime(){return this.timeline?.currentTime??0}get parentStartTime(){return this._parent?.startTime??0}get currentTime(){return Ge(this._currentTime,0,this.computedDuration)}get startTime(){return this._startTime}set startTime(e){this.delay=e-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?Ge(this._currentTime/this.computedDuration,0,1):0}isInsideTimeRange(){const e=this._currentTime;return this.computedDuration?e>=0&&e<=this.computedDuration:e>=0}_updateCurrentTime(e=!1){if(e||!this.paused){const t=this._parent;this._startTime=this.delay+this.parentStartTime,this.computedDuration=t?.computedDuration?Math.min(this._startTime+this.duration,t.endTime)-this._startTime:this.duration,this._currentTime=this.timelineCurrentTime-this._startTime,this.emit("updateCurrentTime",this._currentTime),this.insideTimeRange=this.isInsideTimeRange()}}_process(e){super._process(e),this._updateCurrentTime()}},zr([w({fallback:0})],u.TimelineNode.prototype,"delay",2),zr([w({fallback:0})],u.TimelineNode.prototype,"duration",2),zr([w({fallback:!1})],u.TimelineNode.prototype,"paused",2),zr([w({internal:!0,fallback:!1})],u.TimelineNode.prototype,"insideTimeRange",2),u.TimelineNode=zr([W("TimelineNode")],u.TimelineNode);var df=Object.defineProperty,pf=Object.getOwnPropertyDescriptor,Vr=(s,e,t,r)=>{for(var i=r>1?void 0:r?pf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&df(e,t,i),i};u.CanvasItem=class extends u.TimelineNode{_parentGlobalVisible;_globalVisible;get globalVisible(){return this._globalVisible??!0}_parentGlobalOpacity;_globalOpacity;get globalOpacity(){return this._globalOpacity??1}_modulate=new Qe(4294967295);context=new Fa;_resetContext=!0;_redrawing=!0;_relayouting=!1;_repainting=!1;_originalBatchables=[];_layoutedBatchables=[];_batchables=[];constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"modulate":this._modulate.value=t,this.requestRepaint();break;case"blendMode":this.requestRepaint();break;case"opacity":this._updateGlobalOpacity();break;case"visible":case"insideTimeRange":this._updateGlobalVisible();break}}show(){this.visible=!0}hide(){this.visible=!1}isVisibleInTree(){return this.globalOpacity>0&&this.globalVisible}canRender(){return super.canRender()&&this.isVisibleInTree()}requestRedraw(){this._redrawing=!0}requestRelayout(){this._relayouting=!0}requestRepaint(){this._repainting=!0}_updateGlobalVisible(){this._parentGlobalVisible=this.getParent()?.globalVisible,this._globalVisible=(this._parentGlobalVisible??!0)&&this.visible&&this.insideTimeRange}_updateGlobalOpacity(){this._parentGlobalOpacity=this.getParent()?.opacity;const e=Ge(this.opacity,0,1)*(this._parentGlobalOpacity??1);this._globalOpacity!==e&&(this._globalOpacity=e,this.requestRepaint())}_draw(){this.emit("draw")}_redraw(){return this.log(this.name,"drawing"),this._draw(),this.context.toBatchables()}_relayout(e){return this.log(this.name,"layouting"),e}_repaint(e){return this.log(this.name,"painting"),e.map(t=>({...t,modulate:this._modulate.toInt8Array(),blendMode:this.blendMode}))}_process(e){super._process(e);const t=this.getParent();this._parentGlobalVisible!==t?.globalVisible&&this._updateGlobalVisible(),this._parentGlobalOpacity!==t?.globalOpacity&&this._updateGlobalOpacity()}_updateBatchables(){const e=this._redrawing;let t=this._relayouting,r=this._repainting,i;e&&(this._originalBatchables=this._redraw(),t=!0),t&&(this._layoutedBatchables=this._relayout(this._originalBatchables),r=!0),r&&(i=this._repaint(this._layoutedBatchables)),e&&this._resetContext&&this.context.reset(),i&&(this._batchables=i,this._redrawing=!1,this._relayouting=!1,this._repainting=!1)}_render(e){this._updateBatchables(),this._batchables.forEach(t=>{t.texture?.upload(e),e.batch2D.render({...t,texture:t.texture?._glTexture(e)})}),super._render(e)}},Vr([w()],u.CanvasItem.prototype,"modulate",2),Vr([w()],u.CanvasItem.prototype,"blendMode",2),Vr([w({internal:!0,fallback:!0})],u.CanvasItem.prototype,"visible",2),Vr([w({internal:!0,fallback:1})],u.CanvasItem.prototype,"opacity",2),u.CanvasItem=Vr([W("CanvasItem")],u.CanvasItem);var gf=Object.defineProperty,mf=Object.getOwnPropertyDescriptor,Gr=(s,e,t,r)=>{for(var i=r>1?void 0:r?mf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&gf(e,t,i),i};u.Viewport=class extends u.Node{constructor(e=!1){super(),this.flipY=e,this.projection.flipY(e)}projection=new Wo;canvasTransform=new ve;_framebufferIndex=0;_framebuffers=[{texture:new Ys,needsUpload:!1},{texture:new Ys,needsUpload:!1}];get valid(){return!!(this.width&&this.height)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}getViewport(){return this}_glFramebufferOptions(e){const{width:t,height:r}=this,{pixelRatio:i}=e;return this._framebuffers.forEach(n=>{const o=n.texture;o.width=t,o.height=r,o.pixelRatio=i,o.upload(e)}),{width:t,height:r,colorTextures:[this.texture._glTexture(e)]}}_glFramebuffer(e){return e.getRelated(this.framebuffer,()=>e.framebuffer.create(this._glFramebufferOptions(e)))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"x":case"y":this.requestUpload(),this.projection.translate(this.x,this.y),this.emit("updateRect");break;case"width":case"height":this.requestUpload(),this.projection.resize(this.width,this.height),this.emit("updateRect");break}}requestUpload(){this._framebuffers.forEach(e=>e.needsUpload=!0)}resize(e,t){this.width=e,this.height=t}upload(e){const t=this.framebuffer;return t.needsUpload&&this.valid?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){return this.valid?(e.flush(),this._tree?.setCurrentViewport(this),this.upload(e),e.framebuffer.bind(this._glFramebuffer(e)),!0):!1}redraw(e,t){if(this.valid){e.flush();const r=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),r.activate(e,0),t(),!0}return!1}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e)&&(e.clear(),t.texture.activate(e,0),Q.draw(e,Fr.instance,{sampler:0}))}render(e,t){const r=this._tree?.getCurrentViewport();e.program.uniforms.projectionMatrix=this.projection.toArray(!0),e.program.uniforms.viewMatrix=this.canvasTransform.toArray(!0),this.activate(e),e.clear(),super.render(e,t),e.flush(),r?r.activate(e):(e.framebuffer.bind(null),this._tree?.setCurrentViewport(void 0))}getRect(){return new Rt(this.x,this.y,this.width,this.height)}toCanvasGlobal(e,t){return this.canvasTransform.applyAffineInverse(e,t)}toCanvasScreen(e,t){return this.canvasTransform.apply(e,t)}},Gr([w({fallback:0})],u.Viewport.prototype,"x",2),Gr([w({fallback:0})],u.Viewport.prototype,"y",2),Gr([w({fallback:0})],u.Viewport.prototype,"width",2),Gr([w({fallback:0})],u.Viewport.prototype,"height",2),u.Viewport=Gr([W("Viewport")],u.Viewport);var yf=Object.defineProperty,_f=Object.getOwnPropertyDescriptor,jr=(s,e,t,r)=>{for(var i=r>1?void 0:r?_f(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&yf(e,t,i),i};u.Effect=class extends u.TimelineNode{material;get _effectMode(){return this.effectMode??"parent"}viewport1=new u.Viewport;viewport2=new u.Viewport;_renderId=0;_renderViewport;_previousSibling;_nextSibling;constructor(e,t=[]){super(),this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"glsl":{const i=new Nr(t);!this.effectMode&&i.has.transition&&(this.effectMode="transition"),this.material=i;break}case"glslSrc":{t?nt.text.load(t).then(i=>this.glsl=i):this.glsl="";break}}}_treeEnter(e){e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(e),this.viewport2.setTree(e)}_treeExit(e){e.off("processing",this._onProcessing),e.off("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(void 0),this.viewport2.setTree(void 0)}_onProcessing(){if(this.canProcess())switch(this._updateCurrentTime(),this._effectMode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}}_onNodeProcessed(e){if(!this.canProcess()||!this.isInsideTimeRange())return;const t=this._tree?.renderStack;if(t)switch(this._effectMode){case"transition":e.equal(this._previousSibling)?(this._previousSibling=void 0,t.push(this)):e.equal(this._nextSibling)&&(this._nextSibling=void 0,t.push(this));break}}_processParent(){const e=this._tree?.renderStack;if(!e)return;const t=e.currentCall?.parentCall;if(!t)return;const r=t.calls;let i,n;r.forEach((o,a)=>{(o.renderable.equal(this._parent)||o.renderable.parent?.equal(this._parent))&&(i=i??a,n=a)}),!(i===void 0||n===void 0)&&(r.splice(n+1,0,e.createCall(this)),r.splice(i,0,e.createCall(this)))}_processChildren(){this.children.length&&(super.emit("process"),this._tree?.renderStack.push(this))}_onProcess(e=0){if(this.canProcess())switch(this._renderId=0,this._effectMode){case"before":super._onProcess(e);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(e){const t=this._tree?.getCurrentViewport();t&&this.apply(e,t,{redraw:!0})}_renderTransition(e){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&(this.viewport1.activateWithCopy(e,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(e),e.clear();else{const t=this._renderViewport;this._renderViewport=void 0,t&&(t.activate(e),e.clear(),this.viewport1.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,t,{from:this.viewport1,to:this.viewport2}),e.texture.unbind(0),e.texture.unbind(1))}}_renderParentOrChildren(e){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&this.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(e),e.clear();else{const t=this._renderViewport;this._renderViewport=void 0,t&&(this.viewport1.activate(e),this.apply(e,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),t.activate(e),this.viewport1.texture.activate(e,0),Q.draw(e))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const e=this._parent.getRect();if(e)return[e.left/this.viewport1.width,e.top/this.viewport1.height,e.width/this.viewport1.width,e.height/this.viewport1.height]}}_render(e){switch(this._effectMode){case"before":this._renderBefore(e);break;case"transition":this._renderTransition(e);break;case"parent":case"children":default:this._renderParentOrChildren(e);break}this._renderId++}apply(e,t,r){this.material&&(r?.redraw?t.redraw(e,()=>{Q.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):Q.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:r?.from?r.from.width/r.from.height:0}))}},jr([w({protected:!0})],u.Effect.prototype,"material",2),jr([w()],u.Effect.prototype,"effectMode",2),jr([w({fallback:""})],u.Effect.prototype,"glsl",2),jr([w({fallback:""})],u.Effect.prototype,"glslSrc",2),u.Effect=jr([W("Effect")],u.Effect);class vf{currentCall;calls=[];createCall(e){return{renderable:e,parentCall:this.currentCall,fn:e.render.bind(e),calls:[]}}push(e){const t=this.createCall(e);return(this.currentCall?.calls??this.calls).push(t),t}render(e){this.calls.forEach(function t(r){r.fn(e,()=>{r.calls.forEach(t)})}),this.calls=[]}}var bf=Object.defineProperty,wf=Object.getOwnPropertyDescriptor,Wr=(s,e,t,r)=>{for(var i=r>1?void 0:r?wf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&bf(e,t,i),i};u.Timeline=class extends u.Node{static from(e,t=!1){const[r,i]=e?Array.isArray(e)?e:[0,e]:[];return new u.Timeline({startTime:r,endTime:i,loop:t})}constructor(e){super(),this.setProperties(e)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"startTime":this.startTime=Math.min(t,this.endTime);break;case"endTime":this.endTime=t||Number.MAX_SAFE_INTEGER;break}}addTime(e){const t=this.startTime,r=this.endTime;let i=this.currentTime;return i=i+e,this.loop&&i>r&&(i=t+i%r),i=Ge(i,t,r),this.currentTime=i,this.emit("updateCurrentTime",i,e),this}_process(e){super._process(e),this.addTime(e)}},Wr([w({fallback:0})],u.Timeline.prototype,"startTime",2),Wr([w({fallback:0})],u.Timeline.prototype,"currentTime",2),Wr([w({fallback:Number.MAX_SAFE_INTEGER})],u.Timeline.prototype,"endTime",2),Wr([w({fallback:!1})],u.Timeline.prototype,"loop",2),u.Timeline=Wr([W("Timeline")],u.Timeline);var xf=Object.getOwnPropertyDescriptor,Pf=(s,e,t,r)=>{for(var i=r>1?void 0:r?xf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.Window=class extends u.Viewport{},u.Window=Pf([W("Window")],u.Window);var Sf=Object.defineProperty,Ks=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Sf(e,t,i),i};class qr extends Ci{input=new $o;renderStack=new vf;root=new u.Window(!0).setTree(this);timeline;_backgroundColor=new Qe;_currentViewport;getCurrentViewport(){return this._currentViewport}setCurrentViewport(e){this._currentViewport=e}constructor(e=new u.Timeline){super(),this.timeline=e.setTree(this)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"backgroundColor":this._backgroundColor.value=t;break}}log(...e){this.debug&&console.log(`[modern-canvas][${performance.now().toFixed(4)}ms]`,...e)}_process(e=0){this.timeline.emit("process",e),this.emit("processing"),this.root.emit("process",e),this.emit("processed")}_render(e){this.emit("rendering"),this.renderStack.render(e),this._renderScreen(e),this.emit("rendered")}_renderScreen(e){e.state.reset(),e.framebuffer.bind(null),e.viewport.bind({x:0,y:0,width:this.root.width*e.pixelRatio,height:this.root.height*e.pixelRatio}),this.backgroundColor&&e.gl.clearColor(...this._backgroundColor.toArray()),e.clear(),this.backgroundColor&&e.gl.clearColor(0,0,0,0);const t=this.root.texture;t.activate(e,0),Q.draw(e),e.texture.unbind(t)}destroy(){super.destroy(),this.root.destroy(),this.input.removeEventListeners()}}Ks([w({internal:!0,fallback:!1})],qr.prototype,"processPaused"),Ks([w()],qr.prototype,"backgroundColor"),Ks([w({internal:!0,fallback:!1})],qr.prototype,"debug");var Cf=Object.getOwnPropertyDescriptor,Tf=(s,e,t,r)=>{for(var i=r>1?void 0:r?Cf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.Transition=class extends u.Effect{constructor(e,t=[]){super(),this.setProperties(e).append(t)}},u.Transition=Tf([W("Transition",{effectMode:"transition",processMode:"pausable",duration:2e3})],u.Transition);var Ef=Object.defineProperty,Mf=Object.getOwnPropertyDescriptor,Zs=(s,e,t,r)=>{for(var i=r>1?void 0:r?Mf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ef(e,t,i),i};u.Node2D=class extends u.CanvasItem{position=new de().on("update",()=>this.updateGlobalTransform());scale=new de(1,1).on("update",()=>this.updateGlobalTransform());skew=new de().on("update",()=>this.updateGlobalTransform());transform=new ve;globalPosition=new de;globalScale=new de;globalSkew=new de;globalTransform=new ve;_parentTransformDirtyId;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"rotation":this.updateGlobalTransform();break}}getTransformOrigin(){return new de(0,0)}updateTransform(e){const t=this.getTransformOrigin(),r=this.transform.identity().translate(-t.x,-t.y).scale(this.scale.x,this.scale.y).skew(this.skew.x,this.skew.y).rotate(this.rotation);e?.(r),r.translate(this.position.x,this.position.y).translate(t.x,t.y)}updateGlobalTransform(){this.updateTransform();const e=this.getParent();if(e?.globalTransform){const{globalPosition:t,globalScale:r,globalSkew:i,globalTransform:n,globalRotation:o}=e;this._parentTransformDirtyId=n.dirtyId,this.globalPosition.set(t.x+this.position.x,t.y+this.position.y),this.globalScale.set(r.x*this.scale.x,r.y*this.scale.y),this.globalSkew.set(i.x*this.skew.x,i.y*this.skew.y),this.globalRotation=o+this.rotation,e.globalTransform.multiply(this.transform,this.globalTransform)}else this.globalPosition.copy(this.position),this.globalScale.copy(this.scale),this.globalSkew.copy(this.skew),this.globalRotation=this.rotation,this.globalTransform.copy(this.transform);this.requestRelayout()}_transformVertices(e,t){let r,i,n,o,a,l;if(t){const h=this.globalTransform.clone();h.multiply(typeof t=="function"?t?.():t),[r,i,n,o,a,l]=h.toArray()}else[r,i,n,o,a,l]=this.globalTransform.toArray();const c=e.slice();for(let h=e.length,f=0;f<h;f+=2){const d=e[f],g=e[f+1];c[f]=r*d+i*g+n,c[f+1]=o*d+a*g+l}return c}_relayout(e){return e=super._relayout(e),this.updateGlobalTransform(),e.map(t=>({...t,vertices:this._transformVertices(t.vertices,t.vertTransform)}))}_process(e){super._process(e);const t=this.getParent();t?.globalTransform&&this._parentTransformDirtyId!==t?.globalTransform?.dirtyId&&this.requestRelayout()}toLocal(e,t){return this.globalTransform.applyAffineInverse(e,t)}toGlobal(e,t){return this.globalTransform.apply(e,t)}},Zs([w({internal:!0,fallback:0})],u.Node2D.prototype,"rotation",2),Zs([w({internal:!0,fallback:0})],u.Node2D.prototype,"globalRotation",2),u.Node2D=Zs([W("Node2D")],u.Node2D);var Af=Object.defineProperty,Of=Object.getOwnPropertyDescriptor,Js=(s,e,t,r)=>{for(var i=r>1?void 0:r?Of(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Af(e,t,i),i};u.Camera2D=class extends u.Node2D{zoom=new de(1,1).on("update",()=>this.updateCanvasTransform());maxZoom=new de(6,6);minZoom=new de(.1,.1);_screenOffset={x:0,y:0};constructor(e,t=[]){super(),this.setProperties(e).append(t)}addZoom(e,t=e){return this.zoom.set(Ge(this.zoom.x+e,this.minZoom.x,this.maxZoom.x),Ge(this.zoom.y+t,this.minZoom.y,this.maxZoom.y)),this}setZoom(e,t=e){return this.zoom.set(Ge(e,this.minZoom.x,this.maxZoom.x),Ge(t,this.minZoom.y,this.maxZoom.y)),this}_input(e,t){if(super._input(e,t),t==="keydown"){const r=e;!this.spaceKey&&r.code==="Space"&&(r.cursor="grab",this.spaceKey=!0)}else if(t==="keyup"){const r=e;r.code==="Space"&&(r.cursor="default",this.spaceKey=!1,this.grabbing=!1)}else if(t==="pointerdown"){const r=e;!this.grabbing&&(this.spaceKey||r.button===1)&&(this.grabbing=!0,r.cursor="grabbing",this._screenOffset={x:r.screenX,y:r.screenY})}else if(t==="pointermove"){const r=e;this.grabbing&&(this.position.add(-(this._screenOffset.x-r.screenX),-(this._screenOffset.y-r.screenY)),this._screenOffset={x:r.screenX,y:r.screenY})}else if(t==="pointerup"){const r=e;this.grabbing&&(this.grabbing=!1,this.spaceKey?r.cursor="grab":r.cursor="default")}else t==="wheel"&&this._onWheel(e)}_onWheel(e){if(e.ctrlKey){if(!(e.wheelDeltaY?Math.abs(Math.abs(e.wheelDeltaY)-Math.abs(3*e.deltaY))<3:e.deltaMode===0)){e.preventDefault();const r=this.zoom.x;this.addZoom(e.deltaY*-.015);const i=1-this.zoom.x/r;this.position.add((e.screenX-this.position.x)*i,(e.screenY-this.position.y)*i)}}else e.preventDefault(),this.position.add(-e.deltaX,-e.deltaY)}updateTransform(){super.updateTransform(),this.updateCanvasTransform()}updateCanvasTransform(){const e=this.getViewport();e&&(e.canvasTransform.identity().scale(this.zoom.x,this.zoom.y).translate(this.position.x,this.position.y),this.emit("updateCanvasTransform"))}toGlobal(e,t){const r=this.getViewport();if(!r)throw new Error("Failed to toGlobal, viewport is empty");return r.toCanvasGlobal(e,t)}toScreen(e,t){const r=this.getViewport();if(!r)throw new Error("Failed to toScreen, viewport is empty");return r.toCanvasScreen(e,t)}},Js([w({internal:!0,fallback:!1})],u.Camera2D.prototype,"spaceKey",2),Js([w({internal:!0,fallback:!1})],u.Camera2D.prototype,"grabbing",2),u.Camera2D=Js([W("Camera2D",{processMode:"disabled",renderMode:"disabled"})],u.Camera2D);const za={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};function kf(s){const e=new ks;if(s==="none")return e;const t=Or(s).reduce((r,{name:i,args:n})=>(r[i]=n[0].normalizedIntValue,r),{});Object.keys(za).forEach(r=>{t[r]=t[r]??za[r]});for(const r in t){const i=t[r];switch(r){case"hue-rotate":e.hueRotate(i*Ne);break;case"saturate":e.saturate(i);break;case"brightness":e.brightness(i);break;case"contrast":e.contrast(i);break;case"invert":e.invert(i);break;case"sepia":e.sepia(i);break;case"opacity":e.opacity(i);break;case"grayscale":e.grayscale(i);break}}return e}function Va(s,e,t,r=new ve){return s=!s||s==="none"?"":s,Or(s,{width:e,height:t}).reverse().forEach(({name:i,args:n})=>{const o=n.map(a=>a.normalizedIntValue);switch(i){case"translate":r.translate(o[0]*e,(o[1]??o[0])*t);break;case"translateX":r.translateX(o[0]*e);break;case"translateY":r.translateY(o[0]*t);break;case"translateZ":r.translateZ(o[0]);break;case"translate3d":r.translate3d(o[0]*e,(o[1]??o[0])*t,o[2]??o[1]??o[0]);break;case"scale":r.scale(o[0],o[1]??o[0]);break;case"scaleX":r.scaleX(o[0]);break;case"scaleY":r.scaleY(o[0]);break;case"scale3d":r.scale3d(o[0],o[1]??o[0],o[2]??o[1]??o[0]);break;case"rotate":r.rotate(o[0]*Ne);break;case"rotateX":r.rotateX(o[0]*Ne);break;case"rotateY":r.rotateY(o[0]*Ne);break;case"rotateZ":r.rotateZ(o[0]*Ne);break;case"rotate3d":r.rotate3d(o[0]*Ne,(o[1]??o[0])*Ne,(o[2]??o[1]??o[0])*Ne,(o[3]??o[2]??o[1]??o[0])*Ne);break;case"skew":r.skew(o[0],o[0]??o[1]);break;case"skewX":r.skewX(o[0]);break;case"skewY":r.skewY(o[0]);break;case"matrix":r.set(o);break}}),r}function Ga(s){const[e,t=e]=s.split(" ");return[e,t].map(r=>{switch(r=r.trim(),r){case"left":case"top":return 0;case"center":return .5;case"right":case"bottom":return 1;default:return Number(r)}})}var ja=Object.defineProperty,Df=Object.getOwnPropertyDescriptor,If=(s,e,t)=>e in s?ja(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Mt=(s,e,t,r)=>{for(var i=r>1?void 0:r?Df(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&ja(e,t,i),i},Rf=(s,e,t)=>If(s,e+"",t);u.ColorAdjustEffect=class extends u.Effect{constructor(e,t=[]){super(),this.setProperties(e).append(t)}apply(e,t){t.redraw(e,()=>{Q.draw(e,u.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},Rf(u.ColorAdjustEffect,"material",new se({vert:`precision mediump float;
119
+ }`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}class Q extends Ii{static _instance;static get instance(){return this._instance??=new this}static draw(e,t=Fr.instance,r){this.instance.draw(e,t,r)}constructor(){super({vertexAttributes:{position:new je({buffer:new Et({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new je({buffer:new Et({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new dr({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}class Zu extends Ii{positionBuffer;uvBuffer;constructor(){const e=new Et({data:new Float32Array,dynamic:!0}),t=new Et({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new je({buffer:e,size:2,normalized:!1,type:"float"}),uv:new je({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new dr({data:new Uint16Array,dynamic:!0})}),this.positionBuffer=e,this.uvBuffer=t}}var Ju=Object.defineProperty,pr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Ju(e,t,i),i};class le extends St{static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}_isPowerOfTwo=!1;_needsUpload=!1;get valid(){return!!(this.width&&this.height)}get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}constructor(e){super(),this.source=e,this._updateSize()}_glTextureOptions(e,t){let r=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(r="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:r,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=ws(this.realWidth)&&ws(this.realHeight),this.requestUpload()}_updateSize(){const e=this.source;"pixels"in e?(this.width=e.width/this.pixelRatio,this.height=e.height/this.pixelRatio):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0)/this.pixelRatio,this.height=Number(e.naturalHeight||e.videoHeight||e.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(e,t){return this._needsUpload&&this.valid?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){return this.valid?(e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t}),!0):!1}inactivate(e){e.texture.unbind(this._glTexture(e))}destroy(){Co&&this.source instanceof ImageBitmap&&this.source.close()}}pr([w({internal:!0})],le.prototype,"source"),pr([w({fallback:0})],le.prototype,"width"),pr([w({fallback:0})],le.prototype,"height"),pr([w({fallback:"linear"})],le.prototype,"filterMode"),pr([w({fallback:"clamp_to_edge"})],le.prototype,"wrapMode"),pr([w({fallback:1})],le.prototype,"pixelRatio");class Ri extends St{frames;constructor(e){super();let t;if(Array.isArray(e))t=e;else if(e instanceof le)t=[{texture:e,duration:0}];else throw new TypeError("Failed new AnimatedTexture");this.frames=t,this.updateDuration()}updateDuration(){return this.duration=this.frames.reduce((e,t)=>t.duration+e,0),this}destroy(){this.frames.forEach(e=>{e.texture.destroy()})}}var Qu=Object.defineProperty,ef=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Qu(e,t,i),i};class Ui extends le{constructor(e=document.createElement("canvas")){super(e)}_updateProperty(e,t,r){switch(e){case"width":this.source.width=Math.max(1,Math.ceil(t*this.pixelRatio));break;case"height":this.source.height=Math.max(1,Math.ceil(t*this.pixelRatio));break}super._updateProperty(e,t,r)}}ef([w({fallback:2})],Ui.prototype,"pixelRatio");class tf extends le{static _cached=new Map;static get(e){const t=new Qe(e),r=t.toHex();let i=this._cached.get(r);return i||(i=new le({width:1,height:1,pixels:new Uint8Array([t.r8,t.g8,t.b8,t.a8])}),this._cached.set(r,i)),i}constructor(e){const t=new Qe(e);super({width:1,height:1,pixels:new Uint8Array([t.r8,t.g8,t.b8,t.a8])})}}class $r extends le{static test(e){return Mr(e)}static linearGradient(e,t,r){t=t||1,r=r||1;const i=document.createElement("canvas");i.width=t,i.height=r;const n=i.getContext("2d");if(!n)throw new Error("Failed to parse linear gradient, get canvas context is null.");const{angle:o=0,stops:a}=e,l=t,c=r,h=l/2,f=c/2,d=(o+90)*Math.PI/180,g=Math.sin(d),p=-Math.cos(d),y=Math.abs(l*Math.sin(d))+Math.abs(c*Math.cos(d)),m=h-g*(y/2),P=f-p*(y/2),E=h+g*(y/2),x=f+p*(y/2),S=n.createLinearGradient(m,P,E,x);for(const b of a)S.addColorStop(b.offset,b.color);n.fillStyle=S,n.fillRect(0,0,l,c);const _=n.getImageData(0,0,i.width,i.height);return{width:_.width,height:_.height,pixels:new Uint8Array(_.data.buffer)}}constructor(e,t,r){super($r.linearGradient(e,t,r))}}function rf(s){return{autoLoad:!!(s?.autoLoad??!0),useBitmap:!!(s?.useBitmap??!0)&&Ps,crossorigin:s?.crossorigin??null}}class sf extends le{bitmap;useBitmap;preserveBitmap=!1;_loadSource;_loadBitmap;constructor(e,t){const r=rf(t);super(e);const i=e.src,n=i.includes(".svg")||i.startsWith("data:image/svg+xml");this.useBitmap=r.useBitmap&&!n,r.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,r=()=>{t.onload=null,t.onerror=null},i=()=>{r(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},n=o=>{r(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,o),this.emit("error",o),e(this)};t.complete&&t.src?i():(t.onload=i,t.onerror=n)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!Ps)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(r=>r.blob()).then(r=>createImageBitmap(r,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(r=>(this.bitmap=r,this.requestUpload(),this._loadBitmap=void 0,this)).catch(r=>(console.warn("Failed to genBitmap",r),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const r=this.source;if(kr&&r instanceof HTMLImageElement&&(!r.complete||r.naturalWidth===0))return!1}const t=super.upload(e);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),t}}class Xs extends le{constructor(e,t=1,r=1){const i={width:t,height:r,pixels:null};e&&(ArrayBuffer.isView(e)?i.pixels=new Uint8Array(e.buffer):i.pixels=new Uint8Array(e)),super(i)}_updateProperty(e,t,r){switch(e){case"width":this.source.width=Math.round(this.width*this.pixelRatio);break;case"height":this.source.height=Math.round(this.height*this.pixelRatio);break;case"pixelRatio":this.source.width=Math.round(this.width*this.pixelRatio),this.source.height=Math.round(this.height*this.pixelRatio);break}super._updateProperty(e,t,r)}}var nf=Object.defineProperty,La=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&nf(e,t,i),i};function of(s){return{autoLoad:!!(s?.autoLoad??!0),autoPlay:!!(s?.autoPlay??!1),fps:Number(s?.fps??0),crossorigin:s?.crossorigin??null,loop:!!(s?.loop??!1),muted:!!(s?.muted??!1),playsinline:!!(s?.playsinline??!0)}}const Hs=class uc extends le{static mimeTypes=new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}));get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(e){this.source.currentTime=e}_spf=0;_autoPlay=!1;_sourceLoad;_nextTime=0;_connected=!1;_requestId;_resolve;_reject;constructor(e,t){const r=of(t);if(!ko(e)){typeof e=="string"&&(e=[e]);const i=e[0].src||e[0],n=document.createElement("video");r.autoLoad&&n.setAttribute("preload","auto"),r.playsinline&&(n.setAttribute("webkit-playsinline",""),n.setAttribute("playsinline","")),r.muted&&(n.setAttribute("muted",""),n.muted=!0),r.loop&&n.setAttribute("loop",""),r.autoPlay&&n.setAttribute("autoplay",""),Bo(n,i,r.crossorigin);for(let o=0;o<e.length;++o){let{src:a,mime:l}=e[o];if(a=a||e[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){const h=a.split("?").shift().toLowerCase(),f=h.slice(h.lastIndexOf(".")+1);l=l||uc.mimeTypes.get(f)||`video/${f}`}const c=document.createElement("source");c.src=a,l&&(c.type=l),n.appendChild(c)}e=n}super(e),this.fps=r.fps,this._autoPlay=r.autoPlay,r.autoPlay&&this.load(),this._setupAutoUpdate()}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"fps":this._spf=t?Math.floor(1e3/t):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_onPlayStart=()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()};_onPlayStop=()=>{this._setupAutoUpdate()};_onCanPlay=()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._nextTime=0,this._updateSize(),this.requestUpload(),this._nextTime=0,!t&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&e.play()};_onError=e=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=void 0,this._resolve=void 0)};_onSeeked=()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)};_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(Ce.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(Ce.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(Ce.off(this.requestUpload),this._connected=!1,this._nextTime=0))}_videoFrameRequestCallback=()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)};requestUpload=()=>{const e=Math.floor(Ce.elapsed*this.source.playbackRate);this._nextTime-=e,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)};async load(){if(!this._sourceLoad){const e=this.source;(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((t,r)=>{this.valid?(this._sourceLoad=void 0,t(this)):(this._resolve=t,this._reject=r,e.load())})}return this._sourceLoad}destroy(){this._setupAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load())}};La([w({internal:!0,fallback:!0})],Hs.prototype,"autoUpdate"),La([w({internal:!0,fallback:0})],Hs.prototype,"fps");let Na=Hs;class Ys extends Xs{}class Fa extends ge{fillStyle;strokeStyle;strokeAlignment;lineCap;lineJoin;lineWidth;miterLimit;uvTransform;vertTransform;_draws=[];_parseDrawStyle(e){return e?e instanceof le?{texture:e}:{backgroundColor:new Qe(e).toInt8Array()}:{}}stroke(e){if(!this.curves.length)return;let t=this.strokeStyle;if(!t&&this.style.stroke)switch(typeof this.style.stroke){case"string":t=this.style.stroke;break;case"object":_s(this.style.stroke)&&(t=this.style.stroke.color);break}this._draws.push({...e,...this._parseDrawStyle(t),type:"stroke",path:new ge(this),uvTransform:this.uvTransform,vertTransform:this.vertTransform,lineStyle:{alignment:this.strokeAlignment??.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),this.resetStatus()}fillRect(e,t,r,i){this.rect(e,t,r,i).fill()}strokeRect(e,t,r,i){this.rect(e,t,r,i).stroke()}fill(e){if(!this.curves.length)return;let t=this.fillStyle;if(!t&&this.style.fill)switch(typeof this.style.fill){case"string":t=this.style.fill;break;case"object":_s(this.style.fill)&&(t=this.style.fill.color);break}this._draws.push({...e,...this._parseDrawStyle(t),type:"fill",path:new ge(this),uvTransform:this.uvTransform,vertTransform:this.vertTransform}),this.resetStatus()}copy(e){return super.copy(e),this.strokeStyle=e.strokeStyle,this.fillStyle=e.fillStyle,this.uvTransform=e.uvTransform,this.vertTransform=e.vertTransform,this.strokeAlignment=e.strokeAlignment,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineWidth=e.lineWidth,this.miterLimit=e.miterLimit,this._draws=e._draws.slice(),this}resetStatus(){super.reset(),this.strokeStyle=void 0,this.fillStyle=void 0,this.uvTransform=void 0,this.vertTransform=void 0,this.strokeAlignment=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0}reset(){return this.resetStatus(),this._draws.length=0,this}buildUvs(e,t,r,i,n){if(i){const o=n&&(typeof n=="function"?n:(c,h)=>n.apply({x:c,y:h}).toArray()),a=i.width,l=i.height;for(let c=t.length,h=e;h<c;h+=2){const f=t[h],d=t[h+1];let g,p;o?[g,p]=o(f,d):[g,p]=[f/a,d/l],r.push(g,p)}}else for(let o=t.length,a=e;a<o;a+=2)r.push(0,0)}toBatchables(){const e=[];for(let t=this._draws.length,r=0;r<t;r++){const i=this._draws[r],n=[],o=[],a=[];i.type==="fill"?i.path.fillTriangulate({vertices:n,indices:o}):i.path.strokeTriangulate({vertices:n,indices:o,lineStyle:i.lineStyle,flipAlignment:!1,closed:!0}),i.texture&&this.buildUvs(0,n,a,i.texture,i.uvTransform),e.push({vertices:new Float32Array(n),indices:new Float32Array(o),uvs:new Float32Array(a),texture:i.texture,backgroundColor:i.backgroundColor,type:i.type,disableWrapMode:i.disableWrapMode,vertTransform:i.vertTransform})}return e}}class af{front=[];default=[];back=[];get internal(){return this.getInternal()}constructor(...e){this.set(e)}set(e){return this.front.length=0,this.default.length=0,this.back.length=0,e.forEach(t=>{switch(t.internalMode){case"front":this.front.push(t);break;case"default":this.default.push(t);break;case"back":this.back.push(t);break}}),this}getInternal(e){if(e)switch(e){case"front":return this.front;case"default":return this.default;case"back":return this.back;default:throw new Error(`Unknown internal mode: ${e}`)}else return[...this.front,...this.default,...this.back]}toJSON(){return[...this.default]}}var lf=Object.defineProperty,cf=Object.getOwnPropertyDescriptor,pt=(s,e,t,r)=>{for(var i=r>1?void 0:r?cf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&lf(e,t,i),i};const $a={};function hf(s){let e=$a[s]??0;return e++,$a[s]=e,e}u.Node=class extends It{_readyed=!1;constructor(e,t=[]){super(),this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties({name:`${this.is}:${hf(this.is)}`,...e}).append(t),this.on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}setProperties(e){if(e){const{meta:t,...r}=e;if(t)for(const i in t)this.meta[i]=t[i];super.setProperties(r)}return this}getName(){return this.name}setName(e){return this.name=e,this}_tree;get tree(){return this.getTree()}set tree(e){this.setTree(e)}getTree(){return this._tree}getViewport(){return this.parent?.getViewport()??this.getWindow()}getWindow(){return this._tree?.root}isInsideTree(){return!!this._tree}setTree(e){const t=this._tree;if(!e?.equal(t)){t&&this.emit("treeExit",t),this._tree=e,e&&this.emit("treeEnter",e);const r=this._children.internal;for(let i=r.length,n=0;n<i;n++){const o=r[n];!e&&this.emit("childExitingTree",o),o.setTree(e),e&&this.emit("childEnteredTree",o)}e&&(this.emit("treePostEnter",e),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}log(...e){this._tree?.log(...e)}_parent;get parent(){return this._parent}set parent(e){this.setParent(e)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(e){if(!this._parent?.equal(e)){const t=this._parent;t&&this.emit("unparented",t),this._parent=e,e&&this.emit("parented",e),this.setTree(e?._tree)}return this}_children=new af;get children(){return this._children.default}set children(e){this._children.set(e)}getChildren(e="default"){return this._children.getInternal(e===!0?void 0:e)}getChild(e=0){return this.children[e]}get siblingIndex(){return this.getIndex()}set siblingIndex(e){this._parent?.moveChild(this,e)}get previousSibling(){return this._parent?.children[this.getIndex()-1]}get nextSibling(){return this._parent?.children[this.getIndex()+1]}get firstSibling(){return this._parent?.children[0]}get lastSibling(){const e=this._parent?.children;return e?e[e.length-1]:void 0}canProcess(){if(!this._tree)return!1;switch(this.processMode){case"inherit":return this._parent?.canProcess()??!0;case"pausable":return!this._tree.processPaused;case"when_paused":return this._tree.processPaused;case"always":return!0;case"disabled":default:return!1}}canInput(){if(!this._tree)return!1;switch(this.inputMode){case"inherit":return this._parent?.canInput()??!0;case"always":return!0;case"disabled":default:return!1}}canRender(){if(!this._tree)return!1;switch(this.renderMode){case"inherit":return this._parent?.canRender()??!0;case"always":return!0;case"disabled":default:return!1}}_onTreeEnter(e){this._treeEnter(e),this.emit("treeEntered",e)}_onTreeExit(e){this.emit("treeExiting",e),this._treeExit(e),this.emit("treeExited",e)}_onParented(e){this._parented(e)}_onUnparented(e){this._unparented(e)}_onReady(){this._ready()}_onProcess(e=0){const t=this._tree,r=this.canRender(),i=this.canProcess(),n=[],o=[];this._children.internal.forEach(l=>{switch(l.processSortMode){case"default":o.push(l);break;case"parent_before":n.push(l);break}}),n.forEach(l=>{l.emit("process",e)}),i&&(t?.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let a;if(r){const l=t.renderStack.push(this);a=t.renderStack.currentCall,t.renderStack.currentCall=l}if(this.mask instanceof u.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.appendChild(this.mask,"front"));else{const l=this.getNode("__$mask");l&&this.removeChild(l)}o.forEach(l=>{l.emit("process",e)}),r&&(t.renderStack.currentCall=a),i&&(this.emit("processed",e),t?.emit("nodeProcessed",this))}render(e,t){const r=this.mask;r&&(e.flush(),e.mask.push(this,r)),this._render(e),t?.(),r&&(e.flush(),e.mask.pop(this))}input(e,t){if(e.propagationStopped)return;const r=this._children.internal;for(let i=r.length-1;i>=0;i--)r[i].input(e,t);e.propagationStopped||this.canInput()&&this._input(e,t)}getIndex(){return this._parent?.getChildren(this.internalMode).indexOf(this)??0}getNode(e){return this._children.internal.find(t=>t.name===e)}removeNode(e){this.getNode(e)?.remove()}addSibling(e){return this.equal(e)||!this.hasParent()||e.hasParent()?this:(e.internalMode=this.internalMode,this._parent.moveChild(e,this.getIndex()+1),this)}prepend(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this.moveChild(r,0)})}append(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this.appendChild(r)})}before(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this._parent?.moveChild(r,this.getIndex())})}after(...e){let t;Array.isArray(e[0])?t=e[0]:t=e,t.forEach(r=>{this._parent?.moveChild(r,this.getIndex()+1)})}insertBefore(e,t){return!t.hasParent()||!this.equal(t.parent)||this.moveChild(e,t.getIndex()),e}appendChild(e,t=e.internalMode){if(this.equal(e)||e.hasParent())return e;switch(t){case"front":this._children.front.push(e);break;case"default":this._children.default.push(e);break;case"back":this._children.back.push(e);break}return e.internalMode!==t&&(e.internalMode=t),e.setParent(this),this.emit("appendChild",e),e}moveChild(e,t,r=e.internalMode){if(this.equal(e)||e.hasParent()&&!this.equal(e.parent))return this;const i=this._children.getInternal(e.internalMode),n=i.indexOf(e),o=this._children.getInternal(r);return(e.internalMode!==r||t!==n)&&(n>-1&&i.splice(n,1),e.setParent(this),t>-1&&t<o.length?o.splice(t,0,e):o.push(e),n>-1?this.emit("moveChild",e,t,n):this.emit("appendChild",e)),e.internalMode!==r&&(e.internalMode=r),this}removeChild(e){const t=e.getIndex();return this.equal(e.parent)&&t>-1&&(this.getChildren(e.internalMode).splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),e}removeChildren(){this.children.forEach(e=>this.removeChild(e))}remove(){this._parent?.removeChild(this)}forEachChild(e){return this.children.forEach(e),this}forEachDescendant(e){return this.children.forEach(t=>{e(t),t.forEachDescendant(e)}),this}forEachAncestor(e){const t=this.parent;return t&&(e(t),t.forEachAncestor(e)),this}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}destroy(){super.destroy(),this._children.internal.forEach(e=>this.removeChild(e))}clone(){return new this.constructor(this.toJSON(),this._children.internal)}toJSON(){return Ve({...super.toJSON(),children:this.children.length?[...this.children.map(e=>e.toJSON())]:void 0,meta:{...this.meta,inCanvasIs:this.is}})}static parse(e){if(Array.isArray(e))return e.map(l=>this.parse(l));const{meta:t={},children:r,...i}=e,{inCanvasIs:n="Node"}=t,o=Pi.get(n)??u.Node,a=new o({...i,meta:t});return r?.forEach(l=>a.appendChild(this.parse(l))),a}},pt([w({fallback:_o()})],u.Node.prototype,"id",2),pt([w({fallback:_o()})],u.Node.prototype,"name",2),pt([w({default:()=>({})})],u.Node.prototype,"meta",2),pt([w({internal:!0,fallback:"inherit"})],u.Node.prototype,"processMode",2),pt([w({internal:!0,fallback:"default"})],u.Node.prototype,"processSortMode",2),pt([w({internal:!0,fallback:"inherit"})],u.Node.prototype,"renderMode",2),pt([w({internal:!0,fallback:"inherit"})],u.Node.prototype,"inputMode",2),pt([w({internal:!0,fallback:"default"})],u.Node.prototype,"internalMode",2),pt([w({internal:!0})],u.Node.prototype,"mask",2),u.Node=pt([W("Node")],u.Node);var uf=Object.defineProperty,ff=Object.getOwnPropertyDescriptor,zr=(s,e,t,r)=>{for(var i=r>1?void 0:r?ff(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&uf(e,t,i),i};u.TimelineNode=class extends u.Node{constructor(e,t=[]){super(),this.setProperties(e).append(t)}computedDuration=0;_currentTime=0;_startTime=0;get timeline(){return this._tree?.timeline}get timelineCurrentTime(){return this.timeline?.currentTime??0}get parentStartTime(){return this._parent?.startTime??0}get currentTime(){return Ge(this._currentTime,0,this.computedDuration)}get startTime(){return this._startTime}set startTime(e){this.delay=e-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?Ge(this._currentTime/this.computedDuration,0,1):0}isInsideTimeRange(){const e=this._currentTime;return this.computedDuration?e>=0&&e<=this.computedDuration:e>=0}_updateCurrentTime(e=!1){if(e||!this.paused){const t=this._parent;this._startTime=this.delay+this.parentStartTime,this.computedDuration=t?.computedDuration?Math.min(this._startTime+this.duration,t.endTime)-this._startTime:this.duration,this._currentTime=this.timelineCurrentTime-this._startTime,this.emit("updateCurrentTime",this._currentTime),this.insideTimeRange=this.isInsideTimeRange()}}_process(e){super._process(e),this._updateCurrentTime()}},zr([w({fallback:0})],u.TimelineNode.prototype,"delay",2),zr([w({fallback:0})],u.TimelineNode.prototype,"duration",2),zr([w({fallback:!1})],u.TimelineNode.prototype,"paused",2),zr([w({internal:!0,fallback:!1})],u.TimelineNode.prototype,"insideTimeRange",2),u.TimelineNode=zr([W("TimelineNode")],u.TimelineNode);var df=Object.defineProperty,pf=Object.getOwnPropertyDescriptor,Vr=(s,e,t,r)=>{for(var i=r>1?void 0:r?pf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&df(e,t,i),i};u.CanvasItem=class extends u.TimelineNode{_parentGlobalVisible;_globalVisible;get globalVisible(){return this._globalVisible??!0}_parentGlobalOpacity;_globalOpacity;get globalOpacity(){return this._globalOpacity??1}_modulate=new Qe(4294967295);context=new Fa;_resetContext=!0;_redrawing=!0;_relayouting=!1;_repainting=!1;_originalBatchables=[];_layoutedBatchables=[];_batchables=[];constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"modulate":this._modulate.value=t,this.requestRepaint();break;case"blendMode":this.requestRepaint();break;case"opacity":this._updateGlobalOpacity();break;case"visible":case"insideTimeRange":this._updateGlobalVisible();break}}show(){this.visible=!0}hide(){this.visible=!1}isVisibleInTree(){return this.globalOpacity>0&&this.globalVisible}canRender(){return super.canRender()&&this.isVisibleInTree()}requestRedraw(){this._redrawing=!0}requestRelayout(){this._relayouting=!0}requestRepaint(){this._repainting=!0}_updateGlobalVisible(){this._parentGlobalVisible=this.getParent()?.globalVisible,this._globalVisible=(this._parentGlobalVisible??!0)&&this.visible&&this.insideTimeRange}_updateGlobalOpacity(){this._parentGlobalOpacity=this.getParent()?.opacity;const e=Ge(this.opacity,0,1)*(this._parentGlobalOpacity??1);this._globalOpacity!==e&&(this._globalOpacity=e,this.requestRepaint())}_draw(){this.emit("draw")}_redraw(){return this.log(this.name,"drawing"),this._draw(),this.context.toBatchables()}_relayout(e){return this.log(this.name,"layouting"),e}_repaint(e){return this.log(this.name,"painting"),e.map(t=>({...t,modulate:this._modulate.toInt8Array(),blendMode:this.blendMode}))}_process(e){super._process(e);const t=this.getParent();this._parentGlobalVisible!==t?.globalVisible&&this._updateGlobalVisible(),this._parentGlobalOpacity!==t?.globalOpacity&&this._updateGlobalOpacity()}_updateBatchables(){const e=this._redrawing;let t=this._relayouting,r=this._repainting,i;e&&(this._originalBatchables=this._redraw(),t=!0),t&&(this._layoutedBatchables=this._relayout(this._originalBatchables),r=!0),r&&(i=this._repaint(this._layoutedBatchables)),e&&this._resetContext&&this.context.reset(),i&&(this._batchables=i,this._redrawing=!1,this._relayouting=!1,this._repainting=!1)}_render(e){this._updateBatchables(),this._batchables.forEach(t=>{t.texture?.upload(e),e.batch2D.render({...t,texture:t.texture?._glTexture(e)})}),super._render(e)}},Vr([w()],u.CanvasItem.prototype,"modulate",2),Vr([w()],u.CanvasItem.prototype,"blendMode",2),Vr([w({internal:!0,fallback:!0})],u.CanvasItem.prototype,"visible",2),Vr([w({internal:!0,fallback:1})],u.CanvasItem.prototype,"opacity",2),u.CanvasItem=Vr([W("CanvasItem")],u.CanvasItem);var gf=Object.defineProperty,mf=Object.getOwnPropertyDescriptor,Gr=(s,e,t,r)=>{for(var i=r>1?void 0:r?mf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&gf(e,t,i),i};u.Viewport=class extends u.Node{constructor(e=!1){super(),this.flipY=e,this.projection.flipY(e)}projection=new Wo;canvasTransform=new ve;_framebufferIndex=0;_framebuffers=[{texture:new Ys,needsUpload:!1},{texture:new Ys,needsUpload:!1}];get valid(){return!!(this.width&&this.height)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}getViewport(){return this}_glFramebufferOptions(e){const{width:t,height:r}=this,{pixelRatio:i}=e;return this._framebuffers.forEach(n=>{const o=n.texture;o.width=t,o.height=r,o.pixelRatio=i,o.upload(e)}),{width:t,height:r,colorTextures:[this.texture._glTexture(e)]}}_glFramebuffer(e){return e.getRelated(this.framebuffer,()=>e.framebuffer.create(this._glFramebufferOptions(e)))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"x":case"y":this.requestUpload(),this.projection.translate(this.x,this.y),this.emit("updateRect");break;case"width":case"height":this.requestUpload(),this.projection.resize(this.width,this.height),this.emit("updateRect");break}}requestUpload(){this._framebuffers.forEach(e=>e.needsUpload=!0)}resize(e,t){this.width=e,this.height=t}upload(e){const t=this.framebuffer;return t.needsUpload&&this.valid?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){return this.valid?(e.flush(),this._tree?.setCurrentViewport(this),this.upload(e),e.framebuffer.bind(this._glFramebuffer(e)),!0):!1}redraw(e,t){if(this.valid){e.flush();const r=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),r.activate(e,0),t(),!0}return!1}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e)&&(e.clear(),t.texture.activate(e,0),Q.draw(e,Fr.instance,{sampler:0}))}render(e,t){const r=this._tree?.getCurrentViewport();e.program.uniforms.projectionMatrix=this.projection.toArray(!0),e.program.uniforms.viewMatrix=this.canvasTransform.toArray(!0),this.activate(e),e.clear(),super.render(e,t),e.flush(),r?r.activate(e):(e.framebuffer.bind(null),this._tree?.setCurrentViewport(void 0))}getRect(){return new Rt(this.x,this.y,this.width,this.height)}toCanvasGlobal(e,t){return this.canvasTransform.applyAffineInverse(e,t)}toCanvasScreen(e,t){return this.canvasTransform.apply(e,t)}},Gr([w({fallback:0})],u.Viewport.prototype,"x",2),Gr([w({fallback:0})],u.Viewport.prototype,"y",2),Gr([w({fallback:0})],u.Viewport.prototype,"width",2),Gr([w({fallback:0})],u.Viewport.prototype,"height",2),u.Viewport=Gr([W("Viewport")],u.Viewport);var yf=Object.defineProperty,_f=Object.getOwnPropertyDescriptor,jr=(s,e,t,r)=>{for(var i=r>1?void 0:r?_f(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&yf(e,t,i),i};u.Effect=class extends u.TimelineNode{material;get _effectMode(){return this.effectMode??"parent"}viewport1=new u.Viewport;viewport2=new u.Viewport;_renderId=0;_renderViewport;_previousSibling;_nextSibling;constructor(e,t=[]){super(),this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"glsl":{const i=new Nr(t);!this.effectMode&&i.has.transition&&(this.effectMode="transition"),this.material=i;break}case"glslSrc":{t?nt.text.load(t).then(i=>this.glsl=i):this.glsl="";break}}}_treeEnter(e){e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(e),this.viewport2.setTree(e)}_treeExit(e){e.off("processing",this._onProcessing),e.off("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(void 0),this.viewport2.setTree(void 0)}_onProcessing(){if(this.canProcess())switch(this._updateCurrentTime(),this._effectMode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}}_onNodeProcessed(e){if(!this.canProcess()||!this.isInsideTimeRange())return;const t=this._tree?.renderStack;if(t)switch(this._effectMode){case"transition":e.equal(this._previousSibling)?(this._previousSibling=void 0,t.push(this)):e.equal(this._nextSibling)&&(this._nextSibling=void 0,t.push(this));break}}_processParent(){const e=this._tree?.renderStack;if(!e)return;const t=e.currentCall?.parentCall;if(!t)return;const r=t.calls;let i,n;r.forEach((o,a)=>{(o.renderable.equal(this._parent)||o.renderable.parent?.equal(this._parent))&&(i=i??a,n=a)}),!(i===void 0||n===void 0)&&(r.splice(n+1,0,e.createCall(this)),r.splice(i,0,e.createCall(this)))}_processChildren(){this.children.length&&(super.emit("process"),this._tree?.renderStack.push(this))}_onProcess(e=0){if(this.canProcess())switch(this._renderId=0,this._effectMode){case"before":super._onProcess(e);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(e){const t=this._tree?.getCurrentViewport();t&&this.apply(e,t,{redraw:!0})}_renderTransition(e){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&(this.viewport1.activateWithCopy(e,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(e),e.clear();else{const t=this._renderViewport;this._renderViewport=void 0,t&&(t.activate(e),e.clear(),this.viewport1.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,t,{from:this.viewport1,to:this.viewport2}),e.texture.unbind(0),e.texture.unbind(1))}}_renderParentOrChildren(e){if(this._renderId%2===0)this._renderViewport=this._tree?.getCurrentViewport(),this._renderViewport&&this.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(e),e.clear();else{const t=this._renderViewport;this._renderViewport=void 0,t&&(this.viewport1.activate(e),this.apply(e,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),t.activate(e),this.viewport1.texture.activate(e,0),Q.draw(e))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const e=this._parent.getRect();if(e)return[e.left/this.viewport1.width,e.top/this.viewport1.height,e.width/this.viewport1.width,e.height/this.viewport1.height]}}_render(e){switch(this._effectMode){case"before":this._renderBefore(e);break;case"transition":this._renderTransition(e);break;case"parent":case"children":default:this._renderParentOrChildren(e);break}this._renderId++}apply(e,t,r){this.material&&(r?.redraw?t.redraw(e,()=>{Q.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):Q.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:r?.from?r.from.width/r.from.height:0}))}},jr([w({internal:!0})],u.Effect.prototype,"material",2),jr([w()],u.Effect.prototype,"effectMode",2),jr([w({fallback:""})],u.Effect.prototype,"glsl",2),jr([w({fallback:""})],u.Effect.prototype,"glslSrc",2),u.Effect=jr([W("Effect")],u.Effect);class vf{currentCall;calls=[];createCall(e){return{renderable:e,parentCall:this.currentCall,fn:e.render.bind(e),calls:[]}}push(e){const t=this.createCall(e);return(this.currentCall?.calls??this.calls).push(t),t}render(e){this.calls.forEach(function t(r){r.fn(e,()=>{r.calls.forEach(t)})}),this.calls=[]}}var bf=Object.defineProperty,wf=Object.getOwnPropertyDescriptor,Wr=(s,e,t,r)=>{for(var i=r>1?void 0:r?wf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&bf(e,t,i),i};u.Timeline=class extends u.Node{static from(e,t=!1){const[r,i]=e?Array.isArray(e)?e:[0,e]:[];return new u.Timeline({startTime:r,endTime:i,loop:t})}constructor(e){super(),this.setProperties(e)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"startTime":this.startTime=Math.min(t,this.endTime);break;case"endTime":this.endTime=t||Number.MAX_SAFE_INTEGER;break}}addTime(e){const t=this.startTime,r=this.endTime;let i=this.currentTime;return i=i+e,this.loop&&i>r&&(i=t+i%r),i=Ge(i,t,r),this.currentTime=i,this.emit("updateCurrentTime",i,e),this}_process(e){super._process(e),this.addTime(e)}},Wr([w({fallback:0})],u.Timeline.prototype,"startTime",2),Wr([w({fallback:0})],u.Timeline.prototype,"currentTime",2),Wr([w({fallback:Number.MAX_SAFE_INTEGER})],u.Timeline.prototype,"endTime",2),Wr([w({fallback:!1})],u.Timeline.prototype,"loop",2),u.Timeline=Wr([W("Timeline")],u.Timeline);var xf=Object.getOwnPropertyDescriptor,Pf=(s,e,t,r)=>{for(var i=r>1?void 0:r?xf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.Window=class extends u.Viewport{},u.Window=Pf([W("Window")],u.Window);var Sf=Object.defineProperty,Ks=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Sf(e,t,i),i};class qr extends Ci{fonts;input=new $o;renderStack=new vf;root=new u.Window(!0).setTree(this);timeline;_backgroundColor=new Qe;_currentViewport;getCurrentViewport(){return this._currentViewport}setCurrentViewport(e){this._currentViewport=e}constructor(e=new u.Timeline){super(),this.timeline=e.setTree(this)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"backgroundColor":this._backgroundColor.value=t;break}}log(...e){this.debug&&console.log(`[modern-canvas][${performance.now().toFixed(4)}ms]`,...e)}_process(e=0){this.timeline.emit("process",e),this.emit("processing"),this.root.emit("process",e),this.emit("processed")}_render(e){this.emit("rendering"),this.renderStack.render(e),this._renderScreen(e),this.emit("rendered")}_renderScreen(e){e.state.reset(),e.framebuffer.bind(null),e.viewport.bind({x:0,y:0,width:this.root.width*e.pixelRatio,height:this.root.height*e.pixelRatio}),this.backgroundColor&&e.gl.clearColor(...this._backgroundColor.toArray()),e.clear(),this.backgroundColor&&e.gl.clearColor(0,0,0,0);const t=this.root.texture;t.activate(e,0),Q.draw(e),e.texture.unbind(t)}destroy(){super.destroy(),this.root.destroy(),this.input.removeEventListeners()}}Ks([w({internal:!0,fallback:!1})],qr.prototype,"processPaused"),Ks([w()],qr.prototype,"backgroundColor"),Ks([w({internal:!0,fallback:!1})],qr.prototype,"debug");var Cf=Object.getOwnPropertyDescriptor,Tf=(s,e,t,r)=>{for(var i=r>1?void 0:r?Cf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.Transition=class extends u.Effect{constructor(e,t=[]){super(),this.setProperties(e).append(t)}},u.Transition=Tf([W("Transition",{effectMode:"transition",processMode:"pausable",duration:2e3})],u.Transition);var Ef=Object.defineProperty,Mf=Object.getOwnPropertyDescriptor,Zs=(s,e,t,r)=>{for(var i=r>1?void 0:r?Mf(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Ef(e,t,i),i};u.Node2D=class extends u.CanvasItem{position=new de().on("update",()=>this.updateGlobalTransform());scale=new de(1,1).on("update",()=>this.updateGlobalTransform());skew=new de().on("update",()=>this.updateGlobalTransform());transform=new ve;globalPosition=new de;globalScale=new de;globalSkew=new de;globalTransform=new ve;_parentTransformDirtyId;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"rotation":this.updateGlobalTransform();break}}getTransformOrigin(){return new de(0,0)}updateTransform(e){const t=this.getTransformOrigin(),r=this.transform.identity().translate(-t.x,-t.y).scale(this.scale.x,this.scale.y).skew(this.skew.x,this.skew.y).rotate(this.rotation);e?.(r),r.translate(this.position.x,this.position.y).translate(t.x,t.y)}updateGlobalTransform(){this.updateTransform();const e=this.getParent();if(e?.globalTransform){const{globalPosition:t,globalScale:r,globalSkew:i,globalTransform:n,globalRotation:o}=e;this._parentTransformDirtyId=n.dirtyId,this.globalPosition.set(t.x+this.position.x,t.y+this.position.y),this.globalScale.set(r.x*this.scale.x,r.y*this.scale.y),this.globalSkew.set(i.x*this.skew.x,i.y*this.skew.y),this.globalRotation=o+this.rotation,e.globalTransform.multiply(this.transform,this.globalTransform)}else this.globalPosition.copy(this.position),this.globalScale.copy(this.scale),this.globalSkew.copy(this.skew),this.globalRotation=this.rotation,this.globalTransform.copy(this.transform);this.requestRelayout()}_transformVertices(e,t){let r,i,n,o,a,l;if(t){const h=this.globalTransform.clone();h.multiply(typeof t=="function"?t?.():t),[r,i,n,o,a,l]=h.toArray()}else[r,i,n,o,a,l]=this.globalTransform.toArray();const c=e.slice();for(let h=e.length,f=0;f<h;f+=2){const d=e[f],g=e[f+1];c[f]=r*d+i*g+n,c[f+1]=o*d+a*g+l}return c}_relayout(e){return e=super._relayout(e),this.updateGlobalTransform(),e.map(t=>({...t,vertices:this._transformVertices(t.vertices,t.vertTransform)}))}_process(e){super._process(e);const t=this.getParent();t?.globalTransform&&this._parentTransformDirtyId!==t?.globalTransform?.dirtyId&&this.requestRelayout()}toLocal(e,t){return this.globalTransform.applyAffineInverse(e,t)}toGlobal(e,t){return this.globalTransform.apply(e,t)}},Zs([w({internal:!0,fallback:0})],u.Node2D.prototype,"rotation",2),Zs([w({internal:!0,fallback:0})],u.Node2D.prototype,"globalRotation",2),u.Node2D=Zs([W("Node2D")],u.Node2D);var Af=Object.defineProperty,Of=Object.getOwnPropertyDescriptor,Js=(s,e,t,r)=>{for(var i=r>1?void 0:r?Of(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Af(e,t,i),i};u.Camera2D=class extends u.Node2D{zoom=new de(1,1).on("update",()=>this.updateCanvasTransform());maxZoom=new de(6,6);minZoom=new de(.1,.1);_screenOffset={x:0,y:0};constructor(e,t=[]){super(),this.setProperties(e).append(t)}addZoom(e,t=e){return this.zoom.set(Ge(this.zoom.x+e,this.minZoom.x,this.maxZoom.x),Ge(this.zoom.y+t,this.minZoom.y,this.maxZoom.y)),this}setZoom(e,t=e){return this.zoom.set(Ge(e,this.minZoom.x,this.maxZoom.x),Ge(t,this.minZoom.y,this.maxZoom.y)),this}_input(e,t){if(super._input(e,t),t==="keydown"){const r=e;!this.spaceKey&&r.code==="Space"&&(r.cursor="grab",this.spaceKey=!0)}else if(t==="keyup"){const r=e;r.code==="Space"&&(r.cursor="default",this.spaceKey=!1,this.grabbing=!1)}else if(t==="pointerdown"){const r=e;!this.grabbing&&(this.spaceKey||r.button===1)&&(this.grabbing=!0,r.cursor="grabbing",this._screenOffset={x:r.screenX,y:r.screenY})}else if(t==="pointermove"){const r=e;this.grabbing&&(this.position.add(-(this._screenOffset.x-r.screenX),-(this._screenOffset.y-r.screenY)),this._screenOffset={x:r.screenX,y:r.screenY})}else if(t==="pointerup"){const r=e;this.grabbing&&(this.grabbing=!1,this.spaceKey?r.cursor="grab":r.cursor="default")}else t==="wheel"&&this._onWheel(e)}_onWheel(e){if(e.ctrlKey){if(!(e.wheelDeltaY?Math.abs(Math.abs(e.wheelDeltaY)-Math.abs(3*e.deltaY))<3:e.deltaMode===0)){e.preventDefault();const r=this.zoom.x;this.addZoom(e.deltaY*-.015);const i=1-this.zoom.x/r;this.position.add((e.screenX-this.position.x)*i,(e.screenY-this.position.y)*i)}}else e.preventDefault(),this.position.add(-e.deltaX,-e.deltaY)}updateTransform(){super.updateTransform(),this.updateCanvasTransform()}updateCanvasTransform(){const e=this.getViewport();e&&(e.canvasTransform.identity().scale(this.zoom.x,this.zoom.y).translate(this.position.x,this.position.y),this.emit("updateCanvasTransform"))}toGlobal(e,t){const r=this.getViewport();if(!r)throw new Error("Failed to toGlobal, viewport is empty");return r.toCanvasGlobal(e,t)}toScreen(e,t){const r=this.getViewport();if(!r)throw new Error("Failed to toScreen, viewport is empty");return r.toCanvasScreen(e,t)}},Js([w({internal:!0,fallback:!1})],u.Camera2D.prototype,"spaceKey",2),Js([w({internal:!0,fallback:!1})],u.Camera2D.prototype,"grabbing",2),u.Camera2D=Js([W("Camera2D",{processMode:"disabled",renderMode:"disabled"})],u.Camera2D);const za={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};function kf(s){const e=new ks;if(s==="none")return e;const t=Or(s).reduce((r,{name:i,args:n})=>(r[i]=n[0].normalizedIntValue,r),{});Object.keys(za).forEach(r=>{t[r]=t[r]??za[r]});for(const r in t){const i=t[r];switch(r){case"hue-rotate":e.hueRotate(i*Ne);break;case"saturate":e.saturate(i);break;case"brightness":e.brightness(i);break;case"contrast":e.contrast(i);break;case"invert":e.invert(i);break;case"sepia":e.sepia(i);break;case"opacity":e.opacity(i);break;case"grayscale":e.grayscale(i);break}}return e}function Va(s,e,t,r=new ve){return s=!s||s==="none"?"":s,Or(s,{width:e,height:t}).reverse().forEach(({name:i,args:n})=>{const o=n.map(a=>a.normalizedIntValue);switch(i){case"translate":r.translate(o[0]*e,(o[1]??o[0])*t);break;case"translateX":r.translateX(o[0]*e);break;case"translateY":r.translateY(o[0]*t);break;case"translateZ":r.translateZ(o[0]);break;case"translate3d":r.translate3d(o[0]*e,(o[1]??o[0])*t,o[2]??o[1]??o[0]);break;case"scale":r.scale(o[0],o[1]??o[0]);break;case"scaleX":r.scaleX(o[0]);break;case"scaleY":r.scaleY(o[0]);break;case"scale3d":r.scale3d(o[0],o[1]??o[0],o[2]??o[1]??o[0]);break;case"rotate":r.rotate(o[0]*Ne);break;case"rotateX":r.rotateX(o[0]*Ne);break;case"rotateY":r.rotateY(o[0]*Ne);break;case"rotateZ":r.rotateZ(o[0]*Ne);break;case"rotate3d":r.rotate3d(o[0]*Ne,(o[1]??o[0])*Ne,(o[2]??o[1]??o[0])*Ne,(o[3]??o[2]??o[1]??o[0])*Ne);break;case"skew":r.skew(o[0],o[0]??o[1]);break;case"skewX":r.skewX(o[0]);break;case"skewY":r.skewY(o[0]);break;case"matrix":r.set(o);break}}),r}function Ga(s){const[e,t=e]=s.split(" ");return[e,t].map(r=>{switch(r=r.trim(),r){case"left":case"top":return 0;case"center":return .5;case"right":case"bottom":return 1;default:return Number(r)}})}var ja=Object.defineProperty,Df=Object.getOwnPropertyDescriptor,If=(s,e,t)=>e in s?ja(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Mt=(s,e,t,r)=>{for(var i=r>1?void 0:r?Df(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&ja(e,t,i),i},Rf=(s,e,t)=>If(s,e+"",t);u.ColorAdjustEffect=class extends u.Effect{constructor(e,t=[]){super(),this.setProperties(e).append(t)}apply(e,t){t.redraw(e,()=>{Q.draw(e,u.ColorAdjustEffect.material,{sampler:0,saturation:this.saturation,contrast:this.contrast,brightness:this.brightness,red:this.red,green:this.green,blue:this.blue,alpha:this.alpha,gamma:Math.max(this.gamma??1,1e-4)})})}},Rf(u.ColorAdjustEffect,"material",new se({vert:`precision mediump float;
120
120
  attribute vec2 position;
121
121
  attribute vec2 uv;
122
122
  varying vec2 vUv;
@@ -386,7 +386,7 @@ void main(void) {
386
386
  color.rgb = vec3((color.r + color.g + color.b) / 3.0);
387
387
  float alpha = texture2D(sampler, vUv).a;
388
388
  gl_FragColor = vec4(color.rgb * alpha, alpha);
389
- }`})),tl([w({fallback:5})],u.EmbossEffect.prototype,"strength",2),u.EmbossEffect=tl([W("EmbossEffect")],u.EmbossEffect);var rl=Object.defineProperty,td=Object.getOwnPropertyDescriptor,rd=(s,e,t)=>e in s?rl(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,pt=(s,e,t,r)=>{for(var i=r>1?void 0:r?td(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&rl(e,t,i),i},id=(s,e,t)=>rd(s,e+"",t);u.GlitchEffect=class extends u.Effect{_canvas;_texture;_sizes;_offsets;_needsRedraw=!1;constructor(e,t=[]){super(),this.setProperties(e).append(t),this._canvas=document.createElement("canvas"),this._canvas.width=4,this._canvas.height=this.sampleSize,this._texture=new le(this._canvas),this._sizes=new Float32Array(this.slices),this._offsets=new Float32Array(this.slices)}redraw(){const e=this.sampleSize,t=this._texture,r=this._canvas.getContext("2d");r.clearRect(0,0,8,e);let i,n=0;for(let o=0;o<this.slices;o++){i=Math.floor(this._offsets[o]*256);const a=this._sizes[o]*e,l=i>0?i:0,c=i<0?-i:0;r.fillStyle=`rgba(${l}, ${c}, 0, 1)`,r.fillRect(0,n>>0,e,a+1>>0),n+=a}t.requestUpload()}apply(e,t){this._needsRedraw||(this._needsRedraw=!0,this.redraw());const r=t.width,i=t.height,n=this.direction*(Math.PI/180),o=Math.sin(n),a=Math.cos(n);t.redraw(e,()=>{this._texture.activate(e,1),Q.draw(e,u.GlitchEffect.material,{sampler:0,filterClamp:[0,0,1,1],filterArea:[r,i,0,0],dimensions:[r,i],aspect:i/r,displacementMap:1,offset:this.offset,sinDir:o,cosDir:a,fillMode:this.fillMode,seed:this.seed,red:this.red,green:this.green,blue:this.blue})})}},id(u.GlitchEffect,"material",new se({vert:`precision mediump float;
389
+ }`})),tl([w({fallback:5})],u.EmbossEffect.prototype,"strength",2),u.EmbossEffect=tl([W("EmbossEffect")],u.EmbossEffect);var rl=Object.defineProperty,td=Object.getOwnPropertyDescriptor,rd=(s,e,t)=>e in s?rl(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,gt=(s,e,t,r)=>{for(var i=r>1?void 0:r?td(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&rl(e,t,i),i},id=(s,e,t)=>rd(s,e+"",t);u.GlitchEffect=class extends u.Effect{_canvas;_texture;_sizes;_offsets;_needsRedraw=!1;constructor(e,t=[]){super(),this.setProperties(e).append(t),this._canvas=document.createElement("canvas"),this._canvas.width=4,this._canvas.height=this.sampleSize,this._texture=new le(this._canvas),this._sizes=new Float32Array(this.slices),this._offsets=new Float32Array(this.slices)}redraw(){const e=this.sampleSize,t=this._texture,r=this._canvas.getContext("2d");r.clearRect(0,0,8,e);let i,n=0;for(let o=0;o<this.slices;o++){i=Math.floor(this._offsets[o]*256);const a=this._sizes[o]*e,l=i>0?i:0,c=i<0?-i:0;r.fillStyle=`rgba(${l}, ${c}, 0, 1)`,r.fillRect(0,n>>0,e,a+1>>0),n+=a}t.requestUpload()}apply(e,t){this._needsRedraw||(this._needsRedraw=!0,this.redraw());const r=t.width,i=t.height,n=this.direction*(Math.PI/180),o=Math.sin(n),a=Math.cos(n);t.redraw(e,()=>{this._texture.activate(e,1),Q.draw(e,u.GlitchEffect.material,{sampler:0,filterClamp:[0,0,1,1],filterArea:[r,i,0,0],dimensions:[r,i],aspect:i/r,displacementMap:1,offset:this.offset,sinDir:o,cosDir:a,fillMode:this.fillMode,seed:this.seed,red:this.red,green:this.green,blue:this.blue})})}},id(u.GlitchEffect,"material",new se({vert:`precision mediump float;
390
390
  attribute vec2 position;
391
391
  attribute vec2 uv;
392
392
  varying vec2 vUv;
@@ -487,7 +487,7 @@ void main(void) {
487
487
  gl_FragColor.g = texture2D(sampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g;
488
488
  gl_FragColor.b = texture2D(sampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b;
489
489
  gl_FragColor.a = texture2D(sampler, coord).a;
490
- }`})),pt([w({fallback:10})],u.GlitchEffect.prototype,"slices",2),pt([w({fallback:512})],u.GlitchEffect.prototype,"sampleSize",2),pt([w({fallback:100})],u.GlitchEffect.prototype,"offset",2),pt([w({fallback:0})],u.GlitchEffect.prototype,"direction",2),pt([w({fallback:2})],u.GlitchEffect.prototype,"fillMode",2),pt([w({fallback:0})],u.GlitchEffect.prototype,"seed",2),pt([w({default:()=>[2,2]})],u.GlitchEffect.prototype,"red",2),pt([w({default:()=>[-10,4]})],u.GlitchEffect.prototype,"green",2),pt([w({default:()=>[10,-4]})],u.GlitchEffect.prototype,"blue",2),u.GlitchEffect=pt([W("GlitchEffect")],u.GlitchEffect);var il=Object.defineProperty,sd=Object.getOwnPropertyDescriptor,nd=(s,e,t)=>e in s?il(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Bt=(s,e,t,r)=>{for(var i=r>1?void 0:r?sd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&il(e,t,i),i},od=(s,e,t)=>nd(s,e+"",t);const ad=`vec3 mod289(vec3 x)
490
+ }`})),gt([w({fallback:10})],u.GlitchEffect.prototype,"slices",2),gt([w({fallback:512})],u.GlitchEffect.prototype,"sampleSize",2),gt([w({fallback:100})],u.GlitchEffect.prototype,"offset",2),gt([w({fallback:0})],u.GlitchEffect.prototype,"direction",2),gt([w({fallback:2})],u.GlitchEffect.prototype,"fillMode",2),gt([w({fallback:0})],u.GlitchEffect.prototype,"seed",2),gt([w({default:()=>[2,2]})],u.GlitchEffect.prototype,"red",2),gt([w({default:()=>[-10,4]})],u.GlitchEffect.prototype,"green",2),gt([w({default:()=>[10,-4]})],u.GlitchEffect.prototype,"blue",2),u.GlitchEffect=gt([W("GlitchEffect")],u.GlitchEffect);var il=Object.defineProperty,sd=Object.getOwnPropertyDescriptor,nd=(s,e,t)=>e in s?il(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Bt=(s,e,t,r)=>{for(var i=r>1?void 0:r?sd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&il(e,t,i),i},od=(s,e,t)=>nd(s,e+"",t);const ad=`vec3 mod289(vec3 x)
491
491
  {
492
492
  return x - floor(x * (1.0 / 289.0)) * 289.0;
493
493
  }
@@ -705,7 +705,7 @@ void main(void) {
705
705
  } else {
706
706
  gl_FragColor = vec4(0.);
707
707
  }
708
- }`})),sn([w({protected:!0})],u.MaskEffect.prototype,"texture",2),sn([w({fallback:""})],u.MaskEffect.prototype,"src",2),u.MaskEffect=sn([W("MaskEffect")],u.MaskEffect);var al=Object.defineProperty,dd=Object.getOwnPropertyDescriptor,pd=(s,e,t)=>e in s?al(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Lt=(s,e,t,r)=>{for(var i=r>1?void 0:r?dd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&al(e,t,i),i},ll=(s,e,t)=>pd(s,typeof e!="symbol"?e+"":e,t);const gd=`precision highp float;
708
+ }`})),sn([w({internal:!0})],u.MaskEffect.prototype,"texture",2),sn([w({fallback:""})],u.MaskEffect.prototype,"src",2),u.MaskEffect=sn([W("MaskEffect")],u.MaskEffect);var al=Object.defineProperty,dd=Object.getOwnPropertyDescriptor,pd=(s,e,t)=>e in s?al(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Lt=(s,e,t,r)=>{for(var i=r>1?void 0:r?dd(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&al(e,t,i),i},ll=(s,e,t)=>pd(s,typeof e!="symbol"?e+"":e,t);const gd=`precision highp float;
709
709
  varying vec2 vUv;
710
710
  uniform sampler2D sampler;
711
711
  uniform vec2 uThickness;
@@ -859,12 +859,12 @@ void main() {
859
859
  color /= total;
860
860
 
861
861
  gl_FragColor = color;
862
- }`})),Yr([w()],u.ZoomBlurEffect.prototype,"center",2),Yr([w({fallback:20})],u.ZoomBlurEffect.prototype,"innerRadius",2),Yr([w({fallback:-1})],u.ZoomBlurEffect.prototype,"radius",2),Yr([w({fallback:.1})],u.ZoomBlurEffect.prototype,"strength",2),u.ZoomBlurEffect=Yr([W("ZoomBlurEffect")],u.ZoomBlurEffect);function Li(s,e){let t=!1;const{left:r=0,top:i=0,width:n,height:o}=e,a=new ve().translate(-r,-i).scale(1/n,1/o);if(s.cropRect){const{left:l=0,top:c=0,right:h=0,bottom:f=0}=s.cropRect;a.scale(Math.abs(1-(l+h)),Math.abs(1-(c+f))).translate(l,c),t=!0}if(s.tile){const{translateX:l=0,translateY:c=0,scaleX:h=1,scaleY:f=1}=s.tile;a.translate(-l/n,-c/o).scale(1/h,1/f),t=!0}else if(s.stretchRect){const{left:l=0,top:c=0,right:h=0,bottom:f=0}=s.stretchRect;a.scale(Math.abs(1-(-l+-h)),Math.abs(1-(-c+-f))).translate(-l,-c),t=!0}return{disableWrapMode:t,uvTransform:a}}var xd=Object.defineProperty,tt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&xd(e,t,i),i};class Te extends It{constructor(e){super(),this.parent=e}_texture;_setProperties(e){return super.setProperties(e)}setProperties(e){return this._setProperties(K(e)?void 0:ct(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"color":case"cropRect":case"stretchRect":case"dpi":case"rotateWithShape":case"tile":case"opacity":case"enabled":this.parent.requestRedraw();break;case"image":case"linearGradient":case"radialGradient":this._updateTexture();break}}async loadTexture(){return this.linearGradient||this.radialGradient?new $r(this.linearGradient??this.radialGradient,this.parent.size.width,this.parent.size.height):K(this.image)?void 0:(this.parent.tree?.log(`load image ${this.image}`),await nt.texture.load(this.image))}async _updateTexture(){this._texture=await this.loadTexture(),this.parent.requestRedraw()}canDraw(){return!!(this.enabled&&(this._texture||this.color))}draw(){const e=this.parent.context,{uvTransform:t,disableWrapMode:r}=Li(this,{width:this.parent.size.width,height:this.parent.size.height});e.uvTransform=t,e.fillStyle=this._texture??this.color,e.fill({disableWrapMode:r})}}tt([w({fallback:!0})],Te.prototype,"enabled"),tt([w()],Te.prototype,"color"),tt([w()],Te.prototype,"image"),tt([w()],Te.prototype,"linearGradient"),tt([w()],Te.prototype,"radialGradient"),tt([w()],Te.prototype,"cropRect"),tt([w()],Te.prototype,"stretchRect"),tt([w()],Te.prototype,"dpi"),tt([w()],Te.prototype,"rotateWithShape"),tt([w()],Te.prototype,"tile"),tt([w()],Te.prototype,"opacity");var Pd=Object.defineProperty,Sd=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Pd(e,t,i),i};class nn extends Te{setProperties(e){return super._setProperties(K(e)?void 0:Wc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"fillWithShape":this.parent.requestRedraw();break}}}Sd([w()],nn.prototype,"fillWithShape");var Cd=Object.defineProperty,Td=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Cd(e,t,i),i};class on extends Te{setProperties(e){return super._setProperties(K(e)?void 0:qc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"fillWithShape":this.parent.requestRedraw();break}}}Td([w()],on.prototype,"fillWithShape");var Ed=Object.defineProperty,Kr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Ed(e,t,i),i};class Zt extends Te{setProperties(e){return super._setProperties(K(e)?void 0:wi(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"width":case"style":case"lineCap":case"lineJoin":case"enabled":this.parent.requestRedraw();break}}canDraw(){return!!(this.enabled&&(this.width||this.color||super.canDraw()))}draw(){const e=this.parent.context,{uvTransform:t,disableWrapMode:r}=Li(this,{width:this.parent.size.width,height:this.parent.size.height});e.lineWidth=this.width||1,e.uvTransform=t,e.strokeStyle=this._texture??this.color,e.lineCap=this.lineCap,e.lineJoin=this.lineJoin,e.stroke({disableWrapMode:r})}}Kr([w({fallback:"#00000000"})],Zt.prototype,"color"),Kr([w({fallback:0})],Zt.prototype,"width"),Kr([w({fallback:"solid"})],Zt.prototype,"style"),Kr([w({fallback:"butt"})],Zt.prototype,"lineCap"),Kr([w({fallback:"miter"})],Zt.prototype,"lineJoin");var Md=Object.defineProperty,Zr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Md(e,t,i),i};class Jt extends It{constructor(e){super(),this.parent=e}setProperties(e){return super.setProperties(K(e)?void 0:Xc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"color":case"blur":case"offsetX":case"offsetY":this.updateEffect();break}}updateEffect(){const e="__$shadow";let t=this.parent.getNode(e);this.blur||this.offsetX||this.offsetY?(t||(t=new u.DropShadowEffect({name:e}),this.parent.appendChild(t,"back")),t.setProperties(this.getProperties())):t&&this.parent.removeChild(t)}}Zr([w({fallback:!0})],Jt.prototype,"enabled"),Zr([w({fallback:"#000000FF"})],Jt.prototype,"color"),Zr([w({fallback:0})],Jt.prototype,"blur"),Zr([w({fallback:0})],Jt.prototype,"offsetY"),Zr([w({fallback:0})],Jt.prototype,"offsetX");var Ad=Object.defineProperty,Jr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Ad(e,t,i),i};class Qt extends It{constructor(e){super(),this.parent=e,this._updatePath2DSet()}_path2DSet=new Tt;setProperties(e){return super.setProperties(K(e)?void 0:Yc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"svg":case"paths":case"viewBox":case"enabled":this._updatePath2DSet(),this.parent.requestRedraw();break}}_updatePath2DSet(){let e;if(this.svg){const o=Fs(this.svg);this._path2DSet=zs(o),e=this._path2DSet.viewBox}else this.paths?.forEach((o,a)=>{const{data:l,...c}=o,h=new ge;h.style=c,h.addData(l),this._path2DSet.paths[a]=h});if(!e){const o=this._path2DSet.getBoundingBox();e=o?[o.x,o.y,o.width||1,o.height||1]:[0,0,1,1]}const[t,r,i,n]=e;this._path2DSet.paths.forEach(o=>{o.applyTransform(new be().translate(-t,-r).scale(1/i,1/n))})}draw(){if(this.enabled&&this._path2DSet.paths.length){const e=this.parent.context,{width:t,height:r}=this.parent.size;this._path2DSet.paths.forEach(i=>{e.addPath(i.clone().applyTransform(new be().scale(t,r)))})}else this.drawRect()}drawRect(){const e=this.parent.context,{width:t,height:r}=this.parent.size,{borderRadius:i}=this.parent.style;t&&r&&(i?e.roundRect(0,0,t,r,i):e.rect(0,0,t,r))}}Jr([w({fallback:!0})],Qt.prototype,"enabled"),Jr([w()],Qt.prototype,"preset"),Jr([w()],Qt.prototype,"svg"),Jr([w()],Qt.prototype,"viewBox"),Jr([w()],Qt.prototype,"paths");class Qr extends St{constructor(e){super(),this.setProperties(e)}}const fl=vo();for(const s in fl){const e=fl[s];yi(Qr,s,{fallback:e})}var Ee=Uint8Array,We=Uint16Array,an=Int32Array,Ni=new Ee([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fi=new Ee([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ln=new Ee([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dl=function(s,e){for(var t=new We(31),r=0;r<31;++r)t[r]=e+=1<<s[r-1];for(var i=new an(t[30]),r=1;r<30;++r)for(var n=t[r];n<t[r+1];++n)i[n]=n-t[r]<<5|r;return{b:t,r:i}},pl=dl(Ni,2),gl=pl.b,cn=pl.r;gl[28]=258,cn[258]=28;for(var ml=dl(Fi,0),Od=ml.b,yl=ml.r,hn=new We(32768),te=0;te<32768;++te){var Nt=(te&43690)>>1|(te&21845)<<1;Nt=(Nt&52428)>>2|(Nt&13107)<<2,Nt=(Nt&61680)>>4|(Nt&3855)<<4,hn[te]=((Nt&65280)>>8|(Nt&255)<<8)>>1}for(var gt=(function(s,e,t){for(var r=s.length,i=0,n=new We(e);i<r;++i)s[i]&&++n[s[i]-1];var o=new We(e);for(i=1;i<e;++i)o[i]=o[i-1]+n[i-1]<<1;var a;if(t){a=new We(1<<e);var l=15-e;for(i=0;i<r;++i)if(s[i])for(var c=i<<4|s[i],h=e-s[i],f=o[s[i]-1]++<<h,d=f|(1<<h)-1;f<=d;++f)a[hn[f]>>l]=c}else for(a=new We(r),i=0;i<r;++i)s[i]&&(a[i]=hn[o[s[i]-1]++]>>15-s[i]);return a}),Ft=new Ee(288),te=0;te<144;++te)Ft[te]=8;for(var te=144;te<256;++te)Ft[te]=9;for(var te=256;te<280;++te)Ft[te]=7;for(var te=280;te<288;++te)Ft[te]=8;for(var ei=new Ee(32),te=0;te<32;++te)ei[te]=5;var kd=gt(Ft,9,0),Dd=gt(Ft,9,1),Id=gt(ei,5,0),Rd=gt(ei,5,1),un=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},rt=function(s,e,t){var r=e/8|0;return(s[r]|s[r+1]<<8)>>(e&7)&t},fn=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},dn=function(s){return(s+7)/8|0},_l=function(s,e,t){return(t==null||t>s.length)&&(t=s.length),new Ee(s.subarray(e,t))},Ud=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],it=function(s,e,t){var r=new Error(e||Ud[s]);if(r.code=s,Error.captureStackTrace&&Error.captureStackTrace(r,it),!t)throw r;return r},Bd=function(s,e,t,r){var i=s.length,n=0;if(!i||e.f&&!e.l)return t||new Ee(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new Ee(i*3));var c=function(Be){var $e=t.length;if(Be>$e){var Se=new Ee(Math.max($e*2,Be));Se.set(t),t=Se}},h=e.f||0,f=e.p||0,d=e.b||0,g=e.l,p=e.d,y=e.m,m=e.n,P=i*8;do{if(!g){h=rt(s,f,1);var E=rt(s,f+1,3);if(f+=3,E)if(E==1)g=Dd,p=Rd,y=9,m=5;else if(E==2){var b=rt(s,f,31)+257,C=rt(s,f+10,15)+4,T=b+rt(s,f+5,31)+1;f+=14;for(var B=new Ee(T),G=new Ee(19),R=0;R<C;++R)G[ln[R]]=rt(s,f+R*3,7);f+=C*3;for(var U=un(G),V=(1<<U)-1,L=gt(G,U,1),R=0;R<T;){var D=L[rt(s,f,V)];f+=D&15;var x=D>>4;if(x<16)B[R++]=x;else{var H=0,I=0;for(x==16?(I=3+rt(s,f,3),f+=2,H=B[R-1]):x==17?(I=3+rt(s,f,7),f+=3):x==18&&(I=11+rt(s,f,127),f+=7);I--;)B[R++]=H}}var N=B.subarray(0,b),$=B.subarray(b);y=un(N),m=un($),g=gt(N,y,1),p=gt($,m,1)}else it(1);else{var x=dn(f)+4,S=s[x-4]|s[x-3]<<8,_=x+S;if(_>i){l&&it(0);break}a&&c(d+S),t.set(s.subarray(x,_),d),e.b=d+=S,e.p=f=_*8,e.f=h;continue}if(f>P){l&&it(0);break}}a&&c(d+131072);for(var O=(1<<y)-1,j=(1<<m)-1,A=f;;A=f){var H=g[fn(s,f)&O],M=H>>4;if(f+=H&15,f>P){l&&it(0);break}if(H||it(2),M<256)t[d++]=M;else if(M==256){A=f,g=null;break}else{var F=M-254;if(M>264){var R=M-257,z=Ni[R];F=rt(s,f,(1<<z)-1)+gl[R],f+=z}var Y=p[fn(s,f)&j],J=Y>>4;Y||it(3),f+=Y&15;var $=Od[J];if(J>3){var z=Fi[J];$+=fn(s,f)&(1<<z)-1,f+=z}if(f>P){l&&it(0);break}a&&c(d+131072);var oe=d+F;if(d<$){var wt=n-$,Ze=Math.min($,oe);for(wt+d<0&&it(3);d<Ze;++d)t[d]=r[wt+d]}for(;d<oe;++d)t[d]=t[d-$]}}e.l=g,e.p=A,e.b=d,e.f=h,g&&(h=1,e.m=y,e.d=p,e.n=m)}while(!h);return d!=t.length&&o?_l(t,0,d):t.subarray(0,d)},At=function(s,e,t){t<<=e&7;var r=e/8|0;s[r]|=t,s[r+1]|=t>>8},ti=function(s,e,t){t<<=e&7;var r=e/8|0;s[r]|=t,s[r+1]|=t>>8,s[r+2]|=t>>16},pn=function(s,e){for(var t=[],r=0;r<s.length;++r)s[r]&&t.push({s:r,f:s[r]});var i=t.length,n=t.slice();if(!i)return{t:xl,l:0};if(i==1){var o=new Ee(t[0].s+1);return o[t[0].s]=1,{t:o,l:1}}t.sort(function(_,b){return _.f-b.f}),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,h=1,f=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=i-1;)a=t[t[c].f<t[f].f?c++:f++],l=t[c!=h&&t[c].f<t[f].f?c++:f++],t[h++]={s:-1,f:a.f+l.f,l:a,r:l};for(var d=n[0].s,r=1;r<i;++r)n[r].s>d&&(d=n[r].s);var g=new We(d+1),p=gn(t[h-1],g,0);if(p>e){var r=0,y=0,m=p-e,P=1<<m;for(n.sort(function(b,C){return g[C.s]-g[b.s]||b.f-C.f});r<i;++r){var E=n[r].s;if(g[E]>e)y+=P-(1<<p-g[E]),g[E]=e;else break}for(y>>=m;y>0;){var x=n[r].s;g[x]<e?y-=1<<e-g[x]++-1:++r}for(;r>=0&&y;--r){var S=n[r].s;g[S]==e&&(--g[S],++y)}p=e}return{t:new Ee(g),l:p}},gn=function(s,e,t){return s.s==-1?Math.max(gn(s.l,e,t+1),gn(s.r,e,t+1)):e[s.s]=t},vl=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new We(++e),r=0,i=s[0],n=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(s[a]==i&&a!=e)++n;else{if(!i&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(i),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(i);n=1,i=s[a]}return{c:t.subarray(0,r),n:e}},ri=function(s,e){for(var t=0,r=0;r<e.length;++r)t+=s[r]*e[r];return t},bl=function(s,e,t){var r=t.length,i=dn(e+2);s[i]=r&255,s[i+1]=r>>8,s[i+2]=s[i]^255,s[i+3]=s[i+1]^255;for(var n=0;n<r;++n)s[i+n+4]=t[n];return(i+4+r)*8},wl=function(s,e,t,r,i,n,o,a,l,c,h){At(e,h++,t),++i[256];for(var f=pn(i,15),d=f.t,g=f.l,p=pn(n,15),y=p.t,m=p.l,P=vl(d),E=P.c,x=P.n,S=vl(y),_=S.c,b=S.n,C=new We(19),T=0;T<E.length;++T)++C[E[T]&31];for(var T=0;T<_.length;++T)++C[_[T]&31];for(var B=pn(C,7),G=B.t,R=B.l,U=19;U>4&&!G[ln[U-1]];--U);var V=c+5<<3,L=ri(i,Ft)+ri(n,ei)+o,D=ri(i,d)+ri(n,y)+o+14+3*U+ri(C,G)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&V<=L&&V<=D)return bl(e,h,s.subarray(l,l+c));var H,I,N,$;if(At(e,h,1+(D<L)),h+=2,D<L){H=gt(d,g,0),I=d,N=gt(y,m,0),$=y;var O=gt(G,R,0);At(e,h,x-257),At(e,h+5,b-1),At(e,h+10,U-4),h+=14;for(var T=0;T<U;++T)At(e,h+3*T,G[ln[T]]);h+=3*U;for(var j=[E,_],A=0;A<2;++A)for(var M=j[A],T=0;T<M.length;++T){var F=M[T]&31;At(e,h,O[F]),h+=G[F],F>15&&(At(e,h,M[T]>>5&127),h+=M[T]>>12)}}else H=kd,I=Ft,N=Id,$=ei;for(var T=0;T<a;++T){var z=r[T];if(z>255){var F=z>>18&31;ti(e,h,H[F+257]),h+=I[F+257],F>7&&(At(e,h,z>>23&31),h+=Ni[F]);var Y=z&31;ti(e,h,N[Y]),h+=$[Y],Y>3&&(ti(e,h,z>>5&8191),h+=Fi[Y])}else ti(e,h,H[z]),h+=I[z]}return ti(e,h,H[256]),h+I[256]},Ld=new an([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),xl=new Ee(0),Nd=function(s,e,t,r,i,n){var o=n.z||s.length,a=new Ee(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),c=n.l,h=(n.r||0)&7;if(e){h&&(l[0]=n.r>>3);for(var f=Ld[e-1],d=f>>13,g=f&8191,p=(1<<t)-1,y=n.p||new We(32768),m=n.h||new We(p+1),P=Math.ceil(t/3),E=2*P,x=function(ze){return(s[ze]^s[ze+1]<<P^s[ze+2]<<E)&p},S=new an(25e3),_=new We(288),b=new We(32),C=0,T=0,B=n.i||0,G=0,R=n.w||0,U=0;B+2<o;++B){var V=x(B),L=B&32767,D=m[V];if(y[L]=D,m[V]=L,R<=B){var H=o-B;if((C>7e3||G>24576)&&(H>423||!c)){h=wl(s,l,0,S,_,b,T,G,U,B-U,h),G=C=T=0,U=B;for(var I=0;I<286;++I)_[I]=0;for(var I=0;I<30;++I)b[I]=0}var N=2,$=0,O=g,j=L-D&32767;if(H>2&&V==x(B-j))for(var A=Math.min(d,H)-1,M=Math.min(32767,B),F=Math.min(258,H);j<=M&&--O&&L!=D;){if(s[B+N]==s[B+N-j]){for(var z=0;z<F&&s[B+z]==s[B+z-j];++z);if(z>N){if(N=z,$=j,z>A)break;for(var Y=Math.min(j,z-2),J=0,I=0;I<Y;++I){var oe=B-j+I&32767,wt=y[oe],Ze=oe-wt&32767;Ze>J&&(J=Ze,D=oe)}}}L=D,D=y[L],j+=L-D&32767}if($){S[G++]=268435456|cn[N]<<18|yl[$];var Be=cn[N]&31,$e=yl[$]&31;T+=Ni[Be]+Fi[$e],++_[257+Be],++b[$e],R=B+N,++C}else S[G++]=s[B],++_[s[B]]}}for(B=Math.max(B,R);B<o;++B)S[G++]=s[B],++_[s[B]];h=wl(s,l,c,S,_,b,T,G,U,B-U,h),c||(n.r=h&7|l[h/8|0]<<3,h-=7,n.h=m,n.p=y,n.i=B,n.w=R)}else{for(var B=n.w||0;B<o+c;B+=65535){var Se=B+65535;Se>=o&&(l[h/8|0]=c,Se=o),h=bl(l,h+1,s.subarray(B,Se))}n.i=o}return _l(a,0,r+dn(h)+i)},Pl=function(){var s=1,e=0;return{p:function(t){for(var r=s,i=e,n=t.length|0,o=0;o!=n;){for(var a=Math.min(o+2655,n);o<a;++o)i+=r+=t[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}s=r,e=i},d:function(){return s%=65521,e%=65521,(s&255)<<24|(s&65280)<<8|(e&255)<<8|e>>8}}},Fd=function(s,e,t,r,i){if(!i&&(i={l:1},e.dictionary)){var n=e.dictionary.subarray(-32768),o=new Ee(n.length+s.length);o.set(n),o.set(s,n.length),s=o,i.w=n.length}return Nd(s,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(s.length)))*1.5):20:12+e.mem,t,r,i)},Sl=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8},$d=function(s,e){var t=e.level,r=t==0?0:t<6?1:t==9?3:2;if(s[0]=120,s[1]=r<<6|(e.dictionary&&32),s[1]|=31-(s[0]<<8|s[1])%31,e.dictionary){var i=Pl();i.p(e.dictionary),Sl(s,2,i.d())}},zd=function(s,e){return((s[0]&15)!=8||s[0]>>4>7||(s[0]<<8|s[1])%31)&&it(6,"invalid zlib data"),(s[1]>>5&1)==1&&it(6,"invalid zlib data: "+(s[1]&32?"need":"unexpected")+" dictionary"),(s[1]>>3&4)+2};function Vd(s,e){e||(e={});var t=Pl();t.p(s);var r=Fd(s,e,e.dictionary?6:2,4);return $d(r,e),Sl(r,r.length-4,t.d()),r}function Gd(s,e){return Bd(s.subarray(zd(s),-4),{i:2},e,e)}var jd=typeof TextDecoder<"u"&&new TextDecoder,Wd=0;try{jd.decode(xl,{stream:!0}),Wd=1}catch{}const qd="modern-font";function ii(s,e){if(!s)throw new Error(`[${qd}] ${e}`)}function Xd(s){if("buffer"in s){const e=s.buffer;return s.byteOffset>0||s.byteLength<s.buffer.byteLength?e.slice(s.byteOffset,s.byteOffset+s.byteLength):e}else return s}function mr(s){return"buffer"in s?new DataView(s.buffer,s.byteOffset,s.byteLength):new DataView(s)}function Hd(s){let e="";for(let t=0,r=s.length,i;t<r;t++)i=s.charCodeAt(t),i!==0&&(e+=String.fromCharCode(i));return e}function $i(s){s=Hd(s);const e=[];for(let t=0,r=s.length,i;t<r;t++)i=s.charCodeAt(t),e.push(i>>8),e.push(i&255);return e}function Yd(s){let e="";for(let t=0,r=s.length;t<r;t++)s[t]<127?e+=String.fromCharCode(s[t]):e+=`%${(256+s[t]).toString(16).slice(1)}`;return unescape(e)}function Kd(s){let e="";for(let t=0,r=s.length;t<r;t+=2)e+=String.fromCharCode((s[t]<<8)+s[t+1]);return e}var Zd=Object.defineProperty,Me=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Zd(e,t,i),i};const si={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Ae(){return function(s,e){Object.defineProperty(s.constructor.prototype,e,{get(){if(typeof e=="string"){if(e.startsWith("read"))return(...t)=>this.read(e.substring(4).toLowerCase(),...t);if(e.startsWith("write"))return(...t)=>this.write(e.substring(5).toLowerCase(),...t)}},configurable:!0,enumerable:!0})}}class me extends DataView{constructor(e,t,r,i){super(Xd(e),t,r),this.littleEndian=i}cursor=0;readColumn(e){if(e.size){const t=Array.from({length:e.size},(r,i)=>this.read(e.type,e.offset+i));switch(e.type){case"char":return t.join("");default:return t}}else return this.read(e.type,e.offset)}writeColumn(e,t){e.size?Array.from({length:e.size},(r,i)=>{this.write(e.type,t[i],e.offset+i)}):this.write(e.type,t,e.offset)}read(e,t=this.cursor,r=this.littleEndian){switch(e){case"char":return this.readChar(t);case"fixed":return this.readFixed(t,r);case"longDateTime":return this.readLongDateTime(t,r)}const i=`get${e.replace(/^\S/,l=>l.toUpperCase())}`,n=this,a=n[i]?.bind(n)?.(t,r);return this.cursor+=si[e],a}readUint24(e=this.cursor){const[t,r,i]=this.readBytes(e,3);return(t<<16)+(r<<8)+i}readBytes(e,t){t==null&&(t=e,e=this.cursor);const r=[];for(let i=0;i<t;++i)r.push(this.getUint8(e+i));return this.cursor=e+t,r}readString(e,t){const r=this.readBytes(e,t);let i="";for(let n=0,o=r.length;n<o;n++)i+=String.fromCharCode(r[n]);return i}readFixed(e,t){const r=this.readInt32(e,t)/65536;return Math.ceil(r*1e5)/1e5}readLongDateTime(e=this.cursor,t){const r=this.readUint32(e+4,t),i=new Date;return i.setTime(r*1e3+-20775456e5),i}readChar(e){return this.readString(e,1)}write(e,t,r=this.cursor,i=this.littleEndian){switch(e){case"char":return this.writeChar(t,r);case"fixed":return this.writeFixed(t,r);case"longDateTime":return this.writeLongDateTime(t,r)}const n=`set${e.replace(/^\S/,c=>c.toUpperCase())}`,o=this,l=o[n]?.bind(o)?.(r,t,i);return this.cursor+=si[e.toLowerCase()],l}writeString(e="",t=this.cursor){const r=e.replace(/[^\x00-\xFF]/g,"11").length;this.seek(t);for(let i=0,n=e.length,o;i<n;++i)o=e.charCodeAt(i)||0,o>127?this.writeUint16(o):this.writeUint8(o);return this.cursor+=r,this}writeChar(e,t){return this.writeString(e,t)}writeFixed(e,t){return this.writeInt32(Math.round(e*65536),t),this}writeLongDateTime(e,t=this.cursor){typeof e>"u"?e=-20775456e5:typeof e.getTime=="function"?e=e.getTime():/^\d+$/.test(e)?e=+e:e=Date.parse(e);const i=Math.round((e- -20775456e5)/1e3);return this.writeUint32(0,t),this.writeUint32(i,t+4),this}writeBytes(e,t=this.cursor){let r;if(Array.isArray(e)){r=e.length;for(let i=0;i<r;++i)this.setUint8(t+i,e[i])}else{const i=mr(e);r=i.byteLength;for(let n=0;n<r;++n)this.setUint8(t+n,i.getUint8(n))}return this.cursor=t+r,this}seek(e){return this.cursor=e,this}}Me([Ae()],me.prototype,"readInt8"),Me([Ae()],me.prototype,"readInt16"),Me([Ae()],me.prototype,"readInt32"),Me([Ae()],me.prototype,"readUint8"),Me([Ae()],me.prototype,"readUint16"),Me([Ae()],me.prototype,"readUint32"),Me([Ae()],me.prototype,"readFloat32"),Me([Ae()],me.prototype,"readFloat64"),Me([Ae()],me.prototype,"writeInt8"),Me([Ae()],me.prototype,"writeInt16"),Me([Ae()],me.prototype,"writeInt32"),Me([Ae()],me.prototype,"writeUint8"),Me([Ae()],me.prototype,"writeUint16"),Me([Ae()],me.prototype,"writeUint32"),Me([Ae()],me.prototype,"writeFloat32"),Me([Ae()],me.prototype,"writeFloat64");const Cl=new WeakMap;function v(s){const e=typeof s=="object"?s:{type:s},{size:t=1,type:r}=e;return(i,n)=>{if(typeof n!="string")return;let o=Cl.get(i);o||(o={columns:[],byteLength:0},Cl.set(i,o));const a={...e,name:n,byteLength:t*si[r],offset:e.offset??o.columns.reduce((l,c)=>l+c.byteLength,0)};o.columns.push(a),o.byteLength=o.columns.reduce((l,c)=>l+si[c.type]*(c.size??1),0),Object.defineProperty(i.constructor.prototype,n,{get(){return this.view.readColumn(a)},set(l){this.view.writeColumn(a,l)},configurable:!0,enumerable:!0})}}class qe{view;constructor(e,t,r,i){this.view=new me(e,t,r,i)}}class zi extends qe{get buffer(){return this.view.buffer}toBuffer(){return this.view.buffer.slice(this.view.byteOffset,this.view.byteOffset+this.view.byteLength)}toBlob(){return new Blob([new Uint8Array(this.view.buffer,this.view.byteOffset,this.view.byteLength)],{type:this.mimeType})}toFontFace(e){return new FontFace(e,this.view.buffer)}}var Jd=Object.defineProperty,De=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Jd(e,t,i),i};const Ie=class fc extends zi{format="EmbeddedOpenType";mimeType="application/vnd.ms-fontobject";static from(e){const t=e.sfnt,i=t.name.names,n=$i(i.fontFamily||""),o=n.length,a=$i(i.fontStyle||""),l=a.length,c=$i(i.version||""),h=c.length,f=$i(i.fullName||""),d=f.length,g=86+o+4+l+4+h+4+d+2+e.view.byteLength,p=new fc(new ArrayBuffer(g),0,g,!0);p.EOTSize=p.view.byteLength,p.FontDataSize=e.view.byteLength,p.Version=131073,p.Flags=0,p.Charset=1,p.MagicNumber=20556,p.Padding1=0,p.CheckSumAdjustment=t.head.checkSumAdjustment;const y=t.os2;return y&&(p.FontPANOSE=y.fontPANOSE,p.Italic=y.fsSelection,p.Weight=y.usWeightClass,p.fsType=y.fsType,p.UnicodeRange=y.ulUnicodeRange,p.CodePageRange=y.ulCodePageRange),p.view.writeUint16(o),p.view.writeBytes(n),p.view.writeUint16(0),p.view.writeUint16(l),p.view.writeBytes(a),p.view.writeUint16(0),p.view.writeUint16(h),p.view.writeBytes(c),p.view.writeUint16(0),p.view.writeUint16(d),p.view.writeBytes(f),p.view.writeUint16(0),p.view.writeUint16(0),p.view.writeBytes(e.view),p}};De([v("uint32")],Ie.prototype,"EOTSize"),De([v("uint32")],Ie.prototype,"FontDataSize"),De([v("uint32")],Ie.prototype,"Version"),De([v("uint32")],Ie.prototype,"Flags"),De([v({type:"uint8",size:10})],Ie.prototype,"FontPANOSE"),De([v("uint8")],Ie.prototype,"Charset"),De([v("uint8")],Ie.prototype,"Italic"),De([v("uint32")],Ie.prototype,"Weight"),De([v("uint16")],Ie.prototype,"fsType"),De([v("uint16")],Ie.prototype,"MagicNumber"),De([v({type:"uint8",size:16})],Ie.prototype,"UnicodeRange"),De([v({type:"uint8",size:8})],Ie.prototype,"CodePageRange"),De([v("uint32")],Ie.prototype,"CheckSumAdjustment"),De([v({type:"uint8",size:16})],Ie.prototype,"Reserved"),De([v("uint16")],Ie.prototype,"Padding1");var Qd=Object.defineProperty,Vi=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Qd(e,t,i),i};class yr extends qe{constructor(e,t){super(e,t,16)}}Vi([v({type:"char",size:4})],yr.prototype,"tag"),Vi([v("uint32")],yr.prototype,"checkSum"),Vi([v("uint32")],yr.prototype,"offset"),Vi([v("uint32")],yr.prototype,"length");const mn=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],ep=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"];class yn{index;name;isComposite=!1;components=[];pathCommands=[];constructor(e){const t={...e};if(this.index=t.index??0,t.name===".notdef"?t.unicode=void 0:t.name===".null"&&(t.unicode=0),t.unicode===0&&t.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=t.name??null,t.unicode&&(this.unicode=t.unicode),t.unicodes?this.unicodes=t.unicodes:t.unicode&&(this.unicodes=[t.unicode])}getPathCommands(e=0,t=0,r=72,i={},n){const o=1/(n?.unitsPerEm??1e3)*r,{xScale:a=o,yScale:l=o}=i,c=this.pathCommands,h=[];for(let f=0,d=c.length;f<d;f+=1){const g=c[f];g.type==="M"?h.push({type:"M",x:e+g.x*a,y:t+-g.y*l}):g.type==="L"?h.push({type:"L",x:e+g.x*a,y:t+-g.y*l}):g.type==="Q"?h.push({type:"Q",x1:e+g.x1*a,y1:t+-g.y1*l,x:e+g.x*a,y:t+-g.y*l}):g.type==="C"?h.push({type:"C",x1:e+g.x1*a,y1:t+-g.y1*l,x2:e+g.x2*a,y2:t+-g.y2*l,x:e+g.x*a,y:t+-g.y*l}):g.type==="Z"&&h.push({type:"Z"})}return h}}class tp extends yn{parse(e,t,r){const i=this,{nominalWidthX:n,defaultWidthX:o,gsubrsBias:a,subrsBias:l}=e,c=e.topDict.paintType,h=this.index;let f,d,g,p;const y=[],m=[];let P=0,E=!1,x=!1,S=o,_=0,b=0;function C(L,D){y.push({type:"L",x:L,y:D})}function T(L,D,H,I,N,$){y.push({type:"C",x1:L,y1:D,x2:H,y2:I,x:N,y:$})}function B(L,D){x&&c!==2&&G(),x=!0,y.push({type:"M",x:L,y:D})}function G(){y.push({type:"Z"})}function R(L){y.push(...L)}function U(){m.length%2!==0&&!E&&(S=m.shift()+n),P+=m.length>>1,m.length=0,E=!0}function V(L){let D,H,I,N,$,O,j,A,M,F,z,Y,J=0;for(;J<L.length;){let oe=L[J++];switch(oe){case 1:U();break;case 3:U();break;case 4:m.length>1&&!E&&(S=m.shift()+n,E=!0),b+=m.pop(),B(_,b);break;case 5:for(;m.length>0;)_+=m.shift(),b+=m.shift(),C(_,b);break;case 6:for(;m.length>0&&(_+=m.shift(),C(_,b),m.length!==0);)b+=m.shift(),C(_,b);break;case 7:for(;m.length>0&&(b+=m.shift(),C(_,b),m.length!==0);)_+=m.shift(),C(_,b);break;case 8:for(;m.length>0;)f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p+m.shift(),T(f,d,g,p,_,b);break;case 10:$=m.pop()+l,O=e.subrs[$],O&&V(O);break;case 11:return;case 12:switch(oe=L[J],J+=1,oe){case 35:f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),j=g+m.shift(),A=p+m.shift(),M=j+m.shift(),F=A+m.shift(),z=M+m.shift(),Y=F+m.shift(),_=z+m.shift(),b=Y+m.shift(),m.shift(),T(f,d,g,p,j,A),T(M,F,z,Y,_,b);break;case 34:f=_+m.shift(),d=b,g=f+m.shift(),p=d+m.shift(),j=g+m.shift(),A=p,M=j+m.shift(),F=p,z=M+m.shift(),Y=b,_=z+m.shift(),T(f,d,g,p,j,A),T(M,F,z,Y,_,b);break;case 36:f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),j=g+m.shift(),A=p,M=j+m.shift(),F=p,z=M+m.shift(),Y=F+m.shift(),_=z+m.shift(),T(f,d,g,p,j,A),T(M,F,z,Y,_,b);break;case 37:f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),j=g+m.shift(),A=p+m.shift(),M=j+m.shift(),F=A+m.shift(),z=M+m.shift(),Y=F+m.shift(),Math.abs(z-_)>Math.abs(Y-b)?_=z+m.shift():b=Y+m.shift(),T(f,d,g,p,j,A),T(M,F,z,Y,_,b);break;default:console.warn(`Glyph ${h}: unknown operator ${1200+oe}`),m.length=0}break;case 14:if(m.length>=4){const wt=mn[m.pop()],Ze=mn[m.pop()],Be=m.pop(),$e=m.pop();if(wt&&Ze){i.isComposite=!0,i.components=[];const Se=e.charset.indexOf(wt),ze=e.charset.indexOf(Ze);i.components.push({glyphIndex:ze,dx:0,dy:0}),i.components.push({glyphIndex:Se,dx:$e,dy:Be}),R(r.get(ze).pathCommands);const ot=JSON.parse(JSON.stringify(r.get(Se).pathCommands));for(let at=0;at<ot.length;at+=1){const Je=ot[at];Je.type!=="Z"&&(Je.x+=$e,Je.y+=Be),(Je.type==="Q"||Je.type==="C")&&(Je.x1+=$e,Je.y1+=Be),Je.type==="C"&&(Je.x2+=$e,Je.y2+=Be)}R(ot)}}else m.length>0&&!E&&(S=m.shift()+n,E=!0);x&&c!==2&&(G(),x=!1);break;case 18:U();break;case 19:case 20:U(),J+=P+7>>3;break;case 21:m.length>2&&!E&&(S=m.shift()+n,E=!0),b+=m.pop(),_+=m.pop(),B(_,b);break;case 22:m.length>1&&!E&&(S=m.shift()+n,E=!0),_+=m.pop(),B(_,b);break;case 23:U();break;case 24:for(;m.length>2;)f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p+m.shift(),T(f,d,g,p,_,b);_+=m.shift(),b+=m.shift(),C(_,b);break;case 25:for(;m.length>6;)_+=m.shift(),b+=m.shift(),C(_,b);f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p+m.shift(),T(f,d,g,p,_,b);break;case 26:for(m.length%2&&(_+=m.shift());m.length>0;)f=_,d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g,b=p+m.shift(),T(f,d,g,p,_,b);break;case 27:for(m.length%2&&(b+=m.shift());m.length>0;)f=_+m.shift(),d=b,g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p,T(f,d,g,p,_,b);break;case 28:D=L[J],H=L[J+1],m.push((D<<24|H<<16)>>16),J+=2;break;case 29:$=m.pop()+a,O=e.gsubrs[$],O&&V(O);break;case 30:for(;m.length>0&&(f=_,d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p+(m.length===1?m.shift():0),T(f,d,g,p,_,b),m.length!==0);)f=_+m.shift(),d=b,g=f+m.shift(),p=d+m.shift(),b=p+m.shift(),_=g+(m.length===1?m.shift():0),T(f,d,g,p,_,b);break;case 31:for(;m.length>0&&(f=_+m.shift(),d=b,g=f+m.shift(),p=d+m.shift(),b=p+m.shift(),_=g+(m.length===1?m.shift():0),T(f,d,g,p,_,b),m.length!==0);)f=_,d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p+(m.length===1?m.shift():0),T(f,d,g,p,_,b);break;default:oe<32?console.warn(`Glyph ${h}: unknown operator ${oe}`):oe<247?m.push(oe-139):oe<251?(D=L[J],J+=1,m.push((oe-247)*256+D+108)):oe<255?(D=L[J],J+=1,m.push(-(oe-251)*256-D-108)):(D=L[J],H=L[J+1],I=L[J+2],N=L[J+3],J+=4,m.push((D<<24|H<<16|I<<8|N)/65536))}}}V(t),this.pathCommands=y,E&&(this.advanceWidth=S)}}class _n{constructor(e){this._sfnt=e}_items=[];get(e){const t=this._items[e];let r;if(t)r=t;else{r=this._get(e);const i=this._sfnt.hmtx.metrics[e];i&&(r.advanceWidth=r.advanceWidth||i.advanceWidth,r.leftSideBearing=r.leftSideBearing||i.leftSideBearing);const n=this._sfnt.cmap.glyphIndexToUnicodesMap.get(e);n&&(r.unicode??=n[0],r.unicodes??=n),this._items[e]=r}return r}}class rp extends _n{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(e){const t=this._sfnt.cff,r=new tp({index:e});return r.parse(t,t.charStringsIndex.get(e),this),r.name=t.charset[e],r}}var ip=Object.defineProperty,Tl=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ip(e,t,i),i};class Gi extends qe{_offsets;get offsets(){return this._offsets??=this.readOffsets()}_objects;get objects(){return this._objects??=this.readObjects()}constructor(e,t,r,i){super(e,t,r,i),this._init()}_init(){const e=this.view,t=this.count,r=this.offsetSize;this.objectOffset=(t+1)*r+2,this.endOffset=e.byteOffset+this.objectOffset+this.offsets[t]}readOffsets(){const e=this.view,t=this.count,r=this.offsetSize;e.seek(3);const i=[];for(let n=0,o=t+1;n<o;n++){const a=this.view;let l=0;for(let c=0;c<r;c++)l<<=8,l+=a.readUint8();i.push(l)}return i}readObjects(){const e=[];for(let t=0,r=this.count;t<r;t++)e.push(this.get(t));return e}get(e){const t=this.offsets,r=this.objectOffset,i=r+t[e],o=r+t[e+1]-i;return this._isString?this.view.readString(i,o):this.view.readBytes(i,o)}}Tl([v("uint16")],Gi.prototype,"count"),Tl([v("uint8")],Gi.prototype,"offsetSize");class ji extends Gi{_isString=!1}class El extends Gi{_isString=!0}const sp=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],np=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],op=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],ap=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"];function Wi(s,e){return e<=390?sp[e]:s[e-391]}function re(s,e="number",t){return(r,i)=>{if(typeof i!="string")return;const n={type:e,operator:s,default:t??e==="number"?0:void 0};Object.defineProperty(r.constructor.prototype,i,{get(){return this._getProp(n)},set(o){this._setProp(n,o)},configurable:!0,enumerable:!0})}}class Ml extends qe{_dict;get dict(){return this._dict??=this._readDict()}_stringIndex;setStringIndex(e){return this._stringIndex=e,this}_readFloatOperand(){const e=this.view;let t="";const r=15,i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const n=e.readUint8(),o=n>>4,a=n&15;if(o===r||(t+=i[o],a===r))break;t+=i[a]}return Number.parseFloat(t)}_readOperand(e){const t=this.view;let r,i,n,o;if(e===28)return r=t.readUint8(),i=t.readUint8(),r<<8|i;if(e===29)return r=t.readUint8(),i=t.readUint8(),n=t.readUint8(),o=t.readUint8(),r<<24|i<<16|n<<8|o;if(e===30)return this._readFloatOperand();if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return r=t.readUint8(),(e-247)*256+r+108;if(e>=251&&e<=254)return r=t.readUint8(),-(e-251)*256-r-108;throw new Error(`invalid b0 ${e}, at: ${t.cursor}`)}_readDict(){const e=this.view;e.seek(0);let t=[];const r=e.cursor+e.byteLength,i={};for(;e.cursor<r;){let n=e.readUint8();n<=21?(n===12&&(n=1200+e.readUint8()),i[n]=t,t=[]):t.push(this._readOperand(n))}return i}_getProp(e){const t=this.dict[e.operator]??e.default;switch(e.type){case"number":return t[0];case"string":return Wi(this._stringIndex?.objects??[],t[0]);case"number[]":return t}return t}_setProp(e,t){}}var lp=Object.defineProperty,vn=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&lp(e,t,i),i};class qi extends Ml{}vn([re(19)],qi.prototype,"subrs"),vn([re(20)],qi.prototype,"defaultWidthX"),vn([re(21)],qi.prototype,"nominalWidthX");var cp=Object.defineProperty,ce=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&cp(e,t,i),i};class ne extends Ml{}ce([re(0,"string")],ne.prototype,"version"),ce([re(1,"string")],ne.prototype,"notice"),ce([re(1200,"string")],ne.prototype,"copyright"),ce([re(2,"string")],ne.prototype,"fullName"),ce([re(3,"string")],ne.prototype,"familyName"),ce([re(4,"string")],ne.prototype,"weight"),ce([re(1201)],ne.prototype,"isFixedPitch"),ce([re(1202)],ne.prototype,"italicAngle"),ce([re(1203,"number",-100)],ne.prototype,"underlinePosition"),ce([re(1204,"number",50)],ne.prototype,"underlineThickness"),ce([re(1205)],ne.prototype,"paintType"),ce([re(1206,"number",2)],ne.prototype,"charstringType"),ce([re(1207,"number[]",[.001,0,0,.001,0,0])],ne.prototype,"fontMatrix"),ce([re(13)],ne.prototype,"uniqueId"),ce([re(5,"number[]",[0,0,0,0])],ne.prototype,"fontBBox"),ce([re(1208)],ne.prototype,"strokeWidth"),ce([re(14)],ne.prototype,"xuid"),ce([re(15)],ne.prototype,"charset"),ce([re(16)],ne.prototype,"encoding"),ce([re(17)],ne.prototype,"charStrings"),ce([re(18,"number[]",[0,0])],ne.prototype,"private");function we(s,e=s){return t=>{mt.tableDefinitions.set(s,{tag:s,prop:e,class:t}),Object.defineProperty(mt.prototype,e,{get(){return this.get(s)},set(r){return this.set(s,r)},configurable:!0,enumerable:!0})}}class mt{static tableDefinitions=new Map;tables=new Map;tableViews=new Map;get hasGlyf(){return this.tableViews.has("glyf")}get names(){return this.name.names}get unitsPerEm(){return this.head.unitsPerEm}get ascender(){return this.hhea.ascent}get descender(){return this.hhea.descent}get createdTimestamp(){return this.head.created}get modifiedTimestamp(){return this.head.modified}get numGlyphs(){return this.maxp.numGlyphs}get unicodes(){return this.cmap.glyphIndexToUnicodesMap}get glyphs(){return this.hasGlyf?this.glyf.glyphs:this.cff.glyphs}charToGlyphIndex(e){let t=this.cmap.unicodeToGlyphIndexMap.get(e.codePointAt(0));if(t===void 0&&!this.hasGlyf){const{encoding:r,charset:i}=this.cff;t=i.indexOf(r[e.codePointAt(0)])}return t??0}charToGlyph(e){return this.glyphs.get(this.charToGlyphIndex(e))}textToGlyphIndexes(e){const t=[];for(const r of e)t.push(this.charToGlyphIndex(r));return t}textToGlyphs(e){const t=this.glyphs,r=this.textToGlyphIndexes(e),i=r.length,n=Array.from({length:i}),o=t.get(0);for(let a=0;a<i;a+=1)n[a]=t.get(r[a])||o;return n}getPathCommands(e,t,r,i,n){const o=[];return this.forEachGlyph(e,t,r,i,n,(a,l,c,h,f)=>{o.push(...a.getPathCommands(l,c,h,f,this))}),o}getAdvanceWidth(e,t,r){return this.forEachGlyph(e,0,0,t,r,()=>{})}forEachGlyph(e,t=0,r=0,i=72,n={},o){const a=1/this.unitsPerEm*i,l=this.textToGlyphs(e);for(let c=0;c<l.length;c+=1){const h=l[c];o.call(this,h,t,r,i,n),h.advanceWidth&&(t+=h.advanceWidth*a),n.letterSpacing?t+=n.letterSpacing*i:n.tracking&&(t+=n.tracking/1e3*i)}return t}constructor(e){(e instanceof Map?e:new Map(Object.entries(e))).forEach((r,i)=>{this.tableViews.set(i,new DataView(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)))})}clone(){return new mt(this.tableViews)}delete(e){const t=mt.tableDefinitions.get(e);return t?(this.tableViews.delete(e),this.tables.delete(t.prop),this):this}set(e,t){const r=mt.tableDefinitions.get(e);return r&&this.tables.set(r.prop,t),this.tableViews.set(e,t.view),this}get(e){const t=mt.tableDefinitions.get(e);if(!t)return;let r=this.tables.get(t.prop);if(!r){const i=t.class;if(i){const n=this.tableViews.get(e);if(!n)return;r=new i(n.buffer,n.byteOffset,n.byteLength).setSFNT(this),this.tables.set(t.prop,r)}}return r}}class Oe extends qe{setSFNT(e){return this._sfnt=e,this}getSFNT(){return this._sfnt}}var hp=Object.defineProperty,up=Object.getOwnPropertyDescriptor,ni=(s,e,t,r)=>{for(var i=r>1?void 0:r?up(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&hp(e,t,i),i};let er=class extends Oe{_glyphs;get glyphs(){return this._glyphs??=new rp(this._sfnt)}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}privateDict;subrsIndex;get defaultWidthX(){return this.privateDict?.defaultWidthX??0}get nominalWidthX(){return this.privateDict?.nominalWidthX??0}get subrs(){return this.subrsIndex?.objects??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}constructor(s,e,t,r){super(s,e,t,r),this._init()}_init(){const s=this.view,{buffer:e,byteOffset:t}=s,r=t+4;this.nameIndex=new El(e,r),this.topDictIndex=new ji(e,this.nameIndex.endOffset),this.stringIndex=new El(e,this.topDictIndex.endOffset),this.globalSubrIndex=new ji(e,this.stringIndex.endOffset),this.topDict=new ne(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);const i=this.topDict.private[0],n=this.topDict.private[1];i&&(this.privateDict=new qi(e,t+n,i).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new ji(e,t+n+this.privateDict.subrs))),this.charStringsIndex=new ji(e,t+this.topDict.charStrings);const o=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=np:this.topDict.charset===1?this.charset=op:this.topDict.charset===2?this.charset=ap:this.charset=this._readCharset(t+this.topDict.charset,o,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=mn:this.topDict.encoding===1?this.encoding=ep:this.encoding=this._readEncoding(t+this.topDict.encoding)}_readCharset(s,e,t){const r=this.view;r.seek(s);let i,n,o;e-=1;const a=[".notdef"],l=r.readUint8();if(l===0)for(i=0;i<e;i+=1)n=r.readUint16(),a.push(Wi(t,n));else if(l===1)for(;a.length<=e;)for(n=r.readUint16(),o=r.readUint8(),i=0;i<=o;i+=1)a.push(Wi(t,n)),n+=1;else if(l===2)for(;a.length<=e;)for(n=r.readUint16(),o=r.readUint16(),i=0;i<=o;i+=1)a.push(Wi(t,n)),n+=1;else throw new Error(`Unknown charset format ${l}`);return a}_readEncoding(s){const e=this.view;e.seek(s);let t,r;const i={},n=e.readUint8();if(n===0){const o=e.readUint8();for(t=0;t<o;t+=1)r=e.readUint8(),i[r]=t}else if(n===1){const o=e.readUint8();for(r=1,t=0;t<o;t+=1){const a=e.readUint8(),l=e.readUint8();for(let c=a;c<=a+l;c+=1)i[c]=r,r+=1}}else console.warn(`unknown encoding format:${n}`);return i}_calcSubroutineBias(s){let e;return s.length<1240?e=107:s.length<33900?e=1131:e=32768,e}};ni([v("uint8")],er.prototype,"majorVersion",2),ni([v("uint8")],er.prototype,"minorVersion",2),ni([v("uint8")],er.prototype,"headerSize",2),ni([v("uint8")],er.prototype,"offsetSize",2),er=ni([we("CFF ","cff")],er);var fp=Object.defineProperty,Xi=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&fp(e,t,i),i};const oi=class dc extends qe{constructor(e=new ArrayBuffer(262),t){super(e,t,262)}static from(e){const t=new dc;return t.format=0,t.length=t.view.byteLength,t.language=0,e.forEach((r,i)=>{i<256&&r<256&&t.view.writeUint8(r,6+i)}),t}getUnicodeToGlyphIndexMap(){const e=new Map;return this.glyphIndexArray.forEach((t,r)=>{e.set(r,t)}),e}};Xi([v("uint16")],oi.prototype,"format"),Xi([v("uint16")],oi.prototype,"length"),Xi([v("uint16")],oi.prototype,"language"),Xi([v({type:"uint8",size:256})],oi.prototype,"glyphIndexArray");let bn=oi;var dp=Object.defineProperty,wn=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&dp(e,t,i),i};class ai extends qe{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((e,t)=>Math.max(e,t),0)}get subHeaders(){const e=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:e},(t,r)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(e-r)*8-2)/2}))}get glyphIndexArray(){const e=this.maxSubHeaderKey,t=6+256*2+e*8;this.view.seek(t);const r=(this.view.byteLength-t)/2;return Array.from({length:r},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(e){const t=new Map,r=this.subHeaderKeys,i=this.maxSubHeaderKey,n=this.subHeaders,o=this.glyphIndexArray,a=r.findIndex(c=>c===i);let l=0;for(let c=0;c<256;c++)if(r[c]===0)c>=a||c<n[0].firstCode||c>=n[0].firstCode+n[0].entryCount||n[0].idRangeOffset+(c-n[0].firstCode)>=o.length?l=0:(l=o[n[0].idRangeOffset+(c-n[0].firstCode)],l!==0&&(l=l+n[0].idDelta)),l!==0&&l<e&&t.set(c,l);else{const h=r[c];for(let f=0,d=n[h].entryCount;f<d;f++)if(n[h].idRangeOffset+f>=o.length?l=0:(l=o[n[h].idRangeOffset+f],l!==0&&(l=l+n[h].idDelta)),l!==0&&l<e){const g=(c<<8|f+n[h].firstCode)%65535;t.set(g,l)}}return t}}wn([v("uint16")],ai.prototype,"format"),wn([v("uint16")],ai.prototype,"length"),wn([v("uint16")],ai.prototype,"language");function Al(s){return s>32767?s-65536:s<-32767?s+65536:s}function xn(s,e){let t;const r=[];let i={};return s.forEach((n,o)=>{e&&o>e||((!t||o!==t.unicode+1||n!==t.glyphIndex+1)&&(t?(i.end=t.unicode,r.push(i),i={start:o,startId:n,delta:Al(n-o)}):(i.start=Number(o),i.startId=n,i.delta=Al(n-o))),t={unicode:o,glyphIndex:n})}),t&&(i.end=t.unicode,r.push(i)),r}var pp=Object.defineProperty,tr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&pp(e,t,i),i};const $t=class pc extends qe{get endCode(){const e=this.segCountX2;return this.view.seek(14),Array.from({length:e/2},()=>this.view.readUint16())}set endCode(e){this.view.seek(14),e.forEach(t=>this.view.writeUint16(t))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(e){this.view.writeUint16(e,14+this.segCountX2)}get startCode(){const e=this.segCountX2;return this.view.seek(14+e+2),Array.from({length:e/2},()=>this.view.readUint16())}set startCode(e){this.view.seek(14+this.segCountX2+2),e.forEach(t=>this.view.writeUint16(t))}get idDelta(){const e=this.segCountX2;return this.view.seek(14+e+2+e),Array.from({length:e/2},()=>this.view.readUint16())}set idDelta(e){const t=this.segCountX2;this.view.seek(14+t+2+t),e.forEach(r=>this.view.writeUint16(r))}get idRangeOffsetCursor(){const e=this.segCountX2;return 14+e+2+e*2}get idRangeOffset(){const e=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:e/2},()=>this.view.readUint16())}set idRangeOffset(e){this.view.seek(this.idRangeOffsetCursor),e.forEach(t=>this.view.writeUint16(t))}get glyphIndexArrayCursor(){const e=this.segCountX2;return 14+e+2+e*3}get glyphIndexArray(){const e=this.glyphIndexArrayCursor;this.view.seek(e);const t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}static from(e){const t=xn(e,65535),r=t.length+1,i=Math.floor(Math.log(r)/Math.LN2),n=2*2**i,o=new pc(new ArrayBuffer(24+t.length*8));return o.format=4,o.length=o.view.byteLength,o.language=0,o.segCountX2=r*2,o.searchRange=n,o.entrySelector=i,o.rangeShift=2*r-n,o.endCode=[...t.map(a=>a.end),65535],o.reservedPad=0,o.startCode=[...t.map(a=>a.start),65535],o.idDelta=[...t.map(a=>a.delta),1],o.idRangeOffset=Array.from({length:r},()=>0),o}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.segCountX2/2,r=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,i=this.startCode,n=this.endCode,o=this.idRangeOffset,a=this.idDelta,l=this.glyphIndexArray;for(let c=0;c<t;++c)for(let h=i[c],f=n[c];h<=f;++h)if(o[c]===0)e.set(h,(h+a[c])%65536);else{const d=c+o[c]/2+(h-i[c])-r,g=l[d];g!==0?e.set(h,(g+a[c])%65536):e.set(h,0)}return e.delete(65535),e}};tr([v("uint16")],$t.prototype,"format"),tr([v("uint16")],$t.prototype,"length"),tr([v("uint16")],$t.prototype,"language"),tr([v("uint16")],$t.prototype,"segCountX2"),tr([v("uint16")],$t.prototype,"searchRange"),tr([v("uint16")],$t.prototype,"entrySelector"),tr([v("uint16")],$t.prototype,"rangeShift");let Pn=$t;var gp=Object.defineProperty,li=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&gp(e,t,i),i};class rr extends qe{get glyphIndexArray(){return this.view.seek(12),Array.from({length:this.entryCount},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(){const e=this.glyphIndexArray,t=new Map;return e.forEach((r,i)=>{t.set(i,r)}),t}}li([v("uint16")],rr.prototype,"format"),li([v("uint16")],rr.prototype,"length"),li([v("uint16")],rr.prototype,"language"),li([v("uint16")],rr.prototype,"firstCode"),li([v("uint16")],rr.prototype,"entryCount");var mp=Object.defineProperty,ci=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&mp(e,t,i),i};const _r=class gc extends qe{get groups(){const e=this.nGroups;return this.view.seek(16),Array.from({length:e},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(e){const t=xn(e),r=new gc(new ArrayBuffer(16+t.length*12));return r.format=12,r.reserved=0,r.length=r.view.byteLength,r.language=0,r.nGroups=t.length,t.forEach(i=>{r.view.writeUint32(i.start),r.view.writeUint32(i.end),r.view.writeUint32(i.startId)}),r}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.groups;for(let r=0,i=t.length;r<i;r++){const n=t[r];let o=n.startGlyphCode,a=n.startCharCode;const l=n.endCharCode;for(;a<=l;)e.set(a++,o++)}return e}};ci([v("uint16")],_r.prototype,"format"),ci([v("uint16")],_r.prototype,"reserved"),ci([v("uint32")],_r.prototype,"length"),ci([v("uint32")],_r.prototype,"language"),ci([v("uint32")],_r.prototype,"nGroups");let Sn=_r;var yp=Object.defineProperty,Cn=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&yp(e,t,i),i};class hi extends qe{getVarSelectorRecords(){const e=this.numVarSelectorRecords;return this.view.seek(10),Array.from({length:e},()=>{const t={varSelector:this.view.readUint24(),defaultUVSOffset:this.view.readUint32(),unicodeValueRanges:[],nonDefaultUVSOffset:this.view.readUint32(),uVSMappings:[]};if(t.defaultUVSOffset){this.view.seek(t.defaultUVSOffset);const r=this.view.readUint32();t.unicodeValueRanges=Array.from({length:r},()=>({startUnicodeValue:this.view.readUint24(),additionalCount:this.view.readUint8()}))}if(t.nonDefaultUVSOffset){this.view.seek(t.nonDefaultUVSOffset);const r=this.view.readUint32();t.uVSMappings=Array.from({length:r},()=>({unicodeValue:this.view.readUint24(),glyphID:this.view.readUint16()}))}return t})}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.getVarSelectorRecords();for(let r=0,i=t.length;r<i;r++){const{uVSMappings:n}=t[r];n.forEach(o=>{e.set(o.unicodeValue,o.glyphID)})}return e}}Cn([v("uint16")],hi.prototype,"format"),Cn([v("uint32")],hi.prototype,"length"),Cn([v("uint32")],hi.prototype,"numVarSelectorRecords");var _p=Object.defineProperty,vp=Object.getOwnPropertyDescriptor,Tn=(s,e,t,r)=>{for(var i=r>1?void 0:r?vp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_p(e,t,i),i};let vr=class extends Oe{static from(s){const e=Array.from(s.keys()).some(h=>h>65535),t=Pn.from(s),r=bn.from(s),i=e?Sn.from(s):void 0,n=4+(i?32:24),o=n+t.view.byteLength,a=o+r.view.byteLength,l=[{platformID:0,platformSpecificID:3,offset:n},{platformID:1,platformSpecificID:0,offset:o},{platformID:3,platformSpecificID:1,offset:n},i&&{platformID:3,platformSpecificID:10,offset:a}].filter(Boolean),c=new vr(new ArrayBuffer(4+8*l.length+t.view.byteLength+r.view.byteLength+(i?.view.byteLength??0)));return c.numberSubtables=l.length,c.view.seek(4),l.forEach(h=>{c.view.writeUint16(h.platformID),c.view.writeUint16(h.platformSpecificID),c.view.writeUint32(h.offset)}),c.view.writeBytes(t.view,n),c.view.writeBytes(r.view,o),i&&c.view.writeBytes(i.view,a),c}_unicodeToGlyphIndexMap;get unicodeToGlyphIndexMap(){return this._unicodeToGlyphIndexMap??=this.readunicodeToGlyphIndexMap()}_glyphIndexToUnicodesMap;get glyphIndexToUnicodesMap(){if(!this._glyphIndexToUnicodesMap){const s=new Map,e=this.unicodeToGlyphIndexMap,t=Array.from(e.keys());for(let r=0,i=t.length;r<i;r++){const n=t[r],o=e.get(n);s.has(o)?s.get(o).push(n):s.set(o,[n])}this._glyphIndexToUnicodesMap=s}return this._glyphIndexToUnicodesMap}readSubtables(){const s=this.numberSubtables;return this.view.seek(4),Array.from({length:s},()=>({platformID:this.view.readUint16(),platformSpecificID:this.view.readUint16(),offset:this.view.readUint32()})).map(e=>{this.view.seek(e.offset);const t=this.view.readUint16();let r;switch(t){case 0:r=new bn(this.view.buffer,e.offset);break;case 2:r=new ai(this.view.buffer,e.offset,this.view.readUint16());break;case 4:r=new Pn(this.view.buffer,e.offset,this.view.readUint16());break;case 6:r=new rr(this.view.buffer,e.offset,this.view.readUint16());break;case 12:r=new Sn(this.view.buffer,e.offset,this.view.readUint32(e.offset+4));break;case 14:default:r=new hi(this.view.buffer,e.offset,this.view.readUint32());break}return{...e,format:t,view:r}})}readunicodeToGlyphIndexMap(){const s=this.readSubtables(),e=s.find(o=>o.format===0)?.view,t=s.find(o=>o.platformID===3&&o.platformSpecificID===3&&o.format===2)?.view,r=s.find(o=>o.platformID===3&&o.platformSpecificID===1&&o.format===4)?.view,i=s.find(o=>o.platformID===3&&o.platformSpecificID===10&&o.format===12)?.view,n=s.find(o=>o.platformID===0&&o.platformSpecificID===5&&o.format===14)?.view;return new Map([...e?.getUnicodeToGlyphIndexMap()??[],...t?.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs)??[],...r?.getUnicodeToGlyphIndexMap()??[],...i?.getUnicodeToGlyphIndexMap()??[],...n?.getUnicodeToGlyphIndexMap()??[]])}};Tn([v("uint16")],vr.prototype,"version",2),Tn([v("uint16")],vr.prototype,"numberSubtables",2),vr=Tn([we("cmap")],vr);class bp extends yn{_parseContours(e){const t=[];let r=[];for(let i=0;i<e.length;i+=1){const n=e[i];r.push(n),n.lastPointOfContour&&(t.push(r),r=[])}return ii(r.length===0,"There are still points left in the current contour."),t}_transformPoints(e,t){const r=[];for(let i=0;i<e.length;i+=1){const n=e[i],o={x:t.xScale*n.x+t.scale10*n.y+t.dx,y:t.scale01*n.x+t.yScale*n.y+t.dy,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour};r.push(o)}return r}_parseGlyphCoordinate(e,t,r,i,n){let o;return(t&i)>0?(o=e.view.readUint8(),(t&n)===0&&(o=-o),o=r+o):(t&n)>0?o=r:o=r+e.view.readInt16(),o}parse(e,t,r){e.view.seek(t);const i=this.numberOfContours=e.view.readInt16();if(this.xMin=e.view.readInt16(),this.yMin=e.view.readInt16(),this.xMax=e.view.readInt16(),this.yMax=e.view.readInt16(),i>0){const a=this.endPointIndices=[];for(let y=0;y<i;y++)a.push(e.view.readUint16());const l=this.instructionLength=e.view.readUint16();ii(l<5e3,`Bad instructionLength:${l}`);const c=this.instructions=[];for(let y=0;y<l;++y)c.push(e.view.readUint8());const h=e.view.byteOffset,f=a[a.length-1]+1;ii(f<2e4,`Bad numberOfCoordinates:${h}`);const d=[];let g,p=0;for(;p<f;)if(g=e.view.readUint8(),d.push(g),p++,g&8&&p<f){const y=e.view.readUint8();for(let m=0;m<y;m++)d.push(g),p++}if(ii(d.length===f,`Bad flags length: ${d.length}, numberOfCoordinates: ${f}`),a.length>0){const y=[];let m;if(f>0){for(let x=0;x<f;x+=1)g=d[x],m={},m.onCurve=!!(g&1),m.lastPointOfContour=a.includes(x),y.push(m);let P=0;for(let x=0;x<f;x+=1)g=d[x],m=y[x],m.x=this._parseGlyphCoordinate(e,g,P,2,16),P=m.x;let E=0;for(let x=0;x<f;x+=1)g=d[x],m=y[x],m.y=this._parseGlyphCoordinate(e,g,E,4,32),E=m.y}this.points=y}else this.points=[]}else if(i===0)this.points=[];else{this.isComposite=!0,this.points=[],this.components=[];let a,l=!0;for(;l;){a=e.view.readUint16();const c={glyphIndex:e.view.readUint16(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(c.dx=e.view.readInt16(),c.dy=e.view.readInt16()):c.matchedPoints=[e.view.readUint16(),e.view.readUint16()]:(a&2)>0?(c.dx=e.view.readInt8(),c.dy=e.view.readInt8()):c.matchedPoints=[e.view.readUint8(),e.view.readUint8()],(a&8)>0?c.xScale=c.yScale=e.view.readInt16()/16384:(a&64)>0?(c.xScale=e.view.readInt16()/16384,c.yScale=e.view.readInt16()/16384):(a&128)>0&&(c.xScale=e.view.readInt16()/16384,c.scale01=e.view.readInt16()/16384,c.scale10=e.view.readInt16()/16384,c.yScale=e.view.readInt16()/16384),this.components.push(c),l=!!(a&32)}if(a&256){this.instructionLength=e.view.readUint16(),this.instructions=[];for(let c=0;c<this.instructionLength;c+=1)this.instructions.push(e.view.readUint8())}}if(this.isComposite)for(let a=0;a<this.components.length;a+=1){const l=this.components[a],c=r.get(l.glyphIndex);if(c.getPathCommands(),c.points){let h;if(l.matchedPoints===void 0)h=this._transformPoints(c.points,l);else{ii(l.matchedPoints[0]>this.points.length-1||l.matchedPoints[1]>c.points.length-1,`Matched points out of range in ${this.name}`);const f=this.points[l.matchedPoints[0]];let d=c.points[l.matchedPoints[1]];const g={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};d=this._transformPoints([d],g)[0],g.dx=f.x-d.x,g.dy=f.y-d.y,h=this._transformPoints(c.points,g)}this.points=this.points.concat(h)}}const n=[],o=this._parseContours(this.points);for(let a=0,l=o.length;a<l;++a){const c=o[a];let h=c[c.length-1],f=c[0];h.onCurve?n.push({type:"M",x:h.x,y:h.y}):f.onCurve?n.push({type:"M",x:f.x,y:f.y}):n.push({type:"M",x:(h.x+f.x)*.5,y:(h.y+f.y)*.5});for(let d=0,g=c.length;d<g;++d)if(h=f,f=c[(d+1)%g],h.onCurve)n.push({type:"L",x:h.x,y:h.y});else{let p=f;f.onCurve||(p={x:(h.x+f.x)*.5,y:(h.y+f.y)*.5}),n.push({type:"Q",x1:h.x,y1:h.y,x:p.x,y:p.y})}n.push({type:"Z"})}this.pathCommands=n}}class wp extends _n{get length(){return this._sfnt.loca.locations.length}_get(e){const t=this._sfnt.loca.locations,r=t[e],i=new bp({index:e});return r!==t[e+1]&&i.parse(this._sfnt.glyf,r,this),i}}var xp=Object.getOwnPropertyDescriptor,Pp=(s,e,t,r)=>{for(var i=r>1?void 0:r?xp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Hi=class extends Oe{static from(s){const e=s.reduce((r,i)=>r+i.byteLength,0),t=new Hi(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeBytes(r)}),t}_glyphs;get glyphs(){return this._glyphs??=new wp(this._sfnt)}};Hi=Pp([we("glyf")],Hi);var Sp=Object.getOwnPropertyDescriptor,Cp=(s,e,t,r)=>{for(var i=r>1?void 0:r?Sp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let En=class extends Oe{};En=Cp([we("GPOS","gpos")],En);var Tp=Object.defineProperty,Ep=Object.getOwnPropertyDescriptor,ir=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ep(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Tp(e,t,i),i};let Ot=class extends Oe{};ir([v("uint16")],Ot.prototype,"majorVersion",2),ir([v("uint16")],Ot.prototype,"minorVersion",2),ir([v("uint16")],Ot.prototype,"scriptListOffset",2),ir([v("uint16")],Ot.prototype,"featureListOffset",2),ir([v("uint16")],Ot.prototype,"lookupListOffset",2),ir([v("uint16")],Ot.prototype,"featureVariationsOffset",2),Ot=ir([we("GSUB","gsub")],Ot);var Mp=Object.defineProperty,Ap=Object.getOwnPropertyDescriptor,ye=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ap(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Mp(e,t,i),i};let ue=class extends Oe{constructor(s=new ArrayBuffer(54),e){super(s,e,Math.min(54,s.byteLength-(e??0)))}};ye([v("fixed")],ue.prototype,"version",2),ye([v("fixed")],ue.prototype,"fontRevision",2),ye([v("uint32")],ue.prototype,"checkSumAdjustment",2),ye([v("uint32")],ue.prototype,"magickNumber",2),ye([v("uint16")],ue.prototype,"flags",2),ye([v("uint16")],ue.prototype,"unitsPerEm",2),ye([v({type:"longDateTime"})],ue.prototype,"created",2),ye([v({type:"longDateTime"})],ue.prototype,"modified",2),ye([v("int16")],ue.prototype,"xMin",2),ye([v("int16")],ue.prototype,"yMin",2),ye([v("int16")],ue.prototype,"xMax",2),ye([v("int16")],ue.prototype,"yMax",2),ye([v("uint16")],ue.prototype,"macStyle",2),ye([v("uint16")],ue.prototype,"lowestRecPPEM",2),ye([v("int16")],ue.prototype,"fontDirectionHint",2),ye([v("int16")],ue.prototype,"indexToLocFormat",2),ye([v("int16")],ue.prototype,"glyphDataFormat",2),ue=ye([we("head")],ue);var Op=Object.defineProperty,kp=Object.getOwnPropertyDescriptor,Re=(s,e,t,r)=>{for(var i=r>1?void 0:r?kp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Op(e,t,i),i};let xe=class extends Oe{constructor(s=new ArrayBuffer(36),e){super(s,e,Math.min(36,s.byteLength-(e??0)))}};Re([v("fixed")],xe.prototype,"version",2),Re([v("int16")],xe.prototype,"ascent",2),Re([v("int16")],xe.prototype,"descent",2),Re([v("int16")],xe.prototype,"lineGap",2),Re([v("uint16")],xe.prototype,"advanceWidthMax",2),Re([v("int16")],xe.prototype,"minLeftSideBearing",2),Re([v("int16")],xe.prototype,"minRightSideBearing",2),Re([v("int16")],xe.prototype,"xMaxExtent",2),Re([v("int16")],xe.prototype,"caretSlopeRise",2),Re([v("int16")],xe.prototype,"caretSlopeRun",2),Re([v("int16")],xe.prototype,"caretOffset",2),Re([v({type:"int16",size:4})],xe.prototype,"reserved",2),Re([v("int16")],xe.prototype,"metricDataFormat",2),Re([v("uint16")],xe.prototype,"numOfLongHorMetrics",2),xe=Re([we("hhea")],xe);var Dp=Object.getOwnPropertyDescriptor,Ip=(s,e,t,r)=>{for(var i=r>1?void 0:r?Dp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Yi=class extends Oe{static from(s){const e=s.length*4,t=new Yi(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeUint16(r.advanceWidth),t.view.writeUint16(r.leftSideBearing)}),t}_metrics;get metrics(){return this._metrics??=this.readMetrics()}readMetrics(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.hhea.numOfLongHorMetrics;let t=0;const r=this.view;return r.seek(0),Array.from({length:s}).map((i,n)=>(n<e&&(t=r.readUint16()),{advanceWidth:t,leftSideBearing:r.readUint16()}))}};Yi=Ip([we("hmtx")],Yi);var Rp=Object.getOwnPropertyDescriptor,Up=(s,e,t,r)=>{for(var i=r>1?void 0:r?Rp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Mn=class extends Oe{};Mn=Up([we("kern","kern")],Mn);var Bp=Object.getOwnPropertyDescriptor,Lp=(s,e,t,r)=>{for(var i=r>1?void 0:r?Bp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Ki=class extends Oe{static from(s,e=1){const t=s.length*(e?4:2),r=new Ki(new ArrayBuffer(t));return s.forEach(i=>{e?r.view.writeUint32(i):r.view.writeUint16(i/2)}),r}_locations;get locations(){return this._locations??=this.readLocations()}readLocations(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.head.indexToLocFormat,t=this.view;return t.seek(0),Array.from({length:s}).map(()=>e?t.readUint32():t.readUint16()*2)}};Ki=Lp([we("loca")],Ki);var Np=Object.defineProperty,Fp=Object.getOwnPropertyDescriptor,ke=(s,e,t,r)=>{for(var i=r>1?void 0:r?Fp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Np(e,t,i),i};let _e=class extends Oe{constructor(s=new ArrayBuffer(32),e){super(s,e,Math.min(32,s.byteLength-(e??0)))}};ke([v("fixed")],_e.prototype,"version",2),ke([v("uint16")],_e.prototype,"numGlyphs",2),ke([v("uint16")],_e.prototype,"maxPoints",2),ke([v("uint16")],_e.prototype,"maxContours",2),ke([v("uint16")],_e.prototype,"maxComponentPoints",2),ke([v("uint16")],_e.prototype,"maxComponentContours",2),ke([v("uint16")],_e.prototype,"maxZones",2),ke([v("uint16")],_e.prototype,"maxTwilightPoints",2),ke([v("uint16")],_e.prototype,"maxStorage",2),ke([v("uint16")],_e.prototype,"maxFunctionDefs",2),ke([v("uint16")],_e.prototype,"maxInstructionDefs",2),ke([v("uint16")],_e.prototype,"maxStackElements",2),ke([v("uint16")],_e.prototype,"maxSizeOfInstructions",2),ke([v("uint16")],_e.prototype,"maxComponentElements",2),ke([v("uint16")],_e.prototype,"maxComponentDepth",2),_e=ke([we("maxp")],_e);var $p=Object.defineProperty,zp=Object.getOwnPropertyDescriptor,Zi=(s,e,t,r)=>{for(var i=r>1?void 0:r?zp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&$p(e,t,i),i};const Ol={0:"copyright",1:"fontFamily",2:"fontSubFamily",3:"uniqueSubFamily",4:"fullName",5:"version",6:"postScriptName",7:"tradeMark",8:"manufacturer",9:"designer",10:"description",11:"urlOfFontVendor",12:"urlOfFontDesigner",13:"licence",14:"urlOfLicence",16:"preferredFamily",17:"preferredSubFamily",18:"compatibleFull",19:"sampleText"},An={Macintosh:1,Microsoft:3},Vp={Default:0},kl={UCS2:1};let br=class extends Oe{_names;get names(){return this._names??=this.readNames()}readNames(){const s=this.count;this.view.seek(6);const e=[];for(let a=0;a<s;++a)e.push({platform:this.view.readUint16(),encoding:this.view.readUint16(),language:this.view.readUint16(),nameId:this.view.readUint16(),length:this.view.readUint16(),offset:this.view.readUint16()});const t=this.stringOffset;for(let a=0;a<s;++a){const l=e[a];l.name=this.view.readBytes(t+l.offset,l.length)}let r=An.Macintosh,i=Vp.Default,n=0;e.some(a=>a.platform===An.Microsoft&&a.encoding===kl.UCS2&&a.language===1033)&&(r=An.Microsoft,i=kl.UCS2,n=1033);const o={};for(let a=0;a<s;++a){const l=e[a];l.platform===r&&l.encoding===i&&l.language===n&&Ol[l.nameId]&&(o[Ol[l.nameId]]=n===0?Yd(l.name):Kd(l.name))}return o}};Zi([v("uint16")],br.prototype,"format",2),Zi([v("uint16")],br.prototype,"count",2),Zi([v("uint16")],br.prototype,"stringOffset",2),br=Zi([we("name")],br);var Gp=Object.defineProperty,jp=Object.getOwnPropertyDescriptor,X=(s,e,t,r)=>{for(var i=r>1?void 0:r?jp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Gp(e,t,i),i};let q=class extends Oe{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};X([v("uint16")],q.prototype,"version",2),X([v("int16")],q.prototype,"xAvgCharWidth",2),X([v("uint16")],q.prototype,"usWeightClass",2),X([v("uint16")],q.prototype,"usWidthClass",2),X([v("uint16")],q.prototype,"fsType",2),X([v("uint16")],q.prototype,"ySubscriptXSize",2),X([v("uint16")],q.prototype,"ySubscriptYSize",2),X([v("uint16")],q.prototype,"ySubscriptXOffset",2),X([v("uint16")],q.prototype,"ySubscriptYOffset",2),X([v("uint16")],q.prototype,"ySuperscriptXSize",2),X([v("uint16")],q.prototype,"ySuperscriptYSize",2),X([v("uint16")],q.prototype,"ySuperscriptXOffset",2),X([v("uint16")],q.prototype,"ySuperscriptYOffset",2),X([v("uint16")],q.prototype,"yStrikeoutSize",2),X([v("uint16")],q.prototype,"yStrikeoutPosition",2),X([v("uint16")],q.prototype,"sFamilyClass",2),X([v({type:"uint8"})],q.prototype,"bFamilyType",2),X([v({type:"uint8"})],q.prototype,"bSerifStyle",2),X([v({type:"uint8"})],q.prototype,"bWeight",2),X([v({type:"uint8"})],q.prototype,"bProportion",2),X([v({type:"uint8"})],q.prototype,"bContrast",2),X([v({type:"uint8"})],q.prototype,"bStrokeVariation",2),X([v({type:"uint8"})],q.prototype,"bArmStyle",2),X([v({type:"uint8"})],q.prototype,"bLetterform",2),X([v({type:"uint8"})],q.prototype,"bMidline",2),X([v({type:"uint8"})],q.prototype,"bXHeight",2),X([v({type:"uint8",size:16})],q.prototype,"ulUnicodeRange",2),X([v({type:"char",size:4})],q.prototype,"achVendID",2),X([v("uint16")],q.prototype,"fsSelection",2),X([v("uint16")],q.prototype,"usFirstCharIndex",2),X([v("uint16")],q.prototype,"usLastCharIndex",2),X([v("int16")],q.prototype,"sTypoAscender",2),X([v("int16")],q.prototype,"sTypoDescender",2),X([v("int16")],q.prototype,"sTypoLineGap",2),X([v("uint16")],q.prototype,"usWinAscent",2),X([v("uint16")],q.prototype,"usWinDescent",2),X([v({offset:72,type:"uint8",size:8})],q.prototype,"ulCodePageRange",2),X([v({offset:72,type:"int16"})],q.prototype,"sxHeight",2),X([v("int16")],q.prototype,"sCapHeight",2),X([v("uint16")],q.prototype,"usDefaultChar",2),X([v("uint16")],q.prototype,"usBreakChar",2),X([v("uint16")],q.prototype,"usMaxContext",2),q=X([we("OS/2","os2")],q);var Wp=Object.defineProperty,qp=Object.getOwnPropertyDescriptor,yt=(s,e,t,r)=>{for(var i=r>1?void 0:r?qp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Wp(e,t,i),i};let Ke=class extends Oe{constructor(s=new ArrayBuffer(32),e,t){super(s,e,t)}};yt([v("fixed")],Ke.prototype,"format",2),yt([v("fixed")],Ke.prototype,"italicAngle",2),yt([v("int16")],Ke.prototype,"underlinePosition",2),yt([v("int16")],Ke.prototype,"underlineThickness",2),yt([v("uint32")],Ke.prototype,"isFixedPitch",2),yt([v("uint32")],Ke.prototype,"minMemType42",2),yt([v("uint32")],Ke.prototype,"maxMemType42",2),yt([v("uint32")],Ke.prototype,"minMemType1",2),yt([v("uint32")],Ke.prototype,"maxMemType1",2),Ke=yt([we("post")],Ke);var Xp=Object.defineProperty,Hp=Object.getOwnPropertyDescriptor,Ue=(s,e,t,r)=>{for(var i=r>1?void 0:r?Hp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Xp(e,t,i),i};let Pe=class extends Oe{constructor(s=new ArrayBuffer(36),e){super(s,e,Math.min(36,s.byteLength-(e??0)))}};Ue([v("fixed")],Pe.prototype,"version",2),Ue([v("int16")],Pe.prototype,"vertTypoAscender",2),Ue([v("int16")],Pe.prototype,"vertTypoDescender",2),Ue([v("int16")],Pe.prototype,"vertTypoLineGap",2),Ue([v("int16")],Pe.prototype,"advanceHeightMax",2),Ue([v("int16")],Pe.prototype,"minTopSideBearing",2),Ue([v("int16")],Pe.prototype,"minBottomSideBearing",2),Ue([v("int16")],Pe.prototype,"yMaxExtent",2),Ue([v("int16")],Pe.prototype,"caretSlopeRise",2),Ue([v("int16")],Pe.prototype,"caretSlopeRun",2),Ue([v("int16")],Pe.prototype,"caretOffset",2),Ue([v({type:"int16",size:4})],Pe.prototype,"reserved",2),Ue([v("int16")],Pe.prototype,"metricDataFormat",2),Ue([v("int16")],Pe.prototype,"numOfLongVerMetrics",2),Pe=Ue([we("vhea")],Pe);var Yp=Object.getOwnPropertyDescriptor,Kp=(s,e,t,r)=>{for(var i=r>1?void 0:r?Yp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Ji=class extends Oe{static from(s){const e=s.length*4,t=new Ji(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeUint16(r.advanceHeight),t.view.writeInt16(r.topSideBearing)}),t}_metrics;get metrics(){return this._metrics??=this.readMetrics()}readMetrics(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.vhea?.numOfLongVerMetrics??0,t=this.view;t.seek(0);let r=0;return Array.from({length:s}).map((i,n)=>(n<e&&(r=t.readUint16()),{advanceHeight:r,topSideBearing:t.readUint8()}))}};Ji=Kp([we("vmtx")],Ji);var Zp=Object.defineProperty,ui=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Zp(e,t,i),i};class st extends zi{format="TrueType";mimeType="font/ttf";_sfnt;get sfnt(){return this._sfnt||(this._sfnt=this.createSFNT()),this._sfnt}static signature=new Set([65536,1953658213,1954115633]);static is(e){return typeof e=="number"?this.signature.has(e):this.signature.has(mr(e).getUint32(0))}static checksum(e){const t=mr(e);let r=t.byteLength;for(;r%4;)r++;let i=0;for(let n=0,o=r/4;n<o;n+=4)n*4<r-4&&(i+=t.getUint32(n*4,!1));return i&4294967295}static from(e){const t=f=>f+3&-4,r=e.tableViews.size,i=Array.from(e.tableViews.values()).reduce((f,d)=>f+t(d.byteLength),0),n=new this(new ArrayBuffer(12+r*16+i));n.scalerType=65536,n.numTables=r;const o=Math.log(2);n.searchRange=Math.floor(Math.log(r)/o)*16,n.entrySelector=Math.floor(n.searchRange/o),n.rangeShift=r*16-n.searchRange;let a=12+r*16,l=0;const c=n.getDirectories();e.tableViews.forEach((f,d)=>{const g=c[l++];g.tag=d,g.checkSum=this.checksum(f),g.offset=a,g.length=f.byteLength,n.view.writeBytes(f,a),a+=t(g.length)});const h=n.createSFNT().head;return h.checkSumAdjustment=0,h.checkSumAdjustment=2981146554-this.checksum(n.view),n}getDirectories(){let e=this.view.byteOffset+12;return Array.from({length:this.numTables},()=>{const t=new yr(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new mt(this.getDirectories().reduce((e,t)=>(e[t.tag]=new DataView(this.view.buffer,this.view.byteOffset+t.offset,t.length),e),{}))}}ui([v("uint32")],st.prototype,"scalerType"),ui([v("uint16")],st.prototype,"numTables"),ui([v("uint16")],st.prototype,"searchRange"),ui([v("uint16")],st.prototype,"entrySelector"),ui([v("uint16")],st.prototype,"rangeShift");class On extends st{format="OpenType";mimeType="font/otf";static signature=new Set([1330926671]);static from(e){return super.from(e)}}var Jp=Object.defineProperty,fi=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Jp(e,t,i),i};class sr extends qe{constructor(e,t){super(e,t,20)}}fi([v({type:"char",size:4})],sr.prototype,"tag"),fi([v("uint32")],sr.prototype,"offset"),fi([v("uint32")],sr.prototype,"compLength"),fi([v("uint32")],sr.prototype,"origLength"),fi([v("uint32")],sr.prototype,"origChecksum");var Qp=Object.defineProperty,Xe=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Qp(e,t,i),i};const Fe=class Kn extends zi{format="WOFF";mimeType="font/woff";get subfontFormat(){return st.is(this.flavor)?"TrueType":On.is(this.flavor)?"OpenType":"Open"}_sfnt;get sfnt(){return this._sfnt||(this._sfnt=this.createSFNT()),this._sfnt}static signature=new Set([2001684038]);static is(e){return typeof e=="number"?this.signature.has(e):this.signature.has(mr(e).getUint32(0))}static checkSum(e){const t=mr(e),r=t.byteLength,i=Math.floor(r/4);let n=0,o=0;for(;o<i;)n+=t.getUint32(4*o++,!1);let a=r-i*4;if(a){let l=i*4;for(;a>0;)n+=t.getUint8(l)<<a*8,l++,a--}return n%4294967296}static from(e,t=new ArrayBuffer(0)){const r=f=>f+3&-4,i=[];e.tableViews.forEach((f,d)=>{const g=mr(Vd(new Uint8Array(f.buffer,f.byteOffset,f.byteLength)));i.push({tag:d,view:g.byteLength<f.byteLength?g:f,rawView:f})});const n=i.length,o=i.reduce((f,d)=>f+r(d.view.byteLength),0),a=new Kn(new ArrayBuffer(44+20*n+o+t.byteLength));a.signature=2001684038,a.flavor=65536,a.length=a.view.byteLength,a.numTables=n,a.totalSFNTSize=12+16*n+i.reduce((f,d)=>f+r(d.rawView.byteLength),0);let l=44+n*20,c=0;const h=a.getDirectories();return i.forEach(f=>{const d=h[c++];d.tag=f.tag,d.offset=l,d.compLength=f.view.byteLength,d.origChecksum=Kn.checkSum(f.rawView),d.origLength=f.rawView.byteLength,a.view.writeBytes(f.view,l),l+=r(d.compLength)}),a.view.writeBytes(t),a}getDirectories(){let e=44;return Array.from({length:this.numTables},()=>{const t=new sr(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new mt(this.getDirectories().reduce((e,t)=>{const r=t.tag,i=this.view.byteOffset+t.offset,n=t.compLength,o=t.origLength,a=i+n;return e[r]=n>=o?new DataView(this.view.buffer,i,n):new DataView(Gd(new Uint8Array(this.view.buffer.slice(i,a))).buffer),e},{}))}};Xe([v("uint32")],Fe.prototype,"signature"),Xe([v("uint32")],Fe.prototype,"flavor"),Xe([v("uint32")],Fe.prototype,"length"),Xe([v("uint16")],Fe.prototype,"numTables"),Xe([v("uint16")],Fe.prototype,"reserved"),Xe([v("uint32")],Fe.prototype,"totalSFNTSize"),Xe([v("uint16")],Fe.prototype,"majorVersion"),Xe([v("uint16")],Fe.prototype,"minorVersion"),Xe([v("uint32")],Fe.prototype,"metaOffset"),Xe([v("uint32")],Fe.prototype,"metaLength"),Xe([v("uint32")],Fe.prototype,"metaOrigLength"),Xe([v("uint32")],Fe.prototype,"privOffset"),Xe([v("uint32")],Fe.prototype,"privLength");let Qi=Fe;function Dl(s,e=!0){if(st.is(s))return new st(s);if(On.is(s))return new On(s);if(Qi.is(s))return new Qi(s);if(e)throw new Error("Failed to parseFont")}function Il(s,e=!0){const t=Dl(s,!1);if(t)return t;if(e)throw new Error("Failed to parseFont")}class es{static defaultRequestInit={cache:"force-cache"};fallbackFont;loading=new Map;loaded=new Map;familyToUrl=new Map;setFallbackFont(e){this.fallbackFont=e}async loadFallbackFont(e,t={}){this.fallbackFont=await this.load(e,t)}_createRequest(e,t){const r=new AbortController;return{url:e,when:fetch(e,{...es.defaultRequestInit,...t,signal:r.signal}).then(i=>i.arrayBuffer()),cancel:()=>r.abort()}}injectFontFace(e,t){return document.fonts.add(new FontFace(e,t)),this}injectStyleTag(e,t){const r=document.createElement("style");return r.appendChild(document.createTextNode(`@font-face {
862
+ }`})),Yr([w()],u.ZoomBlurEffect.prototype,"center",2),Yr([w({fallback:20})],u.ZoomBlurEffect.prototype,"innerRadius",2),Yr([w({fallback:-1})],u.ZoomBlurEffect.prototype,"radius",2),Yr([w({fallback:.1})],u.ZoomBlurEffect.prototype,"strength",2),u.ZoomBlurEffect=Yr([W("ZoomBlurEffect")],u.ZoomBlurEffect);function Li(s,e){let t=!1;const{left:r=0,top:i=0,width:n,height:o}=e,a=new ve().translate(-r,-i).scale(1/n,1/o);if(s.cropRect){const{left:l=0,top:c=0,right:h=0,bottom:f=0}=s.cropRect;a.scale(Math.abs(1-(l+h)),Math.abs(1-(c+f))).translate(l,c),t=!0}if(s.tile){const{translateX:l=0,translateY:c=0,scaleX:h=1,scaleY:f=1}=s.tile;a.translate(-l/n,-c/o).scale(1/h,1/f),t=!0}else if(s.stretchRect){const{left:l=0,top:c=0,right:h=0,bottom:f=0}=s.stretchRect;a.scale(Math.abs(1-(-l+-h)),Math.abs(1-(-c+-f))).translate(-l,-c),t=!0}return{disableWrapMode:t,uvTransform:a}}var xd=Object.defineProperty,tt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&xd(e,t,i),i};class Te extends It{constructor(e){super(),this.parent=e}_texture;_setProperties(e){return super.setProperties(e)}setProperties(e){return this._setProperties(K(e)?void 0:ht(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"color":case"cropRect":case"stretchRect":case"dpi":case"rotateWithShape":case"tile":case"opacity":case"enabled":this.parent.requestRedraw();break;case"image":case"linearGradient":case"radialGradient":this._updateTexture();break}}async loadTexture(){return this.linearGradient||this.radialGradient?new $r(this.linearGradient??this.radialGradient,this.parent.size.width,this.parent.size.height):K(this.image)?void 0:(this.parent.tree?.log(`load image ${this.image}`),await nt.texture.load(this.image))}async _updateTexture(){this._texture=await this.loadTexture(),this.parent.requestRedraw()}canDraw(){return!!(this.enabled&&(this._texture||this.color))}draw(){const e=this.parent.context,{uvTransform:t,disableWrapMode:r}=Li(this,{width:this.parent.size.width,height:this.parent.size.height});e.uvTransform=t,e.fillStyle=this._texture??this.color,e.fill({disableWrapMode:r})}}tt([w({fallback:!0})],Te.prototype,"enabled"),tt([w()],Te.prototype,"color"),tt([w()],Te.prototype,"image"),tt([w()],Te.prototype,"linearGradient"),tt([w()],Te.prototype,"radialGradient"),tt([w()],Te.prototype,"cropRect"),tt([w()],Te.prototype,"stretchRect"),tt([w()],Te.prototype,"dpi"),tt([w()],Te.prototype,"rotateWithShape"),tt([w()],Te.prototype,"tile"),tt([w()],Te.prototype,"opacity");var Pd=Object.defineProperty,Sd=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Pd(e,t,i),i};class nn extends Te{setProperties(e){return super._setProperties(K(e)?void 0:Wc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"fillWithShape":this.parent.requestRedraw();break}}}Sd([w()],nn.prototype,"fillWithShape");var Cd=Object.defineProperty,Td=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Cd(e,t,i),i};class on extends Te{setProperties(e){return super._setProperties(K(e)?void 0:qc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"fillWithShape":this.parent.requestRedraw();break}}}Td([w()],on.prototype,"fillWithShape");var Ed=Object.defineProperty,Kr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Ed(e,t,i),i};class Zt extends Te{setProperties(e){return super._setProperties(K(e)?void 0:wi(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"width":case"style":case"lineCap":case"lineJoin":case"enabled":this.parent.requestRedraw();break}}canDraw(){return!!(this.enabled&&(this.width||this.color||super.canDraw()))}draw(){const e=this.parent.context,{uvTransform:t,disableWrapMode:r}=Li(this,{width:this.parent.size.width,height:this.parent.size.height});e.lineWidth=this.width||1,e.uvTransform=t,e.strokeStyle=this._texture??this.color,e.lineCap=this.lineCap,e.lineJoin=this.lineJoin,e.stroke({disableWrapMode:r})}}Kr([w({fallback:"#00000000"})],Zt.prototype,"color"),Kr([w({fallback:0})],Zt.prototype,"width"),Kr([w({fallback:"solid"})],Zt.prototype,"style"),Kr([w({fallback:"butt"})],Zt.prototype,"lineCap"),Kr([w({fallback:"miter"})],Zt.prototype,"lineJoin");var Md=Object.defineProperty,Zr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Md(e,t,i),i};class Jt extends It{constructor(e){super(),this.parent=e}setProperties(e){return super.setProperties(K(e)?void 0:Xc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"color":case"blur":case"offsetX":case"offsetY":this.updateEffect();break}}updateEffect(){const e="__$shadow";let t=this.parent.getNode(e);this.blur||this.offsetX||this.offsetY?(t||(t=new u.DropShadowEffect({name:e}),this.parent.appendChild(t,"back")),t.setProperties(this.getProperties())):t&&this.parent.removeChild(t)}}Zr([w({fallback:!0})],Jt.prototype,"enabled"),Zr([w({fallback:"#000000FF"})],Jt.prototype,"color"),Zr([w({fallback:0})],Jt.prototype,"blur"),Zr([w({fallback:0})],Jt.prototype,"offsetY"),Zr([w({fallback:0})],Jt.prototype,"offsetX");var Ad=Object.defineProperty,Jr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Ad(e,t,i),i};class Qt extends It{constructor(e){super(),this.parent=e,this._updatePath2DSet()}_path2DSet=new Tt;setProperties(e){return super.setProperties(K(e)?void 0:Yc(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"svg":case"paths":case"viewBox":case"enabled":this._updatePath2DSet(),this.parent.requestRedraw();break}}_updatePath2DSet(){let e;if(this.svg){const o=Fs(this.svg);this._path2DSet=zs(o),e=this._path2DSet.viewBox}else this.paths?.forEach((o,a)=>{const{data:l,...c}=o,h=new ge;h.style=c,h.addData(l),this._path2DSet.paths[a]=h});if(!e){const o=this._path2DSet.getBoundingBox();e=o?[o.x,o.y,o.width||1,o.height||1]:[0,0,1,1]}const[t,r,i,n]=e;this._path2DSet.paths.forEach(o=>{o.applyTransform(new be().translate(-t,-r).scale(1/i,1/n))})}draw(){if(this.enabled&&this._path2DSet.paths.length){const e=this.parent.context,{width:t,height:r}=this.parent.size;this._path2DSet.paths.forEach(i=>{e.addPath(i.clone().applyTransform(new be().scale(t,r)))})}else this.drawRect()}drawRect(){const e=this.parent.context,{width:t,height:r}=this.parent.size,{borderRadius:i}=this.parent.style;t&&r&&(i?e.roundRect(0,0,t,r,i):e.rect(0,0,t,r))}}Jr([w({fallback:!0})],Qt.prototype,"enabled"),Jr([w()],Qt.prototype,"preset"),Jr([w()],Qt.prototype,"svg"),Jr([w()],Qt.prototype,"viewBox"),Jr([w()],Qt.prototype,"paths");class Qr extends St{constructor(e){super(),this.setProperties(e)}}const fl=vo();for(const s in fl){const e=fl[s];yi(Qr,s,{fallback:e})}var Ee=Uint8Array,We=Uint16Array,an=Int32Array,Ni=new Ee([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fi=new Ee([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ln=new Ee([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dl=function(s,e){for(var t=new We(31),r=0;r<31;++r)t[r]=e+=1<<s[r-1];for(var i=new an(t[30]),r=1;r<30;++r)for(var n=t[r];n<t[r+1];++n)i[n]=n-t[r]<<5|r;return{b:t,r:i}},pl=dl(Ni,2),gl=pl.b,cn=pl.r;gl[28]=258,cn[258]=28;for(var ml=dl(Fi,0),Od=ml.b,yl=ml.r,hn=new We(32768),te=0;te<32768;++te){var Nt=(te&43690)>>1|(te&21845)<<1;Nt=(Nt&52428)>>2|(Nt&13107)<<2,Nt=(Nt&61680)>>4|(Nt&3855)<<4,hn[te]=((Nt&65280)>>8|(Nt&255)<<8)>>1}for(var mt=(function(s,e,t){for(var r=s.length,i=0,n=new We(e);i<r;++i)s[i]&&++n[s[i]-1];var o=new We(e);for(i=1;i<e;++i)o[i]=o[i-1]+n[i-1]<<1;var a;if(t){a=new We(1<<e);var l=15-e;for(i=0;i<r;++i)if(s[i])for(var c=i<<4|s[i],h=e-s[i],f=o[s[i]-1]++<<h,d=f|(1<<h)-1;f<=d;++f)a[hn[f]>>l]=c}else for(a=new We(r),i=0;i<r;++i)s[i]&&(a[i]=hn[o[s[i]-1]++]>>15-s[i]);return a}),Ft=new Ee(288),te=0;te<144;++te)Ft[te]=8;for(var te=144;te<256;++te)Ft[te]=9;for(var te=256;te<280;++te)Ft[te]=7;for(var te=280;te<288;++te)Ft[te]=8;for(var ei=new Ee(32),te=0;te<32;++te)ei[te]=5;var kd=mt(Ft,9,0),Dd=mt(Ft,9,1),Id=mt(ei,5,0),Rd=mt(ei,5,1),un=function(s){for(var e=s[0],t=1;t<s.length;++t)s[t]>e&&(e=s[t]);return e},rt=function(s,e,t){var r=e/8|0;return(s[r]|s[r+1]<<8)>>(e&7)&t},fn=function(s,e){var t=e/8|0;return(s[t]|s[t+1]<<8|s[t+2]<<16)>>(e&7)},dn=function(s){return(s+7)/8|0},_l=function(s,e,t){return(t==null||t>s.length)&&(t=s.length),new Ee(s.subarray(e,t))},Ud=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],it=function(s,e,t){var r=new Error(e||Ud[s]);if(r.code=s,Error.captureStackTrace&&Error.captureStackTrace(r,it),!t)throw r;return r},Bd=function(s,e,t,r){var i=s.length,n=0;if(!i||e.f&&!e.l)return t||new Ee(0);var o=!t,a=o||e.i!=2,l=e.i;o&&(t=new Ee(i*3));var c=function(Be){var $e=t.length;if(Be>$e){var Se=new Ee(Math.max($e*2,Be));Se.set(t),t=Se}},h=e.f||0,f=e.p||0,d=e.b||0,g=e.l,p=e.d,y=e.m,m=e.n,P=i*8;do{if(!g){h=rt(s,f,1);var E=rt(s,f+1,3);if(f+=3,E)if(E==1)g=Dd,p=Rd,y=9,m=5;else if(E==2){var b=rt(s,f,31)+257,C=rt(s,f+10,15)+4,T=b+rt(s,f+5,31)+1;f+=14;for(var B=new Ee(T),G=new Ee(19),R=0;R<C;++R)G[ln[R]]=rt(s,f+R*3,7);f+=C*3;for(var U=un(G),V=(1<<U)-1,L=mt(G,U,1),R=0;R<T;){var D=L[rt(s,f,V)];f+=D&15;var x=D>>4;if(x<16)B[R++]=x;else{var H=0,I=0;for(x==16?(I=3+rt(s,f,3),f+=2,H=B[R-1]):x==17?(I=3+rt(s,f,7),f+=3):x==18&&(I=11+rt(s,f,127),f+=7);I--;)B[R++]=H}}var N=B.subarray(0,b),$=B.subarray(b);y=un(N),m=un($),g=mt(N,y,1),p=mt($,m,1)}else it(1);else{var x=dn(f)+4,S=s[x-4]|s[x-3]<<8,_=x+S;if(_>i){l&&it(0);break}a&&c(d+S),t.set(s.subarray(x,_),d),e.b=d+=S,e.p=f=_*8,e.f=h;continue}if(f>P){l&&it(0);break}}a&&c(d+131072);for(var O=(1<<y)-1,j=(1<<m)-1,A=f;;A=f){var H=g[fn(s,f)&O],M=H>>4;if(f+=H&15,f>P){l&&it(0);break}if(H||it(2),M<256)t[d++]=M;else if(M==256){A=f,g=null;break}else{var F=M-254;if(M>264){var R=M-257,z=Ni[R];F=rt(s,f,(1<<z)-1)+gl[R],f+=z}var Y=p[fn(s,f)&j],J=Y>>4;Y||it(3),f+=Y&15;var $=Od[J];if(J>3){var z=Fi[J];$+=fn(s,f)&(1<<z)-1,f+=z}if(f>P){l&&it(0);break}a&&c(d+131072);var oe=d+F;if(d<$){var wt=n-$,Ze=Math.min($,oe);for(wt+d<0&&it(3);d<Ze;++d)t[d]=r[wt+d]}for(;d<oe;++d)t[d]=t[d-$]}}e.l=g,e.p=A,e.b=d,e.f=h,g&&(h=1,e.m=y,e.d=p,e.n=m)}while(!h);return d!=t.length&&o?_l(t,0,d):t.subarray(0,d)},At=function(s,e,t){t<<=e&7;var r=e/8|0;s[r]|=t,s[r+1]|=t>>8},ti=function(s,e,t){t<<=e&7;var r=e/8|0;s[r]|=t,s[r+1]|=t>>8,s[r+2]|=t>>16},pn=function(s,e){for(var t=[],r=0;r<s.length;++r)s[r]&&t.push({s:r,f:s[r]});var i=t.length,n=t.slice();if(!i)return{t:xl,l:0};if(i==1){var o=new Ee(t[0].s+1);return o[t[0].s]=1,{t:o,l:1}}t.sort(function(_,b){return _.f-b.f}),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,h=1,f=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=i-1;)a=t[t[c].f<t[f].f?c++:f++],l=t[c!=h&&t[c].f<t[f].f?c++:f++],t[h++]={s:-1,f:a.f+l.f,l:a,r:l};for(var d=n[0].s,r=1;r<i;++r)n[r].s>d&&(d=n[r].s);var g=new We(d+1),p=gn(t[h-1],g,0);if(p>e){var r=0,y=0,m=p-e,P=1<<m;for(n.sort(function(b,C){return g[C.s]-g[b.s]||b.f-C.f});r<i;++r){var E=n[r].s;if(g[E]>e)y+=P-(1<<p-g[E]),g[E]=e;else break}for(y>>=m;y>0;){var x=n[r].s;g[x]<e?y-=1<<e-g[x]++-1:++r}for(;r>=0&&y;--r){var S=n[r].s;g[S]==e&&(--g[S],++y)}p=e}return{t:new Ee(g),l:p}},gn=function(s,e,t){return s.s==-1?Math.max(gn(s.l,e,t+1),gn(s.r,e,t+1)):e[s.s]=t},vl=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new We(++e),r=0,i=s[0],n=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(s[a]==i&&a!=e)++n;else{if(!i&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(i),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(i);n=1,i=s[a]}return{c:t.subarray(0,r),n:e}},ri=function(s,e){for(var t=0,r=0;r<e.length;++r)t+=s[r]*e[r];return t},bl=function(s,e,t){var r=t.length,i=dn(e+2);s[i]=r&255,s[i+1]=r>>8,s[i+2]=s[i]^255,s[i+3]=s[i+1]^255;for(var n=0;n<r;++n)s[i+n+4]=t[n];return(i+4+r)*8},wl=function(s,e,t,r,i,n,o,a,l,c,h){At(e,h++,t),++i[256];for(var f=pn(i,15),d=f.t,g=f.l,p=pn(n,15),y=p.t,m=p.l,P=vl(d),E=P.c,x=P.n,S=vl(y),_=S.c,b=S.n,C=new We(19),T=0;T<E.length;++T)++C[E[T]&31];for(var T=0;T<_.length;++T)++C[_[T]&31];for(var B=pn(C,7),G=B.t,R=B.l,U=19;U>4&&!G[ln[U-1]];--U);var V=c+5<<3,L=ri(i,Ft)+ri(n,ei)+o,D=ri(i,d)+ri(n,y)+o+14+3*U+ri(C,G)+2*C[16]+3*C[17]+7*C[18];if(l>=0&&V<=L&&V<=D)return bl(e,h,s.subarray(l,l+c));var H,I,N,$;if(At(e,h,1+(D<L)),h+=2,D<L){H=mt(d,g,0),I=d,N=mt(y,m,0),$=y;var O=mt(G,R,0);At(e,h,x-257),At(e,h+5,b-1),At(e,h+10,U-4),h+=14;for(var T=0;T<U;++T)At(e,h+3*T,G[ln[T]]);h+=3*U;for(var j=[E,_],A=0;A<2;++A)for(var M=j[A],T=0;T<M.length;++T){var F=M[T]&31;At(e,h,O[F]),h+=G[F],F>15&&(At(e,h,M[T]>>5&127),h+=M[T]>>12)}}else H=kd,I=Ft,N=Id,$=ei;for(var T=0;T<a;++T){var z=r[T];if(z>255){var F=z>>18&31;ti(e,h,H[F+257]),h+=I[F+257],F>7&&(At(e,h,z>>23&31),h+=Ni[F]);var Y=z&31;ti(e,h,N[Y]),h+=$[Y],Y>3&&(ti(e,h,z>>5&8191),h+=Fi[Y])}else ti(e,h,H[z]),h+=I[z]}return ti(e,h,H[256]),h+I[256]},Ld=new an([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),xl=new Ee(0),Nd=function(s,e,t,r,i,n){var o=n.z||s.length,a=new Ee(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),c=n.l,h=(n.r||0)&7;if(e){h&&(l[0]=n.r>>3);for(var f=Ld[e-1],d=f>>13,g=f&8191,p=(1<<t)-1,y=n.p||new We(32768),m=n.h||new We(p+1),P=Math.ceil(t/3),E=2*P,x=function(ze){return(s[ze]^s[ze+1]<<P^s[ze+2]<<E)&p},S=new an(25e3),_=new We(288),b=new We(32),C=0,T=0,B=n.i||0,G=0,R=n.w||0,U=0;B+2<o;++B){var V=x(B),L=B&32767,D=m[V];if(y[L]=D,m[V]=L,R<=B){var H=o-B;if((C>7e3||G>24576)&&(H>423||!c)){h=wl(s,l,0,S,_,b,T,G,U,B-U,h),G=C=T=0,U=B;for(var I=0;I<286;++I)_[I]=0;for(var I=0;I<30;++I)b[I]=0}var N=2,$=0,O=g,j=L-D&32767;if(H>2&&V==x(B-j))for(var A=Math.min(d,H)-1,M=Math.min(32767,B),F=Math.min(258,H);j<=M&&--O&&L!=D;){if(s[B+N]==s[B+N-j]){for(var z=0;z<F&&s[B+z]==s[B+z-j];++z);if(z>N){if(N=z,$=j,z>A)break;for(var Y=Math.min(j,z-2),J=0,I=0;I<Y;++I){var oe=B-j+I&32767,wt=y[oe],Ze=oe-wt&32767;Ze>J&&(J=Ze,D=oe)}}}L=D,D=y[L],j+=L-D&32767}if($){S[G++]=268435456|cn[N]<<18|yl[$];var Be=cn[N]&31,$e=yl[$]&31;T+=Ni[Be]+Fi[$e],++_[257+Be],++b[$e],R=B+N,++C}else S[G++]=s[B],++_[s[B]]}}for(B=Math.max(B,R);B<o;++B)S[G++]=s[B],++_[s[B]];h=wl(s,l,c,S,_,b,T,G,U,B-U,h),c||(n.r=h&7|l[h/8|0]<<3,h-=7,n.h=m,n.p=y,n.i=B,n.w=R)}else{for(var B=n.w||0;B<o+c;B+=65535){var Se=B+65535;Se>=o&&(l[h/8|0]=c,Se=o),h=bl(l,h+1,s.subarray(B,Se))}n.i=o}return _l(a,0,r+dn(h)+i)},Pl=function(){var s=1,e=0;return{p:function(t){for(var r=s,i=e,n=t.length|0,o=0;o!=n;){for(var a=Math.min(o+2655,n);o<a;++o)i+=r+=t[o];r=(r&65535)+15*(r>>16),i=(i&65535)+15*(i>>16)}s=r,e=i},d:function(){return s%=65521,e%=65521,(s&255)<<24|(s&65280)<<8|(e&255)<<8|e>>8}}},Fd=function(s,e,t,r,i){if(!i&&(i={l:1},e.dictionary)){var n=e.dictionary.subarray(-32768),o=new Ee(n.length+s.length);o.set(n),o.set(s,n.length),s=o,i.w=n.length}return Nd(s,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(s.length)))*1.5):20:12+e.mem,t,r,i)},Sl=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8},$d=function(s,e){var t=e.level,r=t==0?0:t<6?1:t==9?3:2;if(s[0]=120,s[1]=r<<6|(e.dictionary&&32),s[1]|=31-(s[0]<<8|s[1])%31,e.dictionary){var i=Pl();i.p(e.dictionary),Sl(s,2,i.d())}},zd=function(s,e){return((s[0]&15)!=8||s[0]>>4>7||(s[0]<<8|s[1])%31)&&it(6,"invalid zlib data"),(s[1]>>5&1)==1&&it(6,"invalid zlib data: "+(s[1]&32?"need":"unexpected")+" dictionary"),(s[1]>>3&4)+2};function Vd(s,e){e||(e={});var t=Pl();t.p(s);var r=Fd(s,e,e.dictionary?6:2,4);return $d(r,e),Sl(r,r.length-4,t.d()),r}function Gd(s,e){return Bd(s.subarray(zd(s),-4),{i:2},e,e)}var jd=typeof TextDecoder<"u"&&new TextDecoder,Wd=0;try{jd.decode(xl,{stream:!0}),Wd=1}catch{}const qd="modern-font";function ii(s,e){if(!s)throw new Error(`[${qd}] ${e}`)}function Xd(s){if("buffer"in s){const e=s.buffer;return s.byteOffset>0||s.byteLength<s.buffer.byteLength?e.slice(s.byteOffset,s.byteOffset+s.byteLength):e}else return s}function mr(s){return"buffer"in s?new DataView(s.buffer,s.byteOffset,s.byteLength):new DataView(s)}function Hd(s){let e="";for(let t=0,r=s.length,i;t<r;t++)i=s.charCodeAt(t),i!==0&&(e+=String.fromCharCode(i));return e}function $i(s){s=Hd(s);const e=[];for(let t=0,r=s.length,i;t<r;t++)i=s.charCodeAt(t),e.push(i>>8),e.push(i&255);return e}function Yd(s){let e="";for(let t=0,r=s.length;t<r;t++)s[t]<127?e+=String.fromCharCode(s[t]):e+=`%${(256+s[t]).toString(16).slice(1)}`;return unescape(e)}function Kd(s){let e="";for(let t=0,r=s.length;t<r;t+=2)e+=String.fromCharCode((s[t]<<8)+s[t+1]);return e}var Zd=Object.defineProperty,Me=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Zd(e,t,i),i};const si={int8:1,int16:2,int32:4,uint8:1,uint16:2,uint32:4,float32:4,float64:8,fixed:4,longDateTime:8,char:1};function Ae(){return function(s,e){Object.defineProperty(s.constructor.prototype,e,{get(){if(typeof e=="string"){if(e.startsWith("read"))return(...t)=>this.read(e.substring(4).toLowerCase(),...t);if(e.startsWith("write"))return(...t)=>this.write(e.substring(5).toLowerCase(),...t)}},configurable:!0,enumerable:!0})}}class me extends DataView{constructor(e,t,r,i){super(Xd(e),t,r),this.littleEndian=i}cursor=0;readColumn(e){if(e.size){const t=Array.from({length:e.size},(r,i)=>this.read(e.type,e.offset+i));switch(e.type){case"char":return t.join("");default:return t}}else return this.read(e.type,e.offset)}writeColumn(e,t){e.size?Array.from({length:e.size},(r,i)=>{this.write(e.type,t[i],e.offset+i)}):this.write(e.type,t,e.offset)}read(e,t=this.cursor,r=this.littleEndian){switch(e){case"char":return this.readChar(t);case"fixed":return this.readFixed(t,r);case"longDateTime":return this.readLongDateTime(t,r)}const i=`get${e.replace(/^\S/,l=>l.toUpperCase())}`,n=this,a=n[i]?.bind(n)?.(t,r);return this.cursor+=si[e],a}readUint24(e=this.cursor){const[t,r,i]=this.readBytes(e,3);return(t<<16)+(r<<8)+i}readBytes(e,t){t==null&&(t=e,e=this.cursor);const r=[];for(let i=0;i<t;++i)r.push(this.getUint8(e+i));return this.cursor=e+t,r}readString(e,t){const r=this.readBytes(e,t);let i="";for(let n=0,o=r.length;n<o;n++)i+=String.fromCharCode(r[n]);return i}readFixed(e,t){const r=this.readInt32(e,t)/65536;return Math.ceil(r*1e5)/1e5}readLongDateTime(e=this.cursor,t){const r=this.readUint32(e+4,t),i=new Date;return i.setTime(r*1e3+-20775456e5),i}readChar(e){return this.readString(e,1)}write(e,t,r=this.cursor,i=this.littleEndian){switch(e){case"char":return this.writeChar(t,r);case"fixed":return this.writeFixed(t,r);case"longDateTime":return this.writeLongDateTime(t,r)}const n=`set${e.replace(/^\S/,c=>c.toUpperCase())}`,o=this,l=o[n]?.bind(o)?.(r,t,i);return this.cursor+=si[e.toLowerCase()],l}writeString(e="",t=this.cursor){const r=e.replace(/[^\x00-\xFF]/g,"11").length;this.seek(t);for(let i=0,n=e.length,o;i<n;++i)o=e.charCodeAt(i)||0,o>127?this.writeUint16(o):this.writeUint8(o);return this.cursor+=r,this}writeChar(e,t){return this.writeString(e,t)}writeFixed(e,t){return this.writeInt32(Math.round(e*65536),t),this}writeLongDateTime(e,t=this.cursor){typeof e>"u"?e=-20775456e5:typeof e.getTime=="function"?e=e.getTime():/^\d+$/.test(e)?e=+e:e=Date.parse(e);const i=Math.round((e- -20775456e5)/1e3);return this.writeUint32(0,t),this.writeUint32(i,t+4),this}writeBytes(e,t=this.cursor){let r;if(Array.isArray(e)){r=e.length;for(let i=0;i<r;++i)this.setUint8(t+i,e[i])}else{const i=mr(e);r=i.byteLength;for(let n=0;n<r;++n)this.setUint8(t+n,i.getUint8(n))}return this.cursor=t+r,this}seek(e){return this.cursor=e,this}}Me([Ae()],me.prototype,"readInt8"),Me([Ae()],me.prototype,"readInt16"),Me([Ae()],me.prototype,"readInt32"),Me([Ae()],me.prototype,"readUint8"),Me([Ae()],me.prototype,"readUint16"),Me([Ae()],me.prototype,"readUint32"),Me([Ae()],me.prototype,"readFloat32"),Me([Ae()],me.prototype,"readFloat64"),Me([Ae()],me.prototype,"writeInt8"),Me([Ae()],me.prototype,"writeInt16"),Me([Ae()],me.prototype,"writeInt32"),Me([Ae()],me.prototype,"writeUint8"),Me([Ae()],me.prototype,"writeUint16"),Me([Ae()],me.prototype,"writeUint32"),Me([Ae()],me.prototype,"writeFloat32"),Me([Ae()],me.prototype,"writeFloat64");const Cl=new WeakMap;function v(s){const e=typeof s=="object"?s:{type:s},{size:t=1,type:r}=e;return(i,n)=>{if(typeof n!="string")return;let o=Cl.get(i);o||(o={columns:[],byteLength:0},Cl.set(i,o));const a={...e,name:n,byteLength:t*si[r],offset:e.offset??o.columns.reduce((l,c)=>l+c.byteLength,0)};o.columns.push(a),o.byteLength=o.columns.reduce((l,c)=>l+si[c.type]*(c.size??1),0),Object.defineProperty(i.constructor.prototype,n,{get(){return this.view.readColumn(a)},set(l){this.view.writeColumn(a,l)},configurable:!0,enumerable:!0})}}class qe{view;constructor(e,t,r,i){this.view=new me(e,t,r,i)}}class zi extends qe{get buffer(){return this.view.buffer}toBuffer(){return this.view.buffer.slice(this.view.byteOffset,this.view.byteOffset+this.view.byteLength)}toBlob(){return new Blob([new Uint8Array(this.view.buffer,this.view.byteOffset,this.view.byteLength)],{type:this.mimeType})}toFontFace(e){return new FontFace(e,this.view.buffer)}}var Jd=Object.defineProperty,De=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Jd(e,t,i),i};const Ie=class fc extends zi{format="EmbeddedOpenType";mimeType="application/vnd.ms-fontobject";static from(e){const t=e.sfnt,i=t.name.names,n=$i(i.fontFamily||""),o=n.length,a=$i(i.fontStyle||""),l=a.length,c=$i(i.version||""),h=c.length,f=$i(i.fullName||""),d=f.length,g=86+o+4+l+4+h+4+d+2+e.view.byteLength,p=new fc(new ArrayBuffer(g),0,g,!0);p.EOTSize=p.view.byteLength,p.FontDataSize=e.view.byteLength,p.Version=131073,p.Flags=0,p.Charset=1,p.MagicNumber=20556,p.Padding1=0,p.CheckSumAdjustment=t.head.checkSumAdjustment;const y=t.os2;return y&&(p.FontPANOSE=y.fontPANOSE,p.Italic=y.fsSelection,p.Weight=y.usWeightClass,p.fsType=y.fsType,p.UnicodeRange=y.ulUnicodeRange,p.CodePageRange=y.ulCodePageRange),p.view.writeUint16(o),p.view.writeBytes(n),p.view.writeUint16(0),p.view.writeUint16(l),p.view.writeBytes(a),p.view.writeUint16(0),p.view.writeUint16(h),p.view.writeBytes(c),p.view.writeUint16(0),p.view.writeUint16(d),p.view.writeBytes(f),p.view.writeUint16(0),p.view.writeUint16(0),p.view.writeBytes(e.view),p}};De([v("uint32")],Ie.prototype,"EOTSize"),De([v("uint32")],Ie.prototype,"FontDataSize"),De([v("uint32")],Ie.prototype,"Version"),De([v("uint32")],Ie.prototype,"Flags"),De([v({type:"uint8",size:10})],Ie.prototype,"FontPANOSE"),De([v("uint8")],Ie.prototype,"Charset"),De([v("uint8")],Ie.prototype,"Italic"),De([v("uint32")],Ie.prototype,"Weight"),De([v("uint16")],Ie.prototype,"fsType"),De([v("uint16")],Ie.prototype,"MagicNumber"),De([v({type:"uint8",size:16})],Ie.prototype,"UnicodeRange"),De([v({type:"uint8",size:8})],Ie.prototype,"CodePageRange"),De([v("uint32")],Ie.prototype,"CheckSumAdjustment"),De([v({type:"uint8",size:16})],Ie.prototype,"Reserved"),De([v("uint16")],Ie.prototype,"Padding1");var Qd=Object.defineProperty,Vi=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Qd(e,t,i),i};class yr extends qe{constructor(e,t){super(e,t,16)}}Vi([v({type:"char",size:4})],yr.prototype,"tag"),Vi([v("uint32")],yr.prototype,"checkSum"),Vi([v("uint32")],yr.prototype,"offset"),Vi([v("uint32")],yr.prototype,"length");const mn=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],ep=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"];class yn{index;name;isComposite=!1;components=[];pathCommands=[];constructor(e){const t={...e};if(this.index=t.index??0,t.name===".notdef"?t.unicode=void 0:t.name===".null"&&(t.unicode=0),t.unicode===0&&t.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=t.name??null,t.unicode&&(this.unicode=t.unicode),t.unicodes?this.unicodes=t.unicodes:t.unicode&&(this.unicodes=[t.unicode])}getPathCommands(e=0,t=0,r=72,i={},n){const o=1/(n?.unitsPerEm??1e3)*r,{xScale:a=o,yScale:l=o}=i,c=this.pathCommands,h=[];for(let f=0,d=c.length;f<d;f+=1){const g=c[f];g.type==="M"?h.push({type:"M",x:e+g.x*a,y:t+-g.y*l}):g.type==="L"?h.push({type:"L",x:e+g.x*a,y:t+-g.y*l}):g.type==="Q"?h.push({type:"Q",x1:e+g.x1*a,y1:t+-g.y1*l,x:e+g.x*a,y:t+-g.y*l}):g.type==="C"?h.push({type:"C",x1:e+g.x1*a,y1:t+-g.y1*l,x2:e+g.x2*a,y2:t+-g.y2*l,x:e+g.x*a,y:t+-g.y*l}):g.type==="Z"&&h.push({type:"Z"})}return h}}class tp extends yn{parse(e,t,r){const i=this,{nominalWidthX:n,defaultWidthX:o,gsubrsBias:a,subrsBias:l}=e,c=e.topDict.paintType,h=this.index;let f,d,g,p;const y=[],m=[];let P=0,E=!1,x=!1,S=o,_=0,b=0;function C(L,D){y.push({type:"L",x:L,y:D})}function T(L,D,H,I,N,$){y.push({type:"C",x1:L,y1:D,x2:H,y2:I,x:N,y:$})}function B(L,D){x&&c!==2&&G(),x=!0,y.push({type:"M",x:L,y:D})}function G(){y.push({type:"Z"})}function R(L){y.push(...L)}function U(){m.length%2!==0&&!E&&(S=m.shift()+n),P+=m.length>>1,m.length=0,E=!0}function V(L){let D,H,I,N,$,O,j,A,M,F,z,Y,J=0;for(;J<L.length;){let oe=L[J++];switch(oe){case 1:U();break;case 3:U();break;case 4:m.length>1&&!E&&(S=m.shift()+n,E=!0),b+=m.pop(),B(_,b);break;case 5:for(;m.length>0;)_+=m.shift(),b+=m.shift(),C(_,b);break;case 6:for(;m.length>0&&(_+=m.shift(),C(_,b),m.length!==0);)b+=m.shift(),C(_,b);break;case 7:for(;m.length>0&&(b+=m.shift(),C(_,b),m.length!==0);)_+=m.shift(),C(_,b);break;case 8:for(;m.length>0;)f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p+m.shift(),T(f,d,g,p,_,b);break;case 10:$=m.pop()+l,O=e.subrs[$],O&&V(O);break;case 11:return;case 12:switch(oe=L[J],J+=1,oe){case 35:f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),j=g+m.shift(),A=p+m.shift(),M=j+m.shift(),F=A+m.shift(),z=M+m.shift(),Y=F+m.shift(),_=z+m.shift(),b=Y+m.shift(),m.shift(),T(f,d,g,p,j,A),T(M,F,z,Y,_,b);break;case 34:f=_+m.shift(),d=b,g=f+m.shift(),p=d+m.shift(),j=g+m.shift(),A=p,M=j+m.shift(),F=p,z=M+m.shift(),Y=b,_=z+m.shift(),T(f,d,g,p,j,A),T(M,F,z,Y,_,b);break;case 36:f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),j=g+m.shift(),A=p,M=j+m.shift(),F=p,z=M+m.shift(),Y=F+m.shift(),_=z+m.shift(),T(f,d,g,p,j,A),T(M,F,z,Y,_,b);break;case 37:f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),j=g+m.shift(),A=p+m.shift(),M=j+m.shift(),F=A+m.shift(),z=M+m.shift(),Y=F+m.shift(),Math.abs(z-_)>Math.abs(Y-b)?_=z+m.shift():b=Y+m.shift(),T(f,d,g,p,j,A),T(M,F,z,Y,_,b);break;default:console.warn(`Glyph ${h}: unknown operator ${1200+oe}`),m.length=0}break;case 14:if(m.length>=4){const wt=mn[m.pop()],Ze=mn[m.pop()],Be=m.pop(),$e=m.pop();if(wt&&Ze){i.isComposite=!0,i.components=[];const Se=e.charset.indexOf(wt),ze=e.charset.indexOf(Ze);i.components.push({glyphIndex:ze,dx:0,dy:0}),i.components.push({glyphIndex:Se,dx:$e,dy:Be}),R(r.get(ze).pathCommands);const at=JSON.parse(JSON.stringify(r.get(Se).pathCommands));for(let lt=0;lt<at.length;lt+=1){const Je=at[lt];Je.type!=="Z"&&(Je.x+=$e,Je.y+=Be),(Je.type==="Q"||Je.type==="C")&&(Je.x1+=$e,Je.y1+=Be),Je.type==="C"&&(Je.x2+=$e,Je.y2+=Be)}R(at)}}else m.length>0&&!E&&(S=m.shift()+n,E=!0);x&&c!==2&&(G(),x=!1);break;case 18:U();break;case 19:case 20:U(),J+=P+7>>3;break;case 21:m.length>2&&!E&&(S=m.shift()+n,E=!0),b+=m.pop(),_+=m.pop(),B(_,b);break;case 22:m.length>1&&!E&&(S=m.shift()+n,E=!0),_+=m.pop(),B(_,b);break;case 23:U();break;case 24:for(;m.length>2;)f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p+m.shift(),T(f,d,g,p,_,b);_+=m.shift(),b+=m.shift(),C(_,b);break;case 25:for(;m.length>6;)_+=m.shift(),b+=m.shift(),C(_,b);f=_+m.shift(),d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p+m.shift(),T(f,d,g,p,_,b);break;case 26:for(m.length%2&&(_+=m.shift());m.length>0;)f=_,d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g,b=p+m.shift(),T(f,d,g,p,_,b);break;case 27:for(m.length%2&&(b+=m.shift());m.length>0;)f=_+m.shift(),d=b,g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p,T(f,d,g,p,_,b);break;case 28:D=L[J],H=L[J+1],m.push((D<<24|H<<16)>>16),J+=2;break;case 29:$=m.pop()+a,O=e.gsubrs[$],O&&V(O);break;case 30:for(;m.length>0&&(f=_,d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p+(m.length===1?m.shift():0),T(f,d,g,p,_,b),m.length!==0);)f=_+m.shift(),d=b,g=f+m.shift(),p=d+m.shift(),b=p+m.shift(),_=g+(m.length===1?m.shift():0),T(f,d,g,p,_,b);break;case 31:for(;m.length>0&&(f=_+m.shift(),d=b,g=f+m.shift(),p=d+m.shift(),b=p+m.shift(),_=g+(m.length===1?m.shift():0),T(f,d,g,p,_,b),m.length!==0);)f=_,d=b+m.shift(),g=f+m.shift(),p=d+m.shift(),_=g+m.shift(),b=p+(m.length===1?m.shift():0),T(f,d,g,p,_,b);break;default:oe<32?console.warn(`Glyph ${h}: unknown operator ${oe}`):oe<247?m.push(oe-139):oe<251?(D=L[J],J+=1,m.push((oe-247)*256+D+108)):oe<255?(D=L[J],J+=1,m.push(-(oe-251)*256-D-108)):(D=L[J],H=L[J+1],I=L[J+2],N=L[J+3],J+=4,m.push((D<<24|H<<16|I<<8|N)/65536))}}}V(t),this.pathCommands=y,E&&(this.advanceWidth=S)}}class _n{constructor(e){this._sfnt=e}_items=[];get(e){const t=this._items[e];let r;if(t)r=t;else{r=this._get(e);const i=this._sfnt.hmtx.metrics[e];i&&(r.advanceWidth=r.advanceWidth||i.advanceWidth,r.leftSideBearing=r.leftSideBearing||i.leftSideBearing);const n=this._sfnt.cmap.glyphIndexToUnicodesMap.get(e);n&&(r.unicode??=n[0],r.unicodes??=n),this._items[e]=r}return r}}class rp extends _n{get length(){return this._sfnt.cff.charStringsIndex.offsets.length-1}_get(e){const t=this._sfnt.cff,r=new tp({index:e});return r.parse(t,t.charStringsIndex.get(e),this),r.name=t.charset[e],r}}var ip=Object.defineProperty,Tl=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&ip(e,t,i),i};class Gi extends qe{_offsets;get offsets(){return this._offsets??=this.readOffsets()}_objects;get objects(){return this._objects??=this.readObjects()}constructor(e,t,r,i){super(e,t,r,i),this._init()}_init(){const e=this.view,t=this.count,r=this.offsetSize;this.objectOffset=(t+1)*r+2,this.endOffset=e.byteOffset+this.objectOffset+this.offsets[t]}readOffsets(){const e=this.view,t=this.count,r=this.offsetSize;e.seek(3);const i=[];for(let n=0,o=t+1;n<o;n++){const a=this.view;let l=0;for(let c=0;c<r;c++)l<<=8,l+=a.readUint8();i.push(l)}return i}readObjects(){const e=[];for(let t=0,r=this.count;t<r;t++)e.push(this.get(t));return e}get(e){const t=this.offsets,r=this.objectOffset,i=r+t[e],o=r+t[e+1]-i;return this._isString?this.view.readString(i,o):this.view.readBytes(i,o)}}Tl([v("uint16")],Gi.prototype,"count"),Tl([v("uint8")],Gi.prototype,"offsetSize");class ji extends Gi{_isString=!1}class El extends Gi{_isString=!0}const sp=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],np=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron"],op=[".notdef","space","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],ap=[".notdef","space","dollaroldstyle","dollarsuperior","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","fi","fl","ffi","ffl","parenleftinferior","parenrightinferior","hyphensuperior","colonmonetary","onefitted","rupiah","centoldstyle","figuredash","hypheninferior","onequarter","onehalf","threequarters","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior"];function Wi(s,e){return e<=390?sp[e]:s[e-391]}function re(s,e="number",t){return(r,i)=>{if(typeof i!="string")return;const n={type:e,operator:s,default:t??e==="number"?0:void 0};Object.defineProperty(r.constructor.prototype,i,{get(){return this._getProp(n)},set(o){this._setProp(n,o)},configurable:!0,enumerable:!0})}}class Ml extends qe{_dict;get dict(){return this._dict??=this._readDict()}_stringIndex;setStringIndex(e){return this._stringIndex=e,this}_readFloatOperand(){const e=this.view;let t="";const r=15,i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const n=e.readUint8(),o=n>>4,a=n&15;if(o===r||(t+=i[o],a===r))break;t+=i[a]}return Number.parseFloat(t)}_readOperand(e){const t=this.view;let r,i,n,o;if(e===28)return r=t.readUint8(),i=t.readUint8(),r<<8|i;if(e===29)return r=t.readUint8(),i=t.readUint8(),n=t.readUint8(),o=t.readUint8(),r<<24|i<<16|n<<8|o;if(e===30)return this._readFloatOperand();if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return r=t.readUint8(),(e-247)*256+r+108;if(e>=251&&e<=254)return r=t.readUint8(),-(e-251)*256-r-108;throw new Error(`invalid b0 ${e}, at: ${t.cursor}`)}_readDict(){const e=this.view;e.seek(0);let t=[];const r=e.cursor+e.byteLength,i={};for(;e.cursor<r;){let n=e.readUint8();n<=21?(n===12&&(n=1200+e.readUint8()),i[n]=t,t=[]):t.push(this._readOperand(n))}return i}_getProp(e){const t=this.dict[e.operator]??e.default;switch(e.type){case"number":return t[0];case"string":return Wi(this._stringIndex?.objects??[],t[0]);case"number[]":return t}return t}_setProp(e,t){}}var lp=Object.defineProperty,vn=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&lp(e,t,i),i};class qi extends Ml{}vn([re(19)],qi.prototype,"subrs"),vn([re(20)],qi.prototype,"defaultWidthX"),vn([re(21)],qi.prototype,"nominalWidthX");var cp=Object.defineProperty,ce=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&cp(e,t,i),i};class ne extends Ml{}ce([re(0,"string")],ne.prototype,"version"),ce([re(1,"string")],ne.prototype,"notice"),ce([re(1200,"string")],ne.prototype,"copyright"),ce([re(2,"string")],ne.prototype,"fullName"),ce([re(3,"string")],ne.prototype,"familyName"),ce([re(4,"string")],ne.prototype,"weight"),ce([re(1201)],ne.prototype,"isFixedPitch"),ce([re(1202)],ne.prototype,"italicAngle"),ce([re(1203,"number",-100)],ne.prototype,"underlinePosition"),ce([re(1204,"number",50)],ne.prototype,"underlineThickness"),ce([re(1205)],ne.prototype,"paintType"),ce([re(1206,"number",2)],ne.prototype,"charstringType"),ce([re(1207,"number[]",[.001,0,0,.001,0,0])],ne.prototype,"fontMatrix"),ce([re(13)],ne.prototype,"uniqueId"),ce([re(5,"number[]",[0,0,0,0])],ne.prototype,"fontBBox"),ce([re(1208)],ne.prototype,"strokeWidth"),ce([re(14)],ne.prototype,"xuid"),ce([re(15)],ne.prototype,"charset"),ce([re(16)],ne.prototype,"encoding"),ce([re(17)],ne.prototype,"charStrings"),ce([re(18,"number[]",[0,0])],ne.prototype,"private");function we(s,e=s){return t=>{yt.tableDefinitions.set(s,{tag:s,prop:e,class:t}),Object.defineProperty(yt.prototype,e,{get(){return this.get(s)},set(r){return this.set(s,r)},configurable:!0,enumerable:!0})}}class yt{static tableDefinitions=new Map;tables=new Map;tableViews=new Map;get hasGlyf(){return this.tableViews.has("glyf")}get names(){return this.name.names}get unitsPerEm(){return this.head.unitsPerEm}get ascender(){return this.hhea.ascent}get descender(){return this.hhea.descent}get createdTimestamp(){return this.head.created}get modifiedTimestamp(){return this.head.modified}get numGlyphs(){return this.maxp.numGlyphs}get unicodes(){return this.cmap.glyphIndexToUnicodesMap}get glyphs(){return this.hasGlyf?this.glyf.glyphs:this.cff.glyphs}charToGlyphIndex(e){let t=this.cmap.unicodeToGlyphIndexMap.get(e.codePointAt(0));if(t===void 0&&!this.hasGlyf){const{encoding:r,charset:i}=this.cff;t=i.indexOf(r[e.codePointAt(0)])}return t??0}charToGlyph(e){return this.glyphs.get(this.charToGlyphIndex(e))}textToGlyphIndexes(e){const t=[];for(const r of e)t.push(this.charToGlyphIndex(r));return t}textToGlyphs(e){const t=this.glyphs,r=this.textToGlyphIndexes(e),i=r.length,n=Array.from({length:i}),o=t.get(0);for(let a=0;a<i;a+=1)n[a]=t.get(r[a])||o;return n}getPathCommands(e,t,r,i,n){const o=[];return this.forEachGlyph(e,t,r,i,n,(a,l,c,h,f)=>{o.push(...a.getPathCommands(l,c,h,f,this))}),o}getAdvanceWidth(e,t,r){return this.forEachGlyph(e,0,0,t,r,()=>{})}forEachGlyph(e,t=0,r=0,i=72,n={},o){const a=1/this.unitsPerEm*i,l=this.textToGlyphs(e);for(let c=0;c<l.length;c+=1){const h=l[c];o.call(this,h,t,r,i,n),h.advanceWidth&&(t+=h.advanceWidth*a),n.letterSpacing?t+=n.letterSpacing*i:n.tracking&&(t+=n.tracking/1e3*i)}return t}constructor(e){(e instanceof Map?e:new Map(Object.entries(e))).forEach((r,i)=>{this.tableViews.set(i,new DataView(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)))})}clone(){return new yt(this.tableViews)}delete(e){const t=yt.tableDefinitions.get(e);return t?(this.tableViews.delete(e),this.tables.delete(t.prop),this):this}set(e,t){const r=yt.tableDefinitions.get(e);return r&&this.tables.set(r.prop,t),this.tableViews.set(e,t.view),this}get(e){const t=yt.tableDefinitions.get(e);if(!t)return;let r=this.tables.get(t.prop);if(!r){const i=t.class;if(i){const n=this.tableViews.get(e);if(!n)return;r=new i(n.buffer,n.byteOffset,n.byteLength).setSFNT(this),this.tables.set(t.prop,r)}}return r}}class Oe extends qe{setSFNT(e){return this._sfnt=e,this}getSFNT(){return this._sfnt}}var hp=Object.defineProperty,up=Object.getOwnPropertyDescriptor,ni=(s,e,t,r)=>{for(var i=r>1?void 0:r?up(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&hp(e,t,i),i};let er=class extends Oe{_glyphs;get glyphs(){return this._glyphs??=new rp(this._sfnt)}get gsubrs(){return this.globalSubrIndex.objects}get gsubrsBias(){return this._calcSubroutineBias(this.globalSubrIndex.objects)}privateDict;subrsIndex;get defaultWidthX(){return this.privateDict?.defaultWidthX??0}get nominalWidthX(){return this.privateDict?.nominalWidthX??0}get subrs(){return this.subrsIndex?.objects??[]}get subrsBias(){return this._calcSubroutineBias(this.subrs)}constructor(s,e,t,r){super(s,e,t,r),this._init()}_init(){const s=this.view,{buffer:e,byteOffset:t}=s,r=t+4;this.nameIndex=new El(e,r),this.topDictIndex=new ji(e,this.nameIndex.endOffset),this.stringIndex=new El(e,this.topDictIndex.endOffset),this.globalSubrIndex=new ji(e,this.stringIndex.endOffset),this.topDict=new ne(new Uint8Array(this.topDictIndex.objects[0]).buffer).setStringIndex(this.stringIndex);const i=this.topDict.private[0],n=this.topDict.private[1];i&&(this.privateDict=new qi(e,t+n,i).setStringIndex(this.stringIndex),this.privateDict.subrs&&(this.subrsIndex=new ji(e,t+n+this.privateDict.subrs))),this.charStringsIndex=new ji(e,t+this.topDict.charStrings);const o=this.charStringsIndex.offsets.length-1;this.topDict.charset===0?this.charset=np:this.topDict.charset===1?this.charset=op:this.topDict.charset===2?this.charset=ap:this.charset=this._readCharset(t+this.topDict.charset,o,this.stringIndex.objects),this.topDict.encoding===0?this.encoding=mn:this.topDict.encoding===1?this.encoding=ep:this.encoding=this._readEncoding(t+this.topDict.encoding)}_readCharset(s,e,t){const r=this.view;r.seek(s);let i,n,o;e-=1;const a=[".notdef"],l=r.readUint8();if(l===0)for(i=0;i<e;i+=1)n=r.readUint16(),a.push(Wi(t,n));else if(l===1)for(;a.length<=e;)for(n=r.readUint16(),o=r.readUint8(),i=0;i<=o;i+=1)a.push(Wi(t,n)),n+=1;else if(l===2)for(;a.length<=e;)for(n=r.readUint16(),o=r.readUint16(),i=0;i<=o;i+=1)a.push(Wi(t,n)),n+=1;else throw new Error(`Unknown charset format ${l}`);return a}_readEncoding(s){const e=this.view;e.seek(s);let t,r;const i={},n=e.readUint8();if(n===0){const o=e.readUint8();for(t=0;t<o;t+=1)r=e.readUint8(),i[r]=t}else if(n===1){const o=e.readUint8();for(r=1,t=0;t<o;t+=1){const a=e.readUint8(),l=e.readUint8();for(let c=a;c<=a+l;c+=1)i[c]=r,r+=1}}else console.warn(`unknown encoding format:${n}`);return i}_calcSubroutineBias(s){let e;return s.length<1240?e=107:s.length<33900?e=1131:e=32768,e}};ni([v("uint8")],er.prototype,"majorVersion",2),ni([v("uint8")],er.prototype,"minorVersion",2),ni([v("uint8")],er.prototype,"headerSize",2),ni([v("uint8")],er.prototype,"offsetSize",2),er=ni([we("CFF ","cff")],er);var fp=Object.defineProperty,Xi=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&fp(e,t,i),i};const oi=class dc extends qe{constructor(e=new ArrayBuffer(262),t){super(e,t,262)}static from(e){const t=new dc;return t.format=0,t.length=t.view.byteLength,t.language=0,e.forEach((r,i)=>{i<256&&r<256&&t.view.writeUint8(r,6+i)}),t}getUnicodeToGlyphIndexMap(){const e=new Map;return this.glyphIndexArray.forEach((t,r)=>{e.set(r,t)}),e}};Xi([v("uint16")],oi.prototype,"format"),Xi([v("uint16")],oi.prototype,"length"),Xi([v("uint16")],oi.prototype,"language"),Xi([v({type:"uint8",size:256})],oi.prototype,"glyphIndexArray");let bn=oi;var dp=Object.defineProperty,wn=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&dp(e,t,i),i};class ai extends qe{get subHeaderKeys(){return this.view.seek(6),Array.from({length:256},()=>this.view.readUint16()/8)}get maxSubHeaderKey(){return this.subHeaderKeys.reduce((e,t)=>Math.max(e,t),0)}get subHeaders(){const e=this.maxSubHeaderKey;return this.view.seek(6+256*2),Array.from({length:e},(t,r)=>({firstCode:this.view.readUint16(),entryCount:this.view.readUint16(),idDelta:this.view.readUint16(),idRangeOffset:(this.view.readUint16()-(e-r)*8-2)/2}))}get glyphIndexArray(){const e=this.maxSubHeaderKey,t=6+256*2+e*8;this.view.seek(t);const r=(this.view.byteLength-t)/2;return Array.from({length:r},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(e){const t=new Map,r=this.subHeaderKeys,i=this.maxSubHeaderKey,n=this.subHeaders,o=this.glyphIndexArray,a=r.findIndex(c=>c===i);let l=0;for(let c=0;c<256;c++)if(r[c]===0)c>=a||c<n[0].firstCode||c>=n[0].firstCode+n[0].entryCount||n[0].idRangeOffset+(c-n[0].firstCode)>=o.length?l=0:(l=o[n[0].idRangeOffset+(c-n[0].firstCode)],l!==0&&(l=l+n[0].idDelta)),l!==0&&l<e&&t.set(c,l);else{const h=r[c];for(let f=0,d=n[h].entryCount;f<d;f++)if(n[h].idRangeOffset+f>=o.length?l=0:(l=o[n[h].idRangeOffset+f],l!==0&&(l=l+n[h].idDelta)),l!==0&&l<e){const g=(c<<8|f+n[h].firstCode)%65535;t.set(g,l)}}return t}}wn([v("uint16")],ai.prototype,"format"),wn([v("uint16")],ai.prototype,"length"),wn([v("uint16")],ai.prototype,"language");function Al(s){return s>32767?s-65536:s<-32767?s+65536:s}function xn(s,e){let t;const r=[];let i={};return s.forEach((n,o)=>{e&&o>e||((!t||o!==t.unicode+1||n!==t.glyphIndex+1)&&(t?(i.end=t.unicode,r.push(i),i={start:o,startId:n,delta:Al(n-o)}):(i.start=Number(o),i.startId=n,i.delta=Al(n-o))),t={unicode:o,glyphIndex:n})}),t&&(i.end=t.unicode,r.push(i)),r}var pp=Object.defineProperty,tr=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&pp(e,t,i),i};const $t=class pc extends qe{get endCode(){const e=this.segCountX2;return this.view.seek(14),Array.from({length:e/2},()=>this.view.readUint16())}set endCode(e){this.view.seek(14),e.forEach(t=>this.view.writeUint16(t))}get reservedPad(){return this.view.readUint16(14+this.segCountX2)}set reservedPad(e){this.view.writeUint16(e,14+this.segCountX2)}get startCode(){const e=this.segCountX2;return this.view.seek(14+e+2),Array.from({length:e/2},()=>this.view.readUint16())}set startCode(e){this.view.seek(14+this.segCountX2+2),e.forEach(t=>this.view.writeUint16(t))}get idDelta(){const e=this.segCountX2;return this.view.seek(14+e+2+e),Array.from({length:e/2},()=>this.view.readUint16())}set idDelta(e){const t=this.segCountX2;this.view.seek(14+t+2+t),e.forEach(r=>this.view.writeUint16(r))}get idRangeOffsetCursor(){const e=this.segCountX2;return 14+e+2+e*2}get idRangeOffset(){const e=this.segCountX2;return this.view.seek(this.idRangeOffsetCursor),Array.from({length:e/2},()=>this.view.readUint16())}set idRangeOffset(e){this.view.seek(this.idRangeOffsetCursor),e.forEach(t=>this.view.writeUint16(t))}get glyphIndexArrayCursor(){const e=this.segCountX2;return 14+e+2+e*3}get glyphIndexArray(){const e=this.glyphIndexArrayCursor;this.view.seek(e);const t=(this.view.byteLength-e)/2;return Array.from({length:t},()=>this.view.readUint16())}static from(e){const t=xn(e,65535),r=t.length+1,i=Math.floor(Math.log(r)/Math.LN2),n=2*2**i,o=new pc(new ArrayBuffer(24+t.length*8));return o.format=4,o.length=o.view.byteLength,o.language=0,o.segCountX2=r*2,o.searchRange=n,o.entrySelector=i,o.rangeShift=2*r-n,o.endCode=[...t.map(a=>a.end),65535],o.reservedPad=0,o.startCode=[...t.map(a=>a.start),65535],o.idDelta=[...t.map(a=>a.delta),1],o.idRangeOffset=Array.from({length:r},()=>0),o}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.segCountX2/2,r=(this.glyphIndexArrayCursor-this.idRangeOffsetCursor)/2,i=this.startCode,n=this.endCode,o=this.idRangeOffset,a=this.idDelta,l=this.glyphIndexArray;for(let c=0;c<t;++c)for(let h=i[c],f=n[c];h<=f;++h)if(o[c]===0)e.set(h,(h+a[c])%65536);else{const d=c+o[c]/2+(h-i[c])-r,g=l[d];g!==0?e.set(h,(g+a[c])%65536):e.set(h,0)}return e.delete(65535),e}};tr([v("uint16")],$t.prototype,"format"),tr([v("uint16")],$t.prototype,"length"),tr([v("uint16")],$t.prototype,"language"),tr([v("uint16")],$t.prototype,"segCountX2"),tr([v("uint16")],$t.prototype,"searchRange"),tr([v("uint16")],$t.prototype,"entrySelector"),tr([v("uint16")],$t.prototype,"rangeShift");let Pn=$t;var gp=Object.defineProperty,li=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&gp(e,t,i),i};class rr extends qe{get glyphIndexArray(){return this.view.seek(12),Array.from({length:this.entryCount},()=>this.view.readUint16())}getUnicodeToGlyphIndexMap(){const e=this.glyphIndexArray,t=new Map;return e.forEach((r,i)=>{t.set(i,r)}),t}}li([v("uint16")],rr.prototype,"format"),li([v("uint16")],rr.prototype,"length"),li([v("uint16")],rr.prototype,"language"),li([v("uint16")],rr.prototype,"firstCode"),li([v("uint16")],rr.prototype,"entryCount");var mp=Object.defineProperty,ci=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&mp(e,t,i),i};const _r=class gc extends qe{get groups(){const e=this.nGroups;return this.view.seek(16),Array.from({length:e},()=>({startCharCode:this.view.readUint32(),endCharCode:this.view.readUint32(),startGlyphCode:this.view.readUint32()}))}static from(e){const t=xn(e),r=new gc(new ArrayBuffer(16+t.length*12));return r.format=12,r.reserved=0,r.length=r.view.byteLength,r.language=0,r.nGroups=t.length,t.forEach(i=>{r.view.writeUint32(i.start),r.view.writeUint32(i.end),r.view.writeUint32(i.startId)}),r}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.groups;for(let r=0,i=t.length;r<i;r++){const n=t[r];let o=n.startGlyphCode,a=n.startCharCode;const l=n.endCharCode;for(;a<=l;)e.set(a++,o++)}return e}};ci([v("uint16")],_r.prototype,"format"),ci([v("uint16")],_r.prototype,"reserved"),ci([v("uint32")],_r.prototype,"length"),ci([v("uint32")],_r.prototype,"language"),ci([v("uint32")],_r.prototype,"nGroups");let Sn=_r;var yp=Object.defineProperty,Cn=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&yp(e,t,i),i};class hi extends qe{getVarSelectorRecords(){const e=this.numVarSelectorRecords;return this.view.seek(10),Array.from({length:e},()=>{const t={varSelector:this.view.readUint24(),defaultUVSOffset:this.view.readUint32(),unicodeValueRanges:[],nonDefaultUVSOffset:this.view.readUint32(),uVSMappings:[]};if(t.defaultUVSOffset){this.view.seek(t.defaultUVSOffset);const r=this.view.readUint32();t.unicodeValueRanges=Array.from({length:r},()=>({startUnicodeValue:this.view.readUint24(),additionalCount:this.view.readUint8()}))}if(t.nonDefaultUVSOffset){this.view.seek(t.nonDefaultUVSOffset);const r=this.view.readUint32();t.uVSMappings=Array.from({length:r},()=>({unicodeValue:this.view.readUint24(),glyphID:this.view.readUint16()}))}return t})}getUnicodeToGlyphIndexMap(){const e=new Map,t=this.getVarSelectorRecords();for(let r=0,i=t.length;r<i;r++){const{uVSMappings:n}=t[r];n.forEach(o=>{e.set(o.unicodeValue,o.glyphID)})}return e}}Cn([v("uint16")],hi.prototype,"format"),Cn([v("uint32")],hi.prototype,"length"),Cn([v("uint32")],hi.prototype,"numVarSelectorRecords");var _p=Object.defineProperty,vp=Object.getOwnPropertyDescriptor,Tn=(s,e,t,r)=>{for(var i=r>1?void 0:r?vp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&_p(e,t,i),i};let vr=class extends Oe{static from(s){const e=Array.from(s.keys()).some(h=>h>65535),t=Pn.from(s),r=bn.from(s),i=e?Sn.from(s):void 0,n=4+(i?32:24),o=n+t.view.byteLength,a=o+r.view.byteLength,l=[{platformID:0,platformSpecificID:3,offset:n},{platformID:1,platformSpecificID:0,offset:o},{platformID:3,platformSpecificID:1,offset:n},i&&{platformID:3,platformSpecificID:10,offset:a}].filter(Boolean),c=new vr(new ArrayBuffer(4+8*l.length+t.view.byteLength+r.view.byteLength+(i?.view.byteLength??0)));return c.numberSubtables=l.length,c.view.seek(4),l.forEach(h=>{c.view.writeUint16(h.platformID),c.view.writeUint16(h.platformSpecificID),c.view.writeUint32(h.offset)}),c.view.writeBytes(t.view,n),c.view.writeBytes(r.view,o),i&&c.view.writeBytes(i.view,a),c}_unicodeToGlyphIndexMap;get unicodeToGlyphIndexMap(){return this._unicodeToGlyphIndexMap??=this.readunicodeToGlyphIndexMap()}_glyphIndexToUnicodesMap;get glyphIndexToUnicodesMap(){if(!this._glyphIndexToUnicodesMap){const s=new Map,e=this.unicodeToGlyphIndexMap,t=Array.from(e.keys());for(let r=0,i=t.length;r<i;r++){const n=t[r],o=e.get(n);s.has(o)?s.get(o).push(n):s.set(o,[n])}this._glyphIndexToUnicodesMap=s}return this._glyphIndexToUnicodesMap}readSubtables(){const s=this.numberSubtables;return this.view.seek(4),Array.from({length:s},()=>({platformID:this.view.readUint16(),platformSpecificID:this.view.readUint16(),offset:this.view.readUint32()})).map(e=>{this.view.seek(e.offset);const t=this.view.readUint16();let r;switch(t){case 0:r=new bn(this.view.buffer,e.offset);break;case 2:r=new ai(this.view.buffer,e.offset,this.view.readUint16());break;case 4:r=new Pn(this.view.buffer,e.offset,this.view.readUint16());break;case 6:r=new rr(this.view.buffer,e.offset,this.view.readUint16());break;case 12:r=new Sn(this.view.buffer,e.offset,this.view.readUint32(e.offset+4));break;case 14:default:r=new hi(this.view.buffer,e.offset,this.view.readUint32());break}return{...e,format:t,view:r}})}readunicodeToGlyphIndexMap(){const s=this.readSubtables(),e=s.find(o=>o.format===0)?.view,t=s.find(o=>o.platformID===3&&o.platformSpecificID===3&&o.format===2)?.view,r=s.find(o=>o.platformID===3&&o.platformSpecificID===1&&o.format===4)?.view,i=s.find(o=>o.platformID===3&&o.platformSpecificID===10&&o.format===12)?.view,n=s.find(o=>o.platformID===0&&o.platformSpecificID===5&&o.format===14)?.view;return new Map([...e?.getUnicodeToGlyphIndexMap()??[],...t?.getUnicodeToGlyphIndexMap(this._sfnt.maxp.numGlyphs)??[],...r?.getUnicodeToGlyphIndexMap()??[],...i?.getUnicodeToGlyphIndexMap()??[],...n?.getUnicodeToGlyphIndexMap()??[]])}};Tn([v("uint16")],vr.prototype,"version",2),Tn([v("uint16")],vr.prototype,"numberSubtables",2),vr=Tn([we("cmap")],vr);class bp extends yn{_parseContours(e){const t=[];let r=[];for(let i=0;i<e.length;i+=1){const n=e[i];r.push(n),n.lastPointOfContour&&(t.push(r),r=[])}return ii(r.length===0,"There are still points left in the current contour."),t}_transformPoints(e,t){const r=[];for(let i=0;i<e.length;i+=1){const n=e[i],o={x:t.xScale*n.x+t.scale10*n.y+t.dx,y:t.scale01*n.x+t.yScale*n.y+t.dy,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour};r.push(o)}return r}_parseGlyphCoordinate(e,t,r,i,n){let o;return(t&i)>0?(o=e.view.readUint8(),(t&n)===0&&(o=-o),o=r+o):(t&n)>0?o=r:o=r+e.view.readInt16(),o}parse(e,t,r){e.view.seek(t);const i=this.numberOfContours=e.view.readInt16();if(this.xMin=e.view.readInt16(),this.yMin=e.view.readInt16(),this.xMax=e.view.readInt16(),this.yMax=e.view.readInt16(),i>0){const a=this.endPointIndices=[];for(let y=0;y<i;y++)a.push(e.view.readUint16());const l=this.instructionLength=e.view.readUint16();ii(l<5e3,`Bad instructionLength:${l}`);const c=this.instructions=[];for(let y=0;y<l;++y)c.push(e.view.readUint8());const h=e.view.byteOffset,f=a[a.length-1]+1;ii(f<2e4,`Bad numberOfCoordinates:${h}`);const d=[];let g,p=0;for(;p<f;)if(g=e.view.readUint8(),d.push(g),p++,g&8&&p<f){const y=e.view.readUint8();for(let m=0;m<y;m++)d.push(g),p++}if(ii(d.length===f,`Bad flags length: ${d.length}, numberOfCoordinates: ${f}`),a.length>0){const y=[];let m;if(f>0){for(let x=0;x<f;x+=1)g=d[x],m={},m.onCurve=!!(g&1),m.lastPointOfContour=a.includes(x),y.push(m);let P=0;for(let x=0;x<f;x+=1)g=d[x],m=y[x],m.x=this._parseGlyphCoordinate(e,g,P,2,16),P=m.x;let E=0;for(let x=0;x<f;x+=1)g=d[x],m=y[x],m.y=this._parseGlyphCoordinate(e,g,E,4,32),E=m.y}this.points=y}else this.points=[]}else if(i===0)this.points=[];else{this.isComposite=!0,this.points=[],this.components=[];let a,l=!0;for(;l;){a=e.view.readUint16();const c={glyphIndex:e.view.readUint16(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(a&1)>0?(a&2)>0?(c.dx=e.view.readInt16(),c.dy=e.view.readInt16()):c.matchedPoints=[e.view.readUint16(),e.view.readUint16()]:(a&2)>0?(c.dx=e.view.readInt8(),c.dy=e.view.readInt8()):c.matchedPoints=[e.view.readUint8(),e.view.readUint8()],(a&8)>0?c.xScale=c.yScale=e.view.readInt16()/16384:(a&64)>0?(c.xScale=e.view.readInt16()/16384,c.yScale=e.view.readInt16()/16384):(a&128)>0&&(c.xScale=e.view.readInt16()/16384,c.scale01=e.view.readInt16()/16384,c.scale10=e.view.readInt16()/16384,c.yScale=e.view.readInt16()/16384),this.components.push(c),l=!!(a&32)}if(a&256){this.instructionLength=e.view.readUint16(),this.instructions=[];for(let c=0;c<this.instructionLength;c+=1)this.instructions.push(e.view.readUint8())}}if(this.isComposite)for(let a=0;a<this.components.length;a+=1){const l=this.components[a],c=r.get(l.glyphIndex);if(c.getPathCommands(),c.points){let h;if(l.matchedPoints===void 0)h=this._transformPoints(c.points,l);else{ii(l.matchedPoints[0]>this.points.length-1||l.matchedPoints[1]>c.points.length-1,`Matched points out of range in ${this.name}`);const f=this.points[l.matchedPoints[0]];let d=c.points[l.matchedPoints[1]];const g={xScale:l.xScale,scale01:l.scale01,scale10:l.scale10,yScale:l.yScale,dx:0,dy:0};d=this._transformPoints([d],g)[0],g.dx=f.x-d.x,g.dy=f.y-d.y,h=this._transformPoints(c.points,g)}this.points=this.points.concat(h)}}const n=[],o=this._parseContours(this.points);for(let a=0,l=o.length;a<l;++a){const c=o[a];let h=c[c.length-1],f=c[0];h.onCurve?n.push({type:"M",x:h.x,y:h.y}):f.onCurve?n.push({type:"M",x:f.x,y:f.y}):n.push({type:"M",x:(h.x+f.x)*.5,y:(h.y+f.y)*.5});for(let d=0,g=c.length;d<g;++d)if(h=f,f=c[(d+1)%g],h.onCurve)n.push({type:"L",x:h.x,y:h.y});else{let p=f;f.onCurve||(p={x:(h.x+f.x)*.5,y:(h.y+f.y)*.5}),n.push({type:"Q",x1:h.x,y1:h.y,x:p.x,y:p.y})}n.push({type:"Z"})}this.pathCommands=n}}class wp extends _n{get length(){return this._sfnt.loca.locations.length}_get(e){const t=this._sfnt.loca.locations,r=t[e],i=new bp({index:e});return r!==t[e+1]&&i.parse(this._sfnt.glyf,r,this),i}}var xp=Object.getOwnPropertyDescriptor,Pp=(s,e,t,r)=>{for(var i=r>1?void 0:r?xp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Hi=class extends Oe{static from(s){const e=s.reduce((r,i)=>r+i.byteLength,0),t=new Hi(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeBytes(r)}),t}_glyphs;get glyphs(){return this._glyphs??=new wp(this._sfnt)}};Hi=Pp([we("glyf")],Hi);var Sp=Object.getOwnPropertyDescriptor,Cp=(s,e,t,r)=>{for(var i=r>1?void 0:r?Sp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let En=class extends Oe{};En=Cp([we("GPOS","gpos")],En);var Tp=Object.defineProperty,Ep=Object.getOwnPropertyDescriptor,ir=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ep(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Tp(e,t,i),i};let Ot=class extends Oe{};ir([v("uint16")],Ot.prototype,"majorVersion",2),ir([v("uint16")],Ot.prototype,"minorVersion",2),ir([v("uint16")],Ot.prototype,"scriptListOffset",2),ir([v("uint16")],Ot.prototype,"featureListOffset",2),ir([v("uint16")],Ot.prototype,"lookupListOffset",2),ir([v("uint16")],Ot.prototype,"featureVariationsOffset",2),Ot=ir([we("GSUB","gsub")],Ot);var Mp=Object.defineProperty,Ap=Object.getOwnPropertyDescriptor,ye=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ap(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Mp(e,t,i),i};let ue=class extends Oe{constructor(s=new ArrayBuffer(54),e){super(s,e,Math.min(54,s.byteLength-(e??0)))}};ye([v("fixed")],ue.prototype,"version",2),ye([v("fixed")],ue.prototype,"fontRevision",2),ye([v("uint32")],ue.prototype,"checkSumAdjustment",2),ye([v("uint32")],ue.prototype,"magickNumber",2),ye([v("uint16")],ue.prototype,"flags",2),ye([v("uint16")],ue.prototype,"unitsPerEm",2),ye([v({type:"longDateTime"})],ue.prototype,"created",2),ye([v({type:"longDateTime"})],ue.prototype,"modified",2),ye([v("int16")],ue.prototype,"xMin",2),ye([v("int16")],ue.prototype,"yMin",2),ye([v("int16")],ue.prototype,"xMax",2),ye([v("int16")],ue.prototype,"yMax",2),ye([v("uint16")],ue.prototype,"macStyle",2),ye([v("uint16")],ue.prototype,"lowestRecPPEM",2),ye([v("int16")],ue.prototype,"fontDirectionHint",2),ye([v("int16")],ue.prototype,"indexToLocFormat",2),ye([v("int16")],ue.prototype,"glyphDataFormat",2),ue=ye([we("head")],ue);var Op=Object.defineProperty,kp=Object.getOwnPropertyDescriptor,Re=(s,e,t,r)=>{for(var i=r>1?void 0:r?kp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Op(e,t,i),i};let xe=class extends Oe{constructor(s=new ArrayBuffer(36),e){super(s,e,Math.min(36,s.byteLength-(e??0)))}};Re([v("fixed")],xe.prototype,"version",2),Re([v("int16")],xe.prototype,"ascent",2),Re([v("int16")],xe.prototype,"descent",2),Re([v("int16")],xe.prototype,"lineGap",2),Re([v("uint16")],xe.prototype,"advanceWidthMax",2),Re([v("int16")],xe.prototype,"minLeftSideBearing",2),Re([v("int16")],xe.prototype,"minRightSideBearing",2),Re([v("int16")],xe.prototype,"xMaxExtent",2),Re([v("int16")],xe.prototype,"caretSlopeRise",2),Re([v("int16")],xe.prototype,"caretSlopeRun",2),Re([v("int16")],xe.prototype,"caretOffset",2),Re([v({type:"int16",size:4})],xe.prototype,"reserved",2),Re([v("int16")],xe.prototype,"metricDataFormat",2),Re([v("uint16")],xe.prototype,"numOfLongHorMetrics",2),xe=Re([we("hhea")],xe);var Dp=Object.getOwnPropertyDescriptor,Ip=(s,e,t,r)=>{for(var i=r>1?void 0:r?Dp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Yi=class extends Oe{static from(s){const e=s.length*4,t=new Yi(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeUint16(r.advanceWidth),t.view.writeUint16(r.leftSideBearing)}),t}_metrics;get metrics(){return this._metrics??=this.readMetrics()}readMetrics(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.hhea.numOfLongHorMetrics;let t=0;const r=this.view;return r.seek(0),Array.from({length:s}).map((i,n)=>(n<e&&(t=r.readUint16()),{advanceWidth:t,leftSideBearing:r.readUint16()}))}};Yi=Ip([we("hmtx")],Yi);var Rp=Object.getOwnPropertyDescriptor,Up=(s,e,t,r)=>{for(var i=r>1?void 0:r?Rp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Mn=class extends Oe{};Mn=Up([we("kern","kern")],Mn);var Bp=Object.getOwnPropertyDescriptor,Lp=(s,e,t,r)=>{for(var i=r>1?void 0:r?Bp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Ki=class extends Oe{static from(s,e=1){const t=s.length*(e?4:2),r=new Ki(new ArrayBuffer(t));return s.forEach(i=>{e?r.view.writeUint32(i):r.view.writeUint16(i/2)}),r}_locations;get locations(){return this._locations??=this.readLocations()}readLocations(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.head.indexToLocFormat,t=this.view;return t.seek(0),Array.from({length:s}).map(()=>e?t.readUint32():t.readUint16()*2)}};Ki=Lp([we("loca")],Ki);var Np=Object.defineProperty,Fp=Object.getOwnPropertyDescriptor,ke=(s,e,t,r)=>{for(var i=r>1?void 0:r?Fp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Np(e,t,i),i};let _e=class extends Oe{constructor(s=new ArrayBuffer(32),e){super(s,e,Math.min(32,s.byteLength-(e??0)))}};ke([v("fixed")],_e.prototype,"version",2),ke([v("uint16")],_e.prototype,"numGlyphs",2),ke([v("uint16")],_e.prototype,"maxPoints",2),ke([v("uint16")],_e.prototype,"maxContours",2),ke([v("uint16")],_e.prototype,"maxComponentPoints",2),ke([v("uint16")],_e.prototype,"maxComponentContours",2),ke([v("uint16")],_e.prototype,"maxZones",2),ke([v("uint16")],_e.prototype,"maxTwilightPoints",2),ke([v("uint16")],_e.prototype,"maxStorage",2),ke([v("uint16")],_e.prototype,"maxFunctionDefs",2),ke([v("uint16")],_e.prototype,"maxInstructionDefs",2),ke([v("uint16")],_e.prototype,"maxStackElements",2),ke([v("uint16")],_e.prototype,"maxSizeOfInstructions",2),ke([v("uint16")],_e.prototype,"maxComponentElements",2),ke([v("uint16")],_e.prototype,"maxComponentDepth",2),_e=ke([we("maxp")],_e);var $p=Object.defineProperty,zp=Object.getOwnPropertyDescriptor,Zi=(s,e,t,r)=>{for(var i=r>1?void 0:r?zp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&$p(e,t,i),i};const Ol={0:"copyright",1:"fontFamily",2:"fontSubFamily",3:"uniqueSubFamily",4:"fullName",5:"version",6:"postScriptName",7:"tradeMark",8:"manufacturer",9:"designer",10:"description",11:"urlOfFontVendor",12:"urlOfFontDesigner",13:"licence",14:"urlOfLicence",16:"preferredFamily",17:"preferredSubFamily",18:"compatibleFull",19:"sampleText"},An={Macintosh:1,Microsoft:3},Vp={Default:0},kl={UCS2:1};let br=class extends Oe{_names;get names(){return this._names??=this.readNames()}readNames(){const s=this.count;this.view.seek(6);const e=[];for(let a=0;a<s;++a)e.push({platform:this.view.readUint16(),encoding:this.view.readUint16(),language:this.view.readUint16(),nameId:this.view.readUint16(),length:this.view.readUint16(),offset:this.view.readUint16()});const t=this.stringOffset;for(let a=0;a<s;++a){const l=e[a];l.name=this.view.readBytes(t+l.offset,l.length)}let r=An.Macintosh,i=Vp.Default,n=0;e.some(a=>a.platform===An.Microsoft&&a.encoding===kl.UCS2&&a.language===1033)&&(r=An.Microsoft,i=kl.UCS2,n=1033);const o={};for(let a=0;a<s;++a){const l=e[a];l.platform===r&&l.encoding===i&&l.language===n&&Ol[l.nameId]&&(o[Ol[l.nameId]]=n===0?Yd(l.name):Kd(l.name))}return o}};Zi([v("uint16")],br.prototype,"format",2),Zi([v("uint16")],br.prototype,"count",2),Zi([v("uint16")],br.prototype,"stringOffset",2),br=Zi([we("name")],br);var Gp=Object.defineProperty,jp=Object.getOwnPropertyDescriptor,X=(s,e,t,r)=>{for(var i=r>1?void 0:r?jp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Gp(e,t,i),i};let q=class extends Oe{get fontPANOSE(){return[this.bFamilyType,this.bSerifStyle,this.bWeight,this.bProportion,this.bContrast,this.bStrokeVariation,this.bArmStyle,this.bLetterform,this.bMidline,this.bXHeight]}};X([v("uint16")],q.prototype,"version",2),X([v("int16")],q.prototype,"xAvgCharWidth",2),X([v("uint16")],q.prototype,"usWeightClass",2),X([v("uint16")],q.prototype,"usWidthClass",2),X([v("uint16")],q.prototype,"fsType",2),X([v("uint16")],q.prototype,"ySubscriptXSize",2),X([v("uint16")],q.prototype,"ySubscriptYSize",2),X([v("uint16")],q.prototype,"ySubscriptXOffset",2),X([v("uint16")],q.prototype,"ySubscriptYOffset",2),X([v("uint16")],q.prototype,"ySuperscriptXSize",2),X([v("uint16")],q.prototype,"ySuperscriptYSize",2),X([v("uint16")],q.prototype,"ySuperscriptXOffset",2),X([v("uint16")],q.prototype,"ySuperscriptYOffset",2),X([v("uint16")],q.prototype,"yStrikeoutSize",2),X([v("uint16")],q.prototype,"yStrikeoutPosition",2),X([v("uint16")],q.prototype,"sFamilyClass",2),X([v({type:"uint8"})],q.prototype,"bFamilyType",2),X([v({type:"uint8"})],q.prototype,"bSerifStyle",2),X([v({type:"uint8"})],q.prototype,"bWeight",2),X([v({type:"uint8"})],q.prototype,"bProportion",2),X([v({type:"uint8"})],q.prototype,"bContrast",2),X([v({type:"uint8"})],q.prototype,"bStrokeVariation",2),X([v({type:"uint8"})],q.prototype,"bArmStyle",2),X([v({type:"uint8"})],q.prototype,"bLetterform",2),X([v({type:"uint8"})],q.prototype,"bMidline",2),X([v({type:"uint8"})],q.prototype,"bXHeight",2),X([v({type:"uint8",size:16})],q.prototype,"ulUnicodeRange",2),X([v({type:"char",size:4})],q.prototype,"achVendID",2),X([v("uint16")],q.prototype,"fsSelection",2),X([v("uint16")],q.prototype,"usFirstCharIndex",2),X([v("uint16")],q.prototype,"usLastCharIndex",2),X([v("int16")],q.prototype,"sTypoAscender",2),X([v("int16")],q.prototype,"sTypoDescender",2),X([v("int16")],q.prototype,"sTypoLineGap",2),X([v("uint16")],q.prototype,"usWinAscent",2),X([v("uint16")],q.prototype,"usWinDescent",2),X([v({offset:72,type:"uint8",size:8})],q.prototype,"ulCodePageRange",2),X([v({offset:72,type:"int16"})],q.prototype,"sxHeight",2),X([v("int16")],q.prototype,"sCapHeight",2),X([v("uint16")],q.prototype,"usDefaultChar",2),X([v("uint16")],q.prototype,"usBreakChar",2),X([v("uint16")],q.prototype,"usMaxContext",2),q=X([we("OS/2","os2")],q);var Wp=Object.defineProperty,qp=Object.getOwnPropertyDescriptor,_t=(s,e,t,r)=>{for(var i=r>1?void 0:r?qp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Wp(e,t,i),i};let Ke=class extends Oe{constructor(s=new ArrayBuffer(32),e,t){super(s,e,t)}};_t([v("fixed")],Ke.prototype,"format",2),_t([v("fixed")],Ke.prototype,"italicAngle",2),_t([v("int16")],Ke.prototype,"underlinePosition",2),_t([v("int16")],Ke.prototype,"underlineThickness",2),_t([v("uint32")],Ke.prototype,"isFixedPitch",2),_t([v("uint32")],Ke.prototype,"minMemType42",2),_t([v("uint32")],Ke.prototype,"maxMemType42",2),_t([v("uint32")],Ke.prototype,"minMemType1",2),_t([v("uint32")],Ke.prototype,"maxMemType1",2),Ke=_t([we("post")],Ke);var Xp=Object.defineProperty,Hp=Object.getOwnPropertyDescriptor,Ue=(s,e,t,r)=>{for(var i=r>1?void 0:r?Hp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Xp(e,t,i),i};let Pe=class extends Oe{constructor(s=new ArrayBuffer(36),e){super(s,e,Math.min(36,s.byteLength-(e??0)))}};Ue([v("fixed")],Pe.prototype,"version",2),Ue([v("int16")],Pe.prototype,"vertTypoAscender",2),Ue([v("int16")],Pe.prototype,"vertTypoDescender",2),Ue([v("int16")],Pe.prototype,"vertTypoLineGap",2),Ue([v("int16")],Pe.prototype,"advanceHeightMax",2),Ue([v("int16")],Pe.prototype,"minTopSideBearing",2),Ue([v("int16")],Pe.prototype,"minBottomSideBearing",2),Ue([v("int16")],Pe.prototype,"yMaxExtent",2),Ue([v("int16")],Pe.prototype,"caretSlopeRise",2),Ue([v("int16")],Pe.prototype,"caretSlopeRun",2),Ue([v("int16")],Pe.prototype,"caretOffset",2),Ue([v({type:"int16",size:4})],Pe.prototype,"reserved",2),Ue([v("int16")],Pe.prototype,"metricDataFormat",2),Ue([v("int16")],Pe.prototype,"numOfLongVerMetrics",2),Pe=Ue([we("vhea")],Pe);var Yp=Object.getOwnPropertyDescriptor,Kp=(s,e,t,r)=>{for(var i=r>1?void 0:r?Yp(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};let Ji=class extends Oe{static from(s){const e=s.length*4,t=new Ji(new ArrayBuffer(e));return s.forEach(r=>{t.view.writeUint16(r.advanceHeight),t.view.writeInt16(r.topSideBearing)}),t}_metrics;get metrics(){return this._metrics??=this.readMetrics()}readMetrics(){const s=this._sfnt.maxp.numGlyphs,e=this._sfnt.vhea?.numOfLongVerMetrics??0,t=this.view;t.seek(0);let r=0;return Array.from({length:s}).map((i,n)=>(n<e&&(r=t.readUint16()),{advanceHeight:r,topSideBearing:t.readUint8()}))}};Ji=Kp([we("vmtx")],Ji);var Zp=Object.defineProperty,ui=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Zp(e,t,i),i};class st extends zi{format="TrueType";mimeType="font/ttf";_sfnt;get sfnt(){return this._sfnt||(this._sfnt=this.createSFNT()),this._sfnt}static signature=new Set([65536,1953658213,1954115633]);static is(e){return typeof e=="number"?this.signature.has(e):this.signature.has(mr(e).getUint32(0))}static checksum(e){const t=mr(e);let r=t.byteLength;for(;r%4;)r++;let i=0;for(let n=0,o=r/4;n<o;n+=4)n*4<r-4&&(i+=t.getUint32(n*4,!1));return i&4294967295}static from(e){const t=f=>f+3&-4,r=e.tableViews.size,i=Array.from(e.tableViews.values()).reduce((f,d)=>f+t(d.byteLength),0),n=new this(new ArrayBuffer(12+r*16+i));n.scalerType=65536,n.numTables=r;const o=Math.log(2);n.searchRange=Math.floor(Math.log(r)/o)*16,n.entrySelector=Math.floor(n.searchRange/o),n.rangeShift=r*16-n.searchRange;let a=12+r*16,l=0;const c=n.getDirectories();e.tableViews.forEach((f,d)=>{const g=c[l++];g.tag=d,g.checkSum=this.checksum(f),g.offset=a,g.length=f.byteLength,n.view.writeBytes(f,a),a+=t(g.length)});const h=n.createSFNT().head;return h.checkSumAdjustment=0,h.checkSumAdjustment=2981146554-this.checksum(n.view),n}getDirectories(){let e=this.view.byteOffset+12;return Array.from({length:this.numTables},()=>{const t=new yr(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new yt(this.getDirectories().reduce((e,t)=>(e[t.tag]=new DataView(this.view.buffer,this.view.byteOffset+t.offset,t.length),e),{}))}}ui([v("uint32")],st.prototype,"scalerType"),ui([v("uint16")],st.prototype,"numTables"),ui([v("uint16")],st.prototype,"searchRange"),ui([v("uint16")],st.prototype,"entrySelector"),ui([v("uint16")],st.prototype,"rangeShift");class On extends st{format="OpenType";mimeType="font/otf";static signature=new Set([1330926671]);static from(e){return super.from(e)}}var Jp=Object.defineProperty,fi=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Jp(e,t,i),i};class sr extends qe{constructor(e,t){super(e,t,20)}}fi([v({type:"char",size:4})],sr.prototype,"tag"),fi([v("uint32")],sr.prototype,"offset"),fi([v("uint32")],sr.prototype,"compLength"),fi([v("uint32")],sr.prototype,"origLength"),fi([v("uint32")],sr.prototype,"origChecksum");var Qp=Object.defineProperty,Xe=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Qp(e,t,i),i};const Fe=class Kn extends zi{format="WOFF";mimeType="font/woff";get subfontFormat(){return st.is(this.flavor)?"TrueType":On.is(this.flavor)?"OpenType":"Open"}_sfnt;get sfnt(){return this._sfnt||(this._sfnt=this.createSFNT()),this._sfnt}static signature=new Set([2001684038]);static is(e){return typeof e=="number"?this.signature.has(e):this.signature.has(mr(e).getUint32(0))}static checkSum(e){const t=mr(e),r=t.byteLength,i=Math.floor(r/4);let n=0,o=0;for(;o<i;)n+=t.getUint32(4*o++,!1);let a=r-i*4;if(a){let l=i*4;for(;a>0;)n+=t.getUint8(l)<<a*8,l++,a--}return n%4294967296}static from(e,t=new ArrayBuffer(0)){const r=f=>f+3&-4,i=[];e.tableViews.forEach((f,d)=>{const g=mr(Vd(new Uint8Array(f.buffer,f.byteOffset,f.byteLength)));i.push({tag:d,view:g.byteLength<f.byteLength?g:f,rawView:f})});const n=i.length,o=i.reduce((f,d)=>f+r(d.view.byteLength),0),a=new Kn(new ArrayBuffer(44+20*n+o+t.byteLength));a.signature=2001684038,a.flavor=65536,a.length=a.view.byteLength,a.numTables=n,a.totalSFNTSize=12+16*n+i.reduce((f,d)=>f+r(d.rawView.byteLength),0);let l=44+n*20,c=0;const h=a.getDirectories();return i.forEach(f=>{const d=h[c++];d.tag=f.tag,d.offset=l,d.compLength=f.view.byteLength,d.origChecksum=Kn.checkSum(f.rawView),d.origLength=f.rawView.byteLength,a.view.writeBytes(f.view,l),l+=r(d.compLength)}),a.view.writeBytes(t),a}getDirectories(){let e=44;return Array.from({length:this.numTables},()=>{const t=new sr(this.view.buffer,e);return e+=t.view.byteLength,t})}createSFNT(){return new yt(this.getDirectories().reduce((e,t)=>{const r=t.tag,i=this.view.byteOffset+t.offset,n=t.compLength,o=t.origLength,a=i+n;return e[r]=n>=o?new DataView(this.view.buffer,i,n):new DataView(Gd(new Uint8Array(this.view.buffer.slice(i,a))).buffer),e},{}))}};Xe([v("uint32")],Fe.prototype,"signature"),Xe([v("uint32")],Fe.prototype,"flavor"),Xe([v("uint32")],Fe.prototype,"length"),Xe([v("uint16")],Fe.prototype,"numTables"),Xe([v("uint16")],Fe.prototype,"reserved"),Xe([v("uint32")],Fe.prototype,"totalSFNTSize"),Xe([v("uint16")],Fe.prototype,"majorVersion"),Xe([v("uint16")],Fe.prototype,"minorVersion"),Xe([v("uint32")],Fe.prototype,"metaOffset"),Xe([v("uint32")],Fe.prototype,"metaLength"),Xe([v("uint32")],Fe.prototype,"metaOrigLength"),Xe([v("uint32")],Fe.prototype,"privOffset"),Xe([v("uint32")],Fe.prototype,"privLength");let Qi=Fe;function Dl(s,e=!0){if(st.is(s))return new st(s);if(On.is(s))return new On(s);if(Qi.is(s))return new Qi(s);if(e)throw new Error("Failed to parseFont")}function Il(s,e=!0){const t=Dl(s,!1);if(t)return t;if(e)throw new Error("Failed to parseFont")}class es{static defaultRequestInit={cache:"force-cache"};fallbackFont;loading=new Map;loaded=new Map;familyToUrl=new Map;setFallbackFont(e){this.fallbackFont=e}async loadFallbackFont(e,t={}){this.fallbackFont=await this.load(e,t)}_createRequest(e,t){const r=new AbortController;return{url:e,when:fetch(e,{...es.defaultRequestInit,...t,signal:r.signal}).then(i=>i.arrayBuffer()),cancel:()=>r.abort()}}injectFontFace(e,t){return document.fonts.add(new FontFace(e,t)),this}injectStyleTag(e,t){const r=document.createElement("style");return r.appendChild(document.createTextNode(`@font-face {
863
863
  font-family: "${e}";
864
864
  src: url(${t});
865
- }`)),document.head.appendChild(r),this}_parseUrls(e){const t=Array.from(new Set([...e.split(","),e]));return Array.from(new Set(t.map(r=>this.familyToUrl.get(r.trim())??this.familyToUrl.get(r)??r)))}get(e){let t;return e&&(t=this._parseUrls(e).reduce((i,n)=>i||this.loaded.get(n),void 0)),t??this.fallbackFont}set(e,t){return this.familyToUrl.set(e,t.src),this.loaded.set(t.src,t),this}delete(e){return this._parseUrls(e).forEach(t=>{this.familyToUrl.delete(t),this.loaded.delete(t)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(e,t={}){const{cancelOther:r,injectFontFace:i=!0,injectStyleTag:n=!0,...o}=t;let a,l;if(typeof e=="string"?a=e:{src:a,family:l}=e,this.loaded.has(a))return r&&(this.loading.forEach(g=>g.cancel()),this.loading.clear()),f(this.loaded.get(a));let c=this.loading.get(a);return c||(c=this._createRequest(a,o),this.loading.set(a,c)),r&&this.loading.forEach((g,p)=>{g!==c&&(g.cancel(),this.loading.delete(p))}),c.when.then(g=>{if(this.loaded.has(a))return f(this.loaded.get(a));{const p=d(g);return t.noAdd||this.loaded.set(a,p),p.familySet.forEach(y=>{this.familyToUrl.set(y,a),typeof document<"u"&&(i&&this.injectFontFace(y,g),n&&this.injectStyleTag(y,a))}),p}}).catch(g=>{if(g instanceof DOMException&&g.message==="The user aborted a request.")return d();throw g}).finally(()=>{this.loading.delete(a)});function h(){return l?Array.isArray(l)?l:[l]:[]}function f(g){return h().forEach(p=>{g.familySet.add(p)}),g}function d(g=new ArrayBuffer(0)){let p;function y(){return p||(p=g.byteLength?Il(g,!1):void 0),p}function m(){const P=y();if(P instanceof st||P instanceof Qi)return P.sfnt}return{src:a,family:l,buffer:g,familySet:new Set(h()),getFont:y,getSFNT:m}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(e=>e.when))}}const Rl=new es,eg=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:zi,get Cff(){return er},get Cmap(){return vr},CmapSubtableFormat0:bn,CmapSubtableFormat12:Sn,CmapSubtableFormat14:hi,CmapSubtableFormat2:ai,CmapSubtableFormat4:Pn,CmapSubtableFormat6:rr,FontDataObject:qe,FontDataView:me,Fonts:es,get Glyf(){return Hi},Glyph:yn,GlyphSet:_n,get Gpos(){return En},get Gsub(){return Ot},get Head(){return ue},get Hhea(){return xe},get Hmtx(){return Yi},get Kern(){return Mn},get Loca(){return Ki},get Maxp(){return _e},get Name(){return br},get Os2(){return q},get Post(){return Ke},SFNT:mt,TTF:st,TableDirectory:yr,get Vhea(){return Pe},get Vmtx(){return Ji},WOFF:Qi,WOFFTableDirectoryEntry:sr,createCmapSegments:xn,dataTypeToByteLength:si,defineColumn:v,defineSFNTTable:we,fonts:Rl,parseFont:Il,parseSFNTFont:Dl},Symbol.toStringTag,{value:"Module"}));function kn(s,e,t){if(typeof e=="string"&&e.startsWith("linear-gradient")){const{x0:r,y0:i,x1:n,y1:o,stops:a}=tg(e,t.left,t.top,t.width,t.height),l=s.createLinearGradient(r,i,n,o);return a.forEach(c=>l.addColorStop(c.offset,c.color)),l}return e}function ts(s,e,t){s?.color&&(s.color=kn(t,s.color,e)),s?.backgroundColor&&(s.backgroundColor=kn(t,s.backgroundColor,e)),s?.textStrokeColor&&(s.textStrokeColor=kn(t,s.textStrokeColor,e))}function tg(s,e,t,r,i){const n=s.match(/linear-gradient\((.+)\)$/)?.[1]??"",o=n.split(",")[0],a=o.includes("deg")?o:"0deg",l=n.replace(a,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),h=(Number(a.replace("deg",""))||0)*Math.PI/180,f=r*Math.sin(h),d=i*Math.cos(h);return{x0:e+r/2-f,y0:t+i/2+d,x1:e+r/2+f,y1:t+i/2-d,stops:Array.from(l).map(g=>{let p=g[2];return p.startsWith("(")?p=p.split(",").length>3?`rgba${p}`:`rgb${p}`:p=`#${p}`,{offset:Number(g[3].replace("%",""))/100,color:p}})}}function wr(s){const{ctx:e,path:t,fontSize:r,clipRect:i}=s;e.save(),e.beginPath();const n=t.style,o={...n,fill:s.color??n.fill,stroke:s.textStrokeColor??n.stroke,strokeWidth:s.textStrokeWidth?s.textStrokeWidth*r:n.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",shadowOffsetX:(s.shadowOffsetX??0)*r,shadowOffsetY:(s.shadowOffsetY??0)*r,shadowBlur:(s.shadowBlur??0)*r,shadowColor:s.shadowColor};i&&(e.rect(i.left,i.top,i.width,i.height),e.clip(),e.beginPath()),t.drawTo(e,o),e.restore()}function rg(s,e,t){const{left:r,top:i,width:n,height:o}=t,a=s.canvas;a.dataset.viewBox=`${r} ${i} ${n} ${o}`,a.dataset.pixelRatio=String(e);const l=n,c=o;a.width=Math.max(1,Math.ceil(l*e)),a.height=Math.max(1,Math.ceil(c*e)),a.style.width=`${l}px`,a.style.height=`${c}px`,s.clearRect(0,0,a.width,a.height),s.scale(e,e),s.translate(-r,-i)}function ig(s,e){const{paragraphs:t,computedStyle:r,glyphBox:i}=e;ts(r,i,s),t.forEach(n=>{ts(n.computedStyle,n.lineBox,s),n.fragments.forEach(o=>{ts(o.computedStyle,o.inlineBox,s)})})}const sg=new Set(["©","®","÷"]),ng=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),og={1:"italic",32:"bold"},ag={1:"italic",2:"bold"},Ul={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class Bl{constructor(e,t,r){this.content=e,this.index=t,this.parent=r}path=new ge().setMeta(this);lineBox=new Z;inlineBox=new Z;glyphBox;advanceWidth=0;advanceHeight=0;underlinePosition=0;underlineThickness=0;strikeoutPosition=0;strikeoutSize=0;ascender=0;descender=0;typoAscender=0;typoDescender=0;typoLineGap=0;winAscent=0;winDescent=0;xHeight=0;capHeight=0;baseline=0;centerDiviation=0;fontStyle;get compatibleGlyphBox(){const e=this.computedStyle.fontSize*.8;return this.glyphBox??(this.isVertical?new Z(this.lineBox.left+this.lineBox.width/2-e/2,this.lineBox.top,e,this.lineBox.height):new Z(this.lineBox.left,this.lineBox.top+this.lineBox.height/2-e/2,this.lineBox.width,e))}get center(){return this.compatibleGlyphBox.center}get computedFill(){return this.parent.computedFill}get computedOutline(){return this.parent.computedOutline}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}_getFontSFNT(e){const t=this.computedStyle.fontFamily,r=e??Rl;let n=(t?r.get(t):r.fallbackFont)?.getSFNT();return n?.textToGlyphIndexes(this.content).includes(0)&&(n=r.fallbackFont?.getSFNT()),n}updateGlyph(e=this._getFontSFNT()){if(!e)return this;const{hhea:t,os2:r,post:i,head:n}=e,o=n.unitsPerEm,a=t.ascent,l=t.descent,{content:c,computedStyle:h,isVertical:f}=this,{fontSize:d}=h,g=o/d,p=e.getAdvanceWidth(c,d),y=(a+Math.abs(l))/g,m=a/g;return this.advanceWidth=p,this.advanceHeight=y,this.inlineBox.width=f?y:p,this.inlineBox.height=f?p:y,this.underlinePosition=(a-i.underlinePosition)/g,this.underlineThickness=i.underlineThickness/g,this.strikeoutPosition=(a-r.yStrikeoutPosition)/g,this.strikeoutSize=r.yStrikeoutSize/g,this.ascender=a/g,this.descender=l/g,this.typoAscender=r.sTypoAscender/g,this.typoDescender=r.sTypoDescender/g,this.typoLineGap=r.sTypoLineGap/g,this.winAscent=r.usWinAscent/g,this.winDescent=r.usWinDescent/g,this.xHeight=r.sxHeight/g,this.capHeight=r.sCapHeight/g,this.baseline=m,this.centerDiviation=y/2-m,this.fontStyle=og[r.fsSelection]??ag[n.macStyle],this}update(e){const t=this._getFontSFNT(e);if(!t)return this;this.updateGlyph(t);const{isVertical:r,content:i,computedStyle:n,baseline:o,inlineBox:a,ascender:l,descender:c,typoAscender:h,fontStyle:f,advanceWidth:d,advanceHeight:g}=this,{left:p,top:y}=a,m=n.fontStyle==="italic"&&f!=="italic";let P=p,E=y+o,x;const S=new ge().setMeta(this);if(r&&(P+=(g-d)/2,Math.abs(d-g)>.1&&(E-=(l-h)/(l+Math.abs(c))*g),x=void 0),r&&!sg.has(i)&&(i.codePointAt(0)<=256||ng.has(i))){S.addCommands(t.getPathCommands(i,P,y+o-(g-d)/2,n.fontSize));const b={y:y-(g-d)/2+g/2,x:P+d/2};m&&this._italic(S,r?{x:b.x,y:y-(g-d)/2+o}:void 0),S.rotate(90,b)}else x!==void 0?(S.addCommands(t.glyphs.get(x).getPathCommands(P,E,n.fontSize)),m&&this._italic(S,r?{x:P+d/2,y:y+h/(l+Math.abs(c))*g}:void 0)):(S.addCommands(t.getPathCommands(i,P,E,n.fontSize)),m&&this._italic(S,r?{x:P+g/2,y:E}:void 0));const _=n.fontWeight??400;return _ in Ul&&(_===700||_==="bold")&&f!=="bold"&&S.bold(Ul[_]*n.fontSize*.05),S.style={fill:this.computedFill??n.color,fillRule:"nonzero",stroke:this.computedOutline??(n.textStrokeWidth?n.textStrokeColor:"none"),strokeWidth:n.textStrokeWidth?n.textStrokeWidth*n.fontSize*.03:0},this.path=S,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(e,t){e.skew(-.24,0,t||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(e,t,r){if(this.path.curves[0]?.curves.length)return this.path.getMinMax(e,t,r)}getGlyphBoundingBox(e){const t=this.getGlyphMinMax(void 0,void 0,e);if(!t)return;const{min:r,max:i}=t;return new Z(r.x,r.y,i.x-r.x,i.y-r.y)}drawTo(e,t={}){const r=this.computedStyle,i={ctx:e,path:this.path,fontSize:r.fontSize,color:r.color,...t};if(this.glyphBox)wr(i);else{e.save(),e.beginPath();const n=this.path.style,o={...n,fill:i.color??n.fill,stroke:i.textStrokeColor??n.stroke,strokeWidth:i.textStrokeWidth?i.textStrokeWidth*i.fontSize:n.strokeWidth,shadowOffsetX:(i.shadowOffsetX??0)*i.fontSize,shadowOffsetY:(i.shadowOffsetY??0)*i.fontSize,shadowBlur:(i.shadowBlur??0)*i.fontSize,shadowColor:i.shadowColor};Ls(e,o),e.font=`${i.fontSize}px ${i.fontFamily}`,this.isVertical?(e.textBaseline="middle",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.inlineBox.height/2)):(e.textBaseline="alphabetic",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.baseline)),e.restore()}}}function Ll(){const s=new Map;async function e(r){if(!s.has(r)){s.set(r,r);try{s.set(r,await fetch(r).then(i=>i.text()))}catch(i){console.warn(i),s.delete(r)}}}function t(r){return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("blob://")}return{loaded:s,needsLoad:t,load:e}}function Nl(s){const e=new Map;function t(r){let i=e.get(r);if(!i){const n=Fs(s.needsLoad(r)?s.loaded.get(r)??r:r),o=zs(n);i={dom:n,pathSet:o},e.set(r,i)}return i}return{parsed:e,parse:t}}function Dn(s,e){return typeof s=="number"?s:s.endsWith("%")?(s=s.substring(0,s.length-1),Math.ceil(Number(s)/100*e.total)):s.endsWith("rem")?(s=s.substring(0,s.length-3),Number(s)*e.fontSize):s.endsWith("em")?(s=s.substring(0,s.length-2),Number(s)*e.fontSize):Number(s)}function In(s){return K(s)?{}:s}function lg(s,e){const t=Object.keys(s),r=Object.keys(e);return Array.from(new Set([...t,...r])).every(n=>xr(s[n],e[n]))}function xr(s,e){const t=typeof s;return t===typeof e?t==="object"?lg(s,e):s===e:!1}function Rn(s){if(!s)return s;const e={};for(const t in s)s[t]!==""&&s[t]!==void 0&&(e[t]=s[t]);return e}class cg{constructor(e,t={},r,i){this.content=e,this.style=t,this.index=r,this.parent=i,this.updateComputedStyle().initCharacters()}inlineBox=new Z;fill;outline;get computedFill(){return this.fill??this.parent.computedFill}get computedOutline(){return this.outline??this.parent.computedOutline}get computedContent(){const e=this.computedStyle;return e.textTransform==="uppercase"?this.content.toUpperCase():e.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,...Rn(this.style)},this}initCharacters(){const e=[];let t=0;for(const r of this.computedContent)e.push(new Bl(r,t++,this));return this.characters=e,this}}class hg{constructor(e,t,r){this.style=e,this.index=t,this.parent=r,this.updateComputedStyle()}lineBox=new Z;fragments=[];fill;outline;get computedFill(){return this.fill??this.parent.fill}get computedOutline(){return this.outline??this.parent.outline}updateComputedStyle(){return this.computedStyle={...Rn(this.parent.computedStyle),...Rn(this.style)},this}}function Lm(s){return s}class rs{static notZeroStyles=new Set(["width","height"]);static pxStyles=new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","margin","marginLeft","marginTop","marginRight","marginBottom","padding","paddingLeft","paddingTop","paddingRight","paddingBottom"]);_toDomStyle(e){const t={};for(const r in e){const i=e[r];rs.notZeroStyles.has(r)&&i===0||(typeof i=="number"&&rs.pxStyles.has(r)?t[r]=`${i}px`:t[r]=i)}return t}createDom(e,t){const r=document.createElement("section"),i={...t},n=t.writingMode.includes("horizontal");switch(t.textAlign){case"start":case"left":i.justifyContent="flex-start";break;case"center":i.justifyContent="center";break;case"end":case"right":i.justifyContent="flex-end";break}switch(t.verticalAlign){case"top":i.alignItems="flex-start";break;case"middle":i.alignItems="center";break;case"bottom":i.alignItems="flex-end";break}const o=!!(i.justifyContent||i.alignItems);Object.assign(r.style,{...this._toDomStyle({...i,boxSizing:i.boxSizing??"border-box",display:i.display??(o?"inline-flex":void 0),width:i.width??"max-content",height:i.height??"max-content"}),whiteSpace:"pre-wrap",wordBreak:"break-all"});const a=document.createElement("ul");return Object.assign(a.style,{verticalAlign:"inherit",listStyleType:"inherit",padding:"0",margin:"0",width:o&&n?"100%":void 0,height:o&&!n?"100%":void 0}),e.forEach(l=>{const c=document.createElement("li");Object.assign(c.style,{verticalAlign:"inherit",...this._toDomStyle(l.style)}),l.fragments.forEach(h=>{const f=document.createElement("span");Object.assign(f.style,{verticalAlign:"inherit",...this._toDomStyle(h.style)}),f.appendChild(document.createTextNode(h.content)),c.appendChild(f)}),a.appendChild(c)}),r.appendChild(a),r}measureDomText(e){const t=document.createRange();t.selectNodeContents(e);const r=e.data??"";let i=0;return Array.from(r).map(n=>{const o=i+=r.substring(i).indexOf(n),a=o+n.length;i+=n.length,t.setStart(e,Math.max(o,0)),t.setEnd(e,a);const l=t.getClientRects?.()??[t.getBoundingClientRect()];let c=l[l.length-1];l.length>1&&c.width<2&&(c=l[l.length-2]);const h=t.toString();if(h!==""&&c&&c.width+c.height!==0)return{content:h,top:c.top,left:c.left,height:c.height,width:c.width}}).filter(Boolean)}measureDom(e){const t=[],r=[],i=[];return e.querySelectorAll("li").forEach((n,o)=>{const a=n.getBoundingClientRect();t.push({paragraphIndex:o,left:a.left,top:a.top,width:a.width,height:a.height}),n.querySelectorAll(":scope > *").forEach((l,c)=>{const h=l.getBoundingClientRect();r.push({paragraphIndex:o,fragmentIndex:c,left:h.left,top:h.top,width:h.width,height:h.height});let f=0;!l.children.length&&l.firstChild instanceof window.Text?this.measureDomText(l.firstChild).forEach(d=>{i.push({...d,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:c,characterIndex:f++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(d=>{d.firstChild instanceof window.Text&&this.measureDomText(d.firstChild).forEach(g=>{i.push({...g,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:c,characterIndex:f++,textWidth:-1,textHeight:-1})})})})}),{paragraphs:t,fragments:r,characters:i}}measureParagraphDom(e,t){const r=t.getBoundingClientRect(),i=this.measureDom(t);i.paragraphs.forEach(a=>{const l=e[a.paragraphIndex];l.lineBox.left=a.left-r.left,l.lineBox.top=a.top-r.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),i.fragments.forEach(a=>{const l=e[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-r.left,l.inlineBox.top=a.top-r.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const n=[];let o=0;return i.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:c,characterIndex:h}=a;n.push({...a,newParagraphIndex:l,left:a.left-r.left,top:a.top-r.top});const f=e[l].fragments[c].characters[h],{fontHeight:d,isVertical:g}=f,p=n[o];f.inlineBox.left=p.left,f.inlineBox.top=p.top,f.inlineBox.width=p.width,f.inlineBox.height=p.height,g?(f.lineBox.left=p.left+(p.width-d)/2,f.lineBox.top=p.top,f.lineBox.width=d,f.lineBox.height=p.height):(f.lineBox.left=p.left,f.lineBox.top=p.top+(p.height-d)/2,f.lineBox.width=p.width,f.lineBox.height=d),o++}),{paragraphs:e,boundingBox:new Z(0,0,r.width,r.height)}}measure(e,t,r){let i;r||(r=this.createDom(e,t),Object.assign(r.style,{position:"fixed",visibility:"hidden"}),document.body.appendChild(r),i=()=>r?.parentNode?.removeChild(r));const n=this.measureParagraphDom(e,r);return i?.(),n}}function ug(){const s=new Tt,e=Ll(),t=Nl(e);return{name:"background",pathSet:s,load:async r=>{const{backgroundImage:i}=r.computedStyle;i&&e.needsLoad(i)&&await e.load(i)},update:r=>{s.paths.length=0;const{computedStyle:i,lineBox:n,isVertical:o}=r,{backgroundImage:a,backgroundSize:l,backgroundColormap:c}=i;if(K(a))return;const{pathSet:h}=t.parse(a),f=h.getBoundingBox(!0);let d,g,p,y;o?{x:g,y:d,width:y,height:p}=n:{x:d,y:g,width:p,height:y}=n;const m=In(c??"none"),P=h.paths.map(_=>{const b=_.clone();return b.style.fill&&b.style.fill in m&&(b.style.fill=m[b.style.fill]),b.style.stroke&&b.style.stroke in m&&(b.style.stroke=m[b.style.stroke]),b});let E,x;if(l==="rigid"){E=Math.max(r.fontSize*5/f.width),x=E;const _=new k;_.x=f.width-p/E,_.y=f.height-y/x,P.forEach(b=>{b.applyTransform(C=>{const T=C.x>f.left+f.width/2,B=C.y>f.top+f.height/2;T&&(C.x-=_.x),B&&(C.y-=_.y)})})}else E=p/f.width,x=y/f.height;const S=new be;S.translate(-f.x,-f.y),S.scale(E,x),o&&(S.translate(-p/2,-y/2),S.rotate(-Math.PI/2),S.translate(y/2,p/2)),S.translate(d,g),P.forEach(_=>{_.applyTransform(b=>{b.applyMatrix3(S)})}),s.paths.push(...P)},renderOrder:-2,render:(r,i)=>{const{boundingBox:n,computedStyle:o}=i;K(o.backgroundColor)||(r.fillStyle=o.backgroundColor,r.fillRect(...n.array)),s.paths.forEach(a=>{if(wr({ctx:r,path:a,fontSize:o.fontSize}),i.debug){const l=new Tt([a]).getBoundingBox();l&&r.strokeRect(l.x,l.y,l.width,l.height)}}),i.paragraphs.forEach(a=>{const{lineBox:l,style:c}=a;K(c.backgroundColor)||(r.fillStyle=c.backgroundColor,r.fillRect(...l.array)),a.fragments.forEach(h=>{const{inlineBox:f,style:d}=h;K(d.backgroundColor)||(r.fillStyle=d.backgroundColor,r.fillRect(...f.array))})})}}}function Un(s){const{highlight:e,highlightImage:t,highlightReferImage:r,highlightColormap:i,highlightLine:n,highlightSize:o,highlightThickness:a}=s;return{image:e?.image??t??"none",referImage:e?.referImage??r??"none",colormap:e?.colormap??i??"none",line:e?.line??n??"none",size:e?.size??o??"cover",thickness:e?.thickness??a??"100%"}}function fg(){const s=new Tt,e=[],t=Ll(),r=Nl(t);return{name:"highlight",pathSet:s,load:async i=>{const n=new Set;i.forEachCharacter(o=>{const{computedStyle:a}=o,{image:l,referImage:c}=Un(a);l&&t.needsLoad(l)&&n.add(l),c&&t.needsLoad(c)&&n.add(c)}),await Promise.all(Array.from(n).map(o=>t.load(o)))},update:i=>{e.length=0,s.paths.length=0;let n=[],o,a;i.forEachCharacter(l=>{const{computedStyle:c}=l,h=Un(c),{image:f,colormap:d,line:g,size:p,thickness:y}=h;if(K(f))o?.length&&(o=[],n.push(o));else{const{inlineBox:m,isVertical:P}=l,{fontSize:E}=c;(!a||xr(a.image,f)&&xr(a.colormap,d)&&xr(a.line,g)&&xr(a.size,p)&&xr(a.thickness,y))&&o?.length&&(P?o[0].inlineBox.left===m.left:o[0].inlineBox.top===m.top)&&o[0].fontSize===E?o.push(l):(o=[],o.push(l),n.push(o))}a=h}),n=n.filter(l=>l.length);for(let l=0;l<n.length;l++){const c=n[l],h=c[0],f=Z.from(...c.map(O=>O.compatibleGlyphBox));if(!f.height||!f.width)continue;const{computedStyle:d,isVertical:g,inlineBox:p,compatibleGlyphBox:y,strikeoutPosition:m,underlinePosition:P}=h,{fontSize:E}=d,{image:x,referImage:S,colormap:_,line:b,size:C,thickness:T}=Un(d),B=Dn(T,{fontSize:E,total:f.width})/f.width,G=In(_),{pathSet:R,dom:U}=r.parse(x),V=R.getBoundingBox(!0),L=E/V.width*2,D=new Z().copy(f);g&&(D.width=f.height,D.height=f.width,D.left=f.left+f.width);const H=Math.floor(D.width);let I=H;C!=="cover"&&(I=Dn(C,{fontSize:E,total:f.width})||H,D.width=I);const N=!K(S)&&K(b);if(N)V.copy(r.parse(S).pathSet.getBoundingBox(!0));else{let O;if(K(b))if(V.width/V.height>4){O="underline";const j=U.getAttribute("viewBox");if(j){const[A,M,F,z]=j.split(" ").map(J=>Number(J)),Y=M+z/2;V.y<Y&&V.y+V.height>Y?O="line-through":V.y+V.height<Y?O="overline":O="underline"}}else O="outline";else O=b;switch(O){case"outline":{const j=D.width*.2,A=D.height*.2;g?(D.x-=A/2,D.y-=j/2,D.x-=D.height):(D.x-=j/2,D.y-=A/2),D.width+=j,D.height+=A;break}case"overline":D.height=V.height*L,g?D.x=p.left+p.width:D.y=p.top;break;case"line-through":D.height=V.height*L,g?D.x=p.left+p.width-m+D.height/2:D.y=p.top+m-D.height/2;break;case"underline":D.height=V.height*L,g?D.x=y.left+y.width-P:D.y=p.top+P;break}}const $=new be;if($.translate(-V.x,-V.y),$.scale(D.width/V.width,D.height/V.height),g){const O=D.width/2,j=D.height/2;N||$.translate(-O,-j),$.rotate(-Math.PI/2),N||$.translate(j,O)}$.translate(D.x,D.y);for(let O=0;O<Math.ceil(H/I);O++){const j=$.clone();g?j.translate(0,O*D.width):j.translate(O*D.width,0),R.paths.forEach(A=>{const M=A.clone().applyTransform(j);M.style.strokeWidth&&(M.style.strokeWidth*=L*B),M.style.strokeMiterlimit&&(M.style.strokeMiterlimit*=L),M.style.strokeDashoffset&&(M.style.strokeDashoffset*=L),M.style.strokeDasharray&&(M.style.strokeDasharray=M.style.strokeDasharray.map(F=>F*L)),M.style.fill&&M.style.fill in G&&(M.style.fill=G[M.style.fill]),M.style.stroke&&M.style.stroke in G&&(M.style.stroke=G[M.style.stroke]),s.paths.push(M),H!==I&&(g?e[s.paths.length-1]=new Z(f.left-f.width*2,f.top,f.width*4,f.height):e[s.paths.length-1]=new Z(f.left,f.top-f.height*2,f.width,f.height*4))})}}},renderOrder:-1,getBoundingBox:()=>{const i=[];return s.paths.forEach((n,o)=>{const a=e[o];let l=n.getBoundingBox();if(a){const c=Math.max(l.x,a.x),h=Math.max(l.y,a.y),f=Math.min(l.right,a.right),d=Math.min(l.bottom,a.bottom);l=new Z(c,h,f-c,d-h)}i.push(l)}),Z.from(...i)},render:(i,n)=>{s.paths.forEach((o,a)=>{if(wr({ctx:i,path:o,fontSize:n.computedStyle.fontSize,clipRect:e[a]}),n.debug){const l=new Tt([o]).getBoundingBox();l&&i.strokeRect(l.x,l.y,l.width,l.height)}})}}}function dg(s,e){return`<svg width="${s*2}" height="${s*2}" xmlns="http://www.w3.org/2000/svg">
865
+ }`)),document.head.appendChild(r),this}_parseUrls(e){const t=Array.from(new Set([...e.split(","),e]));return Array.from(new Set(t.map(r=>this.familyToUrl.get(r.trim())??this.familyToUrl.get(r)??r)))}get(e){let t;return e&&(t=this._parseUrls(e).reduce((i,n)=>i||this.loaded.get(n),void 0)),t??this.fallbackFont}set(e,t){return this.familyToUrl.set(e,t.src),this.loaded.set(t.src,t),this}delete(e){return this._parseUrls(e).forEach(t=>{this.familyToUrl.delete(t),this.loaded.delete(t)}),this}clear(){return this.familyToUrl.clear(),this.loading.clear(),this.loaded.clear(),this}async load(e,t={}){const{cancelOther:r,injectFontFace:i=!0,injectStyleTag:n=!0,...o}=t;let a,l;if(typeof e=="string"?a=e:{src:a,family:l}=e,this.loaded.has(a))return r&&(this.loading.forEach(g=>g.cancel()),this.loading.clear()),f(this.loaded.get(a));let c=this.loading.get(a);return c||(c=this._createRequest(a,o),this.loading.set(a,c)),r&&this.loading.forEach((g,p)=>{g!==c&&(g.cancel(),this.loading.delete(p))}),c.when.then(g=>{if(this.loaded.has(a))return f(this.loaded.get(a));{const p=d(g);return t.noAdd||this.loaded.set(a,p),p.familySet.forEach(y=>{this.familyToUrl.set(y,a),typeof document<"u"&&(i&&this.injectFontFace(y,g),n&&this.injectStyleTag(y,a))}),p}}).catch(g=>{if(g instanceof DOMException&&g.message==="The user aborted a request.")return d();throw g}).finally(()=>{this.loading.delete(a)});function h(){return l?Array.isArray(l)?l:[l]:[]}function f(g){return h().forEach(p=>{g.familySet.add(p)}),g}function d(g=new ArrayBuffer(0)){let p;function y(){return p||(p=g.byteLength?Il(g,!1):void 0),p}function m(){const P=y();if(P instanceof st||P instanceof Qi)return P.sfnt}return{src:a,family:l,buffer:g,familySet:new Set(h()),getFont:y,getSFNT:m}}}async waitUntilLoad(){await Promise.all(Array.from(this.loading.values()).map(e=>e.when))}}const Rl=new es,eg=Object.freeze(Object.defineProperty({__proto__:null,BaseFont:zi,get Cff(){return er},get Cmap(){return vr},CmapSubtableFormat0:bn,CmapSubtableFormat12:Sn,CmapSubtableFormat14:hi,CmapSubtableFormat2:ai,CmapSubtableFormat4:Pn,CmapSubtableFormat6:rr,FontDataObject:qe,FontDataView:me,Fonts:es,get Glyf(){return Hi},Glyph:yn,GlyphSet:_n,get Gpos(){return En},get Gsub(){return Ot},get Head(){return ue},get Hhea(){return xe},get Hmtx(){return Yi},get Kern(){return Mn},get Loca(){return Ki},get Maxp(){return _e},get Name(){return br},get Os2(){return q},get Post(){return Ke},SFNT:yt,TTF:st,TableDirectory:yr,get Vhea(){return Pe},get Vmtx(){return Ji},WOFF:Qi,WOFFTableDirectoryEntry:sr,createCmapSegments:xn,dataTypeToByteLength:si,defineColumn:v,defineSFNTTable:we,fonts:Rl,parseFont:Il,parseSFNTFont:Dl},Symbol.toStringTag,{value:"Module"}));function kn(s,e,t){if(typeof e=="string"&&e.startsWith("linear-gradient")){const{x0:r,y0:i,x1:n,y1:o,stops:a}=tg(e,t.left,t.top,t.width,t.height),l=s.createLinearGradient(r,i,n,o);return a.forEach(c=>l.addColorStop(c.offset,c.color)),l}return e}function ts(s,e,t){s?.color&&(s.color=kn(t,s.color,e)),s?.backgroundColor&&(s.backgroundColor=kn(t,s.backgroundColor,e)),s?.textStrokeColor&&(s.textStrokeColor=kn(t,s.textStrokeColor,e))}function tg(s,e,t,r,i){const n=s.match(/linear-gradient\((.+)\)$/)?.[1]??"",o=n.split(",")[0],a=o.includes("deg")?o:"0deg",l=n.replace(a,"").matchAll(/(#|rgba|rgb)(.+?) ([\d.]+%)/gi),h=(Number(a.replace("deg",""))||0)*Math.PI/180,f=r*Math.sin(h),d=i*Math.cos(h);return{x0:e+r/2-f,y0:t+i/2+d,x1:e+r/2+f,y1:t+i/2-d,stops:Array.from(l).map(g=>{let p=g[2];return p.startsWith("(")?p=p.split(",").length>3?`rgba${p}`:`rgb${p}`:p=`#${p}`,{offset:Number(g[3].replace("%",""))/100,color:p}})}}function wr(s){const{ctx:e,path:t,fontSize:r,clipRect:i}=s;e.save(),e.beginPath();const n=t.style,o={...n,fill:s.color??n.fill,stroke:s.textStrokeColor??n.stroke,strokeWidth:s.textStrokeWidth?s.textStrokeWidth*r:n.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",shadowOffsetX:(s.shadowOffsetX??0)*r,shadowOffsetY:(s.shadowOffsetY??0)*r,shadowBlur:(s.shadowBlur??0)*r,shadowColor:s.shadowColor};i&&(e.rect(i.left,i.top,i.width,i.height),e.clip(),e.beginPath()),t.drawTo(e,o),e.restore()}function rg(s,e,t){const{left:r,top:i,width:n,height:o}=t,a=s.canvas;a.dataset.viewBox=`${r} ${i} ${n} ${o}`,a.dataset.pixelRatio=String(e);const l=n,c=o;a.width=Math.max(1,Math.ceil(l*e)),a.height=Math.max(1,Math.ceil(c*e)),a.style.width=`${l}px`,a.style.height=`${c}px`,s.clearRect(0,0,a.width,a.height),s.scale(e,e),s.translate(-r,-i)}function ig(s,e){const{paragraphs:t,computedStyle:r,glyphBox:i}=e;ts(r,i,s),t.forEach(n=>{ts(n.computedStyle,n.lineBox,s),n.fragments.forEach(o=>{ts(o.computedStyle,o.inlineBox,s)})})}const sg=new Set(["©","®","÷"]),ng=new Set(["—","…","“","”","﹏","﹋","﹌","‘","’","˜"]),og={1:"italic",32:"bold"},ag={1:"italic",2:"bold"},Ul={100:-.2,200:-.1,300:0,400:0,normal:0,500:.1,600:.2,700:.3,bold:.3,800:.4,900:.5};class Bl{constructor(e,t,r){this.content=e,this.index=t,this.parent=r}path=new ge().setMeta(this);lineBox=new Z;inlineBox=new Z;glyphBox;advanceWidth=0;advanceHeight=0;underlinePosition=0;underlineThickness=0;strikeoutPosition=0;strikeoutSize=0;ascender=0;descender=0;typoAscender=0;typoDescender=0;typoLineGap=0;winAscent=0;winDescent=0;xHeight=0;capHeight=0;baseline=0;centerDiviation=0;fontStyle;get compatibleGlyphBox(){const e=this.computedStyle.fontSize*.8;return this.glyphBox??(this.isVertical?new Z(this.lineBox.left+this.lineBox.width/2-e/2,this.lineBox.top,e,this.lineBox.height):new Z(this.lineBox.left,this.lineBox.top+this.lineBox.height/2-e/2,this.lineBox.width,e))}get center(){return this.compatibleGlyphBox.center}get computedFill(){return this.parent.computedFill}get computedOutline(){return this.parent.computedOutline}get computedStyle(){return this.parent.computedStyle}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get fontSize(){return this.computedStyle.fontSize}get fontHeight(){return this.fontSize*this.computedStyle.lineHeight}_getFontSFNT(e){const t=this.computedStyle.fontFamily,r=e??Rl;let n=(t?r.get(t):r.fallbackFont)?.getSFNT();return n?.textToGlyphIndexes(this.content).includes(0)&&(n=r.fallbackFont?.getSFNT()),n}updateGlyph(e=this._getFontSFNT()){if(!e)return this;const{hhea:t,os2:r,post:i,head:n}=e,o=n.unitsPerEm,a=t.ascent,l=t.descent,{content:c,computedStyle:h,isVertical:f}=this,{fontSize:d}=h,g=o/d,p=e.getAdvanceWidth(c,d),y=(a+Math.abs(l))/g,m=a/g;return this.advanceWidth=p,this.advanceHeight=y,this.inlineBox.width=f?y:p,this.inlineBox.height=f?p:y,this.underlinePosition=(a-i.underlinePosition)/g,this.underlineThickness=i.underlineThickness/g,this.strikeoutPosition=(a-r.yStrikeoutPosition)/g,this.strikeoutSize=r.yStrikeoutSize/g,this.ascender=a/g,this.descender=l/g,this.typoAscender=r.sTypoAscender/g,this.typoDescender=r.sTypoDescender/g,this.typoLineGap=r.sTypoLineGap/g,this.winAscent=r.usWinAscent/g,this.winDescent=r.usWinDescent/g,this.xHeight=r.sxHeight/g,this.capHeight=r.sCapHeight/g,this.baseline=m,this.centerDiviation=y/2-m,this.fontStyle=og[r.fsSelection]??ag[n.macStyle],this}update(e){const t=this._getFontSFNT(e);if(!t)return this;this.updateGlyph(t);const{isVertical:r,content:i,computedStyle:n,baseline:o,inlineBox:a,ascender:l,descender:c,typoAscender:h,fontStyle:f,advanceWidth:d,advanceHeight:g}=this,{left:p,top:y}=a,m=n.fontStyle==="italic"&&f!=="italic";let P=p,E=y+o,x;const S=new ge().setMeta(this);if(r&&(P+=(g-d)/2,Math.abs(d-g)>.1&&(E-=(l-h)/(l+Math.abs(c))*g),x=void 0),r&&!sg.has(i)&&(i.codePointAt(0)<=256||ng.has(i))){S.addCommands(t.getPathCommands(i,P,y+o-(g-d)/2,n.fontSize));const b={y:y-(g-d)/2+g/2,x:P+d/2};m&&this._italic(S,r?{x:b.x,y:y-(g-d)/2+o}:void 0),S.rotate(90,b)}else x!==void 0?(S.addCommands(t.glyphs.get(x).getPathCommands(P,E,n.fontSize)),m&&this._italic(S,r?{x:P+d/2,y:y+h/(l+Math.abs(c))*g}:void 0)):(S.addCommands(t.getPathCommands(i,P,E,n.fontSize)),m&&this._italic(S,r?{x:P+g/2,y:E}:void 0));const _=n.fontWeight??400;return _ in Ul&&(_===700||_==="bold")&&f!=="bold"&&S.bold(Ul[_]*n.fontSize*.05),S.style={fill:this.computedFill??n.color,fillRule:"nonzero",stroke:this.computedOutline??(n.textStrokeWidth?n.textStrokeColor:"none"),strokeWidth:n.textStrokeWidth?n.textStrokeWidth*n.fontSize*.03:0},this.path=S,this.glyphBox=this.getGlyphBoundingBox(),this}_italic(e,t){e.skew(-.24,0,t||{y:this.inlineBox.top+this.baseline,x:this.inlineBox.left+this.inlineBox.width/2})}getGlyphMinMax(e,t,r){if(this.path.curves[0]?.curves.length)return this.path.getMinMax(e,t,r)}getGlyphBoundingBox(e){const t=this.getGlyphMinMax(void 0,void 0,e);if(!t)return;const{min:r,max:i}=t;return new Z(r.x,r.y,i.x-r.x,i.y-r.y)}drawTo(e,t={}){const r=this.computedStyle,i={ctx:e,path:this.path,fontSize:r.fontSize,color:r.color,...t};if(this.glyphBox)wr(i);else{e.save(),e.beginPath();const n=this.path.style,o={...n,fill:i.color??n.fill,stroke:i.textStrokeColor??n.stroke,strokeWidth:i.textStrokeWidth?i.textStrokeWidth*i.fontSize:n.strokeWidth,shadowOffsetX:(i.shadowOffsetX??0)*i.fontSize,shadowOffsetY:(i.shadowOffsetY??0)*i.fontSize,shadowBlur:(i.shadowBlur??0)*i.fontSize,shadowColor:i.shadowColor};Ls(e,o),e.font=`${i.fontSize}px ${i.fontFamily}`,this.isVertical?(e.textBaseline="middle",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.inlineBox.height/2)):(e.textBaseline="alphabetic",e.fillText(this.content,this.inlineBox.left,this.inlineBox.top+this.baseline)),e.restore()}}}function Ll(){const s=new Map;async function e(r){if(!s.has(r)){s.set(r,r);try{s.set(r,await fetch(r).then(i=>i.text()))}catch(i){console.warn(i),s.delete(r)}}}function t(r){return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("blob://")}return{loaded:s,needsLoad:t,load:e}}function Nl(s){const e=new Map;function t(r){let i=e.get(r);if(!i){const n=Fs(s.needsLoad(r)?s.loaded.get(r)??r:r),o=zs(n);i={dom:n,pathSet:o},e.set(r,i)}return i}return{parsed:e,parse:t}}function Dn(s,e){return typeof s=="number"?s:s.endsWith("%")?(s=s.substring(0,s.length-1),Math.ceil(Number(s)/100*e.total)):s.endsWith("rem")?(s=s.substring(0,s.length-3),Number(s)*e.fontSize):s.endsWith("em")?(s=s.substring(0,s.length-2),Number(s)*e.fontSize):Number(s)}function In(s){return K(s)?{}:s}function lg(s,e){const t=Object.keys(s),r=Object.keys(e);return Array.from(new Set([...t,...r])).every(n=>xr(s[n],e[n]))}function xr(s,e){const t=typeof s;return t===typeof e?t==="object"?lg(s,e):s===e:!1}function Rn(s){if(!s)return s;const e={};for(const t in s)s[t]!==""&&s[t]!==void 0&&(e[t]=s[t]);return e}class cg{constructor(e,t={},r,i){this.content=e,this.style=t,this.index=r,this.parent=i,this.updateComputedStyle().initCharacters()}inlineBox=new Z;fill;outline;get computedFill(){return this.fill??this.parent.computedFill}get computedOutline(){return this.outline??this.parent.computedOutline}get computedContent(){const e=this.computedStyle;return e.textTransform==="uppercase"?this.content.toUpperCase():e.textTransform==="lowercase"?this.content.toLowerCase():this.content}updateComputedStyle(){return this.computedStyle={...this.parent.computedStyle,...Rn(this.style)},this}initCharacters(){const e=[];let t=0;for(const r of this.computedContent)e.push(new Bl(r,t++,this));return this.characters=e,this}}class hg{constructor(e,t,r){this.style=e,this.index=t,this.parent=r,this.updateComputedStyle()}lineBox=new Z;fragments=[];fill;outline;get computedFill(){return this.fill??this.parent.fill}get computedOutline(){return this.outline??this.parent.outline}updateComputedStyle(){return this.computedStyle={...Rn(this.parent.computedStyle),...Rn(this.style)},this}}function Lm(s){return s}class rs{static notZeroStyles=new Set(["width","height"]);static pxStyles=new Set(["width","height","fontSize","letterSpacing","textStrokeWidth","textIndent","shadowOffsetX","shadowOffsetY","shadowBlur","margin","marginLeft","marginTop","marginRight","marginBottom","padding","paddingLeft","paddingTop","paddingRight","paddingBottom"]);_toDomStyle(e){const t={};for(const r in e){const i=e[r];rs.notZeroStyles.has(r)&&i===0||(typeof i=="number"&&rs.pxStyles.has(r)?t[r]=`${i}px`:t[r]=i)}return t}createDom(e,t){const r=document.createElement("section"),i={...t},n=t.writingMode.includes("horizontal");switch(t.textAlign){case"start":case"left":i.justifyContent="flex-start";break;case"center":i.justifyContent="center";break;case"end":case"right":i.justifyContent="flex-end";break}switch(t.verticalAlign){case"top":i.alignItems="flex-start";break;case"middle":i.alignItems="center";break;case"bottom":i.alignItems="flex-end";break}const o=!!(i.justifyContent||i.alignItems);Object.assign(r.style,{...this._toDomStyle({...i,boxSizing:i.boxSizing??"border-box",display:i.display??(o?"inline-flex":void 0),width:i.width??"max-content",height:i.height??"max-content"}),whiteSpace:"pre-wrap",wordBreak:"break-all"});const a=document.createElement("ul");return Object.assign(a.style,{verticalAlign:"inherit",listStyleType:"inherit",padding:"0",margin:"0",width:o&&n?"100%":void 0,height:o&&!n?"100%":void 0}),e.forEach(l=>{const c=document.createElement("li");Object.assign(c.style,{verticalAlign:"inherit",...this._toDomStyle(l.style)}),l.fragments.forEach(h=>{const f=document.createElement("span");Object.assign(f.style,{verticalAlign:"inherit",...this._toDomStyle(h.style)}),f.appendChild(document.createTextNode(h.content)),c.appendChild(f)}),a.appendChild(c)}),r.appendChild(a),r}measureDomText(e){const t=document.createRange();t.selectNodeContents(e);const r=e.data??"";let i=0;return Array.from(r).map(n=>{const o=i+=r.substring(i).indexOf(n),a=o+n.length;i+=n.length,t.setStart(e,Math.max(o,0)),t.setEnd(e,a);const l=t.getClientRects?.()??[t.getBoundingClientRect()];let c=l[l.length-1];l.length>1&&c.width<2&&(c=l[l.length-2]);const h=t.toString();if(h!==""&&c&&c.width+c.height!==0)return{content:h,top:c.top,left:c.left,height:c.height,width:c.width}}).filter(Boolean)}measureDom(e){const t=[],r=[],i=[];return e.querySelectorAll("li").forEach((n,o)=>{const a=n.getBoundingClientRect();t.push({paragraphIndex:o,left:a.left,top:a.top,width:a.width,height:a.height}),n.querySelectorAll(":scope > *").forEach((l,c)=>{const h=l.getBoundingClientRect();r.push({paragraphIndex:o,fragmentIndex:c,left:h.left,top:h.top,width:h.width,height:h.height});let f=0;!l.children.length&&l.firstChild instanceof window.Text?this.measureDomText(l.firstChild).forEach(d=>{i.push({...d,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:c,characterIndex:f++,textWidth:-1,textHeight:-1})}):l.querySelectorAll(":scope > *").forEach(d=>{d.firstChild instanceof window.Text&&this.measureDomText(d.firstChild).forEach(g=>{i.push({...g,newParagraphIndex:-1,paragraphIndex:o,fragmentIndex:c,characterIndex:f++,textWidth:-1,textHeight:-1})})})})}),{paragraphs:t,fragments:r,characters:i}}measureParagraphDom(e,t){const r=t.getBoundingClientRect(),i=this.measureDom(t);i.paragraphs.forEach(a=>{const l=e[a.paragraphIndex];l.lineBox.left=a.left-r.left,l.lineBox.top=a.top-r.top,l.lineBox.width=a.width,l.lineBox.height=a.height}),i.fragments.forEach(a=>{const l=e[a.paragraphIndex].fragments[a.fragmentIndex];l.inlineBox.left=a.left-r.left,l.inlineBox.top=a.top-r.top,l.inlineBox.width=a.width,l.inlineBox.height=a.height});const n=[];let o=0;return i.characters.forEach(a=>{const{paragraphIndex:l,fragmentIndex:c,characterIndex:h}=a;n.push({...a,newParagraphIndex:l,left:a.left-r.left,top:a.top-r.top});const f=e[l].fragments[c].characters[h],{fontHeight:d,isVertical:g}=f,p=n[o];f.inlineBox.left=p.left,f.inlineBox.top=p.top,f.inlineBox.width=p.width,f.inlineBox.height=p.height,g?(f.lineBox.left=p.left+(p.width-d)/2,f.lineBox.top=p.top,f.lineBox.width=d,f.lineBox.height=p.height):(f.lineBox.left=p.left,f.lineBox.top=p.top+(p.height-d)/2,f.lineBox.width=p.width,f.lineBox.height=d),o++}),{paragraphs:e,boundingBox:new Z(0,0,r.width,r.height)}}measure(e,t,r){let i;r||(r=this.createDom(e,t),Object.assign(r.style,{position:"fixed",visibility:"hidden"}),document.body.appendChild(r),i=()=>r?.parentNode?.removeChild(r));const n=this.measureParagraphDom(e,r);return i?.(),n}}function ug(){const s=new Tt,e=Ll(),t=Nl(e);return{name:"background",pathSet:s,load:async r=>{const{backgroundImage:i}=r.computedStyle;i&&e.needsLoad(i)&&await e.load(i)},update:r=>{s.paths.length=0;const{computedStyle:i,lineBox:n,isVertical:o}=r,{backgroundImage:a,backgroundSize:l,backgroundColormap:c}=i;if(K(a))return;const{pathSet:h}=t.parse(a),f=h.getBoundingBox(!0);let d,g,p,y;o?{x:g,y:d,width:y,height:p}=n:{x:d,y:g,width:p,height:y}=n;const m=In(c??"none"),P=h.paths.map(_=>{const b=_.clone();return b.style.fill&&b.style.fill in m&&(b.style.fill=m[b.style.fill]),b.style.stroke&&b.style.stroke in m&&(b.style.stroke=m[b.style.stroke]),b});let E,x;if(l==="rigid"){E=Math.max(r.fontSize*5/f.width),x=E;const _=new k;_.x=f.width-p/E,_.y=f.height-y/x,P.forEach(b=>{b.applyTransform(C=>{const T=C.x>f.left+f.width/2,B=C.y>f.top+f.height/2;T&&(C.x-=_.x),B&&(C.y-=_.y)})})}else E=p/f.width,x=y/f.height;const S=new be;S.translate(-f.x,-f.y),S.scale(E,x),o&&(S.translate(-p/2,-y/2),S.rotate(-Math.PI/2),S.translate(y/2,p/2)),S.translate(d,g),P.forEach(_=>{_.applyTransform(b=>{b.applyMatrix3(S)})}),s.paths.push(...P)},renderOrder:-2,render:(r,i)=>{const{boundingBox:n,computedStyle:o}=i;K(o.backgroundColor)||(r.fillStyle=o.backgroundColor,r.fillRect(...n.array)),s.paths.forEach(a=>{if(wr({ctx:r,path:a,fontSize:o.fontSize}),i.debug){const l=new Tt([a]).getBoundingBox();l&&r.strokeRect(l.x,l.y,l.width,l.height)}}),i.paragraphs.forEach(a=>{const{lineBox:l,style:c}=a;K(c.backgroundColor)||(r.fillStyle=c.backgroundColor,r.fillRect(...l.array)),a.fragments.forEach(h=>{const{inlineBox:f,style:d}=h;K(d.backgroundColor)||(r.fillStyle=d.backgroundColor,r.fillRect(...f.array))})})}}}function Un(s){const{highlight:e,highlightImage:t,highlightReferImage:r,highlightColormap:i,highlightLine:n,highlightSize:o,highlightThickness:a}=s;return{image:e?.image??t??"none",referImage:e?.referImage??r??"none",colormap:e?.colormap??i??"none",line:e?.line??n??"none",size:e?.size??o??"cover",thickness:e?.thickness??a??"100%"}}function fg(){const s=new Tt,e=[],t=Ll(),r=Nl(t);return{name:"highlight",pathSet:s,load:async i=>{const n=new Set;i.forEachCharacter(o=>{const{computedStyle:a}=o,{image:l,referImage:c}=Un(a);l&&t.needsLoad(l)&&n.add(l),c&&t.needsLoad(c)&&n.add(c)}),await Promise.all(Array.from(n).map(o=>t.load(o)))},update:i=>{e.length=0,s.paths.length=0;let n=[],o,a;i.forEachCharacter(l=>{const{computedStyle:c}=l,h=Un(c),{image:f,colormap:d,line:g,size:p,thickness:y}=h;if(K(f))o?.length&&(o=[],n.push(o));else{const{inlineBox:m,isVertical:P}=l,{fontSize:E}=c;(!a||xr(a.image,f)&&xr(a.colormap,d)&&xr(a.line,g)&&xr(a.size,p)&&xr(a.thickness,y))&&o?.length&&(P?o[0].inlineBox.left===m.left:o[0].inlineBox.top===m.top)&&o[0].fontSize===E?o.push(l):(o=[],o.push(l),n.push(o))}a=h}),n=n.filter(l=>l.length);for(let l=0;l<n.length;l++){const c=n[l],h=c[0],f=Z.from(...c.map(O=>O.compatibleGlyphBox));if(!f.height||!f.width)continue;const{computedStyle:d,isVertical:g,inlineBox:p,compatibleGlyphBox:y,strikeoutPosition:m,underlinePosition:P}=h,{fontSize:E}=d,{image:x,referImage:S,colormap:_,line:b,size:C,thickness:T}=Un(d),B=Dn(T,{fontSize:E,total:f.width})/f.width,G=In(_),{pathSet:R,dom:U}=r.parse(x),V=R.getBoundingBox(!0),L=E/V.width*2,D=new Z().copy(f);g&&(D.width=f.height,D.height=f.width,D.left=f.left+f.width);const H=Math.floor(D.width);let I=H;C!=="cover"&&(I=Dn(C,{fontSize:E,total:f.width})||H,D.width=I);const N=!K(S)&&K(b);if(N)V.copy(r.parse(S).pathSet.getBoundingBox(!0));else{let O;if(K(b))if(V.width/V.height>4){O="underline";const j=U.getAttribute("viewBox");if(j){const[A,M,F,z]=j.split(" ").map(J=>Number(J)),Y=M+z/2;V.y<Y&&V.y+V.height>Y?O="line-through":V.y+V.height<Y?O="overline":O="underline"}}else O="outline";else O=b;switch(O){case"outline":{const j=D.width*.2,A=D.height*.2;g?(D.x-=A/2,D.y-=j/2,D.x-=D.height):(D.x-=j/2,D.y-=A/2),D.width+=j,D.height+=A;break}case"overline":D.height=V.height*L,g?D.x=p.left+p.width:D.y=p.top;break;case"line-through":D.height=V.height*L,g?D.x=p.left+p.width-m+D.height/2:D.y=p.top+m-D.height/2;break;case"underline":D.height=V.height*L,g?D.x=y.left+y.width-P:D.y=p.top+P;break}}const $=new be;if($.translate(-V.x,-V.y),$.scale(D.width/V.width,D.height/V.height),g){const O=D.width/2,j=D.height/2;N||$.translate(-O,-j),$.rotate(-Math.PI/2),N||$.translate(j,O)}$.translate(D.x,D.y);for(let O=0;O<Math.ceil(H/I);O++){const j=$.clone();g?j.translate(0,O*D.width):j.translate(O*D.width,0),R.paths.forEach(A=>{const M=A.clone().applyTransform(j);M.style.strokeWidth&&(M.style.strokeWidth*=L*B),M.style.strokeMiterlimit&&(M.style.strokeMiterlimit*=L),M.style.strokeDashoffset&&(M.style.strokeDashoffset*=L),M.style.strokeDasharray&&(M.style.strokeDasharray=M.style.strokeDasharray.map(F=>F*L)),M.style.fill&&M.style.fill in G&&(M.style.fill=G[M.style.fill]),M.style.stroke&&M.style.stroke in G&&(M.style.stroke=G[M.style.stroke]),s.paths.push(M),H!==I&&(g?e[s.paths.length-1]=new Z(f.left-f.width*2,f.top,f.width*4,f.height):e[s.paths.length-1]=new Z(f.left,f.top-f.height*2,f.width,f.height*4))})}}},renderOrder:-1,getBoundingBox:()=>{const i=[];return s.paths.forEach((n,o)=>{const a=e[o];let l=n.getBoundingBox();if(a){const c=Math.max(l.x,a.x),h=Math.max(l.y,a.y),f=Math.min(l.right,a.right),d=Math.min(l.bottom,a.bottom);l=new Z(c,h,f-c,d-h)}i.push(l)}),Z.from(...i)},render:(i,n)=>{s.paths.forEach((o,a)=>{if(wr({ctx:i,path:o,fontSize:n.computedStyle.fontSize,clipRect:e[a]}),n.debug){const l=new Tt([o]).getBoundingBox();l&&i.strokeRect(l.x,l.y,l.width,l.height)}})}}}function dg(s,e){return`<svg width="${s*2}" height="${s*2}" xmlns="http://www.w3.org/2000/svg">
866
866
  <circle cx="${s}" cy="${s}" r="${s}" fill="${e}" />
867
- </svg>`}function pg(){const s=new Tt;return{name:"listStyle",pathSet:s,update:e=>{s.paths.length=0;const{paragraphs:t,isVertical:r,fontSize:i}=e,n=i*.45;t.forEach(o=>{const{computedStyle:a}=o,{color:l,listStyleImage:c,listStyleColormap:h,listStyleSize:f,listStyleType:d}=a,g=In(h);let p=f,y;if(!K(c))y=c;else if(!K(d)){const b=i*.38/2;switch(p=p==="cover"?b*2:p,d){case"disc":y=dg(b,String(l));break}}if(!y)return;const m=zs(y),P=m.getBoundingBox(),E=o.fragments[0]?.characters[0];if(!E)return;const{inlineBox:x}=E,S=p==="cover"?1:Dn(p,{total:i,fontSize:i})/i,_=new be;if(r){const b=i/P.height*S;_.translate(-P.left,-P.top).rotate(Math.PI/2).scale(b,b).translate(x.left+(x.width-P.height*b)/2,x.top-n)}else{const b=i/P.height*S;_.translate(-P.left,-P.top).scale(b,b).translate(x.left-P.width*b-n,x.top+(x.height-P.height*b)/2)}s.paths.push(...m.paths.map(b=>{const C=b.clone();return C.applyTransform(_),C.style.fill&&C.style.fill in g&&(C.style.fill=g[C.style.fill]),C.style.stroke&&C.style.stroke in g&&(C.style.stroke=g[C.style.stroke]),C}))})}}}function gg(){return{name:"outline"}}const zt=new k,Pr=new be,Vt=new be;function mg(){const s=new Tt;return{name:"render",pathSet:s,update:e=>{s.paths.length=0;const{paragraphs:t}=e;t.forEach(r=>{r.fragments.forEach(i=>{i.characters.forEach(n=>{s.paths.push(n.path)})})})},getBoundingBox:e=>{const{characters:t,fontSize:r,effects:i}=e,n=[];return t.forEach(o=>{i?.forEach(a=>{if(!o.glyphBox)return;const l=o.glyphBox.clone(),c=Bn(e,a);zt.set(l.left,l.top),zt.applyMatrix3(c),l.left=zt.x,l.top=zt.y,zt.set(l.right,l.bottom),zt.applyMatrix3(c),l.width=zt.x-l.left,l.height=zt.y-l.top;const h=(a.shadowOffsetX??0)*r,f=(a.shadowOffsetY??0)*r,d=Math.max(.1,a.textStrokeWidth??0)*r;l.left+=h-d,l.top+=f-d,l.width+=d*2,l.height+=d*2,n.push(l)})}),n.length?Z.from(...n):void 0},render:(e,t)=>{const{paragraphs:r,glyphBox:i,effects:n}=t;n?n.forEach(o=>{ts(o,i,e),e.save();const[a,l,c,h,f,d]=Bn(t,o).transpose().elements;e.transform(a,h,l,f,c,d),t.forEachCharacter(g=>{g.drawTo(e,o)}),e.restore()}):r.forEach(o=>{o.fragments.forEach(a=>{a.characters.forEach(l=>{l.drawTo(e)})})}),t.debug&&r.forEach(o=>{e.strokeRect(o.lineBox.x,o.lineBox.y,o.lineBox.width,o.lineBox.height)})}}}function Bn(s,e){const{fontSize:t,glyphBox:r}=s,i=(e.translateX??0)*t,n=(e.translateY??0)*t,o=Math.PI*2,a=(e.skewX??0)/360*o,l=(e.skewY??0)/360*o,{left:c,top:h,width:f,height:d}=r,g=c+f/2,p=h+d/2;return Pr.identity(),Vt.makeTranslation(i,n),Pr.multiply(Vt),Vt.makeTranslation(g,p),Pr.multiply(Vt),Vt.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),Pr.multiply(Vt),Vt.makeTranslation(-g,-p),Pr.multiply(Vt),Pr.clone()}function yg(){const s=new Tt;return{name:"textDecoration",pathSet:s,update:e=>{s.paths.length=0;const t=[];let r,i;e.forEachCharacter(n=>{const{computedStyle:o,isVertical:a,inlineBox:l,underlinePosition:c,underlineThickness:h,strikeoutPosition:f,strikeoutSize:d}=n,{color:g,textDecoration:p,writingMode:y}=o;if(K(p))i=void 0;else{let m=!1;if(i?.textDecoration===p&&i?.writingMode===y&&i?.color===g&&(a?r[0].inlineBox.left===l.left:r[0].inlineBox.top===l.top))switch(p){case"underline":r[0].underlinePosition===c&&r[0].underlineThickness===h&&(m=!0);break;case"line-through":r[0].strikeoutPosition===f&&r[0].strikeoutSize===d&&(m=!0);break}m?r.push(n):(r=[],r.push(n),t.push(r)),i=o}}),t.forEach(n=>{const{computedStyle:o,isVertical:a,underlinePosition:l,underlineThickness:c,strikeoutPosition:h,strikeoutSize:f}=n[0],{color:d,textDecoration:g}=o,p=Z.from(...n.map(C=>C.inlineBox)),{left:y,top:m,width:P,height:E}=p;let x=a?y+P:m;const S=a?-1:1;let _=0;switch(g){case"overline":_=c*2;break;case"underline":x+=S*l,_=c*2;break;case"line-through":x+=S*h,_=f*2;break}x-=_;let b;a?b=new ge([{type:"M",x,y:m},{type:"L",x,y:m+E},{type:"L",x:x+_,y:m+E},{type:"L",x:x+_,y:m},{type:"Z"}],{fill:d}):b=new ge([{type:"M",x:y,y:x},{type:"L",x:y+P,y:x},{type:"L",x:y+P,y:x+_},{type:"L",x:y,y:x+_},{type:"Z"}],{fill:d}),s.paths.push(b)})},render:(e,t)=>{const{effects:r,computedStyle:i}=t;r?r.forEach(n=>{e.save();const[o,a,l,c,h,f]=Bn(t,n).transpose().elements;e.transform(o,c,a,h,l,f),s.paths.forEach(d=>{wr({ctx:e,path:d,fontSize:i.fontSize,...n})}),e.restore()}):s.paths.forEach(n=>{wr({ctx:e,path:n,fontSize:i.fontSize})})}}}var _g=Object.defineProperty,Gt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&_g(e,t,i),i};const Fl=vo();class kt extends fo{needsUpdate=!0;computedStyle={...Fl};paragraphs=[];lineBox=new Z;rawGlyphBox=new Z;glyphBox=new Z;pathBox=new Z;boundingBox=new Z;measurer=new rs;plugins=new Map;pathSets=[];get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(t=>t.characters))}constructor(e={}){super(),this.set(e)}set(e={}){const{content:t,effects:r,style:i,measureDom:n,fonts:o,fill:a,outline:l}=wo(e);this.debug=e.debug??!1,this.content=t,this.effects=r,this.style=i,this.measureDom=n,this.fonts=o,this.fill=a,this.outline=l,this.use(ug()).use(gg()).use(pg()).use(yg()).use(fg()).use(mg()),(e.plugins??[]).forEach(c=>{this.use(c)}),this.updateParagraphs()}use(e){return this.plugins.set(e.name,e),this}forEachCharacter(e){return this.paragraphs.forEach((t,r)=>{t.fragments.forEach((i,n)=>{i.characters.forEach((o,a)=>{e(o,{paragraphIndex:r,fragmentIndex:n,characterIndex:a})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(e=>e.load?.(this)))}updateParagraphs(){this.computedStyle={...Fl,...this.style};const{content:e}=this,t=[];return e.forEach((r,i)=>{const{fragments:n,fill:o,outline:a,...l}=r,c=new hg(l,i,this);c.fill=o,c.outline=a,n.forEach((h,f)=>{const{content:d,fill:g,outline:p,...y}=h;if(d!==void 0){const m=new cg(d,y,f,c);c.fragments.push(m),m.fill=g,m.outline=p}}),t.push(c)}),this.paragraphs=t,this}createDom(){return this.updateParagraphs(),this.measurer.createDom(this.paragraphs,this.computedStyle)}measure(e=this.measureDom){const t={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const r=this.measurer.measure(this.paragraphs,this.computedStyle,e);this.paragraphs=r.paragraphs,this.lineBox=r.boundingBox,this.characters.forEach(i=>{i.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((i,n)=>(i.updateOrder??0)-(n.updateOrder??0)).forEach(i=>{i.update?.(this)}),this.pathSets.length=0,Array.from(this.plugins.values()).sort((i,n)=>(i.renderOrder??0)-(n.renderOrder??0)).forEach(i=>{i.pathSet?.paths.length&&this.pathSets.push(i.pathSet)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const i in t)r[i]=this[i],this[i]=t[i];return this.emit("measure",{text:this,result:r}),r}getGlyphBox(){const e=k.MAX,t=k.MIN;return this.characters.forEach(r=>{if(!r.getGlyphMinMax(e,t)){const{inlineBox:i}=r,{left:n,top:o,width:a,height:l}=i,c=new k(n,o),h=new k(n+a,o+l);e.min(c,h),t.max(c,h)}}),new Z(e.x,e.y,t.x-e.x,t.y-e.y)}updatePathBox(){return this.pathBox=Z.from(this.glyphBox,...Array.from(this.plugins.values()).map(e=>e.getBoundingBox?e.getBoundingBox(this):e.pathSet?.getBoundingBox()).filter(Boolean)),this}updateBoundingBox(){return this.boundingBox=Z.from(this.rawGlyphBox,this.lineBox,this.pathBox),this}requestUpdate(){return this.needsUpdate=!0,this}update(e=this.measureDom){const t=this.measure(e);for(const r in t)this[r]=t[r];return this.emit("update",{text:this}),this.needsUpdate=!1,this}render(e){const{view:t,pixelRatio:r=2}=e,i=t.getContext("2d");i&&(this.needsUpdate&&this.update(),rg(i,r,this.boundingBox),ig(i,this),Array.from(this.plugins.values()).sort((n,o)=>(n.renderOrder??0)-(o.renderOrder??0)).forEach(n=>{if(n.render)n.render?.(i,this);else if(n.pathSet){const o=this.computedStyle;n.pathSet.paths.forEach(a=>{wr({ctx:i,path:a,fontSize:o.fontSize})})}}),this.emit("render",{text:this,view:t,pixelRatio:r}),e.onContext?.(i))}toString(){return this.content.flatMap(e=>e.fragments.map(t=>t.content)).join("")}}Gt([w({internal:!0})],kt.prototype,"debug"),Gt([w()],kt.prototype,"content"),Gt([w()],kt.prototype,"style"),Gt([w()],kt.prototype,"effects"),Gt([w()],kt.prototype,"fill"),Gt([w()],kt.prototype,"outline"),Gt([w({internal:!0})],kt.prototype,"measureDom"),Gt([w({internal:!0})],kt.prototype,"fonts");var vg=Object.defineProperty,jt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&vg(e,t,i),i};class _t extends It{constructor(e){super(),this.parent=e,this.base.setPropertyAccessor(this)}base=new kt;measureResult;_textureMap=new Map;setProperties(e){return super.setProperties(K(e)?void 0:wo(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"enabled":case"effects":case"measureDom":case"fonts":this.parent.requestRedraw();break;case"fill":case"outline":case"content":this._updateTextureMap();break}}_updateTextureMap(){this.base.update(),this._textureMap.clear();const e=[];if(this.base.paragraphs.forEach((t,r)=>{const i=[];if(t.fragments.forEach((n,o)=>{if(n.characters.length){const a=Z.from(...n.characters.map(l=>l.compatibleGlyphBox));this._updateTexture(`${r}.${o}.fill`,n.fill,a),this._updateTexture(`${r}.${o}.outline`,n.outline,a),i.push(a)}}),i.length){const n=Z.from(...i);this._updateTexture(`${r}.fill`,t.fill,n),this._updateTexture(`${r}.outline`,t.outline,n),e.push(n)}}),e.length){const t=Z.from(...e);this._updateTexture("fill",this.fill,t),this._updateTexture("outline",this.outline,t)}this.parent.requestRedraw()}async _updateTexture(e,t,r){t&&Object.keys(t).length>0&&(this._textureMap.set(e,{texture:await this._loadTexture(t,r),box:r}),this.parent.requestRedraw())}async _loadTexture(e,t){return e.linearGradient||e.radialGradient?new $r(e.linearGradient??e.radialGradient,t.width,t.height):K(e.image)?void 0:(this.parent.tree?.log(`load image ${e.image}`),await nt.texture.load(e.image))}setContent(e){this.content=vs(e)}measure(){return this.base.measure()}updateMeasure(){return this.measureResult=this.measure(),this}canDraw(){return!!(this.enabled&&!/^\s*$/.test(this.base.toString()))}_getVertTransform(){const e=this.parent;if(e.scale.x>0&&e.scale.y>0)return;const t=e.scale.x*e.scale.y,r=e.getTransformOrigin();return new ve().translate(-r.x,-r.y).scale(t>0?1:-1,1).translate(r.x,r.y)}draw(){const e=this.parent.context;this.base.update(),this.base.pathSets.forEach(t=>{t.paths.forEach(r=>{const i=r.getMeta();if(i instanceof Bl){const n=i.parent.index,o=i.parent.parent.index;if(r.style.fill&&!K(r.style.fill))if(typeof r.style.fill=="object"){const a=r.style.fill,l=this._textureMap.get(`${o}.${n}.fill`)??this._textureMap.get(`${o}.fill`)??this._textureMap.get("fill");if(a.enabled!==!1&&(l||a.color)){const{uvTransform:c,disableWrapMode:h}=Li(a,l?.box??{width:this.parent.size.width,height:this.parent.size.height});e.addPath(r),e.style={...r.style},e.uvTransform=c,e.fillStyle=l?.texture??a.color,e.vertTransform=this._getVertTransform(),e.fill({disableWrapMode:h})}}else e.addPath(r),e.style={...r.style},e.vertTransform=this._getVertTransform(),e.fill();if(r.style.stroke&&!K(r.style.stroke))if(typeof r.style.stroke=="object"){const a=r.style.stroke,l=this._textureMap.get(`${o}.${n}.outline`)??this._textureMap.get(`${o}.outline`)??this._textureMap.get("outline");if(a.enabled!==!1&&(l||a.color)&&(a.width===void 0||a.width)){const{uvTransform:c,disableWrapMode:h}=Li(a,l?.box??{width:this.parent.size.width,height:this.parent.size.height});e.addPath(r),e.style={...r.style},e.lineWidth=a.width||1,e.uvTransform=c,e.strokeStyle=l?.texture??a.color,e.lineCap=a.lineCap,e.lineJoin=a.lineJoin,e.vertTransform=this._getVertTransform(),e.stroke({disableWrapMode:h})}}else e.addPath(r),e.style={...r.style},e.vertTransform=this._getVertTransform(),e.stroke()}})})}}jt([w({fallback:!0})],_t.prototype,"enabled"),jt([w({fallback:()=>[]})],_t.prototype,"content"),jt([w({alias:"parent.style.json"})],_t.prototype,"style"),jt([w()],_t.prototype,"effects"),jt([w()],_t.prototype,"fill"),jt([w()],_t.prototype,"outline"),jt([w({alias:"base.measureDom"})],_t.prototype,"measureDom"),jt([w({alias:"base.fonts"})],_t.prototype,"fonts");var bg=Object.getOwnPropertyDescriptor,wg=(s,e,t,r)=>{for(var i=r>1?void 0:r?bg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.BaseElement2D=class extends u.Node2D{size=new de().on("update",()=>{this.updateGlobalTransform(),this.requestRedraw()});get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}_background=new nn(this);get background(){return this._background}set background(e){this._background.resetProperties().setProperties(e)}_shape=new Qt(this);get shape(){return this._shape}set shape(e){this._shape.resetProperties().setProperties(e)}_fill=new Te(this);get fill(){return this._fill}set fill(e){this._fill.resetProperties().setProperties(e)}_outline=new Zt(this);get outline(){return this._outline}set outline(e){this._outline.resetProperties().setProperties(e)}_foreground=new on(this);get foreground(){return this._foreground}set foreground(e){this._foreground.resetProperties().setProperties(e)}_text=new _t(this);get text(){return this._text}set text(e){this._text.resetProperties().setProperties(e)}_shadow=new Jt(this);get shadow(){return this._shadow}set shadow(e){this._shadow.resetProperties().setProperties(e)}constructor(e,t=[]){super(),this._updateStyleProperty=this._updateStyleProperty.bind(this),this.style=new Qr,this.setProperties(e).append(t)}setProperties(e){if(e){const{style:t,text:r,shape:i,background:n,fill:o,outline:a,foreground:l,shadow:c,...h}=e;t&&this.style.setProperties(t),n&&this.background.setProperties(n),i&&this.shape.setProperties(i),o&&this.fill.setProperties(o),a&&this.outline.setProperties(a),r&&this.text.setProperties(r),l&&this.foreground.setProperties(l),c&&this.shadow.setProperties(c),super.setProperties(h)}return this}_updateStyleProperty(e,t,r){switch(e){case"rotate":this.rotation=this.style.rotate*Go;break;case"scaleX":this.scale.x=this.style.scaleX,this.text.canDraw()&&(t^r)<0&&this.requestRedraw();break;case"scaleY":this.scale.y=this.style.scaleY,this.text.canDraw()&&(t^r)<0&&this.requestRedraw();break;case"skewX":this.skew.x=this.style.skewX;break;case"skewY":this.skew.y=this.style.skewY;break;case"transform":case"transformOrigin":this.updateGlobalTransform();break;case"opacity":this.opacity=this.style.opacity;break;case"visibility":this.visible=this.style.visibility==="visible";break;case"filter":this.requestRepaint();break;case"maskImage":this._updateMaskImage();break;case"backgroundColor":this.background.color=this.style.backgroundColor;break;case"backgroundImage":this.background.image=this.style.backgroundImage;break;case"borderStyle":case"outlineStyle":this.outline.style=t;break;case"borderWidth":case"outlineWidth":this.outline.width=t;break;case"borderColor":case"outlineColor":this.outline.color=t;break;case"borderRadius":default:this.requestRedraw();break}}_updateMaskImage(){const e="__$style.maskImage",t=this.style.maskImage;if(t&&t!=="none"){const r=this.getNode(e);r?r.src=t:this.appendChild(new u.MaskEffect({name:e,src:t}),"back")}else{const r=this.getNode(e);r&&this.removeChild(r)}}getTransformOrigin(){const{width:e,height:t}=this.size,[r,i]=Ga(this.style.transformOrigin);return new de(r*e,i*t)}updateTransform(e){const{width:t,height:r}=this.size;super.updateTransform(i=>{Va(this.style.transform??"",t,r,i),e?.(i)})}updateGlobalTransform(){super.updateGlobalTransform(),this._updateOverflow()}getRect(){return this.getGlobalAabb()}_getPointArray(){const{width:e,height:t}=this.size,r=0,i=0,n=r+e,o=i+t;return[{x:r,y:i},{x:r,y:o},{x:n,y:i},{x:n,y:o}]}getAabb(){return new Rt(this._getPointArray().map(e=>this.transform.apply(e)))}getGlobalAabb(){return new Rt(this._getPointArray().map(e=>this.globalTransform.apply(e)))}getObb(){const e=this.getTransformOrigin(),t=this.transform.apply(e).sub(e);return{rect:new Rt(this._getPointArray().map(r=>(r.x+=t.x,r.y+=t.y,r))),rotation:this.rotation}}getGlobalObb(){const e=this.getTransformOrigin(),t=this.globalTransform.apply(e).sub(e);return{rect:new Rt(this._getPointArray().map(r=>(r.x+=t.x,r.y+=t.y,r))),rotation:this.globalRotation}}_updateOverflow(){this.style.overflow==="hidden"?this.mask=this.getRect().toJSON():this.mask=void 0}_draw(){super._draw(),this._text.canDraw()&&this._text.updateMeasure(),this._background.canDraw()&&(this._tree?.log(this.name,"background drawing"),this._background.fillWithShape?this._shape.draw():this._shape.drawRect(),this._background.draw()),this._fill.canDraw()&&(this._tree?.log(this.name,"fill drawing"),this._shape.draw(),this._fill.draw()),this._outline.canDraw()&&(this._tree?.log(this.name,"outline drawing"),this._shape.draw(),this._outline.draw()),this._foreground.canDraw()&&(this._tree?.log(this.name,"foreground drawing"),this._foreground.fillWithShape?this._shape.draw():this._shape.drawRect(),this._foreground.draw()),this._text.canDraw()&&(this._tree?.log(this.name,"text drawing"),this._text.draw()),this._drawContent()}_drawContent(){}_repaint(e){return super._repaint(e).map(t=>({...t}))}canPointerEvents(){return this.style.pointerEvents!=="none"}input(e,t){const r=this.getChildren(!0);for(let i=r.length-1;i>=0;i--)r[i].input(e,t);this.isVisibleInTree()&&this._input(e,t)}_positionInput(e,t){const{width:r,height:i}=this.size;return e.x>=0&&e.x<r&&e.y>=0&&e.y<i}_input(e,t){switch(t){case"pointerdown":case"pointermove":case"pointerup":{if(this.canPointerEvents()){const{screenX:r,screenY:i}=e;if(r&&i){const n=new de(r,i),o=this.getViewport();o&&o.toCanvasGlobal(n,n),this.toLocal(n,n),this._positionInput(n,t)&&(e.target||(e.target=this),this.emit(t,e))}}break}}}toJSON(){const e=t=>Object.keys(t).length>0?t:void 0;return Ve({...super.toJSON(),style:e(this.style.toJSON()),background:e(this.background.toJSON()),shape:e(this.shape.toJSON()),fill:e(this.fill.toJSON()),outline:e(this.outline.toJSON()),text:e(this.text.toJSON()),foreground:e(this.foreground.toJSON()),shadow:e(this.shadow.toJSON())})}},u.BaseElement2D=wg([W("BaseElement2D")],u.BaseElement2D);class Ln extends Qr{constructor(e){super(),this.setProperties(e)}}const $l={left:0,top:0,width:0,height:0};for(const s in $l)yi(Ln,s,{fallback:$l[s]});class zl extends Qr{constructor(e){super(),this.setProperties(e)}}var xg=Object.getOwnPropertyDescriptor,Pg=(s,e,t,r)=>{for(var i=r>1?void 0:r?xg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.Element2D=class extends u.BaseElement2D{get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}constructor(e,t=[]){super(),this.style=new Ln,this.setProperties(e).append(t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"left":this.position.x=Number(t);break;case"top":this.position.y=Number(t);break;case"width":this.size.width=Number(t);break;case"height":this.size.height=Number(t);break}switch(e){case"width":case"height":this.mask instanceof u.BaseElement2D&&(this.mask.size.width=this.size.width,this.mask.size.height=this.size.height);break}}},u.Element2D=Pg([W("Element2D")],u.Element2D);const fe={left:0,top:1,right:2,bottom:3,start:4,end:5,horizontal:6,vertical:7,all:8},Vl={column:0,row:1,all:2},nr={auto:0,"flex-start":1,center:2,"flex-end":3,stretch:4,baseline:5,"space-between":6,"space-around":7,"space-evenly":8},Nn={flex:0,none:1,contents:2},is={inherit:0,ltr:1,rtl:2},Fn={column:0,"column-reverse":1,row:2,"row-reverse":3},$n={"no-wrap":0,wrap:1,"Wrap-reverse":2},zn={"flex-start":0,center:1,"flex-end":2,"space-between":3,"space-around":4,"space-evenly":5},Vn={visible:0,hidden:1,scroll:2},Gn={static:0,relative:1,absolute:2},jn={"border-box":0,"content-box":1};class ss{constructor(e){this._element=e}static _yoga;static async load(){const{loadYoga:e}=await import("yoga-layout/load");this._yoga=await e()}_node=ss._yoga.Node.create();get _style(){return this._element.style}get offsetLeft(){return this._node.getComputedLeft()}get offsetTop(){return this._node.getComputedTop()}get offsetWidth(){return this._node.getComputedWidth()}get offsetHeight(){return this._node.getComputedHeight()}calculateLayout(e,t,r){return this._node.calculateLayout(e,t,r)}getComputedLayout(){return this._node.getComputedLayout()}updateStyleProperty(e,t,r){switch(e){case"alignContent":this._node.setAlignContent(t?nr[t]:nr["flex-start"]);break;case"alignItems":this._node.setAlignItems(t?nr[t]:nr["flex-start"]);break;case"alignSelf":this._node.setAlignSelf(t?nr[t]:nr["flex-start"]);break;case"aspectRatio":this._node.setAspectRatio(t);break;case"borderTop":this._node.setBorder(fe.top,this._style.borderWidth);break;case"borderBottom":this._node.setBorder(fe.bottom,this._style.borderWidth);break;case"borderLeft":this._node.setBorder(fe.left,this._style.borderWidth);break;case"borderRight":this._node.setBorder(fe.right,this._style.borderWidth);break;case"border":this._node.setBorder(fe.all,this._style.borderWidth);break;case"direction":this._node.setDirection(t?is[t]:is.inherit);break;case"display":this._node.setDisplay(t?Nn[t]:Nn.flex);break;case"flex":this._node.setFlex(this._style.flex);break;case"flexBasis":this._node.setFlexBasis(this._style.flexBasis);break;case"flexDirection":this._node.setFlexDirection(t?Fn[t]:Fn.row);break;case"flexGrow":this._node.setFlexGrow(this._style.flexGrow);break;case"flexShrink":this._node.setFlexShrink(this._style.flexShrink);break;case"flexWrap":this._node.setFlexWrap(t?$n[t]:$n.wrap);break;case"height":this._node.setHeight(this._style.height);break;case"justifyContent":this._node.setJustifyContent(t?zn[t]:zn["flex-start"]);break;case"gap":t!==void 0&&this._node.setGap(Vl.all,t);break;case"marginTop":this._node.setMargin(fe.top,t);break;case"marginBottom":this._node.setMargin(fe.bottom,t);break;case"marginLeft":this._node.setMargin(fe.left,t);break;case"marginRight":this._node.setMargin(fe.right,t);break;case"margin":this._node.setMargin(fe.all,t);break;case"maxHeight":this._node.setMaxHeight(t);break;case"maxWidth":this._node.setMaxWidth(t);break;case"minHeight":this._node.setMinHeight(this._style.minHeight);break;case"minWidth":this._node.setMinWidth(this._style.minWidth);break;case"overflow":this._node.setOverflow(t?Vn[t]:Vn.visible);break;case"paddingTop":this._node.setPadding(fe.top,this._style.paddingTop);break;case"paddingBottom":this._node.setPadding(fe.bottom,this._style.paddingBottom);break;case"paddingLeft":this._node.setPadding(fe.left,this._style.paddingLeft);break;case"paddingRight":this._node.setPadding(fe.right,this._style.paddingRight);break;case"padding":this._node.setPadding(fe.all,this._style.padding);break;case"top":this._node.setPosition(fe.top,this._style.top);break;case"bottom":this._node.setPosition(fe.bottom,this._style.bottom);break;case"left":this._node.setPosition(fe.left,this._style.left);break;case"right":this._node.setPosition(fe.right,this._style.right);break;case"position":this._node.setPositionType(t?Gn[t]:Gn.static);break;case"boxSizing":this._node.setBoxSizing(t?jn[t]:jn["content-box"]);break;case"width":this._node.setWidth(this._style.width);break}}}var Sg=Object.getOwnPropertyDescriptor,Cg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Sg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.FlexElement2D=class extends u.BaseElement2D{get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}_layout=new ss(this);get offsetLeft(){return this._layout.offsetLeft}get offsetTop(){return this._layout.offsetTop}get offsetWidth(){return this._layout.offsetWidth}get offsetHeight(){return this._layout.offsetHeight}constructor(e,t=[]){super(),this.style=new zl,this.setProperties(e).append(t)}_parented(e){super._parented(e),e._layout&&this._layout._node&&e._layout._node.insertChild(this._layout._node,e._layout._node.getChildCount())}_unparented(e){super._unparented(e),e._layout?._node&&e._layout._node.removeChild(this._layout._node)}_updateStyleProperty(e,t,r){super._updateStyleProperty(e,t,r),this._layout.updateStyleProperty(e,t,r),this._layout._node.isDirty()&&this.requestRelayout()}updateTransform(){this.calculateLayout(void 0,void 0,is.ltr);const{left:e,top:t,width:r,height:i}=this._layout.getComputedLayout();this.position.x=e,this.position.y=t,this.size.x=r,this.size.y=i,super.updateTransform()}calculateLayout(e,t,r){const i=this.getParent();i?._layout?.calculateLayout?i?._layout.calculateLayout(e,t,r):this._layout.calculateLayout(e,t,r)}},u.FlexElement2D=Cg([W("FlexElement2D")],u.FlexElement2D);var Tg=Object.defineProperty,Eg=Object.getOwnPropertyDescriptor,di=(s,e,t,r)=>{for(var i=r>1?void 0:r?Eg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Tg(e,t,i),i};u.Image2D=class extends u.Element2D{get currentFrameTexture(){return this.texture?.frames[this._frameIndex]?.texture}get textureDuration(){return this.texture?.duration??0}get naturalWidth(){return this.currentFrameTexture?.realWidth??0}get naturalHeight(){return this.currentFrameTexture?.realHeight??0}get complete(){return this._complete}_frameIndex=0;_complete=!1;_wait=Promise.resolve();constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._wait=this._load(t);break;case"srcRect":this.requestRedraw();break}}decode(){return this._wait}setResource(e){let t;if(e instanceof Ri?t=e:t=new Ri(e),this.texture=t.updateDuration(),this.currentFrameTexture&&(!this.style.width||!this.style.height)){const r=this.currentFrameTexture;this.style.width=r.realWidth,this.style.height=r.realHeight}return this}async _load(e){if(this._complete=!1,e)try{this.setResource(this.gif||e?.includes(".gif")?await nt.gif.load(e):await nt.texture.load(e)),this.requestRedraw(),this.emit("load")}catch(t){console.warn(t),this.emit("error",t)}else this.texture=void 0;this._complete=!0}_getFrameCurrentTime(){const e=this.textureDuration;if(!e||!this._tree)return 0;const t=this._currentTime;return t<0?0:t%e}_updateFrameIndex(){if(!this.texture)return this;const e=this._getFrameCurrentTime(),t=this.texture.frames,r=t.length;if(r<=1&&this._frameIndex===0)return this;let i=r-1;for(let n=0,o=0;o<r;o++)if(n+=t[o].duration??0,n>=e){i=o;break}return this._frameIndex!==i&&(this._frameIndex=i,this.requestRedraw()),this}_process(e){this._updateFrameIndex(),super._process(e)}_drawContent(){const e=this.currentFrameTexture;if(e?.valid){const{left:t=0,top:r=0,right:i=0,bottom:n=0}=this.srcRect??{},{width:o,height:a}=this.size;this.context.fillStyle=e;const l=Math.abs(1+(t+i))*o,c=Math.abs(1+(r+n))*a,h=1/l,f=1/c,d=t*o*h,g=r*a*f;this.context.uvTransform=new ve().scale(h,f).translate(d,g),this.shape.draw(),this.context.fill()}}_repaint(e){return super._repaint(e).map(t=>({...t,disableWrapMode:!0}))}},di([w({protected:!0})],u.Image2D.prototype,"texture",2),di([w({fallback:""})],u.Image2D.prototype,"src",2),di([w()],u.Image2D.prototype,"srcRect",2),di([w({fallback:!1})],u.Image2D.prototype,"gif",2),u.Image2D=di([W("Image2D")],u.Image2D);class Wn extends u.Element2D{texture;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_drawContent(){if(this.texture?.valid){const{width:e,height:t}=this.size;this.context.fillStyle=this.texture,this.context.uvTransform=new ve().scale(1/e,1/t),this.shape.drawRect(),this.context.fill()}}}var Mg=Object.defineProperty,Ag=Object.getOwnPropertyDescriptor,Gl=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ag(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Mg(e,t,i),i};u.Lottie2D=class extends Wn{texture=new Ui;animation;constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._load();break}}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":this.texture.width=this.style.width;break;case"height":this.texture.height=this.style.height;break}}async _load(){this.animation=await nt.lottie.load(this.src,this.texture.source),this.duration=this.animation.getDuration(!1)*1e3,this.texture.requestUpload(),this.requestRedraw()}_process(e){this.animation?.goToAndStop(this.currentTime,!1),this.texture.requestUpload(),this.requestRedraw(),super._process(e)}},Gl([w({fallback:""})],u.Lottie2D.prototype,"src",2),u.Lottie2D=Gl([W("Lottie2D")],u.Lottie2D);var Og=Object.defineProperty,kg=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Og(e,t,i),i};class qn extends u.Element2D{constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":case"height":this.requestRedraw();break}}_drawCircle(e,t){this.context.arc(e,t,this.handleSize,0,Math.PI*2,!0),this.context.fillStyle=le.WHITE,this.context.fill(),this.context.arc(e,t,this.handleSize,0,Math.PI*2,!0),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_drawEllipse(e,t){this.context.roundRect(e-this.handleSize,t-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.fillStyle=le.WHITE,this.context.fill(),this.context.roundRect(e-this.handleSize,t-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_draw(){const{width:e,height:t}=this.getRect();this.context.rect(0,0,e,t),this.context.strokeStyle="#00FF00",this.context.stroke(),this._drawCircle(0,0),this._drawCircle(e,t),this._drawCircle(0,t),this._drawEllipse(0,t/2),this._drawCircle(e,0),this._drawEllipse(e,t/2)}}kg([w({fallback:6})],qn.prototype,"handleSize");var Dg=Object.defineProperty,Ig=Object.getOwnPropertyDescriptor,jl=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ig(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Dg(e,t,i),i};u.Video2D=class extends Wn{get videoDuration(){return(this.texture?.duration??0)*1e3}_wait=Promise.resolve();constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._wait=this._load(t);break}}waitLoad(){return this._wait}async _load(e){this.texture=await nt.video.load(e),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_updateVideoCurrentTime(){let e=this._currentTime;if(e<0)return;const t=this.texture;if(!t)return;const r=t.duration;e=r?e%(r*1e3):0,!t.isPlaying&&!t.seeking&&(e=~~e/1e3,t.currentTime!==e&&(t.currentTime=e))}_process(e){this._updateVideoCurrentTime(),super._process(e)}},jl([w({fallback:""})],u.Video2D.prototype,"src",2),u.Video2D=jl([W("Video2D")],u.Video2D);var Rg=Object.defineProperty,Ug=Object.getOwnPropertyDescriptor,pi=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ug(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Rg(e,t,i),i};const Wl=s=>s,ql=Sr(.25,.1,.25,1),Xl=Sr(.42,0,1,1),Hl=Sr(0,0,.58,1),Yl=Sr(.42,0,.58,1);function Sr(s,e,t,r){const n=3*s-3*t+1,o=3*t-6*s,a=3*s,l=3*e-3*r+1,c=3*r-6*e,h=3*e,f=y=>(3*n*y+2*o)*y+a,d=y=>((n*y+o)*y+a)*y,g=y=>((l*y+c)*y+h)*y;function p(y){let m=y,P,E;for(let _=0;_<8;_++){if(E=d(m)-y,Math.abs(E)<1e-6)return m;if(P=f(m),Math.abs(P)<1e-6)break;m-=E/P}let x=1,S=0;for(m=y;x>S;){if(E=d(m)-y,Math.abs(E)<1e-6)return m;E>0?x=m:S=m,m=(x+S)/2}return m}return y=>g(p(y))}const ns={linear:Wl,ease:ql,easeIn:Xl,easeOut:Hl,easeInOut:Yl};u.Animation=class extends u.TimelineNode{_keyframes=[];_isFirstUpdatePosition=!1;_cachedProps=new ao;_stoped=!1;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_parented(e){super._parented(e),this._updateCachedProps()}_unparented(e){super._unparented(e),this.cancel()}_process(){this.canProcess()&&this.commitStyles()}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"effectMode":case"keyframes":this._updateKeyframes();break}}_getTargets(){let e;switch(this.effectMode){case"sibling":e=this.getParent()?.getChildren(!0).filter(t=>t instanceof u.CanvasItem)??[];break;case"parent":default:e=[this.getParent()].filter(Boolean);break}return e.map(t=>t.style)}_updateKeyframes(){const e=[],t=this.keyframes;for(let n=t.length,o=0;o<n;o++){const{offset:a=o===0?0:o/(n-1),easing:l="linear",...c}=t[o];e.push({offset:a,easing:this._parseEasing(l),props:c})}const r=e[0],i=e[e.length-1];r&&r.offset!==0&&e.unshift({offset:0,easing:this._parseEasing("linear"),props:{}}),i&&i.offset!==1&&e.push({offset:1,easing:this._parseEasing("linear"),props:{}}),this._keyframes=e,this._updateCachedProps()}commitStyles(){if(!this.keyframes.length)return;if(this._updateCurrentTime(),this.isInsideTimeRange())this._isFirstUpdatePosition||(this._isFirstUpdatePosition=!0,this._updateCachedProps());else{if(!this._isFirstUpdatePosition)return;this._isFirstUpdatePosition=!1}const e=this._getTargets(),t=1/e.length,r=this.currentTimeProgress;e.forEach((i,n)=>{const o=t===1?r:Ge(Math.max(0,r-t*n)/t,0,1),a=this._cachedProps.get(i);if(!a)return;const l=this._parseKeyframes(o,a);l?.length&&this._commitStyle(o,i,a,l[0],l[1])})}_updateCachedProps(){this.cancel(),this._getTargets().forEach(e=>{const t=new Map,r=this._keyframes;for(let i=r.length,n=0;n<i;n++)Object.keys(r[n].props).forEach(o=>{t.set(o,e[o])});this._cachedProps.set(e,t)})}_parseEasing(e){if(!e)return ns.linear;if(e in ns)return ns[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(r=>Number(r));return Sr(t[0],t[1],t[2],t[3])}_parseKeyframes(e,t){let r;const i=this._keyframes;for(let n=i.length,o=0;o<n;o++){const a=i[o],{offset:l,easing:c}=a,h={...a.props};if(r&&e<=l){const{offset:f,easing:d}=r,g={...r.props};return t.forEach((p,y)=>{(!(y in g)||g[y]===null)&&(g[y]=p),(!(y in h)||h[y]===null)&&(h[y]=p)}),[{offset:f,easing:d,props:g},{offset:l,easing:c,props:h}]}r=a}return null}_commitStyle(e,t,r,i,n){const{offset:o,easing:a,props:l}=i,{offset:c,props:h}=n,f=c-o,d=a((e-o)/f),g={width:t.width,height:t.height,fontSize:t.fontSize};r.forEach((p,y)=>{t[y]=this._getDiffValue(y,l[y],h[y],d,g)})}_getDiffValue(e,t,r,i,n){let o,a;if(t==="none"&&(t=void 0),r==="none"&&(r=void 0),t===void 0||r===void 0)if(t!==void 0)o=Ar(e,String(t),n),a=xs(o);else if(r!==void 0)a=Ar(e,String(r),n),o=xs(a);else return;else o=Ar(e,String(t),n),a=Ar(e,String(r),n);if(Array.isArray(o)&&Array.isArray(a)){const l=new Set,c={},h={};o.forEach(({name:d,args:g})=>{c[d]=g,l.add(d)}),a.forEach(({name:d,args:g})=>{h[d]=g,l.add(d)});let f="";return l.forEach(d=>{const g=Math.max(c[d]?.length??0,h[d]?.length??0),p=c[d],y=h[d];f+=`${d}(${Array.from({length:g},(m,P)=>{const E=p?.[P],x=y?.[P],S=E?.normalizedIntValue??0,_=x?.normalizedIntValue??0;return Number.isNaN(S)||Number.isNaN(_)?x?.value??0:he(S,_,i)}).join(", ")}) `}),f}else if(!Array.isArray(o)&&!Array.isArray(a))return Number.isNaN(o.normalizedIntValue)||Number.isNaN(a.normalizedIntValue)?a.value:he(o.normalizedIntValue,a.normalizedIntValue,i)}isPlaying(){return!this.paused&&this.isInsideTimeRange()}play(){return this._stoped?(this._stoped=!1,this.startTime=this.timelineCurrentTime):this.startTime=this.timelineCurrentTime-this.currentTime,this.paused=!1,!0}pause(){return this.paused=!0,!0}stop(){return this._stoped=!0,this.paused=!0,this._currentTime=0,!0}cancel(){this._getTargets().forEach(e=>{this._cachedProps.get(e)?.forEach((t,r)=>{e[r]=t}),this._cachedProps.delete(e)})}},pi([w({fallback:"parent"})],u.Animation.prototype,"effectMode",2),pi([w({fallback:!1})],u.Animation.prototype,"loop",2),pi([w({default:()=>[]})],u.Animation.prototype,"keyframes",2),pi([w()],u.Animation.prototype,"easing",2),u.Animation=pi([W("Animation",{renderMode:"disabled",processMode:"pausable",processSortMode:"parent_before",duration:2e3})],u.Animation);class os extends Dt{static _instance;static get instance(){return this._instance||(this._instance=new os),this._instance}playbackRate=1;muted=!1;volume=1;paused=!1;refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}}class gi extends Dt{static PADDING=.1;_source=null;_audio=null;_end=0;_pausedReal=!1;_duration=0;_start=0;_playing=!1;get progress(){return(this._source?.currentTime??0)/this._duration}_paused=!1;get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}set(e,t){if(this[e]===void 0)throw new Error(`Property with name ${e} does not exist.`);switch(e){case"playbackRate":this.playbackRate=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(e){this._playing=!1,this._duration=e.source.duration;const t=this._source=e.source.cloneNode(!1);return t.src=e.parent.src,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this._audio=e,this}_stop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._stop(),this._source&&this.emit("stop")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}refresh(){if(!this._audio||!this._source)return;const e=this._audio.context,t=this._audio.parent;this._source.loop=this._loop||t.loop;const r=e.volume*(e.muted?0:1),i=t.volume*(t.muted?0:1),n=this._volume*(this._muted?0:1);this._source.volume=n*r*i,this._source.playbackRate=this._playbackRate*e.playbackRate*t.playbackRate}refreshPaused(){if(!this._source||!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,playbackRate:this._playbackRate,loop:this._loop})),this.emit("pause",e))}play(e={}){if(!this._source)return;const{start:t=0,end:r=0}=e;r&&console.assert(r>t,"End time is before start time"),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.volume!==void 0&&(this._volume=e.volume),e.loop!==void 0&&(this._loop=e.loop),e.muted!==void 0&&(this._muted=e.muted),this.refresh(),this.loop&&r!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=r||this._duration,this._start=Math.max(0,this._start-gi.PADDING),this._end=Math.min(this._end+gi.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),Ce.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onUpdate=()=>{this._source&&(this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete())};_onComplete(){Ce.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){Ce.off(this._onUpdate),super.destroy();const e=this._source;e&&(e.onended=null,e.onplay=null,e.onpause=null,this._stop()),this._source=null,this._playbackRate=1,this._volume=1,this._loop=!1,this._end=0,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._audio&&(this._audio.context.off("refresh",this.refresh),this._audio.context.off("refreshPaused",this.refreshPaused),this._audio=null)}}class Kl{constructor(e){this.parent=e}source=new globalThis.Audio;_src="";get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}get duration(){return this.source.duration}get isPlayable(){return!!this.source&&this.source.readyState===4}get context(){return os.instance}async load(){return new Promise(e=>{this.source.onload=()=>e(this),this.source.src=this._src,this.source.load()})}createSound(){return new gi}}class Xn extends Dt{constructor(e,t){super(),this._input=e,this._output=t}_processers=[];get processors(){return this._processers}set processors(e){if(this._processers.forEach(t=>t.disconnect()),this._processers.length=0,this._input.connect(this._output),e.length){this._processers=e.slice(0),this._input.disconnect();let t;e.forEach(r=>{t?t.connect(r.destination):this._input.connect(r.destination),t=r}),t.connect(this._output)}}get destination(){return this._input}}class Bg{constructor(e,t=null){this.destination=e,this.source=t}connect(e){this.source?.connect(e)}disconnect(){this.source?.disconnect()}}function Lg(){if(Ss)return new AudioContext;if(Cs){const s=globalThis.webkitAudioContext;return new s}else throw new Error("Failed to createAudioContext")}function Ng(s,e,t){if(Ts)return new OfflineAudioContext(s,e,t);if(Ao){const r=globalThis.webkitOfflineAudioContext;return new r(s,e,t)}else throw new Error("Failed to createOfflineAudioContext")}class Wt extends Xn{static _instance;static get instance(){return this._instance||(this._instance=new Wt),this._instance}static get audioContext(){return this.instance.audioContext}static get offlineContext(){return this.instance.offlineContext}static setParamValue(e,t){this.instance.setParamValue(e,t)}static decode(e){return this.instance.decode(e)}_context;_offlineContext;get audioContext(){return this._context}get offlineContext(){return this._offlineContext}_locked;muted=!1;volume=1;playbackRate=1;autoPause=!0;_paused=!1;_pausedOnBlur=!1;get paused(){return this._paused}set paused(e){e&&this._context.state==="running"?this._context.suspend():!e&&this._context.state==="suspended"&&this._context.resume(),this._paused=e}_compressor;_analyser;constructor(){const e=Lg(),t=Ng(1,2,Ts?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),r=e.createDynamicsCompressor(),i=e.createAnalyser();i.connect(r),r.connect(e.destination),super(i,r),this._context=e,this._offlineContext=t,this._compressor=r,this._analyser=i,this._locked=e.state==="suspended"&&(Pt||Mo),kr&&(this._locked&&(this._unlock(),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),globalThis.addEventListener("focus",this._onFocus),globalThis.addEventListener("blur",this._onBlur))}_onFocus(){if(!this.autoPause)return;const e=this._context.state;(e==="suspended"||e==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}_onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}_unlock=()=>{this._locked&&(this.playEmptySound(),this._context.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))};playEmptySound(){const e=this._context.createBufferSource();e.buffer=this._context.createBuffer(1,1,22050),e.connect(this._context.destination),e.start(0,0,0),e.context.state==="suspended"&&e.context.resume()}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(e){return new Promise((t,r)=>{const i=o=>{r(new Error(o?.message||"Unable to decode file"))},n=this._offlineContext.decodeAudioData(e,t,i);n&&n.catch(i)})}setParamValue(e,t){e.setValueAtTime?e.setValueAtTime(t,this._context.currentTime):e.value=t}}class Zl extends Dt{_audio=null;_sourceNode=null;_gain=null;_progress=0;get progress(){return this._progress}_pausedReal=!1;_paused=!1;get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh(),this._update(!0))}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}_duration=0;_end=0;_elapsed=0;_lastUpdate=this._now();_processors=[];init(e){return this._audio=e,e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this}_now(){return this._audio?.context.audioContext.currentTime??0}play(e={}){if(!this._audio)return;const{end:t=0,start:r=0}=e;t&&console.assert(t>r,"End time is before start time"),this._end=t,this._elapsed=r,e.volume!==void 0&&(this._volume=e.volume),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.muted!==void 0&&(this._muted=e.muted),e.loop!==void 0&&(this._loop=e.loop),e.processors!==void 0&&(this._processors=e.processors),this._paused=!1;const{source:i,gain:n}=this._audio.cloneSource();this._sourceNode=i,this._gain=n,this.refresh(),i.onended=this._onComplete.bind(this),this._duration=i.buffer?.duration??0,this._lastUpdate=this._now(),this._loop?(i.loopStart=r,i.loopEnd=t,i.start(0,r)):t?i.start(0,r,t-r):i.start(0,r),this.emit("start"),this._update(!0),this._enableTicker(!0)}_stop(){if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.stop(0),this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}this._sourceNode=null}}stop(){this._sourceNode&&(this._stop(),this.emit("stop"))}_update(e=!1){if(this._sourceNode){const t=this._now(),r=t-this._lastUpdate;if(r>0||e){this._elapsed+=r*this._sourceNode.playbackRate.value,this._lastUpdate=t;const i=this._duration;let n;if(this._sourceNode.loopStart){const o=this._sourceNode.loopEnd-this._sourceNode.loopStart;n=(this._sourceNode.loopStart+this._elapsed%o)/i}else n=this._elapsed%i/i;this._progress=n,this.emit("progress",n,i)}}}refresh(){if(!this._audio||!this._sourceNode)return;const e=this._audio.context,t=this._audio.parent;this._sourceNode.loop=this._loop||t.loop,e.setParamValue(this._gain.gain,this._volume*(this._muted?0:1)*t.volume*(t.muted?0:1)*e.volume*(e.muted?0:1)),e.setParamValue(this._sourceNode.playbackRate,this._playbackRate*t.playbackRate*e.playbackRate),this.applyProcessors()}applyProcessors(){if(this._sourceNode&&this._processors.length){this._sourceNode.disconnect();let e=this._sourceNode;this._processors.forEach(t=>{e.connect(t.destination),e=t}),e.connect(this._gain)}}refreshPaused(){if(!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,playbackRate:this._playbackRate,loop:this._loop,volume:this._volume})),this.emit("pause",e))}_onComplete=()=>{if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}}this._sourceNode=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)};_updateListener=()=>this._update();_enableTicker(e){Ce.off(this._updateListener),e&&Ce.on(this._updateListener)}destroy(){super.destroy(),this._stop(),this._gain?.disconnect(),this._gain=null,this._audio?.context.off("refresh",this.refresh),this._audio?.context.off("refreshPaused",this.refreshPaused),this._audio=null,this._processors.forEach(e=>e.disconnect()),this._processors.length=0,this._end=0,this._playbackRate=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}}class Jl extends Xn{constructor(e){const t=Wt.audioContext,r=t.createBufferSource(),i=t.createGain(),n=t.createAnalyser();r.connect(n),n.connect(i),i.connect(Wt.instance.destination),super(n,i),this.parent=e,this._sourceNode=r,this.gain=i,this.analyser=n}_sourceBuffer;_sourceNode;_sourceLoad;gain;analyser;get context(){return Wt.instance}get isPlayable(){return!!this._sourceNode.buffer}get duration(){return this._sourceNode.buffer?.duration??0}get buffer(){return this._sourceNode.buffer}set buffer(e){this._sourceNode.buffer=e}async load(){return this._sourceLoad||(this._sourceLoad=new Promise(e=>{this._sourceBuffer?this._decode(this._sourceBuffer).then(()=>e(this)):this.parent.src?this._loadUrl(this.parent.src).then(()=>e(this)):e(this)})),this._sourceLoad}_loadUrl(e){return new Promise(t=>{fetch(e).then(r=>r.arrayBuffer()).then(r=>this._decode(r)).finally(()=>t(this))})}_decode(e){return Promise.resolve(e instanceof AudioBuffer?e:Wt.decode(e)).then(t=>(this.parent.isLoaded=!0,this.buffer=t,t))}cloneSource(){const e=this.context,t=this._sourceNode,r=e.audioContext.createBufferSource(),i=e.audioContext.createGain();return r.buffer=t.buffer,r.loop=t.loop,e.setParamValue(r.playbackRate,t.playbackRate.value),r.connect(i),i.connect(this.destination),{source:r,gain:i}}createSound(){return new Zl}}var Fg=Object.defineProperty,$g=Object.getOwnPropertyDescriptor,zg=(s,e,t)=>e in s?Fg(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Vg=(s,e,t,r)=>{for(var i=r>1?void 0:r?$g(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i},Gg=(s,e,t)=>zg(s,e+"",t);u.Audio=class extends u.TimelineNode{_sounds=[];_platformAudio=Oo?new Jl(this):new Kl(this);get platformAudio(){return this._platformAudio}_src;get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}isLoaded=!1;get isPlayable(){return this.isLoaded&&this._platformAudio.isPlayable}get audioDuration(){return this._platformAudio.duration*1e3}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}_isPlaying=!1;get isPlaying(){return this._isPlaying}multiple=!1;start=0;end=0;constructor(e=""){super(),this.src=e}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"paused":this.refreshPaused();break}}async load(){return await this._platformAudio.load(),this}pause(){return this._isPlaying=!1,this.paused=!0,this}resume(){return this._isPlaying=this._sounds.length>0,this.paused=!1,this}stop(){if(!this.isPlayable)return this;this._isPlaying=!1;for(let e=this._sounds.length-1;e>=0;e--)this._sounds[e].stop();return this}play(e={}){if(!this.isLoaded)return;this.multiple||this._removeSounds(),this._isPlaying=!0;const t=this._createSound();this._sounds.push(t),t.once("end",()=>{e.complete?.(),this._onComplete(t)}),t.once("stop",()=>this._onComplete(t));const r=(e?.start??this.start)/1e3,i=(e?.end??this.end)/1e3;return t.play({...e,start:r,end:i}),t}_removeSounds(){for(let e=this._sounds.length-1;e>=0;e--)this._recycleSound(this._sounds[e]);this._sounds.length=0}_createSound(){return u.Audio._soundPool.length>0?u.Audio._soundPool.pop().init(this._platformAudio):this._platformAudio.createSound().init(this._platformAudio)}refresh(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refresh()}refreshPaused(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refreshPaused()}_onComplete=e=>{if(this._sounds){const t=this._sounds.indexOf(e);t>-1&&this._sounds.splice(t,1),this._isPlaying=this._sounds.length>0}this._recycleSound(e)};_recycleSound(e){e.destroy(),u.Audio._soundPool.includes(e)||u.Audio._soundPool.push(e)}_prevTime=0;_timer=0;_process(e){if(super._process(e),this.canProcess()){const t=this._tree?.timeline.currentTime??0;t-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(t-this.delay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=t}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},Gg(u.Audio,"_soundPool",[]),u.Audio=Vg([W("Audio")],u.Audio);class jg extends u.Node2D{}var Wg=Object.defineProperty,qg=Object.getOwnPropertyDescriptor,as=(s,e,t,r)=>{for(var i=r>1?void 0:r?qg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Wg(e,t,i),i};u.AudioWaveform=class extends u.Element2D{_audioBuffer;_src=kr?new le(document.createElement("canvas")):void 0;_needsUpdateTexture=!1;constructor(e={}){super(),this.setProperties(e)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._loadSrc(t);break;case"gap":case"color":case"width":case"height":this._needsUpdateTexture=!0;break}}async _loadSrc(e){await globalThis.fetch(e).then(t=>t.arrayBuffer()).then(t=>Wt.decode(t)).then(t=>{this._audioBuffer=t,this.syncTexture(!0)})}syncTexture(e=!1){const t=this._audioBuffer;if(!t||!e&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const r=this._src?.source;if(!r)return;const{width:i=0,height:n=0}=this.style;r.width=i,r.height=n;const o=r.getContext("2d");if(!o){console.warn("Failed to getContext('2d') in syncTexture");return}o.fillStyle=this.color;const a=t.getChannelData(0),l=Math.ceil(a.length/i),c=n/2;for(let h=1,f=-1,d=0;d<i;d++){for(let g=0;g<l;g++){const p=a[d*l+g];p<h&&(h=p),p>f&&(f=p)}if(!this.gap||d%(this.gap*2)===0){const g=d,p=(1+h)*c,y=this.gap||1,m=Math.max(1,(f-h)*c);o.fillRect(g,p,y,m),h=1,f=-1}}this._src?.requestUpload(),this.requestRedraw()}_process(e){this.syncTexture(),super._process(e)}_drawSrc(){const e=this._src;e?.valid&&(this.context.fillStyle=e,this.context.uvTransform=new ve().scale(1/this.style.width,1/this.style.height))}},as([w()],u.AudioWaveform.prototype,"src",2),as([w({fallback:0})],u.AudioWaveform.prototype,"gap",2),as([w({fallback:"#000000"})],u.AudioWaveform.prototype,"color",2),u.AudioWaveform=as([W("AudioWaveform")],u.AudioWaveform);var Xg=Object.getOwnPropertyDescriptor,Hg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Xg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.Control=class extends u.Element2D{constructor(e,t=[]){super(),this._parentUpdateRect=this._parentUpdateRect.bind(this),this.setProperties(e),this.append(t)}_parented(e){super._parented(e),e.on("updateRect",this._parentUpdateRect)}_unparented(e){super._unparented(e),e.off("updateRect",this._parentUpdateRect)}_parentUpdateRect(){const e=this._parent.getRect();this.style.left=e.left,this.style.top=e.top,this.style.width=e.width,this.style.height=e.height}_input(e,t){super._input(e,t),this._guiInput(e,t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":case"height":case"left":case"top":this.emit("updateRect");break}}_guiInput(e,t){}},u.Control=Hg([W("Control")],u.Control);var Yg=Object.defineProperty,Kg=Object.getOwnPropertyDescriptor,qt=(s,e,t,r)=>{for(var i=r>1?void 0:r?Kg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Yg(e,t,i),i};u.Range=class extends u.Control{constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"allowGreater":case"allowLesser":case"page":case"minValue":case"maxValue":case"step":case"value":this.requestRedraw();break}}},qt([w({fallback:!1})],u.Range.prototype,"allowGreater",2),qt([w({fallback:!1})],u.Range.prototype,"allowLesser",2),qt([w({fallback:1})],u.Range.prototype,"page",2),qt([w({fallback:0})],u.Range.prototype,"minValue",2),qt([w({fallback:100})],u.Range.prototype,"maxValue",2),qt([w({fallback:.01})],u.Range.prototype,"step",2),qt([w({fallback:0})],u.Range.prototype,"value",2),u.Range=qt([W("Range")],u.Range);var Zg=Object.defineProperty,Jg=Object.getOwnPropertyDescriptor,vt=(s,e,t,r)=>{for(var i=r>1?void 0:r?Jg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Zg(e,t,i),i};u.Ruler=class extends u.Control{texture=new Ui;constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"offsetX":case"offsetY":case"thickness":case"markHeight":case"color":case"markBackgroundColor":case"markColor":case"gap":case"scale":this.requestRedraw();break}}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":case"height":this.texture[e]=t,this.requestRedraw();break}}_drawTexture(){const{width:e,height:t}=this.size,{offsetX:r,offsetY:i,thickness:n,markHeight:o,markBackgroundColor:a,markColor:l,color:c,gap:h,gapScale:f}=this,g=this.texture.source.getContext("2d");g.reset(),g.scale(this.texture.pixelRatio,this.texture.pixelRatio);const p=Math.round(r),y=Math.round(i);g.beginPath(),g.fillStyle=a||"#EEE",g.fillRect(0,0,e,n),g.fillRect(0,0,n,t),g.fill(),g.strokeStyle=l||"#000",g.moveTo(n,0),g.lineTo(n,t),g.moveTo(0,n),g.lineTo(e,n),g.stroke();const m=h,P=h*f;let E,x,S,_,b;for(m>=P?(E=m/P,x=Math.floor(E)*m/20,S=m/20*Math.floor(E)/E):(E=P/m,x=Math.floor(m/20/E),x>=2?x=Math.floor(x/2)*2:x=1,S=x*E),g.fillStyle=g.strokeStyle,_=p,b=0;_<e;b++,_+=S)g.moveTo(_,n-(b%5?o:2*o)),g.lineTo(_,n);for(_=p,b=0;_>n;b++,_-=S)g.moveTo(_,n-(b%5?o:2*o)),g.lineTo(_,n);let C=0;for(_=y,b=0;_>n;b++,_-=S)g.moveTo(n-(b%5?o:2*o),_),g.lineTo(n,_);for(_=y,b=0;_<t;b++,_+=S)g.moveTo(n-(b%5?o:2*o),_),g.lineTo(n,_);for(g.save(),g.fillStyle=c,g.scale(.8,.8),C=n-8,_=p,b=0;_<e;b++,_+=S)b%10===0&&g.fillText(String(Math.ceil(x*b)),_*1.25-3,C*1.25);for(_=p,b=0;_>n;b++,_-=S)b%10===0&&g.fillText(String(Math.ceil(-x*b)),_*1.25-3,C*1.25);for(C=0,_=y,b=0;_>n;b++,_-=S)b%10===0&&g.fillText(String(Math.ceil(x*b)),C*1.25,_*1.25+3);for(_=y,b=0;_<t;b++,_+=S)b%10===0&&g.fillText(String(Math.ceil(-x*b)),C*1.25,_*1.25+3);g.restore(),g.stroke(),this.texture.requestUpload()}_draw(){this._drawTexture();const e=this.texture;e?.valid&&(this.context.fillStyle=e,this.context.uvTransform=new ve().scale(1/this.size.width,1/this.size.height),this.context.rect(0,0,e.width,e.height),this.context.fill())}},vt([w({fallback:0})],u.Ruler.prototype,"offsetX",2),vt([w({fallback:0})],u.Ruler.prototype,"offsetY",2),vt([w({fallback:20})],u.Ruler.prototype,"thickness",2),vt([w({fallback:3})],u.Ruler.prototype,"markHeight",2),vt([w({fallback:"#b2b6bc"})],u.Ruler.prototype,"color",2),vt([w({fallback:"#f9f9fa"})],u.Ruler.prototype,"markBackgroundColor",2),vt([w({fallback:"#b2b6bc"})],u.Ruler.prototype,"markColor",2),vt([w({fallback:300})],u.Ruler.prototype,"gap",2),vt([w({fallback:1})],u.Ruler.prototype,"gapScale",2),u.Ruler=vt([W("Ruler")],u.Ruler);var Qg=Object.defineProperty,em=Object.getOwnPropertyDescriptor,Ql=(s,e,t,r)=>{for(var i=r>1?void 0:r?em(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Qg(e,t,i),i};u.ScrollBar=class extends u.Range{constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":case"height":case"left":case"top":this.requestRedraw();break}}_rect(){const{size:e,position:t}=this;let r,i,n,o,a;return this.direction==="vertical"?(n=10,o=e.height*(this.page/(this.maxValue-this.minValue)),r=t.left+e.width-n,i=e.height*(this.value/(this.maxValue-this.minValue)),a=n/2):(n=e.width*(this.page/(this.maxValue-this.minValue)),o=10,r=e.width*(this.value/(this.maxValue-this.minValue)),i=t.top+e.height-o,a=o/2),{left:r,top:i,width:n,height:o,radii:a}}_draw(){const{left:e,top:t,width:r,height:i,radii:n}=this._rect();this.context.roundRect(e,t,r,i,n),this.context.fillStyle=34,this.context.fill()}_pointerInput(e,t){const{left:r,top:i,width:n,height:o}=this._rect(),a=e.x>=r&&e.x<r+n&&e.y>=i&&e.y<i+o;switch(t){case"pointerdown":case"pointermove":a?this._tree?.input.setCursor("pointer"):this._tree?.input.setCursor(void 0);break}return!1}},Ql([w({fallback:"vertical"})],u.ScrollBar.prototype,"direction",2),u.ScrollBar=Ql([W("ScrollBar")],u.ScrollBar);var tm=Object.getOwnPropertyDescriptor,rm=(s,e,t,r)=>{for(var i=r>1?void 0:r?tm(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.XScrollBar=class extends u.ScrollBar{constructor(e,t=[]){super(),this.setProperties(e).append(t)}},u.XScrollBar=rm([W("XScrollBar",{direction:"horizontal"})],u.XScrollBar);var im=Object.getOwnPropertyDescriptor,sm=(s,e,t,r)=>{for(var i=r>1?void 0:r?im(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.YScrollBar=class extends u.ScrollBar{constructor(e,t=[]){super(),this.setProperties(e).append(t)}},u.YScrollBar=sm([W("YScrollBar",{direction:"vertical"})],u.YScrollBar);var nm=Object.defineProperty,om=Object.getOwnPropertyDescriptor,Cr=(s,e,t,r)=>{for(var i=r>1?void 0:r?om(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&nm(e,t,i),i};u.Scaler=class extends u.Node{get target(){if(this.parent?.style)return this.parent}constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"translateY":case"translateX":case"scale":case"min":case"max":{this.scale=Ge(this.scale,this.minScale,this.maxScale),this._updateTarget();break}}}_updateTarget(){const e=this.target;e&&(e.style.transform=`translate(${this.translateX}px, ${this.translateY}px) scale(${this.scale})`,this.emit("updateScale",this.scale))}_onWheel(e){this.target&&(e.preventDefault(),e.ctrlKey?(e.wheelDeltaY?Math.abs(Math.abs(e.wheelDeltaY)-Math.abs(3*e.deltaY))<3:e.deltaMode===0)||(e.preventDefault(),this.scale+=e.deltaY*-.015):(this.translateX-=e.deltaX,this.translateY-=e.deltaY))}_input(e,t){switch(super._input(e,t),t){case"wheel":this._onWheel(e);break}}},Cr([w({default:1})],u.Scaler.prototype,"translateX",2),Cr([w({default:1})],u.Scaler.prototype,"translateY",2),Cr([w({default:1})],u.Scaler.prototype,"scale",2),Cr([w({default:.05})],u.Scaler.prototype,"minScale",2),Cr([w({default:10})],u.Scaler.prototype,"maxScale",2),u.Scaler=Cr([W("Scaler",{processMode:"disabled",renderMode:"disabled"})],u.Scaler);var am=Object.defineProperty,lm=Object.getOwnPropertyDescriptor,cm=(s,e,t)=>e in s?am(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,hm=(s,e,t,r)=>{for(var i=r>1?void 0:r?lm(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i},um=(s,e,t)=>cm(s,e+"",t);u.KawaseTransition=class extends u.Transition{blur=10;quality=10;apply(e,t){const r=this.currentTimeProgress;let i,n;r<.5?(i=0,n=(.5-r)/.5):(i=1,n=(r-.5)/.5);const o=this.blur,a=this.quality,l=t.width,c=t.height,h=[],f=[o];if(o>0){let P=o;const E=o/a;for(let x=1;x<a;x++)P-=E,f.push(P)}const d=1/l,g=1/c,p=[];let y;const m=a-1;for(let P=0;P<m;P++)y=f[P]+.5,p[0]=y*d,p[1]=y*g,h.push({offset:p});y=f[m]+.5,p[0]=y*d,p[1]=y*g,h.push({offset:p}),h.forEach(P=>{Q.draw(e,u.KawaseTransition.material,{sampler:i,progress:n,...P})})}},um(u.KawaseTransition,"material",new se({vert:`attribute vec2 position;
867
+ </svg>`}function pg(){const s=new Tt;return{name:"listStyle",pathSet:s,update:e=>{s.paths.length=0;const{paragraphs:t,isVertical:r,fontSize:i}=e,n=i*.45;t.forEach(o=>{const{computedStyle:a}=o,{color:l,listStyleImage:c,listStyleColormap:h,listStyleSize:f,listStyleType:d}=a,g=In(h);let p=f,y;if(!K(c))y=c;else if(!K(d)){const b=i*.38/2;switch(p=p==="cover"?b*2:p,d){case"disc":y=dg(b,String(l));break}}if(!y)return;const m=zs(y),P=m.getBoundingBox(),E=o.fragments[0]?.characters[0];if(!E)return;const{inlineBox:x}=E,S=p==="cover"?1:Dn(p,{total:i,fontSize:i})/i,_=new be;if(r){const b=i/P.height*S;_.translate(-P.left,-P.top).rotate(Math.PI/2).scale(b,b).translate(x.left+(x.width-P.height*b)/2,x.top-n)}else{const b=i/P.height*S;_.translate(-P.left,-P.top).scale(b,b).translate(x.left-P.width*b-n,x.top+(x.height-P.height*b)/2)}s.paths.push(...m.paths.map(b=>{const C=b.clone();return C.applyTransform(_),C.style.fill&&C.style.fill in g&&(C.style.fill=g[C.style.fill]),C.style.stroke&&C.style.stroke in g&&(C.style.stroke=g[C.style.stroke]),C}))})}}}function gg(){return{name:"outline"}}const zt=new k,Pr=new be,Vt=new be;function mg(){const s=new Tt;return{name:"render",pathSet:s,update:e=>{s.paths.length=0;const{paragraphs:t}=e;t.forEach(r=>{r.fragments.forEach(i=>{i.characters.forEach(n=>{s.paths.push(n.path)})})})},getBoundingBox:e=>{const{characters:t,fontSize:r,effects:i}=e,n=[];return t.forEach(o=>{i?.forEach(a=>{if(!o.glyphBox)return;const l=o.glyphBox.clone(),c=Bn(e,a);zt.set(l.left,l.top),zt.applyMatrix3(c),l.left=zt.x,l.top=zt.y,zt.set(l.right,l.bottom),zt.applyMatrix3(c),l.width=zt.x-l.left,l.height=zt.y-l.top;const h=(a.shadowOffsetX??0)*r,f=(a.shadowOffsetY??0)*r,d=Math.max(.1,a.textStrokeWidth??0)*r;l.left+=h-d,l.top+=f-d,l.width+=d*2,l.height+=d*2,n.push(l)})}),n.length?Z.from(...n):void 0},render:(e,t)=>{const{paragraphs:r,glyphBox:i,effects:n}=t;n?n.forEach(o=>{ts(o,i,e),e.save();const[a,l,c,h,f,d]=Bn(t,o).transpose().elements;e.transform(a,h,l,f,c,d),t.forEachCharacter(g=>{g.drawTo(e,o)}),e.restore()}):r.forEach(o=>{o.fragments.forEach(a=>{a.characters.forEach(l=>{l.drawTo(e)})})}),t.debug&&r.forEach(o=>{e.strokeRect(o.lineBox.x,o.lineBox.y,o.lineBox.width,o.lineBox.height)})}}}function Bn(s,e){const{fontSize:t,glyphBox:r}=s,i=(e.translateX??0)*t,n=(e.translateY??0)*t,o=Math.PI*2,a=(e.skewX??0)/360*o,l=(e.skewY??0)/360*o,{left:c,top:h,width:f,height:d}=r,g=c+f/2,p=h+d/2;return Pr.identity(),Vt.makeTranslation(i,n),Pr.multiply(Vt),Vt.makeTranslation(g,p),Pr.multiply(Vt),Vt.set(1,Math.tan(a),0,Math.tan(l),1,0,0,0,1),Pr.multiply(Vt),Vt.makeTranslation(-g,-p),Pr.multiply(Vt),Pr.clone()}function yg(){const s=new Tt;return{name:"textDecoration",pathSet:s,update:e=>{s.paths.length=0;const t=[];let r,i;e.forEachCharacter(n=>{const{computedStyle:o,isVertical:a,inlineBox:l,underlinePosition:c,underlineThickness:h,strikeoutPosition:f,strikeoutSize:d}=n,{color:g,textDecoration:p,writingMode:y}=o;if(K(p))i=void 0;else{let m=!1;if(i?.textDecoration===p&&i?.writingMode===y&&i?.color===g&&(a?r[0].inlineBox.left===l.left:r[0].inlineBox.top===l.top))switch(p){case"underline":r[0].underlinePosition===c&&r[0].underlineThickness===h&&(m=!0);break;case"line-through":r[0].strikeoutPosition===f&&r[0].strikeoutSize===d&&(m=!0);break}m?r.push(n):(r=[],r.push(n),t.push(r)),i=o}}),t.forEach(n=>{const{computedStyle:o,isVertical:a,underlinePosition:l,underlineThickness:c,strikeoutPosition:h,strikeoutSize:f}=n[0],{color:d,textDecoration:g}=o,p=Z.from(...n.map(C=>C.inlineBox)),{left:y,top:m,width:P,height:E}=p;let x=a?y+P:m;const S=a?-1:1;let _=0;switch(g){case"overline":_=c*2;break;case"underline":x+=S*l,_=c*2;break;case"line-through":x+=S*h,_=f*2;break}x-=_;let b;a?b=new ge([{type:"M",x,y:m},{type:"L",x,y:m+E},{type:"L",x:x+_,y:m+E},{type:"L",x:x+_,y:m},{type:"Z"}],{fill:d}):b=new ge([{type:"M",x:y,y:x},{type:"L",x:y+P,y:x},{type:"L",x:y+P,y:x+_},{type:"L",x:y,y:x+_},{type:"Z"}],{fill:d}),s.paths.push(b)})},render:(e,t)=>{const{effects:r,computedStyle:i}=t;r?r.forEach(n=>{e.save();const[o,a,l,c,h,f]=Bn(t,n).transpose().elements;e.transform(o,c,a,h,l,f),s.paths.forEach(d=>{wr({ctx:e,path:d,fontSize:i.fontSize,...n})}),e.restore()}):s.paths.forEach(n=>{wr({ctx:e,path:n,fontSize:i.fontSize})})}}}var _g=Object.defineProperty,Gt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&_g(e,t,i),i};const Fl=vo();class kt extends fo{needsUpdate=!0;computedStyle={...Fl};paragraphs=[];lineBox=new Z;rawGlyphBox=new Z;glyphBox=new Z;pathBox=new Z;boundingBox=new Z;measurer=new rs;plugins=new Map;pathSets=[];get fontSize(){return this.computedStyle.fontSize}get isVertical(){return this.computedStyle.writingMode.includes("vertical")}get characters(){return this.paragraphs.flatMap(e=>e.fragments.flatMap(t=>t.characters))}constructor(e={}){super(),this.set(e)}set(e={}){const{content:t,effects:r,style:i,measureDom:n,fonts:o,fill:a,outline:l}=wo(e);this.debug=e.debug??!1,this.content=t,this.effects=r,this.style=i,this.measureDom=n,this.fonts=o,this.fill=a,this.outline=l,this.use(ug()).use(gg()).use(pg()).use(yg()).use(fg()).use(mg()),(e.plugins??[]).forEach(c=>{this.use(c)}),this.updateParagraphs()}use(e){return this.plugins.set(e.name,e),this}forEachCharacter(e){return this.paragraphs.forEach((t,r)=>{t.fragments.forEach((i,n)=>{i.characters.forEach((o,a)=>{e(o,{paragraphIndex:r,fragmentIndex:n,characterIndex:a})})})}),this}async load(){await Promise.all(Array.from(this.plugins.values()).map(e=>e.load?.(this)))}updateParagraphs(){this.computedStyle={...Fl,...this.style};const{content:e}=this,t=[];return e.forEach((r,i)=>{const{fragments:n,fill:o,outline:a,...l}=r,c=new hg(l,i,this);c.fill=o,c.outline=a,n.forEach((h,f)=>{const{content:d,fill:g,outline:p,...y}=h;if(d!==void 0){const m=new cg(d,y,f,c);c.fragments.push(m),m.fill=g,m.outline=p}}),t.push(c)}),this.paragraphs=t,this}createDom(){return this.updateParagraphs(),this.measurer.createDom(this.paragraphs,this.computedStyle)}measure(e=this.measureDom){const t={paragraphs:this.paragraphs,lineBox:this.lineBox,rawGlyphBox:this.rawGlyphBox,glyphBox:this.glyphBox,pathBox:this.pathBox,boundingBox:this.boundingBox};this.updateParagraphs();const r=this.measurer.measure(this.paragraphs,this.computedStyle,e);this.paragraphs=r.paragraphs,this.lineBox=r.boundingBox,this.characters.forEach(i=>{i.update(this.fonts)}),this.rawGlyphBox=this.getGlyphBox(),Array.from(this.plugins.values()).sort((i,n)=>(i.updateOrder??0)-(n.updateOrder??0)).forEach(i=>{i.update?.(this)}),this.pathSets.length=0,Array.from(this.plugins.values()).sort((i,n)=>(i.renderOrder??0)-(n.renderOrder??0)).forEach(i=>{i.pathSet?.paths.length&&this.pathSets.push(i.pathSet)}),this.glyphBox=this.getGlyphBox(),this.updatePathBox().updateBoundingBox();for(const i in t)r[i]=this[i],this[i]=t[i];return this.emit("measure",{text:this,result:r}),r}getGlyphBox(){const e=k.MAX,t=k.MIN;return this.characters.forEach(r=>{if(!r.getGlyphMinMax(e,t)){const{inlineBox:i}=r,{left:n,top:o,width:a,height:l}=i,c=new k(n,o),h=new k(n+a,o+l);e.min(c,h),t.max(c,h)}}),new Z(e.x,e.y,t.x-e.x,t.y-e.y)}updatePathBox(){return this.pathBox=Z.from(this.glyphBox,...Array.from(this.plugins.values()).map(e=>e.getBoundingBox?e.getBoundingBox(this):e.pathSet?.getBoundingBox()).filter(Boolean)),this}updateBoundingBox(){return this.boundingBox=Z.from(this.rawGlyphBox,this.lineBox,this.pathBox),this}requestUpdate(){return this.needsUpdate=!0,this}update(e=this.measureDom){const t=this.measure(e);for(const r in t)this[r]=t[r];return this.emit("update",{text:this}),this.needsUpdate=!1,this}render(e){const{view:t,pixelRatio:r=2}=e,i=t.getContext("2d");i&&(this.needsUpdate&&this.update(),rg(i,r,this.boundingBox),ig(i,this),Array.from(this.plugins.values()).sort((n,o)=>(n.renderOrder??0)-(o.renderOrder??0)).forEach(n=>{if(n.render)n.render?.(i,this);else if(n.pathSet){const o=this.computedStyle;n.pathSet.paths.forEach(a=>{wr({ctx:i,path:a,fontSize:o.fontSize})})}}),this.emit("render",{text:this,view:t,pixelRatio:r}),e.onContext?.(i))}toString(){return this.content.flatMap(e=>e.fragments.map(t=>t.content)).join("")}}Gt([w({internal:!0})],kt.prototype,"debug"),Gt([w()],kt.prototype,"content"),Gt([w()],kt.prototype,"style"),Gt([w()],kt.prototype,"effects"),Gt([w()],kt.prototype,"fill"),Gt([w()],kt.prototype,"outline"),Gt([w({internal:!0})],kt.prototype,"measureDom"),Gt([w({internal:!0})],kt.prototype,"fonts");var vg=Object.defineProperty,jt=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&vg(e,t,i),i};class vt extends It{constructor(e){super(),this.parent=e,this.base=new kt().setPropertyAccessor(this)}base;measureResult;_textureMap=new Map;setProperties(e){return super.setProperties(K(e)?void 0:wo(e))}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"enabled":case"effects":case"measureDom":case"fonts":this.parent.requestRedraw();break;case"fill":case"outline":case"content":this._updateTextureMap();break}}_updateBase(){this.base.fonts=this.base.fonts??this.parent.tree?.fonts,this.base.update()}_updateTextureMap(){this._updateBase(),this._textureMap.clear();const e=[];if(this.base.paragraphs.forEach((t,r)=>{const i=[];if(t.fragments.forEach((n,o)=>{if(n.characters.length){const a=Z.from(...n.characters.map(l=>l.compatibleGlyphBox));this._updateTexture(`${r}.${o}.fill`,n.fill,a),this._updateTexture(`${r}.${o}.outline`,n.outline,a),i.push(a)}}),i.length){const n=Z.from(...i);this._updateTexture(`${r}.fill`,t.fill,n),this._updateTexture(`${r}.outline`,t.outline,n),e.push(n)}}),e.length){const t=Z.from(...e);this._updateTexture("fill",this.fill,t),this._updateTexture("outline",this.outline,t)}this.parent.requestRedraw()}async _updateTexture(e,t,r){t&&Object.keys(t).length>0&&(this._textureMap.set(e,{texture:await this._loadTexture(t,r),box:r}),this.parent.requestRedraw())}async _loadTexture(e,t){return e.linearGradient||e.radialGradient?new $r(e.linearGradient??e.radialGradient,t.width,t.height):K(e.image)?void 0:(this.parent.tree?.log(`load image ${e.image}`),await nt.texture.load(e.image))}setContent(e){this.content=vs(e)}measure(){return this._updateBase(),this.base.measure()}updateMeasure(){return this.measureResult=this.measure(),this}canDraw(){return!!(this.enabled&&!/^\s*$/.test(this.base.toString()))}_getVertTransform(){const e=this.parent;if(e.scale.x>0&&e.scale.y>0)return;const t=e.scale.x*e.scale.y,r=e.getTransformOrigin();return new ve().translate(-r.x,-r.y).scale(t>0?1:-1,1).translate(r.x,r.y)}draw(){const e=this.parent.context;this._updateBase(),this.base.pathSets.forEach(t=>{t.paths.forEach(r=>{const i=r.getMeta();if(i instanceof Bl){const n=i.parent.index,o=i.parent.parent.index;if(r.style.fill&&!K(r.style.fill))if(typeof r.style.fill=="object"){const a=r.style.fill,l=this._textureMap.get(`${o}.${n}.fill`)??this._textureMap.get(`${o}.fill`)??this._textureMap.get("fill");if(a.enabled!==!1&&(l||a.color)){const{uvTransform:c,disableWrapMode:h}=Li(a,l?.box??{width:this.parent.size.width,height:this.parent.size.height});e.addPath(r),e.style={...r.style},e.uvTransform=c,e.fillStyle=l?.texture??a.color,e.vertTransform=this._getVertTransform(),e.fill({disableWrapMode:h})}}else e.addPath(r),e.style={...r.style},e.vertTransform=this._getVertTransform(),e.fill();if(r.style.stroke&&!K(r.style.stroke))if(typeof r.style.stroke=="object"){const a=r.style.stroke,l=this._textureMap.get(`${o}.${n}.outline`)??this._textureMap.get(`${o}.outline`)??this._textureMap.get("outline");if(a.enabled!==!1&&(l||a.color)&&(a.width===void 0||a.width)){const{uvTransform:c,disableWrapMode:h}=Li(a,l?.box??{width:this.parent.size.width,height:this.parent.size.height});e.addPath(r),e.style={...r.style},e.lineWidth=a.width||1,e.uvTransform=c,e.strokeStyle=l?.texture??a.color,e.lineCap=a.lineCap,e.lineJoin=a.lineJoin,e.vertTransform=this._getVertTransform(),e.stroke({disableWrapMode:h})}}else e.addPath(r),e.style={...r.style},e.vertTransform=this._getVertTransform(),e.stroke()}})})}}jt([w({fallback:!0})],vt.prototype,"enabled"),jt([w({fallback:()=>[]})],vt.prototype,"content"),jt([w({alias:"parent.style.json"})],vt.prototype,"style"),jt([w()],vt.prototype,"effects"),jt([w()],vt.prototype,"fill"),jt([w()],vt.prototype,"outline"),jt([w({alias:"base.measureDom"})],vt.prototype,"measureDom"),jt([w({alias:"base.fonts"})],vt.prototype,"fonts");var bg=Object.getOwnPropertyDescriptor,wg=(s,e,t,r)=>{for(var i=r>1?void 0:r?bg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.BaseElement2D=class extends u.Node2D{size=new de().on("update",()=>{this.updateGlobalTransform(),this.requestRedraw()});get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}_background=new nn(this);get background(){return this._background}set background(e){this._background.resetProperties().setProperties(e)}_shape=new Qt(this);get shape(){return this._shape}set shape(e){this._shape.resetProperties().setProperties(e)}_fill=new Te(this);get fill(){return this._fill}set fill(e){this._fill.resetProperties().setProperties(e)}_outline=new Zt(this);get outline(){return this._outline}set outline(e){this._outline.resetProperties().setProperties(e)}_foreground=new on(this);get foreground(){return this._foreground}set foreground(e){this._foreground.resetProperties().setProperties(e)}_text=new vt(this);get text(){return this._text}set text(e){this._text.resetProperties().setProperties(e)}_shadow=new Jt(this);get shadow(){return this._shadow}set shadow(e){this._shadow.resetProperties().setProperties(e)}constructor(e,t=[]){super(),this._updateStyleProperty=this._updateStyleProperty.bind(this),this.style=new Qr,this.setProperties(e).append(t)}setProperties(e){if(e){const{style:t,text:r,shape:i,background:n,fill:o,outline:a,foreground:l,shadow:c,...h}=e;t&&this.style.setProperties(t),n&&this.background.setProperties(n),i&&this.shape.setProperties(i),o&&this.fill.setProperties(o),a&&this.outline.setProperties(a),r&&this.text.setProperties(r),l&&this.foreground.setProperties(l),c&&this.shadow.setProperties(c),super.setProperties(h)}return this}_updateStyleProperty(e,t,r){switch(e){case"rotate":this.rotation=this.style.rotate*Go;break;case"scaleX":this.scale.x=this.style.scaleX,this.text.canDraw()&&(t^r)<0&&this.requestRedraw();break;case"scaleY":this.scale.y=this.style.scaleY,this.text.canDraw()&&(t^r)<0&&this.requestRedraw();break;case"skewX":this.skew.x=this.style.skewX;break;case"skewY":this.skew.y=this.style.skewY;break;case"transform":case"transformOrigin":this.updateGlobalTransform();break;case"opacity":this.opacity=this.style.opacity;break;case"visibility":this.visible=this.style.visibility==="visible";break;case"filter":this.requestRepaint();break;case"maskImage":this._updateMaskImage();break;case"backgroundColor":this.background.color=this.style.backgroundColor;break;case"backgroundImage":this.background.image=this.style.backgroundImage;break;case"borderStyle":case"outlineStyle":this.outline.style=t;break;case"borderWidth":case"outlineWidth":this.outline.width=t;break;case"borderColor":case"outlineColor":this.outline.color=t;break;case"borderRadius":default:this.requestRedraw();break}}_updateMaskImage(){const e="__$style.maskImage",t=this.style.maskImage;if(t&&t!=="none"){const r=this.getNode(e);r?r.src=t:this.appendChild(new u.MaskEffect({name:e,src:t}),"back")}else{const r=this.getNode(e);r&&this.removeChild(r)}}getTransformOrigin(){const{width:e,height:t}=this.size,[r,i]=Ga(this.style.transformOrigin);return new de(r*e,i*t)}updateTransform(e){const{width:t,height:r}=this.size;super.updateTransform(i=>{Va(this.style.transform??"",t,r,i),e?.(i)})}updateGlobalTransform(){super.updateGlobalTransform(),this._updateOverflow()}getRect(){return this.getGlobalAabb()}_getPointArray(){const{width:e,height:t}=this.size,r=0,i=0,n=r+e,o=i+t;return[{x:r,y:i},{x:r,y:o},{x:n,y:i},{x:n,y:o}]}getAabb(){return new Rt(this._getPointArray().map(e=>this.transform.apply(e)))}getGlobalAabb(){return new Rt(this._getPointArray().map(e=>this.globalTransform.apply(e)))}getObb(){const e=this.getTransformOrigin(),t=this.transform.apply(e).sub(e);return{rect:new Rt(this._getPointArray().map(r=>(r.x+=t.x,r.y+=t.y,r))),rotation:this.rotation}}getGlobalObb(){const e=this.getTransformOrigin(),t=this.globalTransform.apply(e).sub(e);return{rect:new Rt(this._getPointArray().map(r=>(r.x+=t.x,r.y+=t.y,r))),rotation:this.globalRotation}}_updateOverflow(){this.style.overflow==="hidden"?this.mask=this.getRect().toJSON():this.mask=void 0}_draw(){super._draw(),this._text.canDraw()&&this._text.updateMeasure(),this._background.canDraw()&&(this._tree?.log(this.name,"background drawing"),this._background.fillWithShape?this._shape.draw():this._shape.drawRect(),this._background.draw()),this._fill.canDraw()&&(this._tree?.log(this.name,"fill drawing"),this._shape.draw(),this._fill.draw()),this._outline.canDraw()&&(this._tree?.log(this.name,"outline drawing"),this._shape.draw(),this._outline.draw()),this._foreground.canDraw()&&(this._tree?.log(this.name,"foreground drawing"),this._foreground.fillWithShape?this._shape.draw():this._shape.drawRect(),this._foreground.draw()),this._text.canDraw()&&(this._tree?.log(this.name,"text drawing"),this._text.draw()),this._drawContent()}_drawContent(){}_repaint(e){return super._repaint(e).map(t=>({...t}))}canPointerEvents(){return this.style.pointerEvents!=="none"}input(e,t){const r=this.getChildren(!0);for(let i=r.length-1;i>=0;i--)r[i].input(e,t);this.isVisibleInTree()&&this._input(e,t)}_positionInput(e,t){const{width:r,height:i}=this.size;return e.x>=0&&e.x<r&&e.y>=0&&e.y<i}_input(e,t){switch(t){case"pointerdown":case"pointermove":case"pointerup":{if(this.canPointerEvents()){const{screenX:r,screenY:i}=e;if(r&&i){const n=new de(r,i),o=this.getViewport();o&&o.toCanvasGlobal(n,n),this.toLocal(n,n),this._positionInput(n,t)&&(e.target||(e.target=this),this.emit(t,e))}}break}}}toJSON(){const e=t=>Object.keys(t).length>0?t:void 0;return Ve({...super.toJSON(),style:e(this.style.toJSON()),background:e(this.background.toJSON()),shape:e(this.shape.toJSON()),fill:e(this.fill.toJSON()),outline:e(this.outline.toJSON()),text:e(this.text.toJSON()),foreground:e(this.foreground.toJSON()),shadow:e(this.shadow.toJSON())})}},u.BaseElement2D=wg([W("BaseElement2D")],u.BaseElement2D);class Ln extends Qr{constructor(e){super(),this.setProperties(e)}}const $l={left:0,top:0,width:0,height:0};for(const s in $l)yi(Ln,s,{fallback:$l[s]});class zl extends Qr{constructor(e){super(),this.setProperties(e)}}var xg=Object.getOwnPropertyDescriptor,Pg=(s,e,t,r)=>{for(var i=r>1?void 0:r?xg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.Element2D=class extends u.BaseElement2D{get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}constructor(e,t=[]){super(),this.style=new Ln,this.setProperties(e).append(t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"left":this.position.x=Number(t);break;case"top":this.position.y=Number(t);break;case"width":this.size.width=Number(t);break;case"height":this.size.height=Number(t);break}switch(e){case"width":case"height":this.mask instanceof u.BaseElement2D&&(this.mask.size.width=this.size.width,this.mask.size.height=this.size.height);break}}},u.Element2D=Pg([W("Element2D")],u.Element2D);const fe={left:0,top:1,right:2,bottom:3,start:4,end:5,horizontal:6,vertical:7,all:8},Vl={column:0,row:1,all:2},nr={auto:0,"flex-start":1,center:2,"flex-end":3,stretch:4,baseline:5,"space-between":6,"space-around":7,"space-evenly":8},Nn={flex:0,none:1,contents:2},is={inherit:0,ltr:1,rtl:2},Fn={column:0,"column-reverse":1,row:2,"row-reverse":3},$n={"no-wrap":0,wrap:1,"Wrap-reverse":2},zn={"flex-start":0,center:1,"flex-end":2,"space-between":3,"space-around":4,"space-evenly":5},Vn={visible:0,hidden:1,scroll:2},Gn={static:0,relative:1,absolute:2},jn={"border-box":0,"content-box":1};class ss{constructor(e){this._element=e}static _yoga;static async load(){const{loadYoga:e}=await import("yoga-layout/load");this._yoga=await e()}_node=ss._yoga.Node.create();get _style(){return this._element.style}get offsetLeft(){return this._node.getComputedLeft()}get offsetTop(){return this._node.getComputedTop()}get offsetWidth(){return this._node.getComputedWidth()}get offsetHeight(){return this._node.getComputedHeight()}calculateLayout(e,t,r){return this._node.calculateLayout(e,t,r)}getComputedLayout(){return this._node.getComputedLayout()}updateStyleProperty(e,t,r){switch(e){case"alignContent":this._node.setAlignContent(t?nr[t]:nr["flex-start"]);break;case"alignItems":this._node.setAlignItems(t?nr[t]:nr["flex-start"]);break;case"alignSelf":this._node.setAlignSelf(t?nr[t]:nr["flex-start"]);break;case"aspectRatio":this._node.setAspectRatio(t);break;case"borderTop":this._node.setBorder(fe.top,this._style.borderWidth);break;case"borderBottom":this._node.setBorder(fe.bottom,this._style.borderWidth);break;case"borderLeft":this._node.setBorder(fe.left,this._style.borderWidth);break;case"borderRight":this._node.setBorder(fe.right,this._style.borderWidth);break;case"border":this._node.setBorder(fe.all,this._style.borderWidth);break;case"direction":this._node.setDirection(t?is[t]:is.inherit);break;case"display":this._node.setDisplay(t?Nn[t]:Nn.flex);break;case"flex":this._node.setFlex(this._style.flex);break;case"flexBasis":this._node.setFlexBasis(this._style.flexBasis);break;case"flexDirection":this._node.setFlexDirection(t?Fn[t]:Fn.row);break;case"flexGrow":this._node.setFlexGrow(this._style.flexGrow);break;case"flexShrink":this._node.setFlexShrink(this._style.flexShrink);break;case"flexWrap":this._node.setFlexWrap(t?$n[t]:$n.wrap);break;case"height":this._node.setHeight(this._style.height);break;case"justifyContent":this._node.setJustifyContent(t?zn[t]:zn["flex-start"]);break;case"gap":t!==void 0&&this._node.setGap(Vl.all,t);break;case"marginTop":this._node.setMargin(fe.top,t);break;case"marginBottom":this._node.setMargin(fe.bottom,t);break;case"marginLeft":this._node.setMargin(fe.left,t);break;case"marginRight":this._node.setMargin(fe.right,t);break;case"margin":this._node.setMargin(fe.all,t);break;case"maxHeight":this._node.setMaxHeight(t);break;case"maxWidth":this._node.setMaxWidth(t);break;case"minHeight":this._node.setMinHeight(this._style.minHeight);break;case"minWidth":this._node.setMinWidth(this._style.minWidth);break;case"overflow":this._node.setOverflow(t?Vn[t]:Vn.visible);break;case"paddingTop":this._node.setPadding(fe.top,this._style.paddingTop);break;case"paddingBottom":this._node.setPadding(fe.bottom,this._style.paddingBottom);break;case"paddingLeft":this._node.setPadding(fe.left,this._style.paddingLeft);break;case"paddingRight":this._node.setPadding(fe.right,this._style.paddingRight);break;case"padding":this._node.setPadding(fe.all,this._style.padding);break;case"top":this._node.setPosition(fe.top,this._style.top);break;case"bottom":this._node.setPosition(fe.bottom,this._style.bottom);break;case"left":this._node.setPosition(fe.left,this._style.left);break;case"right":this._node.setPosition(fe.right,this._style.right);break;case"position":this._node.setPositionType(t?Gn[t]:Gn.static);break;case"boxSizing":this._node.setBoxSizing(t?jn[t]:jn["content-box"]);break;case"width":this._node.setWidth(this._style.width);break}}}var Sg=Object.getOwnPropertyDescriptor,Cg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Sg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.FlexElement2D=class extends u.BaseElement2D{get style(){return this._style}set style(e){const t=(...r)=>{this.emit("updateStyleProperty",r[0],r[1],r[2]),this._updateStyleProperty(r[0],r[1],r[2])};e.on("updateProperty",t),this._style?.off("updateProperty",t),this._style=e}_layout=new ss(this);get offsetLeft(){return this._layout.offsetLeft}get offsetTop(){return this._layout.offsetTop}get offsetWidth(){return this._layout.offsetWidth}get offsetHeight(){return this._layout.offsetHeight}constructor(e,t=[]){super(),this.style=new zl,this.setProperties(e).append(t)}_parented(e){super._parented(e),e._layout&&this._layout._node&&e._layout._node.insertChild(this._layout._node,e._layout._node.getChildCount())}_unparented(e){super._unparented(e),e._layout?._node&&e._layout._node.removeChild(this._layout._node)}_updateStyleProperty(e,t,r){super._updateStyleProperty(e,t,r),this._layout.updateStyleProperty(e,t,r),this._layout._node.isDirty()&&this.requestRelayout()}updateTransform(){this.calculateLayout(void 0,void 0,is.ltr);const{left:e,top:t,width:r,height:i}=this._layout.getComputedLayout();this.position.x=e,this.position.y=t,this.size.x=r,this.size.y=i,super.updateTransform()}calculateLayout(e,t,r){const i=this.getParent();i?._layout?.calculateLayout?i?._layout.calculateLayout(e,t,r):this._layout.calculateLayout(e,t,r)}},u.FlexElement2D=Cg([W("FlexElement2D")],u.FlexElement2D);var Tg=Object.defineProperty,Eg=Object.getOwnPropertyDescriptor,di=(s,e,t,r)=>{for(var i=r>1?void 0:r?Eg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Tg(e,t,i),i};u.Image2D=class extends u.Element2D{get currentFrameTexture(){return this.texture?.frames[this._frameIndex]?.texture}get textureDuration(){return this.texture?.duration??0}get naturalWidth(){return this.currentFrameTexture?.realWidth??0}get naturalHeight(){return this.currentFrameTexture?.realHeight??0}get complete(){return this._complete}_frameIndex=0;_complete=!1;_wait=Promise.resolve();constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._wait=this._load(t);break;case"srcRect":this.requestRedraw();break}}decode(){return this._wait}setResource(e){let t;if(e instanceof Ri?t=e:t=new Ri(e),this.texture=t.updateDuration(),this.currentFrameTexture&&(!this.style.width||!this.style.height)){const r=this.currentFrameTexture;this.style.width=r.realWidth,this.style.height=r.realHeight}return this}async _load(e){if(this._complete=!1,e)try{this.setResource(this.gif||e?.includes(".gif")?await nt.gif.load(e):await nt.texture.load(e)),this.requestRedraw(),this.emit("load")}catch(t){console.warn(t),this.emit("error",t)}else this.texture=void 0;this._complete=!0}_getFrameCurrentTime(){const e=this.textureDuration;if(!e||!this._tree)return 0;const t=this._currentTime;return t<0?0:t%e}_updateFrameIndex(){if(!this.texture)return this;const e=this._getFrameCurrentTime(),t=this.texture.frames,r=t.length;if(r<=1&&this._frameIndex===0)return this;let i=r-1;for(let n=0,o=0;o<r;o++)if(n+=t[o].duration??0,n>=e){i=o;break}return this._frameIndex!==i&&(this._frameIndex=i,this.requestRedraw()),this}_process(e){this._updateFrameIndex(),super._process(e)}_drawContent(){const e=this.currentFrameTexture;if(e?.valid){const{left:t=0,top:r=0,right:i=0,bottom:n=0}=this.srcRect??{},{width:o,height:a}=this.size;this.context.fillStyle=e;const l=Math.abs(1+(t+i))*o,c=Math.abs(1+(r+n))*a,h=1/l,f=1/c,d=t*o*h,g=r*a*f;this.context.uvTransform=new ve().scale(h,f).translate(d,g),this.shape.draw(),this.context.fill()}}_repaint(e){return super._repaint(e).map(t=>({...t,disableWrapMode:!0}))}},di([w({internal:!0})],u.Image2D.prototype,"texture",2),di([w({fallback:""})],u.Image2D.prototype,"src",2),di([w()],u.Image2D.prototype,"srcRect",2),di([w({fallback:!1})],u.Image2D.prototype,"gif",2),u.Image2D=di([W("Image2D")],u.Image2D);class Wn extends u.Element2D{texture;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_drawContent(){if(this.texture?.valid){const{width:e,height:t}=this.size;this.context.fillStyle=this.texture,this.context.uvTransform=new ve().scale(1/e,1/t),this.shape.drawRect(),this.context.fill()}}}var Mg=Object.defineProperty,Ag=Object.getOwnPropertyDescriptor,Gl=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ag(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Mg(e,t,i),i};u.Lottie2D=class extends Wn{texture=new Ui;animation;constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._load();break}}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":this.texture.width=this.style.width;break;case"height":this.texture.height=this.style.height;break}}async _load(){this.animation=await nt.lottie.load(this.src,this.texture.source),this.duration=this.animation.getDuration(!1)*1e3,this.texture.requestUpload(),this.requestRedraw()}_process(e){this.animation?.goToAndStop(this.currentTime,!1),this.texture.requestUpload(),this.requestRedraw(),super._process(e)}},Gl([w({fallback:""})],u.Lottie2D.prototype,"src",2),u.Lottie2D=Gl([W("Lottie2D")],u.Lottie2D);var Og=Object.defineProperty,kg=(s,e,t,r)=>{for(var i=void 0,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(e,t,i)||i);return i&&Og(e,t,i),i};class qn extends u.Element2D{constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":case"height":this.requestRedraw();break}}_drawCircle(e,t){this.context.arc(e,t,this.handleSize,0,Math.PI*2,!0),this.context.fillStyle=le.WHITE,this.context.fill(),this.context.arc(e,t,this.handleSize,0,Math.PI*2,!0),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_drawEllipse(e,t){this.context.roundRect(e-this.handleSize,t-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.fillStyle=le.WHITE,this.context.fill(),this.context.roundRect(e-this.handleSize,t-this.handleSize*2,this.handleSize*2,this.handleSize*4,this.handleSize),this.context.strokeStyle="rgba(0, 0, 0, 0.2)",this.context.stroke()}_draw(){const{width:e,height:t}=this.getRect();this.context.rect(0,0,e,t),this.context.strokeStyle="#00FF00",this.context.stroke(),this._drawCircle(0,0),this._drawCircle(e,t),this._drawCircle(0,t),this._drawEllipse(0,t/2),this._drawCircle(e,0),this._drawEllipse(e,t/2)}}kg([w({fallback:6})],qn.prototype,"handleSize");var Dg=Object.defineProperty,Ig=Object.getOwnPropertyDescriptor,jl=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ig(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Dg(e,t,i),i};u.Video2D=class extends Wn{get videoDuration(){return(this.texture?.duration??0)*1e3}_wait=Promise.resolve();constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._wait=this._load(t);break}}waitLoad(){return this._wait}async _load(e){this.texture=await nt.video.load(e),(!this.style.width||!this.style.height)&&(this.style.width=this.texture.width,this.style.height=this.texture.height),this.requestRedraw()}_updateVideoCurrentTime(){let e=this._currentTime;if(e<0)return;const t=this.texture;if(!t)return;const r=t.duration;e=r?e%(r*1e3):0,!t.isPlaying&&!t.seeking&&(e=~~e/1e3,t.currentTime!==e&&(t.currentTime=e))}_process(e){this._updateVideoCurrentTime(),super._process(e)}},jl([w({fallback:""})],u.Video2D.prototype,"src",2),u.Video2D=jl([W("Video2D")],u.Video2D);var Rg=Object.defineProperty,Ug=Object.getOwnPropertyDescriptor,pi=(s,e,t,r)=>{for(var i=r>1?void 0:r?Ug(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Rg(e,t,i),i};const Wl=s=>s,ql=Sr(.25,.1,.25,1),Xl=Sr(.42,0,1,1),Hl=Sr(0,0,.58,1),Yl=Sr(.42,0,.58,1);function Sr(s,e,t,r){const n=3*s-3*t+1,o=3*t-6*s,a=3*s,l=3*e-3*r+1,c=3*r-6*e,h=3*e,f=y=>(3*n*y+2*o)*y+a,d=y=>((n*y+o)*y+a)*y,g=y=>((l*y+c)*y+h)*y;function p(y){let m=y,P,E;for(let _=0;_<8;_++){if(E=d(m)-y,Math.abs(E)<1e-6)return m;if(P=f(m),Math.abs(P)<1e-6)break;m-=E/P}let x=1,S=0;for(m=y;x>S;){if(E=d(m)-y,Math.abs(E)<1e-6)return m;E>0?x=m:S=m,m=(x+S)/2}return m}return y=>g(p(y))}const ns={linear:Wl,ease:ql,easeIn:Xl,easeOut:Hl,easeInOut:Yl};u.Animation=class extends u.TimelineNode{_keyframes=[];_isFirstUpdatePosition=!1;_cachedProps=new ao;_stoped=!1;constructor(e,t=[]){super(),this.setProperties(e).append(t)}_parented(e){super._parented(e),this._updateCachedProps()}_unparented(e){super._unparented(e),this.cancel()}_process(){this.canProcess()&&this.commitStyles()}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"effectMode":case"keyframes":this._updateKeyframes();break}}_getTargets(){let e;switch(this.effectMode){case"sibling":e=this.getParent()?.getChildren(!0).filter(t=>t instanceof u.CanvasItem)??[];break;case"parent":default:e=[this.getParent()].filter(Boolean);break}return e.map(t=>t.style)}_updateKeyframes(){const e=[],t=this.keyframes;for(let n=t.length,o=0;o<n;o++){const{offset:a=o===0?0:o/(n-1),easing:l="linear",...c}=t[o];e.push({offset:a,easing:this._parseEasing(l),props:c})}const r=e[0],i=e[e.length-1];r&&r.offset!==0&&e.unshift({offset:0,easing:this._parseEasing("linear"),props:{}}),i&&i.offset!==1&&e.push({offset:1,easing:this._parseEasing("linear"),props:{}}),this._keyframes=e,this._updateCachedProps()}commitStyles(){if(!this.keyframes.length)return;if(this._updateCurrentTime(),this.isInsideTimeRange())this._isFirstUpdatePosition||(this._isFirstUpdatePosition=!0,this._updateCachedProps());else{if(!this._isFirstUpdatePosition)return;this._isFirstUpdatePosition=!1}const e=this._getTargets(),t=1/e.length,r=this.currentTimeProgress;e.forEach((i,n)=>{const o=t===1?r:Ge(Math.max(0,r-t*n)/t,0,1),a=this._cachedProps.get(i);if(!a)return;const l=this._parseKeyframes(o,a);l?.length&&this._commitStyle(o,i,a,l[0],l[1])})}_updateCachedProps(){this.cancel(),this._getTargets().forEach(e=>{const t=new Map,r=this._keyframes;for(let i=r.length,n=0;n<i;n++)Object.keys(r[n].props).forEach(o=>{t.set(o,e[o])});this._cachedProps.set(e,t)})}_parseEasing(e){if(!e)return ns.linear;if(e in ns)return ns[e];const t=e.replace(/cubic-bezier\((.+)\)/,"$1").split(",").map(r=>Number(r));return Sr(t[0],t[1],t[2],t[3])}_parseKeyframes(e,t){let r;const i=this._keyframes;for(let n=i.length,o=0;o<n;o++){const a=i[o],{offset:l,easing:c}=a,h={...a.props};if(r&&e<=l){const{offset:f,easing:d}=r,g={...r.props};return t.forEach((p,y)=>{(!(y in g)||g[y]===null)&&(g[y]=p),(!(y in h)||h[y]===null)&&(h[y]=p)}),[{offset:f,easing:d,props:g},{offset:l,easing:c,props:h}]}r=a}return null}_commitStyle(e,t,r,i,n){const{offset:o,easing:a,props:l}=i,{offset:c,props:h}=n,f=c-o,d=a((e-o)/f),g={width:t.width,height:t.height,fontSize:t.fontSize};r.forEach((p,y)=>{t[y]=this._getDiffValue(y,l[y],h[y],d,g)})}_getDiffValue(e,t,r,i,n){let o,a;if(t==="none"&&(t=void 0),r==="none"&&(r=void 0),t===void 0||r===void 0)if(t!==void 0)o=Ar(e,String(t),n),a=xs(o);else if(r!==void 0)a=Ar(e,String(r),n),o=xs(a);else return;else o=Ar(e,String(t),n),a=Ar(e,String(r),n);if(Array.isArray(o)&&Array.isArray(a)){const l=new Set,c={},h={};o.forEach(({name:d,args:g})=>{c[d]=g,l.add(d)}),a.forEach(({name:d,args:g})=>{h[d]=g,l.add(d)});let f="";return l.forEach(d=>{const g=Math.max(c[d]?.length??0,h[d]?.length??0),p=c[d],y=h[d];f+=`${d}(${Array.from({length:g},(m,P)=>{const E=p?.[P],x=y?.[P],S=E?.normalizedIntValue??0,_=x?.normalizedIntValue??0;return Number.isNaN(S)||Number.isNaN(_)?x?.value??0:he(S,_,i)}).join(", ")}) `}),f}else if(!Array.isArray(o)&&!Array.isArray(a))return Number.isNaN(o.normalizedIntValue)||Number.isNaN(a.normalizedIntValue)?a.value:he(o.normalizedIntValue,a.normalizedIntValue,i)}isPlaying(){return!this.paused&&this.isInsideTimeRange()}play(){return this._stoped?(this._stoped=!1,this.startTime=this.timelineCurrentTime):this.startTime=this.timelineCurrentTime-this.currentTime,this.paused=!1,!0}pause(){return this.paused=!0,!0}stop(){return this._stoped=!0,this.paused=!0,this._currentTime=0,!0}cancel(){this._getTargets().forEach(e=>{this._cachedProps.get(e)?.forEach((t,r)=>{e[r]=t}),this._cachedProps.delete(e)})}},pi([w({fallback:"parent"})],u.Animation.prototype,"effectMode",2),pi([w({fallback:!1})],u.Animation.prototype,"loop",2),pi([w({default:()=>[]})],u.Animation.prototype,"keyframes",2),pi([w()],u.Animation.prototype,"easing",2),u.Animation=pi([W("Animation",{renderMode:"disabled",processMode:"pausable",processSortMode:"parent_before",duration:2e3})],u.Animation);class os extends Dt{static _instance;static get instance(){return this._instance||(this._instance=new os),this._instance}playbackRate=1;muted=!1;volume=1;paused=!1;refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}}class gi extends Dt{static PADDING=.1;_source=null;_audio=null;_end=0;_pausedReal=!1;_duration=0;_start=0;_playing=!1;get progress(){return(this._source?.currentTime??0)/this._duration}_paused=!1;get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}set(e,t){if(this[e]===void 0)throw new Error(`Property with name ${e} does not exist.`);switch(e){case"playbackRate":this.playbackRate=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(e){this._playing=!1,this._duration=e.source.duration;const t=this._source=e.source.cloneNode(!1);return t.src=e.parent.src,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this._audio=e,this}_stop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._stop(),this._source&&this.emit("stop")}get processors(){return console.warn("HTML Audio does not support processors"),[]}set processors(e){console.warn("HTML Audio does not support processors")}refresh(){if(!this._audio||!this._source)return;const e=this._audio.context,t=this._audio.parent;this._source.loop=this._loop||t.loop;const r=e.volume*(e.muted?0:1),i=t.volume*(t.muted?0:1),n=this._volume*(this._muted?0:1);this._source.volume=n*r*i,this._source.playbackRate=this._playbackRate*e.playbackRate*t.playbackRate}refreshPaused(){if(!this._source||!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,playbackRate:this._playbackRate,loop:this._loop})),this.emit("pause",e))}play(e={}){if(!this._source)return;const{start:t=0,end:r=0}=e;r&&console.assert(r>t,"End time is before start time"),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.volume!==void 0&&(this._volume=e.volume),e.loop!==void 0&&(this._loop=e.loop),e.muted!==void 0&&(this._muted=e.muted),this.refresh(),this.loop&&r!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=r||this._duration,this._start=Math.max(0,this._start-gi.PADDING),this._end=Math.min(this._end+gi.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),Ce.on(this._onUpdate))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onUpdate=()=>{this._source&&(this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete())};_onComplete(){Ce.off(this._onUpdate),this._stop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){Ce.off(this._onUpdate),super.destroy();const e=this._source;e&&(e.onended=null,e.onplay=null,e.onpause=null,this._stop()),this._source=null,this._playbackRate=1,this._volume=1,this._loop=!1,this._end=0,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._audio&&(this._audio.context.off("refresh",this.refresh),this._audio.context.off("refreshPaused",this.refreshPaused),this._audio=null)}}class Kl{constructor(e){this.parent=e}source=new globalThis.Audio;_src="";get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}get duration(){return this.source.duration}get isPlayable(){return!!this.source&&this.source.readyState===4}get context(){return os.instance}async load(){return new Promise(e=>{this.source.onload=()=>e(this),this.source.src=this._src,this.source.load()})}createSound(){return new gi}}class Xn extends Dt{constructor(e,t){super(),this._input=e,this._output=t}_processers=[];get processors(){return this._processers}set processors(e){if(this._processers.forEach(t=>t.disconnect()),this._processers.length=0,this._input.connect(this._output),e.length){this._processers=e.slice(0),this._input.disconnect();let t;e.forEach(r=>{t?t.connect(r.destination):this._input.connect(r.destination),t=r}),t.connect(this._output)}}get destination(){return this._input}}class Bg{constructor(e,t=null){this.destination=e,this.source=t}connect(e){this.source?.connect(e)}disconnect(){this.source?.disconnect()}}function Lg(){if(Ss)return new AudioContext;if(Cs){const s=globalThis.webkitAudioContext;return new s}else throw new Error("Failed to createAudioContext")}function Ng(s,e,t){if(Ts)return new OfflineAudioContext(s,e,t);if(Ao){const r=globalThis.webkitOfflineAudioContext;return new r(s,e,t)}else throw new Error("Failed to createOfflineAudioContext")}class Wt extends Xn{static _instance;static get instance(){return this._instance||(this._instance=new Wt),this._instance}static get audioContext(){return this.instance.audioContext}static get offlineContext(){return this.instance.offlineContext}static setParamValue(e,t){this.instance.setParamValue(e,t)}static decode(e){return this.instance.decode(e)}_context;_offlineContext;get audioContext(){return this._context}get offlineContext(){return this._offlineContext}_locked;muted=!1;volume=1;playbackRate=1;autoPause=!0;_paused=!1;_pausedOnBlur=!1;get paused(){return this._paused}set paused(e){e&&this._context.state==="running"?this._context.suspend():!e&&this._context.state==="suspended"&&this._context.resume(),this._paused=e}_compressor;_analyser;constructor(){const e=Lg(),t=Ng(1,2,Ts?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),r=e.createDynamicsCompressor(),i=e.createAnalyser();i.connect(r),r.connect(e.destination),super(i,r),this._context=e,this._offlineContext=t,this._compressor=r,this._analyser=i,this._locked=e.state==="suspended"&&(Pt||Mo),kr&&(this._locked&&(this._unlock(),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),globalThis.addEventListener("focus",this._onFocus),globalThis.addEventListener("blur",this._onBlur))}_onFocus(){if(!this.autoPause)return;const e=this._context.state;(e==="suspended"||e==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}_onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}_unlock=()=>{this._locked&&(this.playEmptySound(),this._context.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))};playEmptySound(){const e=this._context.createBufferSource();e.buffer=this._context.createBuffer(1,1,22050),e.connect(this._context.destination),e.start(0,0,0),e.context.state==="suspended"&&e.context.resume()}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(e){return new Promise((t,r)=>{const i=o=>{r(new Error(o?.message||"Unable to decode file"))},n=this._offlineContext.decodeAudioData(e,t,i);n&&n.catch(i)})}setParamValue(e,t){e.setValueAtTime?e.setValueAtTime(t,this._context.currentTime):e.value=t}}class Zl extends Dt{_audio=null;_sourceNode=null;_gain=null;_progress=0;get progress(){return this._progress}_pausedReal=!1;_paused=!1;get paused(){return this._paused}set paused(e){this._paused!==e&&(this._paused=e,this.refreshPaused())}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh(),this._update(!0))}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}_duration=0;_end=0;_elapsed=0;_lastUpdate=this._now();_processors=[];init(e){return this._audio=e,e.context.on("refresh",this.refresh),e.context.on("refreshPaused",this.refreshPaused),this}_now(){return this._audio?.context.audioContext.currentTime??0}play(e={}){if(!this._audio)return;const{end:t=0,start:r=0}=e;t&&console.assert(t>r,"End time is before start time"),this._end=t,this._elapsed=r,e.volume!==void 0&&(this._volume=e.volume),e.playbackRate!==void 0&&(this._playbackRate=e.playbackRate),e.muted!==void 0&&(this._muted=e.muted),e.loop!==void 0&&(this._loop=e.loop),e.processors!==void 0&&(this._processors=e.processors),this._paused=!1;const{source:i,gain:n}=this._audio.cloneSource();this._sourceNode=i,this._gain=n,this.refresh(),i.onended=this._onComplete.bind(this),this._duration=i.buffer?.duration??0,this._lastUpdate=this._now(),this._loop?(i.loopStart=r,i.loopEnd=t,i.start(0,r)):t?i.start(0,r,t-r):i.start(0,r),this.emit("start"),this._update(!0),this._enableTicker(!0)}_stop(){if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.stop(0),this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}this._sourceNode=null}}stop(){this._sourceNode&&(this._stop(),this.emit("stop"))}_update(e=!1){if(this._sourceNode){const t=this._now(),r=t-this._lastUpdate;if(r>0||e){this._elapsed+=r*this._sourceNode.playbackRate.value,this._lastUpdate=t;const i=this._duration;let n;if(this._sourceNode.loopStart){const o=this._sourceNode.loopEnd-this._sourceNode.loopStart;n=(this._sourceNode.loopStart+this._elapsed%o)/i}else n=this._elapsed%i/i;this._progress=n,this.emit("progress",n,i)}}}refresh(){if(!this._audio||!this._sourceNode)return;const e=this._audio.context,t=this._audio.parent;this._sourceNode.loop=this._loop||t.loop,e.setParamValue(this._gain.gain,this._volume*(this._muted?0:1)*t.volume*(t.muted?0:1)*e.volume*(e.muted?0:1)),e.setParamValue(this._sourceNode.playbackRate,this._playbackRate*t.playbackRate*e.playbackRate),this.applyProcessors()}applyProcessors(){if(this._sourceNode&&this._processors.length){this._sourceNode.disconnect();let e=this._sourceNode;this._processors.forEach(t=>{e.connect(t.destination),e=t}),e.connect(this._gain)}}refreshPaused(){if(!this._audio)return;const e=this._paused||this._audio.parent.paused||this._audio.context.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._stop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,playbackRate:this._playbackRate,loop:this._loop,volume:this._volume})),this.emit("pause",e))}_onComplete=()=>{if(this._sourceNode){this._enableTicker(!1),this._sourceNode.onended=null,this._sourceNode.disconnect();try{this._sourceNode.buffer=null}catch(e){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",e)}}this._sourceNode=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)};_updateListener=()=>this._update();_enableTicker(e){Ce.off(this._updateListener),e&&Ce.on(this._updateListener)}destroy(){super.destroy(),this._stop(),this._gain?.disconnect(),this._gain=null,this._audio?.context.off("refresh",this.refresh),this._audio?.context.off("refreshPaused",this.refreshPaused),this._audio=null,this._processors.forEach(e=>e.disconnect()),this._processors.length=0,this._end=0,this._playbackRate=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}}class Jl extends Xn{constructor(e){const t=Wt.audioContext,r=t.createBufferSource(),i=t.createGain(),n=t.createAnalyser();r.connect(n),n.connect(i),i.connect(Wt.instance.destination),super(n,i),this.parent=e,this._sourceNode=r,this.gain=i,this.analyser=n}_sourceBuffer;_sourceNode;_sourceLoad;gain;analyser;get context(){return Wt.instance}get isPlayable(){return!!this._sourceNode.buffer}get duration(){return this._sourceNode.buffer?.duration??0}get buffer(){return this._sourceNode.buffer}set buffer(e){this._sourceNode.buffer=e}async load(){return this._sourceLoad||(this._sourceLoad=new Promise(e=>{this._sourceBuffer?this._decode(this._sourceBuffer).then(()=>e(this)):this.parent.src?this._loadUrl(this.parent.src).then(()=>e(this)):e(this)})),this._sourceLoad}_loadUrl(e){return new Promise(t=>{fetch(e).then(r=>r.arrayBuffer()).then(r=>this._decode(r)).finally(()=>t(this))})}_decode(e){return Promise.resolve(e instanceof AudioBuffer?e:Wt.decode(e)).then(t=>(this.parent.isLoaded=!0,this.buffer=t,t))}cloneSource(){const e=this.context,t=this._sourceNode,r=e.audioContext.createBufferSource(),i=e.audioContext.createGain();return r.buffer=t.buffer,r.loop=t.loop,e.setParamValue(r.playbackRate,t.playbackRate.value),r.connect(i),i.connect(this.destination),{source:r,gain:i}}createSound(){return new Zl}}var Fg=Object.defineProperty,$g=Object.getOwnPropertyDescriptor,zg=(s,e,t)=>e in s?Fg(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Vg=(s,e,t,r)=>{for(var i=r>1?void 0:r?$g(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i},Gg=(s,e,t)=>zg(s,e+"",t);u.Audio=class extends u.TimelineNode{_sounds=[];_platformAudio=Oo?new Jl(this):new Kl(this);get platformAudio(){return this._platformAudio}_src;get src(){return this._src}set src(e){this._src!==e&&(this._src=e,this.load())}isLoaded=!1;get isPlayable(){return this.isLoaded&&this._platformAudio.isPlayable}get audioDuration(){return this._platformAudio.duration*1e3}_volume=1;get volume(){return this._volume}set volume(e){this._volume!==e&&(this._volume=e,this.refresh())}_muted=!1;get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this.refresh())}_loop=!1;get loop(){return this._loop}set loop(e){this._loop!==e&&(this._loop=e,this.refresh())}_playbackRate=1;get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate!==e&&(this._playbackRate=e,this.refresh())}_isPlaying=!1;get isPlaying(){return this._isPlaying}multiple=!1;start=0;end=0;constructor(e=""){super(),this.src=e}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"paused":this.refreshPaused();break}}async load(){return await this._platformAudio.load(),this}pause(){return this._isPlaying=!1,this.paused=!0,this}resume(){return this._isPlaying=this._sounds.length>0,this.paused=!1,this}stop(){if(!this.isPlayable)return this;this._isPlaying=!1;for(let e=this._sounds.length-1;e>=0;e--)this._sounds[e].stop();return this}play(e={}){if(!this.isLoaded)return;this.multiple||this._removeSounds(),this._isPlaying=!0;const t=this._createSound();this._sounds.push(t),t.once("end",()=>{e.complete?.(),this._onComplete(t)}),t.once("stop",()=>this._onComplete(t));const r=(e?.start??this.start)/1e3,i=(e?.end??this.end)/1e3;return t.play({...e,start:r,end:i}),t}_removeSounds(){for(let e=this._sounds.length-1;e>=0;e--)this._recycleSound(this._sounds[e]);this._sounds.length=0}_createSound(){return u.Audio._soundPool.length>0?u.Audio._soundPool.pop().init(this._platformAudio):this._platformAudio.createSound().init(this._platformAudio)}refresh(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refresh()}refreshPaused(){for(let e=this._sounds.length,t=0;t<e;t++)this._sounds[t].refreshPaused()}_onComplete=e=>{if(this._sounds){const t=this._sounds.indexOf(e);t>-1&&this._sounds.splice(t,1),this._isPlaying=this._sounds.length>0}this._recycleSound(e)};_recycleSound(e){e.destroy(),u.Audio._soundPool.includes(e)||u.Audio._soundPool.push(e)}_prevTime=0;_timer=0;_process(e){if(super._process(e),this.canProcess()){const t=this._tree?.timeline.currentTime??0;t-this._prevTime>0&&(this._timer||(this._setTimeStop(),this.play({start:this.start+(t-this.delay)%this.duration})),this._isPlaying&&this._setTimeStop()),this._prevTime=t}}_setTimeStop(){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(()=>{this.stop(),this._timer=0},100)}},Gg(u.Audio,"_soundPool",[]),u.Audio=Vg([W("Audio")],u.Audio);class jg extends u.Node2D{}var Wg=Object.defineProperty,qg=Object.getOwnPropertyDescriptor,as=(s,e,t,r)=>{for(var i=r>1?void 0:r?qg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Wg(e,t,i),i};u.AudioWaveform=class extends u.Element2D{_audioBuffer;_src=kr?new le(document.createElement("canvas")):void 0;_needsUpdateTexture=!1;constructor(e={}){super(),this.setProperties(e)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"src":this._loadSrc(t);break;case"gap":case"color":case"width":case"height":this._needsUpdateTexture=!0;break}}async _loadSrc(e){await globalThis.fetch(e).then(t=>t.arrayBuffer()).then(t=>Wt.decode(t)).then(t=>{this._audioBuffer=t,this.syncTexture(!0)})}syncTexture(e=!1){const t=this._audioBuffer;if(!t||!e&&!this._needsUpdateTexture)return;this._needsUpdateTexture=!1;const r=this._src?.source;if(!r)return;const{width:i=0,height:n=0}=this.style;r.width=i,r.height=n;const o=r.getContext("2d");if(!o){console.warn("Failed to getContext('2d') in syncTexture");return}o.fillStyle=this.color;const a=t.getChannelData(0),l=Math.ceil(a.length/i),c=n/2;for(let h=1,f=-1,d=0;d<i;d++){for(let g=0;g<l;g++){const p=a[d*l+g];p<h&&(h=p),p>f&&(f=p)}if(!this.gap||d%(this.gap*2)===0){const g=d,p=(1+h)*c,y=this.gap||1,m=Math.max(1,(f-h)*c);o.fillRect(g,p,y,m),h=1,f=-1}}this._src?.requestUpload(),this.requestRedraw()}_process(e){this.syncTexture(),super._process(e)}_drawSrc(){const e=this._src;e?.valid&&(this.context.fillStyle=e,this.context.uvTransform=new ve().scale(1/this.style.width,1/this.style.height))}},as([w()],u.AudioWaveform.prototype,"src",2),as([w({fallback:0})],u.AudioWaveform.prototype,"gap",2),as([w({fallback:"#000000"})],u.AudioWaveform.prototype,"color",2),u.AudioWaveform=as([W("AudioWaveform")],u.AudioWaveform);var Xg=Object.getOwnPropertyDescriptor,Hg=(s,e,t,r)=>{for(var i=r>1?void 0:r?Xg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.Control=class extends u.Element2D{constructor(e,t=[]){super(),this._parentUpdateRect=this._parentUpdateRect.bind(this),this.setProperties(e),this.append(t)}_parented(e){super._parented(e),e.on("updateRect",this._parentUpdateRect)}_unparented(e){super._unparented(e),e.off("updateRect",this._parentUpdateRect)}_parentUpdateRect(){const e=this._parent.getRect();this.style.left=e.left,this.style.top=e.top,this.style.width=e.width,this.style.height=e.height}_input(e,t){super._input(e,t),this._guiInput(e,t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":case"height":case"left":case"top":this.emit("updateRect");break}}_guiInput(e,t){}},u.Control=Hg([W("Control")],u.Control);var Yg=Object.defineProperty,Kg=Object.getOwnPropertyDescriptor,qt=(s,e,t,r)=>{for(var i=r>1?void 0:r?Kg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Yg(e,t,i),i};u.Range=class extends u.Control{constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"allowGreater":case"allowLesser":case"page":case"minValue":case"maxValue":case"step":case"value":this.requestRedraw();break}}},qt([w({fallback:!1})],u.Range.prototype,"allowGreater",2),qt([w({fallback:!1})],u.Range.prototype,"allowLesser",2),qt([w({fallback:1})],u.Range.prototype,"page",2),qt([w({fallback:0})],u.Range.prototype,"minValue",2),qt([w({fallback:100})],u.Range.prototype,"maxValue",2),qt([w({fallback:.01})],u.Range.prototype,"step",2),qt([w({fallback:0})],u.Range.prototype,"value",2),u.Range=qt([W("Range")],u.Range);var Zg=Object.defineProperty,Jg=Object.getOwnPropertyDescriptor,bt=(s,e,t,r)=>{for(var i=r>1?void 0:r?Jg(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Zg(e,t,i),i};u.Ruler=class extends u.Control{texture=new Ui;constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"offsetX":case"offsetY":case"thickness":case"markHeight":case"color":case"markBackgroundColor":case"markColor":case"gap":case"scale":this.requestRedraw();break}}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":case"height":this.texture[e]=t,this.requestRedraw();break}}_drawTexture(){const{width:e,height:t}=this.size,{offsetX:r,offsetY:i,thickness:n,markHeight:o,markBackgroundColor:a,markColor:l,color:c,gap:h,gapScale:f}=this,g=this.texture.source.getContext("2d");g.reset(),g.scale(this.texture.pixelRatio,this.texture.pixelRatio);const p=Math.round(r),y=Math.round(i);g.beginPath(),g.fillStyle=a||"#EEE",g.fillRect(0,0,e,n),g.fillRect(0,0,n,t),g.fill(),g.strokeStyle=l||"#000",g.moveTo(n,0),g.lineTo(n,t),g.moveTo(0,n),g.lineTo(e,n),g.stroke();const m=h,P=h*f;let E,x,S,_,b;for(m>=P?(E=m/P,x=Math.floor(E)*m/20,S=m/20*Math.floor(E)/E):(E=P/m,x=Math.floor(m/20/E),x>=2?x=Math.floor(x/2)*2:x=1,S=x*E),g.fillStyle=g.strokeStyle,_=p,b=0;_<e;b++,_+=S)g.moveTo(_,n-(b%5?o:2*o)),g.lineTo(_,n);for(_=p,b=0;_>n;b++,_-=S)g.moveTo(_,n-(b%5?o:2*o)),g.lineTo(_,n);let C=0;for(_=y,b=0;_>n;b++,_-=S)g.moveTo(n-(b%5?o:2*o),_),g.lineTo(n,_);for(_=y,b=0;_<t;b++,_+=S)g.moveTo(n-(b%5?o:2*o),_),g.lineTo(n,_);for(g.save(),g.fillStyle=c,g.scale(.8,.8),C=n-8,_=p,b=0;_<e;b++,_+=S)b%10===0&&g.fillText(String(Math.ceil(x*b)),_*1.25-3,C*1.25);for(_=p,b=0;_>n;b++,_-=S)b%10===0&&g.fillText(String(Math.ceil(-x*b)),_*1.25-3,C*1.25);for(C=0,_=y,b=0;_>n;b++,_-=S)b%10===0&&g.fillText(String(Math.ceil(x*b)),C*1.25,_*1.25+3);for(_=y,b=0;_<t;b++,_+=S)b%10===0&&g.fillText(String(Math.ceil(-x*b)),C*1.25,_*1.25+3);g.restore(),g.stroke(),this.texture.requestUpload()}_draw(){this._drawTexture();const e=this.texture;e?.valid&&(this.context.fillStyle=e,this.context.uvTransform=new ve().scale(1/this.size.width,1/this.size.height),this.context.rect(0,0,e.width,e.height),this.context.fill())}},bt([w({fallback:0})],u.Ruler.prototype,"offsetX",2),bt([w({fallback:0})],u.Ruler.prototype,"offsetY",2),bt([w({fallback:20})],u.Ruler.prototype,"thickness",2),bt([w({fallback:3})],u.Ruler.prototype,"markHeight",2),bt([w({fallback:"#b2b6bc"})],u.Ruler.prototype,"color",2),bt([w({fallback:"#f9f9fa"})],u.Ruler.prototype,"markBackgroundColor",2),bt([w({fallback:"#b2b6bc"})],u.Ruler.prototype,"markColor",2),bt([w({fallback:300})],u.Ruler.prototype,"gap",2),bt([w({fallback:1})],u.Ruler.prototype,"gapScale",2),u.Ruler=bt([W("Ruler")],u.Ruler);var Qg=Object.defineProperty,em=Object.getOwnPropertyDescriptor,Ql=(s,e,t,r)=>{for(var i=r>1?void 0:r?em(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&Qg(e,t,i),i};u.ScrollBar=class extends u.Range{constructor(e,t=[]){super(),this.setProperties(e).append(t)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":case"height":case"left":case"top":this.requestRedraw();break}}_rect(){const{size:e,position:t}=this;let r,i,n,o,a;return this.direction==="vertical"?(n=10,o=e.height*(this.page/(this.maxValue-this.minValue)),r=t.left+e.width-n,i=e.height*(this.value/(this.maxValue-this.minValue)),a=n/2):(n=e.width*(this.page/(this.maxValue-this.minValue)),o=10,r=e.width*(this.value/(this.maxValue-this.minValue)),i=t.top+e.height-o,a=o/2),{left:r,top:i,width:n,height:o,radii:a}}_draw(){const{left:e,top:t,width:r,height:i,radii:n}=this._rect();this.context.roundRect(e,t,r,i,n),this.context.fillStyle=34,this.context.fill()}_pointerInput(e,t){const{left:r,top:i,width:n,height:o}=this._rect(),a=e.x>=r&&e.x<r+n&&e.y>=i&&e.y<i+o;switch(t){case"pointerdown":case"pointermove":a?this._tree?.input.setCursor("pointer"):this._tree?.input.setCursor(void 0);break}return!1}},Ql([w({fallback:"vertical"})],u.ScrollBar.prototype,"direction",2),u.ScrollBar=Ql([W("ScrollBar")],u.ScrollBar);var tm=Object.getOwnPropertyDescriptor,rm=(s,e,t,r)=>{for(var i=r>1?void 0:r?tm(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.XScrollBar=class extends u.ScrollBar{constructor(e,t=[]){super(),this.setProperties(e).append(t)}},u.XScrollBar=rm([W("XScrollBar",{direction:"horizontal"})],u.XScrollBar);var im=Object.getOwnPropertyDescriptor,sm=(s,e,t,r)=>{for(var i=r>1?void 0:r?im(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.YScrollBar=class extends u.ScrollBar{constructor(e,t=[]){super(),this.setProperties(e).append(t)}},u.YScrollBar=sm([W("YScrollBar",{direction:"vertical"})],u.YScrollBar);var nm=Object.defineProperty,om=Object.getOwnPropertyDescriptor,Cr=(s,e,t,r)=>{for(var i=r>1?void 0:r?om(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=(r?o(e,t,i):o(i))||i);return r&&i&&nm(e,t,i),i};u.Scaler=class extends u.Node{get target(){if(this.parent?.style)return this.parent}constructor(e,t=[]){super(),this.setProperties(e),this.append(t)}_updateProperty(e,t,r){switch(super._updateProperty(e,t,r),e){case"translateY":case"translateX":case"scale":case"min":case"max":{this.scale=Ge(this.scale,this.minScale,this.maxScale),this._updateTarget();break}}}_updateTarget(){const e=this.target;e&&(e.style.transform=`translate(${this.translateX}px, ${this.translateY}px) scale(${this.scale})`,this.emit("updateScale",this.scale))}_onWheel(e){this.target&&(e.preventDefault(),e.ctrlKey?(e.wheelDeltaY?Math.abs(Math.abs(e.wheelDeltaY)-Math.abs(3*e.deltaY))<3:e.deltaMode===0)||(e.preventDefault(),this.scale+=e.deltaY*-.015):(this.translateX-=e.deltaX,this.translateY-=e.deltaY))}_input(e,t){switch(super._input(e,t),t){case"wheel":this._onWheel(e);break}}},Cr([w({default:1})],u.Scaler.prototype,"translateX",2),Cr([w({default:1})],u.Scaler.prototype,"translateY",2),Cr([w({default:1})],u.Scaler.prototype,"scale",2),Cr([w({default:.05})],u.Scaler.prototype,"minScale",2),Cr([w({default:10})],u.Scaler.prototype,"maxScale",2),u.Scaler=Cr([W("Scaler",{processMode:"disabled",renderMode:"disabled"})],u.Scaler);var am=Object.defineProperty,lm=Object.getOwnPropertyDescriptor,cm=(s,e,t)=>e in s?am(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,hm=(s,e,t,r)=>{for(var i=r>1?void 0:r?lm(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i},um=(s,e,t)=>cm(s,e+"",t);u.KawaseTransition=class extends u.Transition{blur=10;quality=10;apply(e,t){const r=this.currentTimeProgress;let i,n;r<.5?(i=0,n=(.5-r)/.5):(i=1,n=(r-.5)/.5);const o=this.blur,a=this.quality,l=t.width,c=t.height,h=[],f=[o];if(o>0){let P=o;const E=o/a;for(let x=1;x<a;x++)P-=E,f.push(P)}const d=1/l,g=1/c,p=[];let y;const m=a-1;for(let P=0;P<m;P++)y=f[P]+.5,p[0]=y*d,p[1]=y*g,h.push({offset:p});y=f[m]+.5,p[0]=y*d,p[1]=y*g,h.push({offset:p}),h.forEach(P=>{Q.draw(e,u.KawaseTransition.material,{sampler:i,progress:n,...P})})}},um(u.KawaseTransition,"material",new se({vert:`attribute vec2 position;
868
868
  attribute vec2 uv;
869
869
  varying vec2 vUv;
870
870
  void main() {
@@ -1000,4 +1000,4 @@ void main(void) {
1000
1000
  coord = twist(coord, radius - (progress * radius));
1001
1001
  coord = unmapCoord(coord);
1002
1002
  gl_FragColor = texture2D(sampler, coord);
1003
- }`})),u.TwistTransition=Cm([W("TwistTransition")],u.TwistTransition);class ec extends Ut{install(e){const t=async r=>{const{decodeFrames:i}=await import("modern-gif");return await e.fetch(r).then(n=>n.arrayBuffer()).then(n=>i(n)).then(n=>new Ri(n.map(o=>({duration:o.delay,texture:new Xs(o.data,o.width,o.height)}))))};return this.load=r=>e.loadBy(r,()=>t(r)),["image/gif"].forEach(r=>{e.register(r,t)}),e.gif=this,this}}class tc extends Ut{install(e){const t=r=>e.fetch(r).then(i=>i.json());return this.load=r=>e.loadBy(r,()=>t(r)),["json"].forEach(r=>{e.register(r,t)}),e.json=this,this}}class rc extends Ut{install(e){const t=async(r,i)=>(await import("lottie-web").then(o=>o.default)).loadAnimation({container:null,renderer:"canvas",rendererSettings:{context:i.getContext("2d")},loop:!1,autoplay:!1,animationData:await e.fetch(r).then(o=>o.json())});return this.load=(r,i)=>e.loadBy(r,()=>t(r,i)),["lottie"].forEach(r=>{e.register(r,t)}),e.lottie=this,this}}class ic extends Ut{install(e){const t=async r=>await e.fetch(r).then(i=>i.text());return this.load=r=>e.loadBy(r,()=>t(r)),e.text=this,this}}class sc extends Ut{install(e){const t=r=>e.fetchImageBitmap(r,{premultiplyAlpha:"premultiply"}).then(i=>new le(i));return this.load=r=>e.loadBy(r,()=>t(r)),["image/gif","image/jpeg","image/png","image/tiff","image/vnd.wap.wbmp","image/x-icon","image/x-jng","image/x-ms-bmp","image/svg+xml","image/webp"].forEach(r=>{e.register(r,t)}),e.texture=this,this}}class nc extends Ut{install(e){const t=r=>new Na(r).load();return this.load=r=>e.loadBy(r,()=>t(r)),["video/3gpp","video/mpeg","video/quicktime","video/x-flv","video/x-mng","video/x-ms-asf","video/x-ms-wmv","video/x-msvideo","video/mp4"].forEach(r=>{e.register(r,t)}),e.video=this,this}}const Em=Object.entries({"text/html":["html","htm","shtml"],"text/css":["css"],"text/xml":["xml"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls"],"application/vnd.ms-powerpoint":["ppt"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"]});function Mm(s){for(const[e,t]of Em)if(t.includes(s))return e}async function Am(s){let e;if(s.startsWith("data:"))e=s.match(/^data:(.+?);/)?.[1];else if(s.startsWith("http")){const t=s.split(/[#?]/)[0].split(".").pop()?.trim();t&&(e=Mm(t))}return e??await fetch(s).then(t=>t.headers.get("Content-Type"))??""}const ls="WeakRef"in globalThis;class oc{defaultHandler=e=>this.fetch(e);_handlers=new Map;_handleing=new Map;_handled=new Map;_gc=ls?new FinalizationRegistry(e=>{const t=this.get(e);t&&"destroy"in t&&t.destroy(),this._handled.delete(e)}):void 0;constructor(){ls||Ce.on(this.gc.bind(this),{sort:2})}use(e){return e.install(this),this}register(e,t){return this._handlers.set(e,t),this}fetch(e){return fetch(e)}_fixSVG(e){let t;e.includes(";base64,")?t=atob(e.split(",")[1]):t=decodeURIComponent(e.split(",")[1]);const r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,i=r.getAttribute("width"),n=r.getAttribute("height"),o=i&&/^[\d.]+$/.test(i),a=n&&/^[\d.]+$/.test(n);if(!o||!a){const l=r.getAttribute("viewBox")?.split(" ").map(c=>Number(c));o||r.setAttribute("width",String(l?l[2]-l[0]:512)),a||r.setAttribute("height",String(l?l[3]-l[1]:512))}return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r.outerHTML)}`}async fetchImageBitmap(e,t){return e.startsWith("http")?await this.fetch(e).then(r=>r.blob()).then(r=>r.type==="image/svg+xml"?r.text().then(i=>this.fetchImageBitmap(this._fixSVG(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),t)):createImageBitmap(r,t)):(e.startsWith("data:image/svg+xml;")&&(e=this._fixSVG(e)),new Promise(r=>{const i=new Image;i.src=e,i.onload=()=>{i.decode().finally(()=>{r(i)})}}).then(r=>createImageBitmap(r,t)))}get(e){let t=this._handled.get(e);return ls&&t instanceof WeakRef&&(t=t.deref(),t||this._handleing.delete(e)),t}set(e,t){let r=t;ls&&typeof t=="object"&&(this._gc.register(t,e),r=new WeakRef(t)),this._handled.set(e,r)}async loadBy(e,t){const r=this.get(e)??this._handleing.get(e);if(r)return r;const i=t().then(n=>(this.set(e,n),n)).finally(()=>{this._handleing.delete(e)});return this._handleing.set(e,i),i}async load(e,t){return this.loadBy(e,async()=>{const r=await Am(e);return(this._handlers.get(r)??this.defaultHandler)(e,t)})}async waitUntilLoad(){await Promise.all(Array.from(this._handleing.values()).map(e=>e.catch(t=>{console.error(t)})))}gc(){this._handled.forEach((e,t)=>{const r=this.get(t);r&&"destroy"in r&&r.destroy()}),this._handled.clear()}}const nt=new oc().use(new aa).use(new ec).use(new tc).use(new rc).use(new ic).use(new sc).use(new nc);var Om=Object.getOwnPropertyDescriptor,km=(s,e,t,r)=>{for(var i=r>1?void 0:r?Om(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.CanvasItemEditor=class extends u.Control{_pointerStart;_pointerOffset;selected;dragging;hovered;hover=new u.Element2D({name:"hover",internalMode:"back",style:{visibility:"hidden",outlineStyle:"solid",outlineColor:"#00FF00FF",outlineWidth:2,pointerEvents:"none"}});transformRect=new qn({name:"transformRect",internalMode:"back",style:{visibility:"hidden",pointerEvents:"none"}});scaler=new u.Scaler({name:"Scaler",internalMode:"back"}).on("updateScale",e=>{this.ruler.gapScale=e,this._updateScrollbars(),this._updateSelectionRect()});xScrollBar=new u.XScrollBar({name:"XScrollBar",internalMode:"back",style:{visibility:"hidden"}});yScrollBar=new u.YScrollBar({name:"yScrollBar",internalMode:"back",style:{visibility:"hidden"}});drawboard=new u.Element2D({name:"drawboard",style:{width:500,height:500,backgroundColor:"#00FFFFFF",pointerEvents:"none"}},[this.scaler]);ruler=new u.Ruler({name:"ruler",offsetX:100,offsetY:100,style:{pointerEvents:"none"}},[this.drawboard,this.hover,this.transformRect,this.xScrollBar,this.yScrollBar]);constructor(){super(),this._onPointerdown=this._onPointerdown.bind(this),this._onPointermove=this._onPointermove.bind(this),this._onPointerup=this._onPointerup.bind(this),this.append(this.ruler)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":this.drawboard.style.left=(this.size.width-this.drawboard.size.width)/2,this.ruler.offsetX=this.drawboard.style.left;break;case"height":this.drawboard.style.top=(this.size.height-this.drawboard.size.height)/2,this.ruler.offsetY=this.drawboard.style.top;break}}_guiInput(e,t){switch(super._guiInput(e,t),t){case"pointerdown":this._onPointerdown(e);break;case"pointermove":this._onPointermove(e);break;case"pointerup":this._onPointerup();break}}_onPointerdown(e){let t=e.target;t?.equal(this)&&(t=void 0),t?.equal(this.transformRect)&&(t=this.selected),this._pointerOffset={x:e.offsetX,y:e.offsetY},this.selected=t,this.dragging=t,t instanceof u.Element2D?this._pointerStart=t.style.clone():this._pointerStart=void 0,this._updateHover(),this._updateSelectionRect()}_onPointermove(e){let t=e.target;t?.equal(this)&&(t=void 0),t?.equal(this.transformRect)&&(t=this.selected);const{selected:r,dragging:i,_pointerStart:n,_pointerOffset:o}=this;r&&t?.equal(r)?this.hovered=void 0:this.hovered=t;const a=o?{x:e.offsetX-o.x,y:e.offsetY-o.y}:{x:0,y:0};i&&n&&(i.style.left=n.left+a.x/this.scaler.scale,i.style.top=n.top+a.y/this.scaler.scale,i.update()),this._updateHover(),this._updateSelectionRect()}_onPointerup(){this.dragging=void 0,this._updateHover(),this._updateSelectionRect()}_copyGlobalTransform(e,t){e.style.visibility="visible",e.style.width=t.globalScale.x*t.size.x,e.style.height=t.globalScale.y*t.size.y,e.style.left=t.globalPosition.x,e.style.top=t.globalPosition.y,e.style.rotate=t.globalRotation,e.update()}_updateHover(){const e=this.hovered;e instanceof u.Element2D?(this.hover.style.visibility="visible",this._copyGlobalTransform(this.hover,e),this.hover.requestRedraw()):this.hover.style.visibility="hidden"}_updateSelectionRect(){this.selected?(this.transformRect.style.visibility="visible",this._copyGlobalTransform(this.transformRect,this.selected)):this.transformRect.style.visibility="hidden"}_updateScrollbars(){const e=this.ruler.gapScale,t=this.drawboard.size.height*e,r=this.drawboard.size.width*e;t>this.size.height?(this.yScrollBar.style.visibility="visible",this.yScrollBar.maxValue=t,this.yScrollBar.page=this.size.height):this.yScrollBar.style.visibility="hidden",r>this.size.width?(this.xScrollBar.style.visibility="visible",this.xScrollBar.maxValue=r,this.xScrollBar.page=this.size.width):this.xScrollBar.style.visibility="hidden"}},u.CanvasItemEditor=km([W("CanvasItemEditor")],u.CanvasItemEditor);const ac={alpha:!0,stencil:!0,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"};class lc extends qr{renderer;get view(){return this.renderer.view}get gl(){return this.renderer.gl}get screen(){return this.renderer.screen}get width(){return this.screen.width}get height(){return this.screen.height}get pixelRatio(){return this.renderer.pixelRatio}set pixelRatio(e){this.renderer.pixelRatio=e,this.resize(this.width,this.height),this.view&&(this.view.dataset.pixelRatio=String(e))}_resizeObserver=To?new ResizeObserver(e=>{const t=e[0];if(t.target===this.view){const{inlineSize:r,blockSize:i}=Array.isArray(t.contentBoxSize)?t.contentBoxSize[0]:t.contentBoxSize;this.resize(r,i)}}):void 0;constructor(e={}){const{debug:t=!1,view:r,width:i,height:n,pixelRatio:o=Es,backgroundColor:a=0,autoResize:l,autoStart:c,timeline:h,...f}=e;super(h),this.debug=t,this.renderer=new oa(r,{...ac,...f}),this._setupInput(),this.pixelRatio=o,this.backgroundColor=a,l?(!r&&this.renderer.view&&(this.renderer.view.style.width="100%",this.renderer.view.style.height="100%"),this.enableAutoResize(l)):this.resize(i||this.gl.drawingBufferWidth||this.view?.clientWidth||200,n||this.gl.drawingBufferHeight||this.view?.clientHeight||200,!r),c&&this.start()}_setupInput(){return this.view&&(this.input.setTarget(this.view),["pointerdown","pointerover","pointermove","pointerup","wheel","keydown","keypress","keyup"].forEach(e=>{this.input.on(e,t=>{this.root.input(t,e),this.emit(e,t)})})),this}enableAutoResize(e=!0){return this.view&&(e?this._resizeObserver?.observe(this.view):this._resizeObserver?.unobserve(this.view)),this}resize(e,t,r=!1){return this.renderer.resize(e,t,r),this.root.width=e,this.root.height=t,this.root.requestUpload(),this.render(),this}nextTick(){return bs()}async waitUntilLoad(){await nt.waitUntilLoad(),await this.nextTick()}async waitAndRender(e=0){await nt.waitUntilLoad(),this._process(e),await this.nextTick(),this._render(this.renderer)}render(e=0){this._process(e),this._render(this.renderer)}async start(){await this.waitAndRender(),super.start(e=>{this._process(e),this._render(this.renderer)})}destroy(){super.destroy(),this.enableAutoResize(!1),this.renderer.destroy()}toPixels(){return this.renderer.toPixels()}toImageData(){return new ImageData(this.toPixels(),this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}toCanvas2D(){const e=this.toImageData(),t=document.createElement("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r&&(r.fillStyle="rgba(0, 0, 0, 0)",r.clearRect(0,0,t.width,t.height),r.putImageData(e,0,0));const i=document.createElement("canvas");i.width=this.width,i.height=this.height;const n=i.getContext("2d");return n&&(n.fillStyle="rgba(0, 0, 0, 0)",n.clearRect(0,0,i.width,i.height),n.drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height)),i}}let bt;const Hn=[];let Yn=!1;async function Dm(s=100){if(!Yn){for(Yn=!0;Hn.length;){const e=Hn.shift();if(e)try{await e()}catch(t){console.error(t)}else await new Promise(t=>setTimeout(t,s))}Yn=!1}}async function Im(s){const{data:e,width:t,height:r,debug:i=!1,time:n=0}=s;return bt??=new lc({width:1,height:1,preserveDrawingBuffer:!0}),bt.debug=i,bt.root.removeChildren(),bt.timeline.currentTime=n,bt.resize(t,r,!0),(Array.isArray(e)?e:[e]).forEach(o=>{o instanceof u.Node?(o.parent=void 0,bt.root.appendChild(o)):bt.root.appendChild(u.Node.parse(o))}),await s.onBeforeRender?.(bt),await bt.waitAndRender(),bt.toCanvas2D()}async function Rm(s){return new Promise(e=>{Hn.push(async()=>e(await Im(s))),Dm()})}u.AnimatedTexture=Ri,u.Assets=oc,u.AudioPipeline=Xn,u.AudioProcessor=Bg,u.AudioSpectrum=jg,u.BaseElement2DBackground=nn,u.BaseElement2DFill=Te,u.BaseElement2DForeground=on,u.BaseElement2DOutline=Zt,u.BaseElement2DShadow=Jt,u.BaseElement2DShape=Qt,u.BaseElement2DStyle=Qr,u.BaseElement2DText=_t,u.CanvasContext=Fa,u.CanvasTexture=Ui,u.Color=Qe,u.ColorMatrix=ks,u.ColorTexture=tf,u.CoreObject=It,u.DEG_TO_RAD=Go,u.DEVICE_PIXEL_RATIO=Es,u.EffectMaterial=Nr,u.Element2DStyle=Ln,u.Engine=lc,u.FlexElement2DStyle=zl,u.FlexLayout=ss,u.FontLoader=aa,u.Geometry=Ii,u.GifLoader=ec,u.GradientTexture=$r,u.HTMLAudio=Kl,u.HTMLAudioContext=os,u.HTMLSound=gi,u.IN_BROWSER=kr,u.ImageTexture=sf,u.IndexBuffer=dr,u.Input=$o,u.InputEvent=Dr,u.JsonLoader=tc,u.KeyboardInputEvent=Lo,u.Loader=Ut,u.LottieLoader=rc,u.MainLoop=Ci,u.Material=se,u.Matrix=ht,u.Matrix2=xh,u.Matrix3=Ds,u.Matrix4=Vo,u.MouseInputEvent=Os,u.PI=Si,u.PI_2=Ne,u.PixelsTexture=Xs,u.PointerInputEvent=No,u.Projection2D=Wo,u.QuadGeometry=Xu,u.QuadUvGeometry=Q,u.RAD_TO_DEG=bh,u.RawWeakMap=As,u.Rect2=Rt,u.RefCounted=zo,u.Renderer=Xo,u.Resource=St,u.SUPPORTS_AUDIO_CONTEXT=Ss,u.SUPPORTS_CLICK_EVENTS=Mo,u.SUPPORTS_CREATE_IMAGE_BITMAP=Ps,u.SUPPORTS_IMAGE_BITMAP=Co,u.SUPPORTS_MOUSE_EVENTS=gh,u.SUPPORTS_OFFLINE_AUDIO_CONTEXT=Ts,u.SUPPORTS_POINTER_EVENTS=lr,u.SUPPORTS_RESIZE_OBSERVER=To,u.SUPPORTS_TOUCH_EVENTS=Pt,u.SUPPORTS_WEBGL2=So,u.SUPPORTS_WEBKIT_AUDIO_CONTEXT=Cs,u.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=Ao,u.SUPPORTS_WEB_AUDIO=Oo,u.SUPPORTS_WHEEL_EVENTS=Eo,u.SceneTree=qr,u.TextLoader=ic,u.Texture2D=le,u.TextureLoader=sc,u.TextureRect2D=Wn,u.Ticker=Ce,u.Transform2D=ve,u.TransformRect2D=qn,u.UvGeometry=Zu,u.UvMaterial=Fr,u.Vector=et,u.Vector2=de,u.Vector3=Ph,u.Vector4=jo,u.VertexAttribute=je,u.VertexBuffer=Et,u.VideoLoader=nc,u.VideoTexture=Na,u.ViewportTexture=Ys,u.WebAudio=Jl,u.WebAudioContext=Wt,u.WebGLBatch2DModule=Ko,u.WebGLBlendMode=cr,u.WebGLBufferModule=Zo,u.WebGLFramebufferModule=Jo,u.WebGLMaskModule=Qo,u.WebGLModule=Ye,u.WebGLProgramModule=ea,u.WebGLRenderer=oa,u.WebGLScissorModule=ta,u.WebGLState=Xt,u.WebGLStateModule=Yo,u.WebGLStencilModule=ra,u.WebGLTextureModule=ia,u.WebGLVertexArrayModule=sa,u.WebGLViewportModule=na,u.WebSound=Zl,u.WheelInputEvent=Fo,u.alignMap=nr,u.assets=nt,u.boxSizingMap=jn,u.clamp=Ge,u.clampFrag=nl,u.createHTMLCanvas=Ro,u.createNode=ch,u.crossOrigin=Bo,u.cubicBezier=Sr,u.curves=wh,u.customNode=W,u.customNodes=Pi,u.defaultOptions=ac,u.determineCrossOrigin=Uo,u.directionMap=is,u.displayMap=Nn,u.ease=ql,u.easeIn=Xl,u.easeInOut=Yl,u.easeOut=Hl,u.edgeMap=fe,u.flexDirectionMap=Fn,u.flexWrapMap=$n,u.frag=sl,u.getDefaultCssPropertyValue=xs,u.gutterMap=Vl,u.isCanvasElement=Do,u.isElementNode=Ms,u.isImageElement=mh,u.isPow2=ws,u.isVideoElement=ko,u.isWebgl2=Io,u.justifyMap=zn,u.lerp=he,u.linear=Wl,u.log2=Rs,u.mapWebGLBlendModes=Ho,u.nextPow2=Is,u.nextTick=bs,u.overflowMap=Vn,u.parseCSSFilter=kf,u.parseCSSTransform=Va,u.parseCSSTransformOrigin=Ga,u.parseCssFunctions=Or,u.parseCssProperty=Ar,u.positionTypeMap=Gn,u.render=Rm,u.timingFunctions=ns,u.uid=xo,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
1003
+ }`})),u.TwistTransition=Cm([W("TwistTransition")],u.TwistTransition);class ec extends Ut{install(e){const t=async r=>{const{decodeFrames:i}=await import("modern-gif");return await e.fetch(r).then(n=>n.arrayBuffer()).then(n=>i(n)).then(n=>new Ri(n.map(o=>({duration:o.delay,texture:new Xs(o.data,o.width,o.height)}))))};return this.load=r=>e.loadBy(r,()=>t(r)),["image/gif"].forEach(r=>{e.register(r,t)}),e.gif=this,this}}class tc extends Ut{install(e){const t=r=>e.fetch(r).then(i=>i.json());return this.load=r=>e.loadBy(r,()=>t(r)),["json"].forEach(r=>{e.register(r,t)}),e.json=this,this}}class rc extends Ut{install(e){const t=async(r,i)=>(await import("lottie-web").then(o=>o.default)).loadAnimation({container:null,renderer:"canvas",rendererSettings:{context:i.getContext("2d")},loop:!1,autoplay:!1,animationData:await e.fetch(r).then(o=>o.json())});return this.load=(r,i)=>e.loadBy(r,()=>t(r,i)),["lottie"].forEach(r=>{e.register(r,t)}),e.lottie=this,this}}class ic extends Ut{install(e){const t=async r=>await e.fetch(r).then(i=>i.text());return this.load=r=>e.loadBy(r,()=>t(r)),e.text=this,this}}class sc extends Ut{install(e){const t=r=>e.fetchImageBitmap(r,{premultiplyAlpha:"premultiply"}).then(i=>new le(i));return this.load=r=>e.loadBy(r,()=>t(r)),["image/gif","image/jpeg","image/png","image/tiff","image/vnd.wap.wbmp","image/x-icon","image/x-jng","image/x-ms-bmp","image/svg+xml","image/webp"].forEach(r=>{e.register(r,t)}),e.texture=this,this}}class nc extends Ut{install(e){const t=r=>new Na(r).load();return this.load=r=>e.loadBy(r,()=>t(r)),["video/3gpp","video/mpeg","video/quicktime","video/x-flv","video/x-mng","video/x-ms-asf","video/x-ms-wmv","video/x-msvideo","video/mp4"].forEach(r=>{e.register(r,t)}),e.video=this,this}}const Em=Object.entries({"text/html":["html","htm","shtml"],"text/css":["css"],"text/xml":["xml"],"image/gif":["gif"],"image/jpeg":["jpeg","jpg"],"application/x-javascript":["js"],"application/atom+xml":["atom"],"application/rss+xml":["rss"],"text/mathml":["mml"],"text/plain":["txt"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/x-component":["htc"],"image/png":["png"],"image/tiff":["tif","tiff"],"image/vnd.wap.wbmp":["wbmp"],"image/x-icon":["ico"],"image/x-jng":["jng"],"image/x-ms-bmp":["bmp"],"image/svg+xml":["svg"],"image/webp":["webp"],"application/java-archive":["jar","war","ear"],"application/mac-binhex40":["hqx"],"application/msword":["doc"],"application/pdf":["pdf"],"application/postscript":["ps","eps","ai"],"application/rtf":["rtf"],"application/vnd.ms-excel":["xls"],"application/vnd.ms-powerpoint":["ppt"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/x-7z-compressed":["7z"],"application/x-cocoa":["cco"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-makeself":["run"],"application/x-perl":["pl","pm"],"application/x-pilot":["prc","pdb"],"application/x-rar-compressed":["rar"],"application/x-redhat-package-manager":["rpm"],"application/x-sea":["sea"],"application/x-shockwave-flash":["swf"],"application/x-stuffit":["sit"],"application/x-tcl":["tcl","tk"],"application/x-x509-ca-cert":["der","pem","crt"],"application/x-xpinstall":["xpi"],"application/xhtml+xml":["xhtml"],"application/zip":["zip"],"application/octet-stream":["bin","exe","dll","deb","dmg","eot","iso","img","msi","msp","msm"],"audio/midi":["mid","midi","kar"],"audio/mpeg":["mp3"],"audio/ogg":["ogg"],"audio/x-realaudio":["ra"],"video/3gpp":["3gpp","3gp"],"video/mpeg":["mpeg","mpg"],"video/quicktime":["mov"],"video/x-flv":["flv"],"video/x-mng":["mng"],"video/x-ms-asf":["asx","asf"],"video/x-ms-wmv":["wmv"],"video/x-msvideo":["avi"],"video/mp4":["m4v","mp4"]});function Mm(s){for(const[e,t]of Em)if(t.includes(s))return e}async function Am(s){let e;if(s.startsWith("data:"))e=s.match(/^data:(.+?);/)?.[1];else if(s.startsWith("http")){const t=s.split(/[#?]/)[0].split(".").pop()?.trim();t&&(e=Mm(t))}return e??await fetch(s).then(t=>t.headers.get("Content-Type"))??""}const ls="WeakRef"in globalThis;class oc{defaultHandler=e=>this.fetch(e);_handlers=new Map;_handleing=new Map;_handled=new Map;_gc=ls?new FinalizationRegistry(e=>{const t=this.get(e);t&&"destroy"in t&&t.destroy(),this._handled.delete(e)}):void 0;constructor(){ls||Ce.on(this.gc.bind(this),{sort:2})}use(e){return e.install(this),this}register(e,t){return this._handlers.set(e,t),this}fetch(e){return fetch(e)}_fixSVG(e){let t;e.includes(";base64,")?t=atob(e.split(",")[1]):t=decodeURIComponent(e.split(",")[1]);const r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement,i=r.getAttribute("width"),n=r.getAttribute("height"),o=i&&/^[\d.]+$/.test(i),a=n&&/^[\d.]+$/.test(n);if(!o||!a){const l=r.getAttribute("viewBox")?.split(" ").map(c=>Number(c));o||r.setAttribute("width",String(l?l[2]-l[0]:512)),a||r.setAttribute("height",String(l?l[3]-l[1]:512))}return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r.outerHTML)}`}async fetchImageBitmap(e,t){return e.startsWith("http")?await this.fetch(e).then(r=>r.blob()).then(r=>r.type==="image/svg+xml"?r.text().then(i=>this.fetchImageBitmap(this._fixSVG(`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`),t)):createImageBitmap(r,t)):(e.startsWith("data:image/svg+xml;")&&(e=this._fixSVG(e)),new Promise(r=>{const i=new Image;i.src=e,i.onload=()=>{i.decode().finally(()=>{r(i)})}}).then(r=>createImageBitmap(r,t)))}get(e){let t=this._handled.get(e);return ls&&t instanceof WeakRef&&(t=t.deref(),t||this._handleing.delete(e)),t}set(e,t){let r=t;ls&&typeof t=="object"&&(this._gc.register(t,e),r=new WeakRef(t)),this._handled.set(e,r)}async loadBy(e,t){const r=this.get(e)??this._handleing.get(e);if(r)return r;const i=t().then(n=>(this.set(e,n),n)).finally(()=>{this._handleing.delete(e)});return this._handleing.set(e,i),i}async load(e,t){return this.loadBy(e,async()=>{const r=await Am(e);return(this._handlers.get(r)??this.defaultHandler)(e,t)})}async waitUntilLoad(){await Promise.all(Array.from(this._handleing.values()).map(e=>e.catch(t=>{console.error(t)})))}gc(){this._handled.forEach((e,t)=>{const r=this.get(t);r&&"destroy"in r&&r.destroy()}),this._handled.clear()}}const nt=new oc().use(new aa).use(new ec).use(new tc).use(new rc).use(new ic).use(new sc).use(new nc);var Om=Object.getOwnPropertyDescriptor,km=(s,e,t,r)=>{for(var i=r>1?void 0:r?Om(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(i=o(i)||i);return i};u.CanvasItemEditor=class extends u.Control{_pointerStart;_pointerOffset;selected;dragging;hovered;hover=new u.Element2D({name:"hover",internalMode:"back",style:{visibility:"hidden",outlineStyle:"solid",outlineColor:"#00FF00FF",outlineWidth:2,pointerEvents:"none"}});transformRect=new qn({name:"transformRect",internalMode:"back",style:{visibility:"hidden",pointerEvents:"none"}});scaler=new u.Scaler({name:"Scaler",internalMode:"back"}).on("updateScale",e=>{this.ruler.gapScale=e,this._updateScrollbars(),this._updateSelectionRect()});xScrollBar=new u.XScrollBar({name:"XScrollBar",internalMode:"back",style:{visibility:"hidden"}});yScrollBar=new u.YScrollBar({name:"yScrollBar",internalMode:"back",style:{visibility:"hidden"}});drawboard=new u.Element2D({name:"drawboard",style:{width:500,height:500,backgroundColor:"#00FFFFFF",pointerEvents:"none"}},[this.scaler]);ruler=new u.Ruler({name:"ruler",offsetX:100,offsetY:100,style:{pointerEvents:"none"}},[this.drawboard,this.hover,this.transformRect,this.xScrollBar,this.yScrollBar]);constructor(){super(),this._onPointerdown=this._onPointerdown.bind(this),this._onPointermove=this._onPointermove.bind(this),this._onPointerup=this._onPointerup.bind(this),this.append(this.ruler)}_updateStyleProperty(e,t,r){switch(super._updateStyleProperty(e,t,r),e){case"width":this.drawboard.style.left=(this.size.width-this.drawboard.size.width)/2,this.ruler.offsetX=this.drawboard.style.left;break;case"height":this.drawboard.style.top=(this.size.height-this.drawboard.size.height)/2,this.ruler.offsetY=this.drawboard.style.top;break}}_guiInput(e,t){switch(super._guiInput(e,t),t){case"pointerdown":this._onPointerdown(e);break;case"pointermove":this._onPointermove(e);break;case"pointerup":this._onPointerup();break}}_onPointerdown(e){let t=e.target;t?.equal(this)&&(t=void 0),t?.equal(this.transformRect)&&(t=this.selected),this._pointerOffset={x:e.offsetX,y:e.offsetY},this.selected=t,this.dragging=t,t instanceof u.Element2D?this._pointerStart=t.style.clone():this._pointerStart=void 0,this._updateHover(),this._updateSelectionRect()}_onPointermove(e){let t=e.target;t?.equal(this)&&(t=void 0),t?.equal(this.transformRect)&&(t=this.selected);const{selected:r,dragging:i,_pointerStart:n,_pointerOffset:o}=this;r&&t?.equal(r)?this.hovered=void 0:this.hovered=t;const a=o?{x:e.offsetX-o.x,y:e.offsetY-o.y}:{x:0,y:0};i&&n&&(i.style.left=n.left+a.x/this.scaler.scale,i.style.top=n.top+a.y/this.scaler.scale,i.update()),this._updateHover(),this._updateSelectionRect()}_onPointerup(){this.dragging=void 0,this._updateHover(),this._updateSelectionRect()}_copyGlobalTransform(e,t){e.style.visibility="visible",e.style.width=t.globalScale.x*t.size.x,e.style.height=t.globalScale.y*t.size.y,e.style.left=t.globalPosition.x,e.style.top=t.globalPosition.y,e.style.rotate=t.globalRotation,e.update()}_updateHover(){const e=this.hovered;e instanceof u.Element2D?(this.hover.style.visibility="visible",this._copyGlobalTransform(this.hover,e),this.hover.requestRedraw()):this.hover.style.visibility="hidden"}_updateSelectionRect(){this.selected?(this.transformRect.style.visibility="visible",this._copyGlobalTransform(this.transformRect,this.selected)):this.transformRect.style.visibility="hidden"}_updateScrollbars(){const e=this.ruler.gapScale,t=this.drawboard.size.height*e,r=this.drawboard.size.width*e;t>this.size.height?(this.yScrollBar.style.visibility="visible",this.yScrollBar.maxValue=t,this.yScrollBar.page=this.size.height):this.yScrollBar.style.visibility="hidden",r>this.size.width?(this.xScrollBar.style.visibility="visible",this.xScrollBar.maxValue=r,this.xScrollBar.page=this.size.width):this.xScrollBar.style.visibility="hidden"}},u.CanvasItemEditor=km([W("CanvasItemEditor")],u.CanvasItemEditor);const ac={alpha:!0,stencil:!0,antialias:!1,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:"default"};class lc extends qr{renderer;get view(){return this.renderer.view}get gl(){return this.renderer.gl}get screen(){return this.renderer.screen}get width(){return this.screen.width}get height(){return this.screen.height}get pixelRatio(){return this.renderer.pixelRatio}set pixelRatio(e){this.renderer.pixelRatio=e,this.resize(this.width,this.height),this.view&&(this.view.dataset.pixelRatio=String(e))}_resizeObserver=To?new ResizeObserver(e=>{const t=e[0];if(t.target===this.view){const{inlineSize:r,blockSize:i}=Array.isArray(t.contentBoxSize)?t.contentBoxSize[0]:t.contentBoxSize;this.resize(r,i)}}):void 0;constructor(e={}){const{debug:t=!1,view:r,width:i,height:n,pixelRatio:o=Es,backgroundColor:a=0,fonts:l,autoResize:c,autoStart:h,timeline:f,...d}=e;super(f),this.debug=t,this.renderer=new oa(r,{...ac,...d}),this._setupInput(),this.pixelRatio=o,this.backgroundColor=a,this.fonts=l,c?(!r&&this.renderer.view&&(this.renderer.view.style.width="100%",this.renderer.view.style.height="100%"),this.enableAutoResize(c)):this.resize(i||this.gl.drawingBufferWidth||this.view?.clientWidth||200,n||this.gl.drawingBufferHeight||this.view?.clientHeight||200,!r),h&&this.start()}_setupInput(){return this.view&&(this.input.setTarget(this.view),["pointerdown","pointerover","pointermove","pointerup","wheel","keydown","keypress","keyup"].forEach(e=>{this.input.on(e,t=>{this.root.input(t,e),this.emit(e,t)})})),this}enableAutoResize(e=!0){return this.view&&(e?this._resizeObserver?.observe(this.view):this._resizeObserver?.unobserve(this.view)),this}resize(e,t,r=!1){return this.renderer.resize(e,t,r),this.root.width=e,this.root.height=t,this.root.requestUpload(),this.render(),this}nextTick(){return bs()}async waitUntilLoad(){await nt.waitUntilLoad(),await this.nextTick()}async waitAndRender(e=0){await nt.waitUntilLoad(),this._process(e),await this.nextTick(),this._render(this.renderer)}render(e=0){this._process(e),this._render(this.renderer)}async start(){await this.waitAndRender(),super.start(e=>{this._process(e),this._render(this.renderer)})}destroy(){super.destroy(),this.enableAutoResize(!1),this.renderer.destroy()}toPixels(){return this.renderer.toPixels()}toImageData(){return new ImageData(this.toPixels(),this.gl.drawingBufferWidth,this.gl.drawingBufferHeight)}toCanvas2D(){const e=this.toImageData(),t=document.createElement("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r&&(r.fillStyle="rgba(0, 0, 0, 0)",r.clearRect(0,0,t.width,t.height),r.putImageData(e,0,0));const i=document.createElement("canvas");i.width=this.width,i.height=this.height;const n=i.getContext("2d");return n&&(n.fillStyle="rgba(0, 0, 0, 0)",n.clearRect(0,0,i.width,i.height),n.drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height)),i}}let ot;const Hn=[];let Yn=!1;async function Dm(s=100){if(!Yn){for(Yn=!0;Hn.length;){const e=Hn.shift();if(e)try{await e()}catch(t){console.error(t)}else await new Promise(t=>setTimeout(t,s))}Yn=!1}}async function Im(s){const{debug:e=!1,fonts:t,width:r,height:i,time:n=0,data:o}=s;return ot??=new lc({width:1,height:1,preserveDrawingBuffer:!0}),ot.debug=e,ot.fonts=t,ot.root.removeChildren(),ot.timeline.currentTime=n,ot.resize(r,i,!0),(Array.isArray(o)?o:[o]).forEach(a=>{a instanceof u.Node?(a.parent=void 0,ot.root.appendChild(a)):ot.root.appendChild(u.Node.parse(a))}),await s.onBeforeRender?.(ot),await ot.waitAndRender(),ot.toCanvas2D()}async function Rm(s){return new Promise(e=>{Hn.push(async()=>e(await Im(s))),Dm()})}u.AnimatedTexture=Ri,u.Assets=oc,u.AudioPipeline=Xn,u.AudioProcessor=Bg,u.AudioSpectrum=jg,u.BaseElement2DBackground=nn,u.BaseElement2DFill=Te,u.BaseElement2DForeground=on,u.BaseElement2DOutline=Zt,u.BaseElement2DShadow=Jt,u.BaseElement2DShape=Qt,u.BaseElement2DStyle=Qr,u.BaseElement2DText=vt,u.CanvasContext=Fa,u.CanvasTexture=Ui,u.Color=Qe,u.ColorMatrix=ks,u.ColorTexture=tf,u.CoreObject=It,u.DEG_TO_RAD=Go,u.DEVICE_PIXEL_RATIO=Es,u.EffectMaterial=Nr,u.Element2DStyle=Ln,u.Engine=lc,u.FlexElement2DStyle=zl,u.FlexLayout=ss,u.FontLoader=aa,u.Geometry=Ii,u.GifLoader=ec,u.GradientTexture=$r,u.HTMLAudio=Kl,u.HTMLAudioContext=os,u.HTMLSound=gi,u.IN_BROWSER=kr,u.ImageTexture=sf,u.IndexBuffer=dr,u.Input=$o,u.InputEvent=Dr,u.JsonLoader=tc,u.KeyboardInputEvent=Lo,u.Loader=Ut,u.LottieLoader=rc,u.MainLoop=Ci,u.Material=se,u.Matrix=ut,u.Matrix2=xh,u.Matrix3=Ds,u.Matrix4=Vo,u.MouseInputEvent=Os,u.PI=Si,u.PI_2=Ne,u.PixelsTexture=Xs,u.PointerInputEvent=No,u.Projection2D=Wo,u.QuadGeometry=Xu,u.QuadUvGeometry=Q,u.RAD_TO_DEG=bh,u.RawWeakMap=As,u.Rect2=Rt,u.RefCounted=zo,u.Renderer=Xo,u.Resource=St,u.SUPPORTS_AUDIO_CONTEXT=Ss,u.SUPPORTS_CLICK_EVENTS=Mo,u.SUPPORTS_CREATE_IMAGE_BITMAP=Ps,u.SUPPORTS_IMAGE_BITMAP=Co,u.SUPPORTS_MOUSE_EVENTS=gh,u.SUPPORTS_OFFLINE_AUDIO_CONTEXT=Ts,u.SUPPORTS_POINTER_EVENTS=lr,u.SUPPORTS_RESIZE_OBSERVER=To,u.SUPPORTS_TOUCH_EVENTS=Pt,u.SUPPORTS_WEBGL2=So,u.SUPPORTS_WEBKIT_AUDIO_CONTEXT=Cs,u.SUPPORTS_WEBKIT_OFFLINE_AUDIO_CONTEXT=Ao,u.SUPPORTS_WEB_AUDIO=Oo,u.SUPPORTS_WHEEL_EVENTS=Eo,u.SceneTree=qr,u.TextLoader=ic,u.Texture2D=le,u.TextureLoader=sc,u.TextureRect2D=Wn,u.Ticker=Ce,u.Transform2D=ve,u.TransformRect2D=qn,u.UvGeometry=Zu,u.UvMaterial=Fr,u.Vector=et,u.Vector2=de,u.Vector3=Ph,u.Vector4=jo,u.VertexAttribute=je,u.VertexBuffer=Et,u.VideoLoader=nc,u.VideoTexture=Na,u.ViewportTexture=Ys,u.WebAudio=Jl,u.WebAudioContext=Wt,u.WebGLBatch2DModule=Ko,u.WebGLBlendMode=cr,u.WebGLBufferModule=Zo,u.WebGLFramebufferModule=Jo,u.WebGLMaskModule=Qo,u.WebGLModule=Ye,u.WebGLProgramModule=ea,u.WebGLRenderer=oa,u.WebGLScissorModule=ta,u.WebGLState=Xt,u.WebGLStateModule=Yo,u.WebGLStencilModule=ra,u.WebGLTextureModule=ia,u.WebGLVertexArrayModule=sa,u.WebGLViewportModule=na,u.WebSound=Zl,u.WheelInputEvent=Fo,u.alignMap=nr,u.assets=nt,u.boxSizingMap=jn,u.clamp=Ge,u.clampFrag=nl,u.createHTMLCanvas=Ro,u.createNode=ch,u.crossOrigin=Bo,u.cubicBezier=Sr,u.curves=wh,u.customNode=W,u.customNodes=Pi,u.defaultOptions=ac,u.determineCrossOrigin=Uo,u.directionMap=is,u.displayMap=Nn,u.ease=ql,u.easeIn=Xl,u.easeInOut=Yl,u.easeOut=Hl,u.edgeMap=fe,u.flexDirectionMap=Fn,u.flexWrapMap=$n,u.frag=sl,u.getDefaultCssPropertyValue=xs,u.gutterMap=Vl,u.isCanvasElement=Do,u.isElementNode=Ms,u.isImageElement=mh,u.isPow2=ws,u.isVideoElement=ko,u.isWebgl2=Io,u.justifyMap=zn,u.lerp=he,u.linear=Wl,u.log2=Rs,u.mapWebGLBlendModes=Ho,u.nextPow2=Is,u.nextTick=bs,u.overflowMap=Vn,u.parseCSSFilter=kf,u.parseCSSTransform=Va,u.parseCSSTransformOrigin=Ga,u.parseCssFunctions=Or,u.parseCssProperty=Ar,u.positionTypeMap=Gn,u.render=Rm,u.timingFunctions=ns,u.uid=xo,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));