@visactor/vrender
Version:
```typescript import { xxx } from '@visactor/vrender'; ```
1 lines • 1.84 MB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).VRender={})}(this,(function(exports){"use strict";class Hook{constructor(t,e){this._args=t,this.name=e,this.taps=[]}tap(t,e){this._tap("sync",t,e)}unTap(t,e){const i="string"==typeof t?t.trim():t.name;i&&(this.taps=this.taps.filter((t=>!(t.name===i&&(!e||t.fn===e)))))}_parseOptions(t,e,i){let r;if("string"==typeof e)r={name:e.trim()};else if("object"!=typeof e||null===e)throw new Error("Invalid tap options");if("string"!=typeof r.name||""===r.name)throw new Error("Missing name for tap");return r=Object.assign({type:t,fn:i},r),r}_tap(t,e,i){this._insert(this._parseOptions(t,e,i))}_insert(t){let e;"string"==typeof t.before?e=new Set([t.before]):Array.isArray(t.before)&&(e=new Set(t.before));let i=0;"number"==typeof t.stage&&(i=t.stage);let r=this.taps.length;for(;r>0;){r--;const t=this.taps[r];this.taps[r+1]=t;const n=t.stage||0;if(e){if(e.has(t.name)){e.delete(t.name);continue}if(e.size>0)continue}if(!(n>i)){r++;break}}this.taps[r]=t}}class SyncHook extends Hook{call(...t){this.taps.map((t=>t.fn)).forEach((e=>e(...t)))}}class Generator{static GenAutoIncrementId(){return Generator.auto_increment_id++}}Generator.auto_increment_id=0;class Application{}const APPLICATION_STATE_SYMBOL=Symbol.for("@visactor/vrender-core/application-state");function createApplicationState(){return{application:new Application}}function getApplicationState(){const t=globalThis;return t[APPLICATION_STATE_SYMBOL]||(t[APPLICATION_STATE_SYMBOL]=createApplicationState()),t[APPLICATION_STATE_SYMBOL]}const application=getApplicationState().application;let idx=0;class PerformanceRAF{constructor(){this.nextAnimationFrameCbs=new Map,this._rafHandle=null,this.runAnimationFrame=t=>{this._rafHandle=null;const e=this.nextAnimationFrameCbs;this.nextAnimationFrameCbs=new Map,e.forEach((e=>e(t)))},this.tryRunAnimationFrameNextFrame=()=>{null===this._rafHandle&&0!==this.nextAnimationFrameCbs.size&&(this._rafHandle=application.global.getRequestAnimationFrame()(this.runAnimationFrame))}}addAnimationFrameCb(t){return this.nextAnimationFrameCbs.set(++idx,t),this.tryRunAnimationFrameNextFrame(),idx}removeAnimationFrameCb(t){return!!this.nextAnimationFrameCbs.has(t)&&(this.nextAnimationFrameCbs.delete(t),!0)}wait(){return new Promise((t=>{this.addAnimationFrameCb((()=>t()))}))}}class EventListenerManager{constructor(){this._listenerMap=new Map,this._eventListenerTransformer=t=>t}setEventListenerTransformer(t){this._eventListenerTransformer=t||(t=>t)}addEventListener(t,e,i){if(!e)return;const r=this._resolveCapture(i),n=this._resolveOnce(i),s=this._getOrCreateListenerTypeMap(t),a=this._getOrCreateWrappedMap(s,e);if(a.has(r))return;const o=i=>{const s=this._eventListenerTransformer(i);"function"==typeof e?e(s):e.handleEvent&&e.handleEvent(s),n&&this._deleteListenerRecord(t,e,r)};a.set(r,{wrappedListener:o,options:i}),this._nativeAddEventListener(t,o,i)}removeEventListener(t,e,i){var r,n;if(!e)return;const s=this._resolveCapture(i),a=null===(n=null===(r=this._listenerMap.get(t))||void 0===r?void 0:r.get(e))||void 0===n?void 0:n.get(s);a&&(this._nativeRemoveEventListener(t,a.wrappedListener,s),this._deleteListenerRecord(t,e,s))}dispatchEvent(t){return this._nativeDispatchEvent(t)}clearAllEventListeners(){this._listenerMap.forEach(((t,e)=>{t.forEach((t=>{t.forEach(((t,i)=>{this._nativeRemoveEventListener(e,t.wrappedListener,i)}))}))})),this._listenerMap.clear()}_resolveCapture(t){return"boolean"==typeof t?t:!!(null==t?void 0:t.capture)}_resolveOnce(t){return"object"==typeof t&&!!(null==t?void 0:t.once)}_getOrCreateListenerTypeMap(t){let e=this._listenerMap.get(t);return e||(e=new Map,this._listenerMap.set(t,e)),e}_getOrCreateWrappedMap(t,e){let i=t.get(e);return i||(i=new Map,t.set(e,i)),i}_deleteListenerRecord(t,e,i){const r=this._listenerMap.get(t);if(!r)return;const n=r.get(e);n&&(n.delete(i),0===n.size&&r.delete(e),0===r.size&&this._listenerMap.delete(t))}_nativeAddEventListener(t,e,i){throw new Error("_nativeAddEventListener must be implemented by derived classes")}_nativeRemoveEventListener(t,e,i){throw new Error("_nativeRemoveEventListener must be implemented by derived classes")}_nativeDispatchEvent(t){throw new Error("_nativeDispatchEvent must be implemented by derived classes")}}var __awaiter$7=function(t,e,i,r){return new(i||(i=Promise))((function(n,s){function a(t){try{l(r.next(t))}catch(t){s(t)}}function o(t){try{l(r.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}l((r=r.apply(t,e||[])).next())}))};class DefaultGlobal extends EventListenerManager{get env(){return this._env}get isImageAnonymous(){return this._isImageAnonymous}set isImageAnonymous(t){this._isImageAnonymous=t}get devicePixelRatio(){return this._env||this.setEnv("browser"),this.envContribution.getDevicePixelRatio()}get supportEvent(){return this._env||this.setEnv("browser"),this.envContribution.supportEvent}set supportEvent(t){this._env||this.setEnv("browser"),this.envContribution.supportEvent=t}get supportsTouchEvents(){return this._env||this.setEnv("browser"),this.envContribution.supportsTouchEvents}set supportsTouchEvents(t){this._env||this.setEnv("browser"),this.envContribution.supportsTouchEvents=t}get supportsPointerEvents(){return this._env||this.setEnv("browser"),this.envContribution.supportsPointerEvents}set supportsPointerEvents(t){this._env||this.setEnv("browser"),this.envContribution.supportsPointerEvents=t}get supportsMouseEvents(){return this._env||this.setEnv("browser"),this.envContribution.supportsMouseEvents}set supportsMouseEvents(t){this._env||this.setEnv("browser"),this.envContribution.supportsMouseEvents=t}get applyStyles(){return this._env||this.setEnv("browser"),this.envContribution.applyStyles}set applyStyles(t){this._env||this.setEnv("browser"),this.envContribution.applyStyles=t}constructor(t){super(),this.contributions=t,this._isImageAnonymous=!0,this._performanceRAFList=[],this.eventListenerTransformer=t=>t,this.id=Generator.GenAutoIncrementId(),this.hooks={onSetEnv:new SyncHook(["lastEnv","env","global"])},this.measureTextMethod="native",this.optimizeVisible=!1}_nativeAddEventListener(t,e,i){return this._env||this.setEnv("browser"),this.envContribution.addEventListener(t,e,i)}_nativeRemoveEventListener(t,e,i){return this._env||this.setEnv("browser"),this.envContribution.removeEventListener(t,e,i)}_nativeDispatchEvent(t){return this._env||this.setEnv("browser"),this.envContribution.dispatchEvent(t)}bindContribution(t){const e=[];if(this.contributions.getContributions().forEach((i=>{const r=i.configure(this,t);r&&r.then&&e.push(r)})),e.length)return Promise.all(e)}getDynamicCanvasCount(){return this._env||this.setEnv("browser"),this.envContribution.getDynamicCanvasCount()}getStaticCanvasCount(){return this._env||this.setEnv("browser"),this.envContribution.getStaticCanvasCount()}setEnv(t,e){if(e&&!0===e.force||this._env!==t)return this.deactiveCurrentEnv(),this.activeEnv(t,e)}deactiveCurrentEnv(){this.envContribution&&this.envContribution.release()}activeEnv(t,e){const i=this._env;this._env=t;const r=this.bindContribution(e);if(r&&r.then)return r.then((()=>{this.envParams=e,this.hooks.onSetEnv.call(i,t,this)}));this.envParams=e,this.hooks.onSetEnv.call(i,t,this)}setActiveEnvContribution(t){this.envContribution=t}createCanvas(t){return this._env||this.setEnv("browser"),this.envContribution.createCanvas(t)}createOffscreenCanvas(t){return this._env||this.setEnv("browser"),this.envContribution.createOffscreenCanvas(t)}releaseCanvas(t){return this._env||this.setEnv("browser"),this.envContribution.releaseCanvas(t)}getRequestAnimationFrame(){return this._env||this.setEnv("browser"),this.envContribution.getRequestAnimationFrame()}getSpecifiedRequestAnimationFrame(t){this._env||this.setEnv("browser"),this._performanceRAFList[t]||(this._performanceRAFList[t]=new PerformanceRAF);const e=this._performanceRAFList[t];return t=>e.addAnimationFrameCb(t)}getSpecifiedPerformanceRAF(t){return this._env||this.setEnv("browser"),this._performanceRAFList[t]||(this._performanceRAFList[t]=new PerformanceRAF),this._performanceRAFList[t]}getSpecifiedCancelAnimationFrame(t){if(this._env||this.setEnv("browser"),!this._performanceRAFList[t])return()=>!1;const e=this._performanceRAFList[t];return t=>e.removeAnimationFrameCb(t)}getCancelAnimationFrame(){return this._env||this.setEnv("browser"),this.envContribution.getCancelAnimationFrame()}getElementById(t){return this._env||this.setEnv("browser"),this.envContribution.getElementById?this.envContribution.getElementById(t):null}getRootElement(){return this._env||this.setEnv("browser"),this.envContribution.getRootElement?this.envContribution.getRootElement():null}getDocument(){return this._env||this.setEnv("browser"),this.envContribution.getDocument?this.envContribution.getDocument():null}mapToCanvasPoint(t,e){return this._env||this.setEnv("browser"),this.envContribution.mapToCanvasPoint?this.envContribution.mapToCanvasPoint(t,e):null}loadImage(t){return this._env||this.setEnv("browser"),this.envContribution.loadImage(t)}loadSvg(t){return this._env||this.setEnv("browser"),this.envContribution.loadSvg(t)}loadJson(t){return this._env||this.setEnv("browser"),this.envContribution.loadJson(t)}loadArrayBuffer(t){return this._env||this.setEnv("browser"),this.envContribution.loadArrayBuffer(t)}loadBlob(t){return this._env||this.setEnv("browser"),this.envContribution.loadBlob(t)}loadFont(t,e,i){return __awaiter$7(this,void 0,void 0,(function*(){return this._env||this.setEnv("browser"),this.envContribution.loadFont(t,e,i)}))}isChrome(){return null!=this._isChrome||(this._env||this.setEnv("browser"),this._isChrome="browser"===this._env&&navigator.userAgent.indexOf("Chrome")>-1),this._isChrome}isSafari(){return null!=this._isSafari||(this._env||this.setEnv("browser"),this._isSafari="browser"===this._env&&/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)),this._isSafari}getNativeAABBBounds(t){return this._env||this.setEnv("browser"),this.envContribution.getNativeAABBBounds(t)}removeDom(t){return this._env||this.setEnv("browser"),this.envContribution.removeDom(t)}createDom(t){return this._env||this.setEnv("browser"),this.envContribution.createDom(t)}updateDom(t,e){return this._env||this.setEnv("browser"),this.envContribution.updateDom(t,e)}getElementTop(t,e=!1){return this._env||this.setEnv("browser"),this.envContribution.getElementTop(t,e)}getElementLeft(t,e=!1){return this._env||this.setEnv("browser"),this.envContribution.getElementLeft(t,e)}getElementTopLeft(t,e=!1){return this._env||this.setEnv("browser"),this.envContribution.getElementTopLeft(t,e)}isMacOS(){return this._env||this.setEnv("browser"),this.envContribution.isMacOS()}copyToClipBoard(t){return this._env||this.setEnv("browser"),this.envContribution.copyToClipBoard(t)}}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var eventemitter3={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function r(){}function n(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function s(t,e,r,s,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new n(r,s||t,a),l=i?i+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function o(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(i=!1)),o.prototype.eventNames=function(){var t,r,n=[];if(0===this._eventsCount)return n;for(r in t=this._events)e.call(t,r)&&n.push(i?r.slice(1):r);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(t)):n},o.prototype.listeners=function(t){var e=i?i+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var n=0,s=r.length,a=new Array(s);n<s;n++)a[n]=r[n].fn;return a},o.prototype.listenerCount=function(t){var e=i?i+t:t,r=this._events[e];return r?r.fn?1:r.length:0},o.prototype.emit=function(t,e,r,n,s,a){var o=i?i+t:t;if(!this._events[o])return!1;var l,h,c=this._events[o],u=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,r),!0;case 4:return c.fn.call(c.context,e,r,n),!0;case 5:return c.fn.call(c.context,e,r,n,s),!0;case 6:return c.fn.call(c.context,e,r,n,s,a),!0}for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];c.fn.apply(c.context,l)}else{var d,p=c.length;for(h=0;h<p;h++)switch(c[h].once&&this.removeListener(t,c[h].fn,void 0,!0),u){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,e);break;case 3:c[h].fn.call(c[h].context,e,r);break;case 4:c[h].fn.call(c[h].context,e,r,n);break;default:if(!l)for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c[h].fn.apply(c[h].context,l)}}return!0},o.prototype.on=function(t,e,i){return s(this,t,e,i,!1)},o.prototype.once=function(t,e,i){return s(this,t,e,i,!0)},o.prototype.removeListener=function(t,e,r,n){var s=i?i+t:t;if(!this._events[s])return this;if(!e)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==e||n&&!o.once||r&&o.context!==r||a(this,s);else{for(var l=0,h=[],c=o.length;l<c;l++)(o[l].fn!==e||n&&!o[l].once||r&&o[l].context!==r)&&h.push(o[l]);h.length?this._events[s]=1===h.length?h[0]:h:a(this,s)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&a(this,e)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,t.exports=o}(eventemitter3);var eventemitter3Exports=eventemitter3.exports,EventEmitter=getDefaultExportFromCjs(eventemitter3Exports);const isType=(t,e)=>Object.prototype.toString.call(t)===`[object ${e}]`;var isType$1=isType;const isBoolean=(t,e=!1)=>e?"boolean"==typeof t:!0===t||!1===t||isType$1(t,"Boolean");var isBoolean$1=isBoolean;const isFunction=t=>"function"==typeof t;var isFunction$1=isFunction;const isNil=t=>null==t;var isNil$1=isNil;const isValid=t=>null!=t;var isValid$1=isValid;const isObject=t=>{const e=typeof t;return null!==t&&"object"===e||"function"===e};var isObject$1=isObject;const isObjectLike=t=>"object"==typeof t&&null!==t;var isObjectLike$1=isObjectLike;const isPlainObject$2=function(t){if(!isObjectLike$1(t)||!isType$1(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};var isPlainObject$3=isPlainObject$2;const isUndefined=t=>void 0===t;var isUndefined$1=isUndefined;const isString=(t,e=!1)=>{const i=typeof t;return e?"string"===i:"string"===i||isType$1(t,"String")};var isString$1=isString;const isArray=t=>Array.isArray?Array.isArray(t):isType$1(t,"Array");var isArray$1=isArray;const isArrayLike=function(t){return null!==t&&"function"!=typeof t&&Number.isFinite(t.length)};var isArrayLike$1=isArrayLike;const isDate=t=>isType$1(t,"Date");var isDate$1=isDate;const isNumber$1=(t,e=!1)=>{const i=typeof t;return e?"number"===i:"number"===i||isType$1(t,"Number")};var isNumber$2=isNumber$1;const isValidNumber=t=>isNumber$2(t)&&Number.isFinite(t);var isValidNumber$1=isValidNumber;const isValidUrl=t=>new RegExp(/^(http(s)?:\/\/)\w+[^\s]+(\.[^\s]+){1,}$/).test(t);var isValidUrl$1=isValidUrl;const isBase64=t=>new RegExp(/^data:image\/(?:gif|png|jpeg|bmp|webp|svg\+xml)(?:;charset=utf-8)?;base64,(?:[A-Za-z0-9]|[+/])+={0,2}/g).test(t);var isBase64$1=isBase64;const getType=t=>({}.toString.call(t).replace(/^\[object /,"").replace(/]$/,""));var getType$1=getType;const objectProto=Object.prototype,isPrototype=function(t){const e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||objectProto)};var isPrototype$1=isPrototype;const hasOwnProperty$1=Object.prototype.hasOwnProperty;function isEmpty(t){if(isNil$1(t))return!0;if(isArrayLike$1(t))return!t.length;const e=getType$1(t);if("Map"===e||"Set"===e)return!t.size;if(isPrototype$1(t))return!Object.keys(t).length;for(const e in t)if(hasOwnProperty$1.call(t,e))return!1;return!0}const get=(t,e,i)=>{const r=isString$1(e)?e.split("."):e;for(let e=0;e<r.length;e++)t=t?t[r[e]]:void 0;return void 0===t?i:t};var get$1=get;const hasOwnProperty=Object.prototype.hasOwnProperty,has=(t,e)=>null!=t&&hasOwnProperty.call(t,e);var has$1=has;function cloneDeep(t,e,i){let r;if(!isValid$1(t)||"object"!=typeof t||e&&e(t))return t;const n=isArray$1(t),s=t.length;r=n?new Array(s):"object"==typeof t?{}:isBoolean$1(t)||isNumber$2(t)||isString$1(t)?t:isDate$1(t)?new Date(+t):void 0;const a=n?void 0:Object.keys(Object(t));let o=-1;if(r)for(;++o<(a||t).length;){const n=a?a[o]:o,s=t[n];i&&i.includes(n.toString())?r[n]=s:r[n]=cloneDeep(s,e,i)}return r}function baseMerge(t,e,i=!1,r=!1){if(e){if(t===e)return;if(isValid$1(e)&&"object"==typeof e){const n=Object(e),s=[];for(const t in n)s.push(t);let{length:a}=s,o=-1;for(;a--;){const a=s[++o];!isValid$1(n[a])||"object"!=typeof n[a]||r&&isArray$1(t[a])?assignMergeValue(t,a,n[a]):baseMergeDeep(t,e,a,i,r)}}}}function baseMergeDeep(t,e,i,r=!1,n=!1){const s=t[i],a=e[i];let o=e[i],l=!0;if(isArray$1(a)){if(r)o=[];else if(isArray$1(s))o=s;else if(isArrayLike$1(s)){o=new Array(s.length);let t=-1;const e=s.length;for(;++t<e;)o[t]=s[t]}}else isPlainObject$3(a)?(o=null!=s?s:{},"function"!=typeof s&&"object"==typeof s||(o={})):l=!1;l&&baseMerge(o,a,r,n),assignMergeValue(t,i,o)}function assignMergeValue(t,e,i){(void 0!==i&&!eq(t[e],i)||void 0===i&&!(e in t))&&(t[e]=i)}function eq(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function merge(t,...e){let i=-1;const r=e.length;for(;++i<r;)baseMerge(t,e[i],!0);return t}function objToString(t){return Object.prototype.toString.call(t)}function objectKeys(t){return Object.keys(t)}function isEqual(t,e,i){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(null==t||null==e)return!1;if(Number.isNaN(t)&&Number.isNaN(e))return!0;if(objToString(t)!==objToString(e))return!1;if(isFunction$1(t))return!!(null==i?void 0:i.skipFunction);if("object"!=typeof t)return!1;if(isArray$1(t)){if(t.length!==e.length)return!1;for(let r=t.length-1;r>=0;r--)if(!isEqual(t[r],e[r],i))return!1;return!0}if(!isPlainObject$3(t))return!1;const r=objectKeys(t),n=objectKeys(e);if(r.length!==n.length)return!1;r.sort(),n.sort();for(let t=r.length-1;t>=0;t--)if(r[t]!=n[t])return!1;for(let n=r.length-1;n>=0;n--){const s=r[n];if(!isEqual(t[s],e[s],i))return!1}return!0}function keys(t){if(!t)return[];if(Object.keys)return Object.keys(t);const e=[];for(const i in t)t.hasOwnProperty(i)&&e.push(i);return e}function defaults(t,e,i){const r=keys(e);for(let n=0;n<r.length;n++){const s=r[n];(i?null!=e[s]:null==t[s])&&(t[s]=e[s])}return t}function mixin(t,e,i=!0){if(t="prototype"in t?t.prototype:t,e="prototype"in e?e.prototype:e,Object.getOwnPropertyNames){const r=Object.getOwnPropertyNames(e);for(let n=0;n<r.length;n++){const s=r[n];"constructor"!==s&&(i?null!=e[s]:null==t[s])&&(t[s]=e[s])}}else defaults(t,e,i)}function array(t){return isValid$1(t)?isArray$1(t)?t:[t]:[]}function last(t){if(isArrayLike$1(t))return t[t.length-1]}const maxInArray=(t,e)=>{var i;if(0===t.length)return;let r=t[0];for(let n=1;n<t.length;n++){const s=t[n];(null!==(i=null==e?void 0:e(s,r))&&void 0!==i?i:s-r)>0&&(r=s)}return r},minInArray=(t,e)=>{var i;if(0===t.length)return;let r=t[0];for(let n=1;n<t.length;n++){const s=t[n];(null!==(i=null==e?void 0:e(s,r))&&void 0!==i?i:s-r)<0&&(r=s)}return r};function arrayEqual(t,e){if(!isArray$1(t)||!isArray$1(e))return!1;if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function flattenArray(t){if(!isArray$1(t))return[t];const e=[];for(const i of t)e.push(...flattenArray(i));return e}function range(t,e,i){isValid$1(e)||(e=t,t=0),isValid$1(i)||(i=1);let r=-1;const n=0|Math.max(0,Math.ceil((e-t)/i)),s=new Array(n);for(;++r<n;)s[r]=t+r*i;return s}function ascending(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function toNumber(t){return Number(t)}const hasConsole="undefined"!=typeof console;function log(t,e,i){const r=[e].concat([].slice.call(i));hasConsole&&console[t].apply(console,r)}var LoggerLevel;!function(t){t[t.None=0]="None",t[t.Error=1]="Error",t[t.Warn=2]="Warn",t[t.Info=3]="Info",t[t.Debug=4]="Debug"}(LoggerLevel||(LoggerLevel={}));class Logger{static getInstance(t,e){return Logger._instance&&isNumber$2(t)?Logger._instance.level(t):Logger._instance||(Logger._instance=new Logger(t,e)),Logger._instance}static setInstance(t){return Logger._instance=t}static setInstanceLevel(t){Logger._instance?Logger._instance.level(t):Logger._instance=new Logger(t)}static clearInstance(){Logger._instance=null}constructor(t=LoggerLevel.None,e){this._onErrorHandler=[],this._level=t,this._method=e}addErrorHandler(t){this._onErrorHandler.find((e=>e===t))||this._onErrorHandler.push(t)}removeErrorHandler(t){const e=this._onErrorHandler.findIndex((e=>e===t));e<0||this._onErrorHandler.splice(e,1)}callErrorHandler(...t){this._onErrorHandler.forEach((e=>e(...t)))}canLogInfo(){return this._level>=LoggerLevel.Info}canLogDebug(){return this._level>=LoggerLevel.Debug}canLogError(){return this._level>=LoggerLevel.Error}canLogWarn(){return this._level>=LoggerLevel.Warn}level(t){return arguments.length?(this._level=+t,this):this._level}error(...t){var e;return this._level>=LoggerLevel.Error&&(this._onErrorHandler.length?this.callErrorHandler(...t):log(null!==(e=this._method)&&void 0!==e?e:"error","ERROR",t)),this}warn(...t){return this._level>=LoggerLevel.Warn&&log(this._method||"warn","WARN",t),this}info(...t){return this._level>=LoggerLevel.Info&&log(this._method||"log","INFO",t),this}debug(...t){return this._level>=LoggerLevel.Debug&&log(this._method||"log","DEBUG",t),this}}function bisect(t,e,i=0,r){for(isNil$1(r)&&(r=t.length);i<r;){const n=i+r>>>1;ascending(t[n],e)>0?r=n:i=n+1}return i}Logger._instance=null;const binaryFuzzySearchInNumberRange=(t,e,i)=>{let r=t,n=e;for(;r<n;){const t=Math.floor((r+n)/2);i(t)>=0?n=t:r=t+1}return r},DEFAULT_ABSOLUTE_TOLERATE=1e-10,DEFAULT_RELATIVE_TOLERATE=1e-10;function isNumberClose(t,e,i=DEFAULT_RELATIVE_TOLERATE,r=DEFAULT_ABSOLUTE_TOLERATE){const n=r,s=i*Math.max(t,e);return Math.abs(t-e)<=Math.max(n,s)}function isGreater(t,e,i,r){return t>e&&!isNumberClose(t,e,i,r)}function isLess(t,e,i,r){return t<e&&!isNumberClose(t,e,i,r)}const memoize=t=>{let e=null,i=null;return(...r)=>(e&&r.every(((t,i)=>t===e[i]))||(e=r,i=t(...r)),i)},clamp=function(t,e,i){return t<e?e:t>i?i:t};var clamp$1=clamp;const clampRange=(t,e,i)=>{let[r,n]=t;n<r&&(r=t[1],n=t[0]);const s=n-r;return s>=i-e?[e,i]:(r=Math.min(Math.max(r,e),i-s),[r,r+s])};var clampRange$1=clampRange;function clamper(t,e){let i;return t>e&&(i=t,t=e,e=i),i=>Math.max(t,Math.min(e,i))}let hasRaf=!1;try{hasRaf="function"==typeof requestAnimationFrame&&"function"==typeof cancelAnimationFrame}catch(t){hasRaf=!1}function debounce(t,e,i){let r,n,s,a,o,l,h=0,c=!1,u=!1,d=!0;const p=!e&&0!==e&&hasRaf;if("function"!=typeof t)throw new TypeError("Expected a function");function g(e){const i=r,s=n;return r=n=void 0,h=e,a=t.apply(s,i),a}function f(t,e){return p?(cancelAnimationFrame(o),requestAnimationFrame(t)):setTimeout(t,e)}function m(t){const i=t-l;return void 0===l||i>=e||i<0||u&&t-h>=s}function v(){const t=Date.now();if(m(t))return b(t);o=f(v,function(t){const i=t-h,r=e-(t-l);return u?Math.min(r,s-i):r}(t))}function b(t){return o=void 0,d&&r?g(t):(r=n=void 0,a)}function y(...t){const i=Date.now(),s=m(i);if(r=t,n=this,l=i,s){if(void 0===o)return function(t){return h=t,o=f(v,e),c?g(t):a}(l);if(u)return o=f(v,e),g(l)}return void 0===o&&(o=f(v,e)),a}return e=+e||0,isObject$1(i)&&(c=!!i.leading,u="maxWait"in i,u&&(s=Math.max(isValidNumber$1(i.maxWait)?i.maxWait:0,e)),d="trailing"in i?!!i.trailing:d),y.cancel=function(){void 0!==o&&function(t){if(p)return cancelAnimationFrame(t);clearTimeout(t)}(o),h=0,r=l=n=o=void 0},y.flush=function(){return void 0===o?a:b(Date.now())},y.pending=function(){return void 0!==o},y}function throttle(t,e,i){let r=!0,n=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return isObject$1(i)&&(r="leading"in i?!!i.leading:r,n="trailing"in i?!!i.trailing:n),debounce(t,e,{leading:r,trailing:n,maxWait:e})}function interpolateNumber$1(t,e){return i=>t*(1-i)+e*i}function interpolateNumberRound(t,e){return function(i){return Math.round(t*(1-i)+e*i)}}function interpolateDate(t,e){const i=t.valueOf(),r=e.valueOf(),n=new Date;return t=>(n.setTime(i*(1-t)+r*t),n)}hasRaf=!1;const reA=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,reB=new RegExp(reA.source,"g");function zero(t){return function(){return t}}function one(t){return function(e){return t(e)+""}}function interpolateString(t,e){let i,r,n,s=reA.lastIndex=reB.lastIndex=0,a=-1;const o=[],l=[];for(t+="",e+="";(i=reA.exec(t))&&(r=reB.exec(e));)(n=r.index)>s&&(n=e.slice(s,n),o[a]?o[a]+=n:o[++a]=n),(i=i[0])===(r=r[0])?o[a]?o[a]+=r:o[++a]=r:(o[++a]=null,l.push({i:a,x:interpolateNumber$1(i,r)})),s=reB.lastIndex;return s<e.length&&(n=e.slice(s),o[a]?o[a]+=n:o[++a]=n),o.length<2?l[0]?one(l[0].x):zero(e):(e=l.length,function(t){for(let i,r=0;r<e;++r)o[(i=l[r]).i]=i.x(t);return o.join("")})}const epsilon=1e-12,pi=Math.PI,halfPi$1=pi/2,tau=2*pi,pi2=2*Math.PI,abs=Math.abs,atan2=Math.atan2,cos=Math.cos,max=Math.max,min=Math.min,sin=Math.sin,sqrt=Math.sqrt,pow=Math.pow;function acos(t){return t>1?0:t<-1?pi:Math.acos(t)}function asin(t){return t>=1?halfPi$1:t<=-1?-halfPi$1:Math.asin(t)}function pointAt(t,e,i,r,n){let s=i,a=r;return"number"==typeof t&&"number"==typeof i&&(s=(1-n)*t+n*i),"number"==typeof e&&"number"==typeof r&&(a=(1-n)*e+n*r),{x:s,y:a}}function crossProduct$1(t,e){return t[0]*e[1]-t[1]*e[0]}function fuzzyEqualVec(t,e){return abs(t[0]-e[0])+abs(t[1]-e[1])<1e-12}class Point{constructor(t=0,e=0,i,r){this.x=0,this.y=0,this.x=t,this.y=e,this.x1=i,this.y1=r}clone(){return new Point(this.x,this.y)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x1=t.x1,this.y1=t.y1,this.defined=t.defined,this.context=t.context,this}set(t,e){return this.x=t,this.y=e,this}add(t){return isNumber$2(t)?(this.x+=t,void(this.y+=t)):(this.x+=t.x,this.y+=t.y,this)}sub(t){return isNumber$2(t)?(this.x-=t,void(this.y-=t)):(this.x-=t.x,this.y-=t.y,this)}multi(t){throw new Error("暂不支持")}div(t){throw new Error("暂不支持")}}class PointService{static distancePP(t,e){return sqrt(pow(t.x-e.x,2)+pow(t.y-e.y,2))}static distanceNN(t,e,i,r){return sqrt(pow(t-i,2)+pow(e-r,2))}static distancePN(t,e,i){return sqrt(pow(e-t.x,2)+pow(i-t.y,2))}static pointAtPP(t,e,i){return new Point((e.x-t.x)*i+t.x,(e.y-t.y)*i+t.y)}}function degreeToRadian(t){return t*(Math.PI/180)}function radianToDegree(t){return 180*t/Math.PI}const clampRadian$1=(t=0)=>{if(t<0)for(;t<-tau;)t+=tau;else if(t>0)for(;t>tau;)t-=tau;return t},clampAngleByRadian=clampRadian$1;function polarToCartesian(t,e,i){return e?{x:t.x+e*Math.cos(i),y:t.y+e*Math.sin(i)}:{x:t.x,y:t.y}}function getAngleByPoint(t,e){return Math.atan2(e.y-t.y,e.x-t.x)}function normalizeAngle(t){for(;t<0;)t+=2*Math.PI;for(;t>=2*Math.PI;)t-=2*Math.PI;return t}function computeQuadrant(t){return(t=normalizeAngle(t))>0&&t<=Math.PI/2?2:t>Math.PI/2&&t<=Math.PI?3:t>Math.PI&&t<=3*Math.PI/2?4:1}function sub(t,e,i){t[0]=e[0]-i[0],t[1]=e[1]-i[1]}function isIntersect$1(t,e,i,r){let n=t[0],s=e[0],a=i[0],o=r[0];return s<n&&([n,s]=[s,n]),o<a&&([o,a]=[a,o]),!(s<a||o<n||(n=t[1],s=e[1],a=i[1],o=r[1],s<n&&([n,s]=[s,n]),o<a&&([o,a]=[a,o]),s<a||o<n))}function getIntersectPoint(t,e,i,r){if(!isIntersect$1(t,e,i,r))return!1;const n=[0,0],s=[0,0],a=[0,0];if(sub(n,e,t),sub(s,r,i),fuzzyEqualVec(n,s))return!0;sub(a,i,t);const o=crossProduct$1(a,s)/crossProduct$1(n,s);return o>=0&&o<=1&&[t[0]+n[0]*o,t[1]+n[1]*o]}function getRectIntersect(t,e,i){if(null===t)return e;if(null===e)return t;const{x11:r,x12:n,y11:s,y12:a,x21:o,x22:l,y21:h,y22:c}=formatTwoBBox(t,e,i);return r>=l||n<=o||s>=c||a<=h?{x1:0,y1:0,x2:0,y2:0}:{x1:Math.max(r,o),y1:Math.max(s,h),x2:Math.min(n,l),y2:Math.min(a,c)}}var InnerBBox;!function(t){t[t.NONE=0]="NONE",t[t.BBOX1=1]="BBOX1",t[t.BBOX2=2]="BBOX2"}(InnerBBox||(InnerBBox={}));const formatTwoBBox=(t,e,i)=>{let r=t.x1,n=t.x2,s=t.y1,a=t.y2,o=e.x1,l=e.x2,h=e.y1,c=e.y2;return i&&(r>n&&([r,n]=[n,r]),s>a&&([s,a]=[a,s]),o>l&&([o,l]=[l,o]),h>c&&([h,c]=[c,h])),{x11:r,x12:n,y11:s,y12:a,x21:o,x22:l,y21:h,y22:c}};function rectInsideAnotherRect(t,e,i){if(!t||!e)return InnerBBox.NONE;const{x11:r,x12:n,y11:s,y12:a,x21:o,x22:l,y21:h,y22:c}=formatTwoBBox(t,e,i);return r>o&&n<l&&s>h&&a<c?InnerBBox.BBOX1:o>r&&l<n&&h>s&&c<a?InnerBBox.BBOX2:InnerBBox.NONE}function isRectIntersect(t,e,i){if(t&&e){if(!i)return!(t.x1>e.x2||t.x2<e.x1||t.y1>e.y2||t.y2<e.y1);const{x11:r,x12:n,y11:s,y12:a,x21:o,x22:l,y21:h,y22:c}=formatTwoBBox(t,e,!0);return!(r>l||n<o||s>c||a<h)}return!0}function pointInRect(t,e,i){if(!e)return!0;if(!i)return t.x>=e.x1&&t.x<=e.x2&&t.y>=e.y1&&t.y<=e.y2;let r=e.x1,n=e.x2,s=e.y1,a=e.y2;return r>n&&([r,n]=[n,r]),s>a&&([s,a]=[a,s]),t.x>=r&&t.x<=n&&t.y>=s&&t.y<=a}function getProjectionRadius(t,e){return Math.abs(e[0]*t[0]+e[1]*t[1])}function rotatePoint({x:t,y:e},i,r={x:0,y:0}){return{x:(t-r.x)*Math.cos(i)-(e-r.y)*Math.sin(i)+r.x,y:(t-r.x)*Math.sin(i)+(e-r.y)*Math.cos(i)+r.y}}function getCenterPoint(t){return{x:(t.x1+t.x2)/2,y:(t.y1+t.y2)/2}}function toRect(t,e){const i=e?degreeToRadian(t.angle):t.angle,r=getCenterPoint(t);return[rotatePoint({x:t.x1,y:t.y1},i,r),rotatePoint({x:t.x2,y:t.y1},i,r),rotatePoint({x:t.x2,y:t.y2},i,r),rotatePoint({x:t.x1,y:t.y2},i,r)]}function isRotateAABBIntersect(t,e,i=!1){const r=toRect(t,i),n=toRect(e,i),s=(t,e)=>[e.x-t.x,e.y-t.y],a=s(getCenterPoint(t),getCenterPoint(e)),o=s(r[0],r[1]),l=s(r[1],r[2]),h=s(n[0],n[1]),c=s(n[1],n[2]),u=i?degreeToRadian(t.angle):t.angle;let d=i?degreeToRadian(90-t.angle):t.angle+halfPi$1;const p=i?degreeToRadian(e.angle):e.angle;let g=i?degreeToRadian(90-e.angle):e.angle+halfPi$1;d>pi2&&(d-=pi2),g>pi2&&(g-=pi2);const f=(t,e,i,r)=>{const n=[Math.cos(e),Math.sin(e)];return t+(getProjectionRadius(n,i)+getProjectionRadius(n,r))/2>getProjectionRadius(n,a)};return f((t.x2-t.x1)/2,u,h,c)&&f((t.y2-t.y1)/2,d,h,c)&&f((e.x2-e.x1)/2,p,o,l)&&f((e.y2-e.y1)/2,g,o,l)}const EPSILON$1=1e-8;function polygonContainPoint(t,e,i){let r=0,n=t[0];if(!n)return!1;for(let s=1;s<t.length;s++){const a=t[s];r+=isPointInLine(n.x,n.y,a.x,a.y,e,i),n=a}const s=t[0];return isAroundEqual$1(n.x,s.x)&&isAroundEqual$1(n.y,s.y)||(r+=isPointInLine(n.x,n.y,s.x,s.y,e,i)),0!==r}function isPointInLine(t,e,i,r,n,s){if(s>e&&s>r||s<e&&s<r)return 0;if(r===e)return 0;const a=(s-e)/(r-e);let o=r<e?1:-1;1!==a&&0!==a||(o=r<e?.5:-.5);const l=a*(i-t)+t;return l===n?1/0:l>n?o:0}function isAroundEqual$1(t,e){return Math.abs(t-e)<EPSILON$1}const eastAsianCharacterInfo=t=>{let e=t.charCodeAt(0),i=2===t.length?t.charCodeAt(1):0,r=e;return 55296<=e&&e<=56319&&56320<=i&&i<=57343&&(e&=1023,i&=1023,r=e<<10|i,r+=65536),12288===r||65281<=r&&r<=65376||65504<=r&&r<=65510?"F":8361===r||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?"H":4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?"W":32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||172===r||175===r||10214<=r&&r<=10221||10629<=r&&r<=10630?"Na":161===r||164===r||167<=r&&r<=168||170===r||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||198===r||208===r||215<=r&&r<=216||222<=r&&r<=225||230===r||232<=r&&r<=234||236<=r&&r<=237||240===r||242<=r&&r<=243||247<=r&&r<=250||252===r||254===r||257===r||273===r||275===r||283===r||294<=r&&r<=295||299===r||305<=r&&r<=307||312===r||319<=r&&r<=322||324===r||328<=r&&r<=331||333===r||338<=r&&r<=339||358<=r&&r<=359||363===r||462===r||464===r||466===r||468===r||470===r||472===r||474===r||476===r||593===r||609===r||708===r||711===r||713<=r&&r<=715||717===r||720===r||728<=r&&r<=731||733===r||735===r||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||1025===r||1040<=r&&r<=1103||1105===r||8208===r||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||8240===r||8242<=r&&r<=8243||8245===r||8251===r||8254===r||8308===r||8319===r||8321<=r&&r<=8324||8364===r||8451===r||8453===r||8457===r||8467===r||8470===r||8481<=r&&r<=8482||8486===r||8491===r||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||8585===r||8592<=r&&r<=8601||8632<=r&&r<=8633||8658===r||8660===r||8679===r||8704===r||8706<=r&&r<=8707||8711<=r&&r<=8712||8715===r||8719===r||8721===r||8725===r||8730===r||8733<=r&&r<=8736||8739===r||8741===r||8743<=r&&r<=8748||8750===r||8756<=r&&r<=8759||8764<=r&&r<=8765||8776===r||8780===r||8786===r||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||8853===r||8857===r||8869===r||8895===r||8978===r||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||9675===r||9678<=r&&r<=9681||9698<=r&&r<=9701||9711===r||9733<=r&&r<=9734||9737===r||9742<=r&&r<=9743||9748<=r&&r<=9749||9756===r||9758===r||9792===r||9794===r||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||9839===r||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||9955===r||9960<=r&&r<=9983||10045===r||10071===r||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||65533===r||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?"A":"N"};function getContextFont(t,e={},i){i||(i=1);const{fontStyle:r=e.fontStyle,fontVariant:n=e.fontVariant,fontWeight:s=e.fontWeight,fontSize:a=e.fontSize,fontFamily:o=e.fontFamily}=t;return(r?r+" ":"")+(n?n+" ":"")+(s?s+" ":"")+a*i+"px "+(o||"sans-serif")}class TextMeasure{constructor(t,e){this._numberCharSize=null,this._fullCharSize=null,this._letterCharSize=null,this._specialCharSizeMap={},this._canvas=null,this._context=null,this._contextSaved=!1,this._notSupportCanvas=!1,this._notSupportVRender=!1,this._userSpec={},this.specialCharSet="-/: .,@%'\"~",this._option=t,this._userSpec=null!=e?e:{},this.textSpec=this._initSpec(),isValid$1(t.specialCharSet)&&(this.specialCharSet=t.specialCharSet),this._standardMethod=isValid$1(t.getTextBounds)?this.fullMeasure.bind(this):this.measureWithNaiveCanvas.bind(this)}initContext(){if(this._notSupportCanvas)return!1;if(isNil$1(this._canvas)&&(isValid$1(this._option.getCanvasForMeasure)&&(this._canvas=this._option.getCanvasForMeasure()),isNil$1(this._canvas)&&"undefined"!=typeof window&&void 0!==window.document&&globalThis&&isValid$1(globalThis.document)&&(this._canvas=globalThis.document.createElement("canvas"))),isNil$1(this._context)&&isValid$1(this._canvas)){const t=this._canvas.getContext("2d");isValid$1(t)&&(t.save(),t.font=getContextFont(this.textSpec),this._contextSaved=!0,this._context=t)}return!isNil$1(this._context)||(this._notSupportCanvas=!0,!1)}_initSpec(){var t,e,i;const{defaultFontParams:r={}}=this._option,{fontStyle:n=r.fontStyle,fontVariant:s=r.fontVariant,fontWeight:a=(null!==(t=r.fontWeight)&&void 0!==t?t:"normal"),fontSize:o=(null!==(e=r.fontSize)&&void 0!==e?e:12),fontFamily:l=(null!==(i=r.fontFamily)&&void 0!==i?i:"sans-serif"),align:h,textAlign:c=(null!=h?h:"center"),baseline:u,textBaseline:d=(null!=u?u:"middle"),ellipsis:p,limit:g}=this._userSpec;let{lineHeight:f=o}=this._userSpec;if(isString$1(f)&&"%"===f[f.length-1]){const t=Number.parseFloat(f.substring(0,f.length-1))/100;f=o*t}return{fontStyle:n,fontVariant:s,fontFamily:l,fontSize:o,fontWeight:a,textAlign:c,textBaseline:d,ellipsis:p,limit:g,lineHeight:f}}measure(t,e){switch(e){case"vrender":case"canopus":return this.fullMeasure(t);case"canvas":return this.measureWithNaiveCanvas(t);case"simple":return this.quickMeasureWithoutCanvas(t);default:return this.quickMeasure(t)}}fullMeasure(t){if(isNil$1(t))return{width:0,height:0};if(isNil$1(this._option.getTextBounds)||!this._notSupportVRender)return this.measureWithNaiveCanvas(t);const{fontFamily:e,fontSize:i,fontWeight:r,textAlign:n,textBaseline:s,ellipsis:a,limit:o,lineHeight:l}=this.textSpec;let h;try{const c=this._option.getTextBounds({text:t,fontFamily:e,fontSize:i,fontWeight:r,textAlign:n,textBaseline:s,ellipsis:!!a,maxLineWidth:o||1/0,lineHeight:l});h={width:c.width(),height:c.height()}}catch(e){this._notSupportVRender=!0,h=this.measureWithNaiveCanvas(t)}return h}measureWithNaiveCanvas(t){return this._measureReduce(t,this._measureWithNaiveCanvas.bind(this))}_measureWithNaiveCanvas(t){var e;if(!this.initContext())return this._quickMeasureWithoutCanvas(t);const i=this._context.measureText(t),{fontSize:r,lineHeight:n}=this.textSpec;return{width:i.width,height:null!==(e=n)&&void 0!==e?e:r,fontBoundingBoxAscent:i.fontBoundingBoxAscent,fontBoundingBoxDescent:i.fontBoundingBoxDescent}}quickMeasure(t){return this._measureReduce(t,this._quickMeasure.bind(this))}_quickMeasure(t){const e={width:0,height:0};for(let i=0;i<t.length;i++){const r=t[i];let n=this._measureSpecialChar(r);isNil$1(n)&&TextMeasure.NUMBERS_CHAR_SET.includes(r)&&(n=this._measureNumberChar()),isNil$1(n)&&["F","W"].includes(eastAsianCharacterInfo(r))&&(n=this._measureFullSizeChar()),isNil$1(n)&&(n=this._measureLetterChar()),e.width+=n.width,e.height=Math.max(e.height,n.height),!isNil$1(n.fontBoundingBoxAscent)&&(e.fontBoundingBoxAscent=n.fontBoundingBoxAscent),!isNil$1(n.fontBoundingBoxDescent)&&(e.fontBoundingBoxDescent=n.fontBoundingBoxDescent)}return e}quickMeasureWithoutCanvas(t){return this._measureReduce(t,this._quickMeasureWithoutCanvas.bind(this))}_quickMeasureWithoutCanvas(t){var e;const i={width:0,height:0},{fontSize:r,lineHeight:n}=this.textSpec;for(let e=0;e<t.length;e++){const n=t[e],s=["F","W"].includes(eastAsianCharacterInfo(n))?1:.53;i.width+=s*r}return i.height=null!==(e=n)&&void 0!==e?e:r,i}_measureReduce(t,e){var i;const{fontSize:r,lineHeight:n}=this.textSpec,s={width:0,height:0};if(isNil$1(t))return s;if(isArray$1(t)){const a=t.filter(isValid$1).map((t=>t.toString()));return 0===a.length?s:1===a.length?e(a[0]):{width:a.reduce(((t,i)=>Math.max(t,e(i).width)),0),height:a.length*((null!==(i=n)&&void 0!==i?i:r)+1)+1}}return e(t.toString())}_measureNumberChar(){if(isNil$1(this._numberCharSize)){const t=this._standardMethod(TextMeasure.NUMBERS_CHAR_SET);this._numberCharSize={width:t.width/TextMeasure.NUMBERS_CHAR_SET.length,height:t.height,fontBoundingBoxAscent:t.fontBoundingBoxAscent,fontBoundingBoxDescent:t.fontBoundingBoxDescent}}return this._numberCharSize}_measureFullSizeChar(){return isNil$1(this._fullCharSize)&&(this._fullCharSize=this._standardMethod(TextMeasure.FULL_SIZE_CHAR)),this._fullCharSize}_measureLetterChar(){if(isNil$1(this._letterCharSize)){const t=this._standardMethod(TextMeasure.ALPHABET_CHAR_SET);this._letterCharSize={width:t.width/TextMeasure.ALPHABET_CHAR_SET.length,height:t.height,fontBoundingBoxAscent:t.fontBoundingBoxAscent,fontBoundingBoxDescent:t.fontBoundingBoxDescent}}return this._letterCharSize}_measureSpecialChar(t){return isValid$1(this._specialCharSizeMap[t])?this._specialCharSizeMap[t]:this.specialCharSet.includes(t)?(this._specialCharSizeMap[t]=this._standardMethod(t),this._specialCharSizeMap[t]):null}release(){isValid$1(this._canvas)&&(this._canvas=null),isValid$1(this._context)&&(this._contextSaved&&(this._context.restore(),this._contextSaved=!1),this._context=null)}}TextMeasure.ALPHABET_CHAR_SET="abcdefghijklmnopqrstuvwxyz",TextMeasure.NUMBERS_CHAR_SET="0123456789",TextMeasure.FULL_SIZE_CHAR="字";const calculateAnchorOfBounds=(t,e)=>{const{x1:i,x2:r,y1:n,y2:s}=t,a=Math.abs(r-i),o=Math.abs(s-n);let l=(i+r)/2,h=(n+s)/2,c=0,u=0;switch(e){case"top":case"inside-top":u=-.5;break;case"bottom":case"inside-bottom":u=.5;break;case"left":case"inside-left":c=-.5;break;case"right":case"inside-right":c=.5;break;case"top-right":c=.5,u=-.5;break;case"top-left":c=-.5,u=-.5;break;case"bottom-right":c=.5,u=.5;break;case"bottom-left":c=-.5,u=.5}return l+=c*a,h+=u*o,{x:l,y:h}},aabbSeparation=(t,e)=>Math.max(e.x1-t.x2,t.x1-e.x2,e.y1-t.y2,t.y1-e.y2),obbSeparation=(t,e)=>{const i=[{x:Math.cos(t.angle),y:Math.sin(t.angle)},{x:-Math.sin(t.angle),y:Math.cos(t.angle)},{x:Math.cos(e.angle),y:Math.sin(t.angle)},{x:-Math.sin(e.angle),y:Math.cos(t.angle)}];function r(t,e,i){const r=t.getRotatedCorners().map((t=>t.x*e+t.y*i));return{min:Math.min(...r),max:Math.max(...r)}}let n=0;for(const s of i){const i=r(t,s.x,s.y),a=r(e,s.x,s.y);let o;o=i.max<a.min?a.min-i.max:a.max<i.min?i.min-a.max:0,n=Math.max(n,o)}return n};function transformBoundsWithMatrix(t,e,i){const{x1:r,y1:n,x2:s,y2:a}=e;return i.onlyTranslate()?(t!==e&&t.setValue(e.x1,e.y1,e.x2,e.y2),t.translate(i.e,i.f),e):(t.clear(),t.add(i.a*r+i.c*n+i.e,i.b*r+i.d*n+i.f),t.add(i.a*s+i.c*n+i.e,i.b*s+i.d*n+i.f),t.add(i.a*s+i.c*a+i.e,i.b*s+i.d*a+i.f),t.add(i.a*r+i.c*a+i.e,i.b*r+i.d*a+i.f),e)}class Bounds{constructor(t){t?this.setValue(t.x1,t.y1,t.x2,t.y2):this.clear()}clone(){return new Bounds(this)}clear(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this}empty(){return this.x1===+Number.MAX_VALUE&&this.y1===+Number.MAX_VALUE&&this.x2===-Number.MAX_VALUE&&this.y2===-Number.MAX_VALUE}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}setValue(t=0,e=0,i=0,r=0){return this.x1=t,this.y1=e,this.x2=i,this.y2=r,this}set(t=0,e=0,i=0,r=0){return i<t?(this.x2=t,this.x1=i):(this.x1=t,this.x2=i),r<e?(this.y2=e,this.y1=r):(this.y1=e,this.y2=r),this}add(t=0,e=0){return t<this.x1&&(this.x1=t),e<this.y1&&(this.y1=e),t>this.x2&&(this.x2=t),e>this.y2&&(this.y2=e),this}expand(t=0){return isArray$1(t)?(this.y1-=t[0],this.x2+=t[1],this.y2+=t[2],this.x1-=t[3]):(this.x1-=t,this.y1-=t,this.x2+=t,this.y2+=t),this}round(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this}translate(t=0,e=0){return this.x1+=t,this.x2+=t,this.y1+=e,this.y2+=e,this}rotate(t=0,e=0,i=0){const r=this.rotatedPoints(t,e,i);return this.clear().add(r[0],r[1]).add(r[2],r[3]).add(r[4],r[5]).add(r[6],r[7])}scale(t=0,e=0,i=0,r=0){const n=this.scalePoints(t,e,i,r);return this.clear().add(n[0],n[1]).add(n[2],n[3])}union(t){return t.x1<this.x1&&(this.x1=t.x1),t.y1<this.y1&&(this.y1=t.y1),t.x2>this.x2&&(this.x2=t.x2),t.y2>this.y2&&(this.y2=t.y2),this}intersect(t){return t.x1>this.x1&&(this.x1=t.x1),t.y1>this.y1&&(this.y1=t.y1),t.x2<this.x2&&(this.x2=t.x2),t.y2<this.y2&&(this.y2=t.y2),this}encloses(t){return t&&this.x1<=t.x1&&this.x2>=t.x2&&this.y1<=t.y1&&this.y2>=t.y2}alignsWith(t){return t&&(this.x1===t.x1||this.x2===t.x2||this.y1===t.y1||this.y2===t.y2)}intersects(t){return t&&!(this.x2<t.x1||this.x1>t.x2||this.y2<t.y1||this.y1>t.y2)}contains(t=0,e=0){return!(t<this.x1||t>this.x2||e<this.y1||e>this.y2)}containsPoint(t){return!(t.x<this.x1||t.x>this.x2||t.y<this.y1||t.y>this.y2)}width(){return this.empty()?0:this.x2-this.x1}height(){return this.empty()?0:this.y2-this.y1}scaleX(t=0){return this.x1*=t,this.x2*=t,this}scaleY(t=0){return this.y1*=t,this.y2*=t,this}transformWithMatrix(t){return transformBoundsWithMatrix(this,this,t),this}copy(t){return this.x1=t.x1,this.y1=t.y1,this.x2=t.x2,this.y2=t.y2,this}rotatedPoints(t,e,i){const{x1:r,y1:n,x2:s,y2:a}=this,o=Math.cos(t),l=Math.sin(t),h=e-e*o+i*l,c=i-e*l-i*o;return[o*r-l*n+h,l*r+o*n+c,o*r-l*a+h,l*r+o*a+c,o*s-l*n+h,l*s+o*n+c,o*s-l*a+h,l*s+o*a+c]}scalePoints(t,e,i,r){const{x1:n,y1:s,x2:a,y2:o}=this;return[t*n+(1-t)*i,e*s+(1-e)*r,t*a+(1-t)*i,e*o+(1-e)*r]}}class AABBBounds extends Bounds{}class OBBBounds extends Bounds{constructor(t,e=0){var i;super(t),t&&(this.angle=null!==(i=t.angle)&&void 0!==i?i:e)}intersects(t){return isRotateAABBIntersect(this,t)}setValue(t=0,e=0,i=0,r=0,n=0){return super.setValue(t,e,i,r),this.angle=n,this}clone(){return new OBBBounds(this)}getRotatedCorners(){const t={x:(this.x1+this.x2)/2,y:(this.y1+this.y2)/2};return[rotatePoint({x:this.x1,y:this.y1},this.angle,t),rotatePoint({x:this.x2,y:this.y1},this.angle,t),rotatePoint({x:this.x1,y:this.y2},this.angle,t),rotatePoint({x:this.x2,y:this.y2},this.angle,t)]}}class Matrix{constructor(t=1,e=0,i=0,r=1,n=0,s=0){this.a=t,this.b=e,this.c=i,this.d=r,this.e=n,this.f=s}equalToMatrix(t){return!(this.e!==t.e||this.f!==t.f||this.a!==t.a||this.d!==t.d||this.b!==t.b||this.c!==t.c)}equalTo(t,e,i,r,n,s){return!(this.e!==n||this.f!==s||this.a!==t||this.d!==r||this.b!==e||this.c!==i)}setValue(t,e,i,r,n,s){return this.a=t,this.b=e,this.c=i,this.d=r,this.e=n,this.f=s,this}reset(){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this}getInverse(){const t=this.a,e=this.b,i=this.c,r=this.d,n=this.e,s=this.f,a=new Matrix,o=t*r-e*i;return a.a=r/o,a.b=-e/o,a.c=-i/o,a.d=t/o,a.e=(i*s-r*n)/o,a.f=-(t*s-e*n)/o,a}rotate(t){const e=Math.cos(t),i=Math.sin(t),r=this.a*e+this.c*i,n=this.b*e+this.d*i,s=this.a*-i+this.c*e,a=this.b*-i+this.d*e;return this.a=r,this.b=n,this.c=s,this.d=a,this}rotateByCenter(t,e,i){const r=Math.cos(t),n=Math.sin(t),s=(1-r)*e+n*i,a=(1-r)*i-n*e,o=r*this.a-n*this.b,l=n*this.a+r*this.b,h=r*this.c-n*this.d,c=n*this.c+r*this.d,u=r*this.e-n*this.f+s,d=n*this.e+r*this.f+a;return this.a=o,this.b=l,this.c=h,this.d=c,this.e=u,this.f=d,this}scale(t,e){return this.a*=t,this.b*=t,this.c*=e,this.d*=e,this}setScale(t,e){return this.b=this.b/this.a*t,this.c=this.c/this.d*e,this.a=t,this.d=e,this}transform(t,e,i,r,n,s){return this.multiply(t,e,i,r,n,s),this}translate(t,e){return this.e+=this.a*t+this.c*e,this.f+=this.b*t+this.d*e,this}transpose(){const{a:t,b:e,c:i,d:r,e:n,f:s}=this;return this.a=e,this.b=t,this.c=r,this.d=i,this.e=s,this.f=n,this}multiply(t,e,i,r,n,s){const a=this.a,o=this.b,l=this.c,h=this.d,c=a*t+l*e,u=o*t+h*e,d=a*i+l*r,p=o*i+h*r,g=a*n+l*s+this.e,f=o*n+h*s+this.f;return this.a=c,this.b=u,this.c=d,this.d=p,this.e=g,this.f=f,this}interpolate(t,e){const i=new Matrix;return i.a=this.a+(t.a-this.a)*e,i.b=this.b+(t.b-this.b)*e,i.c=this.c+(t.c-this.c)*e,i.d=this.d+(t.d-this.d)*e,i.e=this.e+(t.e-this.e)*e,i.f=this.f+(t.f-this.f)*e,i}transformPoint(t,e){const{a:i,b:r,c:n,d:s,e:a,f:o}=this,l=i*s-r*n,h=s/l,c=-r/l,u=-n/l,d=i/l,p=(n*o-s*a)/l,g=-(i*o-r*a)/l,{x:f,y:m}=t;e.x=f*h+m*u+p,e.y=f*c+m*d+g}onlyTranslate(t=1){return this.a===t&&0===this.b&&0===this.c&&this.d===t}clone(){return new Matrix(this.a,this.b,this.c,this.d,this.e,this.f)}toTransformAttrs(){const t=this.a,e=this.b,i=this.c,r=this.d,n=t*r-e*i,s={x:this.e,y:this.f,rotateDeg:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!==t||0!==e){const a=Math.sqrt(t*t+e*e);s.rotateDeg=e>0?Math.acos(t/a):-Math.acos(t/a),s.scaleX=a,s.scaleY=n/a,s.skewX=(t*i+e*r)/n,s.skewY=0}else if(0!==i||0!==r){const a=Math.sqrt(i*i+r*r);s.rotateDeg=Math.PI/2-(r>0?Math.acos(-i/a):-Math.acos(i/a)),s.scaleX=n/a,s.scaleY=a,s.skewX=0,s.skewY=(t*i+e*r)/n}return s.rotateDeg=radianToDegree(s.rotateDeg),s}}function normalTransform(t,e,i,r,n,s,a,o){const l=e.a,h=e.b,c=e.c,u=e.d,d=e.e,p=e.f,g=cos(a),f=sin(a);let m,v;o?(m=o[0],v=o[1]):(m=i,v=r);const b=m-i,y=v-r,x=l*g+c*f,A=h*g+u*f,S=c*g-l*f,C=u*g-h*f;t.a=n*x,t.b=n*A,t.c=s*S,t.d=s*C,t.e=d+l*m+c*v-x*b-S*y,t.f=p+h*m+u*v-A*b-C*y}class LRU{constructor(){this.CLEAN_THRESHOLD=1e3,this.L_TIME=1e3,this.R_COUNT=1,this.R_TIMESTAMP_MAX_SIZE=20}clearCache(t,e){const{CLEAN_THRESHOLD:i=this.CLEAN_THRESHOLD,L_TIME:r=this.L_TIME,R_COUNT:n=this.R_COUNT}=e;if(t.size<i)return 0;let s=0;const a=e=>{s++,t.delete(e)},o=Date.now();return t.forEach(((t,e)=>{if(t.timestamp.length<n)return a(e);let i=0;for(;o-t.timestamp[t.timestamp.length-1-i]<r&&(i++,!(i>=n)););if(i<n)return a(e);for(;o-t.timestamp[0]>r;)t.timestamp.shift()})),s}addLimitedTimestamp(t,e,i){const{R_TIMESTAMP_MAX_SIZE:r=this.R_TIMESTAMP_MAX_SIZE}=i;t.timestamp.length>r&&t.timestamp.shift(),t.timestamp.push(e)}clearTimeStamp(t,e){const{L_TIME:i=this.L_TIME}=e,r=Date.now();t.forEach((t=>{for(;r-t.timestamp[0]>i;)t.timestamp.shift()}))}clearItemTimestamp(t,e){const{L_TIME:i=this.L_TIME}=e,r=Date.now();for(;r-t.timestamp[0]>i;)t.timestamp.shift()}}function hslToRgb(t,e,i){e/=100,i/=100;const r=(1-Math.abs(2*i-1))*e,n=r*(1-Math.abs(t/60%2-1)),s=i-r/2;let a=0,o=0,l=0;return 0<=t&&t<60?(a=r,o=n,l=0):60<=t&&t<120?(a=n,o=r,l=0):120<=t&&t<180?(a=0,o=r,l=n):180<=t&&t<240?(a=0,o=n,l=r):240<=t&&t<300?(a=n,o=0,l=r):300<=t&&t<360&&(a=r,o=0,l=n),a=Math.round(255*(a+s)),o=Math.round(255*(o+s)),l=Math.round(255*(l+s)),{r:a,g:o,b:l}}function rgbToHsl(t,e,i){t/=255,e/=255,i/=255;const r=Math.min(t,e,i),n=Math.max(t,e,i),s=n-r;let a=0,o=0,l=0;return a=0===s?0:n===t?(e-i)/s%6:n===e?(i-t)/s+2:(t-e)/s+4,a=Math.round(60*a),a<0&&(a+=360),l=(n+r)/2,o=0===s?0:s/(1-Math.abs(2*l-1)),o=+(100*o).toFixed(1),l=+(100*l).toFixed(1),{h:a,s:o,l:l}}const REG_HEX=/^#([0-9a-f]{3,8})$/,DEFAULT_COLORS_OPACITY={transparent:4294967040},DEFAULT_COLORS={aliceblue:15792383,antiquewhite:16444375,aqu