ice-render 2.1.1 → 2.2.0

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.cjs CHANGED
@@ -22,9 +22,9 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- "use strict";function _defineProperty(t,e,i){return(e=function _toPropertyKey(t){var e=function _toPrimitive(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ownKeys(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,s)}return i}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(i),!0).forEach(function(e){_defineProperty(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function isNil(t){return null==t}function isString(t){return"string"==typeof t}function isUndefined(t){return void 0===t}function round(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(0===e)return Math.round(t);const[i,s]="".concat(t).split("e"),o=s?parseInt(s,10):0,r=Math.round(Number("".concat(i,"e").concat(o+e))),[a,h]="".concat(r).split("e");return Number("".concat(a,"e").concat((h?parseInt(h,10):0)-e))}function isPlainObject(t){if(null===t||"object"!=typeof t||Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function merge(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];for(const e of i)if(null!=e)for(const i in e){const s=e[i];if(void 0===s)continue;const o=t[i];isPlainObject(s)&&isPlainObject(o)?(Object.prototype.hasOwnProperty.call(t,i)||(t[i]=cloneDeep(o)),merge(t[i],s)):t[i]=s}return t}function cloneDeep(t){if(Array.isArray(t))return t.map(t=>cloneDeep(t));if(isPlainObject(t)){const e={};for(const i in t)e[i]=cloneDeep(t[i]);return e}return t}
25
+ "use strict";function _defineProperty(t,e,i){return(e=function _toPropertyKey(t){var e=function _toPrimitive(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var s=i.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ownKeys(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e&&(s=s.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,s)}return i}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(i),!0).forEach(function(e){_defineProperty(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function isNil(t){return null==t}function isString(t){return"string"==typeof t}function isUndefined(t){return void 0===t}function round(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(0===e)return Math.round(t);const[i,s]="".concat(t).split("e"),o=s?parseInt(s,10):0,r=Math.round(Number("".concat(i,"e").concat(o+e))),[u,a]="".concat(r).split("e");return Number("".concat(u,"e").concat((a?parseInt(a,10):0)-e))}function isPlainObject(t){if(null===t||"object"!=typeof t||Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function merge(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];for(const e of i)if(null!=e)for(const i in e){const s=e[i];if(void 0===s)continue;const o=t[i];isPlainObject(s)&&isPlainObject(o)?(Object.prototype.hasOwnProperty.call(t,i)||(t[i]=cloneDeep(o)),merge(t[i],s)):t[i]=s}return t}function cloneDeep(t){if(Array.isArray(t))return t.map(t=>cloneDeep(t));if(isPlainObject(t)){const e={};for(const i in t)e[i]=cloneDeep(t[i]);return e}return t}
26
26
  //!ICE 自定的事件名称常量,原生 DOM 事件的名称不变。
27
- var t={ICE_FRAME_EVENT:"ICE_FRAME_EVENT",BEFORE_RENDER:"BEFORE_RENDER",AFTER_RENDER:"AFTER_RENDER",BEFORE_ADD:"BEFORE_ADD",AFTER_ADD:"AFTER_ADD",BEFORE_REMOVE:"BEFORE_REMOVE",AFTER_REMOVE:"AFTER_REMOVE",ROUND_FINISH:"ROUND_FINISH",HOOK_MOUSEDOWN:"HOOK_MOUSEDOWN",HOOK_MOUSEMOVE:"HOOK_MOUSEMOVE",HOOK_MOUSEUP:"HOOK_MOUSEUP",BEFORE_RESIZE:"BEFORE_RESIZE",AFTER_RESIZE:"AFTER_RESIZE",BEFORE_ROTATE:"BEFORE_ROTATE",AFTER_ROTATE:"AFTER_ROTATE",BEFORE_MOVE:"BEFORE_MOVE",AFTER_MOVE:"AFTER_MOVE"};function springProgress(t,e){const i=t,s=Math.sqrt(Math.max(1e-6,1-t*t));return t=>{const o=Math.max(0,t)*e;return 1-Math.exp(-i*o)*(Math.cos(s*o)+i/s*Math.sin(s*o))}}const e={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:(4-2*t)*t-1,easeInQuart:t=>t*t*t*t,easeOutQuart:t=>1-Math.pow(1-t,4),easeInOutQuart:t=>t<.5?8*t*t*t*t:1-8*Math.pow(1-t,4),easeInCubic:t=>t*t*t,easeOutCubic:t=>1-Math.pow(1-t,3),easeInOutCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,spring:springProgress(.55,12),springSoft:springProgress(.75,14),springSnappy:springProgress(.4,9)},i={color:{blue:{50:"#EFF6FF",100:"#DBEAFE",200:"#BFDBFE",300:"#93C5FD",400:"#60A5FA",500:"#3B82F6",600:"#2563EB",700:"#1D4ED8",800:"#1E40AF",900:"#1E3A8A"},emerald:{50:"#ECFDF5",100:"#D1FAE5",200:"#A7F3D0",300:"#6EE7B7",400:"#34D399",500:"#10B981",600:"#059669",700:"#047857",800:"#065F46",900:"#064E3B"},amber:{50:"#FFFBEB",100:"#FEF3C7",200:"#FDE68A",300:"#FCD34D",400:"#FBBF24",500:"#F59E0B",600:"#D97706",700:"#B45309",800:"#92400E",900:"#78350F"},red:{50:"#FEF2F2",100:"#FEE2E2",200:"#FECACA",300:"#FCA5A5",400:"#F87171",500:"#EF4444",600:"#DC2626",700:"#B91C1C",800:"#991B1B",900:"#7F1D1D"},gray:{50:"#F9FAFB",100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",400:"#9CA3AF",500:"#6B7280",600:"#4B5563",700:"#374151",800:"#1F2937",900:"#111827"},violet:{50:"#F5F3FF",100:"#EDE9FE",200:"#DDD6FE",300:"#C4B5FD",400:"#A78BFA",500:"#8B5CF6",600:"#7C3AED",700:"#6D28D9",800:"#5B21B6",900:"#4C1D95"},teal:{50:"#F0FDFA",100:"#CCFBF1",200:"#99F6E4",300:"#5EEAD4",400:"#2DD4BF",500:"#14B8A6",600:"#0D9488",700:"#0F766E",800:"#115E59",900:"#134E4A"},pink:{50:"#FDF2F8",100:"#FCE7F3",200:"#FBCFE8",300:"#F9A8D4",400:"#F472B6",500:"#EC4899",600:"#DB2777",700:"#BE185D",800:"#9D174D",900:"#831843"},indigo:{50:"#EEF2FF",100:"#E0E7FF",200:"#C7D2FE",300:"#A5B4FC",400:"#818CF8",500:"#6366F1",600:"#4F46E5",700:"#4338CA",800:"#3730A3",900:"#312E81"}},spacing:{1:4,2:8,3:12,4:16,6:24,8:32,12:48,16:64},radius:{sm:4,md:8,lg:12,xl:16,full:9999},fontSize:{sm:12,md:14,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":44},fontFamily:{base:"Arial"},fontWeight:{normal:400,bold:700}};function buildSemantic(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=t.color;return _objectSpread2({primary:i.blue[500],success:i.emerald[500],warning:i.amber[500],danger:i.red[500],info:i.blue[400],text:i.gray[800],muted:i.gray[500],hint:i.gray[400],border:i.gray[200],background:"#ffffff",palette:[i.blue[500],i.emerald[500],i.amber[500],i.red[500],i.violet[500],i.teal[500],i.pink[500],i.indigo[500]],motion:{duration:{fast:100,normal:200,slow:300,slower:500},easing:{linear:"linear",out:"easeOutCubic",inOut:"easeInOutCubic",outQuart:"easeOutQuart",spring:"spring",springSoft:"springSoft",springSnappy:"springSnappy"}}},e)}const s={base:i,semantic:buildSemantic(i)},o={base:i,semantic:buildSemantic(i,{primary:i.color.blue[400],success:i.color.emerald[400],warning:i.color.amber[400],danger:i.color.red[400],info:i.color.teal[400],text:i.color.gray[200],muted:i.color.gray[400],hint:i.color.gray[500],border:i.color.gray[700],background:i.color.gray[900],palette:[i.color.blue[400],i.color.emerald[400],i.color.amber[400],i.color.red[400],i.color.violet[400],i.color.teal[400],i.color.pink[400],i.color.indigo[400]]})},r={default:s,dark:o};let a=s;function registerTheme(t,e){r[t]=e}function resolveTheme(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a;return"string"==typeof t?r[t]||s:{base:e.base,semantic:_objectSpread2(_objectSpread2({},e.semantic),t)}}function setTheme(t){return a=resolveTheme(t,a),a}function getTheme(){return a}const h={card:t=>({radius:t.base.radius.lg,style:{fillStyle:t.semantic.background,strokeStyle:t.semantic.border,lineWidth:1,shadow:"md"}}),gradient:t=>({radius:t.base.radius.lg,style:{fillGradient:{type:"linear",from:[0,0],to:[0,200],stops:[[0,t.semantic.primary],[1,t.semantic.background]]},strokeStyle:t.semantic.border,lineWidth:1}}),panel:t=>({radius:t.base.radius.md,style:{fillStyle:t.semantic.background,strokeStyle:t.semantic.border,lineWidth:1,shadow:"sm"}}),button:t=>({radius:t.base.radius.md,style:{fillStyle:t.semantic.primary,strokeStyle:t.semantic.primary,lineWidth:1,shadow:"sm"}}),"button-danger":t=>({radius:t.base.radius.md,style:{fillStyle:t.semantic.danger,strokeStyle:t.semantic.danger,lineWidth:1,shadow:"sm"}}),title:t=>({stroke:!1,style:{fontSize:t.base.fontSize["2xl"],fontWeight:t.base.fontWeight.bold,fillStyle:t.semantic.text}}),subtitle:t=>({stroke:!1,style:{fontSize:t.base.fontSize.lg,fillStyle:t.semantic.muted}}),body:t=>({stroke:!1,style:{fontSize:t.base.fontSize.md,fillStyle:t.semantic.text}}),label:t=>({stroke:!1,style:{fontSize:t.base.fontSize.sm,fillStyle:t.semantic.hint}})};var l={baseTokens:i,DEFAULT_THEME:s,DARK_THEME:o,registerTheme:registerTheme,setTheme:setTheme,getTheme:getTheme,STYLE_PRESETS:h};var c=class AnimationManager{constructor(t){_defineProperty(this,"animationMap",new Map),_defineProperty(this,"paused",!1),_defineProperty(this,"pausedAt",0),_defineProperty(this,"warned",new WeakSet),this.ice=t}start(){return this.ice.evtBus.on(t.ICE_FRAME_EVENT,this.frameEventHandler,this),this}stop(){return this.ice.evtBus.off(t.ICE_FRAME_EVENT,this.frameEventHandler,this),this}frameEventHandler(t){if(this.paused)return;const e=Date.now(),i=[...this.animationMap.values()];for(let t=0;t<i.length;t++){const s=i[t],o=s.state.interactive;s.state.interactive=!1,this.tween(s,e),s.state.interactive=o}}__writeValue(t,e,i){const s=e.indexOf(".");if(-1===s)return void(t[e]=i);const o=e.slice(0,s),r=e.slice(s+1);t[o]&&"object"==typeof t[o]||(t[o]={}),this.__writeValue(t[o],r,i)}tween(t,e){const i={},s=t.props.animations,o=isUndefined(e)?Date.now():e;let r=!1;for(const t in s){const e=s[t];if(e.finished)continue;let a;if(isUndefined(e.startTime)&&(e.startTime=o,this.__resolveMotion(e)),isUndefined(e.easing)&&(e.easing="linear"),Array.isArray(e.keyframes)){const i=this.__normalizeKeyframes(e);if(!i){this.__reject(e,"[ICE] 动画属性「".concat(t,"」的 keyframes 非法:需要 ≥2 帧、offset 为数字、各帧取值同型(都是数字或等长的数字数组);已跳过。"));continue}a=i}else if(!this.__isTweenable(e.from,e.to)){this.__reject(e,"[ICE] 动画属性「".concat(t,"」的取值必须都是数字或等长的数字数组,当前为 ")+"".concat(this.__describe(e.from)," → ").concat(this.__describe(e.to),";已跳过。"));continue}const h=Number(e.duration);if(!Number.isFinite(h)||h<=0){this.__reject(e,"[ICE] 动画属性「".concat(t,"」的 duration 必须是正数,当前为 ").concat(String(e.duration),";已直接落到终点。")),this.__writeValue(i,t,this.__roundIfNeeded(e,this.__sampleValue(a,e,1)));continue}const l=Number(e.delay)||0,c=o-e.startTime-l;if(c<0){r=!0,this.__writeValue(i,t,this.__sampleValue(a,e,0));continue}if(c>=h){let s=this.__sampleValue(a,e,1);this.shouldRepeat(e)?(e.startTime=o,s=this.__sampleValue(a,e,0),r=!0):e.finished=!0,this.__writeValue(i,t,this.__roundIfNeeded(e,s));continue}r=!0;const d=a?c/h:this.__easingFn(e.easing,e)(c/h);this.__writeValue(i,t,this.__roundIfNeeded(e,this.__sampleValue(a,e,d)))}return r||this.remove(t),Object.keys(i).length>0&&t.setState(i),t}__sampleValue(t,e,i){if(!t)return this.__interpolate(e.from,e.to,i);const s=t[0],o=t[t.length-1];if(i<=s.offset)return s.value;if(i>=o.offset)return o.value;for(let s=0;s<t.length-1;s++){const o=t[s],r=t[s+1];if(i<o.offset||i>r.offset)continue;const a=r.offset-o.offset;if(a<=0)return r.value;const h=(i-o.offset)/a,l=this.__easingFn(isUndefined(o.easing)?e.easing:o.easing,e);return this.__interpolate(o.value,r.value,l(h))}return o.value}__interpolate(t,e,i){if("number"==typeof t)return t+(e-t)*i;const s=new Array(t.length);for(let o=0;o<t.length;o++)s[o]=t[o]+(e[o]-t[o])*i;return s}__isTweenable(t,e){const i=this.__valueKind(t);return null!==i&&i===this.__valueKind(e)&&("number"===i||t.length===e.length)}__valueKind(t){if("number"==typeof t)return"number";if(Array.isArray(t)&&t.length>0){for(let e=0;e<t.length;e++)if("number"!=typeof t[e])return null;return"array"}return null}__normalizeKeyframes(t){if(t.__frames)return t.__frames;const e=t.keyframes;if(!Array.isArray(e)||e.length<2)return null;const i=[];for(let t=0;t<e.length;t++){const s=e[t]||{},o=isUndefined(s.offset)?t/(e.length-1):Number(s.offset);if(!Number.isFinite(o))return null;i.push({offset:Math.min(1,Math.max(0,o)),value:s.value,easing:s.easing})}i.sort((t,e)=>t.offset-e.offset);const s=this.__valueKind(i[0].value);if(null===s)return null;const o="array"===s?i[0].value.length:0;for(let t=1;t<i.length;t++){if(this.__valueKind(i[t].value)!==s)return null;if("array"===s&&i[t].value.length!==o)return null}return t.__frames=i,i}__easingFn(t,i){const s="string"==typeof t?e[t]:void 0;return s||(i&&this.__warnOnce(i,"[ICE] 未知的缓动「".concat(String(t),"」,已回退为 linear。可用:").concat(Object.keys(e).join(" / "))),e.linear)}__roundIfNeeded(t,e){return t.round?"number"==typeof e?Math.round(e):e.map(t=>Math.round(t)):e}__describe(t){return Array.isArray(t)?"数组[".concat(t.length,"]"):typeof t}__reject(t,e){t.finished=!0,this.__warnOnce(t,e)}__warnOnce(t,e){t&&"object"==typeof t&&(this.warned.has(t)||this.warned.add(t))}__resolveMotion(t){const e=(this.ice&&this.ice.theme||getTheme()).semantic.motion;"string"==typeof t.duration&&void 0!==e.duration[t.duration]&&(t.duration=e.duration[t.duration]),"string"==typeof t.easing&&void 0!==e.easing[t.easing]&&(t.easing=e.easing[t.easing])}shouldRepeat(t){return!0===t.loop||"number"==typeof t.iterationCount&&t.iterationCount>1&&(t.iterationCount--,!0)}pause(){this.paused||(this.paused=!0,this.pausedAt=Date.now())}resume(){if(!this.paused)return;const t=Date.now()-this.pausedAt,e=[...this.animationMap.values()];for(const i of e){const e=i.props.animations;for(const i in e){const s=e[i];isUndefined(s.startTime)||(s.startTime+=t)}}this.paused=!1}isPaused(){return this.paused}add(t){this.animationMap.set(t.props.id,t)}remove(t){isString(t)?this.animationMap.delete(t):this.animationMap.delete(t.props.id)}};let d=0;function bumpVisibilityEpoch(){d++}function getVisibilityEpoch(){return d}function isEffectivelyVisible(t){return t&&"function"==typeof t.isEffectivelyVisible?t.isEffectivelyVisible():!!(t&&t.state&&t.state.display)}function flattenAllComponents(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return flattenTree(e,t.childNodes||[]),flattenTree(e,t.toolNodes||[]),e}function hitTestComponents(t,e,i,s){const o=flattenAllComponents(t);o.sort((t,e)=>t.state.zIndex-e.state.zIndex);const r=t.renderer,a=r&&"function"==typeof r.getWorldBox;let h=null;for(let t=0;t<o.length;t++){const l=o[t];if(!l.isControlPanel&&(l.state.interactive&&isEffectivelyVisible(l))){if(a){const t=r.getWorldBox(l);if(t&&(e<t[0]-s||e>t[2]+s||i<t[1]-s||i>t[3]+s))continue}if(l.containsPoint(e,i)){if("function"==typeof l.isPointClippedOut&&l.isPointClippedOut(e,i))continue;h=l}}}return h}function flattenTree(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;for(let o=0;o<e.length;o++){const r=e[o];r._level=i,r._pid=s,t.push(r);const a=r.props&&void 0!==r.props.id?r.props.id:r.id;flattenTree(t,r.childNodes||[],i+1,a)}return t}class Path2DRecorder{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;_defineProperty(this,"_commands",[]),_defineProperty(this,"_closed",!1),_defineProperty(this,"native",null),_defineProperty(this,"__current",null),_defineProperty(this,"__subpathStart",null),this.native=t||null,this._isPolyfill=!this.native}get drawable(){return this.native||this}moveTo(t,e){this._commands.push(["moveTo",t,e]),this.__current=[t,e],this.__subpathStart=[t,e],this.native&&this.native.moveTo(t,e)}lineTo(t,e){this._commands.push(["lineTo",t,e]),this.__current=[t,e],this.native&&this.native.lineTo(t,e)}bezierCurveTo(t,e,i,s,o,r){this._commands.push(["bezierCurveTo",t,e,i,s,o,r]),this.__current=[o,r],this.native&&this.native.bezierCurveTo(t,e,i,s,o,r)}quadraticCurveTo(t,e,i,s){this._commands.push(["quadraticCurveTo",t,e,i,s]),this.__current=[i,s],this.native&&this.native.quadraticCurveTo(t,e,i,s)}arcTo(t,e,i,s,o){const r=Math.abs(Number(o)||0),a=this.__current;if(!a||0===r)return void this.lineTo(t,e);const h=a[0]-t,l=a[1]-e,c=i-t,d=s-e,u=Math.sqrt(h*h+l*l),p=Math.sqrt(c*c+d*d);if(0===u||0===p)return void this.lineTo(t,e);const f=h/u,g=l/u,m=c/p,y=d/p,_=f*y-g*m,x=Math.max(-1,Math.min(1,f*m+g*y));if(Math.abs(_)<1e-9||Math.abs(x)>=1-1e-9)return void this.lineTo(t,e);const b=Math.acos(x),v=r/Math.tan(b/2),E=t+f*v,C=e+g*v,w=t+m*v,M=e+y*v,S=f+m,P=g+y,T=Math.sqrt(S*S+P*P)||1,I=r/Math.sin(b/2),B=t+S/T*I,O=e+P/T*I,R=Math.atan2(C-O,E-B),A=Math.atan2(M-O,w-B);this.lineTo(E,C),this.arc(B,O,r,R,A,_>0)}rect(t,e,i,s){this._commands.push(["rect",t,e,i,s]),this.__current=[t,e],this.__subpathStart=[t,e],this.native&&this.native.rect(t,e,i,s)}arc(t,e,i,s,o){let r=arguments.length>5&&void 0!==arguments[5]&&arguments[5];this._commands.push(["arc",t,e,i,s,o,r]),this.__current=[t+i*Math.cos(o),e+i*Math.sin(o)],this.native&&this.native.arc(t,e,i,s,o,r)}ellipse(t,e,i,s,o,r,a,h){this._commands.push(["ellipse",t,e,i,s,o,r,a,h]),this.__current=[t+i*Math.cos(a)*Math.cos(o)-s*Math.sin(a)*Math.sin(o),e+i*Math.cos(a)*Math.sin(o)+s*Math.sin(a)*Math.cos(o)],this.native&&this.native.ellipse(t,e,i,s,o,r,a,h)}closePath(){this._closed=!0;const t=this._commands[this._commands.length-1];t&&"closePath"===t[0]||this._commands.push(["closePath"]),this.__current=this.__subpathStart?[this.__subpathStart[0],this.__subpathStart[1]]:null,this.native&&this.native.closePath()}get currentPoint(){return this.__current}}let u=null;(()=>{const t="undefined"!=typeof window?window:"undefined"!=typeof global?global:{};u=t||{},u.requestFrame=u.requestAnimationFrame||u.webkitRequestAnimationFrame||u.mozRequestAnimationFrame||u.oRequestAnimationFrame||u.msRequestAnimationFrame,"function"!=typeof u.requestFrame&&(u.requestFrame=function(t){return setTimeout(function(){t(Date.now())},16)}),u.createPath2D=()=>"function"==typeof u.Path2D?new Path2DRecorder(new u.Path2D):new Path2DRecorder,u.loadFont=(t,e)=>{if("function"==typeof u.FontFace&&u.document&&u.document.fonts){const i=new u.FontFace(t,e);return u.document.fonts.add(i),i.load()}return u.wx&&"function"==typeof u.wx.loadFont?u.wx.loadFont(e):Promise.resolve()},u.createImage=()=>{if("function"==typeof u.Image)return new u.Image;if(u.wx&&"function"==typeof u.wx.createImage)return u.wx.createImage();throw new Error("当前运行时没有可用的 Image 构造器,无法加载图片。")},"number"==typeof u.devicePixelRatio&&u.devicePixelRatio>0||(u.devicePixelRatio=(()=>{if(u.wx&&"function"==typeof u.wx.getSystemInfoSync)try{return u.wx.getSystemInfoSync().pixelRatio||1}catch(t){return 1}return 1})()),u.createOffscreenCanvas=(t,e)=>{if(u.wx&&"function"==typeof u.wx.createOffscreenCanvas){const i=u.wx.createOffscreenCanvas({type:"2d",width:t,height:e}),s=i.getContext("2d");if(!s)throw new Error("当前运行时无法创建 2d 离屏上下文。");return{canvas:i,ctx:s}}if(u.document&&"function"==typeof u.document.createElement){const i=u.document.createElement("canvas");i.width=t,i.height=e;const s=i.getContext("2d");if(!s)throw new Error("当前运行时无法创建 2d 离屏上下文。");return{canvas:i,ctx:s}}throw new Error("当前运行时没有可用的离屏 canvas。")}})();var p=u,f="undefined"!=typeof Float32Array?Float32Array:Array,g=Math.PI/180;function toRadian(t){return t*g}function invert(t,e){var i=e[0],s=e[1],o=e[2],r=e[3],a=e[4],h=e[5],l=i*r-s*o;return l?(l=1/l,t[0]=r*l,t[1]=-s*l,t[2]=-o*l,t[3]=i*l,t[4]=(o*h-r*a)*l,t[5]=(s*a-i*h)*l,t):null}function multiply(t,e,i){var s=e[0],o=e[1],r=e[2],a=e[3],h=e[4],l=e[5],c=i[0],d=i[1],u=i[2],p=i[3],f=i[4],g=i[5];return t[0]=s*c+r*d,t[1]=o*c+a*d,t[2]=s*u+r*p,t[3]=o*u+a*p,t[4]=s*f+r*g+h,t[5]=o*f+a*g+l,t}function cross(t,e,i){var s=e[0]*i[1]-e[1]*i[0];return t[0]=t[1]=0,t[2]=s,t}function transformMat2d(t,e,i){var s=e[0],o=e[1];return t[0]=i[0]*s+i[2]*o+i[4],t[1]=i[1]*s+i[3]*o+i[5],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),function create(){var t=new f(2);return f!=Float32Array&&(t[0]=0,t[1]=0),t}();var m=class ICEEvent{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_defineProperty(this,"AT_TARGET",2),_defineProperty(this,"BUBBLING_PHASE",3),_defineProperty(this,"CAPTURING_PHASE",1),_defineProperty(this,"NONE",0);for(const e in t)this[e]=t[e];for(const t in e)this[t]=e[t]}composedPath(){throw new Error("Method not implemented.")}initEvent(t,e,i){throw new Error("Method not implemented.")}preventDefault(){throw new Error("Method not implemented.")}stopImmediatePropagation(){throw new Error("Method not implemented.")}stopPropagation(){throw new Error("Method not implemented.")}};class ICEEventTarget{constructor(){_defineProperty(this,"listeners",{}),_defineProperty(this,"suspendedEventNames",[])}on(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p;this.listeners[t]||(this.listeners[t]=[]),this.off(t,e,i),this.listeners[t].push({callback:e,scope:i})}off(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p,s=this.listeners[t];if(s){s=[...s];for(let o=0;o<s.length;o++){const r=s[o],a=r.callback;if((a===e||a&&a.__onceOriginal===e)&&r.scope===i)return void this.listeners[t].splice(o,1)}}}trigger(t){let e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(function isEmpty(t){return null==t||(Array.isArray(t)||"string"==typeof t?0===t.length:"object"!=typeof t||0===Object.keys(t).length)}(this.listeners[t]))return!1;if(this.suspendedEventNames.includes(t))return!1;i?(e=new m(i),e.originalEvent=i.originalEvent?i.originalEvent:i,e.param=_objectSpread2({},s)):e=new m({type:t,timeStamp:Date.now(),param:_objectSpread2({},s)});const o=[...this.listeners[t]];for(let i=0;i<o.length;i++){const s=o[i];-1!==this.listeners[t].indexOf(s)&&s.callback.call(s.scope,e)}return!0}once(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p;const s=this;function callback(o){s.off(t,callback,i),e.call(i,o)}callback.__onceOriginal=e,s.on(t,callback,i)}suspend(t){t&&!this.suspendedEventNames.includes(t)&&this.suspendedEventNames.push(t)}resume(t){const e=this.suspendedEventNames.indexOf(t);-1!==e&&this.suspendedEventNames.splice(e,1)}purgeEvents(){this.listeners={},this.suspendedEventNames=[]}hasListener(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p;if(!this.listeners[t])return!1;const s=this.listeners[t];if(!s)return!1;for(let t=0;t<s.length;t++){const o=s[t];if(o.callback===e&&o.scope===i)return!0}return!1}}ICEEventTarget.prototype.addEventListener=ICEEventTarget.prototype.on,ICEEventTarget.prototype.removeEventListener=ICEEventTarget.prototype.off,ICEEventTarget.prototype.dispatchEvent=ICEEventTarget.prototype.trigger;var y=ICEEventTarget;class GeoUtil{constructor(){throw new Error("GeoUtil is a static util class.")}static pointInPolygon(t,e,i){if(!i||i.length<3)return!1;let s=!1;for(let o=0,r=i.length-1;o<i.length;r=o++){const a=i[o][0],h=i[o][1],l=i[r][0],c=i[r][1];h>e!=c>e&&t<(l-a)*(e-h)/(c-h)+a&&(s=!s)}return s}static distanceToSegment(t,e,i,s,o,r){const a=o-i,h=r-s,l=a*a+h*h;let c=0===l?0:((t-i)*a+(e-s)*h)/l;return c=c<0?0:c>1?1:c,Math.hypot(t-(i+c*a),e-(s+c*h))}static distanceToPolyline(t,e,i){if(!t||0===t.length)return 1/0;if(1===t.length)return Math.hypot(e-t[0][0],i-t[0][1]);let s=1/0;for(let o=0;o<t.length-1;o++){const r=GeoUtil.distanceToSegment(e,i,t[o][0],t[o][1],t[o+1][0],t[o+1][1]);r<s&&(s=r)}return s}static samplePolyline(t,e){const i=[];if(!t||t.length<2||e<1)return t?t.map(t=>[t[0],t[1]]):i;const s=[];let o=0;for(let e=0;e<t.length-1;e++){const i=Math.hypot(t[e+1][0]-t[e][0],t[e+1][1]-t[e][1]);s.push(i),o+=i}if(0===o)return[t[0].slice(),t[t.length-1].slice()];for(let r=0;r<=e;r++){const a=o*r/e;let h=0;for(let e=0;e<s.length;e++){if(h+s[e]>=a||e===s.length-1){const o=0===s[e]?0:(a-h)/s[e];i.push([t[e][0]+(t[e+1][0]-t[e][0])*o,t[e][1]+(t[e+1][1]-t[e][1])*o]);break}h+=s[e]}}return i}static segmentIntersect(t,e,i,s){const o=e[0]-t[0],r=e[1]-t[1],a=s[0]-i[0],h=s[1]-i[1],l=o*h-r*a;if(0===l)return null;const c=((i[0]-t[0])*h-(i[1]-t[1])*a)/l,d=((i[0]-t[0])*r-(i[1]-t[1])*o)/l;return c<0||c>1||d<0||d>1?null:[t[0]+c*o,t[1]+c*r]}static calcRotateAngle(t,e,i,s){const o=t-i,r=e-s,a=Math.hypot(o,r),h=o/a;let l=(r/a<0?-1:1)*Math.acos(h)*180/Math.PI+360;return l%=360,l}static calcRotateAngleFromMatrix(t){const e=t[0],i=t[1];return Math.atan2(i,e)*(180/Math.PI)}static calcScaleFromMatrix(t){const e=t[0],i=t[1],s=t[2],o=t[3];return[Math.hypot(e,i),Math.hypot(s,o)]}}class ICEBoundingBox{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0,0,0,0,0,0,0];_defineProperty(this,"tl",[0,0]),_defineProperty(this,"tr",[0,0]),_defineProperty(this,"bl",[0,0]),_defineProperty(this,"br",[0,0]),_defineProperty(this,"tc",[0,0]),_defineProperty(this,"rc",[0,0]),_defineProperty(this,"bc",[0,0]),_defineProperty(this,"lc",[0,0]),_defineProperty(this,"center",[0,0]),this.tl=[t[0],t[1]],this.tr=[t[2],t[3]],this.bl=[t[4],t[5]],this.br=[t[6],t[7]],this.tc=[(this.tr[0]+this.tl[0])/2,(this.tr[1]+this.tl[1])/2],this.bc=[(this.br[0]+this.bl[0])/2,(this.br[1]+this.bl[1])/2],this.lc=[(this.bl[0]+this.tl[0])/2,(this.bl[1]+this.tl[1])/2],this.rc=[(this.br[0]+this.tr[0])/2,(this.br[1]+this.tr[1])/2],this.center=[t[8],t[9]]}static fromDimension(t,e,i,s){return new ICEBoundingBox([...[t,e],...[t+i,e],...[t,e+s],...[t+i,e+s],...[t+i/2,e+s/2]])}containsPoint(t){const{minX:e,minY:i,maxX:s,maxY:o}=this.getMinAndMaxPoint();if(t[0]<e||t[0]>s||t[1]<i||t[1]>o)return!1;let r,a=0;const h=this.getBoundingLines();for(let e=0;e<h.length;e++){const i=h[e];if(!(t[1]>i.o[1]&&t[1]>i.d[1])&&!(t[1]<i.o[1]&&t[1]<i.d[1])){if(i.o[0]===i.d[0]&&i.o[0]>=t[0])r=i.o[0];else{const e=(i.d[1]-i.o[1])/(i.d[0]-i.o[0]);r=i.o[0]+(t[1]-i.o[1])/e}r>t[0]&&a++}}return 0!==a&&a%2==1}getBoundingLines(){return[{o:[...this.tl],d:[...this.tr]},{o:[...this.tr],d:[...this.br]},{o:[...this.br],d:[...this.bl]},{o:[...this.bl],d:[...this.tl]}]}getMinAndMaxPoint(){let t=this.tl[0],e=this.tl[1],i=this.tl[0],s=this.tl[1];const o=[this.tr,this.bl,this.br];for(let r=0;r<o.length;r++){const a=o[r];a[0]<t&&(t=a[0]),a[0]>i&&(i=a[0]),a[1]<e&&(e=a[1]),a[1]>s&&(s=a[1])}return{minX:t,minY:e,maxX:i,maxY:s}}containsBox(t){const e=this.getMinAndMaxPoint(),i=t.getMinAndMaxPoint();return i.minX>=e.minX&&i.maxX<=e.maxX&&i.minY>=e.minY&&i.maxY<=e.maxY}isIntersect(t){const e=this.tl[0],i=this.br[0],s=this.tl[1],o=this.br[1],r=t.tl[0],a=t.br[0],h=t.tl[1],l=t.br[1];return!(e>a||s>l||i<r||o<h)}transform(t){const e=transformMat2d([],this.tl,t),i=transformMat2d([],this.tr,t),s=transformMat2d([],this.bl,t),o=transformMat2d([],this.br,t),r=transformMat2d([],this.center,t);return new ICEBoundingBox([...e,...i,...s,...o,...r])}union(t){const e=this.getMinAndMaxPoint(),i=t.getMinAndMaxPoint(),s=Math.min(e.minX,i.minX),o=Math.min(e.minY,i.minY),r=Math.max(e.maxX,i.maxX),a=Math.max(e.maxY,i.maxY);return ICEBoundingBox.fromDimension(s,o,r-s,a-o)}get width(){const t=this.br[0]-this.bl[0],e=this.br[1]-this.bl[1];return Math.hypot(t,e)}get height(){const t=this.br[0]-this.tr[0],e=this.br[1]-this.tr[1];return Math.hypot(t,e)}get left(){return this.tl[0]}set left(t){throw new Error("Can not set left to ICEBoundingBox directly.")}get top(){return this.tl[1]}set top(t){throw new Error("Can not set top to ICEBoundingBox directly.")}get centerX(){return this.center[0]}get centerY(){return this.center[1]}get centerPoint(){return this.center}}var _=ICEBoundingBox;const x={sm:{shadowColor:"rgba(0,0,0,0.12)",shadowBlur:4,shadowOffsetX:0,shadowOffsetY:1},md:{shadowColor:"rgba(0,0,0,0.18)",shadowBlur:10,shadowOffsetX:0,shadowOffsetY:3},lg:{shadowColor:"rgba(0,0,0,0.25)",shadowBlur:20,shadowOffsetX:0,shadowOffsetY:6}},b=[["shadowColor","rgba(0,0,0,0)"],["shadowBlur",0],["shadowOffsetX",0],["shadowOffsetY",0],["globalAlpha",1],["globalCompositeOperation","source-over"],["lineCap","butt"],["lineJoin","miter"],["miterLimit",10],["textAlign","start"],["textBaseline","alphabetic"]],v=Object.freeze([1,0,0,1,0,0]),E={left:0,top:0,width:0,height:0,style:Object.freeze({fillStyle:"red",strokeStyle:"blue",lineWidth:1}),lineDash:Object.freeze([]),lineDashOffset:0,lineDashFlow:!1,lineDashFlowSpeed:60,lineBorder:!1,lineBorderWidth:1.5,lineBorderColor:"#999999",fill:!0,stroke:!0,animations:Object.freeze({}),transform:Object.freeze({translate:Object.freeze([0,0]),scale:Object.freeze([1,1]),skew:Object.freeze([0,0]),rotate:0}),linearMatrix:Object.freeze([]),composedMatrix:Object.freeze([]),origin:"localCenter",originX:0,originY:0,clipChildren:!1,opacity:1,localOrigin:Object.freeze([0,0]),absoluteOrigin:Object.freeze([0,0]),display:!0,draggable:!0,transformable:!0,interactive:!0,linkable:!0,showMinBoundingBox:!1,showMaxBoundingBox:!1};function normalizeGradientStops(t){const e=[];if(!Array.isArray(t))return e;for(let i=0;i<t.length;i++){const s=t[i];let o=NaN,r="";Array.isArray(s)?(o=Number(s[0]),r=String(s[1])):s&&"object"==typeof s&&(o=Number(s.offset),r=String(s.color)),isFinite(o)&&r&&e.push([o<0?0:o>1?1:o,r])}return e.sort((t,e)=>t[0]-e[0]),e}function triggerSubtreeMove(e,i){const s=e&&e.childNodes||[];for(let e=0;e<s.length;e++){const o=s[e];o.trigger(t.AFTER_MOVE,i),triggerSubtreeMove(o,i)}}class ICEComponent extends y{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),_defineProperty(this,"__dirty",!0),_defineProperty(this,"__everRendered",!1),_defineProperty(this,"__localBoxScratch",[0,0,0,0]),_defineProperty(this,"__activeCtm",null),_defineProperty(this,"__activeWorldMatrix",null),_defineProperty(this,"__visEpoch",-1),_defineProperty(this,"__visValue",!0),_defineProperty(this,"__opacityApplied",!1),_defineProperty(this,"__gradCache",{}),_defineProperty(this,"__paramsDirty",!0),_defineProperty(this,"__absScratchA",null),_defineProperty(this,"__absScratchB",null),_defineProperty(this,"__transScratch",null),_defineProperty(this,"__originScratch",null),_defineProperty(this,"__composeScratch",null),_defineProperty(this,"__viewportScratch",null),this.__userProps=t,t&&t.preset&&h[t.preset]&&(this.__presetName=t.preset,t=merge({},h[t.preset](getTheme()),t)),this.props=Object.create(E),this.props.id=t&&void 0!==t.id?t.id:"ICE_"+function uuid(){if(p.crypto&&"function"==typeof p.crypto.randomUUID)return p.crypto.randomUUID();if(p.crypto&&"function"==typeof p.crypto.getRandomValues){const t=new Uint8Array(16);p.crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128;const e=[];for(let i=0;i<t.length;i++)e.push((t[i]+256).toString(16).slice(1));return e.slice(0,4).join("")+"-"+e.slice(4,6).join("")+"-"+e.slice(6,8).join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10,16).join("")}let t=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:3&i|8).toString(16)})}(),this.props.zIndex=ICEComponent.instanceCounter++,merge(this.props,t),this.__initState(),this.root=p,this.initEvents()}__initState(){this.state=Object.create(E),this.state.id=this.props.id,this.state.zIndex=this.props.zIndex;for(const t in this.props)Object.prototype.hasOwnProperty.call(this.props,t)&&(this.state[t]=cloneDeep(this.props[t]));this.state.linearMatrix=[],this.state.composedMatrix=[],this.state.localOrigin=[0,0],this.state.absoluteOrigin=[0,0]}__reapplyPreset(t){if(!this.__presetName||!h[this.__presetName])return;const e=h[this.__presetName](t||getTheme()),i=this.__userProps||{},s={};for(const t in e)"style"===t?s.style=merge({},e.style,i.style):void 0!==i[t]?s[t]=i[t]:s[t]=e[t];this.setState(s)}initEvents(){this.on("mousedown",this.mouseDownEvtHandler,this),this.on("keydown",this.keyboardEvtHandler,this),this.on("keyup",this.keyboardEvtHandler,this)}mouseDownEvtHandler(t){this.state.interactive&&this.state.draggable&&(this.on("mousemove",this.mouseMoveEvtHandler,this),this.on("mouseup",this.mouseUpEvtHandler,this))}mouseMoveEvtHandler(t){const e=this.ice&&this.ice.viewport?this.ice.viewport.scale:1,i=t.movementX/e,s=t.movementY/e;return this.moveGlobalPosition(i,s,t),!0}mouseUpEvtHandler(t){this.off("mousemove",this.mouseMoveEvtHandler,this),this.off("mouseup",this.mouseUpEvtHandler,this)}keyboardEvtHandler(t){switch(t.key){case"ArrowUp":this.moveGlobalPosition(0,-2,t);break;case"ArrowDown":this.moveGlobalPosition(0,2,t);break;case"ArrowLeft":this.moveGlobalPosition(-2,0,t);break;case"ArrowRight":this.moveGlobalPosition(2,0,t);break;case"Delete":this.parentNode&&this.parentNode.removeChild?this.parentNode.removeChild(this):this.ice.removeChild(this)}}render(){this.__renderCore(null,!0)}renderTo(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t)return;const i=this.ctx;this.ctx=t;try{this.__renderCore(e,!1)}finally{this.ctx=i}}isEffectivelyVisible(){if(this.__visEpoch===getVisibilityEpoch())return this.__visValue;const t=this.__computeEffectivelyVisible();return this.__visEpoch=getVisibilityEpoch(),this.__visValue=t,t}__computeEffectivelyVisible(){if(!this.state.display)return!1;let t=this.parentNode;for(;t&&t.state;){if(!t.state.display)return!1;t=t.parentNode}return!0}__renderCore(e,i){if(this.trigger(t.BEFORE_RENDER),!this.isEffectivelyVisible())return;this.refreshParams(),this.applyStyleToCtx();const s=this.getEffectiveOpacity();1!==s&&(this.__applyStyleProp("globalAlpha",(Number(this.ctx.globalAlpha)||1)*s),this.__opacityApplied=!0),this.applyTransformToCtx(e,i);const o=this.__applyAncestorClips();this.doRender(),o&&this.ctx.restore(),this.__resetLeakyCtxState(),this.trigger(t.AFTER_RENDER),this.__everRendered=!0,this.dirty=!1}applyStyleToCtx(){const t=this.props.style,e=this.state.style;let i=null,s=null;if(t)for(const e in t)"fillGradient"!==e?"strokeGradient"!==e?this.__applyStyleProp(e,t[e]):s=t[e]:i=t[e];if(e)for(const t in e)"fillGradient"!==t?"strokeGradient"!==t?this.__applyStyleProp(t,e[t]):s=e[t]:i=e[t];i&&this.__applyStyleProp("fillGradient",i),s&&this.__applyStyleProp("strokeGradient",s)}__applyStyleProp(t,e){if("fillGradient"===t||"strokeGradient"===t){const i="fillGradient"===t?"fillStyle":"strokeStyle",s=this.__resolveGradient("fillGradient"===t?"fill":"stroke",e);if(s)this.ctx[i]=s;else if(e){const t=normalizeGradientStops(e.stops);t.length&&(this.ctx[i]=t[Math.floor(t.length/2)][1])}return}if("shadow"===t&&"string"==typeof e&&x[e]){const t=x[e];return this.ctx.shadowColor=t.shadowColor,this.ctx.shadowBlur=t.shadowBlur,this.ctx.shadowOffsetX=t.shadowOffsetX,void(this.ctx.shadowOffsetY=t.shadowOffsetY)}this.ctx[t]=e}__resolveGradient(t,e){if(!e||"object"!=typeof e)return null;const i=this.__gradCache[t];if(i&&i.src===e)return i.grad;const s=this.__buildGradient(e);return this.__gradCache[t]={src:e,grad:s},s}__buildGradient(t){const e=this.ctx;if(!e)return null;const i=normalizeGradientStops(t.stops);if(i.length<1)return null;const s=Number(this.state.width)||0,o=Number(this.state.height)||0,r=t.type||"linear";let a=null;if("radial"===r&&"function"==typeof e.createRadialGradient){const i=Array.isArray(t.center)?t.center:[s/2,o/2],r=Number(t.radius)>0?Number(t.radius):Math.max(s,o)/2,h=Number(t.innerRadius)>0?Number(t.innerRadius):0;a=e.createRadialGradient(i[0],i[1],h,i[0],i[1],r)}else if("conic"===r&&"function"==typeof e.createConicGradient){const i=Array.isArray(t.center)?t.center:[s/2,o/2];a=e.createConicGradient(Number(t.startAngle)||0,i[0],i[1])}else{if("conic"===r)return null;if("function"==typeof e.createLinearGradient){const i=Array.isArray(t.from)?t.from:[0,0],o=Array.isArray(t.to)?t.to:[s,0];a=e.createLinearGradient(i[0],i[1],o[0],o[1])}}if(!a&&"function"!=typeof e.createLinearGradient)return null;if(!a)return null;for(let t=0;t<i.length;t++)try{a.addColorStop(i[t][0],i[t][1])}catch(t){}return a}calcComponentParams(){return{width:this.state.width,height:this.state.height}}__localBox(){const t=this.__localBoxScratch;return t[0]=0,t[1]=0,t[2]=this.state.width||0,t[3]=this.state.height||0,t}measure(){this.refreshParams()}refreshParams(){this.__paramsDirty&&(this.calcComponentParams(),this.__paramsDirty=!1,this.__gradCache.fill=void 0,this.__gradCache.stroke=void 0)}calcLocalOrigin(){let t=this.state.localOrigin;(!t||t.length<2)&&(t=this.state.localOrigin=[0,0]),t[0]=0,t[1]=0;const e=this.state.origin;return e&&"localCenter"!==e?"top-left"===e?(t[0]=0,t[1]=0):"custom"===e&&(t[0]=Number(this.state.originX)||0,t[1]=Number(this.state.originY)||0):(t[0]=this.state.width/2,t[1]=this.state.height/2),this.state.localOrigin=t,t}calcAbsoluteOrigin(){const t=this.state.transform,e=t.translate[0]+this.state.left,i=t.translate[1]+this.state.top,s=this.calcLocalOrigin();let o=this.__originScratch;if(o||(o=this.__originScratch=[0,0]),o[0]=s[0]+e,o[1]=s[1]+i,this.parentNode){transformMat2d(o,o,[1,0,0,1,-this.parentNode.state.localOrigin[0],-this.parentNode.state.localOrigin[1]]);transformMat2d(o,o,this.parentNode.state.composedMatrix)}return this.state.absoluteOrigin=o,o}calcLinearMatrix(){(!this.state.linearMatrix||this.state.linearMatrix.length<6)&&(this.state.linearMatrix=function create$1(){var t=new f(6);return f!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t}());const t=this.state.linearMatrix;!function identity(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}(t);const e=this.state.transform,i=e.skew[0],s=e.skew[1];!function skew(t,e,i,s){const o=Math.tan(i),r=Math.tan(s);return t[0]=e[0],t[1]=e[1]+o,t[2]=e[2]+r,t[3]=e[3],t[4]=e[4],t[5]=e[5],t}(t,t,toRadian(i),toRadian(s));!function rotate(t,e,i){var s=e[0],o=e[1],r=e[2],a=e[3],h=e[4],l=e[5],c=Math.sin(i),d=Math.cos(i);return t[0]=s*d+r*c,t[1]=o*d+a*c,t[2]=s*-c+r*d,t[3]=o*-c+a*d,t[4]=h,t[5]=l,t}(t,t,toRadian(e.rotate));return function scale(t,e,i){var s=e[0],o=e[1],r=e[2],a=e[3],h=e[4],l=e[5],c=i[0],d=i[1];return t[0]=s*c,t[1]=o*c,t[2]=r*d,t[3]=a*d,t[4]=h,t[5]=l,t}(t,t,[e.scale[0],e.scale[1]]),this.state.linearMatrix=t,t}calcAbsoluteLinearMatrix(){let t=this,e=t.calcLinearMatrix();this.__absScratchA||(this.__absScratchA=[0,0,0,0,0,0]),this.__absScratchB||(this.__absScratchB=[0,0,0,0,0,0]);let i=this.__absScratchA;for(;t.parentNode;){const s=t.parentNode,o=s.state&&s.state.linearMatrix&&s.state.linearMatrix.length>=6&&!s.dirty?s.state.linearMatrix:s.calcLinearMatrix();i=i===this.__absScratchA?this.__absScratchB:this.__absScratchA,multiply(i,o,e),e=i,t=s}return this.state.absoluteLinearMatrix=e,e}composeMatrix(){if(this.parentNode&&"function"==typeof this.parentNode.composeMatrix){const t=this.parentNode,e=t.state?t.state.composedMatrix:null;(t.dirty||!e||e.length<6)&&t.composeMatrix()}const t=this.calcAbsoluteOrigin();this.__transScratch||(this.__transScratch=[1,0,0,1,0,0]),this.__transScratch[4]=t[0],this.__transScratch[5]=t[1];const e=this.__transScratch,i=this.calcAbsoluteLinearMatrix();(!this.state.composedMatrix||this.state.composedMatrix.length<6)&&(this.state.composedMatrix=[1,0,0,1,0,0]);const s=multiply(this.state.composedMatrix,e,i);return this.state.composedMatrix=s,s}applyTransformToCtx(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.dirty?this.composeMatrix():this.state.composedMatrix,s=e&&this.ice?this.ice.getRenderViewport():null,o=s&&(1!==s.scale||0!==s.tx||0!==s.ty);let r=null;if(o){this.__viewportScratch||(this.__viewportScratch=[1,0,0,1,0,0]);const t=this.__viewportScratch;t[0]=s.scale,t[1]=0,t[2]=0,t[3]=s.scale,t[4]=s.tx,t[5]=s.ty,r=t}else t&&(r=t);if(this.__activeWorldMatrix=r,t||o){this.__composeScratch||(this.__composeScratch=[1,0,0,1,0,0]);const e=this.__composeScratch;multiply(e,r||t,i),this.__activeCtm=e,this.ctx.setTransform(e[0],e[1],e[2],e[3],e[4],e[5])}else this.__activeCtm=i,this.ctx.setTransform(...i)}applyActiveTransform(){const t=this.__activeCtm;t?this.ctx.setTransform(t[0],t[1],t[2],t[3],t[4],t[5]):this.applyTransformToCtx(null,!0)}hasClippingAncestor(){let t=this.parentNode;for(;t&&t.state;){if(t.state.clipChildren)return!0;t=t.parentNode}return!1}getEffectiveOpacity(){const t=this.state.opacity;let e=void 0===t?1:Number(t);e>=0||(e=1);let i=this.parentNode;for(;i&&i.state;){const t=void 0===i.state.opacity?1:Number(i.state.opacity);t>=0&&1!==t&&(e*=t),i=i.parentNode}return e}isPointClippedOut(t,e){let i=this.parentNode;for(;i&&i.state;){if(i.state.clipChildren){const s=i.__paintWorldBox();if(t<s[0]||t>s[2]||e<s[1]||e>s[3])return!0}i=i.parentNode}return!1}__applyAncestorClips(){const t=this.parentNode;if(!t||!t.state)return!1;const e=this.ctx;if(!e||"function"!=typeof e.clip||"function"!=typeof e.rect)return!1;let i=null,s=t;for(;s&&s.state;)s.state.clipChildren&&(i||(i=[])).push(s),s=s.parentNode;if(!i)return!1;const o=this.__activeWorldMatrix||v;e.save(),e.setTransform(1,0,0,1,0,0);for(let t=i.length-1;t>=0;t--){const s=i[t].__paintWorldBox(),r=o[0]*s[0]+o[2]*s[1]+o[4],a=o[1]*s[0]+o[3]*s[1]+o[5],h=o[0]*s[2]+o[2]*s[1]+o[4],l=o[1]*s[2]+o[3]*s[1]+o[5],c=o[0]*s[0]+o[2]*s[3]+o[4],d=o[1]*s[0]+o[3]*s[3]+o[5],u=o[0]*s[2]+o[2]*s[3]+o[4],p=o[1]*s[2]+o[3]*s[3]+o[5],f=Math.min(r,h,c,u),g=Math.min(a,l,d,p),m=Math.max(r,h,c,u),y=Math.max(a,l,d,p);e.beginPath(),e.rect(f,g,m-f,y-g),e.clip()}return this.applyActiveTransform(),!0}applyWorldTransform(){const t=this.__activeWorldMatrix;t?(this.ctx.setTransform(t[0],t[1],t[2],t[3],t[4],t[5]),this.ctx.lineWidth=1/(Math.abs(t[0])||Math.abs(t[3])||1)):(this.ctx.setTransform(1,0,0,1,0,0),this.ctx.lineWidth=1)}doRender(){if(this.applyWorldTransform(),this.state.showMinBoundingBox||this.state.showMaxBoundingBox){const t=this.state.showMinBoundingBox?this.getMinBoundingBox():null,e=this.state.showMaxBoundingBox?this.getMaxBoundingBox():null,i=t&&e&&this.__areBoundingBoxesNearlyEqual(t,e);t&&!i&&(this.ctx.strokeStyle="#ff0000",this.ctx.fillStyle="rgba(0,0,0,0)",this.ctx.beginPath(),this.ctx.moveTo(t.tl[0],t.tl[1]),this.ctx.lineTo(t.tr[0],t.tr[1]),this.ctx.lineTo(t.br[0],t.br[1]),this.ctx.lineTo(t.bl[0],t.bl[1]),this.ctx.closePath(),this.ctx.stroke(),this.ctx.fill()),e&&(this.ctx.strokeStyle="#0000ff",this.ctx.fillStyle="rgba(0,0,0,0)",this.ctx.beginPath(),this.ctx.moveTo(e.tl[0],e.tl[1]),this.ctx.lineTo(e.tr[0],e.tr[1]),this.ctx.lineTo(e.br[0],e.br[1]),this.ctx.lineTo(e.bl[0],e.bl[1]),this.ctx.closePath(),this.ctx.stroke(),this.ctx.fill())}}__areBoundingBoxesNearlyEqual(t,e){const i=[[t.tl,e.tl],[t.tr,e.tr],[t.bl,e.bl],[t.br,e.br]];for(const[t,e]of i)if(Math.abs(t[0]-e[0])>1||Math.abs(t[1]-e[1])>1)return!1;return!0}hasDerivedChildren(){return!1}getSerializableChildren(){return null}getMinBoundingBox(){const t=arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.composeMatrix():this.state.composedMatrix,e=this.state.localOrigin[0],i=this.state.localOrigin[1],s=this.__localBox(),o=s[0]-e,r=s[1]-i,a=s[2]-e,h=s[3]-i;let l=new _([o,r,a,r,o,h,a,h,0,0]);return l=l.transform(t),l}getMaxBoundingBox(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.getMinBoundingBox(t);const{minX:i,minY:s,maxX:o,maxY:r}=e.getMinAndMaxPoint(),a=e.centerPoint;return e=new _([i,s,o,s,i,r,o,r,a[0],a[1]]),e}setState(t){const e=this.__beforeStateMerge(t);merge(this.state,t),this.paramsDirty=!0,this.dirty=!0,this.ice&&(this.ice.dirty=!0),this.__afterStateMerge(e)}__beforeStateMerge(t){const e=!!t&&(void 0!==t.width&&t.width!==this.state.width||void 0!==t.height&&t.height!==this.state.height);return t&&void 0!==t.display&&t.display!==this.state.display&&bumpVisibilityEpoch(),e}__afterStateMerge(t){t&&this.parentNode&&"function"==typeof this.parentNode.requestLayout&&this.parentNode.requestLayout()}set dirty(t){this.__dirty=t}get dirty(){return this.__dirty}__applyDirty(t){this.dirty=t||!this.__everRendered}set paramsDirty(t){this.__paramsDirty=t}get paramsDirty(){return this.__paramsDirty}setPosition(e,i){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new m;this.trigger(t.BEFORE_MOVE,_objectSpread2(_objectSpread2({},s),{},{left:e,top:i})),this.setState({left:e,top:i}),this.trigger(t.AFTER_MOVE,_objectSpread2(_objectSpread2({},s),{},{left:e,top:i})),triggerSubtreeMove(this,_objectSpread2(_objectSpread2({},s),{},{left:e,top:i}))}moveGlobalPosition(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new m;if(this.parentNode){let i=[t,e];i=transformMat2d([],i,invert([],this.parentNode.calcAbsoluteLinearMatrix())),t=i[0],e=i[1]}this.setPosition(this.state.left+t,this.state.top+e,_objectSpread2(_objectSpread2({},i),{},{tx:t,ty:e}))}setGlobalPosition(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new m;if(this.parentNode){let i=[t,e];i=transformMat2d([],i,invert([],this.parentNode.calcAbsoluteLinearMatrix())),t=i[0],e=i[1]}this.setPosition(t,e,_objectSpread2(_objectSpread2({},i),{},{left:t,top:e}))}setGlobalRotate(t){if(this.parentNode){const e=this.parentNode.calcAbsoluteLinearMatrix();t-=GeoUtil.calcRotateAngleFromMatrix(e)}this.setState({transform:{rotate:t}})}localToGlobal(t,e){let i=[t,e];return i=transformMat2d([],i,this.state.composedMatrix),i}globalToLocal(t,e){let i=[t,e];return i=transformMat2d([],i,invert([],this.state.composedMatrix)),i}getRotateAngle(){const t=arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.composeMatrix():this.state.composedMatrix;return GeoUtil.calcRotateAngleFromMatrix(t)}getLocalLeftTop(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this.getMinBoundingBox(t),i=e.width,s=e.height;return{left:e.centerX-e.width/2,top:e.centerY-e.height/2,width:i,height:s}}__resetLeakyCtxState(){let t=0;const scan=e=>{if(e)for(const i in e){const e=this.__leakyIndex(i);e>=0&&(t|=1<<e)}};if(scan(this.props.style),scan(this.state.style),this.__opacityApplied&&(t|=1<<this.__leakyIndex("globalAlpha"),this.__opacityApplied=!1),this.state.lineDash&&this.state.lineDash.length&&(t|=2048),(this.state.lineDashFlow||this.state.lineDashOffset)&&(t|=2048),!t)return;const e=this.ctx;for(let i=0;i<b.length;i++)t&1<<i&&(e[b[i][0]]=b[i][1]);2048&t&&"function"==typeof e.setLineDash&&(e.setLineDash([]),e.lineDashOffset=0)}__leakyIndex(t){switch(t){case"shadowColor":return 0;case"shadowBlur":return 1;case"shadowOffsetX":return 2;case"shadowOffsetY":return 3;case"globalAlpha":return 4;case"globalCompositeOperation":return 5;case"lineCap":return 6;case"lineJoin":return 7;case"miterLimit":return 8;case"textAlign":return 9;case"textBaseline":return 10;default:return-1}}__paintWorldBox(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0];const e=this.state.composedMatrix,i=this.state.localOrigin,s=i?i[0]:0,o=i?i[1]:0,r=this.__localBox(),a=[r[0]-s,r[2]-s],h=[r[1]-o,r[3]-o];if(t[0]=t[1]=1/0,t[2]=t[3]=-1/0,!e||e.length<6)return t[0]=a[0],t[1]=h[0],t[2]=a[1],t[3]=h[1],t;const l=e[0],c=e[1],d=e[2],u=e[3],p=e[4],f=e[5];for(let e=0;e<2;e++){const i=a[e];for(let e=0;e<2;e++){const s=h[e],o=l*i+d*s+p,r=c*i+u*s+f;o<t[0]&&(t[0]=o),o>t[2]&&(t[2]=o),r<t[1]&&(t[1]=r),r>t[3]&&(t[3]=r)}}return t}containsPoint(t,e){const i=this.state.composedMatrix;if(!i||i.length<6)return this.getMinBoundingBox().containsPoint([t,e]);const s=transformMat2d([],[t,e],invert([],i));return this.containsLocalPoint(s[0],s[1])}containsLocalPoint(t,e){const i=this.state.width/2,s=this.state.height/2;return t>=-i&&t<=i&&e>=-s&&e<=s}destroy(){this.destory()}destory(){this.ice&&this.ice.animationManager&&this.ice.animationManager.remove(this),this.trigger(t.BEFORE_REMOVE,null,{component:this}),this.purgeEvents(),this.ice=null,this.ctx=null,this.root=null,this.evtBus=null,this.parentNode=null}}_defineProperty(ICEComponent,"instanceCounter",0);var C=ICEComponent;var w=class ICEPath extends C{ensurePathBuilt(){const t=this.path2D&&this.path2D._commands;t&&0!==t.length&&!this.dirty||(this.createPathObject(),this.state.closePath&&this.path2D.closePath())}constructor(){super(_objectSpread2({closePath:!0},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})),_defineProperty(this,"path2D",p.createPath2D()),_defineProperty(this,"__flowRegistered",!1)}doRender(){this.dirty&&this.createPathObject(),this.state.closePath&&this.path2D.closePath();const t=this.path2D.drawable||this.path2D,e=this.state.lineDash,i=Array.isArray(e)&&e.length>0,s=this.state.lineDashFlow;s&&this.__ensureFlowAnimation();if(this.state.lineBorder&&i&&this.state.stroke){const e=this.ctx;e.save(),e.setLineDash([]),e.lineWidth=(this.state.style.lineWidth||1)+2*(this.state.lineBorderWidth||4),e.strokeStyle=this.state.lineBorderColor||"#c8c8c8",this.path2D._isPolyfill?(this.replayPath(),e.stroke()):e.stroke(t),e.restore()}if(i&&"function"==typeof this.ctx.setLineDash)if(this.ctx.setLineDash(e),s&&"number"==typeof this.ctx.lineDashOffset){const t=e.reduce((t,e)=>t+e,0)||1,i=this.state.lineDashFlowSpeed||60;this.ctx.lineDashOffset=-Date.now()/1e3*i%t}else this.state.lineDashOffset&&(this.ctx.lineDashOffset=this.state.lineDashOffset);this.path2D._isPolyfill?(this.replayPath(),this.state.fill&&this.ctx.fill(),this.state.stroke&&this.ctx.stroke()):(this.state.fill&&this.ctx.fill(t),this.state.stroke&&this.ctx.stroke(t)),i&&"function"==typeof this.ctx.setLineDash&&this.ctx.setLineDash([]),super.doRender()}__ensureFlowAnimation(){this.__flowRegistered||(this.__flowRegistered=!0,this.props.animations=_objectSpread2(_objectSpread2({},this.props.animations),{},{__flow:{from:0,to:1,duration:100,loop:!0}}),this.ice&&this.ice.animationManager&&this.ice.animationManager.add(this))}replayPath(){const t=this.ctx;t.beginPath();const e=this.path2D._commands;for(let i=0;i<e.length;i++){const s=e[i];t[s[0]](...s.slice(1))}}};var M=class ICERect extends w{constructor(){super(_objectSpread2({width:10,height:10},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}))}createPathObject(){this.path2D=p.createPath2D();const t=0-this.state.localOrigin[0],e=0-this.state.localOrigin[1],i=this.state.width,s=this.state.height,o=Math.min(this.state.radius||0,i/2,s/2);return o>0?(this.path2D.moveTo(t+o,e),this.path2D.lineTo(t+i-o,e),this.path2D.arcTo(t+i,e,t+i,e+o,o),this.path2D.lineTo(t+i,e+s-o),this.path2D.arcTo(t+i,e+s,t+i-o,e+s,o),this.path2D.lineTo(t+o,e+s),this.path2D.arcTo(t,e+s,t,e+s-o,o),this.path2D.lineTo(t,e+o),this.path2D.arcTo(t,e,t+o,e,o),this.path2D.closePath()):this.path2D.rect(t,e,i,s),this.path2D}};class ICEGroup extends M{constructor(t){super(t),_defineProperty(this,"parentNode",null),_defineProperty(this,"childNodes",[]),_defineProperty(this,"__childSet",new WeakSet),_defineProperty(this,"layoutManager",null),_defineProperty(this,"__layoutExplicit",!1),_defineProperty(this,"__layoutRequested",!1),_defineProperty(this,"__layingOut",!1),_defineProperty(this,"__inBatch",!1)}setLayout(t){this.layoutManager=t,this.__layoutExplicit=!0,t&&(this.doLayout(),this.__disableTransformRecursively(this)),this.__propagateLayout(t)}__disableTransformRecursively(t){if(t&&t.childNodes)for(const e of t.childNodes)e.state.transformable=!1,e.state.draggable=!1,this.__disableTransformRecursively(e)}__propagateLayout(t){for(const e of this.childNodes)e instanceof ICEGroup&&!e.__layoutExplicit&&(e.layoutManager=t,e.doLayout(),e.__propagateLayout(t))}doLayout(){if(this.layoutManager){this.__layingOut=!0;try{for(let t=0;t<this.childNodes.length;t++){const e=this.childNodes[t];"function"==typeof e.measure&&e.measure()}this.layoutManager.layoutContainer(this)}finally{this.__layingOut=!1,this.__layoutRequested=!1}}}requestLayout(){this.layoutManager&&!this.__layingOut&&(this.__layoutRequested=!0,this.dirty=!0,this.ice&&(this.ice.dirty=!0))}getPreferredSize(){return this.layoutManager?this.layoutManager.getPreferredSize(this):[0,0]}doRender(){this.__layoutRequested&&this.doLayout(),super.doRender()}initEvents(){super.initEvents(),this.once(t.AFTER_ADD,this.afterAddHandler,this)}afterAddHandler(){for(let t=0;t<this.childNodes.length;t++){const e=this.childNodes[t];this.syncChildEvents(e)}}syncChildEvents(e){e.trigger(t.BEFORE_ADD),e.ice=this.ice,e.ctx=this.ice.ctx,e.evtBus=this.ice.evtBus,e.trigger(t.AFTER_ADD)}addChild(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.__childSet.has(t)||(t.parentNode=this,this.childNodes.push(t),this.__childSet.add(t),bumpVisibilityEpoch(),this.layoutManager&&(t.state.transformable=!1,t.state.draggable=!1,this.__disableTransformRecursively(t)),this.__applyDirty(e),this.ice&&(this.syncChildEvents(t),this.ice.dirty=e,this.ice.renderer&&this.ice.renderer.markQueueDirty()),this.layoutManager&&(t instanceof ICEGroup&&!t.__layoutExplicit&&(t.layoutManager=this.layoutManager),this.__inBatch||this.doLayout()))}addChildren(t){this.__inBatch=!0;try{for(let e=0;e<t.length;e++)this.addChild(t[e],!1)}finally{this.__inBatch=!1}this.dirty=!0,this.ice&&(this.ice.dirty=!0),this.doLayout()}adoptChild(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!t||t===this)return;const i=t.parentNode;if(i&&i!==this&&i.childNodes){const e=i.childNodes.indexOf(t);-1!==e&&i.childNodes.splice(e,1),i.__childSet&&"function"==typeof i.__childSet.delete&&i.__childSet.delete(t),t.parentNode=null,i.ice&&i.ice.renderer&&"function"==typeof i.ice.renderer.markQueueDirty&&i.ice.renderer.markQueueDirty()}else if(!i){const e=this.ice||t.ice;if(e&&Array.isArray(e.childNodes)){const i=e.childNodes.indexOf(t);-1!==i&&e.childNodes.splice(i,1),e.__childSet&&"function"==typeof e.__childSet.delete&&e.__childSet.delete(t),e.renderer&&"function"==typeof e.renderer.markQueueDirty&&e.renderer.markQueueDirty()}}this.addChild(t,e)}removeChild(e){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.__childSet.has(e))return;e.trigger(t.BEFORE_REMOVE);const s=this.childNodes.indexOf(e);-1!==s&&this.childNodes.splice(s,1),this.__childSet.delete(e),bumpVisibilityEpoch(),e.trigger(t.AFTER_REMOVE),this.__applyDirty(i),this.ice&&(this.ice.dirty=i,this.ice.renderer&&this.ice.renderer.markQueueDirty()),e.destory(),this.layoutManager&&!this.__inBatch&&this.doLayout()}removeChildren(t){this.__inBatch=!0;try{for(let e=0;e<t.length;e++)this.removeChild(t[e],!1)}finally{this.__inBatch=!1}this.dirty=!0,this.ice&&(this.ice.dirty=!0),this.doLayout()}setState(t){const e=this.__beforeStateMerge(t);merge(this.state,t),this.paramsDirty=!0,this.dirty=!0,function setRecursively(t){if(t.dirty=!0,t.childNodes&&t.childNodes.length)for(let e=0;e<t.childNodes.length;e++)setRecursively(t.childNodes[e])}(this),this.ice&&(this.ice.dirty=!0),this.__afterStateMerge(e)}destory(){this.removeChildren(this.childNodes),super.destory()}}var S=ICEGroup;class ICEControlPanel extends S{constructor(t){super(_objectSpread2(_objectSpread2({},t),{},{linkable:!1})),_defineProperty(this,"isControlPanel",!0)}doRender(){super.doRender(),this.updateControlPositions()}moveGlobalPosition(t,e,i){super.moveGlobalPosition(t,e,i),this._targetComponent&&this._targetComponent.moveGlobalPosition(t,e,i)}}var P=class ICEEllipse extends w{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=_objectSpread2({radiusX:20,radiusY:10,rotation:0,startAngle:0,endAngle:2*Math.PI,counterclockwise:!0},t);void 0===t.radiusX&&void 0!==t.width&&(e.radiusX=Number(t.width)/2),void 0===t.radiusY&&void 0!==t.height&&(e.radiusY=Number(t.height)/2),e.width=2*e.radiusX,e.height=2*e.radiusY,super(e)}createPathObject(){return this.path2D=p.createPath2D(),this.path2D.ellipse(this.state.radiusX-this.state.localOrigin[0],this.state.radiusY-this.state.localOrigin[1],this.state.radiusX,this.state.radiusY,this.state.rotation,this.state.startAngle,this.state.endAngle,this.state.counterclockwise),this.path2D.closePath(),this.path2D}containsLocalPoint(t,e){const i=this.state.radiusX,s=this.state.radiusY;if(!i||!s)return!1;let o=t,r=e;const a=this.state.rotation||0;if(a){const i=Math.cos(a),s=Math.sin(a);o=t*i+e*s,r=-t*s+e*i}const h=o/i,l=r/s;return h*h+l*l<=1}setState(t){isNil(t.radiusX)?isNil(t.width)||(t.radiusX=t.width/2):t.width=2*t.radiusX,isNil(t.radiusY)?isNil(t.height)||(t.radiusY=t.height/2):t.height=2*t.radiusY,super.setState(t)}};var T=class ICECircle extends P{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=_objectSpread2({radius:10},t);void 0===t.radius&&void 0!==t.width?e.radius=Number(t.width)/2:void 0===t.radius&&void 0!==t.height&&(e.radius=Number(t.height)/2),e.radiusX=e.radius,e.radiusY=e.radius,super(e)}};class ICELinkHook extends T{constructor(){super(_objectSpread2({linkable:!1},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}))}initEvents(){super.initEvents(),this.on("mousedown",this.mosueDownHandler,this),this.on("mousemove",this.mosueMoveHandler,this),this.on("mouseup",this.mosueUpHandler,this),this.on(t.AFTER_MOVE,this.resizeEvtHandler,this)}keyboardEvtHandler(t){}mosueDownHandler(e){this.evtBus.trigger(t.HOOK_MOUSEDOWN,new m({target:this}))}mosueMoveHandler(e){this.evtBus.trigger(t.HOOK_MOUSEMOVE,new m({target:this}))}mosueUpHandler(e){this.evtBus.trigger(t.HOOK_MOUSEUP,new m({target:this}))}resizeEvtHandler(e){if(!this.parentNode)return;const i=this.props.position;this.parentNode.trigger(t.BEFORE_RESIZE,new m(e,{position:i})),this.parentNode.trigger(t.AFTER_RESIZE,new m(e,{position:i}))}}class LineControlPanel extends ICEControlPanel{constructor(t){super(_objectSpread2(_objectSpread2({},t),{},{zIndex:10001e3,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1})),_defineProperty(this,"controlSize",16),this.initControls()}initControls(){const t=this.state.width,e=this.state.height,i=this.controlSize/2;this.startControl=new ICELinkHook({zIndex:10001001,display:!1,left:-i,top:-i,width:this.controlSize,height:this.controlSize,style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1},position:"start"}),this.addChild(this.startControl),this.endControl=new ICELinkHook({zIndex:10001002,display:!1,left:t-i,top:e-i,width:this.controlSize,height:this.controlSize,style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1},position:"end"}),this.addChild(this.endControl)}initEvents(){this.on(t.AFTER_RESIZE,this.resizeEvtHandler,this)}enable(){this.setState({display:!0}),this.resume(t.AFTER_RESIZE),this.showHooks()}disable(){this.setState({display:!1}),this.suspend(t.AFTER_RESIZE),this.hideHooks()}updateControlPositions(){}resizeEvtHandler(t){if(!this.targetComponent)return;const e=t.position;let i=t.movementX,s=t.movementY;const o=this.targetComponent.state,r=o.points.length;let a=o.points[0][0],h=o.points[0][1],l=o.points[r-1][0],c=o.points[r-1][1];const d=transformMat2d([],[i,s],invert([],this.targetComponent.calcAbsoluteLinearMatrix()));switch(i=d[0],s=d[1],e){case"start":a+=i,h+=s;break;case"end":l+=i,c+=s}this.targetComponent.setState({startPoint:[a,h],endPoint:[l,c]})}updatePosition(){if(!this.targetComponent)return;this.setState({left:0,top:-5,width:3,height:3,transform:{translate:[0,0],scale:[1,1],skew:[0,0],rotate:0}});const t=this.controlSize/2,e=this.targetComponent.state.points.length,i=this.targetComponent.state.points[0],s=this.targetComponent.state.points[e-1],o=[i[0],i[1]],r=[s[0],s[1]];this.startControl.setState({left:o[0]-t,top:o[1]-t}),this.endControl.setState({left:r[0]-t,top:r[1]-t})}set targetComponent(e){this._targetComponent&&this._targetComponent.off(t.AFTER_MOVE,this.updatePosition,this),this._targetComponent=e,this._targetComponent&&this._targetComponent.on(t.AFTER_MOVE,this.updatePosition,this),this._targetComponent&&this._targetComponent.once(t.BEFORE_REMOVE,()=>{this.targetComponent=null,this.disable()},this),this.updatePosition()}get targetComponent(){return this._targetComponent}showHooks(){this.startControl.setState({display:!0}),this.endControl.setState({display:!0})}hideHooks(){this.startControl.setState({display:!1}),this.endControl.setState({display:!1})}}class ResizeControl extends M{constructor(t){super(_objectSpread2(_objectSpread2({position:"l",direction:"x",quadrant:1},t),{},{linkable:!1}))}initEvents(){super.initEvents(),this.on(t.AFTER_MOVE,this.resizeEvtHandler,this)}resizeEvtHandler(e){if(!this.parentNode)return;const{quadrant:i}=e;let s=e.movementX,o=e.movementY;const r=this.parentNode.state;let a=r.left,h=r.top,l=r.width,c=r.height;const d=transformMat2d([],[s,o],invert([],this.parentNode.calcAbsoluteLinearMatrix()));switch(s=d[0],o=d[1],i){case 1:a-=s,h+=o,l+=2*s,c-=2*o;break;case 2:a+=s,h+=o,l-=2*s,c-=2*o;break;case 3:a+=s,h-=o,l-=2*s,c+=2*o;break;case 4:a-=s,h-=o,l+=2*s,c+=2*o;break;case 5:h+=o,c-=2*o;break;case 6:h-=o,c+=2*o;break;case 7:a+=s,l-=2*s;break;case 8:a-=s,l+=2*s}const u={top:h,left:a,width:Math.abs(l),height:Math.abs(c)};this.parentNode.trigger(t.BEFORE_RESIZE,new m(e,{quadrant:i})),this.parentNode.setState(u),this.parentNode.trigger(t.AFTER_RESIZE,new m(e,{quadrant:i}))}moveGlobalPosition(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new m;const s=t>0?1:-1,o=e>0?1:-1,r=this.parentNode.state.localOrigin,a=transformMat2d([],[t,e],invert([],this.parentNode.calcAbsoluteLinearMatrix()));t=a[0],e=a[1];let{left:h,top:l}=this.state;const{quadrant:c}=this.state,d=this.state.width/2;let u=0;"x"===this.state.direction?(h+=t,0===round(h)&&(h=.5*s),u=h+d-r[0]>0?8:7):"y"===this.state.direction?(l+=e,0===round(l)&&(l=.5*o),u=l+d-r[1]>0?6:5):"xy"===this.state.direction&&(h+=t,l+=e,u=h+d-r[0]>0?l+d-r[1]>0?4:1:l+d-r[1]>0?3:2);c!==u&&this.parentNode.toggleControlQuadrant(this,c,u),this.setPosition(h,l,new m(i,{left:h,top:l,tx:t,ty:e,quadrant:u}))}}class RotateControl extends T{constructor(t){super(_objectSpread2(_objectSpread2({},t),{},{linkable:!1}))}initEvents(){super.initEvents(),this.on(t.AFTER_MOVE,this.rotateEvtHandler,this)}rotateEvtHandler(e){if(!this.parentNode)return;const i=this.parentNode.calcAbsoluteOrigin();let s=GeoUtil.calcRotateAngle(e.offsetX,e.offsetY,i[0],i[1])+90;e&&e.shiftKey&&(s=function snapAngle(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;return e>0&&isFinite(t)?Math.round(t/e)*e:t}(s));const o={transform:{rotate:s}};this.parentNode.trigger(t.BEFORE_ROTATE,new m(o)),this.parentNode.setState(o),this.parentNode.trigger(t.AFTER_ROTATE,new m(o))}}class TransformControlPanel extends ICEControlPanel{constructor(t){super(_objectSpread2(_objectSpread2({},t),{},{zIndex:10000001,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1})),_defineProperty(this,"rotateControlSize",8),_defineProperty(this,"rotateControlOffsetY",60),_defineProperty(this,"resizeControlInstanceCache",[]),_defineProperty(this,"resizeControlSize",16),_defineProperty(this,"__onTargetRemoved",()=>{this.targetComponent=null,this.disable()}),this.initControls()}initControls(){const t=this.state.width,e=this.state.height,i=t/2,s=e/2,o=this.resizeControlSize/2,r=[{direction:"xy",quadrant:2,position:[-o,-o]},{direction:"y",quadrant:5,position:[i-o,-o]},{direction:"xy",quadrant:1,position:[t-o,-o]},{direction:"x",quadrant:8,position:[t-o,s-o]},{direction:"xy",quadrant:4,position:[t-o,e-o]},{direction:"y",quadrant:6,position:[i-o,e-o]},{direction:"xy",quadrant:3,position:[-o,e-o]},{direction:"x",quadrant:7,position:[-o,s-o]}];this.resizeControlInstanceCache=[];for(let t=0;t<r.length;t++){const e=r[t],i=new ResizeControl({zIndex:10000002,display:!1,left:e.position[0],top:e.position[1],width:this.resizeControlSize,height:this.resizeControlSize,style:{strokeStyle:"#8b0000",fillStyle:"#CC3300",lineWidth:1},direction:e.direction,quadrant:e.quadrant});this.addChild(i),this.resizeControlInstanceCache.push(i)}const a=this.state.width/2-this.rotateControlSize,h=-this.rotateControlOffsetY;this.rotateControlInstance=new RotateControl({zIndex:10000003,display:!1,left:a,top:h,radius:this.rotateControlSize,style:{strokeStyle:"#8b0000",fillStyle:"#CC3300",lineWidth:1}}),this.addChild(this.rotateControlInstance)}initEvents(){super.initEvents(),this.on(t.AFTER_RESIZE,this.resizeEvtHandler,this),this.on(t.AFTER_ROTATE,this.rotateEvtHandler,this),this.on("keydown",this.keyboardEvtHandler,this),this.on("keyup",this.keyboardEvtHandler,this)}enable(){this.rotateControlInstance.setState({display:!0});for(let t=0;t<this.resizeControlInstanceCache.length;t++){this.resizeControlInstanceCache[t].setState({display:!0})}this.setState({display:!0}),this.resume(t.AFTER_RESIZE),this.resume(t.AFTER_ROTATE),this.resume("keydown"),this.resume("keyup")}disable(){this.rotateControlInstance.setState({display:!1});for(let t=0;t<this.resizeControlInstanceCache.length;t++){this.resizeControlInstanceCache[t].setState({display:!1})}this.setState({display:!1}),this.suspend(t.AFTER_RESIZE),this.suspend(t.AFTER_ROTATE),this.suspend("keydown"),this.suspend("keyup")}keyboardEvtHandler(t){this.targetComponent&&this.targetComponent.trigger(t.type,t,{component:this.targetComponent})}rotateEvtHandler(e){if(!this.targetComponent)return;const{rotate:i}=this.state.transform;this.targetComponent.setGlobalRotate(i),this.targetComponent.trigger(t.AFTER_ROTATE),this.updatePanel()}resizeEvtHandler(e){if(!this.targetComponent)return;const{quadrant:i}=e;let s=e.movementX,o=e.movementY;const r=this.targetComponent.state;let a=r.left,h=r.top,l=r.width,c=r.height;const d=transformMat2d([],[s,o],invert([],this.targetComponent.calcAbsoluteLinearMatrix()));switch(s=d[0],o=d[1],i){case 1:a-=s,h+=o,l+=2*s,c-=2*o;break;case 2:a+=s,h+=o,l-=2*s,c-=2*o;break;case 3:a+=s,h-=o,l-=2*s,c+=2*o;break;case 4:a-=s,h-=o,l+=2*s,c+=2*o;break;case 5:h+=o,c-=2*o;break;case 6:h-=o,c+=2*o;break;case 7:a+=s,l-=2*s;break;case 8:a-=s,l+=2*s}if(e&&e.shiftKey){const t=function applyAspectLock(t,e,i,s){const o=Math.abs(i),r=Math.abs(s);if(!(t>0&&e>0))return{width:o,height:r};const a=Math.max(o/t,r/e);return{width:t*a,height:e*a}}(r.width,r.height,l,c),e=h+c/2;a=a+l/2-t.width/2,h=e-t.height/2,l=t.width,c=t.height}this.targetComponent.setState({left:a,top:h,width:Math.abs(l),height:Math.abs(c)}),this.targetComponent.trigger(t.AFTER_RESIZE),this.updatePanel()}updateControlPositions(){const t=this.state.width,e=this.state.height,i=t/2,s=e/2,o=this.resizeControlSize/2;for(let r=0;r<this.resizeControlInstanceCache.length;r++){const a=this.resizeControlInstanceCache[r];let h=[0,0];switch(a.state.quadrant){case 1:h=[t-o,-o];break;case 2:h=[-o,-o];break;case 3:h=[-o,e-o];break;case 4:h=[t-o,e-o];break;case 5:h=[i-o,-o];break;case 6:h=[i-o,e-o];break;case 7:h=[-o,s-o];break;case 8:h=[t-o,s-o]}a.setState({left:h[0],top:h[1]})}const r=this.state.width/2-this.rotateControlSize,a=-this.rotateControlOffsetY;this.rotateControlInstance.setState({left:r,top:a})}updatePanel(){if(!this.targetComponent)return;const t=this.targetComponent.getRotateAngle(!0),{left:e,top:i,width:s,height:o}=this.targetComponent.getLocalLeftTop(!0);this.setState({left:e,top:i,width:s,height:o,transform:{rotate:t}})}set targetComponent(e){const i=this._targetComponent;i&&(i.off(t.AFTER_MOVE,this.updatePanel,this),i.off(t.BEFORE_REMOVE,this.__onTargetRemoved,this)),this._targetComponent=e,e&&(e.on(t.AFTER_MOVE,this.updatePanel,this),e.on(t.BEFORE_REMOVE,this.__onTargetRemoved,this)),this.updatePanel()}get targetComponent(){return this._targetComponent}toggleControlQuadrant(t,e,i){for(let t=0;t<this.resizeControlInstanceCache.length;t++){const s=this.resizeControlInstanceCache[t];s.state.quadrant===i&&s.setState({quadrant:e})}t.setState({quadrant:i})}}var I=class ICEControlPanelManager{constructor(t){this.ice=t,this.transformControlPanel=new TransformControlPanel({left:500,top:100,width:100,height:100,style:{strokeStyle:"#8b0000",fillStyle:"rgba(255, 255, 49, 0.2)",lineWidth:1},transform:{rotate:45}}),this.ice.addTool(this.transformControlPanel),this.transformControlPanel.disable(),this.lineControlPanel=new LineControlPanel({left:700,top:50,width:100,height:100,style:{strokeStyle:"rgba(255, 255, 49, 0)",fillStyle:"rgba(255, 255, 49, 0)",lineWidth:1}}),this.ice.addTool(this.lineControlPanel),this.lineControlPanel.disable()}start(){return this.ice.evtBus.on("mousedown",this.mouseDownHandler,this),this}stop(){return this.ice.evtBus.off("mousedown",this.mouseDownHandler,this),this}mouseDownHandler(t){const e=t.target;if(!(e&&e.ice&&e.state.interactive&&e.state.transformable))return this.lineControlPanel.disable(),void this.transformControlPanel.disable();if(e&&(e.isControlPanel||e.parentNode&&e.parentNode.isControlPanel))return;const i=this.ice.setSelection([e]);this.lineControlPanel.disable(),this.transformControlPanel.disable(),i||(e.isLine?(this.lineControlPanel.targetComponent=e,this.lineControlPanel.enable()):(this.transformControlPanel.targetComponent=e,this.transformControlPanel.enable()))}};var B=class AlignmentGuideManager{constructor(t){_defineProperty(this,"options",{threshold:3,hysteresis:1,edge:!0,center:!0,spacing:!0,guideStyle:{fillStyle:"#EC4899"},guideZIndex:10000010,guideWidth:1}),_defineProperty(this,"enabled",!1),_defineProperty(this,"active",null),_defineProperty(this,"snapping",!1),_defineProperty(this,"intentLeft",0),_defineProperty(this,"intentTop",0),_defineProperty(this,"cachedTargets",[]),_defineProperty(this,"engagedX",!1),_defineProperty(this,"engagedY",!1),_defineProperty(this,"guideX",null),_defineProperty(this,"guideY",null),this.ice=t}enable(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.options=_objectSpread2(_objectSpread2({},this.options),t),this.enabled||(this.enabled=!0,this.ice.evtBus.on("mousedown",this.__onMouseDown,this),this.ice.evtBus.on("mouseup",this.__onMouseUp,this)),this}disable(){return this.enabled?(this.enabled=!1,this.ice.evtBus.off("mousedown",this.__onMouseDown,this),this.ice.evtBus.off("mouseup",this.__onMouseUp,this),this.__detach(),this):this}isEnabled(){return this.enabled}setOptions(t){return this.options=_objectSpread2(_objectSpread2({},this.options),t),this}__onMouseDown(t){const e=t&&t.target;this.__isAlignmentParticipant(e)&&(this.__detach(),this.active=e,this.intentLeft=e.state.left,this.intentTop=e.state.top,this.cachedTargets=this.__computeTargets(),this.engagedX=!1,this.engagedY=!1,this.__ensureGuides(),e.on("mousemove",this.__onDrag,this))}__onDrag(t){if(!this.active||this.snapping)return;const e=t&&"number"==typeof t.movementX?t.movementX:0,i=t&&"number"==typeof t.movementY?t.movementY:0,s=this.ice.viewport?this.ice.viewport.scale:1;this.intentLeft+=e/s,this.intentTop+=i/s,this.snapping=!0,this.active.setState({left:this.intentLeft,top:this.intentTop});const o=this.__boxOf(this.active);if(this.snapping=!1,!o)return;const r=this.options.threshold/s,a=(this.options.threshold+this.options.hysteresis)/s,h=function computeSnap(t,e,i,s,o){const r={x:null,y:null},consider=t=>{if(!t)return;const e=r[t.axis];(!e||Math.abs(t.delta)<Math.abs(e.delta))&&(r[t.axis]=t)};for(const i of e)o.edge&&(consider({axis:"x",type:"edge",delta:i.minX-t.minX,guideValue:i.minX,guideStart:Math.min(t.minY,i.minY),guideEnd:Math.max(t.maxY,i.maxY)}),consider({axis:"x",type:"edge",delta:i.maxX-t.minX,guideValue:i.maxX,guideStart:Math.min(t.minY,i.minY),guideEnd:Math.max(t.maxY,i.maxY)}),consider({axis:"x",type:"edge",delta:i.minX-t.maxX,guideValue:i.minX,guideStart:Math.min(t.minY,i.minY),guideEnd:Math.max(t.maxY,i.maxY)}),consider({axis:"x",type:"edge",delta:i.maxX-t.maxX,guideValue:i.maxX,guideStart:Math.min(t.minY,i.minY),guideEnd:Math.max(t.maxY,i.maxY)}),consider({axis:"y",type:"edge",delta:i.minY-t.minY,guideValue:i.minY,guideStart:Math.min(t.minX,i.minX),guideEnd:Math.max(t.maxX,i.maxX)}),consider({axis:"y",type:"edge",delta:i.maxY-t.minY,guideValue:i.maxY,guideStart:Math.min(t.minX,i.minX),guideEnd:Math.max(t.maxX,i.maxX)}),consider({axis:"y",type:"edge",delta:i.minY-t.maxY,guideValue:i.minY,guideStart:Math.min(t.minX,i.minX),guideEnd:Math.max(t.maxX,i.maxX)}),consider({axis:"y",type:"edge",delta:i.maxY-t.maxY,guideValue:i.maxY,guideStart:Math.min(t.minX,i.minX),guideEnd:Math.max(t.maxX,i.maxX)})),o.center&&(consider({axis:"x",type:"center",delta:i.centerX-t.centerX,guideValue:i.centerX,guideStart:Math.min(t.minY,i.minY),guideEnd:Math.max(t.maxY,i.maxY)}),consider({axis:"y",type:"center",delta:i.centerY-t.centerY,guideValue:i.centerY,guideStart:Math.min(t.minX,i.minX),guideEnd:Math.max(t.maxX,i.maxX)}));if(o.spacing)for(let i=0;i<e.length;i++)for(let s=i+1;s<e.length;s++){const o=e[i],r=e[s],a=Math.min(o.centerX,r.centerX),h=Math.max(o.centerX,r.centerX);if(t.centerX>a&&t.centerX<h){const e=(o.centerX+r.centerX)/2;consider({axis:"x",type:"spacing",delta:e-t.centerX,guideValue:e,guideStart:Math.min(t.minY,o.minY,r.minY),guideEnd:Math.max(t.maxY,o.maxY,r.maxY)})}const l=Math.min(o.centerY,r.centerY),c=Math.max(o.centerY,r.centerY);if(t.centerY>l&&t.centerY<c){const e=(o.centerY+r.centerY)/2;consider({axis:"y",type:"spacing",delta:e-t.centerY,guideValue:e,guideStart:Math.min(t.minX,o.minX,r.minX),guideEnd:Math.max(t.maxX,o.maxX,r.maxX)})}}return r.x=r.x&&Math.abs(r.x.delta)<=i?r.x:null,r.y=r.y&&Math.abs(r.y.delta)<=s?r.y:null,r}(o,this.cachedTargets,this.engagedX?a:r,this.engagedY?a:r,this.options);if(h.x||h.y){const t=this.intentLeft+(h.x?Math.round(h.x.delta):0),e=this.intentTop+(h.y?Math.round(h.y.delta):0);this.active.setState({left:t,top:e}),this.engagedX=!!h.x,this.engagedY=!!h.y,this.__updateGuides(h)}else this.engagedX=!1,this.engagedY=!1,this.__hideGuides()}__onMouseUp(){this.__detach()}__detach(){this.active&&this.active.off("mousemove",this.__onDrag,this),this.active=null,this.intentLeft=0,this.intentTop=0,this.cachedTargets=[],this.engagedX=!1,this.engagedY=!1,this.__hideGuides()}__boxOf(t){const e=t.getMaxBoundingBox(!0);if(!e)return null;const i=e.getMinAndMaxPoint();return function toBox(t,e,i,s){return{minX:t,minY:e,maxX:i,maxY:s,centerX:(t+i)/2,centerY:(e+s)/2}}(i.minX,i.minY,i.maxX,i.maxY)}__computeTargets(){const t=this.ice.childNodes,e=[];for(const i of t){if(i===this.active)continue;if(!this.__isAlignmentParticipant(i))continue;const t=this.__boxOf(i);t&&e.push(t)}return e}__isAlignmentParticipant(t){return!!(t&&t.state&&t.state.interactive&&t.state.draggable)&&(!t.isLine&&(!t.isControlPanel&&(!t.parentNode||!t.parentNode.isControlPanel)))}__ensureGuides(){const t=_objectSpread2({},this.options.guideStyle);this.guideX||(this.guideX=new M({left:0,top:0,width:1,height:1,display:!1,zIndex:this.options.guideZIndex,origin:"top-left",stroke:!1,style:t}),this.ice.addTool(this.guideX)),this.guideY||(this.guideY=new M({left:0,top:0,width:1,height:1,display:!1,zIndex:this.options.guideZIndex,origin:"top-left",stroke:!1,style:t}),this.ice.addTool(this.guideY))}__updateGuides(t){const e=this.options.guideWidth/(this.ice.viewport?this.ice.viewport.scale:1),[i,s]=this.ice.screenToWorld(0,0),[o,r]=this.ice.screenToWorld(this.ice.canvasWidth,this.ice.canvasHeight);t.x&&this.guideX?this.guideX.setState({display:!0,left:t.x.guideValue-e/2,top:s,width:e,height:r-s}):this.guideX&&this.guideX.setState({display:!1}),t.y&&this.guideY?this.guideY.setState({display:!0,left:i,top:t.y.guideValue-e/2,width:o-i,height:e}):this.guideY&&this.guideY.setState({display:!1})}__hideGuides(){this.guideX&&this.guideX.setState({display:!1}),this.guideY&&this.guideY.setState({display:!1})}};const O=[["pointerdown","ICE_POINTERDOWN"],["pointermove","ICE_POINTERMOVE"],["pointerup","ICE_POINTERUP"],["pointercancel","ICE_POINTERCANCEL"]],R=[["mousedown","ICE_MOUSEDOWN"],["mouseup","ICE_MOUSEUP"],["mousemove","ICE_MOUSEMOVE"],["click","ICE_CLICK"],["dblclick","ICE_DBCLICK"],["contextmenu","ICE_CONTEXTMENU"]],A=[["click","ICE_CLICK"],["dblclick","ICE_DBCLICK"],["contextmenu","ICE_CONTEXTMENU"]],k=[["touchstart","ICE_TOUCHSTART"],["touchmove","ICE_TOUCHMOVE"],["touchend","ICE_TOUCHEND"],["touchcancel","ICE_TOUCHCANCEL"]],D=[["wheel","ICE_WHEEL"]],N=[["keydown","ICE_KEYDOWN"],["keyup","ICE_KEYUP"]],F=["ICE_MOUSEMOVE","ICE_POINTERMOVE","ICE_TOUCHMOVE"];function buildDomEventList(t){const e=[];return t?e.push(...O,...A):e.push(...R,...k),e.push(...D,...N),e}function isTouchEvent(t){return!!t&&"string"==typeof t.type&&0===t.type.indexOf("touch")}function normalizeInput(t,e,i){const s=function resolveClientPoint(t){if(!t)return null;if(isTouchEvent(t)){const e=(t.touches&&t.touches.length?t.touches:t.changedTouches)||null,i=e&&e[0];return i&&"number"==typeof i.clientX?{clientX:i.clientX,clientY:i.clientY}:null}return"number"==typeof t.clientX&&"number"==typeof t.clientY?{clientX:t.clientX,clientY:t.clientY}:null}(t);if(!s)return null;const o=e&&"number"==typeof e.left?e.left:0,r=e&&"number"==typeof e.top?e.top:0,a=s.clientX-o,h=s.clientY-r;let l=Number(t.movementX),c=Number(t.movementY);isFinite(l)&&isFinite(c)||(i?(l=a-i.x,c=h-i.y):(l=0,c=0));const d=isTouchEvent(t);return{x:a,y:h,clientX:s.clientX,clientY:s.clientY,movementX:l,movementY:c,pointerType:t.pointerType||(d?"touch":"mouse"),pointerId:"number"==typeof t.pointerId?t.pointerId:-1,button:"number"==typeof t.button?t.button:0,buttons:"number"==typeof t.buttons?t.buttons:0,isPrimary:!1!==t.isPrimary,isTouch:d,shiftKey:!!t.shiftKey,ctrlKey:!!t.ctrlKey,altKey:!!t.altKey,metaKey:!!t.metaKey}}function applyNormalizedInput(t,e){t&&e&&(t.offsetX=e.x,t.offsetY=e.y,t.clientX=e.clientX,t.clientY=e.clientY,t.movementX=e.movementX,t.movementY=e.movementY,t.pointerType=e.pointerType,t.pointerId=e.pointerId,t.isTouchInput=e.isTouch,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.altKey=e.altKey,t.metaKey=e.metaKey)}function toLegacyMouseName(t){switch(t){case"pointerdown":case"touchstart":return"mousedown";case"pointermove":case"touchmove":return"mousemove";case"pointerup":case"touchend":case"pointercancel":case"touchcancel":return"mouseup";default:return null}}const L={sm:5,md:13,lg:26};function stylePaintPad(t){const e=t&&t.style||{};let i=2;const s=Number(e.lineWidth)||0,o=Number(t.lineBorderWidth)||0,r=Math.ceil(Math.max(s,o));r>0&&(i+=r);const a=Number(e.shadowBlur);return a>0?i+=a+Math.max(Math.abs(Number(e.shadowOffsetX)||0),Math.abs(Number(e.shadowOffsetY)||0)):"string"==typeof e.shadow&&L[e.shadow]&&(i+=L[e.shadow]),i}function boxArea(t){return function boxWidth(t){return t[2]-t[0]}(t)*function boxHeight(t){return t[3]-t[1]}(t)}function unionBoxes(t,e){return e[0]<t[0]&&(t[0]=e[0]),e[1]<t[1]&&(t[1]=e[1]),e[2]>t[2]&&(t[2]=e[2]),e[3]>t[3]&&(t[3]=e[3]),t}function intersects(t,e){return!(t[0]>e[2]||t[2]<e[0]||t[1]>e[3]||t[3]<e[1])}function isFiniteBox(t){return isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])&&isFinite(t[3])}function integerAlign(t){return t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3]),t}function mergeBox(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1]),Math.max(t[2],e[2]),Math.max(t[3],e[3])]}function isWorthMerging(t,e){const i=boxArea(t)+boxArea(e);return i<=0||boxArea(mergeBox(t,e))<=2*i}function mapBoxToRender(t,e,i){const s=i||[0,0,0,0];return s[0]=Math.floor(t[0]*e.scale+e.tx),s[1]=Math.floor(t[1]*e.scale+e.ty),s[2]=Math.ceil(t[2]*e.scale+e.tx),s[3]=Math.ceil(t[3]*e.scale+e.ty),s}const X=/(rgba|hsla)\(|transparent|#[0-9a-fA-F]{8}|opacity/i;function isOpaqueDrawing(t){const e=t&&t.style||{};if(t&&void 0!==t.opacity&&1!==t.opacity)return!1;if(void 0!==e.globalAlpha&&1!==e.globalAlpha)return!1;if(e.globalCompositeOperation&&"source-over"!==e.globalCompositeOperation)return!1;if(e.shadow||(Number(e.shadowBlur)||0)>0)return!1;for(const t of["fillStyle","strokeStyle"]){const i=e[t];if("string"==typeof i&&X.test(i))return!1}return!0}var z=class DOMEventDispatcher{constructor(t){_defineProperty(this,"selectionCandidates",[]),_defineProperty(this,"_stopped",!1),_defineProperty(this,"__lastInput",null),_defineProperty(this,"focusedComponent",null),this.ice=t}start(){let t=null;const e=buildDomEventList("function"==typeof p.PointerEvent);for(let i=0;i<e.length;i++){const s=e[i],o=s[0],r=s[1],a=toLegacyMouseName(o);this.ice.evtBus.on(r,e=>{if(this._stopped)return;const i=e.originalEvent||e;this.__handlePointerCapture(r,i);const s=normalizeInput(i,this.__resolveCanvasRect(o),this.__lastInput);s&&(applyNormalizedInput(e,s),this.__lastInput=s);const h=-1!==F.indexOf(r),l=-1!==r.indexOf("KEY"),c="ICE_WHEEL"===r;
27
+ var t={ICE_FRAME_EVENT:"ICE_FRAME_EVENT",BEFORE_RENDER:"BEFORE_RENDER",AFTER_RENDER:"AFTER_RENDER",BEFORE_ADD:"BEFORE_ADD",AFTER_ADD:"AFTER_ADD",BEFORE_REMOVE:"BEFORE_REMOVE",AFTER_REMOVE:"AFTER_REMOVE",ROUND_FINISH:"ROUND_FINISH",HOOK_MOUSEDOWN:"HOOK_MOUSEDOWN",HOOK_MOUSEMOVE:"HOOK_MOUSEMOVE",HOOK_MOUSEUP:"HOOK_MOUSEUP",BEFORE_RESIZE:"BEFORE_RESIZE",AFTER_RESIZE:"AFTER_RESIZE",BEFORE_ROTATE:"BEFORE_ROTATE",AFTER_ROTATE:"AFTER_ROTATE",BEFORE_MOVE:"BEFORE_MOVE",AFTER_MOVE:"AFTER_MOVE"};function springProgress(t,e){const i=t,s=Math.sqrt(Math.max(1e-6,1-t*t));return t=>{const o=Math.max(0,t)*e;return 1-Math.exp(-i*o)*(Math.cos(s*o)+i/s*Math.sin(s*o))}}const e={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:(4-2*t)*t-1,easeInQuart:t=>t*t*t*t,easeOutQuart:t=>1-Math.pow(1-t,4),easeInOutQuart:t=>t<.5?8*t*t*t*t:1-8*Math.pow(1-t,4),easeInCubic:t=>t*t*t,easeOutCubic:t=>1-Math.pow(1-t,3),easeInOutCubic:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,spring:springProgress(.55,12),springSoft:springProgress(.75,14),springSnappy:springProgress(.4,9)},i={color:{blue:{50:"#EFF6FF",100:"#DBEAFE",200:"#BFDBFE",300:"#93C5FD",400:"#60A5FA",500:"#3B82F6",600:"#2563EB",700:"#1D4ED8",800:"#1E40AF",900:"#1E3A8A"},emerald:{50:"#ECFDF5",100:"#D1FAE5",200:"#A7F3D0",300:"#6EE7B7",400:"#34D399",500:"#10B981",600:"#059669",700:"#047857",800:"#065F46",900:"#064E3B"},amber:{50:"#FFFBEB",100:"#FEF3C7",200:"#FDE68A",300:"#FCD34D",400:"#FBBF24",500:"#F59E0B",600:"#D97706",700:"#B45309",800:"#92400E",900:"#78350F"},red:{50:"#FEF2F2",100:"#FEE2E2",200:"#FECACA",300:"#FCA5A5",400:"#F87171",500:"#EF4444",600:"#DC2626",700:"#B91C1C",800:"#991B1B",900:"#7F1D1D"},gray:{50:"#F9FAFB",100:"#F3F4F6",200:"#E5E7EB",300:"#D1D5DB",400:"#9CA3AF",500:"#6B7280",600:"#4B5563",700:"#374151",800:"#1F2937",900:"#111827"},violet:{50:"#F5F3FF",100:"#EDE9FE",200:"#DDD6FE",300:"#C4B5FD",400:"#A78BFA",500:"#8B5CF6",600:"#7C3AED",700:"#6D28D9",800:"#5B21B6",900:"#4C1D95"},teal:{50:"#F0FDFA",100:"#CCFBF1",200:"#99F6E4",300:"#5EEAD4",400:"#2DD4BF",500:"#14B8A6",600:"#0D9488",700:"#0F766E",800:"#115E59",900:"#134E4A"},pink:{50:"#FDF2F8",100:"#FCE7F3",200:"#FBCFE8",300:"#F9A8D4",400:"#F472B6",500:"#EC4899",600:"#DB2777",700:"#BE185D",800:"#9D174D",900:"#831843"},indigo:{50:"#EEF2FF",100:"#E0E7FF",200:"#C7D2FE",300:"#A5B4FC",400:"#818CF8",500:"#6366F1",600:"#4F46E5",700:"#4338CA",800:"#3730A3",900:"#312E81"}},spacing:{1:4,2:8,3:12,4:16,6:24,8:32,12:48,16:64},radius:{sm:4,md:8,lg:12,xl:16,full:9999},fontSize:{sm:12,md:14,lg:16,xl:20,"2xl":24,"3xl":32,"4xl":44},fontFamily:{base:"Arial"},fontWeight:{normal:400,bold:700}};function buildSemantic(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=t.color;return _objectSpread2({primary:i.blue[500],success:i.emerald[500],warning:i.amber[500],danger:i.red[500],info:i.blue[400],text:i.gray[800],muted:i.gray[500],hint:i.gray[400],border:i.gray[200],background:"#ffffff",palette:[i.blue[500],i.emerald[500],i.amber[500],i.red[500],i.violet[500],i.teal[500],i.pink[500],i.indigo[500]],motion:{duration:{fast:100,normal:200,slow:300,slower:500},easing:{linear:"linear",out:"easeOutCubic",inOut:"easeInOutCubic",outQuart:"easeOutQuart",spring:"spring",springSoft:"springSoft",springSnappy:"springSnappy"}}},e)}const s={base:i,semantic:buildSemantic(i)},o={base:i,semantic:buildSemantic(i,{primary:i.color.blue[400],success:i.color.emerald[400],warning:i.color.amber[400],danger:i.color.red[400],info:i.color.teal[400],text:i.color.gray[200],muted:i.color.gray[400],hint:i.color.gray[500],border:i.color.gray[700],background:i.color.gray[900],palette:[i.color.blue[400],i.color.emerald[400],i.color.amber[400],i.color.red[400],i.color.violet[400],i.color.teal[400],i.color.pink[400],i.color.indigo[400]]})},r={default:s,dark:o};let u=s;function registerTheme(t,e){r[t]=e}function resolveTheme(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u;return"string"==typeof t?r[t]||s:{base:e.base,semantic:_objectSpread2(_objectSpread2({},e.semantic),t)}}function setTheme(t){return u=resolveTheme(t,u),u}function getTheme(){return u}const a={card:t=>({radius:t.base.radius.lg,style:{fillStyle:t.semantic.background,strokeStyle:t.semantic.border,lineWidth:1,shadow:"md"}}),gradient:t=>({radius:t.base.radius.lg,style:{fillGradient:{type:"linear",from:[0,0],to:[0,200],stops:[[0,t.semantic.primary],[1,t.semantic.background]]},strokeStyle:t.semantic.border,lineWidth:1}}),panel:t=>({radius:t.base.radius.md,style:{fillStyle:t.semantic.background,strokeStyle:t.semantic.border,lineWidth:1,shadow:"sm"}}),button:t=>({radius:t.base.radius.md,style:{fillStyle:t.semantic.primary,strokeStyle:t.semantic.primary,lineWidth:1,shadow:"sm"}}),"button-danger":t=>({radius:t.base.radius.md,style:{fillStyle:t.semantic.danger,strokeStyle:t.semantic.danger,lineWidth:1,shadow:"sm"}}),title:t=>({stroke:!1,style:{fontSize:t.base.fontSize["2xl"],fontWeight:t.base.fontWeight.bold,fillStyle:t.semantic.text}}),subtitle:t=>({stroke:!1,style:{fontSize:t.base.fontSize.lg,fillStyle:t.semantic.muted}}),body:t=>({stroke:!1,style:{fontSize:t.base.fontSize.md,fillStyle:t.semantic.text}}),label:t=>({stroke:!1,style:{fontSize:t.base.fontSize.sm,fillStyle:t.semantic.hint}})};var h={baseTokens:i,DEFAULT_THEME:s,DARK_THEME:o,registerTheme:registerTheme,setTheme:setTheme,getTheme:getTheme,STYLE_PRESETS:a};var l=class AnimationManager{constructor(t){_defineProperty(this,"animationMap",new Map),_defineProperty(this,"paused",!1),_defineProperty(this,"pausedAt",0),_defineProperty(this,"warned",new WeakSet),this.ice=t}start(){return this.ice.evtBus.on(t.ICE_FRAME_EVENT,this.frameEventHandler,this),this}stop(){return this.ice.evtBus.off(t.ICE_FRAME_EVENT,this.frameEventHandler,this),this}frameEventHandler(t){if(this.paused)return;const e=Date.now(),i=[...this.animationMap.values()];for(let t=0;t<i.length;t++){const s=i[t],o=s.state.interactive;s.state.interactive=!1,this.tween(s,e),s.state.interactive=o}}__writeValue(t,e,i){const s=e.indexOf(".");if(-1===s)return void(t[e]=i);const o=e.slice(0,s),r=e.slice(s+1);t[o]&&"object"==typeof t[o]||(t[o]={}),this.__writeValue(t[o],r,i)}tween(t,e){const i={},s=t.props.animations,o=isUndefined(e)?Date.now():e;let r=!1;for(const t in s){const e=s[t];if(e.finished)continue;let u;if(isUndefined(e.startTime)&&(e.startTime=o,this.__resolveMotion(e)),isUndefined(e.easing)&&(e.easing="linear"),Array.isArray(e.keyframes)){const i=this.__normalizeKeyframes(e);if(!i){this.__reject(e,"[ICE] 动画属性「".concat(t,"」的 keyframes 非法:需要 ≥2 帧、offset 为数字、各帧取值同型(都是数字或等长的数字数组);已跳过。"));continue}u=i}else if(!this.__isTweenable(e.from,e.to)){this.__reject(e,"[ICE] 动画属性「".concat(t,"」的取值必须都是数字或等长的数字数组,当前为 ")+"".concat(this.__describe(e.from)," → ").concat(this.__describe(e.to),";已跳过。"));continue}const a=Number(e.duration);if(!Number.isFinite(a)||a<=0){this.__reject(e,"[ICE] 动画属性「".concat(t,"」的 duration 必须是正数,当前为 ").concat(String(e.duration),";已直接落到终点。")),this.__writeValue(i,t,this.__roundIfNeeded(e,this.__sampleValue(u,e,1)));continue}const h=Number(e.delay)||0,l=o-e.startTime-h;if(l<0){r=!0,this.__writeValue(i,t,this.__sampleValue(u,e,0));continue}if(l>=a){let s=this.__sampleValue(u,e,1);this.shouldRepeat(e)?(e.startTime=o,s=this.__sampleValue(u,e,0),r=!0):e.finished=!0,this.__writeValue(i,t,this.__roundIfNeeded(e,s));continue}r=!0;const c=u?l/a:this.__easingFn(e.easing,e)(l/a);this.__writeValue(i,t,this.__roundIfNeeded(e,this.__sampleValue(u,e,c)))}return r||this.remove(t),Object.keys(i).length>0&&t.setState(i),t}__sampleValue(t,e,i){if(!t)return this.__interpolate(e.from,e.to,i);const s=t[0],o=t[t.length-1];if(i<=s.offset)return s.value;if(i>=o.offset)return o.value;for(let s=0;s<t.length-1;s++){const o=t[s],r=t[s+1];if(i<o.offset||i>r.offset)continue;const u=r.offset-o.offset;if(u<=0)return r.value;const a=(i-o.offset)/u,h=this.__easingFn(isUndefined(o.easing)?e.easing:o.easing,e);return this.__interpolate(o.value,r.value,h(a))}return o.value}__interpolate(t,e,i){if("number"==typeof t)return t+(e-t)*i;const s=new Array(t.length);for(let o=0;o<t.length;o++)s[o]=t[o]+(e[o]-t[o])*i;return s}__isTweenable(t,e){const i=this.__valueKind(t);return null!==i&&i===this.__valueKind(e)&&("number"===i||t.length===e.length)}__valueKind(t){if("number"==typeof t)return"number";if(Array.isArray(t)&&t.length>0){for(let e=0;e<t.length;e++)if("number"!=typeof t[e])return null;return"array"}return null}__normalizeKeyframes(t){if(t.__frames)return t.__frames;const e=t.keyframes;if(!Array.isArray(e)||e.length<2)return null;const i=[];for(let t=0;t<e.length;t++){const s=e[t]||{},o=isUndefined(s.offset)?t/(e.length-1):Number(s.offset);if(!Number.isFinite(o))return null;i.push({offset:Math.min(1,Math.max(0,o)),value:s.value,easing:s.easing})}i.sort((t,e)=>t.offset-e.offset);const s=this.__valueKind(i[0].value);if(null===s)return null;const o="array"===s?i[0].value.length:0;for(let t=1;t<i.length;t++){if(this.__valueKind(i[t].value)!==s)return null;if("array"===s&&i[t].value.length!==o)return null}return t.__frames=i,i}__easingFn(t,i){const s="string"==typeof t?e[t]:void 0;return s||(i&&this.__warnOnce(i,"[ICE] 未知的缓动「".concat(String(t),"」,已回退为 linear。可用:").concat(Object.keys(e).join(" / "))),e.linear)}__roundIfNeeded(t,e){return t.round?"number"==typeof e?Math.round(e):e.map(t=>Math.round(t)):e}__describe(t){return Array.isArray(t)?"数组[".concat(t.length,"]"):typeof t}__reject(t,e){t.finished=!0,this.__warnOnce(t,e)}__warnOnce(t,e){t&&"object"==typeof t&&(this.warned.has(t)||this.warned.add(t))}__resolveMotion(t){const e=(this.ice&&this.ice.theme||getTheme()).semantic.motion;"string"==typeof t.duration&&void 0!==e.duration[t.duration]&&(t.duration=e.duration[t.duration]),"string"==typeof t.easing&&void 0!==e.easing[t.easing]&&(t.easing=e.easing[t.easing])}shouldRepeat(t){return!0===t.loop||"number"==typeof t.iterationCount&&t.iterationCount>1&&(t.iterationCount--,!0)}pause(){this.paused||(this.paused=!0,this.pausedAt=Date.now())}resume(){if(!this.paused)return;const t=Date.now()-this.pausedAt,e=[...this.animationMap.values()];for(const i of e){const e=i.props.animations;for(const i in e){const s=e[i];isUndefined(s.startTime)||(s.startTime+=t)}}this.paused=!1}isPaused(){return this.paused}add(t){this.animationMap.set(t.props.id,t)}remove(t){isString(t)?this.animationMap.delete(t):this.animationMap.delete(t.props.id)}};let c=0;function bumpVisibilityEpoch(){c++}function getVisibilityEpoch(){return c}function isEffectivelyVisible(t){return t&&"function"==typeof t.isEffectivelyVisible?t.isEffectivelyVisible():!!(t&&t.state&&t.state.display)}function flattenAllComponents(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return flattenTree(e,t.childNodes||[]),flattenTree(e,t.toolNodes||[]),e}function hitTestComponents(t,e,i,s){const o=flattenAllComponents(t);o.sort((t,e)=>t.state.zIndex-e.state.zIndex);const r=t.renderer,u=r&&"function"==typeof r.getWorldBox;let a=null;for(let t=0;t<o.length;t++){const h=o[t];if(!h.isControlPanel&&(h.state.interactive&&isEffectivelyVisible(h))){if(u){const t=r.getWorldBox(h);if(t&&(e<t[0]-s||e>t[2]+s||i<t[1]-s||i>t[3]+s))continue}if(h.containsPoint(e,i)){if("function"==typeof h.isPointClippedOut&&h.isPointClippedOut(e,i))continue;a=h}}}return a}function flattenTree(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;for(let o=0;o<e.length;o++){const r=e[o];r._level=i,r._pid=s,t.push(r);const u=r.props&&void 0!==r.props.id?r.props.id:r.id;flattenTree(t,r.childNodes||[],i+1,u)}return t}class Path2DRecorder{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;_defineProperty(this,"_commands",[]),_defineProperty(this,"_closed",!1),_defineProperty(this,"native",null),_defineProperty(this,"__current",null),_defineProperty(this,"__subpathStart",null),this.native=t||null,this._isPolyfill=!this.native}get drawable(){return this.native||this}moveTo(t,e){this._commands.push(["moveTo",t,e]),this.__current=[t,e],this.__subpathStart=[t,e],this.native&&this.native.moveTo(t,e)}lineTo(t,e){this._commands.push(["lineTo",t,e]),this.__current=[t,e],this.native&&this.native.lineTo(t,e)}bezierCurveTo(t,e,i,s,o,r){this._commands.push(["bezierCurveTo",t,e,i,s,o,r]),this.__current=[o,r],this.native&&this.native.bezierCurveTo(t,e,i,s,o,r)}quadraticCurveTo(t,e,i,s){this._commands.push(["quadraticCurveTo",t,e,i,s]),this.__current=[i,s],this.native&&this.native.quadraticCurveTo(t,e,i,s)}arcTo(t,e,i,s,o){const r=Math.abs(Number(o)||0),u=this.__current;if(!u||0===r)return void this.lineTo(t,e);const a=u[0]-t,h=u[1]-e,l=i-t,c=s-e,d=Math.sqrt(a*a+h*h),D=Math.sqrt(l*l+c*c);if(0===d||0===D)return void this.lineTo(t,e);const p=a/d,f=h/d,g=l/D,E=c/D,_=p*E-f*g,C=Math.max(-1,Math.min(1,p*g+f*E));if(Math.abs(_)<1e-9||Math.abs(C)>=1-1e-9)return void this.lineTo(t,e);const F=Math.acos(C),m=r/Math.tan(F/2),y=t+p*m,x=e+f*m,A=t+g*m,B=e+E*m,v=p+g,b=f+E,S=Math.sqrt(v*v+b*b)||1,P=r/Math.sin(F/2),M=t+v/S*P,w=e+b/S*P,I=Math.atan2(x-w,y-M),T=Math.atan2(B-w,A-M);this.lineTo(y,x),this.arc(M,w,r,I,T,_>0)}rect(t,e,i,s){this._commands.push(["rect",t,e,i,s]),this.__current=[t,e],this.__subpathStart=[t,e],this.native&&this.native.rect(t,e,i,s)}arc(t,e,i,s,o){let r=arguments.length>5&&void 0!==arguments[5]&&arguments[5];this._commands.push(["arc",t,e,i,s,o,r]),this.__current=[t+i*Math.cos(o),e+i*Math.sin(o)],this.native&&this.native.arc(t,e,i,s,o,r)}ellipse(t,e,i,s,o,r,u,a){this._commands.push(["ellipse",t,e,i,s,o,r,u,a]),this.__current=[t+i*Math.cos(u)*Math.cos(o)-s*Math.sin(u)*Math.sin(o),e+i*Math.cos(u)*Math.sin(o)+s*Math.sin(u)*Math.cos(o)],this.native&&this.native.ellipse(t,e,i,s,o,r,u,a)}closePath(){this._closed=!0;const t=this._commands[this._commands.length-1];t&&"closePath"===t[0]||this._commands.push(["closePath"]),this.__current=this.__subpathStart?[this.__subpathStart[0],this.__subpathStart[1]]:null,this.native&&this.native.closePath()}get currentPoint(){return this.__current}}const d={TYPE_ID_INVALID:"ICE_TYPE_ID_INVALID",TYPE_CTOR_INVALID:"ICE_TYPE_CTOR_INVALID",TYPE_ID_CONFLICT:"ICE_TYPE_ID_CONFLICT",TYPE_CTOR_CONFLICT:"ICE_TYPE_CTOR_CONFLICT",INIT_TARGET_REQUIRED:"ICE_INIT_TARGET_REQUIRED",INIT_ALREADY_BOUND:"ICE_INIT_ALREADY_BOUND",PLUGIN_NAME_REQUIRED:"ICE_PLUGIN_NAME_REQUIRED",PLUGIN_COMPONENT_REGISTER_FAILED:"ICE_PLUGIN_COMPONENT_REGISTER_FAILED",DESERIALIZE_VERSION_UNSUPPORTED:"ICE_DESERIALIZE_VERSION_UNSUPPORTED",IMAGE_CONSTRUCTOR_MISSING:"ICE_IMAGE_CONSTRUCTOR_MISSING",OFFSCREEN_CONTEXT_UNSUPPORTED:"ICE_OFFSCREEN_CONTEXT_UNSUPPORTED",OFFSCREEN_CANVAS_UNSUPPORTED:"ICE_OFFSCREEN_CANVAS_UNSUPPORTED"};function iceError(t,e,i){const s=new Error(e);return s.name="ICEError",s.code=t,i&&(s.details=i),s}function getICEErrorCode(t){if(!t||"object"!=typeof t)return;const e=t.code;return"string"==typeof e&&0===e.indexOf("ICE_")?e:void 0}let D=null;(()=>{const t="undefined"!=typeof window?window:"undefined"!=typeof global?global:{};D=t||{},D.requestFrame=D.requestAnimationFrame||D.webkitRequestAnimationFrame||D.mozRequestAnimationFrame||D.oRequestAnimationFrame||D.msRequestAnimationFrame,"function"!=typeof D.requestFrame&&(D.requestFrame=function(t){return setTimeout(function(){t(Date.now())},16)}),D.createPath2D=()=>"function"==typeof D.Path2D?new Path2DRecorder(new D.Path2D):new Path2DRecorder,D.loadFont=(t,e)=>{if("function"==typeof D.FontFace&&D.document&&D.document.fonts){const i=new D.FontFace(t,e);return D.document.fonts.add(i),i.load()}return D.wx&&"function"==typeof D.wx.loadFont?D.wx.loadFont(e):Promise.resolve()},D.createImage=()=>{if("function"==typeof D.Image)return new D.Image;if(D.wx&&"function"==typeof D.wx.createImage)return D.wx.createImage();throw iceError(d.IMAGE_CONSTRUCTOR_MISSING,"当前运行时没有可用的 Image 构造器,无法加载图片。")},"number"==typeof D.devicePixelRatio&&D.devicePixelRatio>0||(D.devicePixelRatio=(()=>{if(D.wx&&"function"==typeof D.wx.getSystemInfoSync)try{return D.wx.getSystemInfoSync().pixelRatio||1}catch(t){return 1}return 1})()),D.createOffscreenCanvas=(t,e)=>{if(D.wx&&"function"==typeof D.wx.createOffscreenCanvas){const i=D.wx.createOffscreenCanvas({type:"2d",width:t,height:e}),s=i.getContext("2d");if(!s)throw iceError(d.OFFSCREEN_CONTEXT_UNSUPPORTED,"当前运行时无法创建 2d 离屏上下文。");return{canvas:i,ctx:s}}if(D.document&&"function"==typeof D.document.createElement){const i=D.document.createElement("canvas");i.width=t,i.height=e;const s=i.getContext("2d");if(!s)throw iceError(d.OFFSCREEN_CONTEXT_UNSUPPORTED,"当前运行时无法创建 2d 离屏上下文。");return{canvas:i,ctx:s}}throw iceError(d.OFFSCREEN_CANVAS_UNSUPPORTED,"当前运行时没有可用的离屏 canvas。")}})();var p=D,f="undefined"!=typeof Float32Array?Float32Array:Array,g=Math.PI/180;function toRadian(t){return t*g}function invert(t,e){var i=e[0],s=e[1],o=e[2],r=e[3],u=e[4],a=e[5],h=i*r-s*o;return h?(h=1/h,t[0]=r*h,t[1]=-s*h,t[2]=-o*h,t[3]=i*h,t[4]=(o*a-r*u)*h,t[5]=(s*u-i*a)*h,t):null}function multiply(t,e,i){var s=e[0],o=e[1],r=e[2],u=e[3],a=e[4],h=e[5],l=i[0],c=i[1],d=i[2],D=i[3],p=i[4],f=i[5];return t[0]=s*l+r*c,t[1]=o*l+u*c,t[2]=s*d+r*D,t[3]=o*d+u*D,t[4]=s*p+r*f+a,t[5]=o*p+u*f+h,t}function cross(t,e,i){var s=e[0]*i[1]-e[1]*i[0];return t[0]=t[1]=0,t[2]=s,t}function transformMat2d(t,e,i){var s=e[0],o=e[1];return t[0]=i[0]*s+i[2]*o+i[4],t[1]=i[1]*s+i[3]*o+i[5],t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),function create(){var t=new f(2);return f!=Float32Array&&(t[0]=0,t[1]=0),t}();var E=class ICEEvent{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_defineProperty(this,"AT_TARGET",2),_defineProperty(this,"BUBBLING_PHASE",3),_defineProperty(this,"CAPTURING_PHASE",1),_defineProperty(this,"NONE",0);for(const e in t)this[e]=t[e];for(const t in e)this[t]=e[t]}composedPath(){throw new Error("Method not implemented.")}initEvent(t,e,i){throw new Error("Method not implemented.")}preventDefault(){throw new Error("Method not implemented.")}stopImmediatePropagation(){throw new Error("Method not implemented.")}stopPropagation(){throw new Error("Method not implemented.")}};class ICEEventTarget{constructor(){_defineProperty(this,"listeners",{}),_defineProperty(this,"suspendedEventNames",[])}on(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p;this.listeners[t]||(this.listeners[t]=[]),this.off(t,e,i),this.listeners[t].push({callback:e,scope:i})}off(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p,s=this.listeners[t];if(s){s=[...s];for(let o=0;o<s.length;o++){const r=s[o],u=r.callback;if((u===e||u&&u.__onceOriginal===e)&&r.scope===i)return void this.listeners[t].splice(o,1)}}}trigger(t){let e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(function isEmpty(t){return null==t||(Array.isArray(t)||"string"==typeof t?0===t.length:"object"!=typeof t||0===Object.keys(t).length)}(this.listeners[t]))return!1;if(this.suspendedEventNames.includes(t))return!1;i?(e=new E(i),e.originalEvent=i.originalEvent?i.originalEvent:i,e.param=_objectSpread2({},s)):e=new E({type:t,timeStamp:Date.now(),param:_objectSpread2({},s)});const o=[...this.listeners[t]];for(let i=0;i<o.length;i++){const s=o[i];-1!==this.listeners[t].indexOf(s)&&s.callback.call(s.scope,e)}return!0}once(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p;const s=this;function callback(o){s.off(t,callback,i),e.call(i,o)}callback.__onceOriginal=e,s.on(t,callback,i)}suspend(t){t&&!this.suspendedEventNames.includes(t)&&this.suspendedEventNames.push(t)}resume(t){const e=this.suspendedEventNames.indexOf(t);-1!==e&&this.suspendedEventNames.splice(e,1)}purgeEvents(){this.listeners={},this.suspendedEventNames=[]}hasListener(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:p;if(!this.listeners[t])return!1;const s=this.listeners[t];if(!s)return!1;for(let t=0;t<s.length;t++){const o=s[t];if(o.callback===e&&o.scope===i)return!0}return!1}}ICEEventTarget.prototype.addEventListener=ICEEventTarget.prototype.on,ICEEventTarget.prototype.removeEventListener=ICEEventTarget.prototype.off,ICEEventTarget.prototype.dispatchEvent=ICEEventTarget.prototype.trigger;var _=ICEEventTarget;class GeoUtil{constructor(){throw new Error("GeoUtil is a static util class.")}static pointInPolygon(t,e,i){if(!i||i.length<3)return!1;let s=!1;for(let o=0,r=i.length-1;o<i.length;r=o++){const u=i[o][0],a=i[o][1],h=i[r][0],l=i[r][1];a>e!=l>e&&t<(h-u)*(e-a)/(l-a)+u&&(s=!s)}return s}static distanceToSegment(t,e,i,s,o,r){const u=o-i,a=r-s,h=u*u+a*a;let l=0===h?0:((t-i)*u+(e-s)*a)/h;return l=l<0?0:l>1?1:l,Math.hypot(t-(i+l*u),e-(s+l*a))}static distanceToPolyline(t,e,i){if(!t||0===t.length)return 1/0;if(1===t.length)return Math.hypot(e-t[0][0],i-t[0][1]);let s=1/0;for(let o=0;o<t.length-1;o++){const r=GeoUtil.distanceToSegment(e,i,t[o][0],t[o][1],t[o+1][0],t[o+1][1]);r<s&&(s=r)}return s}static samplePolyline(t,e){const i=[];if(!t||t.length<2||e<1)return t?t.map(t=>[t[0],t[1]]):i;const s=[];let o=0;for(let e=0;e<t.length-1;e++){const i=Math.hypot(t[e+1][0]-t[e][0],t[e+1][1]-t[e][1]);s.push(i),o+=i}if(0===o)return[t[0].slice(),t[t.length-1].slice()];for(let r=0;r<=e;r++){const u=o*r/e;let a=0;for(let e=0;e<s.length;e++){if(a+s[e]>=u||e===s.length-1){const o=0===s[e]?0:(u-a)/s[e];i.push([t[e][0]+(t[e+1][0]-t[e][0])*o,t[e][1]+(t[e+1][1]-t[e][1])*o]);break}a+=s[e]}}return i}static segmentIntersect(t,e,i,s){const o=e[0]-t[0],r=e[1]-t[1],u=s[0]-i[0],a=s[1]-i[1],h=o*a-r*u;if(0===h)return null;const l=((i[0]-t[0])*a-(i[1]-t[1])*u)/h,c=((i[0]-t[0])*r-(i[1]-t[1])*o)/h;return l<0||l>1||c<0||c>1?null:[t[0]+l*o,t[1]+l*r]}static calcRotateAngle(t,e,i,s){const o=t-i,r=e-s,u=Math.hypot(o,r),a=o/u;let h=(r/u<0?-1:1)*Math.acos(a)*180/Math.PI+360;return h%=360,h}static calcRotateAngleFromMatrix(t){const e=t[0],i=t[1];return Math.atan2(i,e)*(180/Math.PI)}static calcScaleFromMatrix(t){const e=t[0],i=t[1],s=t[2],o=t[3];return[Math.hypot(e,i),Math.hypot(s,o)]}}class ICEBoundingBox{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0,0,0,0,0,0,0];_defineProperty(this,"tl",[0,0]),_defineProperty(this,"tr",[0,0]),_defineProperty(this,"bl",[0,0]),_defineProperty(this,"br",[0,0]),_defineProperty(this,"tc",[0,0]),_defineProperty(this,"rc",[0,0]),_defineProperty(this,"bc",[0,0]),_defineProperty(this,"lc",[0,0]),_defineProperty(this,"center",[0,0]),this.tl=[t[0],t[1]],this.tr=[t[2],t[3]],this.bl=[t[4],t[5]],this.br=[t[6],t[7]],this.tc=[(this.tr[0]+this.tl[0])/2,(this.tr[1]+this.tl[1])/2],this.bc=[(this.br[0]+this.bl[0])/2,(this.br[1]+this.bl[1])/2],this.lc=[(this.bl[0]+this.tl[0])/2,(this.bl[1]+this.tl[1])/2],this.rc=[(this.br[0]+this.tr[0])/2,(this.br[1]+this.tr[1])/2],this.center=[t[8],t[9]]}static fromDimension(t,e,i,s){return new ICEBoundingBox([...[t,e],...[t+i,e],...[t,e+s],...[t+i,e+s],...[t+i/2,e+s/2]])}containsPoint(t){const{minX:e,minY:i,maxX:s,maxY:o}=this.getMinAndMaxPoint();if(t[0]<e||t[0]>s||t[1]<i||t[1]>o)return!1;let r,u=0;const a=this.getBoundingLines();for(let e=0;e<a.length;e++){const i=a[e];if(!(t[1]>i.o[1]&&t[1]>i.d[1])&&!(t[1]<i.o[1]&&t[1]<i.d[1])){if(i.o[0]===i.d[0]&&i.o[0]>=t[0])r=i.o[0];else{const e=(i.d[1]-i.o[1])/(i.d[0]-i.o[0]);r=i.o[0]+(t[1]-i.o[1])/e}r>t[0]&&u++}}return 0!==u&&u%2==1}getBoundingLines(){return[{o:[...this.tl],d:[...this.tr]},{o:[...this.tr],d:[...this.br]},{o:[...this.br],d:[...this.bl]},{o:[...this.bl],d:[...this.tl]}]}getMinAndMaxPoint(){let t=this.tl[0],e=this.tl[1],i=this.tl[0],s=this.tl[1];const o=[this.tr,this.bl,this.br];for(let r=0;r<o.length;r++){const u=o[r];u[0]<t&&(t=u[0]),u[0]>i&&(i=u[0]),u[1]<e&&(e=u[1]),u[1]>s&&(s=u[1])}return{minX:t,minY:e,maxX:i,maxY:s}}containsBox(t){const e=this.getMinAndMaxPoint(),i=t.getMinAndMaxPoint();return i.minX>=e.minX&&i.maxX<=e.maxX&&i.minY>=e.minY&&i.maxY<=e.maxY}isIntersect(t){const e=this.tl[0],i=this.br[0],s=this.tl[1],o=this.br[1],r=t.tl[0],u=t.br[0],a=t.tl[1],h=t.br[1];return!(e>u||s>h||i<r||o<a)}transform(t){const e=transformMat2d([],this.tl,t),i=transformMat2d([],this.tr,t),s=transformMat2d([],this.bl,t),o=transformMat2d([],this.br,t),r=transformMat2d([],this.center,t);return new ICEBoundingBox([...e,...i,...s,...o,...r])}union(t){const e=this.getMinAndMaxPoint(),i=t.getMinAndMaxPoint(),s=Math.min(e.minX,i.minX),o=Math.min(e.minY,i.minY),r=Math.max(e.maxX,i.maxX),u=Math.max(e.maxY,i.maxY);return ICEBoundingBox.fromDimension(s,o,r-s,u-o)}get width(){const t=this.br[0]-this.bl[0],e=this.br[1]-this.bl[1];return Math.hypot(t,e)}get height(){const t=this.br[0]-this.tr[0],e=this.br[1]-this.tr[1];return Math.hypot(t,e)}get left(){return this.tl[0]}set left(t){throw new Error("Can not set left to ICEBoundingBox directly.")}get top(){return this.tl[1]}set top(t){throw new Error("Can not set top to ICEBoundingBox directly.")}get centerX(){return this.center[0]}get centerY(){return this.center[1]}get centerPoint(){return this.center}}var C=ICEBoundingBox;const F={sm:{shadowColor:"rgba(0,0,0,0.12)",shadowBlur:4,shadowOffsetX:0,shadowOffsetY:1},md:{shadowColor:"rgba(0,0,0,0.18)",shadowBlur:10,shadowOffsetX:0,shadowOffsetY:3},lg:{shadowColor:"rgba(0,0,0,0.25)",shadowBlur:20,shadowOffsetX:0,shadowOffsetY:6}},m=[["shadowColor","rgba(0,0,0,0)"],["shadowBlur",0],["shadowOffsetX",0],["shadowOffsetY",0],["globalAlpha",1],["globalCompositeOperation","source-over"],["lineCap","butt"],["lineJoin","miter"],["miterLimit",10],["textAlign","start"],["textBaseline","alphabetic"],["direction","inherit"],["letterSpacing","0px"],["wordSpacing","0px"],["fontKerning","auto"],["fontStretch","normal"],["fontVariantCaps","normal"],["textRendering","auto"],["filter","none"],["imageSmoothingEnabled",!0],["imageSmoothingQuality","low"]],y=1<<m.length,x=Object.freeze([1,0,0,1,0,0]),A={left:0,top:0,width:0,height:0,style:Object.freeze({fillStyle:"red",strokeStyle:"blue",lineWidth:1}),lineDash:Object.freeze([]),lineDashOffset:0,lineDashFlow:!1,lineDashFlowSpeed:60,lineBorder:!1,lineBorderWidth:1.5,lineBorderColor:"#999999",fill:!0,stroke:!0,animations:Object.freeze({}),transform:Object.freeze({translate:Object.freeze([0,0]),scale:Object.freeze([1,1]),skew:Object.freeze([0,0]),rotate:0}),linearMatrix:Object.freeze([]),composedMatrix:Object.freeze([]),origin:"localCenter",originX:0,originY:0,clipChildren:!1,opacity:1,localOrigin:Object.freeze([0,0]),absoluteOrigin:Object.freeze([0,0]),display:!0,draggable:!0,transformable:!0,interactive:!0,linkable:!0,showMinBoundingBox:!1,showMaxBoundingBox:!1};function normalizeGradientStops(t){const e=[];if(!Array.isArray(t))return e;for(let i=0;i<t.length;i++){const s=t[i];let o=NaN,r="";Array.isArray(s)?(o=Number(s[0]),r=String(s[1])):s&&"object"==typeof s&&(o=Number(s.offset),r=String(s.color)),isFinite(o)&&r&&e.push([o<0?0:o>1?1:o,r])}return e.sort((t,e)=>t[0]-e[0]),e}function triggerSubtreeMove(e,i){const s=e&&e.childNodes||[];for(let e=0;e<s.length;e++){const o=s[e];o.trigger(t.AFTER_MOVE,i),triggerSubtreeMove(o,i)}}class ICEComponent extends _{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),_defineProperty(this,"__dirty",!0),_defineProperty(this,"__everRendered",!1),_defineProperty(this,"__localBoxScratch",[0,0,0,0]),_defineProperty(this,"__activeCtm",null),_defineProperty(this,"__activeWorldMatrix",null),_defineProperty(this,"__visEpoch",-1),_defineProperty(this,"__visValue",!0),_defineProperty(this,"__opacityApplied",!1),_defineProperty(this,"__gradCache",{}),_defineProperty(this,"__paramsDirty",!0),_defineProperty(this,"__absScratchA",null),_defineProperty(this,"__absScratchB",null),_defineProperty(this,"__transScratch",null),_defineProperty(this,"__originScratch",null),_defineProperty(this,"__composeScratch",null),_defineProperty(this,"__viewportScratch",null),this.__userProps=t,t&&t.preset&&a[t.preset]&&(this.__presetName=t.preset,t=merge({},a[t.preset](getTheme()),t)),this.props=Object.create(A),this.props.id=t&&void 0!==t.id?t.id:"ICE_"+function uuid(){if(p.crypto&&"function"==typeof p.crypto.randomUUID)return p.crypto.randomUUID();if(p.crypto&&"function"==typeof p.crypto.getRandomValues){const t=new Uint8Array(16);p.crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128;const e=[];for(let i=0;i<t.length;i++)e.push((t[i]+256).toString(16).slice(1));return e.slice(0,4).join("")+"-"+e.slice(4,6).join("")+"-"+e.slice(6,8).join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10,16).join("")}let t=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:3&i|8).toString(16)})}(),this.props.zIndex=ICEComponent.instanceCounter++,merge(this.props,t),this.__initState(),this.root=p,this.initEvents()}__initState(){this.state=Object.create(A),this.state.id=this.props.id,this.state.zIndex=this.props.zIndex;for(const t in this.props)Object.prototype.hasOwnProperty.call(this.props,t)&&(this.state[t]=cloneDeep(this.props[t]));this.state.linearMatrix=[],this.state.composedMatrix=[],this.state.localOrigin=[0,0],this.state.absoluteOrigin=[0,0]}__reapplyPreset(t){if(!this.__presetName||!a[this.__presetName])return;const e=a[this.__presetName](t||getTheme()),i=this.__userProps||{},s={};for(const t in e)"style"===t?s.style=merge({},e.style,i.style):void 0!==i[t]?s[t]=i[t]:s[t]=e[t];this.setState(s)}initEvents(){this.on("mousedown",this.mouseDownEvtHandler,this),this.on("keydown",this.keyboardEvtHandler,this),this.on("keyup",this.keyboardEvtHandler,this)}mouseDownEvtHandler(t){this.state.interactive&&this.state.draggable&&(this.on("mousemove",this.mouseMoveEvtHandler,this),this.on("mouseup",this.mouseUpEvtHandler,this))}mouseMoveEvtHandler(t){const e=this.ice&&this.ice.viewport?this.ice.viewport.scale:1,i=t.movementX/e,s=t.movementY/e;return this.moveGlobalPosition(i,s,t),!0}mouseUpEvtHandler(t){this.off("mousemove",this.mouseMoveEvtHandler,this),this.off("mouseup",this.mouseUpEvtHandler,this)}keyboardEvtHandler(t){switch(t.key){case"ArrowUp":this.moveGlobalPosition(0,-2,t);break;case"ArrowDown":this.moveGlobalPosition(0,2,t);break;case"ArrowLeft":this.moveGlobalPosition(-2,0,t);break;case"ArrowRight":this.moveGlobalPosition(2,0,t);break;case"Delete":this.parentNode&&this.parentNode.removeChild?this.parentNode.removeChild(this):this.ice.removeChild(this)}}render(){this.__renderCore(null,!0)}renderTo(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!t)return;const i=this.ctx;this.ctx=t;try{this.__renderCore(e,!1)}finally{this.ctx=i}}isEffectivelyVisible(){if(this.__visEpoch===getVisibilityEpoch())return this.__visValue;const t=this.__computeEffectivelyVisible();return this.__visEpoch=getVisibilityEpoch(),this.__visValue=t,t}__computeEffectivelyVisible(){if(!this.state.display)return!1;let t=this.parentNode;for(;t&&t.state;){if(!t.state.display)return!1;t=t.parentNode}return!0}__renderCore(e,i){if(this.trigger(t.BEFORE_RENDER),!this.isEffectivelyVisible())return;this.refreshParams(),this.applyStyleToCtx();const s=this.getEffectiveOpacity();1!==s&&(this.__applyStyleProp("globalAlpha",(Number(this.ctx.globalAlpha)||1)*s),this.__opacityApplied=!0),this.applyTransformToCtx(e,i);const o=this.__applyAncestorClips();this.doRender(),o&&this.ctx.restore(),this.__resetLeakyCtxState(),this.trigger(t.AFTER_RENDER),this.__everRendered=!0,this.dirty=!1}applyStyleToCtx(){const t=this.props.style,e=this.state.style;let i=null,s=null;if(t)for(const e in t)"fillGradient"!==e?"strokeGradient"!==e?this.__applyStyleProp(e,t[e]):s=t[e]:i=t[e];if(e)for(const t in e)"fillGradient"!==t?"strokeGradient"!==t?this.__applyStyleProp(t,e[t]):s=e[t]:i=e[t];i&&this.__applyStyleProp("fillGradient",i),s&&this.__applyStyleProp("strokeGradient",s)}__applyStyleProp(t,e){if("fillGradient"===t||"strokeGradient"===t){const i="fillGradient"===t?"fillStyle":"strokeStyle",s=this.__resolveGradient("fillGradient"===t?"fill":"stroke",e);if(s)this.ctx[i]=s;else if(e){const t=normalizeGradientStops(e.stops);t.length&&(this.ctx[i]=t[Math.floor(t.length/2)][1])}return}if("shadow"===t&&"string"==typeof e&&F[e]){const t=F[e];return this.ctx.shadowColor=t.shadowColor,this.ctx.shadowBlur=t.shadowBlur,this.ctx.shadowOffsetX=t.shadowOffsetX,void(this.ctx.shadowOffsetY=t.shadowOffsetY)}this.ctx[t]=e}__resolveGradient(t,e){if(!e||"object"!=typeof e)return null;const i=this.__gradCache[t];if(i&&i.src===e)return i.grad;const s=this.__buildGradient(e);return this.__gradCache[t]={src:e,grad:s},s}__buildGradient(t){const e=this.ctx;if(!e)return null;const i=normalizeGradientStops(t.stops);if(i.length<1)return null;const s=Number(this.state.width)||0,o=Number(this.state.height)||0,r=t.type||"linear";let u=null;if("radial"===r&&"function"==typeof e.createRadialGradient){const i=Array.isArray(t.center)?t.center:[s/2,o/2],r=Number(t.radius)>0?Number(t.radius):Math.max(s,o)/2,a=Number(t.innerRadius)>0?Number(t.innerRadius):0;u=e.createRadialGradient(i[0],i[1],a,i[0],i[1],r)}else if("conic"===r&&"function"==typeof e.createConicGradient){const i=Array.isArray(t.center)?t.center:[s/2,o/2];u=e.createConicGradient(Number(t.startAngle)||0,i[0],i[1])}else{if("conic"===r)return null;if("function"==typeof e.createLinearGradient){const i=Array.isArray(t.from)?t.from:[0,0],o=Array.isArray(t.to)?t.to:[s,0];u=e.createLinearGradient(i[0],i[1],o[0],o[1])}}if(!u&&"function"!=typeof e.createLinearGradient)return null;if(!u)return null;for(let t=0;t<i.length;t++)try{u.addColorStop(i[t][0],i[t][1])}catch(t){}return u}calcComponentParams(){return{width:this.state.width,height:this.state.height}}__localBox(){const t=this.__localBoxScratch;return t[0]=0,t[1]=0,t[2]=this.state.width||0,t[3]=this.state.height||0,t}measure(){this.refreshParams()}refreshParams(){this.__paramsDirty&&(this.calcComponentParams(),this.__paramsDirty=!1,this.__gradCache.fill=void 0,this.__gradCache.stroke=void 0)}calcLocalOrigin(){let t=this.state.localOrigin;(!t||t.length<2)&&(t=this.state.localOrigin=[0,0]),t[0]=0,t[1]=0;const e=this.state.origin;return e&&"localCenter"!==e?"top-left"===e?(t[0]=0,t[1]=0):"custom"===e&&(t[0]=Number(this.state.originX)||0,t[1]=Number(this.state.originY)||0):(t[0]=this.state.width/2,t[1]=this.state.height/2),this.state.localOrigin=t,t}calcAbsoluteOrigin(){const t=this.state.transform,e=t.translate[0]+this.state.left,i=t.translate[1]+this.state.top,s=this.calcLocalOrigin();let o=this.__originScratch;if(o||(o=this.__originScratch=[0,0]),o[0]=s[0]+e,o[1]=s[1]+i,this.parentNode){transformMat2d(o,o,[1,0,0,1,-this.parentNode.state.localOrigin[0],-this.parentNode.state.localOrigin[1]]);transformMat2d(o,o,this.parentNode.state.composedMatrix)}return this.state.absoluteOrigin=o,o}calcLinearMatrix(){(!this.state.linearMatrix||this.state.linearMatrix.length<6)&&(this.state.linearMatrix=function create$1(){var t=new f(6);return f!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t}());const t=this.state.linearMatrix;!function identity(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}(t);const e=this.state.transform,i=e.skew[0],s=e.skew[1];!function skew(t,e,i,s){const o=Math.tan(i),r=Math.tan(s);return t[0]=e[0],t[1]=e[1]+o,t[2]=e[2]+r,t[3]=e[3],t[4]=e[4],t[5]=e[5],t}(t,t,toRadian(i),toRadian(s));!function rotate(t,e,i){var s=e[0],o=e[1],r=e[2],u=e[3],a=e[4],h=e[5],l=Math.sin(i),c=Math.cos(i);return t[0]=s*c+r*l,t[1]=o*c+u*l,t[2]=s*-l+r*c,t[3]=o*-l+u*c,t[4]=a,t[5]=h,t}(t,t,toRadian(e.rotate));return function scale(t,e,i){var s=e[0],o=e[1],r=e[2],u=e[3],a=e[4],h=e[5],l=i[0],c=i[1];return t[0]=s*l,t[1]=o*l,t[2]=r*c,t[3]=u*c,t[4]=a,t[5]=h,t}(t,t,[e.scale[0],e.scale[1]]),this.state.linearMatrix=t,t}calcAbsoluteLinearMatrix(){let t=this,e=t.calcLinearMatrix();this.__absScratchA||(this.__absScratchA=[0,0,0,0,0,0]),this.__absScratchB||(this.__absScratchB=[0,0,0,0,0,0]);let i=this.__absScratchA;for(;t.parentNode;){const s=t.parentNode,o=s.state&&s.state.linearMatrix&&s.state.linearMatrix.length>=6&&!s.dirty?s.state.linearMatrix:s.calcLinearMatrix();i=i===this.__absScratchA?this.__absScratchB:this.__absScratchA,multiply(i,o,e),e=i,t=s}return this.state.absoluteLinearMatrix=e,e}composeMatrix(){if(this.parentNode&&"function"==typeof this.parentNode.composeMatrix){const t=this.parentNode,e=t.state?t.state.composedMatrix:null;(t.dirty||!e||e.length<6)&&t.composeMatrix()}const t=this.calcAbsoluteOrigin();this.__transScratch||(this.__transScratch=[1,0,0,1,0,0]),this.__transScratch[4]=t[0],this.__transScratch[5]=t[1];const e=this.__transScratch,i=this.calcAbsoluteLinearMatrix();(!this.state.composedMatrix||this.state.composedMatrix.length<6)&&(this.state.composedMatrix=[1,0,0,1,0,0]);const s=multiply(this.state.composedMatrix,e,i);return this.state.composedMatrix=s,s}applyTransformToCtx(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.dirty?this.composeMatrix():this.state.composedMatrix,s=e&&this.ice?this.ice.getRenderViewport():null,o=s&&(1!==s.scale||0!==s.tx||0!==s.ty);let r=null;if(o){this.__viewportScratch||(this.__viewportScratch=[1,0,0,1,0,0]);const t=this.__viewportScratch;t[0]=s.scale,t[1]=0,t[2]=0,t[3]=s.scale,t[4]=s.tx,t[5]=s.ty,r=t}else t&&(r=t);if(this.__activeWorldMatrix=r,t||o){this.__composeScratch||(this.__composeScratch=[1,0,0,1,0,0]);const e=this.__composeScratch;multiply(e,r||t,i),this.__activeCtm=e,this.ctx.setTransform(e[0],e[1],e[2],e[3],e[4],e[5])}else this.__activeCtm=i,this.ctx.setTransform(...i)}applyActiveTransform(){const t=this.__activeCtm;t?this.ctx.setTransform(t[0],t[1],t[2],t[3],t[4],t[5]):this.applyTransformToCtx(null,!0)}hasClippingAncestor(){let t=this.parentNode;for(;t&&t.state;){if(t.state.clipChildren)return!0;t=t.parentNode}return!1}getEffectiveOpacity(){const t=this.state.opacity;let e=void 0===t?1:Number(t);e>=0||(e=1);let i=this.parentNode;for(;i&&i.state;){const t=void 0===i.state.opacity?1:Number(i.state.opacity);t>=0&&1!==t&&(e*=t),i=i.parentNode}return e}isPointClippedOut(t,e){let i=this.parentNode;for(;i&&i.state;){if(i.state.clipChildren){const s=i.__paintWorldBox();if(t<s[0]||t>s[2]||e<s[1]||e>s[3])return!0}i=i.parentNode}return!1}__applyAncestorClips(){const t=this.parentNode;if(!t||!t.state)return!1;const e=this.ctx;if(!e||"function"!=typeof e.clip||"function"!=typeof e.rect)return!1;let i=null,s=t;for(;s&&s.state;)s.state.clipChildren&&(i||(i=[])).push(s),s=s.parentNode;if(!i)return!1;const o=this.__activeWorldMatrix||x;e.save(),e.setTransform(1,0,0,1,0,0);for(let t=i.length-1;t>=0;t--){const s=i[t].__paintWorldBox(),r=o[0]*s[0]+o[2]*s[1]+o[4],u=o[1]*s[0]+o[3]*s[1]+o[5],a=o[0]*s[2]+o[2]*s[1]+o[4],h=o[1]*s[2]+o[3]*s[1]+o[5],l=o[0]*s[0]+o[2]*s[3]+o[4],c=o[1]*s[0]+o[3]*s[3]+o[5],d=o[0]*s[2]+o[2]*s[3]+o[4],D=o[1]*s[2]+o[3]*s[3]+o[5],p=Math.min(r,a,l,d),f=Math.min(u,h,c,D),g=Math.max(r,a,l,d),E=Math.max(u,h,c,D);e.beginPath(),e.rect(p,f,g-p,E-f),e.clip()}return this.applyActiveTransform(),!0}applyWorldTransform(){const t=this.__activeWorldMatrix;t?(this.ctx.setTransform(t[0],t[1],t[2],t[3],t[4],t[5]),this.ctx.lineWidth=1/(Math.abs(t[0])||Math.abs(t[3])||1)):(this.ctx.setTransform(1,0,0,1,0,0),this.ctx.lineWidth=1)}doRender(){if(this.applyWorldTransform(),this.state.showMinBoundingBox||this.state.showMaxBoundingBox){const t=this.state.showMinBoundingBox?this.getMinBoundingBox():null,e=this.state.showMaxBoundingBox?this.getMaxBoundingBox():null,i=t&&e&&this.__areBoundingBoxesNearlyEqual(t,e);t&&!i&&(this.ctx.strokeStyle="#ff0000",this.ctx.fillStyle="rgba(0,0,0,0)",this.ctx.beginPath(),this.ctx.moveTo(t.tl[0],t.tl[1]),this.ctx.lineTo(t.tr[0],t.tr[1]),this.ctx.lineTo(t.br[0],t.br[1]),this.ctx.lineTo(t.bl[0],t.bl[1]),this.ctx.closePath(),this.ctx.stroke(),this.ctx.fill()),e&&(this.ctx.strokeStyle="#0000ff",this.ctx.fillStyle="rgba(0,0,0,0)",this.ctx.beginPath(),this.ctx.moveTo(e.tl[0],e.tl[1]),this.ctx.lineTo(e.tr[0],e.tr[1]),this.ctx.lineTo(e.br[0],e.br[1]),this.ctx.lineTo(e.bl[0],e.bl[1]),this.ctx.closePath(),this.ctx.stroke(),this.ctx.fill())}}__areBoundingBoxesNearlyEqual(t,e){const i=[[t.tl,e.tl],[t.tr,e.tr],[t.bl,e.bl],[t.br,e.br]];for(const[t,e]of i)if(Math.abs(t[0]-e[0])>1||Math.abs(t[1]-e[1])>1)return!1;return!0}hasDerivedChildren(){return!1}getSerializableChildren(){return null}getMinBoundingBox(){const t=arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.composeMatrix():this.state.composedMatrix,e=this.state.localOrigin[0],i=this.state.localOrigin[1],s=this.__localBox(),o=s[0]-e,r=s[1]-i,u=s[2]-e,a=s[3]-i;let h=new C([o,r,u,r,o,a,u,a,0,0]);return h=h.transform(t),h}getMaxBoundingBox(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.getMinBoundingBox(t);const{minX:i,minY:s,maxX:o,maxY:r}=e.getMinAndMaxPoint(),u=e.centerPoint;return e=new C([i,s,o,s,i,r,o,r,u[0],u[1]]),e}setState(t){const e=this.__beforeStateMerge(t);merge(this.state,t),this.paramsDirty=!0,this.dirty=!0,this.ice&&(this.ice.dirty=!0),this.__afterStateMerge(e)}__beforeStateMerge(t){const e=!!t&&(void 0!==t.width&&t.width!==this.state.width||void 0!==t.height&&t.height!==this.state.height);return t&&void 0!==t.display&&t.display!==this.state.display&&bumpVisibilityEpoch(),e}__afterStateMerge(t){t&&this.parentNode&&"function"==typeof this.parentNode.requestLayout&&this.parentNode.requestLayout()}set dirty(t){this.__dirty=t}get dirty(){return this.__dirty}__applyDirty(t){this.dirty=t||!this.__everRendered}set paramsDirty(t){this.__paramsDirty=t}get paramsDirty(){return this.__paramsDirty}setPosition(e,i){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new E;this.trigger(t.BEFORE_MOVE,_objectSpread2(_objectSpread2({},s),{},{left:e,top:i})),this.setState({left:e,top:i}),this.trigger(t.AFTER_MOVE,_objectSpread2(_objectSpread2({},s),{},{left:e,top:i})),triggerSubtreeMove(this,_objectSpread2(_objectSpread2({},s),{},{left:e,top:i}))}moveGlobalPosition(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new E;if(this.parentNode){let i=[t,e];i=transformMat2d([],i,invert([],this.parentNode.calcAbsoluteLinearMatrix())),t=i[0],e=i[1]}this.setPosition(this.state.left+t,this.state.top+e,_objectSpread2(_objectSpread2({},i),{},{tx:t,ty:e}))}setGlobalPosition(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new E;if(this.parentNode){let i=[t,e];i=transformMat2d([],i,invert([],this.parentNode.calcAbsoluteLinearMatrix())),t=i[0],e=i[1]}this.setPosition(t,e,_objectSpread2(_objectSpread2({},i),{},{left:t,top:e}))}setGlobalRotate(t){if(this.parentNode){const e=this.parentNode.calcAbsoluteLinearMatrix();t-=GeoUtil.calcRotateAngleFromMatrix(e)}this.setState({transform:{rotate:t}})}localToGlobal(t,e){let i=[t,e];return i=transformMat2d([],i,this.state.composedMatrix),i}globalToLocal(t,e){let i=[t,e];return i=transformMat2d([],i,invert([],this.state.composedMatrix)),i}getRotateAngle(){const t=arguments.length>0&&void 0!==arguments[0]&&arguments[0]?this.composeMatrix():this.state.composedMatrix;return GeoUtil.calcRotateAngleFromMatrix(t)}getLocalLeftTop(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=this.getMinBoundingBox(t),i=e.width,s=e.height;return{left:e.centerX-e.width/2,top:e.centerY-e.height/2,width:i,height:s}}__resetLeakyCtxState(){let t=0;const scan=e=>{if(e)for(const i in e){const e=this.__leakyIndex(i);e>=0&&(t|=1<<e)}};if(scan(this.props.style),scan(this.state.style),this.__opacityApplied&&(t|=1<<this.__leakyIndex("globalAlpha"),this.__opacityApplied=!1),this.state.lineDash&&this.state.lineDash.length&&(t|=y),(this.state.lineDashFlow||this.state.lineDashOffset)&&(t|=y),!t)return;const e=this.ctx;for(let i=0;i<m.length;i++)t&1<<i&&(e[m[i][0]]=m[i][1]);t&y&&"function"==typeof e.setLineDash&&(e.setLineDash([]),e.lineDashOffset=0)}__leakyIndex(t){switch(t){case"shadowColor":return 0;case"shadowBlur":return 1;case"shadowOffsetX":return 2;case"shadowOffsetY":return 3;case"globalAlpha":return 4;case"globalCompositeOperation":return 5;case"lineCap":return 6;case"lineJoin":return 7;case"miterLimit":return 8;case"textAlign":return 9;case"textBaseline":return 10;case"direction":return 11;case"letterSpacing":return 12;case"wordSpacing":return 13;case"fontKerning":return 14;case"fontStretch":return 15;case"fontVariantCaps":return 16;case"textRendering":return 17;case"filter":return 18;case"imageSmoothingEnabled":return 19;case"imageSmoothingQuality":return 20;default:return-1}}__paintWorldBox(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0];const e=this.state.composedMatrix,i=this.state.localOrigin,s=i?i[0]:0,o=i?i[1]:0,r=this.__localBox(),u=[r[0]-s,r[2]-s],a=[r[1]-o,r[3]-o];if(t[0]=t[1]=1/0,t[2]=t[3]=-1/0,!e||e.length<6)return t[0]=u[0],t[1]=a[0],t[2]=u[1],t[3]=a[1],t;const h=e[0],l=e[1],c=e[2],d=e[3],D=e[4],p=e[5];for(let e=0;e<2;e++){const i=u[e];for(let e=0;e<2;e++){const s=a[e],o=h*i+c*s+D,r=l*i+d*s+p;o<t[0]&&(t[0]=o),o>t[2]&&(t[2]=o),r<t[1]&&(t[1]=r),r>t[3]&&(t[3]=r)}}return t}containsPoint(t,e){const i=this.state.composedMatrix;if(!i||i.length<6)return this.getMinBoundingBox().containsPoint([t,e]);const s=transformMat2d([],[t,e],invert([],i));return this.containsLocalPoint(s[0],s[1])}containsLocalPoint(t,e){const i=this.state.width/2,s=this.state.height/2;return t>=-i&&t<=i&&e>=-s&&e<=s}destroy(){this.destory()}destory(){this.ice&&this.ice.animationManager&&this.ice.animationManager.remove(this),this.trigger(t.BEFORE_REMOVE,null,{component:this}),this.purgeEvents(),this.ice=null,this.ctx=null,this.root=null,this.evtBus=null,this.parentNode=null}}_defineProperty(ICEComponent,"instanceCounter",0);var B=ICEComponent;var v=class ICEPath extends B{ensurePathBuilt(){const t=this.path2D&&this.path2D._commands;t&&0!==t.length&&!this.dirty||(this.createPathObject(),this.state.closePath&&this.path2D.closePath())}constructor(){super(_objectSpread2({closePath:!0},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})),_defineProperty(this,"path2D",p.createPath2D()),_defineProperty(this,"__flowRegistered",!1)}doRender(){this.dirty&&this.createPathObject(),this.state.closePath&&this.path2D.closePath();const t=this.path2D.drawable||this.path2D,e=this.state.lineDash,i=Array.isArray(e)&&e.length>0,s=this.state.lineDashFlow;s&&this.__ensureFlowAnimation();if(this.state.lineBorder&&i&&this.state.stroke){const e=this.ctx;e.save(),e.setLineDash([]),e.lineWidth=(this.state.style.lineWidth||1)+2*(this.state.lineBorderWidth||4),e.strokeStyle=this.state.lineBorderColor||"#c8c8c8",this.path2D._isPolyfill?(this.replayPath(),e.stroke()):e.stroke(t),e.restore()}if(i&&"function"==typeof this.ctx.setLineDash)if(this.ctx.setLineDash(e),s&&"number"==typeof this.ctx.lineDashOffset){const t=e.reduce((t,e)=>t+e,0)||1,i=this.state.lineDashFlowSpeed||60;this.ctx.lineDashOffset=-Date.now()/1e3*i%t}else this.state.lineDashOffset&&(this.ctx.lineDashOffset=this.state.lineDashOffset);this.path2D._isPolyfill?(this.replayPath(),this.state.fill&&this.ctx.fill(),this.state.stroke&&this.ctx.stroke()):(this.state.fill&&this.ctx.fill(t),this.state.stroke&&this.ctx.stroke(t)),i&&"function"==typeof this.ctx.setLineDash&&this.ctx.setLineDash([]),super.doRender()}__ensureFlowAnimation(){this.__flowRegistered||(this.__flowRegistered=!0,this.props.animations=_objectSpread2(_objectSpread2({},this.props.animations),{},{__flow:{from:0,to:1,duration:100,loop:!0}}),this.ice&&this.ice.animationManager&&this.ice.animationManager.add(this))}replayPath(){const t=this.ctx;t.beginPath();const e=this.path2D._commands;for(let i=0;i<e.length;i++){const s=e[i];t[s[0]](...s.slice(1))}}};var b=class ICERect extends v{constructor(){super(_objectSpread2({width:10,height:10},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}))}createPathObject(){this.path2D=p.createPath2D();const t=0-this.state.localOrigin[0],e=0-this.state.localOrigin[1],i=this.state.width,s=this.state.height,o=Math.min(this.state.radius||0,i/2,s/2);return o>0?(this.path2D.moveTo(t+o,e),this.path2D.lineTo(t+i-o,e),this.path2D.arcTo(t+i,e,t+i,e+o,o),this.path2D.lineTo(t+i,e+s-o),this.path2D.arcTo(t+i,e+s,t+i-o,e+s,o),this.path2D.lineTo(t+o,e+s),this.path2D.arcTo(t,e+s,t,e+s-o,o),this.path2D.lineTo(t,e+o),this.path2D.arcTo(t,e,t+o,e,o),this.path2D.closePath()):this.path2D.rect(t,e,i,s),this.path2D}};class ICEGroup extends b{constructor(t){super(t),_defineProperty(this,"parentNode",null),_defineProperty(this,"childNodes",[]),_defineProperty(this,"__childSet",new WeakSet),_defineProperty(this,"layoutManager",null),_defineProperty(this,"__layoutExplicit",!1),_defineProperty(this,"__layoutRequested",!1),_defineProperty(this,"__layingOut",!1),_defineProperty(this,"__inBatch",!1)}setLayout(t){this.layoutManager=t,this.__layoutExplicit=!0,t&&(this.doLayout(),this.__disableTransformRecursively(this)),this.__propagateLayout(t)}__disableTransformRecursively(t){if(t&&t.childNodes)for(const e of t.childNodes)e.state.transformable=!1,e.state.draggable=!1,this.__disableTransformRecursively(e)}__propagateLayout(t){for(const e of this.childNodes)e instanceof ICEGroup&&!e.__layoutExplicit&&(e.layoutManager=t,e.doLayout(),e.__propagateLayout(t))}doLayout(){if(this.layoutManager){this.__layingOut=!0;try{for(let t=0;t<this.childNodes.length;t++){const e=this.childNodes[t];"function"==typeof e.measure&&e.measure()}this.layoutManager.layoutContainer(this)}finally{this.__layingOut=!1,this.__layoutRequested=!1}}}requestLayout(){this.layoutManager&&!this.__layingOut&&(this.__layoutRequested=!0,this.dirty=!0,this.ice&&(this.ice.dirty=!0))}getPreferredSize(){return this.layoutManager?this.layoutManager.getPreferredSize(this):[0,0]}doRender(){this.__layoutRequested&&this.doLayout(),super.doRender()}initEvents(){super.initEvents(),this.once(t.AFTER_ADD,this.afterAddHandler,this)}afterAddHandler(){for(let t=0;t<this.childNodes.length;t++){const e=this.childNodes[t];this.syncChildEvents(e)}}syncChildEvents(e){e.trigger(t.BEFORE_ADD),e.ice=this.ice,e.ctx=this.ice.ctx,e.evtBus=this.ice.evtBus,e.trigger(t.AFTER_ADD)}addChild(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.__childSet.has(t)||(t.parentNode=this,this.childNodes.push(t),this.__childSet.add(t),bumpVisibilityEpoch(),this.layoutManager&&(t.state.transformable=!1,t.state.draggable=!1,this.__disableTransformRecursively(t)),this.__applyDirty(e),this.ice&&(this.syncChildEvents(t),this.ice.dirty=e,this.ice.renderer&&this.ice.renderer.markQueueDirty()),this.layoutManager&&(t instanceof ICEGroup&&!t.__layoutExplicit&&(t.layoutManager=this.layoutManager),this.__inBatch||this.doLayout()))}addChildren(t){this.__inBatch=!0;try{for(let e=0;e<t.length;e++)this.addChild(t[e],!1)}finally{this.__inBatch=!1}this.dirty=!0,this.ice&&(this.ice.dirty=!0),this.doLayout()}adoptChild(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!t||t===this)return;const i=t.parentNode;if(i&&i!==this&&i.childNodes){const e=i.childNodes.indexOf(t);-1!==e&&i.childNodes.splice(e,1),i.__childSet&&"function"==typeof i.__childSet.delete&&i.__childSet.delete(t),t.parentNode=null,i.ice&&i.ice.renderer&&"function"==typeof i.ice.renderer.markQueueDirty&&i.ice.renderer.markQueueDirty()}else if(!i){const e=this.ice||t.ice;if(e&&Array.isArray(e.childNodes)){const i=e.childNodes.indexOf(t);-1!==i&&e.childNodes.splice(i,1),e.__childSet&&"function"==typeof e.__childSet.delete&&e.__childSet.delete(t),e.renderer&&"function"==typeof e.renderer.markQueueDirty&&e.renderer.markQueueDirty()}}this.addChild(t,e)}removeChild(e){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.__childSet.has(e))return;e.trigger(t.BEFORE_REMOVE);const s=this.childNodes.indexOf(e);-1!==s&&this.childNodes.splice(s,1),this.__childSet.delete(e),bumpVisibilityEpoch(),e.trigger(t.AFTER_REMOVE),this.__applyDirty(i),this.ice&&(this.ice.dirty=i,this.ice.renderer&&this.ice.renderer.markQueueDirty()),e.destory(),this.layoutManager&&!this.__inBatch&&this.doLayout()}removeChildren(t){this.__inBatch=!0;try{for(let e=0;e<t.length;e++)this.removeChild(t[e],!1)}finally{this.__inBatch=!1}this.dirty=!0,this.ice&&(this.ice.dirty=!0),this.doLayout()}setState(t){const e=this.__beforeStateMerge(t);merge(this.state,t),this.paramsDirty=!0,this.dirty=!0,function setRecursively(t){if(t.dirty=!0,t.childNodes&&t.childNodes.length)for(let e=0;e<t.childNodes.length;e++)setRecursively(t.childNodes[e])}(this),this.ice&&(this.ice.dirty=!0),this.__afterStateMerge(e)}destory(){this.removeChildren(this.childNodes),super.destory()}}var S=ICEGroup;class ICEControlPanel extends S{constructor(t){super(_objectSpread2(_objectSpread2({},t),{},{linkable:!1})),_defineProperty(this,"isControlPanel",!0)}doRender(){super.doRender(),this.updateControlPositions()}moveGlobalPosition(t,e,i){super.moveGlobalPosition(t,e,i),this._targetComponent&&this._targetComponent.moveGlobalPosition(t,e,i)}}var P=class ICEEllipse extends v{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=_objectSpread2({radiusX:20,radiusY:10,rotation:0,startAngle:0,endAngle:2*Math.PI,counterclockwise:!0},t);void 0===t.radiusX&&void 0!==t.width&&(e.radiusX=Number(t.width)/2),void 0===t.radiusY&&void 0!==t.height&&(e.radiusY=Number(t.height)/2),e.width=2*e.radiusX,e.height=2*e.radiusY,super(e)}createPathObject(){return this.path2D=p.createPath2D(),this.path2D.ellipse(this.state.radiusX-this.state.localOrigin[0],this.state.radiusY-this.state.localOrigin[1],this.state.radiusX,this.state.radiusY,this.state.rotation,this.state.startAngle,this.state.endAngle,this.state.counterclockwise),this.path2D.closePath(),this.path2D}containsLocalPoint(t,e){const i=this.state.radiusX,s=this.state.radiusY;if(!i||!s)return!1;let o=t,r=e;const u=this.state.rotation||0;if(u){const i=Math.cos(u),s=Math.sin(u);o=t*i+e*s,r=-t*s+e*i}const a=o/i,h=r/s;return a*a+h*h<=1}setState(t){isNil(t.radiusX)?isNil(t.width)||(t.radiusX=t.width/2):t.width=2*t.radiusX,isNil(t.radiusY)?isNil(t.height)||(t.radiusY=t.height/2):t.height=2*t.radiusY,super.setState(t)}};var M=class ICECircle extends P{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=_objectSpread2({radius:10},t);void 0===t.radius&&void 0!==t.width?e.radius=Number(t.width)/2:void 0===t.radius&&void 0!==t.height&&(e.radius=Number(t.height)/2),e.radiusX=e.radius,e.radiusY=e.radius,super(e)}};class ICELinkHook extends M{constructor(){super(_objectSpread2({linkable:!1},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}))}initEvents(){super.initEvents(),this.on("mousedown",this.mosueDownHandler,this),this.on("mousemove",this.mosueMoveHandler,this),this.on("mouseup",this.mosueUpHandler,this),this.on(t.AFTER_MOVE,this.resizeEvtHandler,this)}keyboardEvtHandler(t){}mosueDownHandler(e){this.evtBus.trigger(t.HOOK_MOUSEDOWN,new E({target:this}))}mosueMoveHandler(e){this.evtBus.trigger(t.HOOK_MOUSEMOVE,new E({target:this}))}mosueUpHandler(e){this.evtBus.trigger(t.HOOK_MOUSEUP,new E({target:this}))}resizeEvtHandler(e){if(!this.parentNode)return;const i=this.props.position;this.parentNode.trigger(t.BEFORE_RESIZE,new E(e,{position:i})),this.parentNode.trigger(t.AFTER_RESIZE,new E(e,{position:i}))}}class LineControlPanel extends ICEControlPanel{constructor(t){super(_objectSpread2(_objectSpread2({},t),{},{zIndex:10001e3,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1})),_defineProperty(this,"controlSize",16),this.initControls()}initControls(){const t=this.state.width,e=this.state.height,i=this.controlSize/2;this.startControl=new ICELinkHook({zIndex:10001001,display:!1,left:-i,top:-i,width:this.controlSize,height:this.controlSize,style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1},position:"start"}),this.addChild(this.startControl),this.endControl=new ICELinkHook({zIndex:10001002,display:!1,left:t-i,top:e-i,width:this.controlSize,height:this.controlSize,style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1},position:"end"}),this.addChild(this.endControl)}initEvents(){this.on(t.AFTER_RESIZE,this.resizeEvtHandler,this)}enable(){this.setState({display:!0}),this.resume(t.AFTER_RESIZE),this.showHooks()}disable(){this.setState({display:!1}),this.suspend(t.AFTER_RESIZE),this.hideHooks()}updateControlPositions(){}resizeEvtHandler(t){if(!this.targetComponent)return;const e=t.position;let i=t.movementX,s=t.movementY;const o=this.targetComponent.state,r=o.points.length;let u=o.points[0][0],a=o.points[0][1],h=o.points[r-1][0],l=o.points[r-1][1];const c=transformMat2d([],[i,s],invert([],this.targetComponent.calcAbsoluteLinearMatrix()));switch(i=c[0],s=c[1],e){case"start":u+=i,a+=s;break;case"end":h+=i,l+=s}this.targetComponent.setState({startPoint:[u,a],endPoint:[h,l]})}updatePosition(){if(!this.targetComponent)return;this.setState({left:0,top:-5,width:3,height:3,transform:{translate:[0,0],scale:[1,1],skew:[0,0],rotate:0}});const t=this.controlSize/2,e=this.targetComponent.state.points.length,i=this.targetComponent.state.points[0],s=this.targetComponent.state.points[e-1],o=[i[0],i[1]],r=[s[0],s[1]];this.startControl.setState({left:o[0]-t,top:o[1]-t}),this.endControl.setState({left:r[0]-t,top:r[1]-t})}set targetComponent(e){this._targetComponent&&this._targetComponent.off(t.AFTER_MOVE,this.updatePosition,this),this._targetComponent=e,this._targetComponent&&this._targetComponent.on(t.AFTER_MOVE,this.updatePosition,this),this._targetComponent&&this._targetComponent.once(t.BEFORE_REMOVE,()=>{this.targetComponent=null,this.disable()},this),this.updatePosition()}get targetComponent(){return this._targetComponent}showHooks(){this.startControl.setState({display:!0}),this.endControl.setState({display:!0})}hideHooks(){this.startControl.setState({display:!1}),this.endControl.setState({display:!1})}}class ResizeControl extends b{constructor(t){super(_objectSpread2(_objectSpread2({position:"l",direction:"x",quadrant:1},t),{},{linkable:!1}))}initEvents(){super.initEvents(),this.on(t.AFTER_MOVE,this.resizeEvtHandler,this)}resizeEvtHandler(e){if(!this.parentNode)return;const{quadrant:i}=e;let s=e.movementX,o=e.movementY;const r=this.parentNode.state;let u=r.left,a=r.top,h=r.width,l=r.height;const c=transformMat2d([],[s,o],invert([],this.parentNode.calcAbsoluteLinearMatrix()));switch(s=c[0],o=c[1],i){case 1:u-=s,a+=o,h+=2*s,l-=2*o;break;case 2:u+=s,a+=o,h-=2*s,l-=2*o;break;case 3:u+=s,a-=o,h-=2*s,l+=2*o;break;case 4:u-=s,a-=o,h+=2*s,l+=2*o;break;case 5:a+=o,l-=2*o;break;case 6:a-=o,l+=2*o;break;case 7:u+=s,h-=2*s;break;case 8:u-=s,h+=2*s}const d={top:a,left:u,width:Math.abs(h),height:Math.abs(l)};this.parentNode.trigger(t.BEFORE_RESIZE,new E(e,{quadrant:i})),this.parentNode.setState(d),this.parentNode.trigger(t.AFTER_RESIZE,new E(e,{quadrant:i}))}moveGlobalPosition(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new E;const s=t>0?1:-1,o=e>0?1:-1,r=this.parentNode.state.localOrigin,u=transformMat2d([],[t,e],invert([],this.parentNode.calcAbsoluteLinearMatrix()));t=u[0],e=u[1];let{left:a,top:h}=this.state;const{quadrant:l}=this.state,c=this.state.width/2;let d=0;"x"===this.state.direction?(a+=t,0===round(a)&&(a=.5*s),d=a+c-r[0]>0?8:7):"y"===this.state.direction?(h+=e,0===round(h)&&(h=.5*o),d=h+c-r[1]>0?6:5):"xy"===this.state.direction&&(a+=t,h+=e,d=a+c-r[0]>0?h+c-r[1]>0?4:1:h+c-r[1]>0?3:2);l!==d&&this.parentNode.toggleControlQuadrant(this,l,d),this.setPosition(a,h,new E(i,{left:a,top:h,tx:t,ty:e,quadrant:d}))}}class RotateControl extends M{constructor(t){super(_objectSpread2(_objectSpread2({},t),{},{linkable:!1}))}initEvents(){super.initEvents(),this.on(t.AFTER_MOVE,this.rotateEvtHandler,this)}rotateEvtHandler(e){if(!this.parentNode)return;const i=this.parentNode.calcAbsoluteOrigin();let s=GeoUtil.calcRotateAngle(e.offsetX,e.offsetY,i[0],i[1])+90;e&&e.shiftKey&&(s=function snapAngle(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;return e>0&&isFinite(t)?Math.round(t/e)*e:t}(s));const o={transform:{rotate:s}};this.parentNode.trigger(t.BEFORE_ROTATE,new E(o)),this.parentNode.setState(o),this.parentNode.trigger(t.AFTER_ROTATE,new E(o))}}class TransformControlPanel extends ICEControlPanel{constructor(t){super(_objectSpread2(_objectSpread2({},t),{},{zIndex:10000001,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1})),_defineProperty(this,"rotateControlSize",8),_defineProperty(this,"rotateControlOffsetY",60),_defineProperty(this,"resizeControlInstanceCache",[]),_defineProperty(this,"resizeControlSize",16),_defineProperty(this,"__onTargetRemoved",()=>{this.targetComponent=null,this.disable()}),this.initControls()}initControls(){const t=this.state.width,e=this.state.height,i=t/2,s=e/2,o=this.resizeControlSize/2,r=[{direction:"xy",quadrant:2,position:[-o,-o]},{direction:"y",quadrant:5,position:[i-o,-o]},{direction:"xy",quadrant:1,position:[t-o,-o]},{direction:"x",quadrant:8,position:[t-o,s-o]},{direction:"xy",quadrant:4,position:[t-o,e-o]},{direction:"y",quadrant:6,position:[i-o,e-o]},{direction:"xy",quadrant:3,position:[-o,e-o]},{direction:"x",quadrant:7,position:[-o,s-o]}];this.resizeControlInstanceCache=[];for(let t=0;t<r.length;t++){const e=r[t],i=new ResizeControl({zIndex:10000002,display:!1,left:e.position[0],top:e.position[1],width:this.resizeControlSize,height:this.resizeControlSize,style:{strokeStyle:"#8b0000",fillStyle:"#CC3300",lineWidth:1},direction:e.direction,quadrant:e.quadrant});this.addChild(i),this.resizeControlInstanceCache.push(i)}const u=this.state.width/2-this.rotateControlSize,a=-this.rotateControlOffsetY;this.rotateControlInstance=new RotateControl({zIndex:10000003,display:!1,left:u,top:a,radius:this.rotateControlSize,style:{strokeStyle:"#8b0000",fillStyle:"#CC3300",lineWidth:1}}),this.addChild(this.rotateControlInstance)}initEvents(){super.initEvents(),this.on(t.AFTER_RESIZE,this.resizeEvtHandler,this),this.on(t.AFTER_ROTATE,this.rotateEvtHandler,this),this.on("keydown",this.keyboardEvtHandler,this),this.on("keyup",this.keyboardEvtHandler,this)}enable(){this.rotateControlInstance.setState({display:!0});for(let t=0;t<this.resizeControlInstanceCache.length;t++){this.resizeControlInstanceCache[t].setState({display:!0})}this.setState({display:!0}),this.resume(t.AFTER_RESIZE),this.resume(t.AFTER_ROTATE),this.resume("keydown"),this.resume("keyup")}disable(){this.rotateControlInstance.setState({display:!1});for(let t=0;t<this.resizeControlInstanceCache.length;t++){this.resizeControlInstanceCache[t].setState({display:!1})}this.setState({display:!1}),this.suspend(t.AFTER_RESIZE),this.suspend(t.AFTER_ROTATE),this.suspend("keydown"),this.suspend("keyup")}keyboardEvtHandler(t){this.targetComponent&&this.targetComponent.trigger(t.type,t,{component:this.targetComponent})}rotateEvtHandler(e){if(!this.targetComponent)return;const{rotate:i}=this.state.transform;this.targetComponent.setGlobalRotate(i),this.targetComponent.trigger(t.AFTER_ROTATE),this.updatePanel()}resizeEvtHandler(e){if(!this.targetComponent)return;const{quadrant:i}=e;let s=e.movementX,o=e.movementY;const r=this.targetComponent.state;let u=r.left,a=r.top,h=r.width,l=r.height;const c=transformMat2d([],[s,o],invert([],this.targetComponent.calcAbsoluteLinearMatrix()));switch(s=c[0],o=c[1],i){case 1:u-=s,a+=o,h+=2*s,l-=2*o;break;case 2:u+=s,a+=o,h-=2*s,l-=2*o;break;case 3:u+=s,a-=o,h-=2*s,l+=2*o;break;case 4:u-=s,a-=o,h+=2*s,l+=2*o;break;case 5:a+=o,l-=2*o;break;case 6:a-=o,l+=2*o;break;case 7:u+=s,h-=2*s;break;case 8:u-=s,h+=2*s}if(e&&e.shiftKey){const t=function applyAspectLock(t,e,i,s){const o=Math.abs(i),r=Math.abs(s);if(!(t>0&&e>0))return{width:o,height:r};const u=Math.max(o/t,r/e);return{width:t*u,height:e*u}}(r.width,r.height,h,l),e=a+l/2;u=u+h/2-t.width/2,a=e-t.height/2,h=t.width,l=t.height}this.targetComponent.setState({left:u,top:a,width:Math.abs(h),height:Math.abs(l)}),this.targetComponent.trigger(t.AFTER_RESIZE),this.updatePanel()}updateControlPositions(){const t=this.state.width,e=this.state.height,i=t/2,s=e/2,o=this.resizeControlSize/2;for(let r=0;r<this.resizeControlInstanceCache.length;r++){const u=this.resizeControlInstanceCache[r];let a=[0,0];switch(u.state.quadrant){case 1:a=[t-o,-o];break;case 2:a=[-o,-o];break;case 3:a=[-o,e-o];break;case 4:a=[t-o,e-o];break;case 5:a=[i-o,-o];break;case 6:a=[i-o,e-o];break;case 7:a=[-o,s-o];break;case 8:a=[t-o,s-o]}u.setState({left:a[0],top:a[1]})}const r=this.state.width/2-this.rotateControlSize,u=-this.rotateControlOffsetY;this.rotateControlInstance.setState({left:r,top:u})}updatePanel(){if(!this.targetComponent)return;const t=this.targetComponent.getRotateAngle(!0),{left:e,top:i,width:s,height:o}=this.targetComponent.getLocalLeftTop(!0);this.setState({left:e,top:i,width:s,height:o,transform:{rotate:t}})}set targetComponent(e){const i=this._targetComponent;i&&(i.off(t.AFTER_MOVE,this.updatePanel,this),i.off(t.BEFORE_REMOVE,this.__onTargetRemoved,this)),this._targetComponent=e,e&&(e.on(t.AFTER_MOVE,this.updatePanel,this),e.on(t.BEFORE_REMOVE,this.__onTargetRemoved,this)),this.updatePanel()}get targetComponent(){return this._targetComponent}toggleControlQuadrant(t,e,i){for(let t=0;t<this.resizeControlInstanceCache.length;t++){const s=this.resizeControlInstanceCache[t];s.state.quadrant===i&&s.setState({quadrant:e})}t.setState({quadrant:i})}}var w=class ICEControlPanelManager{constructor(t){this.ice=t,this.transformControlPanel=new TransformControlPanel({left:500,top:100,width:100,height:100,style:{strokeStyle:"#8b0000",fillStyle:"rgba(255, 255, 49, 0.2)",lineWidth:1},transform:{rotate:45}}),this.ice.addTool(this.transformControlPanel),this.transformControlPanel.disable(),this.lineControlPanel=new LineControlPanel({left:700,top:50,width:100,height:100,style:{strokeStyle:"rgba(255, 255, 49, 0)",fillStyle:"rgba(255, 255, 49, 0)",lineWidth:1}}),this.ice.addTool(this.lineControlPanel),this.lineControlPanel.disable()}start(){return this.ice.evtBus.on("mousedown",this.mouseDownHandler,this),this}stop(){return this.ice.evtBus.off("mousedown",this.mouseDownHandler,this),this}mouseDownHandler(t){const e=t.target;if(!(e&&e.ice&&e.state.interactive&&e.state.transformable))return this.lineControlPanel.disable(),void this.transformControlPanel.disable();if(e&&(e.isControlPanel||e.parentNode&&e.parentNode.isControlPanel))return;const i=this.ice.setSelection([e]);this.lineControlPanel.disable(),this.transformControlPanel.disable(),i||(e.isLine?(this.lineControlPanel.targetComponent=e,this.lineControlPanel.enable()):(this.transformControlPanel.targetComponent=e,this.transformControlPanel.enable()))}};var I=class AlignmentGuideManager{constructor(t){_defineProperty(this,"options",{threshold:3,hysteresis:1,edge:!0,center:!0,spacing:!0,guideStyle:{fillStyle:"#EC4899"},guideZIndex:10000010,guideWidth:1}),_defineProperty(this,"enabled",!1),_defineProperty(this,"active",null),_defineProperty(this,"snapping",!1),_defineProperty(this,"intentLeft",0),_defineProperty(this,"intentTop",0),_defineProperty(this,"cachedTargets",[]),_defineProperty(this,"engagedX",!1),_defineProperty(this,"engagedY",!1),_defineProperty(this,"guideX",null),_defineProperty(this,"guideY",null),this.ice=t}enable(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.options=_objectSpread2(_objectSpread2({},this.options),t),this.enabled||(this.enabled=!0,this.ice.evtBus.on("mousedown",this.__onMouseDown,this),this.ice.evtBus.on("mouseup",this.__onMouseUp,this)),this}disable(){return this.enabled?(this.enabled=!1,this.ice.evtBus.off("mousedown",this.__onMouseDown,this),this.ice.evtBus.off("mouseup",this.__onMouseUp,this),this.__detach(),this):this}isEnabled(){return this.enabled}setOptions(t){return this.options=_objectSpread2(_objectSpread2({},this.options),t),this}__onMouseDown(t){const e=t&&t.target;this.__isAlignmentParticipant(e)&&(this.__detach(),this.active=e,this.intentLeft=e.state.left,this.intentTop=e.state.top,this.cachedTargets=this.__computeTargets(),this.engagedX=!1,this.engagedY=!1,this.__ensureGuides(),e.on("mousemove",this.__onDrag,this))}__onDrag(t){if(!this.active||this.snapping)return;const e=t&&"number"==typeof t.movementX?t.movementX:0,i=t&&"number"==typeof t.movementY?t.movementY:0,s=this.ice.viewport?this.ice.viewport.scale:1;this.intentLeft+=e/s,this.intentTop+=i/s,this.snapping=!0,this.active.setState({left:this.intentLeft,top:this.intentTop});const o=this.__boxOf(this.active);if(this.snapping=!1,!o)return;const r=this.options.threshold/s,u=(this.options.threshold+this.options.hysteresis)/s,a=function computeSnap(t,e,i,s,o){const r={x:null,y:null},consider=t=>{if(!t)return;const e=r[t.axis];(!e||Math.abs(t.delta)<Math.abs(e.delta))&&(r[t.axis]=t)};for(const i of e)o.edge&&(consider({axis:"x",type:"edge",delta:i.minX-t.minX,guideValue:i.minX,guideStart:Math.min(t.minY,i.minY),guideEnd:Math.max(t.maxY,i.maxY)}),consider({axis:"x",type:"edge",delta:i.maxX-t.minX,guideValue:i.maxX,guideStart:Math.min(t.minY,i.minY),guideEnd:Math.max(t.maxY,i.maxY)}),consider({axis:"x",type:"edge",delta:i.minX-t.maxX,guideValue:i.minX,guideStart:Math.min(t.minY,i.minY),guideEnd:Math.max(t.maxY,i.maxY)}),consider({axis:"x",type:"edge",delta:i.maxX-t.maxX,guideValue:i.maxX,guideStart:Math.min(t.minY,i.minY),guideEnd:Math.max(t.maxY,i.maxY)}),consider({axis:"y",type:"edge",delta:i.minY-t.minY,guideValue:i.minY,guideStart:Math.min(t.minX,i.minX),guideEnd:Math.max(t.maxX,i.maxX)}),consider({axis:"y",type:"edge",delta:i.maxY-t.minY,guideValue:i.maxY,guideStart:Math.min(t.minX,i.minX),guideEnd:Math.max(t.maxX,i.maxX)}),consider({axis:"y",type:"edge",delta:i.minY-t.maxY,guideValue:i.minY,guideStart:Math.min(t.minX,i.minX),guideEnd:Math.max(t.maxX,i.maxX)}),consider({axis:"y",type:"edge",delta:i.maxY-t.maxY,guideValue:i.maxY,guideStart:Math.min(t.minX,i.minX),guideEnd:Math.max(t.maxX,i.maxX)})),o.center&&(consider({axis:"x",type:"center",delta:i.centerX-t.centerX,guideValue:i.centerX,guideStart:Math.min(t.minY,i.minY),guideEnd:Math.max(t.maxY,i.maxY)}),consider({axis:"y",type:"center",delta:i.centerY-t.centerY,guideValue:i.centerY,guideStart:Math.min(t.minX,i.minX),guideEnd:Math.max(t.maxX,i.maxX)}));if(o.spacing)for(let i=0;i<e.length;i++)for(let s=i+1;s<e.length;s++){const o=e[i],r=e[s],u=Math.min(o.centerX,r.centerX),a=Math.max(o.centerX,r.centerX);if(t.centerX>u&&t.centerX<a){const e=(o.centerX+r.centerX)/2;consider({axis:"x",type:"spacing",delta:e-t.centerX,guideValue:e,guideStart:Math.min(t.minY,o.minY,r.minY),guideEnd:Math.max(t.maxY,o.maxY,r.maxY)})}const h=Math.min(o.centerY,r.centerY),l=Math.max(o.centerY,r.centerY);if(t.centerY>h&&t.centerY<l){const e=(o.centerY+r.centerY)/2;consider({axis:"y",type:"spacing",delta:e-t.centerY,guideValue:e,guideStart:Math.min(t.minX,o.minX,r.minX),guideEnd:Math.max(t.maxX,o.maxX,r.maxX)})}}return r.x=r.x&&Math.abs(r.x.delta)<=i?r.x:null,r.y=r.y&&Math.abs(r.y.delta)<=s?r.y:null,r}(o,this.cachedTargets,this.engagedX?u:r,this.engagedY?u:r,this.options);if(a.x||a.y){const t=this.intentLeft+(a.x?Math.round(a.x.delta):0),e=this.intentTop+(a.y?Math.round(a.y.delta):0);this.active.setState({left:t,top:e}),this.engagedX=!!a.x,this.engagedY=!!a.y,this.__updateGuides(a)}else this.engagedX=!1,this.engagedY=!1,this.__hideGuides()}__onMouseUp(){this.__detach()}__detach(){this.active&&this.active.off("mousemove",this.__onDrag,this),this.active=null,this.intentLeft=0,this.intentTop=0,this.cachedTargets=[],this.engagedX=!1,this.engagedY=!1,this.__hideGuides()}__boxOf(t){const e=t.getMaxBoundingBox(!0);if(!e)return null;const i=e.getMinAndMaxPoint();return function toBox(t,e,i,s){return{minX:t,minY:e,maxX:i,maxY:s,centerX:(t+i)/2,centerY:(e+s)/2}}(i.minX,i.minY,i.maxX,i.maxY)}__computeTargets(){const t=this.ice.childNodes,e=[];for(const i of t){if(i===this.active)continue;if(!this.__isAlignmentParticipant(i))continue;const t=this.__boxOf(i);t&&e.push(t)}return e}__isAlignmentParticipant(t){return!!(t&&t.state&&t.state.interactive&&t.state.draggable)&&(!t.isLine&&(!t.isControlPanel&&(!t.parentNode||!t.parentNode.isControlPanel)))}__ensureGuides(){const t=_objectSpread2({},this.options.guideStyle);this.guideX||(this.guideX=new b({left:0,top:0,width:1,height:1,display:!1,zIndex:this.options.guideZIndex,origin:"top-left",stroke:!1,style:t}),this.ice.addTool(this.guideX)),this.guideY||(this.guideY=new b({left:0,top:0,width:1,height:1,display:!1,zIndex:this.options.guideZIndex,origin:"top-left",stroke:!1,style:t}),this.ice.addTool(this.guideY))}__updateGuides(t){const e=this.options.guideWidth/(this.ice.viewport?this.ice.viewport.scale:1),[i,s]=this.ice.screenToWorld(0,0),[o,r]=this.ice.screenToWorld(this.ice.canvasWidth,this.ice.canvasHeight);t.x&&this.guideX?this.guideX.setState({display:!0,left:t.x.guideValue-e/2,top:s,width:e,height:r-s}):this.guideX&&this.guideX.setState({display:!1}),t.y&&this.guideY?this.guideY.setState({display:!0,left:i,top:t.y.guideValue-e/2,width:o-i,height:e}):this.guideY&&this.guideY.setState({display:!1})}__hideGuides(){this.guideX&&this.guideX.setState({display:!1}),this.guideY&&this.guideY.setState({display:!1})}};const T=[["pointerdown","ICE_POINTERDOWN"],["pointermove","ICE_POINTERMOVE"],["pointerup","ICE_POINTERUP"],["pointercancel","ICE_POINTERCANCEL"]],R=[["mousedown","ICE_MOUSEDOWN"],["mouseup","ICE_MOUSEUP"],["mousemove","ICE_MOUSEMOVE"],["click","ICE_CLICK"],["dblclick","ICE_DBCLICK"],["contextmenu","ICE_CONTEXTMENU"]],O=[["click","ICE_CLICK"],["dblclick","ICE_DBCLICK"],["contextmenu","ICE_CONTEXTMENU"]],N=[["touchstart","ICE_TOUCHSTART"],["touchmove","ICE_TOUCHMOVE"],["touchend","ICE_TOUCHEND"],["touchcancel","ICE_TOUCHCANCEL"]],k=[["wheel","ICE_WHEEL"]],L=[["keydown","ICE_KEYDOWN"],["keyup","ICE_KEYUP"]],z=["ICE_MOUSEMOVE","ICE_POINTERMOVE","ICE_TOUCHMOVE"];function buildDomEventList(t){const e=[];return t?e.push(...T,...O):e.push(...R,...N),e.push(...k,...L),e}function isTouchEvent(t){return!!t&&"string"==typeof t.type&&0===t.type.indexOf("touch")}function normalizeInput(t,e,i){const s=function resolveClientPoint(t){if(!t)return null;if(isTouchEvent(t)){const e=(t.touches&&t.touches.length?t.touches:t.changedTouches)||null,i=e&&e[0];return i&&"number"==typeof i.clientX?{clientX:i.clientX,clientY:i.clientY}:null}return"number"==typeof t.clientX&&"number"==typeof t.clientY?{clientX:t.clientX,clientY:t.clientY}:null}(t);if(!s)return null;const o=e&&"number"==typeof e.left?e.left:0,r=e&&"number"==typeof e.top?e.top:0,u=s.clientX-o,a=s.clientY-r;let h=Number(t.movementX),l=Number(t.movementY);isFinite(h)&&isFinite(l)||(i?(h=u-i.x,l=a-i.y):(h=0,l=0));const c=isTouchEvent(t);return{x:u,y:a,clientX:s.clientX,clientY:s.clientY,movementX:h,movementY:l,pointerType:t.pointerType||(c?"touch":"mouse"),pointerId:"number"==typeof t.pointerId?t.pointerId:-1,button:"number"==typeof t.button?t.button:0,buttons:"number"==typeof t.buttons?t.buttons:0,isPrimary:!1!==t.isPrimary,isTouch:c,shiftKey:!!t.shiftKey,ctrlKey:!!t.ctrlKey,altKey:!!t.altKey,metaKey:!!t.metaKey}}function applyNormalizedInput(t,e){t&&e&&(t.offsetX=e.x,t.offsetY=e.y,t.clientX=e.clientX,t.clientY=e.clientY,t.movementX=e.movementX,t.movementY=e.movementY,t.pointerType=e.pointerType,t.pointerId=e.pointerId,t.isTouchInput=e.isTouch,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.altKey=e.altKey,t.metaKey=e.metaKey)}function toLegacyMouseName(t){switch(t){case"pointerdown":case"touchstart":return"mousedown";case"pointermove":case"touchmove":return"mousemove";case"pointerup":case"touchend":case"pointercancel":case"touchcancel":return"mouseup";default:return null}}const X=/^(-?\d+(?:\.\d+)?)(px|em|rem|%)?$/;function resolveLetterSpacingPx(t,e){if(null==t||""===t)return 0;if("number"==typeof t)return Number.isFinite(t)?t:0;const i=X.exec(String(t).trim());if(!i)return 0;const s=parseFloat(i[1]);if(!Number.isFinite(s))return 0;const o=i[2];return"em"===o||"rem"===o?s*e:"%"===o?s/100*e:s}function resolveLetterSpacingCss(t,e){return"".concat(resolveLetterSpacingPx(t,e),"px")}function resolveLineHeightPx(t,e){if(null==t||""===t||"normal"===t)return null;if("number"==typeof t)return Number.isFinite(t)&&t>0?t:null;const i=X.exec(String(t).trim());if(!i)return null;const s=parseFloat(i[1]);if(!Number.isFinite(s)||s<=0)return null;const o=i[2];return"em"===o||"rem"===o?s*e:"%"===o?s/100*e:void 0===o?s*e:s}const V=["underline","line-through","overline"];function resolveTextDecorations(t){if(!t||"none"===t)return[];return String(t).split(/\s+/).filter(t=>V.includes(t))}const G={sm:5,md:13,lg:26};function stylePaintPad(t){const e=t&&t.style||{};let i=2;const s=Number(e.lineWidth)||0,o=Number(t.lineBorderWidth)||0,r=Math.ceil(Math.max(s,o));r>0&&(i+=r);const u=Number(e.shadowBlur);if(u>0?i+=u+Math.max(Math.abs(Number(e.shadowOffsetX)||0),Math.abs(Number(e.shadowOffsetY)||0)):"string"==typeof e.shadow&&G[e.shadow]&&(i+=G[e.shadow]),resolveTextDecorations(e.textDecoration).indexOf("underline")>=0){const t=Number(e.fontSize)||0;i+=Math.ceil(.2*t)}return i}function boxArea(t){return function boxWidth(t){return t[2]-t[0]}(t)*function boxHeight(t){return t[3]-t[1]}(t)}function unionBoxes(t,e){return e[0]<t[0]&&(t[0]=e[0]),e[1]<t[1]&&(t[1]=e[1]),e[2]>t[2]&&(t[2]=e[2]),e[3]>t[3]&&(t[3]=e[3]),t}function intersects(t,e){return!(t[0]>e[2]||t[2]<e[0]||t[1]>e[3]||t[3]<e[1])}function isFiniteBox(t){return isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])&&isFinite(t[3])}function integerAlign(t){return t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3]),t}function mergeBox(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1]),Math.max(t[2],e[2]),Math.max(t[3],e[3])]}function isWorthMerging(t,e){const i=boxArea(t)+boxArea(e);return i<=0||boxArea(mergeBox(t,e))<=2*i}function mapBoxToRender(t,e,i){const s=i||[0,0,0,0];return s[0]=Math.floor(t[0]*e.scale+e.tx),s[1]=Math.floor(t[1]*e.scale+e.ty),s[2]=Math.ceil(t[2]*e.scale+e.tx),s[3]=Math.ceil(t[3]*e.scale+e.ty),s}const H=/(rgba|hsla)\(|transparent|#[0-9a-fA-F]{8}|opacity/i;function isOpaqueDrawing(t){const e=t&&t.style||{};if(t&&void 0!==t.opacity&&1!==t.opacity)return!1;if(void 0!==e.globalAlpha&&1!==e.globalAlpha)return!1;if(e.globalCompositeOperation&&"source-over"!==e.globalCompositeOperation)return!1;if(e.shadow||(Number(e.shadowBlur)||0)>0)return!1;for(const t of["fillStyle","strokeStyle"]){const i=e[t];if("string"==typeof i&&H.test(i))return!1}return!0}var Y=class DOMEventDispatcher{constructor(t){_defineProperty(this,"selectionCandidates",[]),_defineProperty(this,"_stopped",!1),_defineProperty(this,"__lastInput",null),_defineProperty(this,"focusedComponent",null),this.ice=t}start(){let t=null;const e=buildDomEventList("function"==typeof p.PointerEvent);for(let i=0;i<e.length;i++){const s=e[i],o=s[0],r=s[1],u=toLegacyMouseName(o);this.ice.evtBus.on(r,e=>{if(this._stopped)return;const i=e.originalEvent||e;this.__handlePointerCapture(r,i);const s=normalizeInput(i,this.__resolveCanvasRect(o),this.__lastInput);s&&(applyNormalizedInput(e,s),this.__lastInput=s);const a=-1!==z.indexOf(r),h=-1!==r.indexOf("KEY"),l="ICE_WHEEL"===r;
28
28
  //! 移动类事件触发频率极高,不执行 findTargetComponent();
29
29
  //! 键盘事件必须先选中组件再派发才有意义,同样不做命中检测。
30
- h||l||c||(t=this.findTargetComponent(e));let d=t;c?d=null:l&&this.focusedComponent&&(d=this.focusedComponent),this.__dispatch(o,e,d),a&&a!==o&&this.__dispatch(a,e,d)})}return this}__handlePointerCapture(t,e){const i=this.ice.canvasEl;if(!i||"function"!=typeof i.setPointerCapture)return;const s=e&&e.pointerId;if("number"==typeof s)try{if("ICE_POINTERDOWN"===t){const t=e&&e.target;if(t&&t!==i&&(!i.contains||!i.contains(t)))return;i.setPointerCapture(s)}else"ICE_POINTERUP"!==t&&"ICE_POINTERCANCEL"!==t||"function"==typeof i.releasePointerCapture&&i.hasPointerCapture&&i.hasPointerCapture(s)&&i.releasePointerCapture(s)}catch(t){}}__dispatch(t,e,i){i&&(e.target=i,i.trigger(t,e)),this.ice.evtBus.trigger(t,e,{component:i})}__resolveCanvasRect(t){const e="pointermove"===t||"mousemove"===t||"touchmove"===t,i=this.ice;return e&&i&&"function"==typeof i.refreshInputRect?i.refreshInputRect():i&&"function"==typeof i.updateCanvasBoundingRect&&i.updateCanvasBoundingRect(),i&&"function"==typeof i.getInputRect?i.getInputRect():i&&i.canvasBoundingClientRect||null}set stopped(t){this._stopped=t}get stopped(){return this._stopped}findTargetComponent(t){if(this._stopped)return null;const{offsetX:e,offsetY:i}=t;if("number"!=typeof e||"number"!=typeof i)return null;const[s,o]=this.ice.screenToWorld(e,i);return hitTestComponents(this.ice,s,o,1)}};const V={evtBuses:[],__handlers:null,__hasPointerEvent:!1,start:function(){if(!p||!p.addEventListener||V.__handlers)return;const t="function"==typeof p.PointerEvent;V.__hasPointerEvent=t;const e=buildDomEventList(t),i=[];for(let t=0;t<e.length;t++){const s=e[t],handler=t=>{for(let e=0;e<V.evtBuses.length;e++)V.evtBuses[e].trigger(s[1],t)},o="wheel"===s[0]||"touchmove"===s[0]?{passive:!1}:void 0;o&&"function"==typeof p.addEventListener?p.addEventListener(s[0],handler,o):p.addEventListener(s[0],handler),i.push({name:s[0],handler:handler})}V.__handlers=i},stop:function(){if(V.__handlers&&p&&p.removeEventListener)for(let t=0;t<V.__handlers.length;t++){const e=V.__handlers[t];p.removeEventListener(e.name,e.handler)}V.__handlers=null},registerEvtBus:function(t){V.evtBuses.includes(t)||V.evtBuses.push(t)},delEvtBus:function(t){V.evtBuses.includes(t)&&(V.evtBuses.splice(V.evtBuses.indexOf(t),1),0===V.evtBuses.length&&V.stop())}};var H=V;var Y=class EventBus extends y{constructor(){super()}};class GeoLine{constructor(t,e){this.startPoint=t,this.endPoint=e}contains(t,e){const i=Math.hypot(this.endPoint.x-this.startPoint.x,this.endPoint.y-this.startPoint.y),s=Math.hypot(t-this.startPoint.x,e-this.startPoint.y),o=Math.hypot(t-this.endPoint.x,e-this.endPoint.y);return s+o>=i-3&&s+o<=i+3}}class GeoPoint{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.x=t,this.y=e}static load(t){return new GeoPoint(Number(t.x),Number(t.y))}static cloneArray(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].clone());return e}equals(t){return this.x==t.x&&this.y==t.y}clone(){return new GeoPoint(this.x,this.y)}}class ICEDotPath extends w{constructor(t){super(_objectSpread2({dots:[],closePath:!0},t)),_defineProperty(this,"__dotsShiftX",0),_defineProperty(this,"__dotsShiftY",0)}calcComponentParams(){if(!this.paramsDirty)return{width:this.state.width,height:this.state.height};this.calcDots();const t=this.calc4VertexPoints(),e=Math.abs(t[1][0]-t[0][0]),i=Math.abs(t[2][1]-t[0][1]);return this.state.width=e,this.state.height=i,{width:this.state.width,height:this.state.height}}containsLocalPoint(t,e){const i=this.state.dots;return!i||i.length<3?super.containsLocalPoint(t,e):GeoUtil.pointInPolygon(t,e,i)}calcLocalOrigin(){const t=super.calcLocalOrigin(),e=-t[0]-this.__dotsShiftX,i=-t[1]-this.__dotsShiftY;if(0!==e||0!==i){const s=[1,0,0,1,e,i];for(let t=0;t<this.state.dots.length;t++)this.state.dots[t]=transformMat2d([],this.state.dots[t],s);this.__dotsShiftX=-t[0],this.__dotsShiftY=-t[1]}return t}createPathObject(){this.ensureDots(),this.path2D=p.createPath2D(),this.path2D.moveTo(this.state.dots[0][0],this.state.dots[0][1]);for(let t=1;t<this.state.dots.length;t++){const e=this.state.dots[t];this.path2D.lineTo(e[0],e[1])}return this.path2D}calcDots(){return this.__dotsShiftX=0,this.__dotsShiftY=0,this.__calcDots()}__calcDots(){return this.state.dots=[],this.state.dots}ensureDots(){this.state.dots&&0!==this.state.dots.length||this.calcDots()}calc4VertexPoints(){this.ensureDots();let t=this.state.dots[0][0],e=this.state.dots[0][1],i=this.state.dots[0][0],s=this.state.dots[0][1];for(let o=1;o<this.state.dots.length;o++){const r=this.state.dots[o];r[0]<t&&(t=r[0]),r[0]>i&&(i=r[0]),r[1]<e&&(e=r[1]),r[1]>s&&(s=r[1])}return[[t,e],[i,e],[t,s],[i,s]]}getTransformedDots(){const t=this.state.composedMatrix,e=this.state.dots,i=[];for(let s=0;s<e.length;s++){const o=transformMat2d([],e[s],t);i.push(o)}return i}}var G=class ICEImage extends C{constructor(){super(_objectSpread2({width:100,height:100,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALkAAAC2CAYAAACF+yyJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAtoSURBVHhe7Z3tj15FHYb9VxUVo7zFUBWC8YXoF9++GENMRAWRKAkxGj8pihpjFBVF1CBlKaUU+wK0pYVqt12fn+6xs7PXnDPzO3O2Z+a5r+T6ss995nm2vXf3vM68570vXNuTsmdVctm9KrnsXpVcdq9KLrtXJZfdq5LL7lXJZfeq5LJ7VXLZvSq57F6VXHavSi67VyWX3auSy+5VyWX3quSye1Vy2b0quexelVx2r0ouu1cll92rksvuVcll96rksntVctm9KrnsXpVcdq9KLrtXJZfdq5LL7lXJZfeq5LJ7VfIjcIy7j/M2sp4q+YKWQNvLOqrkC+nhodO7OJacp0q+gHO4/2UVvbYqeWXH+O2lG3sf29nd++Eb1/e/wtC40q9KXtGfX+Dy3v4PzpspKCt9quQVJSgXS1BO+lTJK0pQLvab/zz8F+CjL3FWlquSV/KBE7v79bwJ5VISlJPlquSV/AXsj1MuJUE5Wa5KXsmfvKWSr1WVvJJ2BiWGciljLm/2figny1XJK0pQLvbS4d15zEmfKnlFicfPXsdsKEE56VMlr+hdx7mwqV2P75/ji0dvboahvPSpkle2BjSu9KuSL+AcaDw5T5V8IT3QOHK+KvmCni/oOm0v66iSO/zz5Rv71cwr56Nn+ADzmUs3MB8bQq/LcVVyhzHvg0wsQbnYmCfPTZ+SlAdVyQv92mm4crPhzokHkgnKhaagrEyrkjtM8eAr6UfXCMoNpqCsHFcld5rC7g3PzVPOTPHZkR8imbbpkqeg7BKm+NXFw0Un4swH4CavgTuOaH6Wd/gYGbOt2GTJc8k5IJxrileuHjxzQoSv37uTHutWfh8x9zU4m0BTJd959+apu1z+tdmExgoN+euVvNN6oSnCe1aI4bUvneKDWWPI5PrhFw++F2VC6dG7HGistdpMyc/9u7zgA/bfSGMOxlBmyhT2qVOv29efSNykZYTj5xrz2Jn0KcdvOQs+QGOu0SZKbn+u5/LAyJ/ZGO/uQSnPvp3+waXxc4x57nL6L9Ncnh0Ze002UfIUlDVTUNYkKJdjDWjcHD938vBuD+XMFJQ1U1B2ba6+5HZWgaBsKPFwhdN7Oc6BxsuVoJxJUC6UuJi4V35Nrr7kBOVIYk6uRA80TonEnBxJUG5NquQbbZLNGMqVWgJtX2rMcNA7lTMoR9JRBOXWZHMlt4d+KUc+VTBNRIydzaFcqTnQdqXeVjBbAEE5ki5YUW5NNlfy+CLLmN876y+5QTmPYyc/Ke+RoJxJUC5lDGXWpHZX9iUo55WgnFeCciZBOfL5K4d/ZCm3JlXyfR+BBxso55WgnFeCciZBOZKg3Jpcfcl/nJiwnrKhqWt5x3byLwr98kK9BxQIynmNscn+KWemoGxo6uIVZdfk6ktupqCseW1sJ3gf2o6gnEeCch4vwPCUy4G2M/8OuykGZddmEyW3ZUjG+PSJ3f9etr+eUe6Y8H2I8PU5EpTzSISv0370FF8+tbv38c1fA/oBCgnfZ602UXJzSexGJXsPe7A4Jv4cXgnKeSTs6zXu+Rkj/hxrtZmSm15yt6Xc11+vc/80QTmPMXb7Qg60bS7xZ1izTZXcLLmn/Orm/zrc1vubLRzDK0G5Un9zsXxXxB7GDsewSUlLCLdtweZKPjh2f/m7Ublj/zhyiytBY5RKUK7UEuy7pjEGfwZXiENomxZstuQ1zIW2LfE1ezwpAeVLzIW23Ra3uuSDOdB2U9rzkDn8yfnwQQ73ahU5/SYv4Y3NJjQO6eGDI4vahqYmOBpjm5dM3KqSp66elnL3yPQQNaBxB2twttIdlq3YfcmXJHyfF96ZPpgdzvb84HzeD1s4/pJ8pvNJi7or+e8Lz5wQdrXPxqIFaGNy/zbEn9PM4W8ZVyvte7bxPhRNR+Hh7YL79Vuxq5J7ic+nx6ZmlcqBxoudA403+LuJ2yHGoPFadWtL/qnNb2kaY8wShlsFch2bIo6gMcYsvRBmD5zQOC26NSWvdbD1/oky2k1itF2uT8Py5SHfrVS+qYNw2qZVuyq5FSDkngVPmxGU80pQrpYhdqsyZVq1uwPPo5KgnFeCcnJaldwpQTmvBOXktCq5U4JyXgnKyWlVcqcE5bwSlJPTquROCcp5JSgnp1XJnRKU80pQTk6rkjslKOeVoJycViV3SlDOK0E5Oa1K7pSgnFeCcnJaldwpQTmvBOXktF2VPL6sP/Zww1wJynklKFfLkKm7Mluzq5KPUesGram7Be3mVtou119PTDGhG7TK3ZqSx3xy4VttHx1ZWpC05ztLoDHG1K22nehl6mkYPTTRtt0deP6hwuNvX3z1f7/l7bf9FLmTjMaf08zBVoiewiZLsvFqPP4WriLdi92VPPQoJ7zMeZB5WAJdDzIfrV2XPLbWlBR3aUqKptyqkseWcqagHB40udAybnXJB3Og7ab8ROY0cXaASNtPmXM4oGni9Js8C9q2xFOa8POW2mzJbdchhZ3yo20GS8/A0BilEpQrtQT7rmmMQVsIbAzapgWbK/lLmoT/gJ5J+L/62sGzKY/B8o5jhNu2YFMl95K7LeVaXE7lG6/nlZa2zSX+DGu2mZIvyTDbFV0hjD+HV4JyHgn7+lFeJ1izTZQ8Z4lDuzqpJQ5vEr6ec9U05guv7u7d//Lu3lsTPyfh+6zVJkqegrLmyDHp/6HtCMp5JCjn8SgWq039oFB2ba6+5LWXHS9ZjrvlZceP7XDOTEHZ0NRZKcquydWXnKAcSVDOfATOMFDOK0E5rwTlTIJyJEG5NamS70tQzitBOa8E5UyCcuRzlw//Nqfcmmyu5Ceu5l8Ctxv/YyhnEpTzOHZCj/IeCcqZBOVSxlBmTTZX8pLlPmjxVcqZMbYYLuVKzYG2K5XmTaecSVCOLHmftajdlY12qiyGcqWWQNuXGmM7Fjk5g3IkHXpSbk2q5AW5Ej3QOCUSc3IkQbk1ufqS33Hc9w9LfDuxjg9BuVznQOPlSlDOJCgXStg5esquydWX3ExBWTMFZU2CcjnWgMbN8fMn83e7UlDWTEHZtdlEyUtXRiPGpqCIsXs+KDdlKc+PXG6n8XOMsVN+lDPnYldBady12UTJTVvX3kvqAGwwhjJTphjem7CvP3EufYIxHD/XmO+MzP9iN6bNgcZco82U3Bx7wibF1AMUZshfRn7zpUxxJXhvYnjtK6fSj8kNmVzvjI5hKBP6sLPoNNZabarkg7l4dztKTHEyumhFhK8f20kX/VZ+HzH23Cptv2abLPlgCsouYQqbzzAnG2duHzn2+MiLB7NLaWt4Ekfxg7aUTZf8VpoitQ9MUM5M4VkqXarkLlM8ODITFUG5wRSUleOq5IWmJvaxAz7KDxKUC01BWZlWJXcYcxtkYgnKxcY8ea7egxzbokruMLynml6PtbnKiWcyZ84KodfluCr5gp5P73EcgraXdVTJF9IDjSPnq5Iv4BxoPDlPlbyyNaBxpV+VvKK2pCJxaZeL+zg8g2q8uRmG8tKnSl5RImdJQoJy0qdKXlGCcrEX4foS5aRPlbySdHMV5VLGlMxKIMdVySv504LpL0iCcrJclbyStEoD5VISlJPlquSVpIVtKZeSoJwsVyWvKEG5WHrWcpuXJKytSl5RgnKxBOWkT5W8ok8nVk+zNe8pb6agrPSpkld2DLu11hYB+NHE8uc0rvSrki/gHO5r8Gn4tauSL6SHh06r4Euoki9oCbS9rKNKfgSOcY9OFS6uSi67VyWX3auSy+5VyWX3quSye1Vy2b0quexelVx2r0ouu1cll92rksvuVcll96rksntVctm9KrnsXpVcdq9KLrtXJZfdq5LL7lXJZfeq5LJ7VXLZvSq57F6VXHavSi67VyWX3auSy+5VyWX3quSye1Vy2b0quezca3v/AeMnvtkH1pHJAAAAAElFTkSuQmCC",clipType:"none",sx:0,sy:0,sw:0,sh:0},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}))}doRender(){if(this.state.src){const{loaded:t,image:e}=this.ice.imageCache.setImage(this.state.src);if(t){const t=this.ctx,i=this.state.clipType||"none",s=0-this.state.localOrigin[0],o=0-this.state.localOrigin[1],{sx:r,sy:a,sw:h,sh:l}=this.state,c=h>0&&l>0;"circle"===i&&(t.save(),t.beginPath(),t.arc(0,0,Math.min(this.state.width,this.state.height)/2,0,2*Math.PI),t.closePath(),t.clip()),c?t.drawImage(e,r,a,h,l,s,o,this.state.width,this.state.height):t.drawImage(e,s,o,this.state.width,this.state.height),"circle"===i&&t.restore()}}super.doRender()}};class ICEPolyLine extends ICEDotPath{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(ICEPolyLine.arrangeParam(t)),_defineProperty(this,"isLine",!0),_defineProperty(this,"__polyBoxScratch",[0,0,0,0]),_defineProperty(this,"__arrowFaceIndexes",[])}containsLocalPoint(t,e){const i=this.state.dots;if(!i||i.length<2)return super.containsLocalPoint(t,e);const s=Math.max(4,(this.state.lineWidth||1)/2+3);return GeoUtil.distanceToPolyline(i,t,e)<=s}static arrangeParam(t){let e=merge({},{lineType:"solid",lineWidth:1,arrow:"none",arrowLength:15,arrowAngel:toRadian(30),arrowStyle:"filled",points:[],showMinBoundingBox:!1,showMaxBoundingBox:!1,links:{},routeType:"straight",routeOffset:20,curveType:"straight",label:"",labelStyle:{fontSize:14,fillStyle:"#000000",backgroundColor:"#ffffff"},style:{lineJoin:"round"}},t,{linkable:!1,closePath:!1,fill:!1});const i=e.points.length;return i<2&&(0===i?(e.points.push([0,0]),e.points.push([10,10])):1===i&&e.points.push([10,10])),"dashed"!==e.lineType||e.lineDash&&0!==e.lineDash.length||(e.lineDash=[4*e.lineWidth,4*e.lineWidth]),e=_objectSpread2(_objectSpread2({},e),{left:e.points[0][0],top:e.points[0][1],transform:{translate:[0,0],scale:[1,1],skew:[0,0],rotate:0}}),e.style.lineWidth<1&&(e.style.lineWidth=1),e}initEvents(){super.initEvents(),this.once(t.AFTER_ADD,this.afterAddHandler,this)}afterAddHandler(e){this.evtBus.once(t.ROUND_FINISH,this.syncConnections,this)}syncConnections(){if(!this.ice)return;this.removeLink("start"),this.removeLink("end");const t=this.state.links;t&&(t.start&&t.start.id&&t.start.position&&this.createLink(t.start.id,t.start.position),t.end&&t.end.id&&t.end.position&&this.createLink(t.end.id,t.end.position)),this.paramsDirty=!0,this.dirty=!0,this.ice.dirty=!0}createLink(e,i){const s=this.ice.findComponent(e);s&&s.on(t.AFTER_MOVE,this.followComponent,this),s&&s.on(t.AFTER_RESIZE,this.followComponent,this),s&&s.on(t.AFTER_ROTATE,this.followComponent,this),s&&this.followComponent(),this.state.draggable=!1}removeLink(e,i,s){if(!this.state.links||!this.state.links[e])return;const o=this.state.links[e].id,r=this.state.links[e].position;if(i||(i=o),s||(s=r),o===i&&r===s){const e=this.ice.findComponent(o);e&&e.off(t.AFTER_MOVE,this.followComponent,this),e&&e.off(t.AFTER_RESIZE,this.followComponent,this),e&&e.off(t.AFTER_ROTATE,this.followComponent,this)}let a=!0;this.state.links.start&&this.state.links.start.id&&(a=!1),this.state.links.end&&this.state.links.end.id&&(a=!1),this.state.draggable=a}getLinkFromId(){return this.state.links.start.id}getLinkToId(){return this.state.links.end.id}followComponent(t){for(const t in this.state.links){if(!this.state.links[t]||!this.state.links[t].id||!this.state.links[t].position)continue;const e=this.state.links[t].id,i=this.state.links[t].position,s=this.ice.findComponent(e);if(!s)continue;const o=s.getMinBoundingBox(!0);let r=[0,0];switch(i){case"T":r=o.tc;break;case"R":r=o.rc;break;case"B":r=o.bc;break;case"L":r=o.lc;break;case"C":r=o.center}switch(t){case"start":this.setState({startPoint:[...r]});break;case"end":this.setState({endPoint:[...r]})}}}calcLocalOrigin(){const t=[0,0];return this.state.localOrigin=t,t}__calcDots(){const t=this.state.left,e=this.state.top;this.state.dots=[];for(let i=0;i<this.state.points.length;i++){const s=this.state.points[i],o=s[0]-t,r=s[1]-e;this.state.dots.push([o,r])}return this.calcArrowPoints(),this.state.dots}calcArrowPoints(){if(this.__arrowFaceIndexes.length=0,"start"===this.state.arrow||"both"===this.state.arrow){const t=[...this.state.dots[0]];let e=[[...this.state.dots[0]],[...this.state.dots[1]]];e=this.doCalcArrowPoints(e),this.state.dots.unshift(...e),this.state.dots.unshift([...t]),this.__arrowFaceIndexes.push(0)}if("end"===this.state.arrow||"both"===this.state.arrow){const t=this.state.dots.length,e=[...this.state.dots[t-1]];let i=[[...this.state.dots[t-1]],[...this.state.dots[t-2]]];i=this.doCalcArrowPoints(i),this.state.dots.push(...i),this.state.dots.push([...e]),this.__arrowFaceIndexes.push(this.state.dots.length-4)}}doCalcArrowPoints(t){const e=t[0],i=t[1];i[0]=i[0]-e[0],i[1]=i[1]-e[1];const s=Math.hypot(i[0],i[1]);if(0===s)return[[e[0],e[1]],[e[0],e[1]]];const o=i[0]/s,r=i[1]/s,a=Math.cos(this.state.arrowAngel),h=Math.sin(this.state.arrowAngel);let l=this.state.arrowLength*(o*a-r*h),c=this.state.arrowLength*(r*a+o*h),d=this.state.arrowLength*(o*a+r*h),u=this.state.arrowLength*(r*a-o*h);return l+=e[0],c+=e[1],d+=e[0],u+=e[1],[[l,c],[d,u]]}addDot(t,e){this.state.points.splice(e,0,t),this.state.dots.splice(e,0,[t[0],t[1]])}rmDot(t){return!(this.state.points.length<3)&&(this.state.points.splice(t,1),this.state.dots.splice(t,1),!0)}calcComponentParams(){if(!this.paramsDirty)return{width:this.state.width,height:this.state.height};this.calcDots();const t=this.calc4VertexPoints();let e=1/0,i=1/0,s=-1/0,o=-1/0;for(let r=0;r<t.length;r++){const a=t[r];a[0]<e&&(e=a[0]),a[0]>s&&(s=a[0]),a[1]<i&&(i=a[1]),a[1]>o&&(o=a[1])}return this.state.width=Math.abs(s-e),this.state.height=Math.abs(o-i),{width:this.state.width,height:this.state.height}}isDotsOnSameLine(){const t=this.state.points.length,e=round(this.state.points[0][0],2),i=round(this.state.points[0][1],2);let s=0;const o=[round(this.state.points[t-1][0],2)-e,round(this.state.points[t-1][1],2)-i];for(let r=0;r<t;r++){const t=this.state.points[r];0===cross([],o,[t[0]-e,t[1]-i])[2]&&s++}return s===t}calc4VertexPoints(){return this.isDotsOnSameLine()?this.splitEndpointsTo4Points():super.calc4VertexPoints()}splitEndpointsTo4Points(){const t=this.state.points.length,e=this.state.points[t-1][0]-this.state.points[0][0],i=this.state.points[t-1][1]-this.state.points[0][1],s=this.getRotateAngle(),o=this.state.style.lineWidth||1;let r=Math.cos(s*Math.PI/180)*o/2,a=Math.sin(s*Math.PI/180)*o/2;r=round(r,3),a=round(a,3);return[[0+r,0+a],[0-r,0-a],[e+r,i+a],[e-r,i-a]]}__localBox(){const t=this.__polyBoxScratch;this.ensureDots();const e=this.state.dots;if(!e||0===e.length)return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t;const i=this.calc4VertexPoints();let s=1/0,o=1/0,r=-1/0,a=-1/0;for(let t=0;t<i.length;t++){const e=i[t];e[0]<s&&(s=e[0]),e[0]>r&&(r=e[0]),e[1]<o&&(o=e[1]),e[1]>a&&(a=e[1])}const h=this.__arrowFaceIndexes;for(let t=0;t<h.length;t++){const i=h[t];for(let t=0;t<3;t++){const h=e[i+t];h&&(h[0]<s&&(s=h[0]),h[0]>r&&(r=h[0]),h[1]<o&&(o=h[1]),h[1]>a&&(a=h[1]))}}const l=this.__measureLabelBoxForBounds();return l&&(l.x-l.halfW<s&&(s=l.x-l.halfW),l.x+l.halfW>r&&(r=l.x+l.halfW),l.y-l.halfH<o&&(o=l.y-l.halfH),l.y+l.halfH>a&&(a=l.y+l.halfH)),t[0]=s,t[1]=o,t[2]=r,t[3]=a,t}setState(t){if(isNil(t.width)||delete t.width,isNil(t.height)||delete t.height,isNil(t.transform)||delete t.transform,!isNil(t.left)){const e=t.left-this.state.points[0][0];for(let t=0;t<this.state.points.length;t++)this.state.points[t][0]+=e}if(!isNil(t.top)){const e=t.top-this.state.points[0][1];for(let t=0;t<this.state.points.length;t++)this.state.points[t][1]+=e}if(isNil(t.startPoint)||(this.state.points[0]=[...t.startPoint],this.state.left=this.state.points[0][0],this.state.top=this.state.points[0][1]),!isNil(t.endPoint)){const e=this.state.points.length;this.state.points[e-1]=[...t.endPoint]}isNil(t.startPoint)&&isNil(t.endPoint)||this.recalculateRoute(),isNil(t.links)||(merge(this.state.links,t.links),this.syncConnections()),super.setState(t)}static dirVector(t){switch(t){case"T":return[0,-1];case"B":return[0,1];case"L":return[-1,0];case"R":return[1,0];default:return[0,0]}}recalculateRoute(){if("orthogonal"!==this.state.routeType)return;const t=this.state.points[0],e=this.state.points[this.state.points.length-1],i=this.state.routeOffset||20,s=ICEPolyLine.dirVector(this.state.links&&this.state.links.start&&this.state.links.start.position),o=ICEPolyLine.dirVector(this.state.links&&this.state.links.end&&this.state.links.end.position),r=[t[0]+s[0]*i,t[1]+s[1]*i],a=[e[0]+o[0]*i,e[1]+o[1]*i],h=[t];0===s[0]&&0===s[1]||h.push(r),r[0]!==a[0]&&r[1]!==a[1]&&h.push([a[0],r[1]]),0===o[0]&&0===o[1]||h.push(a),h.push(e),this.state.points=h,this.paramsDirty=!0,this.dirty=!0}createPathObject(){this.ensureDots();const t=this.state.curveType||"straight",e=this.state.dots;if(this.path2D=p.createPath2D(),!e||0===e.length)return this.path2D;if(this.path2D.moveTo(e[0][0],e[0][1]),"quadratic"===t&&e.length>=3)this.path2D.quadraticCurveTo(e[1][0],e[1][1],e[2][0],e[2][1]);else if("cubic"===t&&e.length>=4)this.path2D.bezierCurveTo(e[1][0],e[1][1],e[2][0],e[2][1],e[3][0],e[3][1]);else for(let t=1;t<e.length;t++)this.path2D.lineTo(e[t][0],e[t][1]);return this.path2D}doRender(){const t=this.__arrowFaceIndexes.length>0&&"hollow"!==this.state.arrowStyle&&!1!==this.state.stroke,e=t?this.ctx.strokeStyle:null;super.doRender(),this.applyActiveTransform(),t&&this.drawArrowFills(e),this.drawLabel()}getArrowFaces(){const t=this.__arrowFaceIndexes,e=this.state.dots,i=[];if(!e||0===t.length)return i;for(let s=0;s<t.length;s++){const o=t[s],r=e[o],a=e[o+1],h=e[o+2];r&&a&&h&&i.push([[r[0],r[1]],[a[0],a[1]],[h[0],h[1]]])}return i}drawArrowFills(t){const e=this.getArrowFaces();if(!e.length)return;const i=this.ctx;i.save(),i.beginPath();for(let t=0;t<e.length;t++){const[s,o,r]=e[t];i.moveTo(s[0],s[1]),i.lineTo(o[0],o[1]),i.lineTo(r[0],r[1]),i.closePath()}i.fillStyle=t||this.state.style.strokeStyle||"#000000",i.fill(),i.restore()}__labelMetrics(){const t=this.state.label;if(!t)return null;const e=(this.state.labelStyle||{}).fontSize||14,i=this.getLabelPosition();let s=0;const o=this.ctx;return o&&"function"==typeof o.measureText?(o.font="".concat(e,"px Arial"),s=o.measureText(t).width):s=t.length*e,{x:i[0],y:i[1],halfW:s/2+4,halfH:e/2+4}}getLabelRenderInfo(){const t=this.__labelMetrics();if(!t)return null;const e=this.state.labelStyle||{};return _objectSpread2(_objectSpread2({text:String(this.state.label)},t),{},{fontSize:e.fontSize||14,fillStyle:e.fillStyle||"#000000",backgroundColor:e.backgroundColor||"#ffffff"})}__measureLabelBoxForBounds(){const t=this.ctx,e=!!t&&"font"in t,i=e?t.font:void 0,s=this.__labelMetrics();return e&&(t.font=i),s}drawLabel(){const t=this.state.label;if(!t)return;const e=this.ctx,i=this.state.labelStyle||{};e.save();const s=this.__labelMetrics();s?(e.textAlign="center",e.textBaseline="middle",e.fillStyle=i.backgroundColor||"#ffffff",e.fillRect(s.x-s.halfW,s.y-s.halfH,2*s.halfW,2*s.halfH),e.fillStyle=i.fillStyle||"#000000",e.fillText(t,s.x,s.y),e.restore()):e.restore()}getLabelPosition(){const t=this.state.points,e=t.length,i=this.state.left,s=this.state.top;if(0===e)return[0,0];if(1===e)return[t[0][0]-i,t[0][1]-s];let o,r;if(2===e)o=(t[0][0]+t[1][0])/2,r=(t[0][1]+t[1][1])/2;else{const i=t[Math.floor(e/2)];o=i[0],r=i[1]}return[o-i,r-s]}getRotateAngle(){if(this.isDotsOnSameLine()){const t=0,e=0,i=this.state.points.length,s=this.state.points[i-1][0]-this.state.points[0][0],o=this.state.points[i-1][1]-this.state.points[0][1];let r=GeoUtil.calcRotateAngle(s,o,t,e);return r+=90,r}return super.getRotateAngle()}containsPoint(t,e){const i=this.getLines();for(let s=0;s<i.length;s++){const o=i[s],r=o.o[0],a=o.o[1],h=o.d[0],l=o.d[1],c=Math.hypot(h-r,l-a),d=Math.hypot(r-t,a-e),u=Math.hypot(h-t,l-e);if(d+u>=c-3&&d+u<=c+3)return!0}return!1}getLines(){const t=[],e=this.getTransformedDots();if(!e||e.length<2)return t;for(let i=0;i<e.length-1;i++){const s={o:[e[i][0],e[i][1]],d:[e[i+1][0],e[i+1][1]]};t.push(s)}return t}destory(){this.evtBus&&this.evtBus.off(t.ROUND_FINISH,this.syncConnections,this),this.removeLink("start"),this.removeLink("end"),super.destory()}}var j=ICEPolyLine;class ICEBezier extends j{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=ICEBezier.arrangeParam(t),super(t)}static arrangeParam(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e="cubic"===t.curveType?"cubic":"quadratic",i=t.points&&t.points.length?t.points:ICEBezier.buildDefaultPoints(t,e);return _objectSpread2(_objectSpread2({},t),{},{curveType:e,points:i})}static buildDefaultPoints(t,e){const i=t.startPoint||[0,0],s=t.endPoint||[10,10];if("cubic"===e){return[i,t.controlPoint1||[5,-5],t.controlPoint2||[5,5],s]}return[i,t.controlPoint||[5,-5],s]}}var W=class ICELinkSlot extends T{constructor(){super(_objectSpread2({linkable:!1,draggable:!1,position:"T"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})),_defineProperty(this,"__onHostRemoved",()=>{this._hostComponent=null,this.setState({display:!1})})}keyboardEvtHandler(t){}destory(){this.hostComponent=null,super.destory()}updatePosition(){const t=this._hostComponent.getMinBoundingBox(!0);let e=0,i=0;switch(this.state.position){case"T":e=t.tc[0]-this.state.radius,i=t.tc[1]-this.state.radius;break;case"R":e=t.rc[0]-this.state.radius,i=t.rc[1]-this.state.radius;break;case"B":e=t.bc[0]-this.state.radius,i=t.bc[1]-this.state.radius;break;case"L":e=t.lc[0]-this.state.radius,i=t.lc[1]-this.state.radius;break;case"C":e=t.center[0]-this.state.radius,i=t.center[1]-this.state.radius}this.state.left===e&&this.state.top===i||this.setState({left:e,top:i})}set hostComponent(e){const i=this._hostComponent;i&&(i.off(t.AFTER_RENDER,this.updatePosition,this),i.off(t.BEFORE_REMOVE,this.__onHostRemoved,this)),this._hostComponent=e,e&&(e.on(t.AFTER_RENDER,this.updatePosition,this),e.on(t.BEFORE_REMOVE,this.__onHostRemoved,this),this.setState({display:!0}))}get hostComponent(){return this._hostComponent}};class ICEVisioLink extends j{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=ICEVisioLink.arrangeParam(t),super(t)}static arrangeParam(t){return isNil(t.startPoint)&&(t.startPoint=[0,0]),isNil(t.endPoint)&&(t.endPoint=[10,10]),t.points=[[...t.startPoint],[...t.endPoint]],"bezier"===(t=_objectSpread2({escapeDistance:30,linkShape:"visio"},t)).linkShape&&(t.curveType="straight"),t}__calcDots(){if("bezier"===this.state.linkShape)return this.__calcBezierDots();const t=this.interpolate(),{left:e,top:i}=this.state,s=t[0][2];this.state.points=[],this.state.dots=[];for(let t=0;t<s.length;t++){const o=s[t];this.state.points.push([o.x,o.y]),this.state.dots.push([o.x-e,o.y-i])}return this.calcArrowPoints(),this.state.dots}__calcBezierDots(){const t=this.state.points,e=[...t[0]],i=[...t[t.length-1]],{left:s,top:o}=this.state,r=this.buildBezierPoints(e,i);return this.state.points=r.map(t=>[...t]),this.state.dots=r.map(t=>[t[0]-s,t[1]-o]),this.state.curveType="straight",this.calcArrowPoints(),this.state.dots}buildBezierPoints(t,e){const i=e[0]-t[0],s=e[1]-t[1],o=Math.hypot(i,s);if(o<1e-6)return[[...t],[...e]];const r=[i/o,s/o],a=Math.max(.45*o,24),h=this.slotDirection("start",r),l=this.slotDirection("end",r),c=[t[0]+h[0]*a,t[1]+h[1]*a],d=[e[0]+l[0]*a,e[1]+l[1]*a],u=Math.min(24,Math.max(8,Math.round(o/12))),p=[];for(let i=0;i<=u;i++){const s=i/u,o=1-s,r=o*o*o*t[0]+3*o*o*s*c[0]+3*o*s*s*d[0]+s*s*s*e[0],a=o*o*o*t[1]+3*o*o*s*c[1]+3*o*s*s*d[1]+s*s*s*e[1];p.push([round(r,2),round(a,2)])}return p.filter((t,e)=>0===e||t[0]!==p[e-1][0]||t[1]!==p[e-1][1])}slotDirection(t,e){const i=this.state.links&&this.state.links[t],s=j.dirVector(i&&i.position);return 0!==s[0]||0!==s[1]?s:"start"===t?e:[-e[0],-e[1]]}recalculateRoute(){"bezier"!==this.state.linkShape&&super.recalculateRoute()}interpolate(){const t=this.state.points.length,e=this.state.points[0][0],i=this.state.points[0][1],s=this.state.points[t-1][0],o=this.state.points[t-1][1],r=new GeoPoint(e,i),a=new GeoPoint(s,o),h=[];let l,c,d=null,u=null,p=[],f=new _,g=new _;if(this.ice&&this.state.links&&this.state.links.start&&this.state.links.start.id&&(l=this.ice.findComponent(this.state.links.start.id)),l){f=l.getMinBoundingBox(),h[0]=new GeoPoint(r.x,f.tl[1]-this.state.escapeDistance),h[1]=new GeoPoint(f.tr[0]+this.state.escapeDistance,r.y),h[2]=new GeoPoint(r.x,f.br[1]+this.state.escapeDistance),h[3]=new GeoPoint(f.tl[0]-this.state.escapeDistance,r.y),d=h[0];for(let t=1;t<h.length;t++)this.distance(r,h[t])<this.distance(r,d)&&(d=h[t])}if(this.ice&&this.state.links&&this.state.links.end&&this.state.links.end.id&&(c=this.ice.findComponent(this.state.links.end.id)),c){g=c.getMinBoundingBox(),h[0]=new GeoPoint(a.x,g.tl[1]-this.state.escapeDistance),h[1]=new GeoPoint(g.tr[0]+this.state.escapeDistance,a.y),h[2]=new GeoPoint(a.x,g.br[1]+this.state.escapeDistance),h[3]=new GeoPoint(g.tl[0]-this.state.escapeDistance,a.y),u=h[0];for(let t=1;t<h.length;t++)this.distance(a,h[t])<this.distance(a,u)&&(u=h[t])}let m=0;const y=[r];d&&(y.push(d),m=1),u&&y.push(u),y.push(a);const x=GeoPoint.cloneArray(y);p.push(["s0","s0",x]);const b=GeoPoint.cloneArray(y),v=GeoPoint.cloneArray(b);v.splice(m+1,0,new GeoPoint(v[m].x,v[m+1].y)),p.push(["s1","s1_1",v]);const E=GeoPoint.cloneArray(b);E.splice(m+1,0,new GeoPoint(E[m+1].x,E[m].y)),p.push(["s1","s1_2",E]);const C=GeoPoint.cloneArray(b),w=new GeoPoint((C[m].x+C[m+1].x)/2,C[m].y),M=new GeoPoint((C[m].x+C[m+1].x)/2,C[m+1].y);C.splice(m+1,0,w,M),p.push(["s2","s2_1",C]);const S=GeoPoint.cloneArray(b),P=new GeoPoint(S[m].x,(S[m].y+S[m+1].y)/2),T=new GeoPoint(S[m+1].x,(S[m].y+S[m+1].y)/2);S.splice(m+1,0,P,T),p.push(["s2","s2_2",S]);const I=GeoPoint.cloneArray(b),B=[I[m].x+20,I[m+1].x+20];f&&B.push(f.br[0]+20),g&&B.push(g.br[0]+20);const O=this.max(B),R=new GeoPoint(O,I[m].y),A=new GeoPoint(O,I[m+1].y);I.splice(m+1,0,R,A),p.push(["s2","s2_3",I]);const k=GeoPoint.cloneArray(b),D=[k[m].y-20,k[m+1].y-20];f&&D.push(f.tl[1]-20),g&&D.push(g.tl[1]-20);const N=this.min(D),F=new GeoPoint(k[m].x,N),L=new GeoPoint(k[m+1].x,N);k.splice(m+1,0,F,L),p.push(["s2","s2_4",k]);const X=GeoPoint.cloneArray(b),z=[X[m].x-20,X[m+1].x-20];f&&z.push(f.tl[0]-20),g&&z.push(g.tl[0]-20);const V=this.min(z),H=new GeoPoint(V,X[m].y),Y=new GeoPoint(V,X[m+1].y);X.splice(m+1,0,H,Y),p.push(["s2","s2_5",X]);const G=GeoPoint.cloneArray(b),j=[G[m].y+20,G[m+1].y+20];f&&j.push(f.tl[1]+f.height+20),g&&j.push(g.tl[1]+g.height+20);const W=this.max(j),U=new GeoPoint(G[m].x,W),K=new GeoPoint(G[m+1].x,W);G.splice(m+1,0,U,K),p.push(["s2","s2_6",G]);const q=[];for(let t=0;t<p.length;t++){const e=p[t][2];this.orthogonalPath(e)&&q.push(p[t])}if(p=q,!r.equals(a)){const t=[];for(let e=0;e<p.length;e++){const i=p[e][2];this.forwardPath(i)&&t.push(p[e])}p=t,p.length}const Q=[];for(let t=0;t<p.length;t++){let e=!1,i=p[t][2].slice();(g||f)&&(i=i.slice(1,i.length-1)),f&&(e=e||this.polylineIntersectsRectangle(i,f)),g&&(e=e||this.polylineIntersectsRectangle(i,g)),e||Q.push(p[t])}0!=Q.length&&(p=Q),p.length;const J=p[0][2].length,Z=[];for(let t=0;t<p.length;t++){p[t][2].length==J&&Z.push(p[t])}p=Z;let $=0;for(let t=0;t<p.length;t++)this.scorePath(p[$][2])<this.scorePath(p[t][2])&&($=t);return p=[p[$]],p}orthogonalPath(t){if(t.length<=1)return!0;for(let e=0;e<t.length-1;e++)if(t[e].x!=t[e+1].x&&t[e].y!=t[e+1].y)return!1;return!0}lineIntersectsLine(t,e){if(t.startPoint.x==t.endPoint.x&&e.startPoint.x==e.endPoint.x)return t.startPoint.x==e.startPoint.x&&(t.contains(e.startPoint.x,e.startPoint.y)||t.contains(e.endPoint.x,e.endPoint.y));if(t.startPoint.x==t.endPoint.x||e.startPoint.x==e.endPoint.x){if(t.startPoint.x==t.endPoint.x){const i=t;t=e,e=i}const i=(t.endPoint.y-t.startPoint.y)/(t.endPoint.x-t.startPoint.x),s=t.startPoint.y-i*t.startPoint.x,o=e.startPoint.x,r=i*o+s;return t.contains(o,r)&&e.contains(o,r)}{const i=(t.endPoint.y-t.startPoint.y)/(t.endPoint.x-t.startPoint.x),s=t.startPoint.y-i*t.startPoint.x,o=(e.endPoint.y-e.startPoint.y)/(e.endPoint.x-e.startPoint.x),r=e.startPoint.y-o*e.startPoint.x;if(i==o)return s==r&&(t.contains(e.startPoint.x,e.startPoint.y)||t.contains(e.endPoint.x,e.endPoint.y));{const a=(r-s)/(i-o),h=i*a+s;return t.contains(a,h)&&e.contains(a,h)}}}polylineIntersectsRectangle(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=[];s.push(new GeoLine(new GeoPoint(e.x1,e.y1),new GeoPoint(e.x2,e.y1))),s.push(new GeoLine(new GeoPoint(e.x2,e.y1),new GeoPoint(e.x2,e.y2))),s.push(new GeoLine(new GeoPoint(e.x2,e.y2),new GeoPoint(e.x1,e.y2))),s.push(new GeoLine(new GeoPoint(e.x1,e.y2),new GeoPoint(e.x1,e.y1)));for(let e=0;e<t.length-1;e++){const i=new GeoLine(t[e],t[e+1]);for(let t=0;t<s.length;t++)if(this.lineIntersectsLine(i,s[t]))return!0}if(i){const e=new GeoLine(t[t.length-1],t[0]);for(let t=0;t<s.length;t++)if(this.lineIntersectsLine(e,s[t]))return!0}return!1}scorePath(t){if(t.length<=2)return-1;let e=0;for(let i=1;i<t.length-1;i++)if(t[i-1].x==t[i].x&&t[i].x==t[i+1].x){if(this.signum(t[i+1].y-t[i].y)!=this.signum(t[i].y-t[i-1].y))return-1;e++}else if(t[i-1].y==t[i].y&&t[i].y==t[i+1].y){if(this.signum(t[i+1].x-t[i].x)!=this.signum(t[i].x-t[i-1].x))return-1;e++}else e--;return e}signum(t){return t>0?1:t<0?-1:0}forwardPath(t){if(t.length<=2)return!0;for(let e=0;e<t.length-2;e++)if(t[e].x==t[e+1].x&&t[e+1].x==t[e+2].x){if(0!=this.signum(t[e+1].y-t[e].y)&&this.signum(t[e+1].y-t[e].y)==-1*this.signum(t[e+2].y-t[e+1].y))return!1}else if(t[e].y==t[e+1].y&&t[e+1].y==t[e+2].y&&0!=this.signum(t[e+1].x-t[e].x)&&this.signum(t[e+1].x-t[e].x)==-1*this.signum(t[e+2].x-t[e+1].x))return!1;return!0}distance(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}max(t){if(0==t.lenght)return NaN;{let e=t[0];for(let i=0;i<t.length;i++)e<t[i]&&(e=t[i]);return e}}min(t){if(0==t.lenght)return NaN;{let e=t[0];for(let i=0;i<t.length;i++)e>t[i]&&(e=t[i]);return e}}addDot(t,e){throw new Error("Can NOT add dot to ICEVisioLink mannually.")}rmDot(t){throw new Error("Can NOT remove dot from ICEVisioLink mannually.")}}var U=class ICEIsogon extends ICEDotPath{constructor(){const t=_objectSpread2({radius:10,edges:3,startAngle:90},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});t.edges=Math.floor(t.edges>=3?t.edges:3),t.width=2*t.radius,t.height=2*t.radius,super(t)}__calcDots(){this.state.dots=[];const t=2*Math.PI/this.state.edges,e=this.state.radius;for(let i=0;i<this.state.edges;i++){const s=t*i-toRadian(this.state.startAngle),o=Math.floor(e*Math.cos(s)+e),r=Math.floor(e*Math.sin(s)+e);this.state.dots.push([o,r])}return this.state.dots}calcComponentParams(){return this.paramsDirty?(this.calcDots(),this.state.width=2*this.state.radius,this.state.height=2*this.state.radius,{width:this.state.width,height:this.state.height}):{width:this.state.width,height:this.state.height}}setState(t){isNil(t.radius)?isNil(t.width)?isNil(t.height)||(t.radius=t.height/2):t.radius=t.width/2:(t.width=2*t.radius,t.height=2*t.radius),super.setState(t)}};var K=class ICERose extends ICEDotPath{constructor(){const t=_objectSpread2({radius:50,leafNum:2,pointNumber:100},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});t.leafNum=Math.floor(t.leafNum>=2?t.leafNum:2),t.width=2*t.radius,t.height=2*t.radius,super(t)}__calcDots(){const t=this.state.radius,e=this.state.leafNum;this.state.dots=[];const i=Math.PI/this.state.pointNumber;let s=0,o=0,r=0;for(;s=t+t*Math.sin(e*r)*Math.cos(r),o=t+t*Math.sin(e*r)*Math.sin(r),this.state.dots.push([s,o]),r+=i,!(r>=2*Math.PI););return this.state.dots}calcComponentParams(){return this.paramsDirty?(this.calcDots(),this.state.width=2*this.state.radius,this.state.height=2*this.state.radius,{width:this.state.width,height:this.state.height}):{width:this.state.width,height:this.state.height}}setState(t){isNil(t.radius)?isNil(t.width)?isNil(t.height)||(t.radius=t.height/2,t.width=t.height):(t.radius=t.width/2,t.height=t.width):(t.width=2*t.radius,t.height=2*t.radius),super.setState(t)}};var q=class ICEStar extends ICEDotPath{constructor(){const t=_objectSpread2({outerRadius:50,innerRadius:20,startAngle:90,spikes:5},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});t.spikes=Math.floor(t.spikes>=1?t.spikes:1),t.width=2*t.outerRadius,t.height=2*t.outerRadius,super(t)}__calcDots(){this.state.dots=[];let t=toRadian(this.state.startAngle);const e=Math.PI/this.state.spikes,i=this.state.outerRadius,s=this.state.innerRadius;let o,r;for(let a=0;a<this.state.spikes;a++)o=Math.cos(t)*i+i,r=Math.sin(t)*i+i,this.state.dots.push([o,r]),t+=e,o=Math.cos(t)*s+i,r=Math.sin(t)*s+i,this.state.dots.push([o,r]),t+=e;return this.state.dots}calcComponentParams(){return this.paramsDirty?(this.calcDots(),this.state.width=2*this.state.outerRadius,this.state.height=2*this.state.outerRadius,{width:this.state.width,height:this.state.height}):{width:this.state.width,height:this.state.height}}setState(t){isNil(t.outerRadius)?isNil(t.width)?isNil(t.height)||(t.outerRadius=t.height/2):t.outerRadius=t.width/2:(t.width=2*t.outerRadius,t.height=2*t.outerRadius),super.setState(t)}};const Q="__ICE_UTILS_TEXT_MEASURE_DIV__";class ICEText extends C{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(ICEText.arrangeParam(t)),_defineProperty(this,"__originalDraggable",!0),_defineProperty(this,"__editInput",null),this.measureText()}static arrangeParam(t){const e=merge({text:"",left:0,top:0,width:10,height:10,editing:!1,caretIndex:0,wrap:!1,maxLines:0,ellipsis:"…",lines:null,transformable:!1,style:{fontWeight:"bold",fontSize:32,fontFamily:"Arial",lineWidth:1,textBaseline:"bottom",paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0}},t);return e.style=_objectSpread2(_objectSpread2({},e.style),{},{font:"".concat(e.style.fontWeight," ").concat(e.style.fontSize,"px ").concat(e.style.fontFamily)}),e}initEvents(){super.initEvents(),this.on("dblclick",this.startEditing,this)}startEditing(){this.__originalDraggable=this.state.draggable,this.setState({editing:!0,caretIndex:this.state.text.length,draggable:!1}),this.ice&&this.ice.controlPanelManager&&this.ice.controlPanelManager.transformControlPanel.disable(),this.ice&&this.ice.evtBus&&this.ice.evtBus.on("mousedown",this.__globalMouseDownHandler,this),this.__mountEditInput()}stopEditing(){this.ice&&this.ice.evtBus&&this.ice.evtBus.off("mousedown",this.__globalMouseDownHandler,this),this.__unmountEditInput(),this.setState({editing:!1,draggable:this.__originalDraggable})}__mountEditInput(){const t=this.root&&this.root.document;if(!t||!t.body)return;const e=this.getMinBoundingBox(!0),i=this.ice&&this.ice.canvasEl?this.ice.canvasEl.getBoundingClientRect():{left:0,top:0},{paddingTop:s,paddingRight:o,paddingBottom:r,paddingLeft:a}=this.state.style,h=Math.max(this.state.width-a-o,1),l=Math.max(this.state.height-s-r,this.state.style.fontSize),c=t.createElement("input");c.type="text",c.value=this.state.text,c.style.position="absolute",c.style.left=i.left+e.tl[0]+"px",c.style.top=i.top+e.tl[1]+"px",c.style.width=h+"px",c.style.height=l+"px",c.style.font=this.state.style.font,c.style.paddingTop=s+"px",c.style.paddingRight=o+"px",c.style.paddingBottom=r+"px",c.style.paddingLeft=a+"px",c.style.boxSizing="content-box",c.style.color="transparent",c.style.caretColor=this.state.style.fillStyle||"#000000",c.style.background="transparent",c.style.border="none",c.style.outline="none",c.style.margin="0",c.style.zIndex="9999",t.body.appendChild(c),c.focus(),c.setSelectionRange(c.value.length,c.value.length),c.addEventListener("input",()=>{this.setText(c.value)}),c.addEventListener("compositionend",()=>{this.setText(c.value)}),c.addEventListener("keydown",t=>{"Enter"!==t.key&&"Escape"!==t.key||t.isComposing||this.stopEditing()}),c.addEventListener("blur",()=>{this.stopEditing()}),this.__editInput=c}__unmountEditInput(){this.__editInput&&this.__editInput.parentNode&&this.__editInput.parentNode.removeChild(this.__editInput),this.__editInput=null}__globalMouseDownHandler(t){(t&&t.param&&t.param.component)!==this&&this.stopEditing()}setText(t){const e=Math.max(0,Math.min(this.state.caretIndex,t.length));return this.setState({text:t,caretIndex:e}),this}getText(){return this.state.text}keyboardEvtHandler(t){if(this.__editInput)return;if(!this.state.editing)return void super.keyboardEvtHandler(t);if("keydown"!==t.type)return;const e=t.key,i=this.state.text,s=this.state.caretIndex;"Enter"!==e&&"Escape"!==e?"Backspace"!==e?"Delete"!==e?"ArrowLeft"!==e?"ArrowRight"!==e?"Home"!==e?"End"!==e?e&&1===e.length&&this.setState({text:i.slice(0,s)+e+i.slice(s),caretIndex:s+1}):this.setState({caretIndex:i.length}):this.setState({caretIndex:0}):this.setState({caretIndex:Math.min(i.length,s+1)}):this.setState({caretIndex:Math.max(0,s-1)}):s<i.length&&this.setState({text:i.slice(0,s)+i.slice(s+1)}):s>0&&this.setState({text:i.slice(0,s-1)+i.slice(s),caretIndex:s-1}):this.stopEditing()}renderCaret(){if(this.__editInput)return;const{paddingTop:t,paddingBottom:e,paddingLeft:i}=this.state.style,s=this.state.text.slice(0,this.state.caretIndex);let o=0-this.state.localOrigin[0]+i;"function"==typeof this.ctx.measureText&&(o+=this.ctx.measureText(s).width);const r=0-this.state.localOrigin[1]+t,a=0-this.state.localOrigin[1]+this.state.height-e;this.ctx.save(),this.ctx.strokeStyle=this.state.style.fillStyle||"#000000",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(o,r),this.ctx.lineTo(o,a),this.ctx.stroke(),this.ctx.restore()}calcComponentParams(){return this.paramsDirty?this.measureText():{width:this.state.width,height:this.state.height}}measureText(t){this.state.lines=this.__computeWrappedLines();const e=this.__measureByCanvas();return e?(this.__applyMeasuredSize(e),{width:this.state.width,height:this.state.height}):this.__measureByDOM()}__computeWrappedLines(){var t;if(!this.state.wrap||this.state.editing)return null;const e=Number(this.state.width);if(!(e>0))return null;const i=this.ctx;if(!i||"function"!=typeof i.measureText)return null;const s=this.__measureFn(),o=this.__wrapText(e,s);return this.__truncateLines(o,e,Number(this.state.maxLines)||0,String(null!==(t=this.state.ellipsis)&&void 0!==t?t:"…"),s)}__measureFn(){const t=this.ctx;this.state.style.font&&t&&"function"==typeof t.measureText&&(t.font=this.state.style.font);const e=Number(this.state.style.fontSize)||12;return i=>{if(t&&"function"==typeof t.measureText){const e=t.measureText(i);return e&&e.width||0}return i.length*e}}__graphemes(t){const e=this.root&&this.root.Intl;if(e&&"function"==typeof e.Segmenter)try{const i=new e.Segmenter(void 0,{granularity:"grapheme"}),s=[];for(const e of i.segment(t))s.push(e.segment);return s}catch(t){}return Array.from(t)}__wrapText(t,e){var i;const s=[],o=String(null!==(i=this.state.text)&&void 0!==i?i:"").split("\n");for(let i=0;i<o.length;i++){const r=this.__graphemes(o[i]);let a="";for(let i=0;i<r.length;i++){const o=a+r[i];""!==a&&e(o)>t?(s.push(a),a=r[i]):a=o}s.push(a)}return s}__truncateLines(t,e,i,s,o){if(!(i>0)||t.length<=i)return t;const r=t.slice(0,i),a=this.__graphemes(r[i-1]);for(;a.length>0&&o(a.join("")+s)>e;)a.pop();return r[i-1]=a.join("")+s,r}__measureByCanvas(){var t;if(!this.ctx||"function"!=typeof this.ctx.measureText)return null;this.state.style.font&&(this.ctx.font=this.state.style.font);const e=this.state.lines||String(null!==(t=this.state.text)&&void 0!==t?t:"").split("\n");let i=0,s=0,o=0;for(const t of e){const e=this.ctx.measureText(t);i=Math.max(i,e.width||0);const r=e.actualBoundingBoxAscent,a=e.actualBoundingBoxDescent;if("number"!=typeof r||"number"!=typeof a)return null;s=Math.max(s,r),o=Math.max(o,a)}const r=s+o;if(e.length<=1)return{textWidth:i,textHeight:r};const a=Number(this.state.style.fontSize)||r||12;return{textWidth:i,textHeight:Math.max(r,a*ICEText.LINE_HEIGHT_RATIO)*e.length}}__applyMeasuredSize(t){const{paddingTop:e,paddingBottom:i,paddingLeft:s,paddingRight:o}=this.state.style,r=t.textWidth+s+o,a=t.textHeight+e+i;10===this.props.width&&(this.state.width=r),10===this.props.height&&(this.state.height=a),this.state.textHeight=t.textHeight}__measureByDOM(){let t;try{const e=this.root&&this.root.document;if(!e||"function"!=typeof e.getElementById)return{width:this.state.width,height:this.state.height};if(t=this.root.document.getElementById(Q),!t){t=this.root.document.createElement("div"),t.setAttribute("id",Q);const e={visibility:"hidden",position:"absolute",top:"0",left:"0",padding:"0",margin:"0",border:"none",fontFamily:this.state.style.fontFamily,fontWeight:this.state.style.fontWeight,fontSize:this.state.style.fontSize+"px",lineHeight:"1",whiteSpace:"pre"};for(const i in e)t.style[i]=e[i];t.contenteditable=!1,this.root.document.body.appendChild(t)}t.textContent=this.state.text;const{paddingTop:i,paddingBottom:s,paddingLeft:o,paddingRight:r}=this.state.style,a={width:t.offsetWidth+o+r,height:t.offsetHeight+i+s};return 10===this.props.width&&(this.state.width=a.width),10===this.props.height&&(this.state.height=a.height),this.state.textHeight=t.offsetHeight,{width:this.state.width,height:this.state.height}}catch(t){return{width:this.state.width,height:this.state.height}}}getRenderLines(){var t;const{paddingTop:e,paddingLeft:i,paddingRight:s,textAlign:o,textBaseline:r}=this.state.style,a=this.state.lines||String(null!==(t=this.state.text)&&void 0!==t?t:"").split("\n"),h=(this.state.textHeight||this.state.style.fontSize)/a.length,l="center"===o||"right"===o||"end"===o,c=l?this.__measureFn():null,d=[];for(let t=0;t<a.length;t++){let u=0-this.state.localOrigin[0]+i;if(l){const e=c&&c(a[t])||0;u="center"===o?-e/2:this.state.localOrigin[0]-s-e}let p=0-this.state.localOrigin[1]+e+(t+1)*h;"middle"===r&&(p=(t-(a.length-1)/2)*h),d.push({text:a[t],x:u,y:p})}return d}doRender(){this.dirty&&this.measureText();const{textAlign:t}=this.state.style,e=this.getRenderLines();("center"===t||"right"===t||"end"===t)&&(this.ctx.textAlign="left");for(let t=0;t<e.length;t++)this.state.stroke&&this.ctx.strokeText(e[t].text,e[t].x,e[t].y,this.state.width),this.state.fill&&this.ctx.fillText(e[t].text,e[t].x,e[t].y,this.state.width);this.state.editing&&this.renderCaret(),super.doRender()}}_defineProperty(ICEText,"LINE_HEIGHT_RATIO",1.35);var J=ICEText;var Z=class ICELayoutManager{getPreferredSize(t){return[0,0]}};var $=class ICEFlowLayout extends Z{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.gap=t.gap||10,this.align=t.align||"left"}layoutContainer(t){const e=t.childNodes,i=t.state.width,s=this.gap,o=[[]];let r=0;for(const t of e){const e=t.state.width;r>0&&r+s+e>i&&(o.push([]),r=0),o[o.length-1].push(t),r+=r>0?s+e:e}let a=0;for(const t of o){let e=0,o=0;for(const i of t)e+=i.state.width,o=Math.max(o,i.state.height);e+=s*(t.length-1);let r=0;"center"===this.align?r=(i-e)/2:"right"===this.align&&(r=i-e);for(const e of t)e.setState({left:r,top:a}),r+=e.state.width+s;a+=o+s}}};var tt=class ICEGridLayout extends Z{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.cols=t.cols||2,this.gapX=t.gapX||10,this.gapY=t.gapY||10}layoutContainer(t){const e=t.childNodes;let i=0,s=0,o=0,r=0;for(const t of e)t.setState({left:i,top:s}),i+=t.state.width+this.gapX,o=Math.max(o,t.state.height),r++,r>=this.cols&&(r=0,i=0,s+=o+this.gapY,o=0)}};var et=class ICEBorderLayout extends Z{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.gap=t.gap||5}layoutContainer(t){const e=t.childNodes,i=t.state.width,s=t.state.height;let o=null,r=null,a=null,h=null,l=null;e.forEach(t=>{const e=t.state.layoutConstraint||"center";"north"===e?o=t:"south"===e?r=t:"east"===e?a=t:"west"===e?h=t:l=t});let c=0,d=s,u=0,p=i;o&&(o.setState({left:0,top:0,width:i}),c=o.state.height+this.gap),r&&(r.setState({left:0,top:s-r.state.height,width:i}),d=s-r.state.height-this.gap),a&&(a.setState({left:i-a.state.width,top:c,height:d-c}),p=i-a.state.width-this.gap),h&&(h.setState({left:0,top:c,height:d-c}),u=h.state.width+this.gap),l&&l.setState({left:u,top:c,width:p-u,height:d-c})}};var it=class ICEBoxLayout extends Z{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.axis=t.axis||"x",this.gap=t.gap||5}layoutContainer(t){let e=0;for(const i of t.childNodes)"x"===this.axis?(i.setState({left:e,top:0}),e+=i.state.width+this.gap):(i.setState({left:0,top:e}),e+=i.state.height+this.gap)}};var st=class ICECardLayout extends Z{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),_defineProperty(this,"currentIndex",0),_defineProperty(this,"container",null),this.currentIndex=t.currentIndex||0}layoutContainer(t){this.container=t,t.childNodes.forEach((t,e)=>{t.setState({display:e===this.currentIndex,left:0,top:0})})}show(t){this.currentIndex=t,this.container&&this.layoutContainer(this.container)}next(){this.show(this.currentIndex+1)}previous(){this.show(this.currentIndex-1)}};var nt=class ICEOverlayLayout extends Z{layoutContainer(t){for(const e of t.childNodes)e.setState({left:0,top:0})}};var ot=class ICELayeredLayout extends Z{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.gapX=t.gapX||80,this.gapY=t.gapY||40}layoutContainer(t){const e=t.childNodes||[],i=[],s=[];for(const t of e)if(t.isLine){const e=t.getLinkFromId?t.getLinkFromId():null,i=t.getLinkToId?t.getLinkToId():null;s.push({from:e,to:i,component:t})}else i.push({id:t.props.id,component:t,rank:0,order:0,barycenter:0});if(0===i.length)return;const o={};i.forEach(t=>o[t.id]=t);const r=s.filter(t=>t.from&&t.to&&o[t.from]&&o[t.to]);this.assignRanks(i,r),this.assignOrders(i,r,o),this.assignCoords(i,r,o)}assignRanks(t,e){const i={},visit=(t,s)=>{if(void 0!==i[t])return i[t];if(s.has(t))return 0;s.add(t);const o=e.filter(e=>e.to===t).map(t=>t.from);let r=-1;for(const t of o)r=Math.max(r,visit(t,s));return i[t]=r+1,s.delete(t),i[t]};t.forEach(t=>{t.rank=visit(t.id,new Set)})}assignOrders(t,e,i){const s={};t.forEach(t=>{(s[t.rank]=s[t.rank]||[]).push(t)});const o=Object.keys(s).map(Number).sort((t,e)=>t-e);o.forEach(t=>s[t].forEach((t,e)=>t.order=e));for(let t=0;t<4;t++)for(const t of o){const o=s[t];o.forEach(t=>{const s=e.filter(e=>e.from===t.id).map(t=>i[t.to]);t.barycenter=s.length?s.reduce((t,e)=>t+e.order,0)/s.length:t.order}),o.sort((t,e)=>t.barycenter-e.barycenter),o.forEach((t,e)=>t.order=e)}}assignCoords(t,e,i){const s={};t.forEach(t=>{(s[t.rank]=s[t.rank]||[]).push(t)});const o=Object.keys(s).map(Number).sort((t,e)=>t-e),r=this.gapX,a=this.gapY;let h=0;o.forEach(t=>{const e=s[t],i=Math.max(...e.map(t=>t.component.state.width));let o=0;e.forEach(t=>{t.component.setState({left:h,top:o}),o+=t.component.state.height+a}),h+=i+r});for(const t of e){const e=i[t.from].component,s=i[t.to].component,o=e.state.left+e.state.width,r=e.state.top+e.state.height/2,a=s.state.left,h=s.state.top+s.state.height/2;t.component.setState({startPoint:[o,r],endPoint:[a,h]})}}};const rt=[{typeId:"ice-render:Rect",ctor:M},{typeId:"ice-render:Circle",ctor:T},{typeId:"ice-render:Ellipse",ctor:P},{typeId:"ice-render:Star",ctor:q},{typeId:"ice-render:Isogon",ctor:U},{typeId:"ice-render:Rose",ctor:K},{typeId:"ice-render:Text",ctor:J},{typeId:"ice-render:Image",ctor:G},{typeId:"ice-render:Group",ctor:S},{typeId:"ice-render:VisioLink",ctor:ICEVisioLink},{typeId:"ice-render:PolyLine",ctor:j},{typeId:"ice-render:Bezier",ctor:ICEBezier}],at={};for(let t=0;t<rt.length;t++){const e=rt[t];at[e.typeId]=e.ctor}const ht={evtBuses:[],stopped:!1,frameCallback:function(){for(let e=0;e<ht.evtBuses.length;e++){if(ht.stopped)return;ht.evtBuses[e].trigger(t.ICE_FRAME_EVENT)}ht.stopped||p.requestFrame(ht.frameCallback)},start:function(){ht.stopped=!1,p.requestFrame(ht.frameCallback)},stop:function(){ht.stopped=!0},registerEvtBus:function(t){ht.evtBuses.includes(t)||ht.evtBuses.push(t)},delEvtBus:function(t){ht.evtBuses.includes(t)&&ht.evtBuses.splice(ht.evtBuses.indexOf(t),1)}};var lt=ht;class ICELinkSlotManager{constructor(t){_defineProperty(this,"slotRadius",10),this.ice=t}start(){return this.createLinkSlots(),this.ice.evtBus.on(t.HOOK_MOUSEMOVE,this.hookMouseMoveHandler,this),this.ice.evtBus.on(t.HOOK_MOUSEUP,this.hookMouseUpHandler,this),this.ice.evtBus.on("mouseup",this.globalMouseUpHandler,this),this}stop(){return this.ice.evtBus.off(t.HOOK_MOUSEMOVE,this.hookMouseMoveHandler,this),this.ice.evtBus.off(t.HOOK_MOUSEUP,this.hookMouseUpHandler,this),this.ice.evtBus.off("mouseup",this.globalMouseUpHandler,this),this}hookMouseMoveHandler(t){const e=t.target,i=e.getMaxBoundingBox(),s=flattenTree([],this.ice.childNodes);s.sort((t,e)=>t.state.zIndex-e.state.zIndex),this.collision=null;for(let t=0;t<s.length;t++){const e=s[t];if(!e||!e.state.linkable||!isEffectivelyVisible(e))continue;e.getMaxBoundingBox().isIntersect(i)&&(this.collision=e)}if(!this.collision){for(let t=0;t<this.ice._linkSlots.length;t++){this.ice._linkSlots[t].setState({display:!1,style:{fillStyle:"#3ce92c"}})}return void e.setState({style:{fillStyle:"#3ce92c"}})}let o=!1;for(let t=0;t<this.ice._linkSlots.length;t++){const s=this.ice._linkSlots[t];s.hostComponent!==this.collision&&(s.hostComponent=this.collision),s.setState({display:!0,style:{fillStyle:"#3ce92c"}}),e.setState({style:{fillStyle:"#3ce92c"}});s.getMaxBoundingBox().isIntersect(i)&&(o=!0,s.setState({style:{fillStyle:"#fffb00"}}))}o&&e.setState({style:{fillStyle:"#fffb00"}})}hookMouseUpHandler(t){const e=t.target,i=e.state.position,s=e.parentNode.targetComponent,o=e.getMaxBoundingBox();let r=!1;if(this.collision)for(let t=0;t<this.ice._linkSlots.length;t++){const e=this.ice._linkSlots[t];e.setState({display:!1,style:{fillStyle:"#3ce92c"}});if(e.getMaxBoundingBox().isIntersect(o)){r=!0;const t={};t[i]={id:e.hostComponent.state.id,position:e.state.position},s&&s.setState({links:t});break}}if(r)e.setState({display:!1,style:{fillStyle:"#3ce92c"}});else{const t={};t[i]=null,s&&s.setState({links:t})}this.collision=null}globalMouseUpHandler(t){for(let t=0;t<this.ice._linkSlots.length;t++){this.ice._linkSlots[t].setState({display:!1,style:{fillStyle:"#3ce92c"}})}}createLinkSlots(){if(this.ice._linkSlots&&this.ice._linkSlots.length)return;const t=new W({zIndex:10000010,display:!1,transformable:!1,draggable:!1,radius:this.slotRadius,position:"T",style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1}});this.ice.addTool(t);const e=new W({zIndex:10000011,display:!1,transformable:!1,draggable:!1,radius:this.slotRadius,position:"R",style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1}});this.ice.addTool(e);const i=new W({zIndex:10000012,display:!1,transformable:!1,draggable:!1,radius:this.slotRadius,position:"B",style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1}});this.ice.addTool(i);const s=new W({zIndex:10000013,display:!1,transformable:!1,draggable:!1,radius:this.slotRadius,position:"L",style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1}});this.ice.addTool(s);const o=new W({zIndex:10000014,display:!1,transformable:!1,draggable:!1,radius:this.slotRadius,position:"C",style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1}});this.ice.addTool(o),this.ice._linkSlots=[t,e,i,s,o]}}function toIsoTime(t){if(null==t||""===t)return;if("string"!=typeof t&&"number"!=typeof t&&!(t instanceof Date))return;const e=t instanceof Date?t.getTime():"number"==typeof t?t:Date.parse(t);return Number.isFinite(e)?new Date(e).toISOString():void 0}const ct=["linearMatrix","composedMatrix","localOrigin","absoluteOrigin","dots","textHeight","lines"];class Serializer{get unregisteredTypes(){return this._unregisteredTypes}constructor(t){_defineProperty(this,"_unregisteredTypes",[]),this.ice=t}toJSONString(){return JSON.stringify(this.toJSONObject())}toJSONObject(){this._unregisteredTypes=[];const t=(new Date).toISOString();let e=toIsoTime(this.ice&&this.ice.documentMeta&&this.ice.documentMeta.createTime);if(!e){e=t;const i=this.ice&&this.ice.documentMeta;i&&"object"==typeof i&&(i.createTime=e)}const i={version:1,createTime:e,lastModifyTime:t,childNodes:[]};for(let t=0;t<this.ice.childNodes.length;t++){const e=this.ice.childNodes[t];this.encodeRecursively(e,i)}return i}encodeRecursively(t,e){const i=this.ice.getTypeId(t.constructor),s=i||t.constructor.name;if(!i){const t=String(s);-1===this._unregisteredTypes.indexOf(t)&&this._unregisteredTypes.push(t)}const o={state:this.pickSerializableState(t.state),type:s,childNodes:[]};e.childNodes.push(o);const r="function"==typeof t.hasDerivedChildren&&t.hasDerivedChildren(),a=("function"==typeof t.getSerializableChildren?t.getSerializableChildren():null)||(r?[]:t.childNodes);if(a&&a.length)for(let t=0;t<a.length;t++)this.encodeRecursively(a[t],o)}pickSerializableState(t){const e={};for(const i in t)-1===ct.indexOf(i)&&(e[i]=t[i]);return e}}const dt=[];class Deserializer{constructor(t){_defineProperty(this,"_unknownTypes",[]),this.ice=t}get unknownTypes(){return this._unknownTypes}fromJSONObject(t){this._unknownTypes=[];const e=t&&t.version?t.version:1;this.migrate(t,e),this.__rememberCreateTime(t);const i=t&&t.childNodes||[];for(let t=0;t<i.length;t++)this.decodeRecursively(this.ice,i[t])}__rememberCreateTime(t){const e=this.ice;if(!e||"object"!=typeof e)return;e.documentMeta&&"object"==typeof e.documentMeta||(e.documentMeta={});const i=toIsoTime(t&&t.createTime);i?e.documentMeta.createTime=i:delete e.documentMeta.createTime}fromJSONString(t){const e=JSON.parse(t);this.fromJSONObject(e)}migrate(t,e){if(e>1)throw new Error("不支持的反序列化版本:".concat(e,"(当前支持到 ").concat(1,")"));for(let i=0;i<dt.length;i++){const s=dt[i];e<s.to&&(s.run(t),e=s.to)}t.version=e}decodeRecursively(t,e){if(!e||!e.type)return null;const i=this.ice.getType(e.type);if("function"!=typeof i)return-1===this._unknownTypes.indexOf(e.type)&&this._unknownTypes.push(e.type),null;const s=new i(e.state);t.addChild(s);if(!("function"==typeof s.getSerializableChildren)&&"function"==typeof s.hasDerivedChildren&&s.hasDerivedChildren())return s;const o=e.childNodes;if(o&&o.length)for(let t=0;t<o.length;t++)this.decodeRecursively(s,o[t]);return s}}class PluginHost{constructor(t){_defineProperty(this,"plugins",[]),_defineProperty(this,"renderHooks",[]),_defineProperty(this,"tools",[]),this.ice=t}get names(){return this.plugins.map(t=>t.name)}has(t){return this.plugins.some(e=>e.name===t)}hasRenderHooks(){return this.renderHooks.length>0}use(t){if(!t||!t.name)throw new Error("ICE.use(plugin):插件必须提供非空的 name。");if(this.has(t.name))return!1;if(t.components)for(const e in t.components){const i=t.components[e];if("function"==typeof i)try{this.ice.registerType(e,i)}catch(e){throw new Error('插件 "'.concat(t.name,'" 注册组件类型失败:').concat(e instanceof Error?e.message:String(e)))}}if("function"==typeof t.render&&this.renderHooks.push({pluginName:t.name,hook:t.render}),t.tools)for(let e=0;e<t.tools.length;e++){const i=t.tools[e];i&&i.id&&this.tools.push(_objectSpread2(_objectSpread2({},i),{},{pluginName:t.name,instance:null,attached:!1}))}return this.plugins.push(t),"function"==typeof t.setup&&t.setup(this.ice),!0}unuse(t){const e=this.plugins.findIndex(e=>e.name===t);if(-1===e)return!1;const i=this.plugins[e];for(let e=this.tools.length-1;e>=0;e--)this.tools[e].pluginName===t&&(this.detachTool(this.tools[e]),this.tools.splice(e,1));for(let e=this.renderHooks.length-1;e>=0;e--)this.renderHooks[e].pluginName===t&&this.renderHooks.splice(e,1);return this.plugins.splice(e,1),"function"==typeof i.teardown&&i.teardown(this.ice),!0}invokeRenderHooks(t){for(let e=0;e<this.renderHooks.length;e++)this.renderHooks[e].hook(t)}syncTools(t){let e=!1;for(let i=0;i<this.tools.length;i++){const s=this.tools[i];let o=!1;try{o=!!t&&!!s.match(t,this.ice)}catch(t){o=!1}o?(s.instance||(s.instance=s.create()),!s.attached&&s.instance&&(this.ice.addTool(s.instance),s.attached=!0),"function"==typeof s.onTargetChange&&s.onTargetChange(s.instance,t),s.exclusive&&(e=!0)):this.detachTool(s)}return e}detachAllTools(){for(let t=0;t<this.tools.length;t++)this.detachTool(this.tools[t])}detachTool(t){t.attached&&t.instance&&(this.ice.removeTool(t.instance),t.attached=!1)}clear(){this.detachAllTools(),this.plugins=[],this.renderHooks=[],this.tools=[]}}function resolveRole(t){return t.isControlPanel?"tool":t.isLine?"link":"function"==typeof t.measureText?"text":Array.isArray(t.childNodes)?"container":t.state&&t.state.src?"image":"graphic"}function resolveLabel(t){const e=t.state||{};return"string"==typeof e.ariaLabel&&e.ariaLabel?e.ariaLabel:"string"==typeof e.text&&e.text?e.text:"string"==typeof e.title&&e.title?e.title:t.props&&t.props.id||String(e.id||"")}function resolveBox(t,e){if("function"!=typeof e.__paintWorldBox)return null;const i=e.state&&e.state.composedMatrix;if(!i||i.length<6)return null;const s=e.__paintWorldBox([0,0,0,0]);if(!(isFinite(s[0])&&isFinite(s[1])&&isFinite(s[2])&&isFinite(s[3])))return null;const[o,r]=t.worldToScreen(s[0],s[1]),[a,h]=t.worldToScreen(s[2],s[3]);return{x:Math.min(o,a),y:Math.min(r,h),width:Math.abs(a-o),height:Math.abs(h-r)}}function buildAccessibilityTree(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[],s=t&&t.selectionList||[];let o=0;const walk=(r,a,h)=>{if(!r||!r.length)return;const l=r.slice().sort((t,e)=>(t.state.zIndex||0)-(e.state.zIndex||0));for(let r=0;r<l.length;r++){const c=l[r],d=c.state||{},u=isEffectivelyVisible(c),p=!1!==d.interactive,f=resolveBox(t,c),g=(e.includeHidden||u)&&!!f,m=!e.filter||e.filter(c);g&&m&&i.push({id:c.props&&c.props.id||String(d.id||""),role:resolveRole(c),label:resolveLabel(c),box:f,visible:u,interactive:p,focusable:u&&p,tabIndex:o++,selected:-1!==s.indexOf(c),level:a,parentId:h}),c.childNodes&&c.childNodes.length&&walk(c.childNodes,a+1,c.props&&c.props.id||null)}};return walk(t&&t.childNodes||[],1,null),e.includeTools&&walk(t&&t.toolNodes||[],1,null),i}var ut=class ObjectCache{constructor(t){_defineProperty(this,"map",new WeakMap),_defineProperty(this,"__bytes",0),_defineProperty(this,"__offscreenUnavailable",!1),_defineProperty(this,"__vp",null),_defineProperty(this,"__vpChanged",!1),this.ice=t}__rvp(){return this.ice&&"function"==typeof this.ice.getRenderViewport?this.ice.getRenderViewport():this.ice&&this.ice.viewport||{scale:1,tx:0,ty:0}}beginFrame(){const t=this.__rvp(),e=this.__vp;this.__vpChanged=!!e&&(e.scale!==t.scale||e.tx!==t.tx||e.ty!==t.ty),e?(e.scale=t.scale,e.tx=t.tx,e.ty=t.ty):this.__vp={scale:t.scale,tx:t.tx,ty:t.ty}}__sameViewport(t,e,i,s){return t.rs===e&&t.ox===i&&t.oy===s}isCachable(t){if(this.__vpChanged)return!1;if(this.__offscreenUnavailable)return!1;if(!this.__isOpaque(t))return!1;if("function"==typeof t.hasClippingAncestor&&t.hasClippingAncestor())return!1;if("function"==typeof t.measureText)return!t.state.editing&&isEffectivelyVisible(t);if(t.isLine){if(t.state.lineDashFlow)return!1;if(!isEffectivelyVisible(t))return!1;const e=this.__rvp().scale;if(!(e>0))return!1;const i="function"==typeof t.__localBox?t.__localBox():null,s=i?i[2]-i[0]:Number(t.state.width)||0,o=i?i[3]-i[1]:Number(t.state.height)||0,r=Math.max(0,s)*Math.max(0,o)*e*e;return!(r>2e6)&&!(!this.map.has(t)&&this.__bytes+4*r>33554432)}if("function"==typeof t.calcDots&&!t.isLine){const e=Number(t.state.width)||0,i=Number(t.state.height)||0;return isEffectivelyVisible(t)&&!t.state.lineDashFlow&&e*i>=4e4}return!isOpaqueDrawing(t.state)&&("function"==typeof t.createPathObject&&(!t.childNodes&&!t.isLine&&isEffectivelyVisible(t)))}has(t){return this.map.has(t)}contentKey(t){const e=t.state;if("function"==typeof t.measureText){const t=e.style||{};return[e.text,t.fontWeight,t.fontSize,t.fontFamily,t.font,t.textAlign,t.textBaseline,t.paddingTop,t.paddingBottom,t.paddingLeft,t.paddingRight,e.fill,e.stroke,JSON.stringify(e.lineDash),e.lineDashOffset,e.lineDashFlow,e.lineBorder,e.lineBorderWidth,e.lineBorderColor,this.__styleKey(e)].join("|")}return"function"==typeof t.calcDots?[JSON.stringify(e.dots),e.closePath,e.fill,e.stroke,JSON.stringify(e.lineDash),e.lineDashOffset,e.lineDashFlow,e.lineBorder,e.lineBorderWidth,e.lineBorderColor,this.__styleKey(e)].join("|"):[e.width,e.height,e.radius,e.radiusX,e.radiusY,e.closePath,e.fill,e.stroke,JSON.stringify(e.lineDash),e.lineDashOffset,e.lineDashFlow,e.lineBorder,e.lineBorderWidth,e.lineBorderColor,this.__styleKey(e)].join("|")}__styleKey(t){const e=t.style||{};return[e.fillStyle,e.strokeStyle,e.lineWidth,e.globalAlpha,e.globalCompositeOperation,e.shadow,e.shadowColor,e.shadowBlur,e.shadowOffsetX,e.shadowOffsetY].join("|")}linearKey(t){const e=t.state.composedMatrix;return!e||e.length<6?"":"".concat(e[0],",").concat(e[1],",").concat(e[2],",").concat(e[3])}render(t){if(!this.isCachable(t))return this.map.has(t)&&!this.__isOpaque(t)&&this.invalidate(t),!1;const e=this.__rvp(),i=e.scale,s=e.tx,o=e.ty;let r=this.map.get(t);if(!t.dirty&&r&&this.__sameViewport(r,i,s,o))return this.draw(r),!0;"function"==typeof t.calcDots&&t.refreshParams(),t.composeMatrix();const a=this.linearKey(t),h=this.contentKey(t);let l=!r||r.contentKey!==h||r.linearKey!==a||!this.__sameViewport(r,i,s,o);if(l||(l=!this.refreshPosition(t,r)),l){const e=r||null;e&&(this.__bytes=Math.max(0,this.__bytes-e.pw*e.ph*4));try{r=this.build(t,h,a,i,s,o)}catch(e){return this.__offscreenUnavailable=!0,this.map.delete(t),!1}this.__bytes+=r.pw*r.ph*4}return this.map.set(t,r),this.draw(r),t.dirty=!1,!0}__isOpaque(t){if(t&&"function"==typeof t.getEffectiveOpacity)return 1===t.getEffectiveOpacity();const e=t&&t.state?t.state.opacity:void 0;return void 0===e||1===e}__paintBox(t){const e=t.getMaxBoundingBox().getMinAndMaxPoint(),i=stylePaintPad(t.state);return{minX:e.minX-i,minY:e.minY-i,maxX:e.maxX+i,maxY:e.maxY+i}}build(t,e,i,s,o,r){t.refreshParams(),t.composeMatrix();const a=this.__paintBox(t),h=Math.floor(a.minX*s+o)-1,l=Math.floor(a.minY*s+r)-1,c=Math.max(1,Math.ceil(a.maxX*s+o)-h+1),d=Math.max(1,Math.ceil(a.maxY*s+r)-l+1),{canvas:u,ctx:f}=p.createOffscreenCanvas(c,d),g=[s,0,0,s,o-h,r-l];return t.renderTo(f,g),{canvas:u,ctx:f,pw:c,ph:d,dx:h,dy:l,dx0:h,dy0:l,buildMinX:a.minX,buildMinY:a.minY,rs:s,ox:o,oy:r,contentKey:e,linearKey:i}}refreshPosition(t,e){const i=this.__paintBox(t),s=e.rs,o=s*(i.minX-e.buildMinX),r=s*(i.minY-e.buildMinY);if(Math.abs(o-Math.round(o))>1e-6)return!1;if(Math.abs(r-Math.round(r))>1e-6)return!1;const a=e.dx0+Math.round(o),h=e.dy0+Math.round(r);return!(i.minX*s+e.ox<a)&&(!(i.minY*s+e.oy<h)&&(!(i.maxX*s+e.ox>a+e.pw)&&(!(i.maxY*s+e.oy>h+e.ph)&&(e.dx=a,e.dy=h,!0))))}draw(t){const e=this.ice.ctx;e.save(),e.setTransform(1,0,0,1,0,0),e.drawImage(t.canvas,t.dx,t.dy),e.restore()}invalidate(t){const e=this.map.get(t);e&&(this.__bytes=Math.max(0,this.__bytes-e.pw*e.ph*4)),this.map.delete(t)}clear(){this.map=new WeakMap,this.__bytes=0}};var pt=class CanvasRenderer extends y{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),_defineProperty(this,"stopped",!1),_defineProperty(this,"renderMode","dirty-rect"),_defineProperty(this,"__forceFullRender",!1),_defineProperty(this,"componentQueue",[]),_defineProperty(this,"toolsQueue",[]),_defineProperty(this,"__queueDirty",!0),_defineProperty(this,"__zSnap",[]),_defineProperty(this,"__snap",new WeakMap),_defineProperty(this,"__primed",!1),_defineProperty(this,"__lastFrameCulled",0),this.ice=t,this.cache=new ut(t),"full"!==e.renderMode&&"dirty-rect"!==e.renderMode||(this.renderMode=e.renderMode)}markQueueDirty(){this.__queueDirty=!0}setRenderMode(t){this.renderMode=t}getRenderMode(){return this.renderMode}start(){return this.stopped=!1,this.ice.evtBus.on(t.ICE_FRAME_EVENT,this.frameEvtHandler,this),this}stop(){return this.stopped=!0,this.ice.evtBus.off(t.ICE_FRAME_EVENT,this.frameEvtHandler,this),this}frameEvtHandler(t){if(this.ice.dirty){if(this.refreshQueue(),this.cache.beginFrame(),"dirty-rect"===this.renderMode&&!this.__forceFullRender){const t=this.__collect();if(t)return void this.__renderDirtyRect(t)}this.doRenderFull()}}refreshQueue(){if(this.__queueDirty)this.__rebuildQueue();else if(this.__zOrderChanged()){const compareZ=(t,e)=>t.state.zIndex-e.state.zIndex;this.componentQueue.sort(compareZ),this.toolsQueue.sort(compareZ),this.__snapshotZ()}}__rebuildQueue(){const compareZ=(t,e)=>t.state.zIndex-e.state.zIndex;this.componentQueue=flattenTree([],this.ice.childNodes),this.componentQueue.sort(compareZ),this.toolsQueue=flattenTree([],this.ice.toolNodes),this.toolsQueue.sort(compareZ),this.__queueDirty=!1,this.__snapshotZ(),this.__snap=new WeakMap,this.__primed=!1}__snapshotZ(){const t=this.componentQueue.length+this.toolsQueue.length;this.__zSnap.length!==t&&(this.__zSnap=new Array(t));let e=0;for(let t=0;t<this.componentQueue.length;t++)this.__zSnap[e++]=this.componentQueue[t].state.zIndex;for(let t=0;t<this.toolsQueue.length;t++)this.__zSnap[e++]=this.toolsQueue[t].state.zIndex}__zOrderChanged(){const t=this.componentQueue.length+this.toolsQueue.length;if(this.__zSnap.length!==t)return!0;let e=0;for(let t=0;t<this.componentQueue.length;t++)if(this.__zSnap[e++]!==this.componentQueue[t].state.zIndex)return!0;for(let t=0;t<this.toolsQueue.length;t++)if(this.__zSnap[e++]!==this.toolsQueue[t].state.zIndex)return!0;return!1}doRenderFull(){this.ice.ctx.setTransform(1,0,0,1,0,0),this.ice.ctx.clearRect(0,0,this.ice.canvasWidth,this.ice.canvasHeight);const e=this.__visibleWorldRect();let i=0;for(let t=0;t<this.componentQueue.length;t++){const s=this.componentQueue[t];if(e&&s.isEffectivelyVisible()&&!s.dirty){const t=this.__snap.get(s);if(t&&!intersects(t,e)){i++;continue}}this.__ensureContext(s),this.__renderComponent(s),s.isEffectivelyVisible()&&this.__capture(s)}this.__lastFrameCulled=i;for(let t=0;t<this.toolsQueue.length;t++){const e=this.toolsQueue[t];this.__ensureContext(e),e.render(),e.isEffectivelyVisible()&&this.__capture(e)}this.__invokePluginRender(null),this.__finalizeHidden(this.componentQueue),this.__finalizeHidden(this.toolsQueue),this.__primed=!0,this.ice.dirty=!1,this.ice.evtBus.trigger(t.ROUND_FINISH)}__collect(){if(!this.__primed)return null;const t=this.ice.ctx,e=this.ice.canvasWidth||0,i=this.ice.canvasHeight||0;if(!e||!i)return null;if(!t||"function"!=typeof t.save||"function"!=typeof t.clip||"function"!=typeof t.restore)return null;const s=this.__preCount(this.componentQueue);if(0===s.dirty)return null;if(s.visible>0&&s.dirty/s.visible>.2)return null;const o=[];if(!this.__collectDirtyBoxes(o,this.componentQueue))return null;if(!this.__collectDirtyBoxes(o,this.toolsQueue))return null;const r=function coalesceRegions(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6;const i=[];for(let e=0;e<t.length;e++){const s=t[e];if(!isFiniteBox(s))continue;let o=!1;for(let t=0;t<i.length;t++)if(intersects(i[t],s)&&isWorthMerging(i[t],s)){i[t]=mergeBox(i[t],s),o=!0;break}o||i.push([s[0],s[1],s[2],s[3]])}let s=!0;for(;s;){s=!1;for(let t=0;t<i.length&&!s;t++)for(let e=t+1;e<i.length;e++)if(intersects(i[t],i[e])&&isWorthMerging(i[t],i[e])){i[t]=mergeBox(i[t],i[e]),i.splice(e,1),s=!0;break}}for(;i.length>e;){let t=0,e=1,s=1/0;for(let o=0;o<i.length;o++)for(let r=o+1;r<i.length;r++){const a=boxArea(mergeBox(i[o],i[r]))-boxArea(i[o])-boxArea(i[r]);isWorthMerging(i[o],i[r])&&a<s&&(s=a,t=o,e=r)}if(s===1/0){if(i.length>24)return[i.reduce((t,e)=>mergeBox(t,e),[1/0,1/0,-1/0,-1/0])];break}i[t]=mergeBox(i[t],i[e]),i.splice(e,1)}return i}(o,6);if(!r.length)return null;const a=this.__renderViewport(),h=[];for(let t=0;t<r.length;t++)integerAlign(r[t]),h.push(mapBoxToRender(r[t],a));if(function regionsAreaRatio(t,e,i){if(!e||!i)return 1;let s=0;for(let e=0;e<t.length;e++)s+=boxArea(t[e]);return s/(e*i)}(h,e,i)>.35)return null;if(this.__riskyIntersectsRegions(r,this.componentQueue))return null;if(this.__riskyIntersectsRegions(r,this.toolsQueue))return null;const l=[1/0,1/0,-1/0,-1/0];for(let t=0;t<r.length;t++)unionBoxes(l,r[t]);return{regions:r,renderRegions:h,bounding:l}}__renderViewport(){return"function"==typeof this.ice.getRenderViewport?this.ice.getRenderViewport():this.ice.viewport}__preCount(t){let e=0,i=0,s=!1;for(let o=0;o<t.length;o++){const r=t[o];r.isEffectivelyVisible()?(e++,r.dirty&&i++):this.__snap.has(r)&&(s=!0)}return{visible:e,dirty:i,hiddenErase:s}}__collectDirtyBoxes(t,e){for(let i=0;i<e.length;i++){const s=e[i];if(!s.isEffectivelyVisible()){const e=this.__snap.get(s);e&&t.push([e[0],e[1],e[2],e[3]]);continue}if(!s.dirty)continue;s.__paramsDirtyAtCollect=s.paramsDirty;const o=this.__freshBox(s);if(!o)return!1;const r=this.__snap.get(s);t.push(r?mergeBox(r,o):o)}return!0}__riskyIntersectsRegions(t,e){for(let i=0;i<e.length;i++){const s=e[i];if(!s.isEffectivelyVisible())continue;if(!(this.__isDotPath(s)||this.__isText(s)||!isOpaqueDrawing(s.state)))continue;if(s.dirty){if(!this.__isText(s))continue;if(!s.__paramsDirtyAtCollect&&this.cache.isCachable(s)&&this.cache.has(s))continue;return!0}if(this.cache.isCachable(s)&&this.cache.has(s))continue;const o=this.__snap.get(s);if(!o)return!0;for(let e=0;e<t.length;e++)if(intersects(o,t[e]))return!0}return!1}__renderDirtyRect(e){const i=this.ice.ctx,s=e.regions,o=e.renderRegions;for(let t=0;t<s.length;t++){const e=s[t],r=o[t],a=r[0],h=r[1],l=r[2]-r[0],c=r[3]-r[1];if(!(l<=0||c<=0)){i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(a,h,l,c),i.beginPath(),i.rect(a,h,l,c),i.clip();for(let t=0;t<this.componentQueue.length;t++){const i=this.componentQueue[t];if(!i.isEffectivelyVisible())continue;const s=this.__snap.get(i);(i.dirty||s&&intersects(s,e))&&(this.__ensureContext(i),this.__renderComponent(i),this.__capture(i))}for(let t=0;t<this.toolsQueue.length;t++){const e=this.toolsQueue[t];e.isEffectivelyVisible()&&(this.__ensureContext(e),e.render(),this.__capture(e))}this.__invokePluginRender(e),i.restore()}}this.__finalizeHidden(this.componentQueue),this.__finalizeHidden(this.toolsQueue),this.ice.dirty=!1,this.ice.evtBus.trigger(t.ROUND_FINISH)}__invokePluginRender(t){const e=this.ice&&this.ice.plugins;if(!e||"function"!=typeof e.hasRenderHooks||!e.hasRenderHooks())return;const i=this.ice.ctx,s=this.__renderViewport();i.setTransform(s.scale,0,0,s.scale,s.tx,s.ty),e.invokeRenderHooks({ctx:i,mode:this.renderMode,region:t,width:this.ice.canvasWidth,height:this.ice.canvasHeight})}__ensureContext(t){t.ctx===this.ice.ctx&&t.ice===this.ice||(t.root=this.ice.root,t.ctx=this.ice.ctx,t.evtBus=this.ice.evtBus,t.ice=this.ice)}getWorldBox(t){return this.__snap.get(t)||null}__visibleWorldRect(){const t=this.ice.canvasWidth||0,e=this.ice.canvasHeight||0;if(!t||!e)return null;const[i,s]=this.ice.screenToWorld(0,0),[o,r]=this.ice.screenToWorld(t,e),a=[Math.min(i,o),Math.min(s,r),Math.max(i,o),Math.max(s,r)];return isFiniteBox(a)?a:null}__renderComponent(t){this.cache.render(t)||t.render()}__isDotPath(t){return"function"==typeof t.calcDots}__isText(t){return"function"==typeof t.measureText}__freshBox(t){try{"function"==typeof t.refreshParams&&t.refreshParams();const e=t.getMaxBoundingBox(!0).getMinAndMaxPoint(),i=stylePaintPad(t.state),s=[e.minX-i,e.minY-i,e.maxX+i,e.maxY+i];return isFiniteBox(s)?s:null}catch(t){return null}}__capture(t){let e=this.__snap.get(t);e||(e=new Float64Array(4),this.__snap.set(t,e)),t.__paintWorldBox(e);const i=stylePaintPad(t.state);e[0]-=i,e[1]-=i,e[2]+=i,e[3]+=i}__finalizeHidden(t){for(let e=0;e<t.length;e++){const i=t[e];!i.isEffectivelyVisible()&&i.dirty&&(i.dirty=!1,this.__snap.delete(i))}}};function paint(t){return null==t||""===t?null:String(t)}function gradientDesc(t){if(!t||"object"==typeof t){if(t&&t.__iceGradient)return t.__iceGradient;if(t&&("linear"===t.type||"radial"===t.type||"conic"===t.type)&&t.stops)return t}return null}function gradientDef(t,e){const i=[],s=e&&e.stops;if(Array.isArray(s)&&s.forEach(t=>{Array.isArray(t)&&i.push([Number(t[0])||0,String(t[1])])}),!i.length)return"";const o=i.map(t=>{let[e,i]=t;return'<stop offset="'.concat(escapeXml(String(e)),'" stop-color="').concat(escapeXml(i),'"/>')}).join("");if("radial"===function gradientKind(t){return t&&"radial"===t.type?"radial":"linear"}(e)){const i=Array.isArray(e.center)?e.center:[0,0],s=Number(e.radius)||.5;return'<radialGradient id="'.concat(t,'" gradientUnits="userSpaceOnUse" cx="').concat(i[0],'" cy="').concat(i[1],'" r="').concat(s,'">').concat(o,"</radialGradient>")}const r=Array.isArray(e.from)?e.from:[0,0],a=Array.isArray(e.to)?e.to:[0,1];return'<linearGradient id="'.concat(t,'" gradientUnits="userSpaceOnUse" x1="').concat(r[0],'" y1="').concat(r[1],'" x2="').concat(a[0],'" y2="').concat(a[1],'">').concat(o,"</linearGradient>")}function escapeXml(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const ft={top:"text-before-edge",hanging:"hanging",middle:"central",alphabetic:"alphabetic",ideographic:"ideographic",bottom:"text-after-edge"},gt=2*Math.PI;function directionalDelta(t,e,i){let s=e-t;if(i){for(;s>1e-12;)s-=gt;for(;s<-gt;)s+=gt;Math.abs(s)<1e-12&&(s=-gt)}else{for(;s<-1e-12;)s+=gt;for(;s>gt;)s-=gt;Math.abs(s)<1e-12&&(s=gt)}return s}function matrixAttr(t,e){const n=t=>String(Number((t||0).toFixed(e)));return"matrix(".concat(n(t[0])," ").concat(n(t[1])," ").concat(n(t[2])," ").concat(n(t[3])," ").concat(n(t[4])," ").concat(n(t[5]),")")}function exportSvg(t){return exportSvgResult(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).svg}function exportSvgResult(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i="number"==typeof e.precision?e.precision:2,s=Number(e.scale)>0?Number(e.scale):1,o=!!(t&&t.childNodes&&t.getRenderViewport),r=o?t:t&&t.ice,a=[],collect=t=>{for(let e=0;e<t.length;e++){const i=t[e];a.push(i),i.childNodes&&i.childNodes.length&&collect(i.childNodes)}};collect(o?t.childNodes:[t]),e.includeTools&&r&&r.toolNodes&&collect(r.toolNodes),a.sort((t,e)=>(t.state.zIndex||0)-(e.state.zIndex||0));let h=[1,0,0,1,0,0],l=0,c=0;if("viewport"===e.area&&o){const t=r.getRenderViewport(),e=Number(r.canvasWidth)||0,i=Number(r.canvasHeight)||0;h=[t.scale,0,0,t.scale,t.tx,t.ty],l=e,c=i}else{let t=1/0,i=1/0,o=-1/0,r=-1/0;a.forEach(e=>{if("function"==typeof e.isEffectivelyVisible&&!e.isEffectivelyVisible())return;"function"==typeof e.refreshParams&&e.refreshParams(),"function"==typeof e.composeMatrix&&e.composeMatrix();let s=null;if("function"==typeof e.__paintWorldBox)s=e.__paintWorldBox();else if("function"==typeof e.getMinBoundingBox){const t=e.getMinBoundingBox(!0);s=[t.tl[0],t.tl[1],t.br[0],t.br[1]]}s&&isFinite(s[0])&&isFinite(s[1])&&isFinite(s[2])&&isFinite(s[3])&&(t=Math.min(t,s[0]),i=Math.min(i,s[1]),o=Math.max(o,s[2]),r=Math.max(r,s[3]))});const d=Number(e.padding)>=0?Number(e.padding):0;isFinite(t)||(t=0,i=0,o=1,r=1),t-=d,i-=d,o+=d,r+=d;const u=Math.max(o-t,1),p=Math.max(r-i,1);h=[s,0,0,s,-t*s,-i*s],l=u*s,c=p*s}const d=[],u=[];let p=0;a.forEach(t=>{if("function"==typeof t.isEffectivelyVisible&&!t.isEffectivelyVisible())return;const e=t.state,s=function mergedStyle(t){const e=t.props&&t.props.style,i=t.state&&t.state.style;return e||i?_objectSpread2(_objectSpread2({fillStyle:void 0},e),i):{}}(t),o="function"==typeof t.composeMatrix?t.composeMatrix():e.composedMatrix,r=[],a=[];let h=t.parentNode;for(;h&&h.state;)h.state.clipChildren&&"function"==typeof h.__paintWorldBox&&a.push(h.__paintWorldBox()),h=h.parentNode;const l=['transform="'.concat(matrixAttr(o,i),'"')];if(a.length){const t="ice-clip-".concat(p++),e=a[a.length-1];d.push('<clipPath id="'.concat(t,'"><rect x="').concat(e[0].toFixed(i),'" y="').concat(e[1].toFixed(i),'" width="').concat((e[2]-e[0]).toFixed(i),'" height="').concat((e[3]-e[1]).toFixed(i),'"/></clipPath>')),l.push('clip-path="url(#'.concat(t,')"'))}const c="function"==typeof t.getEffectiveOpacity?t.getEffectiveOpacity():1,f=void 0===s.globalAlpha?1:Number(s.globalAlpha),g=c*(f>=0?f:1);1!==g&&l.push('opacity="'.concat(Number(g.toFixed(3)),'"'));const m=function shadowFilter(t,e){let i=null;if("string"==typeof e.shadow&&x[e.shadow])i=x[e.shadow];else{const t=Number(e.shadowBlur)||0,s=Number(e.shadowOffsetX)||0,o=Number(e.shadowOffsetY)||0;(t||s||o)&&(i={shadowColor:e.shadowColor||"rgba(0,0,0,0.35)",shadowBlur:t,shadowOffsetX:s,shadowOffsetY:o})}if(!i)return null;const s=String(i.shadowColor||"rgba(0,0,0,0.35)"),o=s.match(/^rgba?\(\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*(?:,\s*([0-9.]+)\s*)?\)$/i),r=o?"rgb(".concat(Number(o[1]),", ").concat(Number(o[2]),", ").concat(Number(o[3]),")"):s,a=o&&void 0!==o[4]?Number(o[4]):1,h=Number(i.shadowBlur)||0;return{def:'<filter id="'.concat(t,'" x="-50%" y="-50%" width="200%" height="200%"><feDropShadow dx="').concat(Number(i.shadowOffsetX||0),'" dy="').concat(Number(i.shadowOffsetY||0),'" stdDeviation="').concat(Number((h/2).toFixed(2)),'" flood-color="').concat(escapeXml(r),'" flood-opacity="').concat(a,'"/></filter>'),url:"url(#".concat(t,")")}}("ice-shadow-".concat(p),s);m&&(p++,d.push(m.def),l.push('filter="'.concat(m.url,'"'))),r.push(...l);let y="";if(t instanceof w){"function"==typeof t.ensurePathBuilt&&t.ensurePathBuilt();const o=t.path2D,r=o&&o._commands||[],a=s.fillGradient||gradientDesc(s.fillStyle),h=s.strokeGradient||gradientDesc(s.strokeStyle),l=!(!1===e.fill||!s.fillStyle&&!a),c=!(!1===e.stroke||!s.strokeStyle&&!h);if(r.length&&(l||c)){const l=function commandsToPathData(t,e,i){const n=t=>{const e=Number(t.toFixed(i));return String(e)},s=[];let o=!1;for(let e=0;e<t.length;e++){const i=t[e],r=i[0];if("moveTo"===r)s.push("".concat(o?"L":"M").concat(n(i[1]),",").concat(n(i[2]))),o=!0;else if("lineTo"===r)s.push("L".concat(n(i[1]),",").concat(n(i[2]))),o=!0;else if("bezierCurveTo"===r)s.push("C".concat(n(i[1]),",").concat(n(i[2])," ").concat(n(i[3]),",").concat(n(i[4])," ").concat(n(i[5]),",").concat(n(i[6]))),o=!0;else if("quadraticCurveTo"===r)s.push("Q".concat(n(i[1]),",").concat(n(i[2])," ").concat(n(i[3]),",").concat(n(i[4]))),o=!0;else if("rect"===r)s.push("M".concat(n(i[1]),",").concat(n(i[2]),"h").concat(n(i[3]),"v").concat(n(i[4]),"h").concat(n(-i[3]),"z")),o=!1;else if("arc"===r){const[t,e,r,a,h,l]=i.slice(1),c=t+r*Math.cos(a),d=e+r*Math.sin(a),u=t+r*Math.cos(h),p=e+r*Math.sin(h),f=directionalDelta(a,h,!!l),g=Math.abs(f)>Math.PI?1:0,m=f>0?1:0;if(o||s.push("M".concat(n(c),",").concat(n(d))),Math.abs(f)>=gt-1e-6){const i=t+r*Math.cos(a+Math.PI),o=e+r*Math.sin(a+Math.PI);s.push("A".concat(n(r),",").concat(n(r)," 0 0 ").concat(m," ").concat(n(i),",").concat(n(o))),s.push("A".concat(n(r),",").concat(n(r)," 0 0 ").concat(m," ").concat(n(c),",").concat(n(d)))}else s.push("A".concat(n(r),",").concat(n(r)," 0 ").concat(g," ").concat(m," ").concat(n(u),",").concat(n(p)));o=!0}else if("arcTo"===r){const[t,e]=i.slice(1);s.push("L".concat(n(t),",").concat(n(e))),o=!0}else if("ellipse"===r){const[t,e,r,a,h,l,c,d]=i.slice(1),u=t+r*Math.cos(l)*Math.cos(h)-a*Math.sin(l)*Math.sin(h),p=e+r*Math.cos(l)*Math.sin(h)+a*Math.sin(l)*Math.cos(h),f=t+r*Math.cos(c)*Math.cos(h)-a*Math.sin(c)*Math.sin(h),g=e+r*Math.cos(c)*Math.sin(h)+a*Math.sin(c)*Math.cos(h),m=directionalDelta(l,c,!!d),y=Math.abs(m)>Math.PI?1:0,_=m>0?1:0;if(o||s.push("M".concat(n(u),",").concat(n(p))),Math.abs(m)>=gt-1e-6){const i=t+r*Math.cos(l+Math.PI)*Math.cos(h)-a*Math.sin(l+Math.PI)*Math.sin(h),o=e+r*Math.cos(l+Math.PI)*Math.sin(h)+a*Math.sin(l+Math.PI)*Math.cos(h);s.push("A".concat(n(r),",").concat(n(a)," 0 0 ").concat(_," ").concat(n(i),",").concat(n(o))),s.push("A".concat(n(r),",").concat(n(a)," 0 0 ").concat(_," ").concat(n(u),",").concat(n(p)))}else s.push("A".concat(n(r),",").concat(n(a)," 0 ").concat(y," ").concat(_," ").concat(n(f),",").concat(n(g)));o=!0}else"closePath"===r&&(s.length&&!/z$/i.test(s[s.length-1])&&s.push("Z"),o=!1)}const r=t.some(t=>"closePath"===t[0]);return!e||r||/z\s*$/i.test(s.join(" "))||s.push("Z"),s.join(" ")}(r,!(!o||!o._closed)||!1!==e.closePath,i),c=!1===e.fill||a?null:paint(s.fillStyle),u=!1===e.stroke||h?null:paint(s.strokeStyle),f=[];if(a&&!1!==e.fill){const t="ice-grad-".concat(p++),e=gradientDef(t,a);e?(d.push(e),f.push('fill="url(#'.concat(t,')"'))):c?f.push('fill="'.concat(escapeXml(c),'"')):f.push('fill="none"')}else f.push('fill="'.concat(c?escapeXml(c):"none",'"'));if(h&&!1!==e.stroke){const t="ice-grad-".concat(p++),e=gradientDef(t,h);e&&(d.push(e),f.push('stroke="url(#'.concat(t,')"')))}else u&&f.push('stroke="'.concat(escapeXml(u),'"'));if(void 0!==s.lineWidth&&f.push('stroke-width="'.concat(Number(s.lineWidth),'"')),Array.isArray(e.lineDash)&&e.lineDash.length&&(f.push('stroke-dasharray="'.concat(e.lineDash.join(" "),'"')),e.lineDashOffset&&f.push('stroke-dashoffset="'.concat(Number(e.lineDashOffset),'"'))),e.lineJoin&&f.push('stroke-linejoin="'.concat(e.lineJoin,'"')),e.lineCap&&f.push('stroke-linecap="'.concat(e.lineCap,'"')),y='<path d="'.concat(l,'" ').concat(f.join(" "),"/>"),"hollow"!==e.arrowStyle&&"function"==typeof t.getArrowFaces){const o=t.getArrowFaces(),r=u||(s.strokeStyle?String(s.strokeStyle):"#000000");if(o.length&&!1!==e.stroke){const t=o.map(t=>"M".concat(Number(t[0][0].toFixed(i)),",").concat(Number(t[0][1].toFixed(i)))+"L".concat(Number(t[1][0].toFixed(i)),",").concat(Number(t[1][1].toFixed(i)))+"L".concat(Number(t[2][0].toFixed(i)),",").concat(Number(t[2][1].toFixed(i)),"Z")).join(" ");y+='<path d="'.concat(t,'" fill="').concat(escapeXml(r),'" stroke="none"/>')}}const g="function"==typeof t.getLabelRenderInfo?t.getLabelRenderInfo():null;if(g){const t=Number((g.x-g.halfW).toFixed(i)),e=Number((g.y-g.halfH).toFixed(i)),s=Number((2*g.halfW).toFixed(i)),o=Number((2*g.halfH).toFixed(i));y+='<rect x="'.concat(t,'" y="').concat(e,'" width="').concat(s,'" height="').concat(o,'" fill="').concat(escapeXml(g.backgroundColor),'"/>')+'<text x="'.concat(Number(g.x.toFixed(i)),'" y="').concat(Number(g.y.toFixed(i)),'" ')+'font-family="Arial" font-size="'.concat(Number(g.fontSize),'" fill="').concat(escapeXml(g.fillStyle),'" ')+'text-anchor="middle" dominant-baseline="central">'.concat(escapeXml(g.text),"</text>")}}}else if(t instanceof J){const o="function"==typeof t.getRenderLines?t.getRenderLines():null;if(o&&o.length){const t=!1!==e.fill?paint(s.fillStyle):null,r=e.stroke?paint(s.strokeStyle):null,a=function fontAttributes(t,e){let i=t.fontFamily,s=t.fontSize,o=t.fontWeight,r=t.fontStyle;if(!("string"!=typeof t.font||i&&s)){const e=t.font.match(/^(?:(italic|oblique)\s+)?(?:(bold|bolder|lighter|[0-9]{3})\s+)?([0-9.]+)px\s+(.+)$/);e&&(r=r||e[1],o=o||e[2],s=s||e[3],i=i||e[4])}const a=[];return i&&a.push('font-family="'.concat(escapeXml(String(i)),'"')),null!=s&&""!==s&&a.push('font-size="'.concat(Number(Number(s).toFixed(e)),'"')),o&&a.push('font-weight="'.concat(escapeXml(String(o)),'"')),r&&a.push('font-style="'.concat(escapeXml(String(r)),'"')),a}(s,i);a.push('fill="'.concat(t?escapeXml(t):"none",'"')),r&&(a.push('stroke="'.concat(escapeXml(r),'"')),a.push('stroke-width="'.concat(Number(s.lineWidth)||1,'"')));let h=null;"center"===s.textAlign?(a.push('text-anchor="middle"'),h=0):"right"!==s.textAlign&&"end"!==s.textAlign||(a.push('text-anchor="end"'),h=e.localOrigin[0]-(Number(s.paddingRight)||0));const l=ft[s.textBaseline||"bottom"];l&&a.push('dominant-baseline="'.concat(l,'"'));const c=o.map(t=>{const e=null===h?t.x:h;return'<tspan x="'.concat(Number(e.toFixed(i)),'" y="').concat(Number(t.y.toFixed(i)),'">').concat(escapeXml(t.text),"</tspan>")}).join("");y="<text ".concat(a.join(" "),">").concat(c,"</text>")}}else if(t instanceof G&&e.src&&!(e.sw>0&&e.sh>0)){const t=0-e.localOrigin[0],i=0-e.localOrigin[1],s=['x="'.concat(t,'"'),'y="'.concat(i,'"'),'width="'.concat(e.width,'"'),'height="'.concat(e.height,'"'),'href="'.concat(escapeXml(String(e.src)),'"')];if("circle"===(e.clipType||"none")){const t="ice-clip-".concat(p++),i=Math.min(e.width,e.height)/2;d.push('<clipPath id="'.concat(t,'"><circle cx="0" cy="0" r="').concat(i,'"/></clipPath>')),s.push('clip-path="url(#'.concat(t,')"'))}y="<image ".concat(s.join(" "),' preserveAspectRatio="none"/>')}y&&u.push("<g ".concat(r.join(" "),">").concat(y,"</g>"))});const f=e.background?'<rect x="0" y="0" width="'.concat(l,'" height="').concat(c,'" fill="').concat(escapeXml(e.background),'"/>'):"";return{svg:['<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'.concat(Number(l.toFixed(i)),'" height="').concat(Number(c.toFixed(i)),'" viewBox="0 0 ').concat(Number(l.toFixed(i))," ").concat(Number(c.toFixed(i)),'">'),d.length?"<defs>".concat(d.join(""),"</defs>"):"",f,'<g transform="'.concat(matrixAttr(h,i),'">'),u.join(""),"</g>","</svg>"].filter(Boolean).join(""),width:l,height:c}}class ImageCache{constructor(t){_defineProperty(this,"imageCache",new Map),this.ice=t}setImage(t){let e=this.imageCache.get(t);return e||(e=p.createImage(),e.onload=()=>{this.ice.dirty=!0},e.onerror=()=>{},e.src=t,this.imageCache.size>ImageCache.CACHE_SIZE&&this.imageCache.delete(this.imageCache.keys().next().value),this.imageCache.set(t,e)),{loaded:this.loaded(e),image:e}}loaded(t){return t.complete&&t.naturalWidth>0}}_defineProperty(ImageCache,"CACHE_SIZE",100);const mt=/^[a-z][a-z0-9-]*:[A-Za-z_][A-Za-z0-9_-]*$/;function isTypeId(t){return"string"==typeof t&&mt.test(t)}function assertTypeId(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"typeId";if(!isTypeId(t))throw new Error("".concat(e,' 必须是 "namespace:Type" 格式(namespace 用小写字母/数字/连字符,Type 用字母/数字/下划线/连字符):').concat(String(t)))}function tagGradient(t,e){if(!t||"function"!=typeof t.addColorStop)return t;Object.defineProperty(t,"__iceGradient",{value:e,enumerable:!1,configurable:!0});const i=t.addColorStop.bind(t);return t.addColorStop=(t,s)=>{e.stops.push([t,s]),i(t,s)},t}class ICE{constructor(){_defineProperty(this,"childNodes",[]),_defineProperty(this,"toolNodes",[]),_defineProperty(this,"__childSet",new WeakSet),_defineProperty(this,"__toolSet",new WeakSet),_defineProperty(this,"canvasWidth",0),_defineProperty(this,"canvasHeight",0),_defineProperty(this,"viewport",{scale:1,tx:0,ty:0}),_defineProperty(this,"dpr",1),_defineProperty(this,"__renderVp",null),_defineProperty(this,"__contentBox",null),_defineProperty(this,"__inputRectSnapshot",null),_defineProperty(this,"selectionList",[]),_defineProperty(this,"plugins",new PluginHost(this)),_defineProperty(this,"theme",getTheme()),_defineProperty(this,"typeMapping",Object.create(null)),_defineProperty(this,"__typeIdMapping",null),_defineProperty(this,"documentMeta",{}),_defineProperty(this,"__dirty",!0),_defineProperty(this,"__initialized",!1);for(let t=0;t<rt.length;t++){const e=rt[t];this.registerType(e.typeId,e.ctor)}}__resolveCanvasEl(t){return t&&"function"==typeof t.getContext?t:t&&t.canvas&&"function"==typeof t.canvas.getContext?t.canvas:null}readCanvasRect(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.canvasEl;if(t&&"function"==typeof t.getBoundingClientRect)return t.getBoundingClientRect();const e=t&&t.width||0,i=t&&t.height||0;return{left:0,top:0,width:e,height:i,right:e,bottom:i,x:0,y:0}}init(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t)throw new Error("ICE.init() failed...");const i=this.__resolveCanvasEl(t);if(this.__initialized){if(i&&i===this.canvasEl)return this;throw new Error("同一个 ICE 实例已经绑定到其它 canvas,如需重新初始化请先调用 destroy()。")}return this.root=p,isString(t)?this.canvasEl=this.root.document.getElementById(t):i&&(this.canvasEl=i),e&&"number"==typeof e.dpr&&e.dpr>0&&(this.dpr=e.dpr),this.canvasEl?(this.canvasEl.oncontextmenu=function(t){t.preventDefault()},this.canvasWidth=this.canvasEl.width,this.canvasHeight=this.canvasEl.height,this.canvasBoundingClientRect=this.readCanvasRect(),this.__rememberInputRect(this.canvasBoundingClientRect),this.__contentBox=this.__readContentBox(this.canvasBoundingClientRect),this.ctx=this.canvasEl.getContext("2d"),this.canvasEl.style&&(this.canvasEl.style.touchAction="none"),1!==this.dpr&&this.__applyDevicePixelRatio()):this.ctx=t,this.evtBus=new Y,lt.registerEvtBus(this.evtBus),lt.start(),H.registerEvtBus(this.evtBus),H.start(),this.eventDispatcher=new z(this).start(),this.animationManager=new c(this).start(),this.controlPanelManager=new I(this).start(),this.renderer=new pt(this,e).start(),this.alignmentGuide=new B(this),this.linkSlotManager=new ICELinkSlotManager(this).start(),this.serializer=new Serializer(this),this.deserializer=new Deserializer(this),this.imageCache=new ImageCache(this),this.__initialized=!0,this}destroy(){if(!this.__initialized)return;const t=[this.renderer,this.animationManager,this.controlPanelManager,this.linkSlotManager];for(let e=0;e<t.length;e++){const i=t[e];i&&"function"==typeof i.stop&&i.stop()}this.eventDispatcher&&(this.eventDispatcher.stopped=!0),this.canvasEl&&this.canvasEl.oncontextmenu&&(this.canvasEl.oncontextmenu=null),this.evtBus&&(lt.delEvtBus(this.evtBus),H.delEvtBus(this.evtBus)),0===lt.evtBuses.length&&lt.stop(),this.plugins&&this.plugins.clear(),this.clearAll(),this.renderer=null,this.animationManager=null,this.controlPanelManager=null,this.linkSlotManager=null,this.eventDispatcher=null,this.alignmentGuide=null,this.serializer=null,this.deserializer=null,this.imageCache=null,this.ctx=null,this.canvasEl=null,this.canvasBoundingClientRect=null,this.dpr=1,this.__renderVp=null,this.__contentBox=null,this.__inputRectSnapshot=null,this.__initialized=!1}addTool(e){this.__toolSet.has(e)||(this.evtBus.trigger(t.BEFORE_ADD,null,{component:e}),e.trigger(t.BEFORE_ADD),e.ice=this,e.ctx=this.ctx,e.evtBus=this.evtBus,this.toolNodes.push(e),this.__toolSet.add(e),this.dirty=!0,this.renderer&&this.renderer.markQueueDirty(),e&&"function"==typeof e.__reapplyPreset&&e.__reapplyPreset(this.theme),this.evtBus.trigger(t.AFTER_ADD,null,{component:e}),e.trigger(t.AFTER_ADD))}removeTool(e){if(!this.__toolSet.has(e))return;this.evtBus.trigger(t.BEFORE_REMOVE,null,{component:e}),e.trigger(t.BEFORE_REMOVE);const i=this.toolNodes.indexOf(e);-1!==i&&this.toolNodes.splice(i,1),this.__toolSet.delete(e),this.evtBus.trigger(t.AFTER_REMOVE,null,{component:e}),e.trigger(t.AFTER_REMOVE),this.dirty=!0,this.renderer&&this.renderer.markQueueDirty(),e.destory()}addChild(e){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.__childSet.has(e))return;this.evtBus.trigger(t.BEFORE_ADD,null,{component:e}),e.trigger(t.BEFORE_ADD),e.ice=this,e.ctx=this.ctx,e.evtBus=this.evtBus,e.parentNode=null,this.childNodes.push(e),this.__childSet.add(e);let s=!1;const o=e.props.animations;if(o)for(const t in o){s=!0;break}s&&this.animationManager.add(e),this.dirty=i,this.renderer&&this.renderer.markQueueDirty(),e&&"function"==typeof e.__reapplyPreset&&e.__reapplyPreset(this.theme),this.evtBus.trigger(t.AFTER_ADD,null,{component:e}),e.trigger(t.AFTER_ADD)}addChildren(t){for(let e=0;e<t.length;e++)this.addChild(t[e],!1);this.dirty=!0}removeChild(e){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.__childSet.has(e))return;this.evtBus.trigger(t.BEFORE_REMOVE,null,{component:e}),e.trigger(t.BEFORE_REMOVE);const s=this.childNodes.indexOf(e);-1!==s&&this.childNodes.splice(s,1),this.__childSet.delete(e),this.evtBus.trigger(t.AFTER_REMOVE,null,{component:e}),e.trigger(t.AFTER_REMOVE),this.dirty=i,this.renderer&&this.renderer.markQueueDirty(),e.destory()}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e],!1);this.dirty=!0}clearAll(){this.removeChildren([...this.childNodes]),this.documentMeta={}}findComponent(t){if(!t)return;return this.childNodes.filter(e=>e.props.id===t)[0]||this.__findComponentInTree(this.childNodes,t)}__findComponentInTree(t,e){for(let i=0;i<t.length;i++){const s=t[i];if(s.props&&s.props.id===e)return s;if(s.childNodes&&s.childNodes.length){const t=this.__findComponentInTree(s.childNodes,e);if(t)return t}}}set dirty(t){this.__dirty=t}get dirty(){return this.__dirty}registerType(t,e){if(assertTypeId(t,"registerType 的 typeId"),"function"!=typeof e)throw new Error('registerType("'.concat(t,'") 失败:Clazz 必须是构造函数。'));const i=this.typeMapping[t];if(i){if(i===e)return;throw new Error('typeId "'.concat(t,'" 已注册为 ').concat(i.name||"匿名构造函数",",不能再注册 ").concat(e.name||"匿名构造函数","。"))}const s=this.getTypeId(e);if(s&&s!==t)throw new Error("构造函数 ".concat(e.name||"匿名构造函数",' 已注册为 "').concat(s,'",不能同时注册为 "').concat(t,'"(反查会歧义)。'));this.typeMapping[t]=e,this.__typeIdMapping=null}hasType(t){return"string"==typeof t&&!!this.typeMapping[t]}getRegisteredTypeIds(){return Object.keys(this.typeMapping)}getTypeId(t){if(!t)return;let e=this.__typeIdMapping;if(!e){e=new Map;for(const t in this.typeMapping){const i=this.typeMapping[t];"function"!=typeof i||e.has(i)||e.set(i,t)}this.__typeIdMapping=e}return e.get(t)}use(t){return this.plugins.use(t)}unuse(t){return this.plugins.unuse(t)}getPlugins(){return this.plugins.names}setSelection(t){return this.selectionList=null==t?[]:Array.isArray(t)?t:[t],!!this.plugins&&this.plugins.syncTools(this.selectionList[0]||null)}getAccessibilityTree(t){return buildAccessibilityTree(this,t)}setFocusedComponent(t){let e=t;if("string"==typeof t){e=flattenAllComponents(this).filter(e=>e.props&&e.props.id===t)[0]||null}return this.eventDispatcher&&(this.eventDispatcher.focusedComponent=e||null),this}getFocusedComponent(){return this.eventDispatcher?this.eventDispatcher.focusedComponent:null}getType(t){if("string"==typeof t&&t)return this.typeMapping[t]}loadFont(t,e){return p.loadFont(t,e)}setTheme(t){return this.theme=resolveTheme(t,this.theme),this.__reapplyPresets(),this}setViewport(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const s=Number(t);return this.viewport={scale:s>0?s:1,tx:Number(e)||0,ty:Number(i)||0},this.dirty=!0,this.renderer&&this.renderer.markQueueDirty(),this}screenToWorld(t,e){const i=this.viewport;return[(t-i.tx)/i.scale,(e-i.ty)/i.scale]}worldToScreen(t,e){const i=this.viewport;return[t*i.scale+i.tx,e*i.scale+i.ty]}getRenderViewport(){const t=this.viewport;if(1===this.dpr)return t;let e=this.__renderVp;return e||(e=this.__renderVp={scale:1,tx:0,ty:0,__d:1,__s:1,__tx:0,__ty:0}),e.__d===this.dpr&&e.__s===t.scale&&e.__tx===t.tx&&e.__ty===t.ty||(e.__d=this.dpr,e.__s=t.scale,e.__tx=t.tx,e.__ty=t.ty,e.scale=t.scale*this.dpr,e.tx=t.tx*this.dpr,e.ty=t.ty*this.dpr),e}__applyDevicePixelRatio(){const t=this.canvasEl;if(!t)return;const e=this.__readContentBox("function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():null),i=e.width||t.width,s=e.height||t.height;t.width=Math.round(i*this.dpr),t.height=Math.round(s*this.dpr),t.style&&(t.style.width=i+"px",t.style.height=s+"px"),this.canvasWidth=t.width,this.canvasHeight=t.height,this.updateCanvasBoundingRect()}updateCanvasBoundingRect(){return this.canvasEl&&"function"==typeof this.canvasEl.getBoundingClientRect&&(this.canvasBoundingClientRect=this.canvasEl.getBoundingClientRect(),this.__rememberInputRect(this.canvasBoundingClientRect),this.__contentBox=this.__readContentBox(this.canvasBoundingClientRect)),this.canvasBoundingClientRect}__rememberInputRect(t){if(!t)return;const e=this.__inputRectSnapshot||(this.__inputRectSnapshot={left:0,top:0,width:0,height:0});e.left=t.left||0,e.top=t.top||0,e.width=t.width||0,e.height=t.height||0}refreshInputRect(){const t=this.canvasEl;if(!t||"function"!=typeof t.getBoundingClientRect)return this.canvasBoundingClientRect;const e=t.getBoundingClientRect(),i=this.__inputRectSnapshot,s=!!i,o=s?i.left:0,r=s?i.top:0,a=s?i.width:0,h=s?i.height:0;this.canvasBoundingClientRect=e,this.__rememberInputRect(e);const l=this.__contentBox;return s&&!!l&&Math.abs(e.width-a)<.01&&Math.abs(e.height-h)<.01?(l.left+=e.left-o,l.top+=e.top-r):this.__contentBox=this.__readContentBox(e),e}__readContentBox(t){const e=this.canvasEl;let i=0,s=0,o=0,r=0,a=0,h=0,l=0,c=0;const d=this.root&&"function"==typeof this.root.getComputedStyle&&e?this.root.getComputedStyle(e):null;if(d){const num=t=>{const e=parseFloat(t);return isFinite(e)?e:0};i=num(d.borderLeftWidth),s=num(d.borderRightWidth),o=num(d.borderTopWidth),r=num(d.borderBottomWidth),a=num(d.paddingLeft),h=num(d.paddingRight),l=num(d.paddingTop),c=num(d.paddingBottom)}const u=t&&t.left||0,p=t&&t.top||0,f=t&&t.width||0,g=t&&t.height||0;return{left:u+i+a,top:p+o+l,width:Math.max(0,f-i-s-a-h),height:Math.max(0,g-o-r-l-c)}}getInputRect(){return this.__contentBox||this.updateCanvasBoundingRect(),this.__contentBox||this.canvasBoundingClientRect||{left:0,top:0,width:0,height:0}}zoomAt(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.05,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:20;const r=Number(i);if(!isFinite(r)||r<=0)return this;const[a,h]=this.screenToWorld(t,e),l=this.viewport.scale,c=Math.min(s,o),d=Math.max(s,o),u=Math.min(d,Math.max(c,l*r));return u===l?this:this.setViewport(u,t-a*u,e-h*u)}hitTest(t,e){const[i,s]=this.screenToWorld(t,e);return hitTestComponents(this,i,s,1)}registerTheme(t,e){return registerTheme(t,e),this}getTheme(){return this.theme}__reapplyPresets(){const t=flattenAllComponents(this);for(const e of t)"function"==typeof e.__reapplyPreset&&e.__reapplyPreset(this.theme)}createLinearGradient(t,e,i,s){return tagGradient(this.ctx.createLinearGradient(t,e,i,s),{type:"linear",from:[t,e],to:[i,s],stops:[]})}createRadialGradient(t,e,i,s,o,r){return tagGradient(this.ctx.createRadialGradient(t,e,i,s,o,r),{type:"radial",center:[s,o],radius:r,stops:[]})}createConicGradient(t,e,i){return"function"==typeof this.ctx.createConicGradient?tagGradient(this.ctx.createConicGradient(t,e,i),{type:"conic",startAngle:t,center:[e,i],stops:[]}):null}createPattern(t,e){return this.ctx.createPattern(t,e)}getImageData(t,e,i,s){return this.ctx.getImageData(t,e,i,s)}putImageData(t,e,i){this.ctx.putImageData(t,e,i)}createImageData(t,e){return this.ctx.createImageData(t,e)}toDataURL(t,e){return this.canvasEl.toDataURL(t,e)}toBlob(t,e,i){this.canvasEl.toBlob(t,e,i)}toSvg(){return exportSvg(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}static headless(){const t=new ICE;return t.childNodes=[],t.toolNodes=[],t.evtBus=new Y,t.dirty=!0,t}toSvgResult(){return exportSvgResult(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}toJSONString(){return this.serializer.toJSONString()}toJSONObject(){return this.serializer.toJSONObject()}fromJSONObject(t){lt.stop(),this.renderer.stop(),this.eventDispatcher.stopped=!0,this.animationManager.stop(),this.controlPanelManager.stop(),this.linkSlotManager.stop(),this.clearAll(),this.deserializer.fromJSONObject(t),lt.start(),this.renderer.start(),this.animationManager.start(),this.controlPanelManager.start(),this.linkSlotManager.start(),setTimeout(()=>{this.eventDispatcher&&(this.eventDispatcher.stopped=!1)},300)}fromJSONString(t){const e=JSON.parse(t);this.fromJSONObject(e)}}var yt=ICE;exports.AlignmentGuideManager=B,exports.AnimationManager=c,exports.CanvasRenderer=pt,exports.DARK_THEME=o,exports.DEFAULT_THEME=s,exports.DOMEventDispatcher=z,exports.DOMEventInterceptor=H,exports.Deserializer=Deserializer,exports.EventBus=Y,exports.GeoLine=GeoLine,exports.GeoPoint=GeoPoint,exports.GeoUtil=GeoUtil,exports.ICE=yt,exports.ICEBezier=ICEBezier,exports.ICEBorderLayout=et,exports.ICEBoundingBox=_,exports.ICEBoxLayout=it,exports.ICECardLayout=st,exports.ICECircle=T,exports.ICEComponent=C,exports.ICEControlPanel=ICEControlPanel,exports.ICEControlPanelManager=I,exports.ICEDotPath=ICEDotPath,exports.ICEEllipse=P,exports.ICEEventTarget=y,exports.ICEFlowLayout=$,exports.ICEGridLayout=tt,exports.ICEGroup=S,exports.ICEImage=G,exports.ICEIsogon=U,exports.ICELayeredLayout=ot,exports.ICELayoutManager=Z,exports.ICELinkHook=ICELinkHook,exports.ICELinkSlot=W,exports.ICEOverlayLayout=nt,exports.ICEPath=w,exports.ICEPolyLine=j,exports.ICERect=M,exports.ICERose=K,exports.ICEStar=q,exports.ICEText=J,exports.ICETheme=l,exports.ICEVisioLink=ICEVisioLink,exports.LineControlPanel=LineControlPanel,exports.PluginHost=PluginHost,exports.ResizeControl=ResizeControl,exports.RotateControl=RotateControl,exports.SERIALIZATION_MIGRATIONS=dt,exports.SERIALIZATION_VERSION=1,exports.STYLE_PRESETS=h,exports.Serializer=Serializer,exports.TYPE_ID_PATTERN=mt,exports.TransformControlPanel=TransformControlPanel,exports.assertTypeId=assertTypeId,exports.baseTokens=i,exports.buildAccessibilityTree=buildAccessibilityTree,exports.exportSvg=exportSvg,exports.exportSvgResult=exportSvgResult,exports.getTheme=getTheme,exports.isTypeId=isTypeId,exports.makeTypeId=function makeTypeId(t,e){const i="".concat(t,":").concat(e);return assertTypeId(i),i},exports.parseTypeId=function parseTypeId(t){assertTypeId(t);const e=t.indexOf(":");return{namespace:t.slice(0,e),type:t.slice(e+1)}},exports.registerTheme=registerTheme,exports.setTheme=setTheme,exports.toIsoTime=toIsoTime;
30
+ a||h||l||(t=this.findTargetComponent(e));let c=t;l?c=null:h&&this.focusedComponent&&(c=this.focusedComponent),this.__dispatch(o,e,c),u&&u!==o&&this.__dispatch(u,e,c)})}return this}__handlePointerCapture(t,e){const i=this.ice.canvasEl;if(!i||"function"!=typeof i.setPointerCapture)return;const s=e&&e.pointerId;if("number"==typeof s)try{if("ICE_POINTERDOWN"===t){const t=e&&e.target;if(t&&t!==i&&(!i.contains||!i.contains(t)))return;i.setPointerCapture(s)}else"ICE_POINTERUP"!==t&&"ICE_POINTERCANCEL"!==t||"function"==typeof i.releasePointerCapture&&i.hasPointerCapture&&i.hasPointerCapture(s)&&i.releasePointerCapture(s)}catch(t){}}__dispatch(t,e,i){i&&(e.target=i,i.trigger(t,e)),this.ice.evtBus.trigger(t,e,{component:i})}__resolveCanvasRect(t){const e="pointermove"===t||"mousemove"===t||"touchmove"===t,i=this.ice;return e&&i&&"function"==typeof i.refreshInputRect?i.refreshInputRect():i&&"function"==typeof i.updateCanvasBoundingRect&&i.updateCanvasBoundingRect(),i&&"function"==typeof i.getInputRect?i.getInputRect():i&&i.canvasBoundingClientRect||null}set stopped(t){this._stopped=t}get stopped(){return this._stopped}findTargetComponent(t){if(this._stopped)return null;const{offsetX:e,offsetY:i}=t;if("number"!=typeof e||"number"!=typeof i)return null;const[s,o]=this.ice.screenToWorld(e,i);return hitTestComponents(this.ice,s,o,1)}};const W={evtBuses:[],__handlers:null,__hasPointerEvent:!1,start:function(){if(!p||!p.addEventListener||W.__handlers)return;const t="function"==typeof p.PointerEvent;W.__hasPointerEvent=t;const e=buildDomEventList(t),i=[];for(let t=0;t<e.length;t++){const s=e[t],handler=t=>{for(let e=0;e<W.evtBuses.length;e++)W.evtBuses[e].trigger(s[1],t)},o="wheel"===s[0]||"touchmove"===s[0]?{passive:!1}:void 0;o&&"function"==typeof p.addEventListener?p.addEventListener(s[0],handler,o):p.addEventListener(s[0],handler),i.push({name:s[0],handler:handler})}W.__handlers=i},stop:function(){if(W.__handlers&&p&&p.removeEventListener)for(let t=0;t<W.__handlers.length;t++){const e=W.__handlers[t];p.removeEventListener(e.name,e.handler)}W.__handlers=null},registerEvtBus:function(t){W.evtBuses.includes(t)||W.evtBuses.push(t)},delEvtBus:function(t){W.evtBuses.includes(t)&&(W.evtBuses.splice(W.evtBuses.indexOf(t),1),0===W.evtBuses.length&&W.stop())}};var j=W;var U=class EventBus extends _{constructor(){super()}};class GeoLine{constructor(t,e){this.startPoint=t,this.endPoint=e}contains(t,e){const i=Math.hypot(this.endPoint.x-this.startPoint.x,this.endPoint.y-this.startPoint.y),s=Math.hypot(t-this.startPoint.x,e-this.startPoint.y),o=Math.hypot(t-this.endPoint.x,e-this.endPoint.y);return s+o>=i-3&&s+o<=i+3}}class GeoPoint{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.x=t,this.y=e}static load(t){return new GeoPoint(Number(t.x),Number(t.y))}static cloneArray(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].clone());return e}equals(t){return this.x==t.x&&this.y==t.y}clone(){return new GeoPoint(this.x,this.y)}}class ICEDotPath extends v{constructor(t){super(_objectSpread2({dots:[],closePath:!0},t)),_defineProperty(this,"__dotsShiftX",0),_defineProperty(this,"__dotsShiftY",0)}calcComponentParams(){if(!this.paramsDirty)return{width:this.state.width,height:this.state.height};this.calcDots();const t=this.calc4VertexPoints(),e=Math.abs(t[1][0]-t[0][0]),i=Math.abs(t[2][1]-t[0][1]);return this.state.width=e,this.state.height=i,{width:this.state.width,height:this.state.height}}containsLocalPoint(t,e){const i=this.state.dots;return!i||i.length<3?super.containsLocalPoint(t,e):GeoUtil.pointInPolygon(t,e,i)}calcLocalOrigin(){const t=super.calcLocalOrigin(),e=-t[0]-this.__dotsShiftX,i=-t[1]-this.__dotsShiftY;if(0!==e||0!==i){const s=[1,0,0,1,e,i];for(let t=0;t<this.state.dots.length;t++)this.state.dots[t]=transformMat2d([],this.state.dots[t],s);this.__dotsShiftX=-t[0],this.__dotsShiftY=-t[1]}return t}createPathObject(){this.ensureDots(),this.path2D=p.createPath2D(),this.path2D.moveTo(this.state.dots[0][0],this.state.dots[0][1]);for(let t=1;t<this.state.dots.length;t++){const e=this.state.dots[t];this.path2D.lineTo(e[0],e[1])}return this.path2D}calcDots(){return this.__dotsShiftX=0,this.__dotsShiftY=0,this.__calcDots()}__calcDots(){return this.state.dots=[],this.state.dots}ensureDots(){this.state.dots&&0!==this.state.dots.length||this.calcDots()}calc4VertexPoints(){this.ensureDots();let t=this.state.dots[0][0],e=this.state.dots[0][1],i=this.state.dots[0][0],s=this.state.dots[0][1];for(let o=1;o<this.state.dots.length;o++){const r=this.state.dots[o];r[0]<t&&(t=r[0]),r[0]>i&&(i=r[0]),r[1]<e&&(e=r[1]),r[1]>s&&(s=r[1])}return[[t,e],[i,e],[t,s],[i,s]]}getTransformedDots(){const t=this.state.composedMatrix,e=this.state.dots,i=[];for(let s=0;s<e.length;s++){const o=transformMat2d([],e[s],t);i.push(o)}return i}}var K=class ICEImage extends B{constructor(){super(_objectSpread2({width:100,height:100,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALkAAAC2CAYAAACF+yyJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAtoSURBVHhe7Z3tj15FHYb9VxUVo7zFUBWC8YXoF9++GENMRAWRKAkxGj8pihpjFBVF1CBlKaUU+wK0pYVqt12fn+6xs7PXnDPzO3O2Z+a5r+T6ss995nm2vXf3vM68570vXNuTsmdVctm9KrnsXpVcdq9KLrtXJZfdq5LL7lXJZfeq5LJ7VXLZvSq57F6VXHavSi67VyWX3auSy+5VyWX3quSye1Vy2b0quexelVx2r0ouu1cll92rksvuVcll96rksntVctm9KrnsXpVcdq9KLrtXJZfdq5LL7lXJZfeq5LJ7VfIjcIy7j/M2sp4q+YKWQNvLOqrkC+nhodO7OJacp0q+gHO4/2UVvbYqeWXH+O2lG3sf29nd++Eb1/e/wtC40q9KXtGfX+Dy3v4PzpspKCt9quQVJSgXS1BO+lTJK0pQLvab/zz8F+CjL3FWlquSV/KBE7v79bwJ5VISlJPlquSV/AXsj1MuJUE5Wa5KXsmfvKWSr1WVvJJ2BiWGciljLm/2figny1XJK0pQLvbS4d15zEmfKnlFicfPXsdsKEE56VMlr+hdx7mwqV2P75/ji0dvboahvPSpkle2BjSu9KuSL+AcaDw5T5V8IT3QOHK+KvmCni/oOm0v66iSO/zz5Rv71cwr56Nn+ADzmUs3MB8bQq/LcVVyhzHvg0wsQbnYmCfPTZ+SlAdVyQv92mm4crPhzokHkgnKhaagrEyrkjtM8eAr6UfXCMoNpqCsHFcld5rC7g3PzVPOTPHZkR8imbbpkqeg7BKm+NXFw0Un4swH4CavgTuOaH6Wd/gYGbOt2GTJc8k5IJxrileuHjxzQoSv37uTHutWfh8x9zU4m0BTJd959+apu1z+tdmExgoN+euVvNN6oSnCe1aI4bUvneKDWWPI5PrhFw++F2VC6dG7HGistdpMyc/9u7zgA/bfSGMOxlBmyhT2qVOv29efSNykZYTj5xrz2Jn0KcdvOQs+QGOu0SZKbn+u5/LAyJ/ZGO/uQSnPvp3+waXxc4x57nL6L9Ncnh0Ze002UfIUlDVTUNYkKJdjDWjcHD938vBuD+XMFJQ1U1B2ba6+5HZWgaBsKPFwhdN7Oc6BxsuVoJxJUC6UuJi4V35Nrr7kBOVIYk6uRA80TonEnBxJUG5NquQbbZLNGMqVWgJtX2rMcNA7lTMoR9JRBOXWZHMlt4d+KUc+VTBNRIydzaFcqTnQdqXeVjBbAEE5ki5YUW5NNlfy+CLLmN876y+5QTmPYyc/Ke+RoJxJUC5lDGXWpHZX9iUo55WgnFeCciZBOfL5K4d/ZCm3JlXyfR+BBxso55WgnFeCciZBOZKg3Jpcfcl/nJiwnrKhqWt5x3byLwr98kK9BxQIynmNscn+KWemoGxo6uIVZdfk6ktupqCseW1sJ3gf2o6gnEeCch4vwPCUy4G2M/8OuykGZddmEyW3ZUjG+PSJ3f9etr+eUe6Y8H2I8PU5EpTzSISv0370FF8+tbv38c1fA/oBCgnfZ602UXJzSexGJXsPe7A4Jv4cXgnKeSTs6zXu+Rkj/hxrtZmSm15yt6Xc11+vc/80QTmPMXb7Qg60bS7xZ1izTZXcLLmn/Orm/zrc1vubLRzDK0G5Un9zsXxXxB7GDsewSUlLCLdtweZKPjh2f/m7Ublj/zhyiytBY5RKUK7UEuy7pjEGfwZXiENomxZstuQ1zIW2LfE1ezwpAeVLzIW23Ra3uuSDOdB2U9rzkDn8yfnwQQ73ahU5/SYv4Y3NJjQO6eGDI4vahqYmOBpjm5dM3KqSp66elnL3yPQQNaBxB2twttIdlq3YfcmXJHyfF96ZPpgdzvb84HzeD1s4/pJ8pvNJi7or+e8Lz5wQdrXPxqIFaGNy/zbEn9PM4W8ZVyvte7bxPhRNR+Hh7YL79Vuxq5J7ic+nx6ZmlcqBxoudA403+LuJ2yHGoPFadWtL/qnNb2kaY8wShlsFch2bIo6gMcYsvRBmD5zQOC26NSWvdbD1/oky2k1itF2uT8Py5SHfrVS+qYNw2qZVuyq5FSDkngVPmxGU80pQrpYhdqsyZVq1uwPPo5KgnFeCcnJaldwpQTmvBOXktCq5U4JyXgnKyWlVcqcE5bwSlJPTquROCcp5JSgnp1XJnRKU80pQTk6rkjslKOeVoJycViV3SlDOK0E5Oa1K7pSgnFeCcnJaldwpQTmvBOXktF2VPL6sP/Zww1wJynklKFfLkKm7Mluzq5KPUesGram7Be3mVtou119PTDGhG7TK3ZqSx3xy4VttHx1ZWpC05ztLoDHG1K22nehl6mkYPTTRtt0deP6hwuNvX3z1f7/l7bf9FLmTjMaf08zBVoiewiZLsvFqPP4WriLdi92VPPQoJ7zMeZB5WAJdDzIfrV2XPLbWlBR3aUqKptyqkseWcqagHB40udAybnXJB3Og7ab8ROY0cXaASNtPmXM4oGni9Js8C9q2xFOa8POW2mzJbdchhZ3yo20GS8/A0BilEpQrtQT7rmmMQVsIbAzapgWbK/lLmoT/gJ5J+L/62sGzKY/B8o5jhNu2YFMl95K7LeVaXE7lG6/nlZa2zSX+DGu2mZIvyTDbFV0hjD+HV4JyHgn7+lFeJ1izTZQ8Z4lDuzqpJQ5vEr6ec9U05guv7u7d//Lu3lsTPyfh+6zVJkqegrLmyDHp/6HtCMp5JCjn8SgWq039oFB2ba6+5LWXHS9ZjrvlZceP7XDOTEHZ0NRZKcquydWXnKAcSVDOfATOMFDOK0E5rwTlTIJyJEG5NamS70tQzitBOa8E5UyCcuRzlw//Nqfcmmyu5Ceu5l8Ctxv/YyhnEpTzOHZCj/IeCcqZBOVSxlBmTTZX8pLlPmjxVcqZMbYYLuVKzYG2K5XmTaecSVCOLHmftajdlY12qiyGcqWWQNuXGmM7Fjk5g3IkHXpSbk2q5AW5Ej3QOCUSc3IkQbk1ufqS33Hc9w9LfDuxjg9BuVznQOPlSlDOJCgXStg5esquydWX3ExBWTMFZU2CcjnWgMbN8fMn83e7UlDWTEHZtdlEyUtXRiPGpqCIsXs+KDdlKc+PXG6n8XOMsVN+lDPnYldBady12UTJTVvX3kvqAGwwhjJTphjem7CvP3EufYIxHD/XmO+MzP9iN6bNgcZco82U3Bx7wibF1AMUZshfRn7zpUxxJXhvYnjtK6fSj8kNmVzvjI5hKBP6sLPoNNZabarkg7l4dztKTHEyumhFhK8f20kX/VZ+HzH23Cptv2abLPlgCsouYQqbzzAnG2duHzn2+MiLB7NLaWt4Ekfxg7aUTZf8VpoitQ9MUM5M4VkqXarkLlM8ODITFUG5wRSUleOq5IWmJvaxAz7KDxKUC01BWZlWJXcYcxtkYgnKxcY8ea7egxzbokruMLynml6PtbnKiWcyZ84KodfluCr5gp5P73EcgraXdVTJF9IDjSPnq5Iv4BxoPDlPlbyyNaBxpV+VvKK2pCJxaZeL+zg8g2q8uRmG8tKnSl5RImdJQoJy0qdKXlGCcrEX4foS5aRPlbySdHMV5VLGlMxKIMdVySv504LpL0iCcrJclbyStEoD5VISlJPlquSVpIVtKZeSoJwsVyWvKEG5WHrWcpuXJKytSl5RgnKxBOWkT5W8ok8nVk+zNe8pb6agrPSpkld2DLu11hYB+NHE8uc0rvSrki/gHO5r8Gn4tauSL6SHh06r4Euoki9oCbS9rKNKfgSOcY9OFS6uSi67VyWX3auSy+5VyWX3quSye1Vy2b0quexelVx2r0ouu1cll92rksvuVcll96rksntVctm9KrnsXpVcdq9KLrtXJZfdq5LL7lXJZfeq5LJ7VXLZvSq57F6VXHavSi67VyWX3auSy+5VyWX3quSye1Vy2b0quezca3v/AeMnvtkH1pHJAAAAAElFTkSuQmCC",clipType:"none",sx:0,sy:0,sw:0,sh:0},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}))}doRender(){if(this.state.src){const{loaded:t,image:e}=this.ice.imageCache.setImage(this.state.src);if(t){const t=this.ctx,i=this.state.clipType||"none",s=0-this.state.localOrigin[0],o=0-this.state.localOrigin[1],{sx:r,sy:u,sw:a,sh:h}=this.state,l=a>0&&h>0;"circle"===i&&(t.save(),t.beginPath(),t.arc(0,0,Math.min(this.state.width,this.state.height)/2,0,2*Math.PI),t.closePath(),t.clip()),l?t.drawImage(e,r,u,a,h,s,o,this.state.width,this.state.height):t.drawImage(e,s,o,this.state.width,this.state.height),"circle"===i&&t.restore()}}super.doRender()}};class ICEPolyLine extends ICEDotPath{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(ICEPolyLine.arrangeParam(t)),_defineProperty(this,"isLine",!0),_defineProperty(this,"__polyBoxScratch",[0,0,0,0]),_defineProperty(this,"__arrowFaceIndexes",[])}containsLocalPoint(t,e){const i=this.state.dots;if(!i||i.length<2)return super.containsLocalPoint(t,e);const s=Math.max(4,(this.state.lineWidth||1)/2+3);return GeoUtil.distanceToPolyline(i,t,e)<=s}static arrangeParam(t){let e=merge({},{lineType:"solid",lineWidth:1,arrow:"none",arrowLength:15,arrowAngel:toRadian(30),arrowStyle:"filled",points:[],showMinBoundingBox:!1,showMaxBoundingBox:!1,links:{},routeType:"straight",routeOffset:20,curveType:"straight",label:"",labelStyle:{fontSize:14,fillStyle:"#000000",backgroundColor:"#ffffff"},style:{lineJoin:"round"}},t,{linkable:!1,closePath:!1,fill:!1});const i=e.points.length;return i<2&&(0===i?(e.points.push([0,0]),e.points.push([10,10])):1===i&&e.points.push([10,10])),"dashed"!==e.lineType||e.lineDash&&0!==e.lineDash.length||(e.lineDash=[4*e.lineWidth,4*e.lineWidth]),e=_objectSpread2(_objectSpread2({},e),{left:e.points[0][0],top:e.points[0][1],transform:{translate:[0,0],scale:[1,1],skew:[0,0],rotate:0}}),e.style.lineWidth<1&&(e.style.lineWidth=1),e}initEvents(){super.initEvents(),this.once(t.AFTER_ADD,this.afterAddHandler,this)}afterAddHandler(e){this.evtBus.once(t.ROUND_FINISH,this.syncConnections,this)}syncConnections(){if(!this.ice)return;this.removeLink("start"),this.removeLink("end");const t=this.state.links;t&&(t.start&&t.start.id&&t.start.position&&this.createLink(t.start.id,t.start.position),t.end&&t.end.id&&t.end.position&&this.createLink(t.end.id,t.end.position)),this.paramsDirty=!0,this.dirty=!0,this.ice.dirty=!0}createLink(e,i){const s=this.ice.findComponent(e);s&&s.on(t.AFTER_MOVE,this.followComponent,this),s&&s.on(t.AFTER_RESIZE,this.followComponent,this),s&&s.on(t.AFTER_ROTATE,this.followComponent,this),s&&this.followComponent(),this.state.draggable=!1}removeLink(e,i,s){if(!this.state.links||!this.state.links[e])return;const o=this.state.links[e].id,r=this.state.links[e].position;if(i||(i=o),s||(s=r),o===i&&r===s){const e=this.ice.findComponent(o);e&&e.off(t.AFTER_MOVE,this.followComponent,this),e&&e.off(t.AFTER_RESIZE,this.followComponent,this),e&&e.off(t.AFTER_ROTATE,this.followComponent,this)}let u=!0;this.state.links.start&&this.state.links.start.id&&(u=!1),this.state.links.end&&this.state.links.end.id&&(u=!1),this.state.draggable=u}getLinkFromId(){return this.state.links.start.id}getLinkToId(){return this.state.links.end.id}followComponent(t){for(const t in this.state.links){if(!this.state.links[t]||!this.state.links[t].id||!this.state.links[t].position)continue;const e=this.state.links[t].id,i=this.state.links[t].position,s=this.ice.findComponent(e);if(!s)continue;const o=s.getMinBoundingBox(!0);let r=[0,0];switch(i){case"T":r=o.tc;break;case"R":r=o.rc;break;case"B":r=o.bc;break;case"L":r=o.lc;break;case"C":r=o.center}switch(t){case"start":this.setState({startPoint:[...r]});break;case"end":this.setState({endPoint:[...r]})}}}calcLocalOrigin(){const t=[0,0];return this.state.localOrigin=t,t}__calcDots(){const t=this.state.left,e=this.state.top;this.state.dots=[];for(let i=0;i<this.state.points.length;i++){const s=this.state.points[i],o=s[0]-t,r=s[1]-e;this.state.dots.push([o,r])}return this.calcArrowPoints(),this.state.dots}calcArrowPoints(){if(this.__arrowFaceIndexes.length=0,"start"===this.state.arrow||"both"===this.state.arrow){const t=[...this.state.dots[0]];let e=[[...this.state.dots[0]],[...this.state.dots[1]]];e=this.doCalcArrowPoints(e),this.state.dots.unshift(...e),this.state.dots.unshift([...t]),this.__arrowFaceIndexes.push(0)}if("end"===this.state.arrow||"both"===this.state.arrow){const t=this.state.dots.length,e=[...this.state.dots[t-1]];let i=[[...this.state.dots[t-1]],[...this.state.dots[t-2]]];i=this.doCalcArrowPoints(i),this.state.dots.push(...i),this.state.dots.push([...e]),this.__arrowFaceIndexes.push(this.state.dots.length-4)}}doCalcArrowPoints(t){const e=t[0],i=t[1];i[0]=i[0]-e[0],i[1]=i[1]-e[1];const s=Math.hypot(i[0],i[1]);if(0===s)return[[e[0],e[1]],[e[0],e[1]]];const o=i[0]/s,r=i[1]/s,u=Math.cos(this.state.arrowAngel),a=Math.sin(this.state.arrowAngel);let h=this.state.arrowLength*(o*u-r*a),l=this.state.arrowLength*(r*u+o*a),c=this.state.arrowLength*(o*u+r*a),d=this.state.arrowLength*(r*u-o*a);return h+=e[0],l+=e[1],c+=e[0],d+=e[1],[[h,l],[c,d]]}addDot(t,e){this.state.points.splice(e,0,t),this.state.dots.splice(e,0,[t[0],t[1]])}rmDot(t){return!(this.state.points.length<3)&&(this.state.points.splice(t,1),this.state.dots.splice(t,1),!0)}calcComponentParams(){if(!this.paramsDirty)return{width:this.state.width,height:this.state.height};this.calcDots();const t=this.calc4VertexPoints();let e=1/0,i=1/0,s=-1/0,o=-1/0;for(let r=0;r<t.length;r++){const u=t[r];u[0]<e&&(e=u[0]),u[0]>s&&(s=u[0]),u[1]<i&&(i=u[1]),u[1]>o&&(o=u[1])}return this.state.width=Math.abs(s-e),this.state.height=Math.abs(o-i),{width:this.state.width,height:this.state.height}}isDotsOnSameLine(){const t=this.state.points.length,e=round(this.state.points[0][0],2),i=round(this.state.points[0][1],2);let s=0;const o=[round(this.state.points[t-1][0],2)-e,round(this.state.points[t-1][1],2)-i];for(let r=0;r<t;r++){const t=this.state.points[r];0===cross([],o,[t[0]-e,t[1]-i])[2]&&s++}return s===t}calc4VertexPoints(){return this.isDotsOnSameLine()?this.splitEndpointsTo4Points():super.calc4VertexPoints()}splitEndpointsTo4Points(){const t=this.state.points.length,e=this.state.points[t-1][0]-this.state.points[0][0],i=this.state.points[t-1][1]-this.state.points[0][1],s=this.getRotateAngle(),o=this.state.style.lineWidth||1;let r=Math.cos(s*Math.PI/180)*o/2,u=Math.sin(s*Math.PI/180)*o/2;r=round(r,3),u=round(u,3);return[[0+r,0+u],[0-r,0-u],[e+r,i+u],[e-r,i-u]]}__localBox(){const t=this.__polyBoxScratch;this.ensureDots();const e=this.state.dots;if(!e||0===e.length)return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t;const i=this.calc4VertexPoints();let s=1/0,o=1/0,r=-1/0,u=-1/0;for(let t=0;t<i.length;t++){const e=i[t];e[0]<s&&(s=e[0]),e[0]>r&&(r=e[0]),e[1]<o&&(o=e[1]),e[1]>u&&(u=e[1])}const a=this.__arrowFaceIndexes;for(let t=0;t<a.length;t++){const i=a[t];for(let t=0;t<3;t++){const a=e[i+t];a&&(a[0]<s&&(s=a[0]),a[0]>r&&(r=a[0]),a[1]<o&&(o=a[1]),a[1]>u&&(u=a[1]))}}const h=this.__measureLabelBoxForBounds();return h&&(h.x-h.halfW<s&&(s=h.x-h.halfW),h.x+h.halfW>r&&(r=h.x+h.halfW),h.y-h.halfH<o&&(o=h.y-h.halfH),h.y+h.halfH>u&&(u=h.y+h.halfH)),t[0]=s,t[1]=o,t[2]=r,t[3]=u,t}setState(t){if(isNil(t.width)||delete t.width,isNil(t.height)||delete t.height,isNil(t.transform)||delete t.transform,!isNil(t.left)){const e=t.left-this.state.points[0][0];for(let t=0;t<this.state.points.length;t++)this.state.points[t][0]+=e}if(!isNil(t.top)){const e=t.top-this.state.points[0][1];for(let t=0;t<this.state.points.length;t++)this.state.points[t][1]+=e}if(isNil(t.startPoint)||(this.state.points[0]=[...t.startPoint],this.state.left=this.state.points[0][0],this.state.top=this.state.points[0][1]),!isNil(t.endPoint)){const e=this.state.points.length;this.state.points[e-1]=[...t.endPoint]}isNil(t.startPoint)&&isNil(t.endPoint)||this.recalculateRoute(),isNil(t.links)||(merge(this.state.links,t.links),this.syncConnections()),super.setState(t)}static dirVector(t){switch(t){case"T":return[0,-1];case"B":return[0,1];case"L":return[-1,0];case"R":return[1,0];default:return[0,0]}}recalculateRoute(){if("orthogonal"!==this.state.routeType)return;const t=this.state.points[0],e=this.state.points[this.state.points.length-1],i=this.state.routeOffset||20,s=ICEPolyLine.dirVector(this.state.links&&this.state.links.start&&this.state.links.start.position),o=ICEPolyLine.dirVector(this.state.links&&this.state.links.end&&this.state.links.end.position),r=[t[0]+s[0]*i,t[1]+s[1]*i],u=[e[0]+o[0]*i,e[1]+o[1]*i],a=[t];0===s[0]&&0===s[1]||a.push(r),r[0]!==u[0]&&r[1]!==u[1]&&a.push([u[0],r[1]]),0===o[0]&&0===o[1]||a.push(u),a.push(e),this.state.points=a,this.paramsDirty=!0,this.dirty=!0}createPathObject(){this.ensureDots();const t=this.state.curveType||"straight",e=this.state.dots;if(this.path2D=p.createPath2D(),!e||0===e.length)return this.path2D;if(this.path2D.moveTo(e[0][0],e[0][1]),"quadratic"===t&&e.length>=3)this.path2D.quadraticCurveTo(e[1][0],e[1][1],e[2][0],e[2][1]);else if("cubic"===t&&e.length>=4)this.path2D.bezierCurveTo(e[1][0],e[1][1],e[2][0],e[2][1],e[3][0],e[3][1]);else for(let t=1;t<e.length;t++)this.path2D.lineTo(e[t][0],e[t][1]);return this.path2D}doRender(){const t=this.__arrowFaceIndexes.length>0&&"hollow"!==this.state.arrowStyle&&!1!==this.state.stroke,e=t?this.ctx.strokeStyle:null;super.doRender(),this.applyActiveTransform(),t&&this.drawArrowFills(e),this.drawLabel()}getArrowFaces(){const t=this.__arrowFaceIndexes,e=this.state.dots,i=[];if(!e||0===t.length)return i;for(let s=0;s<t.length;s++){const o=t[s],r=e[o],u=e[o+1],a=e[o+2];r&&u&&a&&i.push([[r[0],r[1]],[u[0],u[1]],[a[0],a[1]]])}return i}drawArrowFills(t){const e=this.getArrowFaces();if(!e.length)return;const i=this.ctx;i.save(),i.beginPath();for(let t=0;t<e.length;t++){const[s,o,r]=e[t];i.moveTo(s[0],s[1]),i.lineTo(o[0],o[1]),i.lineTo(r[0],r[1]),i.closePath()}i.fillStyle=t||this.state.style.strokeStyle||"#000000",i.fill(),i.restore()}__labelMetrics(){const t=this.state.label;if(!t)return null;const e=(this.state.labelStyle||{}).fontSize||14,i=this.getLabelPosition();let s=0;const o=this.ctx;return o&&"function"==typeof o.measureText?(o.font="".concat(e,"px Arial"),s=o.measureText(t).width):s=t.length*e,{x:i[0],y:i[1],halfW:s/2+4,halfH:e/2+4}}getLabelRenderInfo(){const t=this.__labelMetrics();if(!t)return null;const e=this.state.labelStyle||{};return _objectSpread2(_objectSpread2({text:String(this.state.label)},t),{},{fontSize:e.fontSize||14,fillStyle:e.fillStyle||"#000000",backgroundColor:e.backgroundColor||"#ffffff"})}__measureLabelBoxForBounds(){const t=this.ctx,e=!!t&&"font"in t,i=e?t.font:void 0,s=this.__labelMetrics();return e&&(t.font=i),s}drawLabel(){const t=this.state.label;if(!t)return;const e=this.ctx,i=this.state.labelStyle||{};e.save();const s=this.__labelMetrics();s?(e.textAlign="center",e.textBaseline="middle",e.fillStyle=i.backgroundColor||"#ffffff",e.fillRect(s.x-s.halfW,s.y-s.halfH,2*s.halfW,2*s.halfH),e.fillStyle=i.fillStyle||"#000000",e.fillText(t,s.x,s.y),e.restore()):e.restore()}getLabelPosition(){const t=this.state.points,e=t.length,i=this.state.left,s=this.state.top;if(0===e)return[0,0];if(1===e)return[t[0][0]-i,t[0][1]-s];let o,r;if(2===e)o=(t[0][0]+t[1][0])/2,r=(t[0][1]+t[1][1])/2;else{const i=t[Math.floor(e/2)];o=i[0],r=i[1]}return[o-i,r-s]}getRotateAngle(){if(this.isDotsOnSameLine()){const t=0,e=0,i=this.state.points.length,s=this.state.points[i-1][0]-this.state.points[0][0],o=this.state.points[i-1][1]-this.state.points[0][1];let r=GeoUtil.calcRotateAngle(s,o,t,e);return r+=90,r}return super.getRotateAngle()}containsPoint(t,e){const i=this.getLines();for(let s=0;s<i.length;s++){const o=i[s],r=o.o[0],u=o.o[1],a=o.d[0],h=o.d[1],l=Math.hypot(a-r,h-u),c=Math.hypot(r-t,u-e),d=Math.hypot(a-t,h-e);if(c+d>=l-3&&c+d<=l+3)return!0}return!1}getLines(){const t=[],e=this.getTransformedDots();if(!e||e.length<2)return t;for(let i=0;i<e.length-1;i++){const s={o:[e[i][0],e[i][1]],d:[e[i+1][0],e[i+1][1]]};t.push(s)}return t}destory(){this.evtBus&&this.evtBus.off(t.ROUND_FINISH,this.syncConnections,this),this.removeLink("start"),this.removeLink("end"),super.destory()}}var q=ICEPolyLine;class ICEBezier extends q{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=ICEBezier.arrangeParam(t),super(t)}static arrangeParam(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e="cubic"===t.curveType?"cubic":"quadratic",i=t.points&&t.points.length?t.points:ICEBezier.buildDefaultPoints(t,e);return _objectSpread2(_objectSpread2({},t),{},{curveType:e,points:i})}static buildDefaultPoints(t,e){const i=t.startPoint||[0,0],s=t.endPoint||[10,10];if("cubic"===e){return[i,t.controlPoint1||[5,-5],t.controlPoint2||[5,5],s]}return[i,t.controlPoint||[5,-5],s]}}var Q=class ICELinkSlot extends M{constructor(){super(_objectSpread2({linkable:!1,draggable:!1,position:"T"},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})),_defineProperty(this,"__onHostRemoved",()=>{this._hostComponent=null,this.setState({display:!1})})}keyboardEvtHandler(t){}destory(){this.hostComponent=null,super.destory()}updatePosition(){const t=this._hostComponent.getMinBoundingBox(!0);let e=0,i=0;switch(this.state.position){case"T":e=t.tc[0]-this.state.radius,i=t.tc[1]-this.state.radius;break;case"R":e=t.rc[0]-this.state.radius,i=t.rc[1]-this.state.radius;break;case"B":e=t.bc[0]-this.state.radius,i=t.bc[1]-this.state.radius;break;case"L":e=t.lc[0]-this.state.radius,i=t.lc[1]-this.state.radius;break;case"C":e=t.center[0]-this.state.radius,i=t.center[1]-this.state.radius}this.state.left===e&&this.state.top===i||this.setState({left:e,top:i})}set hostComponent(e){const i=this._hostComponent;i&&(i.off(t.AFTER_RENDER,this.updatePosition,this),i.off(t.BEFORE_REMOVE,this.__onHostRemoved,this)),this._hostComponent=e,e&&(e.on(t.AFTER_RENDER,this.updatePosition,this),e.on(t.BEFORE_REMOVE,this.__onHostRemoved,this),this.setState({display:!0}))}get hostComponent(){return this._hostComponent}};class ICEVisioLink extends q{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t=ICEVisioLink.arrangeParam(t),super(t)}static arrangeParam(t){return isNil(t.startPoint)&&(t.startPoint=[0,0]),isNil(t.endPoint)&&(t.endPoint=[10,10]),t.points=[[...t.startPoint],[...t.endPoint]],"bezier"===(t=_objectSpread2({escapeDistance:30,linkShape:"visio"},t)).linkShape&&(t.curveType="straight"),t}__calcDots(){if("bezier"===this.state.linkShape)return this.__calcBezierDots();const t=this.interpolate(),{left:e,top:i}=this.state,s=t[0][2];this.state.points=[],this.state.dots=[];for(let t=0;t<s.length;t++){const o=s[t];this.state.points.push([o.x,o.y]),this.state.dots.push([o.x-e,o.y-i])}return this.calcArrowPoints(),this.state.dots}__calcBezierDots(){const t=this.state.points,e=[...t[0]],i=[...t[t.length-1]],{left:s,top:o}=this.state,r=this.buildBezierPoints(e,i);return this.state.points=r.map(t=>[...t]),this.state.dots=r.map(t=>[t[0]-s,t[1]-o]),this.state.curveType="straight",this.calcArrowPoints(),this.state.dots}buildBezierPoints(t,e){const i=e[0]-t[0],s=e[1]-t[1],o=Math.hypot(i,s);if(o<1e-6)return[[...t],[...e]];const r=[i/o,s/o],u=Math.max(.45*o,24),a=this.slotDirection("start",r),h=this.slotDirection("end",r),l=[t[0]+a[0]*u,t[1]+a[1]*u],c=[e[0]+h[0]*u,e[1]+h[1]*u],d=Math.min(24,Math.max(8,Math.round(o/12))),D=[];for(let i=0;i<=d;i++){const s=i/d,o=1-s,r=o*o*o*t[0]+3*o*o*s*l[0]+3*o*s*s*c[0]+s*s*s*e[0],u=o*o*o*t[1]+3*o*o*s*l[1]+3*o*s*s*c[1]+s*s*s*e[1];D.push([round(r,2),round(u,2)])}return D.filter((t,e)=>0===e||t[0]!==D[e-1][0]||t[1]!==D[e-1][1])}slotDirection(t,e){const i=this.state.links&&this.state.links[t],s=q.dirVector(i&&i.position);return 0!==s[0]||0!==s[1]?s:"start"===t?e:[-e[0],-e[1]]}recalculateRoute(){"bezier"!==this.state.linkShape&&super.recalculateRoute()}interpolate(){const t=this.state.points.length,e=this.state.points[0][0],i=this.state.points[0][1],s=this.state.points[t-1][0],o=this.state.points[t-1][1],r=new GeoPoint(e,i),u=new GeoPoint(s,o),a=[];let h,l,c=null,d=null,D=[],p=new C,f=new C;if(this.ice&&this.state.links&&this.state.links.start&&this.state.links.start.id&&(h=this.ice.findComponent(this.state.links.start.id)),h){p=h.getMinBoundingBox(),a[0]=new GeoPoint(r.x,p.tl[1]-this.state.escapeDistance),a[1]=new GeoPoint(p.tr[0]+this.state.escapeDistance,r.y),a[2]=new GeoPoint(r.x,p.br[1]+this.state.escapeDistance),a[3]=new GeoPoint(p.tl[0]-this.state.escapeDistance,r.y),c=a[0];for(let t=1;t<a.length;t++)this.distance(r,a[t])<this.distance(r,c)&&(c=a[t])}if(this.ice&&this.state.links&&this.state.links.end&&this.state.links.end.id&&(l=this.ice.findComponent(this.state.links.end.id)),l){f=l.getMinBoundingBox(),a[0]=new GeoPoint(u.x,f.tl[1]-this.state.escapeDistance),a[1]=new GeoPoint(f.tr[0]+this.state.escapeDistance,u.y),a[2]=new GeoPoint(u.x,f.br[1]+this.state.escapeDistance),a[3]=new GeoPoint(f.tl[0]-this.state.escapeDistance,u.y),d=a[0];for(let t=1;t<a.length;t++)this.distance(u,a[t])<this.distance(u,d)&&(d=a[t])}let g=0;const E=[r];c&&(E.push(c),g=1),d&&E.push(d),E.push(u);const _=GeoPoint.cloneArray(E);D.push(["s0","s0",_]);const F=GeoPoint.cloneArray(E),m=GeoPoint.cloneArray(F);m.splice(g+1,0,new GeoPoint(m[g].x,m[g+1].y)),D.push(["s1","s1_1",m]);const y=GeoPoint.cloneArray(F);y.splice(g+1,0,new GeoPoint(y[g+1].x,y[g].y)),D.push(["s1","s1_2",y]);const x=GeoPoint.cloneArray(F),A=new GeoPoint((x[g].x+x[g+1].x)/2,x[g].y),B=new GeoPoint((x[g].x+x[g+1].x)/2,x[g+1].y);x.splice(g+1,0,A,B),D.push(["s2","s2_1",x]);const v=GeoPoint.cloneArray(F),b=new GeoPoint(v[g].x,(v[g].y+v[g+1].y)/2),S=new GeoPoint(v[g+1].x,(v[g].y+v[g+1].y)/2);v.splice(g+1,0,b,S),D.push(["s2","s2_2",v]);const P=GeoPoint.cloneArray(F),M=[P[g].x+20,P[g+1].x+20];p&&M.push(p.br[0]+20),f&&M.push(f.br[0]+20);const w=this.max(M),I=new GeoPoint(w,P[g].y),T=new GeoPoint(w,P[g+1].y);P.splice(g+1,0,I,T),D.push(["s2","s2_3",P]);const R=GeoPoint.cloneArray(F),O=[R[g].y-20,R[g+1].y-20];p&&O.push(p.tl[1]-20),f&&O.push(f.tl[1]-20);const N=this.min(O),k=new GeoPoint(R[g].x,N),L=new GeoPoint(R[g+1].x,N);R.splice(g+1,0,k,L),D.push(["s2","s2_4",R]);const z=GeoPoint.cloneArray(F),X=[z[g].x-20,z[g+1].x-20];p&&X.push(p.tl[0]-20),f&&X.push(f.tl[0]-20);const V=this.min(X),G=new GeoPoint(V,z[g].y),H=new GeoPoint(V,z[g+1].y);z.splice(g+1,0,G,H),D.push(["s2","s2_5",z]);const Y=GeoPoint.cloneArray(F),W=[Y[g].y+20,Y[g+1].y+20];p&&W.push(p.tl[1]+p.height+20),f&&W.push(f.tl[1]+f.height+20);const j=this.max(W),U=new GeoPoint(Y[g].x,j),K=new GeoPoint(Y[g+1].x,j);Y.splice(g+1,0,U,K),D.push(["s2","s2_6",Y]);const q=[];for(let t=0;t<D.length;t++){const e=D[t][2];this.orthogonalPath(e)&&q.push(D[t])}if(D=q,!r.equals(u)){const t=[];for(let e=0;e<D.length;e++){const i=D[e][2];this.forwardPath(i)&&t.push(D[e])}D=t,D.length}const Q=[];for(let t=0;t<D.length;t++){let e=!1,i=D[t][2].slice();(f||p)&&(i=i.slice(1,i.length-1)),p&&(e=e||this.polylineIntersectsRectangle(i,p)),f&&(e=e||this.polylineIntersectsRectangle(i,f)),e||Q.push(D[t])}0!=Q.length&&(D=Q),D.length;const J=D[0][2].length,Z=[];for(let t=0;t<D.length;t++){D[t][2].length==J&&Z.push(D[t])}D=Z;let $=0;for(let t=0;t<D.length;t++)this.scorePath(D[$][2])<this.scorePath(D[t][2])&&($=t);return D=[D[$]],D}orthogonalPath(t){if(t.length<=1)return!0;for(let e=0;e<t.length-1;e++)if(t[e].x!=t[e+1].x&&t[e].y!=t[e+1].y)return!1;return!0}lineIntersectsLine(t,e){if(t.startPoint.x==t.endPoint.x&&e.startPoint.x==e.endPoint.x)return t.startPoint.x==e.startPoint.x&&(t.contains(e.startPoint.x,e.startPoint.y)||t.contains(e.endPoint.x,e.endPoint.y));if(t.startPoint.x==t.endPoint.x||e.startPoint.x==e.endPoint.x){if(t.startPoint.x==t.endPoint.x){const i=t;t=e,e=i}const i=(t.endPoint.y-t.startPoint.y)/(t.endPoint.x-t.startPoint.x),s=t.startPoint.y-i*t.startPoint.x,o=e.startPoint.x,r=i*o+s;return t.contains(o,r)&&e.contains(o,r)}{const i=(t.endPoint.y-t.startPoint.y)/(t.endPoint.x-t.startPoint.x),s=t.startPoint.y-i*t.startPoint.x,o=(e.endPoint.y-e.startPoint.y)/(e.endPoint.x-e.startPoint.x),r=e.startPoint.y-o*e.startPoint.x;if(i==o)return s==r&&(t.contains(e.startPoint.x,e.startPoint.y)||t.contains(e.endPoint.x,e.endPoint.y));{const u=(r-s)/(i-o),a=i*u+s;return t.contains(u,a)&&e.contains(u,a)}}}polylineIntersectsRectangle(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const s=[];s.push(new GeoLine(new GeoPoint(e.x1,e.y1),new GeoPoint(e.x2,e.y1))),s.push(new GeoLine(new GeoPoint(e.x2,e.y1),new GeoPoint(e.x2,e.y2))),s.push(new GeoLine(new GeoPoint(e.x2,e.y2),new GeoPoint(e.x1,e.y2))),s.push(new GeoLine(new GeoPoint(e.x1,e.y2),new GeoPoint(e.x1,e.y1)));for(let e=0;e<t.length-1;e++){const i=new GeoLine(t[e],t[e+1]);for(let t=0;t<s.length;t++)if(this.lineIntersectsLine(i,s[t]))return!0}if(i){const e=new GeoLine(t[t.length-1],t[0]);for(let t=0;t<s.length;t++)if(this.lineIntersectsLine(e,s[t]))return!0}return!1}scorePath(t){if(t.length<=2)return-1;let e=0;for(let i=1;i<t.length-1;i++)if(t[i-1].x==t[i].x&&t[i].x==t[i+1].x){if(this.signum(t[i+1].y-t[i].y)!=this.signum(t[i].y-t[i-1].y))return-1;e++}else if(t[i-1].y==t[i].y&&t[i].y==t[i+1].y){if(this.signum(t[i+1].x-t[i].x)!=this.signum(t[i].x-t[i-1].x))return-1;e++}else e--;return e}signum(t){return t>0?1:t<0?-1:0}forwardPath(t){if(t.length<=2)return!0;for(let e=0;e<t.length-2;e++)if(t[e].x==t[e+1].x&&t[e+1].x==t[e+2].x){if(0!=this.signum(t[e+1].y-t[e].y)&&this.signum(t[e+1].y-t[e].y)==-1*this.signum(t[e+2].y-t[e+1].y))return!1}else if(t[e].y==t[e+1].y&&t[e+1].y==t[e+2].y&&0!=this.signum(t[e+1].x-t[e].x)&&this.signum(t[e+1].x-t[e].x)==-1*this.signum(t[e+2].x-t[e+1].x))return!1;return!0}distance(t,e){return Math.hypot(e.x-t.x,e.y-t.y)}max(t){if(0==t.lenght)return NaN;{let e=t[0];for(let i=0;i<t.length;i++)e<t[i]&&(e=t[i]);return e}}min(t){if(0==t.lenght)return NaN;{let e=t[0];for(let i=0;i<t.length;i++)e>t[i]&&(e=t[i]);return e}}addDot(t,e){throw new Error("Can NOT add dot to ICEVisioLink mannually.")}rmDot(t){throw new Error("Can NOT remove dot from ICEVisioLink mannually.")}}var J=class ICEIsogon extends ICEDotPath{constructor(){const t=_objectSpread2({radius:10,edges:3,startAngle:90},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});t.edges=Math.floor(t.edges>=3?t.edges:3),t.width=2*t.radius,t.height=2*t.radius,super(t)}__calcDots(){this.state.dots=[];const t=2*Math.PI/this.state.edges,e=this.state.radius;for(let i=0;i<this.state.edges;i++){const s=t*i-toRadian(this.state.startAngle),o=Math.floor(e*Math.cos(s)+e),r=Math.floor(e*Math.sin(s)+e);this.state.dots.push([o,r])}return this.state.dots}calcComponentParams(){return this.paramsDirty?(this.calcDots(),this.state.width=2*this.state.radius,this.state.height=2*this.state.radius,{width:this.state.width,height:this.state.height}):{width:this.state.width,height:this.state.height}}setState(t){isNil(t.radius)?isNil(t.width)?isNil(t.height)||(t.radius=t.height/2):t.radius=t.width/2:(t.width=2*t.radius,t.height=2*t.radius),super.setState(t)}};var Z=class ICERose extends ICEDotPath{constructor(){const t=_objectSpread2({radius:50,leafNum:2,pointNumber:100},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});t.leafNum=Math.floor(t.leafNum>=2?t.leafNum:2),t.width=2*t.radius,t.height=2*t.radius,super(t)}__calcDots(){const t=this.state.radius,e=this.state.leafNum;this.state.dots=[];const i=Math.PI/this.state.pointNumber;let s=0,o=0,r=0;for(;s=t+t*Math.sin(e*r)*Math.cos(r),o=t+t*Math.sin(e*r)*Math.sin(r),this.state.dots.push([s,o]),r+=i,!(r>=2*Math.PI););return this.state.dots}calcComponentParams(){return this.paramsDirty?(this.calcDots(),this.state.width=2*this.state.radius,this.state.height=2*this.state.radius,{width:this.state.width,height:this.state.height}):{width:this.state.width,height:this.state.height}}setState(t){isNil(t.radius)?isNil(t.width)?isNil(t.height)||(t.radius=t.height/2,t.width=t.height):(t.radius=t.width/2,t.height=t.width):(t.width=2*t.radius,t.height=2*t.radius),super.setState(t)}};var $=class ICEStar extends ICEDotPath{constructor(){const t=_objectSpread2({outerRadius:50,innerRadius:20,startAngle:90,spikes:5},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});t.spikes=Math.floor(t.spikes>=1?t.spikes:1),t.width=2*t.outerRadius,t.height=2*t.outerRadius,super(t)}__calcDots(){this.state.dots=[];let t=toRadian(this.state.startAngle);const e=Math.PI/this.state.spikes,i=this.state.outerRadius,s=this.state.innerRadius;let o,r;for(let u=0;u<this.state.spikes;u++)o=Math.cos(t)*i+i,r=Math.sin(t)*i+i,this.state.dots.push([o,r]),t+=e,o=Math.cos(t)*s+i,r=Math.sin(t)*s+i,this.state.dots.push([o,r]),t+=e;return this.state.dots}calcComponentParams(){return this.paramsDirty?(this.calcDots(),this.state.width=2*this.state.outerRadius,this.state.height=2*this.state.outerRadius,{width:this.state.width,height:this.state.height}):{width:this.state.width,height:this.state.height}}setState(t){isNil(t.outerRadius)?isNil(t.width)?isNil(t.height)||(t.outerRadius=t.height/2):t.outerRadius=t.width/2:(t.width=2*t.outerRadius,t.height=2*t.outerRadius),super.setState(t)}};const tt=[[1424,1535],[1536,1791],[1792,1871],[1872,1919],[1920,1983],[2208,2303],[64285,65023],[65136,65279]],et=/^(?:[\t-\r -@\[-`\{-~\xA0-\xA9\xAB\xAC\xAE-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u037E\u0384\u0385\u0387\u03F6\u0482\u055A-\u055F\u0589\u058A\u058D-\u058F\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0606-\u060F\u061B\u061D-\u061F\u0660-\u066D\u06D4\u06DE\u06E9\u06F0-\u06F9\u06FD\u06FE\u0700-\u070D\u07C0-\u07C9\u07F6-\u07F9\u07FE\u07FF\u0830-\u083E\u085E\u0888\u0964-\u0970\u09E6-\u09EF\u09F2-\u09FB\u09FD\u0A66-\u0A6F\u0A76\u0AE6-\u0AF1\u0B66-\u0B70\u0B72-\u0B77\u0BE6-\u0BFA\u0C66-\u0C6F\u0C77-\u0C7F\u0C84\u0CE6-\u0CEF\u0D4F\u0D58-\u0D5E\u0D66-\u0D79\u0DE6-\u0DEF\u0DF4\u0E3F\u0E4F-\u0E5B\u0ED0-\u0ED9\u0F01-\u0F17\u0F1A-\u0F34\u0F36\u0F38\u0F3A-\u0F3D\u0F85\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FDA\u1040-\u104F\u1090-\u1099\u109E\u109F\u10FB\u1360-\u137C\u1390-\u1399\u1400\u166D\u166E\u1680\u169B\u169C\u16EB-\u16F0\u1735\u1736\u17D4-\u17D6\u17D8-\u17DB\u17E0-\u17E9\u17F0-\u17F9\u1800-\u180A\u1810-\u1819\u1940\u1944-\u194F\u19D0-\u19DA\u19DE-\u19FF\u1A1E\u1A1F\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E-\u1B6A\u1B74-\u1B7F\u1BB0-\u1BB9\u1BFC-\u1BFF\u1C3B-\u1C49\u1C50-\u1C59\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2000-\u200A\u2010-\u2029\u202F-\u205F\u2070\u2074-\u207E\u2080-\u208E\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u2182\u2185-\u218B\u2190-\u2429\u2440-\u244A\u2460-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2CF9-\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E5D\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3004\u3007-\u3029\u3030\u3036-\u303A\u303D-\u303F\u309B\u309C\u30A0\u30FB\u3190-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u3220-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA4FE\uA4FF\uA60D-\uA60F\uA620-\uA629\uA673\uA67E\uA6E6-\uA6EF\uA6F2-\uA6F7\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA830-\uA839\uA874-\uA877\uA8CE-\uA8D9\uA8F8-\uA8FA\uA8FC\uA900-\uA909\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9D0-\uA9D9\uA9DE\uA9DF\uA9F0-\uA9F9\uAA50-\uAA59\uAA5C-\uAA5F\uAA77-\uAA79\uAADE\uAADF\uAAF0\uAAF1\uAB5B\uAB6A\uAB6B\uABEB\uABF0-\uABF9\uFB29\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFEFF\uFF01-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD00-\uDD02\uDD07-\uDD33\uDD37-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDF9F\uDFD0-\uDFD5]|\uD801[\uDCA0-\uDCA9\uDD6F]|\uD802[\uDC57-\uDC5F\uDC77-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDD1F\uDD3F\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE50-\uDE58\uDE7D-\uDE7F\uDE9D-\uDE9F\uDEC8\uDEEB-\uDEF6\uDF39-\uDF3F\uDF58-\uDF5F\uDF78-\uDF7F\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDD40-\uDD49\uDD6E\uDD8E\uDD8F\uDE60-\uDE7E\uDEAD\uDED0-\uDED8\uDF1D-\uDF26\uDF51-\uDF59\uDF86-\uDF89\uDFC5-\uDFCB]|\uD804[\uDC47-\uDC4D\uDC52-\uDC6F\uDCBB\uDCBC\uDCBE-\uDCC1\uDCF0-\uDCF9\uDD36-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDD0-\uDDD9\uDDDB\uDDDD-\uDDDF\uDDE1-\uDDF4\uDE38-\uDE3D\uDEA9\uDEF0-\uDEF9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC5B\uDC5D\uDCC6\uDCD0-\uDCD9\uDDC1-\uDDD7\uDE41-\uDE43\uDE50-\uDE59\uDE60-\uDE6C\uDEB9\uDEC0-\uDEC9\uDED0-\uDEE3\uDF30-\uDF3F]|\uD806[\uDC3B\uDCE0-\uDCF2\uDD44-\uDD46\uDD50-\uDD59\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1\uDFF0-\uDFF9]|\uD807[\uDC41-\uDC45\uDC50-\uDC6C\uDC70\uDC71\uDD50-\uDD59\uDDA0-\uDDA9\uDDE0-\uDDE9\uDEF7\uDEF8\uDF43-\uDF59\uDFC0-\uDFF1\uDFFF]|\uD809[\uDC00-\uDC6E\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD818[\uDD30-\uDD39]|\uD81A[\uDE60-\uDE69\uDE6E\uDE6F\uDEC0-\uDEC9\uDEF5\uDF37-\uDF3F\uDF44\uDF45\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDD6D-\uDD79\uDE80-\uDE9A\uDFE2\uDFF4-\uDFF6]|\uD82F[\uDC9C\uDC9F]|\uD833[\uDC00-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDEC0-\uDED3\uDEE0-\uDEF3\uDF00-\uDF56\uDF60-\uDF78]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCE-\uDFFF]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE8B]|\uD838[\uDD40-\uDD49\uDD4F\uDEF0-\uDEF9\uDEFF]|\uD839[\uDCF0-\uDCF9\uDDF1-\uDDFA\uDDFF]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDC71-\uDCB4\uDD01-\uDD3D\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD00-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFFA])$/,it=/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])$/;function isRtlCodePoint(t){for(let e=0;e<tt.length;e++)if(t>=tt[e][0]&&t<=tt[e][1])return!0;return!1}function resolveTextDirection(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auto";if("ltr"===e||"rtl"===e)return e;const i=String(null!=t?t:"");for(const t of i)if(!et.test(t)&&it.test(t))return isRtlCodePoint(t.codePointAt(0))?"rtl":"ltr";return"ltr"}function resolveTextAlign(t,e){switch(t){case"center":return"center";case"right":return"right";case"start":return"rtl"===e?"right":"left";case"end":return"rtl"===e?"left":"right";default:return"left"}}const st=new Set(["、","。",",",".",";",":","?","!",")","]","}","〉","》","」","』","】","〕","〗","”","’","·","…","—","ー","々","ぁ","ぃ","ぅ","ぇ","ぉ","っ","ゃ","ゅ","ょ","ゎ","ァ","ィ","ゥ","ェ","ォ","ッ","ャ","ュ","ョ","ヮ"]),nt=new Set(["(","[","{","〈","《","「","『","【","〔","〖","“","‘"]),ot=/^[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]$/,rt=/^(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088F\u0897-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09F4-\u09F9\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71-\u0B77\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BF2\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3C-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C5C\u0C5D\u0C60-\u0C63\u0C66-\u0C6F\u0C78-\u0C7E\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDC-\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1-\u0CF3\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D63\u0D66-\u0D78\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u17F0-\u17F9\u180B-\u180D\u180F-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B4C\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u20D0-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA827\uA82C\uA830-\uA835\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE6\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD6D\uDD6F-\uDD85\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDEC2-\uDEC7\uDEFA-\uDF27\uDF30-\uDF54\uDF70-\uDF85\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC52-\uDC75\uDC7F-\uDCBA\uDCC2\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE37\uDE3E-\uDE41\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD3\uDFE1\uDFE2]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDED0-\uDEE3\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF3B\uDF40-\uDF46]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEB0-\uDEF8\uDF60-\uDF67\uDFC0-\uDFE0\uDFF0-\uDFF9]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDDB0-\uDDDB\uDDE0-\uDDE9\uDEE0-\uDEF6\uDF00-\uDF10\uDF12-\uDF3A\uDF3E-\uDF42\uDF50-\uDF5A\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC40-\uDC55\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD39]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDD70-\uDD79\uDE40-\uDE96\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0-\uDFF6]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD833[\uDCF0-\uDCF9\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44\uDEC0-\uDED3\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC30-\uDC6D\uDC8F\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAE\uDEC0-\uDEF9]|\uD839[\uDCD0-\uDCF9\uDDD0-\uDDFA\uDEC0-\uDEDE\uDEE0-\uDEF5\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]|\uDB40[\uDD00-\uDDEF])$/,ut=/^[\x2D\u2010-\u2014]$/,at=/[\u2E80-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFF00-\uFFEF]/,ht=/[\u0E00-\u0EFF\u1000-\u109F\u1780-\u17FF]/,lt=new Map,ct=new Map;function segmentDictionaryWords(t,e){const i=ct.get(t);if(i)return i;let s=null;const o=e&&e.Segmenter;if("function"==typeof o)try{const e=new o(void 0,{granularity:"word"});s=[];for(const i of e.segment(t))s.push(i.segment)}catch(t){s=null}return s&&s.length||(s=splitGraphemes(t,e)),ct.size>500&&ct.clear(),ct.set(t,s),s}function splitGraphemes(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"undefined"!=typeof Intl?Intl:void 0;const i=lt.get(t);if(i)return i;let s;if(e&&"function"==typeof e.Segmenter)try{const i=new e.Segmenter(void 0,{granularity:"grapheme"});s=[];for(const e of i.segment(t))s.push(e.segment)}catch(e){s=Array.from(t)}else s=Array.from(t);return lt.size>500&&lt.clear(),lt.set(t,s),s}function firstGrapheme(t){return splitGraphemes(t)[0]||""}function lastGrapheme(t){const e=splitGraphemes(t);return e[e.length-1]||""}function hardBreak(t,e,i,s){const o=splitGraphemes(t);let r="";for(let t=0;t<o.length;t++){const u=r+o[t];""!==r&&i(u)>e?(s.push(r),r=o[t]):r=u}return r}function wrapParagraph(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"normal",o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"undefined"!=typeof Intl?Intl:void 0;const r=splitGraphemes(t,o);if(!(e>0))return[t];if("break-all"===s)return function greedyWrap(t,e,i){const s=[];let o="";for(let r=0;r<t.length;r++){const u=o+t[r];""!==o&&i(u)>e?(s.push(o),o=t[r]):o=u}return s.push(o),s}(r,e,i);const u=function toUnits(t,e){const i=[];let s="";const flushWord=()=>{s&&(i.push(s),s="")};for(let o=0;o<t.length;o++){const r=t[o];if(ht.test(r)){flushWord();let s=r;for(;o+1<t.length&&ht.test(t[o+1]);)s+=t[++o];for(const t of segmentDictionaryWords(s,e))i.push(t);continue}if(!rt.test(r)||at.test(r))if(ut.test(r)&&s&&o+1<t.length&&rt.test(t[o+1]))i.push(s+r),s="";else{if(flushWord(),ot.test(r)){let e=r;for(;o+1<t.length&&ot.test(t[o+1]);)e+=t[++o];i.push(e);continue}i.push(r)}else s+=r}return flushWord(),i}(r,o),a=[];let h="";for(let t=0;t<u.length;t++){const s=u[t];if(""!==h&&i(h+s)>e){if(st.has(firstGrapheme(s))){h+=s;continue}const t=lastGrapheme(h);let e="";nt.has(t)&&(e=t,h=h.slice(0,h.length-t.length)),a.push(h.replace(/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+$/,"")),h=e+s;continue}""===h&&i(s)>e?h=hardBreak(s,e,i,a):h+=s}return a.push(h.replace(/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+$/,"")),a.length?a:[""]}const dt="__ICE_UTILS_TEXT_MEASURE_DIV__";class ICEText extends B{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(ICEText.arrangeParam(t)),_defineProperty(this,"__autoWidth",!0),_defineProperty(this,"__autoHeight",!0),_defineProperty(this,"__lineWidthCache",null),_defineProperty(this,"__inkMetrics",null),_defineProperty(this,"__fontMetrics",null),_defineProperty(this,"__originalDraggable",!0),_defineProperty(this,"__editInput",null),_defineProperty(this,"__directionApplied",!1),this.__autoWidth=null==t||void 0===t.width,this.__autoHeight=null==t||void 0===t.height,this.measureText()}static arrangeParam(t){const e=merge({text:"",left:0,top:0,width:10,height:10,editing:!1,caretIndex:0,selectionStart:-1,selectionEnd:-1,multiline:!1,wrap:!1,wordBreak:"normal",direction:"auto",maxLines:0,ellipsis:"…",lines:null,transformable:!1,style:{fontWeight:"bold",fontSize:32,fontFamily:"Arial",lineWidth:1,textBaseline:"bottom",lineHeight:0,letterSpacing:0,textDecoration:"none",textDecorationColor:"",textDecorationWidth:0,selectionColor:"rgba(64,128,255,0.35)",paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0}},t);return e.style=_objectSpread2(_objectSpread2({},e.style),{},{font:"".concat(e.style.fontWeight," ").concat(e.style.fontSize,"px ").concat(e.style.fontFamily)}),e}initEvents(){super.initEvents(),this.on("dblclick",this.startEditing,this)}startEditing(){this.__originalDraggable=this.state.draggable,this.setState({editing:!0,caretIndex:this.state.text.length,draggable:!1}),this.ice&&this.ice.controlPanelManager&&this.ice.controlPanelManager.transformControlPanel.disable(),this.ice&&this.ice.evtBus&&this.ice.evtBus.on("mousedown",this.__globalMouseDownHandler,this),this.__mountEditInput()}stopEditing(){this.ice&&this.ice.evtBus&&this.ice.evtBus.off("mousedown",this.__globalMouseDownHandler,this),this.__unmountEditInput(),this.setState({editing:!1,draggable:this.__originalDraggable})}__mountEditInput(){const t=this.root&&this.root.document;if(!t||!t.body)return;const e=this.getMinBoundingBox(!0),i=this.ice&&this.ice.canvasEl?this.ice.canvasEl.getBoundingClientRect():{left:0,top:0},{paddingTop:s,paddingRight:o,paddingBottom:r,paddingLeft:u}=this.state.style,a=Math.max(this.state.width-u-o,1),h=Math.max(this.state.height-s-r,this.state.style.fontSize),l=this.__isMultilineEditing(),c=t.createElement(l?"textarea":"input");l||(c.type="text"),c.value=this.state.text,c.style.position="absolute",c.style.left=i.left+e.tl[0]+"px",c.style.top=i.top+e.tl[1]+"px",c.style.width=a+"px",c.style.height=h+"px",c.style.font=this.state.style.font,c.style.paddingTop=s+"px",c.style.paddingRight=o+"px",c.style.paddingBottom=r+"px",c.style.paddingLeft=u+"px",c.style.boxSizing="content-box",c.style.color="transparent",c.style.caretColor=this.state.style.fillStyle||"#000000",c.style.background="transparent",c.style.border="none",c.style.outline="none",c.style.margin="0",c.style.zIndex="9999",l&&(c.style.whiteSpace="pre",c.style.overflow="hidden",c.style.resize="none",c.wrap="off"),t.body.appendChild(c),c.focus(),c.setSelectionRange(c.value.length,c.value.length);const syncSelection=()=>{const t="number"==typeof c.selectionStart?c.selectionStart:-1,e="number"==typeof c.selectionEnd?c.selectionEnd:-1,i=e>=0?e:this.state.caretIndex;this.state.caretIndex===i&&this.state.selectionStart===t&&this.state.selectionEnd===e||this.setState({caretIndex:i,selectionStart:t,selectionEnd:e})};c.addEventListener("input",()=>{this.setText(c.value),syncSelection()}),c.addEventListener("compositionend",()=>{this.setText(c.value),syncSelection()}),c.addEventListener("select",syncSelection),c.addEventListener("keyup",syncSelection),c.addEventListener("mouseup",syncSelection),c.addEventListener("keydown",t=>{t.isComposing||("Escape"!==t.key?"Enter"===t.key&&(!l||t.ctrlKey||t.metaKey)&&this.stopEditing():this.stopEditing())}),c.addEventListener("blur",()=>{this.stopEditing()}),this.__editInput=c}__unmountEditInput(){this.__editInput&&this.__editInput.parentNode&&this.__editInput.parentNode.removeChild(this.__editInput),this.__editInput=null}__globalMouseDownHandler(t){(t&&t.param&&t.param.component)!==this&&this.stopEditing()}setText(t){const e=Math.max(0,Math.min(this.state.caretIndex,t.length));return this.setState({text:t,caretIndex:e}),this}getText(){return this.state.text}remeasureText(){return this.__paramsDirty=!0,this.dirty=!0,this.__lineWidthCache=null,this}__beforeStateMerge(t){return t&&(void 0!==t.width&&(this.__autoWidth=!1),void 0!==t.height&&(this.__autoHeight=!1),this.__lineWidthCache=null),super.__beforeStateMerge(t)}keyboardEvtHandler(t){if(this.__editInput)return;if(!this.state.editing)return void super.keyboardEvtHandler(t);if("keydown"!==t.type)return;const e=t.key,i=this.state.text,s=this.state.caretIndex;if("Escape"!==e)if("Enter"!==e){if("Backspace"!==e){if("Delete"!==e)"ArrowLeft"!==e?"ArrowRight"!==e?"Home"!==e?"End"!==e?e&&1===e.length&&this.setState({text:i.slice(0,s)+e+i.slice(s),caretIndex:s+1}):this.setState({caretIndex:i.length}):this.setState({caretIndex:0}):this.setState({caretIndex:this.__nextGraphemeBoundary(i,s)}):this.setState({caretIndex:this.__prevGraphemeBoundary(i,s)});else if(s<i.length){const t=this.__nextGraphemeBoundary(i,s);this.setState({text:i.slice(0,s)+i.slice(t)})}}else if(s>0){const t=this.__prevGraphemeBoundary(i,s);this.setState({text:i.slice(0,t)+i.slice(s),caretIndex:t})}}else this.__isMultilineEditing()?this.setState({text:i.slice(0,s)+"\n"+i.slice(s),caretIndex:s+1}):this.stopEditing();else this.stopEditing()}__prevGraphemeBoundary(t,e){if(e<=0)return 0;const i=this.__graphemes(t.slice(0,e));return i.length?e-i[i.length-1].length:0}__nextGraphemeBoundary(t,e){if(e>=t.length)return t.length;const i=this.__graphemes(t.slice(e));return i.length?e+i[0].length:t.length}__isMultilineEditing(){var t;return!!this.state.multiline||String(null!==(t=this.state.text)&&void 0!==t?t:"").indexOf("\n")>=0}__lineBoxes(){const t=this.getRenderLines(),e=Math.max(1,t.length),i=(Number(this.state.textHeight)||this.__fontSizePx())/e,s=this.__lineWidths(t.map(t=>t.text)),o=this.__fontSizePx(),r=this.__inkMetrics||{ascent:.8*o,descent:.2*o},u=this.__fontMetrics||{ascent:.8*o,descent:.2*o},a=Math.max(1,r.ascent+r.descent),h=Math.max(0,i-a),l=[];for(let e=0;e<t.length;e++){const o=this.state.style.textBaseline||"alphabetic";let a;a="top"===o||"hanging"===o?u.ascent:"middle"===o?(u.ascent-u.descent)/2:"bottom"===o||"ideographic"===o?-u.descent:0;const c=t[e].y+a-r.ascent;l.push({text:t[e].text,x:t[e].x,width:s[e]||0,top:c-h/2,height:i})}return l}getSelection(){var t;const e=String(null!==(t=this.state.text)&&void 0!==t?t:""),i=Number(this.state.selectionStart),s=Number(this.state.selectionEnd);return i>=0&&s>=0?{start:Math.max(0,Math.min(i,e.length)),end:Math.max(0,Math.min(s,e.length))}:{start:-1,end:-1}}setSelection(t,e){var i;const s=String(null!==(i=this.state.text)&&void 0!==i?i:""),clamp=t=>Math.max(0,Math.min(Number.isFinite(t)?t:0,s.length)),o=clamp(t),r=clamp(void 0===e?t:e);return this.setState({selectionStart:o,selectionEnd:r,caretIndex:r}),this.__editInput&&"function"==typeof this.__editInput.setSelectionRange&&this.__editInput.setSelectionRange(o,r),this}selectAll(){var t;return this.setSelection(0,String(null!==(t=this.state.text)&&void 0!==t?t:"").length)}clearSelection(){return this.setSelection(this.state.caretIndex,this.state.caretIndex)}getCaretIndexAt(t,e){var i;const s=String(null!==(i=this.state.text)&&void 0!==i?i:"");if(!s)return 0;if(this.state.lines&&!this.state.editing)return 0;const o=this.__lineBoxes();let r=o[0],u=0;for(let t=0;t<o.length;t++){if(e>=o[t].top&&e<=o[t].top+o[t].height){r=o[t],u=t;break}const i=o[t].top+o[t].height/2,s=r.top+r.height/2;Math.abs(e-i)<Math.abs(e-s)&&(r=o[t],u=t)}let a=0;const h=s.split("\n");for(let t=0;t<u&&t<h.length;t++)a+=h[t].length+1;const l=this.__measureFn(),c=resolveTextDirection(r.text,this.state.direction),d=this.__graphemes(r.text),D=[];let p=0;for(let t=0;t<d.length;t++)D.push(p),p+=l(d[t])||0;D.push(p);const visualX=t=>"rtl"===c?r.x+r.width-D[t]:r.x+D[t];let f=0,g=1/0;for(let e=0;e<=d.length;e++){const i=Math.abs(t-visualX(e));i<g&&(g=i,f=e)}return a+d.slice(0,f).join("").length}containsLocalPoint(t,e){var i;if(!super.containsLocalPoint(t,e))return!1;if(!this.state.editing)return!0;if(!String(null!==(i=this.state.text)&&void 0!==i?i:""))return!0;const s=.5*this.__fontSizePx(),o=this.__lineBoxes();for(let i=0;i<o.length;i++){const r=o[i];if(e<r.top-s||e>r.top+r.height+s)continue;const u=Math.min(r.x,r.x+r.width)-s,a=Math.max(r.x,r.x+r.width)+s;if(t>=u&&t<=a)return!0}return!1}renderSelection(){var t;if(this.__editInput)return;const{start:e,end:i}=this.getSelection();if(!(i>e))return;if(this.state.lines&&!this.state.editing)return;const s=String(null!==(t=this.state.text)&&void 0!==t?t:""),o=s.split("\n"),r=this.__lineBoxes(),u=this.state.style.selectionColor;if(!u)return;const a=this.__measureFn(),h=resolveTextDirection(s,this.state.direction);this.ctx.save(),this.ctx.fillStyle=u;let l=0;for(let t=0;t<r.length&&l<=i;t++){const s=r[t].text,u=l+s.length;if(u>=e){const o=Math.max(0,e-l),u=Math.min(s.length,i-l);if(u>o){const e=a(s.slice(0,o))||0,i=a(s.slice(0,u))||0,l=i-e,c="rtl"===h?r[t].x+r[t].width-i:r[t].x+e;this.ctx.fillRect(c,r[t].top,l,r[t].height)}}if(l=u+1,t>=o.length-1)break}this.ctx.restore()}renderCaret(){var t;if(this.__editInput)return;const e=String(null!==(t=this.state.text)&&void 0!==t?t:""),i=Math.max(0,Math.min(this.state.caretIndex,e.length)),s=this.__lineBoxes();let o=s.length-1,r=0;for(let t=0;t<s.length;t++){const e=r+s[t].text.length;if(i<=e){o=t;break}r=e+1}const u=s[o],a=Math.max(0,Math.min(i-r,u.text.length)),h=u.text.slice(0,a),l=resolveTextDirection(u.text,this.state.direction),c=this.__measureFn()(h)||0,d="rtl"===l?u.x+u.width-c:u.x+c,D=u.top,p=u.top+u.height;this.ctx.save(),this.ctx.strokeStyle=this.state.style.fillStyle||"#000000",this.ctx.lineWidth=1,this.ctx.beginPath(),this.ctx.moveTo(d,D),this.ctx.lineTo(d,p),this.ctx.stroke(),this.ctx.restore()}calcComponentParams(){return this.paramsDirty?this.measureText():{width:this.state.width,height:this.state.height}}measureText(t){this.state.lines=this.__computeWrappedLines();const e=this.__measureByCanvas();return e?(this.__applyMeasuredSize(e),{width:this.state.width,height:this.state.height}):this.__measureByDOM()}__computeWrappedLines(){var t;if(!this.state.wrap||this.state.editing)return null;const e=Number(this.state.width);if(!(e>0))return null;const i=this.ctx;if(!i||"function"!=typeof i.measureText)return null;const s=this.__measureFn(),o=this.__wrapText(e,s);return this.__truncateLines(o,e,Number(this.state.maxLines)||0,String(null!==(t=this.state.ellipsis)&&void 0!==t?t:"…"),s)}__measureFn(){const t=this.ctx;this.state.style.font&&t&&"function"==typeof t.measureText&&(t.font=this.state.style.font),this.__applyLetterSpacingToCtx();const e=Number(this.state.style.fontSize)||12;return i=>{if(t&&"function"==typeof t.measureText){const e=t.measureText(i);return e&&e.width||0}return i.length*e}}__fontSizePx(){return Number(this.state.style.fontSize)||12}__applyLetterSpacingToCtx(){const t=this.ctx;t&&"letterSpacing"in t&&(t.letterSpacing=resolveLetterSpacingCss(this.state.style.letterSpacing,this.__fontSizePx()))}__lineAdvance(t){const e=resolveLineHeightPx(this.state.style.lineHeight,this.__fontSizePx());return null!==e?e:Math.max(t,this.__fontSizePx()*ICEText.LINE_HEIGHT_RATIO)}__graphemes(t){return splitGraphemes(t,this.root&&this.root.Intl)}__wrapText(t,e){var i;const s=[],o=String(null!==(i=this.state.text)&&void 0!==i?i:"").split("\n"),r="break-all"===this.state.wordBreak?"break-all":"normal",u=this.root&&this.root.Intl;for(let i=0;i<o.length;i++){const a=wrapParagraph(o[i],t,e,r,u);for(let t=0;t<a.length;t++)s.push(a[t])}return s}__truncateLines(t,e,i,s,o){if(!(i>0)||t.length<=i)return t;const r=t.slice(0,i),u=this.__graphemes(r[i-1]);for(;u.length>0&&o(u.join("")+s)>e;)u.pop();return r[i-1]=u.join("")+s,r}__measureByCanvas(){var t;if(!this.ctx||"function"!=typeof this.ctx.measureText)return null;this.state.style.font&&(this.ctx.font=this.state.style.font),this.__applyLetterSpacingToCtx();const e=this.state.lines||String(null!==(t=this.state.text)&&void 0!==t?t:"").split("\n");let i=0,s=0,o=0,r=0,u=0;const a=[];for(const t of e){const e=this.ctx.measureText(t),h=e.width||0;a.push(h),i=Math.max(i,h);const l=e.actualBoundingBoxAscent,c=e.actualBoundingBoxDescent;if("number"!=typeof l||"number"!=typeof c)return null;s=Math.max(s,l),o=Math.max(o,c);const d=e.fontBoundingBoxAscent,D=e.fontBoundingBoxDescent;"number"==typeof d&&"number"==typeof D&&(r=Math.max(r,d),u=Math.max(u,D))}if(this.__cacheLineWidths(e,a),this.__inkMetrics={ascent:s,descent:o},r>0||u>0)this.__fontMetrics={ascent:r,descent:u};else{const t=this.__fontSizePx();this.__fontMetrics={ascent:.8*t,descent:.2*t}}const h=s+o,l=resolveLineHeightPx(this.state.style.lineHeight,this.__fontSizePx());if(e.length<=1&&null===l)return{textWidth:i,textHeight:h};return{textWidth:i,textHeight:this.__lineAdvance(h)*e.length}}__applyMeasuredSize(t){const{paddingTop:e,paddingBottom:i,paddingLeft:s,paddingRight:o}=this.state.style,r=t.textWidth+s+o,u=t.textHeight+e+i;this.__autoWidth&&(this.state.width=r),this.__autoHeight&&(this.state.height=u),this.state.textHeight=t.textHeight}__measureByDOM(){let t;try{const e=this.root&&this.root.document;if(!e||"function"!=typeof e.getElementById)return{width:this.state.width,height:this.state.height};if(t=this.root.document.getElementById(dt),!t){t=this.root.document.createElement("div"),t.setAttribute("id",dt);const e={visibility:"hidden",position:"absolute",top:"0",left:"0",padding:"0",margin:"0",border:"none",fontFamily:this.state.style.fontFamily,fontWeight:this.state.style.fontWeight,fontSize:this.state.style.fontSize+"px",letterSpacing:resolveLetterSpacingCss(this.state.style.letterSpacing,this.__fontSizePx()),lineHeight:"1",whiteSpace:"pre"},i=resolveLineHeightPx(this.state.style.lineHeight,this.__fontSizePx());null!==i&&(e.lineHeight=i+"px");for(const i in e)t.style[i]=e[i];t.contenteditable=!1,this.root.document.body.appendChild(t)}t.textContent=this.state.text;const{paddingTop:i,paddingBottom:s,paddingLeft:o,paddingRight:r}=this.state.style,u={width:t.offsetWidth+o+r,height:t.offsetHeight+i+s};return this.__autoWidth&&(this.state.width=u.width),this.__autoHeight&&(this.state.height=u.height),this.state.textHeight=t.offsetHeight,{width:this.state.width,height:this.state.height}}catch(t){return{width:this.state.width,height:this.state.height}}}__lineWidthsKey(t){return t.join("\0")+""+(this.state.style.font||"")+""+resolveLetterSpacingCss(this.state.style.letterSpacing,this.__fontSizePx())}__cacheLineWidths(t,e){this.__lineWidthCache={key:this.__lineWidthsKey(t),widths:e.slice()}}__lineWidths(t,e){const i=this.__lineWidthsKey(t),s=this.__lineWidthCache;if(s&&s.key===i&&s.widths.length===t.length)return s.widths;const o=e||this.__measureFn(),r=[];for(let e=0;e<t.length;e++)r.push(o(t[e])||0);return this.__lineWidthCache={key:i,widths:r},r}getRenderLines(){var t;const{paddingTop:e,paddingLeft:i,paddingRight:s,textAlign:o,textBaseline:r}=this.state.style,u=resolveTextAlign(o,this.__resolvedDirection()),a=this.state.lines||String(null!==(t=this.state.text)&&void 0!==t?t:"").split("\n"),h=(this.state.textHeight||this.state.style.fontSize)/a.length,l="center"===u||"right"===u,c=l?this.__lineWidths(a):null,d=[];for(let t=0;t<a.length;t++){let o=0-this.state.localOrigin[0]+i;if(l){const e=c&&c[t]||0;o="center"===u?-e/2:this.state.localOrigin[0]-s-e}let D=0-this.state.localOrigin[1]+e+(t+1)*h;"middle"===r&&(D=(t-(a.length-1)/2)*h),d.push({text:a[t],x:o,y:D})}return d}doRender(){this.dirty&&this.measureText();const t=resolveTextAlign(this.state.style.textAlign,this.__resolvedDirection()),e=this.getRenderLines();("center"===t||"right"===t)&&(this.ctx.textAlign="left"),this.renderSelection();for(let t=0;t<e.length;t++)this.state.stroke&&this.ctx.strokeText(e[t].text,e[t].x,e[t].y,this.state.width),this.state.fill&&this.ctx.fillText(e[t].text,e[t].x,e[t].y,this.state.width);this.__drawTextDecoration(e),this.state.editing&&this.renderCaret(),super.doRender()}__drawTextDecoration(t){const e=resolveTextDecorations(this.state.style.textDecoration);if(!e.length)return;const i=this.state.style.textDecorationColor||(this.state.fill?this.state.style.fillStyle:"");if(!i)return;const s=this.__fontSizePx(),o=Number(this.state.style.textDecorationWidth)>0?Number(this.state.style.textDecorationWidth):Math.max(1,s/14),r={underline:.12*s,"line-through":.3*-s,overline:.8*-s},u=this.__lineWidths(t.map(t=>t.text));this.ctx.save(),this.ctx.strokeStyle=i,this.ctx.lineWidth=o;for(let i=0;i<t.length;i++){const s=u[i]||0;if(s>0)for(const o of e){const e=t[i].y+(r[o]||0);this.ctx.beginPath(),this.ctx.moveTo(t[i].x,e),this.ctx.lineTo(t[i].x+s,e),this.ctx.stroke()}}this.ctx.restore()}applyStyleToCtx(){super.applyStyleToCtx();const t=this.ctx;this.__applyLetterSpacingToCtx(),t&&"direction"in t&&(t.direction=this.__resolvedDirection(),this.__directionApplied=!0)}__resetLeakyCtxState(){if(this.__directionApplied){this.__directionApplied=!1;const t=this.ctx;t&&"direction"in t&&(t.direction="inherit")}super.__resetLeakyCtxState()}__resolvedDirection(){var t;return resolveTextDirection(String(null!==(t=this.state.text)&&void 0!==t?t:""),this.state.direction)}}_defineProperty(ICEText,"LINE_HEIGHT_RATIO",1.35);var Dt=ICEText;var pt=class ICELayoutManager{getPreferredSize(t){return[0,0]}};var ft=class ICEFlowLayout extends pt{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.gap=t.gap||10,this.align=t.align||"left"}layoutContainer(t){const e=t.childNodes,i=t.state.width,s=this.gap,o=[[]];let r=0;for(const t of e){const e=t.state.width;r>0&&r+s+e>i&&(o.push([]),r=0),o[o.length-1].push(t),r+=r>0?s+e:e}let u=0;for(const t of o){let e=0,o=0;for(const i of t)e+=i.state.width,o=Math.max(o,i.state.height);e+=s*(t.length-1);let r=0;"center"===this.align?r=(i-e)/2:"right"===this.align&&(r=i-e);for(const e of t)e.setState({left:r,top:u}),r+=e.state.width+s;u+=o+s}}};var gt=class ICEGridLayout extends pt{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.cols=t.cols||2,this.gapX=t.gapX||10,this.gapY=t.gapY||10}layoutContainer(t){const e=t.childNodes;let i=0,s=0,o=0,r=0;for(const t of e)t.setState({left:i,top:s}),i+=t.state.width+this.gapX,o=Math.max(o,t.state.height),r++,r>=this.cols&&(r=0,i=0,s+=o+this.gapY,o=0)}};var Et=class ICEBorderLayout extends pt{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.gap=t.gap||5}layoutContainer(t){const e=t.childNodes,i=t.state.width,s=t.state.height;let o=null,r=null,u=null,a=null,h=null;e.forEach(t=>{const e=t.state.layoutConstraint||"center";"north"===e?o=t:"south"===e?r=t:"east"===e?u=t:"west"===e?a=t:h=t});let l=0,c=s,d=0,D=i;o&&(o.setState({left:0,top:0,width:i}),l=o.state.height+this.gap),r&&(r.setState({left:0,top:s-r.state.height,width:i}),c=s-r.state.height-this.gap),u&&(u.setState({left:i-u.state.width,top:l,height:c-l}),D=i-u.state.width-this.gap),a&&(a.setState({left:0,top:l,height:c-l}),d=a.state.width+this.gap),h&&h.setState({left:d,top:l,width:D-d,height:c-l})}};var _t=class ICEBoxLayout extends pt{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.axis=t.axis||"x",this.gap=t.gap||5}layoutContainer(t){let e=0;for(const i of t.childNodes)"x"===this.axis?(i.setState({left:e,top:0}),e+=i.state.width+this.gap):(i.setState({left:0,top:e}),e+=i.state.height+this.gap)}};var Ct=class ICECardLayout extends pt{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),_defineProperty(this,"currentIndex",0),_defineProperty(this,"container",null),this.currentIndex=t.currentIndex||0}layoutContainer(t){this.container=t,t.childNodes.forEach((t,e)=>{t.setState({display:e===this.currentIndex,left:0,top:0})})}show(t){this.currentIndex=t,this.container&&this.layoutContainer(this.container)}next(){this.show(this.currentIndex+1)}previous(){this.show(this.currentIndex-1)}};var Ft=class ICEOverlayLayout extends pt{layoutContainer(t){for(const e of t.childNodes)e.setState({left:0,top:0})}};var mt=class ICELayeredLayout extends pt{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.gapX=t.gapX||80,this.gapY=t.gapY||40}layoutContainer(t){const e=t.childNodes||[],i=[],s=[];for(const t of e)if(t.isLine){const e=t.getLinkFromId?t.getLinkFromId():null,i=t.getLinkToId?t.getLinkToId():null;s.push({from:e,to:i,component:t})}else i.push({id:t.props.id,component:t,rank:0,order:0,barycenter:0});if(0===i.length)return;const o={};i.forEach(t=>o[t.id]=t);const r=s.filter(t=>t.from&&t.to&&o[t.from]&&o[t.to]);this.assignRanks(i,r),this.assignOrders(i,r,o),this.assignCoords(i,r,o)}assignRanks(t,e){const i={},visit=(t,s)=>{if(void 0!==i[t])return i[t];if(s.has(t))return 0;s.add(t);const o=e.filter(e=>e.to===t).map(t=>t.from);let r=-1;for(const t of o)r=Math.max(r,visit(t,s));return i[t]=r+1,s.delete(t),i[t]};t.forEach(t=>{t.rank=visit(t.id,new Set)})}assignOrders(t,e,i){const s={};t.forEach(t=>{(s[t.rank]=s[t.rank]||[]).push(t)});const o=Object.keys(s).map(Number).sort((t,e)=>t-e);o.forEach(t=>s[t].forEach((t,e)=>t.order=e));for(let t=0;t<4;t++)for(const t of o){const o=s[t];o.forEach(t=>{const s=e.filter(e=>e.from===t.id).map(t=>i[t.to]);t.barycenter=s.length?s.reduce((t,e)=>t+e.order,0)/s.length:t.order}),o.sort((t,e)=>t.barycenter-e.barycenter),o.forEach((t,e)=>t.order=e)}}assignCoords(t,e,i){const s={};t.forEach(t=>{(s[t.rank]=s[t.rank]||[]).push(t)});const o=Object.keys(s).map(Number).sort((t,e)=>t-e),r=this.gapX,u=this.gapY;let a=0;o.forEach(t=>{const e=s[t],i=Math.max(...e.map(t=>t.component.state.width));let o=0;e.forEach(t=>{t.component.setState({left:a,top:o}),o+=t.component.state.height+u}),a+=i+r});for(const t of e){const e=i[t.from].component,s=i[t.to].component,o=e.state.left+e.state.width,r=e.state.top+e.state.height/2,u=s.state.left,a=s.state.top+s.state.height/2;t.component.setState({startPoint:[o,r],endPoint:[u,a]})}}};const yt=[{typeId:"ice-render:Rect",ctor:b},{typeId:"ice-render:Circle",ctor:M},{typeId:"ice-render:Ellipse",ctor:P},{typeId:"ice-render:Star",ctor:$},{typeId:"ice-render:Isogon",ctor:J},{typeId:"ice-render:Rose",ctor:Z},{typeId:"ice-render:Text",ctor:Dt},{typeId:"ice-render:Image",ctor:K},{typeId:"ice-render:Group",ctor:S},{typeId:"ice-render:VisioLink",ctor:ICEVisioLink},{typeId:"ice-render:PolyLine",ctor:q},{typeId:"ice-render:Bezier",ctor:ICEBezier}],xt={};for(let t=0;t<yt.length;t++){const e=yt[t];xt[e.typeId]=e.ctor}const At={evtBuses:[],stopped:!1,frameCallback:function(){for(let e=0;e<At.evtBuses.length;e++){if(At.stopped)return;At.evtBuses[e].trigger(t.ICE_FRAME_EVENT)}At.stopped||p.requestFrame(At.frameCallback)},start:function(){At.stopped=!1,p.requestFrame(At.frameCallback)},stop:function(){At.stopped=!0},registerEvtBus:function(t){At.evtBuses.includes(t)||At.evtBuses.push(t)},delEvtBus:function(t){At.evtBuses.includes(t)&&At.evtBuses.splice(At.evtBuses.indexOf(t),1)}};var Bt=At;class ICELinkSlotManager{constructor(t){_defineProperty(this,"slotRadius",10),this.ice=t}start(){return this.createLinkSlots(),this.ice.evtBus.on(t.HOOK_MOUSEMOVE,this.hookMouseMoveHandler,this),this.ice.evtBus.on(t.HOOK_MOUSEUP,this.hookMouseUpHandler,this),this.ice.evtBus.on("mouseup",this.globalMouseUpHandler,this),this}stop(){return this.ice.evtBus.off(t.HOOK_MOUSEMOVE,this.hookMouseMoveHandler,this),this.ice.evtBus.off(t.HOOK_MOUSEUP,this.hookMouseUpHandler,this),this.ice.evtBus.off("mouseup",this.globalMouseUpHandler,this),this}hookMouseMoveHandler(t){const e=t.target,i=e.getMaxBoundingBox(),s=flattenTree([],this.ice.childNodes);s.sort((t,e)=>t.state.zIndex-e.state.zIndex),this.collision=null;for(let t=0;t<s.length;t++){const e=s[t];if(!e||!e.state.linkable||!isEffectivelyVisible(e))continue;e.getMaxBoundingBox().isIntersect(i)&&(this.collision=e)}if(!this.collision){for(let t=0;t<this.ice._linkSlots.length;t++){this.ice._linkSlots[t].setState({display:!1,style:{fillStyle:"#3ce92c"}})}return void e.setState({style:{fillStyle:"#3ce92c"}})}let o=!1;for(let t=0;t<this.ice._linkSlots.length;t++){const s=this.ice._linkSlots[t];s.hostComponent!==this.collision&&(s.hostComponent=this.collision),s.setState({display:!0,style:{fillStyle:"#3ce92c"}}),e.setState({style:{fillStyle:"#3ce92c"}});s.getMaxBoundingBox().isIntersect(i)&&(o=!0,s.setState({style:{fillStyle:"#fffb00"}}))}o&&e.setState({style:{fillStyle:"#fffb00"}})}hookMouseUpHandler(t){const e=t.target,i=e.state.position,s=e.parentNode.targetComponent,o=e.getMaxBoundingBox();let r=!1;if(this.collision)for(let t=0;t<this.ice._linkSlots.length;t++){const e=this.ice._linkSlots[t];e.setState({display:!1,style:{fillStyle:"#3ce92c"}});if(e.getMaxBoundingBox().isIntersect(o)){r=!0;const t={};t[i]={id:e.hostComponent.state.id,position:e.state.position},s&&s.setState({links:t});break}}if(r)e.setState({display:!1,style:{fillStyle:"#3ce92c"}});else{const t={};t[i]=null,s&&s.setState({links:t})}this.collision=null}globalMouseUpHandler(t){for(let t=0;t<this.ice._linkSlots.length;t++){this.ice._linkSlots[t].setState({display:!1,style:{fillStyle:"#3ce92c"}})}}createLinkSlots(){if(this.ice._linkSlots&&this.ice._linkSlots.length)return;const t=new Q({zIndex:10000010,display:!1,transformable:!1,draggable:!1,radius:this.slotRadius,position:"T",style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1}});this.ice.addTool(t);const e=new Q({zIndex:10000011,display:!1,transformable:!1,draggable:!1,radius:this.slotRadius,position:"R",style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1}});this.ice.addTool(e);const i=new Q({zIndex:10000012,display:!1,transformable:!1,draggable:!1,radius:this.slotRadius,position:"B",style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1}});this.ice.addTool(i);const s=new Q({zIndex:10000013,display:!1,transformable:!1,draggable:!1,radius:this.slotRadius,position:"L",style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1}});this.ice.addTool(s);const o=new Q({zIndex:10000014,display:!1,transformable:!1,draggable:!1,radius:this.slotRadius,position:"C",style:{strokeStyle:"#0c09d4",fillStyle:"#3ce92c",lineWidth:1}});this.ice.addTool(o),this.ice._linkSlots=[t,e,i,s,o]}}function toIsoTime(t){if(null==t||""===t)return;if("string"!=typeof t&&"number"!=typeof t&&!(t instanceof Date))return;const e=t instanceof Date?t.getTime():"number"==typeof t?t:Date.parse(t);return Number.isFinite(e)?new Date(e).toISOString():void 0}const vt=["linearMatrix","composedMatrix","localOrigin","absoluteOrigin","dots","textHeight","lines"];class Serializer{get unregisteredTypes(){return this._unregisteredTypes}constructor(t){_defineProperty(this,"_unregisteredTypes",[]),this.ice=t}toJSONString(){return JSON.stringify(this.toJSONObject())}toJSONObject(){this._unregisteredTypes=[];const t=(new Date).toISOString();let e=toIsoTime(this.ice&&this.ice.documentMeta&&this.ice.documentMeta.createTime);if(!e){e=t;const i=this.ice&&this.ice.documentMeta;i&&"object"==typeof i&&(i.createTime=e)}const i={version:1,createTime:e,lastModifyTime:t,childNodes:[]};for(let t=0;t<this.ice.childNodes.length;t++){const e=this.ice.childNodes[t];this.encodeRecursively(e,i)}return i}encodeRecursively(t,e){const i=this.ice.getTypeId(t.constructor),s=i||t.constructor.name;if(!i){const t=String(s);-1===this._unregisteredTypes.indexOf(t)&&this._unregisteredTypes.push(t)}const o={state:this.pickSerializableState(t.state),type:s,childNodes:[]};e.childNodes.push(o);const r="function"==typeof t.hasDerivedChildren&&t.hasDerivedChildren(),u=("function"==typeof t.getSerializableChildren?t.getSerializableChildren():null)||(r?[]:t.childNodes);if(u&&u.length)for(let t=0;t<u.length;t++)this.encodeRecursively(u[t],o)}pickSerializableState(t){const e={};for(const i in t)-1===vt.indexOf(i)&&(e[i]=t[i]);return e}}const bt=[];class Deserializer{constructor(t){_defineProperty(this,"_unknownTypes",[]),this.ice=t}get unknownTypes(){return this._unknownTypes}fromJSONObject(t){this._unknownTypes=[];const e=t&&t.version?t.version:1;this.migrate(t,e),this.__rememberCreateTime(t);const i=t&&t.childNodes||[];for(let t=0;t<i.length;t++)this.decodeRecursively(this.ice,i[t])}__rememberCreateTime(t){const e=this.ice;if(!e||"object"!=typeof e)return;e.documentMeta&&"object"==typeof e.documentMeta||(e.documentMeta={});const i=toIsoTime(t&&t.createTime);i?e.documentMeta.createTime=i:delete e.documentMeta.createTime}fromJSONString(t){const e=JSON.parse(t);this.fromJSONObject(e)}migrate(t,e){if(e>1)throw iceError(d.DESERIALIZE_VERSION_UNSUPPORTED,"不支持的反序列化版本:".concat(e,"(当前支持到 ").concat(1,")"),{version:e,supported:1});for(let i=0;i<bt.length;i++){const s=bt[i];e<s.to&&(s.run(t),e=s.to)}t.version=e}decodeRecursively(t,e){if(!e||!e.type)return null;const i=this.ice.getType(e.type);if("function"!=typeof i)return-1===this._unknownTypes.indexOf(e.type)&&this._unknownTypes.push(e.type),null;const s=new i(e.state);t.addChild(s);if(!("function"==typeof s.getSerializableChildren)&&"function"==typeof s.hasDerivedChildren&&s.hasDerivedChildren())return s;const o=e.childNodes;if(o&&o.length)for(let t=0;t<o.length;t++)this.decodeRecursively(s,o[t]);return s}}class PluginHost{constructor(t){_defineProperty(this,"plugins",[]),_defineProperty(this,"renderHooks",[]),_defineProperty(this,"tools",[]),this.ice=t}get names(){return this.plugins.map(t=>t.name)}has(t){return this.plugins.some(e=>e.name===t)}hasRenderHooks(){return this.renderHooks.length>0}use(t){if(!t||!t.name)throw iceError(d.PLUGIN_NAME_REQUIRED,"ICE.use(plugin):插件必须提供非空的 name。");if(this.has(t.name))return!1;if(t.components)for(const e in t.components){const i=t.components[e];if("function"==typeof i)try{this.ice.registerType(e,i)}catch(i){throw iceError(d.PLUGIN_COMPONENT_REGISTER_FAILED,'插件 "'.concat(t.name,'" 注册组件类型失败:').concat(i instanceof Error?i.message:String(i)),{pluginName:t.name,typeId:e,cause:i instanceof Error?i.message:String(i)})}}if("function"==typeof t.render&&this.renderHooks.push({pluginName:t.name,hook:t.render}),t.tools)for(let e=0;e<t.tools.length;e++){const i=t.tools[e];i&&i.id&&this.tools.push(_objectSpread2(_objectSpread2({},i),{},{pluginName:t.name,instance:null,attached:!1}))}return this.plugins.push(t),"function"==typeof t.setup&&t.setup(this.ice),!0}unuse(t){const e=this.plugins.findIndex(e=>e.name===t);if(-1===e)return!1;const i=this.plugins[e];for(let e=this.tools.length-1;e>=0;e--)this.tools[e].pluginName===t&&(this.detachTool(this.tools[e]),this.tools.splice(e,1));for(let e=this.renderHooks.length-1;e>=0;e--)this.renderHooks[e].pluginName===t&&this.renderHooks.splice(e,1);return this.plugins.splice(e,1),"function"==typeof i.teardown&&i.teardown(this.ice),!0}invokeRenderHooks(t){for(let e=0;e<this.renderHooks.length;e++)this.renderHooks[e].hook(t)}syncTools(t){let e=!1;for(let i=0;i<this.tools.length;i++){const s=this.tools[i];let o=!1;try{o=!!t&&!!s.match(t,this.ice)}catch(t){o=!1}o?(s.instance||(s.instance=s.create()),!s.attached&&s.instance&&(this.ice.addTool(s.instance),s.attached=!0),"function"==typeof s.onTargetChange&&s.onTargetChange(s.instance,t),s.exclusive&&(e=!0)):this.detachTool(s)}return e}detachAllTools(){for(let t=0;t<this.tools.length;t++)this.detachTool(this.tools[t])}detachTool(t){t.attached&&t.instance&&(this.ice.removeTool(t.instance),t.attached=!1)}clear(){this.detachAllTools(),this.plugins=[],this.renderHooks=[],this.tools=[]}}function resolveRole(t){return t.isControlPanel?"tool":t.isLine?"link":"function"==typeof t.measureText?"text":Array.isArray(t.childNodes)?"container":t.state&&t.state.src?"image":"graphic"}function resolveLabel(t){const e=t.state||{};return"string"==typeof e.ariaLabel&&e.ariaLabel?e.ariaLabel:"string"==typeof e.text&&e.text?e.text:"string"==typeof e.title&&e.title?e.title:t.props&&t.props.id||String(e.id||"")}function resolveBox(t,e){if("function"!=typeof e.__paintWorldBox)return null;const i=e.state&&e.state.composedMatrix;if(!i||i.length<6)return null;const s=e.__paintWorldBox([0,0,0,0]);if(!(isFinite(s[0])&&isFinite(s[1])&&isFinite(s[2])&&isFinite(s[3])))return null;const[o,r]=t.worldToScreen(s[0],s[1]),[u,a]=t.worldToScreen(s[2],s[3]);return{x:Math.min(o,u),y:Math.min(r,a),width:Math.abs(u-o),height:Math.abs(a-r)}}function buildAccessibilityTree(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[],s=t&&t.selectionList||[];let o=0;const walk=(r,u,a)=>{if(!r||!r.length)return;const h=r.slice().sort((t,e)=>(t.state.zIndex||0)-(e.state.zIndex||0));for(let r=0;r<h.length;r++){const l=h[r],c=l.state||{},d=isEffectivelyVisible(l),D=!1!==c.interactive,p=resolveBox(t,l),f=(e.includeHidden||d)&&!!p,g=!e.filter||e.filter(l);f&&g&&i.push({id:l.props&&l.props.id||String(c.id||""),role:resolveRole(l),label:resolveLabel(l),box:p,visible:d,interactive:D,focusable:d&&D,tabIndex:o++,selected:-1!==s.indexOf(l),level:u,parentId:a}),l.childNodes&&l.childNodes.length&&walk(l.childNodes,u+1,l.props&&l.props.id||null)}};return walk(t&&t.childNodes||[],1,null),e.includeTools&&walk(t&&t.toolNodes||[],1,null),i}var St=class ObjectCache{constructor(t){_defineProperty(this,"map",new WeakMap),_defineProperty(this,"__bytes",0),_defineProperty(this,"__offscreenUnavailable",!1),_defineProperty(this,"__vp",null),_defineProperty(this,"__vpChanged",!1),this.ice=t}__rvp(){return this.ice&&"function"==typeof this.ice.getRenderViewport?this.ice.getRenderViewport():this.ice&&this.ice.viewport||{scale:1,tx:0,ty:0}}beginFrame(){const t=this.__rvp(),e=this.__vp;this.__vpChanged=!!e&&(e.scale!==t.scale||e.tx!==t.tx||e.ty!==t.ty),e?(e.scale=t.scale,e.tx=t.tx,e.ty=t.ty):this.__vp={scale:t.scale,tx:t.tx,ty:t.ty}}__sameViewport(t,e,i,s){return t.rs===e&&t.ox===i&&t.oy===s}isCachable(t){if(this.__vpChanged)return!1;if(this.__offscreenUnavailable)return!1;if(!this.__isOpaque(t))return!1;if("function"==typeof t.hasClippingAncestor&&t.hasClippingAncestor())return!1;if("function"==typeof t.measureText)return!t.state.editing&&isEffectivelyVisible(t);if(t.isLine){if(t.state.lineDashFlow)return!1;if(!isEffectivelyVisible(t))return!1;const e=this.__rvp().scale;if(!(e>0))return!1;const i="function"==typeof t.__localBox?t.__localBox():null,s=i?i[2]-i[0]:Number(t.state.width)||0,o=i?i[3]-i[1]:Number(t.state.height)||0,r=Math.max(0,s)*Math.max(0,o)*e*e;return!(r>2e6)&&!(!this.map.has(t)&&this.__bytes+4*r>33554432)}if("function"==typeof t.calcDots&&!t.isLine){const e=Number(t.state.width)||0,i=Number(t.state.height)||0;return isEffectivelyVisible(t)&&!t.state.lineDashFlow&&e*i>=4e4}return!isOpaqueDrawing(t.state)&&("function"==typeof t.createPathObject&&(!t.childNodes&&!t.isLine&&isEffectivelyVisible(t)))}has(t){return this.map.has(t)}contentKey(t){const e=t.state;if("function"==typeof t.measureText){const t=e.style||{};return[e.text,t.fontWeight,t.fontSize,t.fontFamily,t.font,t.textAlign,t.textBaseline,t.paddingTop,t.paddingBottom,t.paddingLeft,t.paddingRight,t.lineHeight,t.letterSpacing,t.textDecoration,t.textDecorationColor,t.textDecorationWidth,t.selectionColor,e.direction,e.wrap,e.wordBreak,e.maxLines,e.ellipsis,e.selectionStart,e.selectionEnd,e.fill,e.stroke,JSON.stringify(e.lineDash),e.lineDashOffset,e.lineDashFlow,e.lineBorder,e.lineBorderWidth,e.lineBorderColor,this.__styleKey(e)].join("|")}return"function"==typeof t.calcDots?[JSON.stringify(e.dots),e.closePath,e.fill,e.stroke,JSON.stringify(e.lineDash),e.lineDashOffset,e.lineDashFlow,e.lineBorder,e.lineBorderWidth,e.lineBorderColor,this.__styleKey(e)].join("|"):[e.width,e.height,e.radius,e.radiusX,e.radiusY,e.closePath,e.fill,e.stroke,JSON.stringify(e.lineDash),e.lineDashOffset,e.lineDashFlow,e.lineBorder,e.lineBorderWidth,e.lineBorderColor,this.__styleKey(e)].join("|")}__styleKey(t){const e=t.style||{};return[e.fillStyle,e.strokeStyle,e.lineWidth,e.globalAlpha,e.globalCompositeOperation,e.shadow,e.shadowColor,e.shadowBlur,e.shadowOffsetX,e.shadowOffsetY].join("|")}linearKey(t){const e=t.state.composedMatrix;return!e||e.length<6?"":"".concat(e[0],",").concat(e[1],",").concat(e[2],",").concat(e[3])}render(t){if(!this.isCachable(t))return this.map.has(t)&&!this.__isOpaque(t)&&this.invalidate(t),!1;const e=this.__rvp(),i=e.scale,s=e.tx,o=e.ty;let r=this.map.get(t);if(!t.dirty&&r&&this.__sameViewport(r,i,s,o))return this.draw(r),!0;"function"==typeof t.calcDots&&t.refreshParams(),t.composeMatrix();const u=this.linearKey(t),a=this.contentKey(t);let h=!r||r.contentKey!==a||r.linearKey!==u||!this.__sameViewport(r,i,s,o);if(h||(h=!this.refreshPosition(t,r)),h){const e=r||null;e&&(this.__bytes=Math.max(0,this.__bytes-e.pw*e.ph*4));try{r=this.build(t,a,u,i,s,o)}catch(e){return this.__offscreenUnavailable=!0,this.map.delete(t),!1}this.__bytes+=r.pw*r.ph*4}return this.map.set(t,r),this.draw(r),t.dirty=!1,!0}__isOpaque(t){if(t&&"function"==typeof t.getEffectiveOpacity)return 1===t.getEffectiveOpacity();const e=t&&t.state?t.state.opacity:void 0;return void 0===e||1===e}__paintBox(t){const e=t.getMaxBoundingBox().getMinAndMaxPoint(),i=stylePaintPad(t.state);return{minX:e.minX-i,minY:e.minY-i,maxX:e.maxX+i,maxY:e.maxY+i}}build(t,e,i,s,o,r){t.refreshParams(),t.composeMatrix();const u=this.__paintBox(t),a=Math.floor(u.minX*s+o)-1,h=Math.floor(u.minY*s+r)-1,l=Math.max(1,Math.ceil(u.maxX*s+o)-a+1),c=Math.max(1,Math.ceil(u.maxY*s+r)-h+1),{canvas:d,ctx:D}=p.createOffscreenCanvas(l,c),f=[s,0,0,s,o-a,r-h];return t.renderTo(D,f),{canvas:d,ctx:D,pw:l,ph:c,dx:a,dy:h,dx0:a,dy0:h,buildMinX:u.minX,buildMinY:u.minY,rs:s,ox:o,oy:r,contentKey:e,linearKey:i}}refreshPosition(t,e){const i=this.__paintBox(t),s=e.rs,o=s*(i.minX-e.buildMinX),r=s*(i.minY-e.buildMinY);if(Math.abs(o-Math.round(o))>1e-6)return!1;if(Math.abs(r-Math.round(r))>1e-6)return!1;const u=e.dx0+Math.round(o),a=e.dy0+Math.round(r);return!(i.minX*s+e.ox<u)&&(!(i.minY*s+e.oy<a)&&(!(i.maxX*s+e.ox>u+e.pw)&&(!(i.maxY*s+e.oy>a+e.ph)&&(e.dx=u,e.dy=a,!0))))}draw(t){const e=this.ice.ctx;e.save(),e.setTransform(1,0,0,1,0,0),e.drawImage(t.canvas,t.dx,t.dy),e.restore()}invalidate(t){const e=this.map.get(t);e&&(this.__bytes=Math.max(0,this.__bytes-e.pw*e.ph*4)),this.map.delete(t)}clear(){this.map=new WeakMap,this.__bytes=0}};var Pt=class CanvasRenderer extends _{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),_defineProperty(this,"stopped",!1),_defineProperty(this,"renderMode","dirty-rect"),_defineProperty(this,"__forceFullRender",!1),_defineProperty(this,"componentQueue",[]),_defineProperty(this,"toolsQueue",[]),_defineProperty(this,"__queueDirty",!0),_defineProperty(this,"__zSnap",[]),_defineProperty(this,"__snap",new WeakMap),_defineProperty(this,"__primed",!1),_defineProperty(this,"__lastFrameCulled",0),this.ice=t,this.cache=new St(t),"full"!==e.renderMode&&"dirty-rect"!==e.renderMode||(this.renderMode=e.renderMode)}markQueueDirty(){this.__queueDirty=!0}setRenderMode(t){this.renderMode=t}getRenderMode(){return this.renderMode}start(){return this.stopped=!1,this.ice.evtBus.on(t.ICE_FRAME_EVENT,this.frameEvtHandler,this),this}stop(){return this.stopped=!0,this.ice.evtBus.off(t.ICE_FRAME_EVENT,this.frameEvtHandler,this),this}frameEvtHandler(t){if(this.ice.dirty){if(this.refreshQueue(),this.cache.beginFrame(),"dirty-rect"===this.renderMode&&!this.__forceFullRender){const t=this.__collect();if(t)return void this.__renderDirtyRect(t)}this.doRenderFull()}}refreshQueue(){if(this.__queueDirty)this.__rebuildQueue();else if(this.__zOrderChanged()){const compareZ=(t,e)=>t.state.zIndex-e.state.zIndex;this.componentQueue.sort(compareZ),this.toolsQueue.sort(compareZ),this.__snapshotZ()}}__rebuildQueue(){const compareZ=(t,e)=>t.state.zIndex-e.state.zIndex;this.componentQueue=flattenTree([],this.ice.childNodes),this.componentQueue.sort(compareZ),this.toolsQueue=flattenTree([],this.ice.toolNodes),this.toolsQueue.sort(compareZ),this.__queueDirty=!1,this.__snapshotZ(),this.__snap=new WeakMap,this.__primed=!1}__snapshotZ(){const t=this.componentQueue.length+this.toolsQueue.length;this.__zSnap.length!==t&&(this.__zSnap=new Array(t));let e=0;for(let t=0;t<this.componentQueue.length;t++)this.__zSnap[e++]=this.componentQueue[t].state.zIndex;for(let t=0;t<this.toolsQueue.length;t++)this.__zSnap[e++]=this.toolsQueue[t].state.zIndex}__zOrderChanged(){const t=this.componentQueue.length+this.toolsQueue.length;if(this.__zSnap.length!==t)return!0;let e=0;for(let t=0;t<this.componentQueue.length;t++)if(this.__zSnap[e++]!==this.componentQueue[t].state.zIndex)return!0;for(let t=0;t<this.toolsQueue.length;t++)if(this.__zSnap[e++]!==this.toolsQueue[t].state.zIndex)return!0;return!1}doRenderFull(){this.ice.ctx.setTransform(1,0,0,1,0,0),this.ice.ctx.clearRect(0,0,this.ice.canvasWidth,this.ice.canvasHeight);const e=this.__visibleWorldRect();let i=0;for(let t=0;t<this.componentQueue.length;t++){const s=this.componentQueue[t];if(e&&s.isEffectivelyVisible()&&!s.dirty){const t=this.__snap.get(s);if(t&&!intersects(t,e)){i++;continue}}this.__ensureContext(s),this.__renderComponent(s),s.isEffectivelyVisible()&&this.__capture(s)}this.__lastFrameCulled=i;for(let t=0;t<this.toolsQueue.length;t++){const e=this.toolsQueue[t];this.__ensureContext(e),e.render(),e.isEffectivelyVisible()&&this.__capture(e)}this.__invokePluginRender(null),this.__finalizeHidden(this.componentQueue),this.__finalizeHidden(this.toolsQueue),this.__primed=!0,this.ice.dirty=!1,this.ice.evtBus.trigger(t.ROUND_FINISH)}__collect(){if(!this.__primed)return null;const t=this.ice.ctx,e=this.ice.canvasWidth||0,i=this.ice.canvasHeight||0;if(!e||!i)return null;if(!t||"function"!=typeof t.save||"function"!=typeof t.clip||"function"!=typeof t.restore)return null;const s=this.__preCount(this.componentQueue);if(0===s.dirty)return null;if(s.visible>0&&s.dirty/s.visible>.2)return null;const o=[];if(!this.__collectDirtyBoxes(o,this.componentQueue))return null;if(!this.__collectDirtyBoxes(o,this.toolsQueue))return null;const r=function coalesceRegions(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6;const i=[];for(let e=0;e<t.length;e++){const s=t[e];if(!isFiniteBox(s))continue;let o=!1;for(let t=0;t<i.length;t++)if(intersects(i[t],s)&&isWorthMerging(i[t],s)){i[t]=mergeBox(i[t],s),o=!0;break}o||i.push([s[0],s[1],s[2],s[3]])}let s=!0;for(;s;){s=!1;for(let t=0;t<i.length&&!s;t++)for(let e=t+1;e<i.length;e++)if(intersects(i[t],i[e])&&isWorthMerging(i[t],i[e])){i[t]=mergeBox(i[t],i[e]),i.splice(e,1),s=!0;break}}for(;i.length>e;){let t=0,e=1,s=1/0;for(let o=0;o<i.length;o++)for(let r=o+1;r<i.length;r++){const u=boxArea(mergeBox(i[o],i[r]))-boxArea(i[o])-boxArea(i[r]);isWorthMerging(i[o],i[r])&&u<s&&(s=u,t=o,e=r)}if(s===1/0){if(i.length>24)return[i.reduce((t,e)=>mergeBox(t,e),[1/0,1/0,-1/0,-1/0])];break}i[t]=mergeBox(i[t],i[e]),i.splice(e,1)}return i}(o,6);if(!r.length)return null;const u=this.__renderViewport(),a=[];for(let t=0;t<r.length;t++)integerAlign(r[t]),a.push(mapBoxToRender(r[t],u));if(function regionsAreaRatio(t,e,i){if(!e||!i)return 1;let s=0;for(let e=0;e<t.length;e++)s+=boxArea(t[e]);return s/(e*i)}(a,e,i)>.35)return null;if(this.__riskyIntersectsRegions(r,this.componentQueue))return null;if(this.__riskyIntersectsRegions(r,this.toolsQueue))return null;const h=[1/0,1/0,-1/0,-1/0];for(let t=0;t<r.length;t++)unionBoxes(h,r[t]);return{regions:r,renderRegions:a,bounding:h}}__renderViewport(){return"function"==typeof this.ice.getRenderViewport?this.ice.getRenderViewport():this.ice.viewport}__preCount(t){let e=0,i=0,s=!1;for(let o=0;o<t.length;o++){const r=t[o];r.isEffectivelyVisible()?(e++,r.dirty&&i++):this.__snap.has(r)&&(s=!0)}return{visible:e,dirty:i,hiddenErase:s}}__collectDirtyBoxes(t,e){for(let i=0;i<e.length;i++){const s=e[i];if(!s.isEffectivelyVisible()){const e=this.__snap.get(s);e&&t.push([e[0],e[1],e[2],e[3]]);continue}if(!s.dirty)continue;s.__paramsDirtyAtCollect=s.paramsDirty;const o=this.__freshBox(s);if(!o)return!1;const r=this.__snap.get(s);t.push(r?mergeBox(r,o):o)}return!0}__riskyIntersectsRegions(t,e){for(let i=0;i<e.length;i++){const s=e[i];if(!s.isEffectivelyVisible())continue;if(!(this.__isDotPath(s)||this.__isText(s)||!isOpaqueDrawing(s.state)))continue;if(s.dirty){if(!this.__isText(s))continue;if(!s.__paramsDirtyAtCollect&&this.cache.isCachable(s)&&this.cache.has(s))continue;return!0}if(this.cache.isCachable(s)&&this.cache.has(s))continue;const o=this.__snap.get(s);if(!o)return!0;for(let e=0;e<t.length;e++)if(intersects(o,t[e]))return!0}return!1}__renderDirtyRect(e){const i=this.ice.ctx,s=e.regions,o=e.renderRegions;for(let t=0;t<s.length;t++){const e=s[t],r=o[t],u=r[0],a=r[1],h=r[2]-r[0],l=r[3]-r[1];if(!(h<=0||l<=0)){i.save(),i.setTransform(1,0,0,1,0,0),i.clearRect(u,a,h,l),i.beginPath(),i.rect(u,a,h,l),i.clip();for(let t=0;t<this.componentQueue.length;t++){const i=this.componentQueue[t];if(!i.isEffectivelyVisible())continue;const s=this.__snap.get(i);(i.dirty||s&&intersects(s,e))&&(this.__ensureContext(i),this.__renderComponent(i),this.__capture(i))}for(let t=0;t<this.toolsQueue.length;t++){const e=this.toolsQueue[t];e.isEffectivelyVisible()&&(this.__ensureContext(e),e.render(),this.__capture(e))}this.__invokePluginRender(e),i.restore()}}this.__finalizeHidden(this.componentQueue),this.__finalizeHidden(this.toolsQueue),this.ice.dirty=!1,this.ice.evtBus.trigger(t.ROUND_FINISH)}__invokePluginRender(t){const e=this.ice&&this.ice.plugins;if(!e||"function"!=typeof e.hasRenderHooks||!e.hasRenderHooks())return;const i=this.ice.ctx,s=this.__renderViewport();i.setTransform(s.scale,0,0,s.scale,s.tx,s.ty),e.invokeRenderHooks({ctx:i,mode:this.renderMode,region:t,width:this.ice.canvasWidth,height:this.ice.canvasHeight})}__ensureContext(t){t.ctx===this.ice.ctx&&t.ice===this.ice||(t.root=this.ice.root,t.ctx=this.ice.ctx,t.evtBus=this.ice.evtBus,t.ice=this.ice)}getWorldBox(t){return this.__snap.get(t)||null}__visibleWorldRect(){const t=this.ice.canvasWidth||0,e=this.ice.canvasHeight||0;if(!t||!e)return null;const[i,s]=this.ice.screenToWorld(0,0),[o,r]=this.ice.screenToWorld(t,e),u=[Math.min(i,o),Math.min(s,r),Math.max(i,o),Math.max(s,r)];return isFiniteBox(u)?u:null}__renderComponent(t){this.cache.render(t)||t.render()}__isDotPath(t){return"function"==typeof t.calcDots}__isText(t){return"function"==typeof t.measureText}__freshBox(t){try{"function"==typeof t.refreshParams&&t.refreshParams();const e=t.getMaxBoundingBox(!0).getMinAndMaxPoint(),i=stylePaintPad(t.state),s=[e.minX-i,e.minY-i,e.maxX+i,e.maxY+i];return isFiniteBox(s)?s:null}catch(t){return null}}__capture(t){let e=this.__snap.get(t);e||(e=new Float64Array(4),this.__snap.set(t,e)),t.__paintWorldBox(e);const i=stylePaintPad(t.state);e[0]-=i,e[1]-=i,e[2]+=i,e[3]+=i}__finalizeHidden(t){for(let e=0;e<t.length;e++){const i=t[e];!i.isEffectivelyVisible()&&i.dirty&&(i.dirty=!1,this.__snap.delete(i))}}};function paint(t){return null==t||""===t?null:String(t)}function gradientDesc(t){if(!t||"object"==typeof t){if(t&&t.__iceGradient)return t.__iceGradient;if(t&&("linear"===t.type||"radial"===t.type||"conic"===t.type)&&t.stops)return t}return null}function gradientDef(t,e){const i=[],s=e&&e.stops;if(Array.isArray(s)&&s.forEach(t=>{Array.isArray(t)&&i.push([Number(t[0])||0,String(t[1])])}),!i.length)return"";const o=i.map(t=>{let[e,i]=t;return'<stop offset="'.concat(escapeXml(String(e)),'" stop-color="').concat(escapeXml(i),'"/>')}).join("");if("radial"===function gradientKind(t){return t&&"radial"===t.type?"radial":"linear"}(e)){const i=Array.isArray(e.center)?e.center:[0,0],s=Number(e.radius)||.5;return'<radialGradient id="'.concat(t,'" gradientUnits="userSpaceOnUse" cx="').concat(i[0],'" cy="').concat(i[1],'" r="').concat(s,'">').concat(o,"</radialGradient>")}const r=Array.isArray(e.from)?e.from:[0,0],u=Array.isArray(e.to)?e.to:[0,1];return'<linearGradient id="'.concat(t,'" gradientUnits="userSpaceOnUse" x1="').concat(r[0],'" y1="').concat(r[1],'" x2="').concat(u[0],'" y2="').concat(u[1],'">').concat(o,"</linearGradient>")}function escapeXml(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}const Mt={top:"text-before-edge",hanging:"hanging",middle:"central",alphabetic:"alphabetic",ideographic:"ideographic",bottom:"text-after-edge"},wt=2*Math.PI;function directionalDelta(t,e,i){let s=e-t;if(i){for(;s>1e-12;)s-=wt;for(;s<-wt;)s+=wt;Math.abs(s)<1e-12&&(s=-wt)}else{for(;s<-1e-12;)s+=wt;for(;s>wt;)s-=wt;Math.abs(s)<1e-12&&(s=wt)}return s}function matrixAttr(t,e){const n=t=>String(Number((t||0).toFixed(e)));return"matrix(".concat(n(t[0])," ").concat(n(t[1])," ").concat(n(t[2])," ").concat(n(t[3])," ").concat(n(t[4])," ").concat(n(t[5]),")")}function exportSvg(t){return exportSvgResult(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).svg}function exportSvgResult(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i="number"==typeof e.precision?e.precision:2,s=Number(e.scale)>0?Number(e.scale):1,o=!!(t&&t.childNodes&&t.getRenderViewport),r=o?t:t&&t.ice,u=[],collect=t=>{for(let e=0;e<t.length;e++){const i=t[e];u.push(i),i.childNodes&&i.childNodes.length&&collect(i.childNodes)}};collect(o?t.childNodes:[t]),e.includeTools&&r&&r.toolNodes&&collect(r.toolNodes),u.sort((t,e)=>(t.state.zIndex||0)-(e.state.zIndex||0));let a=[1,0,0,1,0,0],h=0,l=0;if("viewport"===e.area&&o){const t=r.getRenderViewport(),e=Number(r.canvasWidth)||0,i=Number(r.canvasHeight)||0;a=[t.scale,0,0,t.scale,t.tx,t.ty],h=e,l=i}else{let t=1/0,i=1/0,o=-1/0,r=-1/0;u.forEach(e=>{if("function"==typeof e.isEffectivelyVisible&&!e.isEffectivelyVisible())return;"function"==typeof e.refreshParams&&e.refreshParams(),"function"==typeof e.composeMatrix&&e.composeMatrix();let s=null;if("function"==typeof e.__paintWorldBox)s=e.__paintWorldBox();else if("function"==typeof e.getMinBoundingBox){const t=e.getMinBoundingBox(!0);s=[t.tl[0],t.tl[1],t.br[0],t.br[1]]}s&&isFinite(s[0])&&isFinite(s[1])&&isFinite(s[2])&&isFinite(s[3])&&(t=Math.min(t,s[0]),i=Math.min(i,s[1]),o=Math.max(o,s[2]),r=Math.max(r,s[3]))});const c=Number(e.padding)>=0?Number(e.padding):0;isFinite(t)||(t=0,i=0,o=1,r=1),t-=c,i-=c,o+=c,r+=c;const d=Math.max(o-t,1),D=Math.max(r-i,1);a=[s,0,0,s,-t*s,-i*s],h=d*s,l=D*s}const c=[],d=[];let D=0;u.forEach(t=>{if("function"==typeof t.isEffectivelyVisible&&!t.isEffectivelyVisible())return;const e=t.state,s=function mergedStyle(t){const e=t.props&&t.props.style,i=t.state&&t.state.style;return e||i?_objectSpread2(_objectSpread2({fillStyle:void 0},e),i):{}}(t),o="function"==typeof t.composeMatrix?t.composeMatrix():e.composedMatrix,r=[],u=[];let a=t.parentNode;for(;a&&a.state;)a.state.clipChildren&&"function"==typeof a.__paintWorldBox&&u.push(a.__paintWorldBox()),a=a.parentNode;const h=['transform="'.concat(matrixAttr(o,i),'"')];if(u.length){const t="ice-clip-".concat(D++),e=u[u.length-1];c.push('<clipPath id="'.concat(t,'"><rect x="').concat(e[0].toFixed(i),'" y="').concat(e[1].toFixed(i),'" width="').concat((e[2]-e[0]).toFixed(i),'" height="').concat((e[3]-e[1]).toFixed(i),'"/></clipPath>')),h.push('clip-path="url(#'.concat(t,')"'))}const l="function"==typeof t.getEffectiveOpacity?t.getEffectiveOpacity():1,p=void 0===s.globalAlpha?1:Number(s.globalAlpha),f=l*(p>=0?p:1);1!==f&&h.push('opacity="'.concat(Number(f.toFixed(3)),'"'));const g=function shadowFilter(t,e){let i=null;if("string"==typeof e.shadow&&F[e.shadow])i=F[e.shadow];else{const t=Number(e.shadowBlur)||0,s=Number(e.shadowOffsetX)||0,o=Number(e.shadowOffsetY)||0;(t||s||o)&&(i={shadowColor:e.shadowColor||"rgba(0,0,0,0.35)",shadowBlur:t,shadowOffsetX:s,shadowOffsetY:o})}if(!i)return null;const s=String(i.shadowColor||"rgba(0,0,0,0.35)"),o=s.match(/^rgba?\(\s*([0-9.]+)\s*,\s*([0-9.]+)\s*,\s*([0-9.]+)\s*(?:,\s*([0-9.]+)\s*)?\)$/i),r=o?"rgb(".concat(Number(o[1]),", ").concat(Number(o[2]),", ").concat(Number(o[3]),")"):s,u=o&&void 0!==o[4]?Number(o[4]):1,a=Number(i.shadowBlur)||0;return{def:'<filter id="'.concat(t,'" x="-50%" y="-50%" width="200%" height="200%"><feDropShadow dx="').concat(Number(i.shadowOffsetX||0),'" dy="').concat(Number(i.shadowOffsetY||0),'" stdDeviation="').concat(Number((a/2).toFixed(2)),'" flood-color="').concat(escapeXml(r),'" flood-opacity="').concat(u,'"/></filter>'),url:"url(#".concat(t,")")}}("ice-shadow-".concat(D),s);g&&(D++,c.push(g.def),h.push('filter="'.concat(g.url,'"'))),r.push(...h);let E="";if(t instanceof v){"function"==typeof t.ensurePathBuilt&&t.ensurePathBuilt();const o=t.path2D,r=o&&o._commands||[],u=s.fillGradient||gradientDesc(s.fillStyle),a=s.strokeGradient||gradientDesc(s.strokeStyle),h=!(!1===e.fill||!s.fillStyle&&!u),l=!(!1===e.stroke||!s.strokeStyle&&!a);if(r.length&&(h||l)){const h=function commandsToPathData(t,e,i){const n=t=>{const e=Number(t.toFixed(i));return String(e)},s=[];let o=!1;for(let e=0;e<t.length;e++){const i=t[e],r=i[0];if("moveTo"===r)s.push("".concat(o?"L":"M").concat(n(i[1]),",").concat(n(i[2]))),o=!0;else if("lineTo"===r)s.push("L".concat(n(i[1]),",").concat(n(i[2]))),o=!0;else if("bezierCurveTo"===r)s.push("C".concat(n(i[1]),",").concat(n(i[2])," ").concat(n(i[3]),",").concat(n(i[4])," ").concat(n(i[5]),",").concat(n(i[6]))),o=!0;else if("quadraticCurveTo"===r)s.push("Q".concat(n(i[1]),",").concat(n(i[2])," ").concat(n(i[3]),",").concat(n(i[4]))),o=!0;else if("rect"===r)s.push("M".concat(n(i[1]),",").concat(n(i[2]),"h").concat(n(i[3]),"v").concat(n(i[4]),"h").concat(n(-i[3]),"z")),o=!1;else if("arc"===r){const[t,e,r,u,a,h]=i.slice(1),l=t+r*Math.cos(u),c=e+r*Math.sin(u),d=t+r*Math.cos(a),D=e+r*Math.sin(a),p=directionalDelta(u,a,!!h),f=Math.abs(p)>Math.PI?1:0,g=p>0?1:0;if(o||s.push("M".concat(n(l),",").concat(n(c))),Math.abs(p)>=wt-1e-6){const i=t+r*Math.cos(u+Math.PI),o=e+r*Math.sin(u+Math.PI);s.push("A".concat(n(r),",").concat(n(r)," 0 0 ").concat(g," ").concat(n(i),",").concat(n(o))),s.push("A".concat(n(r),",").concat(n(r)," 0 0 ").concat(g," ").concat(n(l),",").concat(n(c)))}else s.push("A".concat(n(r),",").concat(n(r)," 0 ").concat(f," ").concat(g," ").concat(n(d),",").concat(n(D)));o=!0}else if("arcTo"===r){const[t,e]=i.slice(1);s.push("L".concat(n(t),",").concat(n(e))),o=!0}else if("ellipse"===r){const[t,e,r,u,a,h,l,c]=i.slice(1),d=t+r*Math.cos(h)*Math.cos(a)-u*Math.sin(h)*Math.sin(a),D=e+r*Math.cos(h)*Math.sin(a)+u*Math.sin(h)*Math.cos(a),p=t+r*Math.cos(l)*Math.cos(a)-u*Math.sin(l)*Math.sin(a),f=e+r*Math.cos(l)*Math.sin(a)+u*Math.sin(l)*Math.cos(a),g=directionalDelta(h,l,!!c),E=Math.abs(g)>Math.PI?1:0,_=g>0?1:0;if(o||s.push("M".concat(n(d),",").concat(n(D))),Math.abs(g)>=wt-1e-6){const i=t+r*Math.cos(h+Math.PI)*Math.cos(a)-u*Math.sin(h+Math.PI)*Math.sin(a),o=e+r*Math.cos(h+Math.PI)*Math.sin(a)+u*Math.sin(h+Math.PI)*Math.cos(a);s.push("A".concat(n(r),",").concat(n(u)," 0 0 ").concat(_," ").concat(n(i),",").concat(n(o))),s.push("A".concat(n(r),",").concat(n(u)," 0 0 ").concat(_," ").concat(n(d),",").concat(n(D)))}else s.push("A".concat(n(r),",").concat(n(u)," 0 ").concat(E," ").concat(_," ").concat(n(p),",").concat(n(f)));o=!0}else"closePath"===r&&(s.length&&!/z$/i.test(s[s.length-1])&&s.push("Z"),o=!1)}const r=t.some(t=>"closePath"===t[0]);return!e||r||/z\s*$/i.test(s.join(" "))||s.push("Z"),s.join(" ")}(r,!(!o||!o._closed)||!1!==e.closePath,i),l=!1===e.fill||u?null:paint(s.fillStyle),d=!1===e.stroke||a?null:paint(s.strokeStyle),p=[];if(u&&!1!==e.fill){const t="ice-grad-".concat(D++),e=gradientDef(t,u);e?(c.push(e),p.push('fill="url(#'.concat(t,')"'))):l?p.push('fill="'.concat(escapeXml(l),'"')):p.push('fill="none"')}else p.push('fill="'.concat(l?escapeXml(l):"none",'"'));if(a&&!1!==e.stroke){const t="ice-grad-".concat(D++),e=gradientDef(t,a);e&&(c.push(e),p.push('stroke="url(#'.concat(t,')"')))}else d&&p.push('stroke="'.concat(escapeXml(d),'"'));if(void 0!==s.lineWidth&&p.push('stroke-width="'.concat(Number(s.lineWidth),'"')),Array.isArray(e.lineDash)&&e.lineDash.length&&(p.push('stroke-dasharray="'.concat(e.lineDash.join(" "),'"')),e.lineDashOffset&&p.push('stroke-dashoffset="'.concat(Number(e.lineDashOffset),'"'))),e.lineJoin&&p.push('stroke-linejoin="'.concat(e.lineJoin,'"')),e.lineCap&&p.push('stroke-linecap="'.concat(e.lineCap,'"')),E='<path d="'.concat(h,'" ').concat(p.join(" "),"/>"),"hollow"!==e.arrowStyle&&"function"==typeof t.getArrowFaces){const o=t.getArrowFaces(),r=d||(s.strokeStyle?String(s.strokeStyle):"#000000");if(o.length&&!1!==e.stroke){const t=o.map(t=>"M".concat(Number(t[0][0].toFixed(i)),",").concat(Number(t[0][1].toFixed(i)))+"L".concat(Number(t[1][0].toFixed(i)),",").concat(Number(t[1][1].toFixed(i)))+"L".concat(Number(t[2][0].toFixed(i)),",").concat(Number(t[2][1].toFixed(i)),"Z")).join(" ");E+='<path d="'.concat(t,'" fill="').concat(escapeXml(r),'" stroke="none"/>')}}const f="function"==typeof t.getLabelRenderInfo?t.getLabelRenderInfo():null;if(f){const t=Number((f.x-f.halfW).toFixed(i)),e=Number((f.y-f.halfH).toFixed(i)),s=Number((2*f.halfW).toFixed(i)),o=Number((2*f.halfH).toFixed(i));E+='<rect x="'.concat(t,'" y="').concat(e,'" width="').concat(s,'" height="').concat(o,'" fill="').concat(escapeXml(f.backgroundColor),'"/>')+'<text x="'.concat(Number(f.x.toFixed(i)),'" y="').concat(Number(f.y.toFixed(i)),'" ')+'font-family="Arial" font-size="'.concat(Number(f.fontSize),'" fill="').concat(escapeXml(f.fillStyle),'" ')+'text-anchor="middle" dominant-baseline="central">'.concat(escapeXml(f.text),"</text>")}}}else if(t instanceof Dt){const o="function"==typeof t.getRenderLines?t.getRenderLines():null;if(o&&o.length){var _;const t=!1!==e.fill?paint(s.fillStyle):null,r=e.stroke?paint(s.strokeStyle):null,u=function fontAttributes(t,e){let i=t.fontFamily,s=t.fontSize,o=t.fontWeight,r=t.fontStyle;if(!("string"!=typeof t.font||i&&s)){const e=t.font.match(/^(?:(italic|oblique)\s+)?(?:(bold|bolder|lighter|[0-9]{3})\s+)?([0-9.]+)px\s+(.+)$/);e&&(r=r||e[1],o=o||e[2],s=s||e[3],i=i||e[4])}const u=[];return i&&u.push('font-family="'.concat(escapeXml(String(i)),'"')),null!=s&&""!==s&&u.push('font-size="'.concat(Number(Number(s).toFixed(e)),'"')),o&&u.push('font-weight="'.concat(escapeXml(String(o)),'"')),r&&u.push('font-style="'.concat(escapeXml(String(r)),'"')),u}(s,i);u.push('fill="'.concat(t?escapeXml(t):"none",'"')),r&&(u.push('stroke="'.concat(escapeXml(r),'"')),u.push('stroke-width="'.concat(Number(s.lineWidth)||1,'"')));const a=Number(s.fontSize)||12,h=resolveLetterSpacingPx(s.letterSpacing,a);0!==h&&u.push('letter-spacing="'.concat(Number(h.toFixed(i)),'"'));const l=resolveTextDecorations(s.textDecoration);l.length&&u.push('text-decoration="'.concat(l.join(" "),'"'));const c=resolveTextDirection(String(null!==(_=e.text)&&void 0!==_?_:""),e.direction),d=resolveTextAlign(s.textAlign,c);"rtl"===c&&u.push('direction="rtl"');let D=null;"center"===d?(u.push('text-anchor="middle"'),D=0):"right"===d?(u.push("rtl"===c?'text-anchor="start"':'text-anchor="end"'),D=e.localOrigin[0]-(Number(s.paddingRight)||0)):u.push("rtl"===c?'text-anchor="end"':'text-anchor="start"');const p=Mt[s.textBaseline||"bottom"];p&&u.push('dominant-baseline="'.concat(p,'"'));const f=o.map(t=>{const e=null===D?t.x:D;return'<tspan x="'.concat(Number(e.toFixed(i)),'" y="').concat(Number(t.y.toFixed(i)),'">').concat(escapeXml(t.text),"</tspan>")}).join("");E="<text ".concat(u.join(" "),">").concat(f,"</text>")}}else if(t instanceof K&&e.src&&!(e.sw>0&&e.sh>0)){const t=0-e.localOrigin[0],i=0-e.localOrigin[1],s=['x="'.concat(t,'"'),'y="'.concat(i,'"'),'width="'.concat(e.width,'"'),'height="'.concat(e.height,'"'),'href="'.concat(escapeXml(String(e.src)),'"')];if("circle"===(e.clipType||"none")){const t="ice-clip-".concat(D++),i=Math.min(e.width,e.height)/2;c.push('<clipPath id="'.concat(t,'"><circle cx="0" cy="0" r="').concat(i,'"/></clipPath>')),s.push('clip-path="url(#'.concat(t,')"'))}E="<image ".concat(s.join(" "),' preserveAspectRatio="none"/>')}E&&d.push("<g ".concat(r.join(" "),">").concat(E,"</g>"))});const p=e.background?'<rect x="0" y="0" width="'.concat(h,'" height="').concat(l,'" fill="').concat(escapeXml(e.background),'"/>'):"";return{svg:['<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'.concat(Number(h.toFixed(i)),'" height="').concat(Number(l.toFixed(i)),'" viewBox="0 0 ').concat(Number(h.toFixed(i))," ").concat(Number(l.toFixed(i)),'">'),c.length?"<defs>".concat(c.join(""),"</defs>"):"",p,'<g transform="'.concat(matrixAttr(a,i),'">'),d.join(""),"</g>","</svg>"].filter(Boolean).join(""),width:h,height:l}}class ImageCache{constructor(t){_defineProperty(this,"imageCache",new Map),this.ice=t}setImage(t){let e=this.imageCache.get(t);return e||(e=p.createImage(),e.onload=()=>{this.ice.dirty=!0},e.onerror=()=>{},e.src=t,this.imageCache.size>ImageCache.CACHE_SIZE&&this.imageCache.delete(this.imageCache.keys().next().value),this.imageCache.set(t,e)),{loaded:this.loaded(e),image:e}}loaded(t){return t.complete&&t.naturalWidth>0}}_defineProperty(ImageCache,"CACHE_SIZE",100);const It=/^[a-z][a-z0-9-]*:[A-Za-z_][A-Za-z0-9_-]*$/;function isTypeId(t){return"string"==typeof t&&It.test(t)}function assertTypeId(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"typeId";if(!isTypeId(t))throw iceError(d.TYPE_ID_INVALID,"".concat(e,' 必须是 "namespace:Type" 格式(namespace 用小写字母/数字/连字符,Type 用字母/数字/下划线/连字符):').concat(String(t)),{label:e,value:String(t)})}function tagGradient(t,e){if(!t||"function"!=typeof t.addColorStop)return t;Object.defineProperty(t,"__iceGradient",{value:e,enumerable:!1,configurable:!0});const i=t.addColorStop.bind(t);return t.addColorStop=(t,s)=>{e.stops.push([t,s]),i(t,s)},t}class ICE{constructor(){_defineProperty(this,"childNodes",[]),_defineProperty(this,"toolNodes",[]),_defineProperty(this,"__childSet",new WeakSet),_defineProperty(this,"__toolSet",new WeakSet),_defineProperty(this,"canvasWidth",0),_defineProperty(this,"canvasHeight",0),_defineProperty(this,"viewport",{scale:1,tx:0,ty:0}),_defineProperty(this,"dpr",1),_defineProperty(this,"__renderVp",null),_defineProperty(this,"__contentBox",null),_defineProperty(this,"__inputRectSnapshot",null),_defineProperty(this,"selectionList",[]),_defineProperty(this,"plugins",new PluginHost(this)),_defineProperty(this,"theme",getTheme()),_defineProperty(this,"typeMapping",Object.create(null)),_defineProperty(this,"__typeIdMapping",null),_defineProperty(this,"documentMeta",{}),_defineProperty(this,"__dirty",!0),_defineProperty(this,"__initialized",!1);for(let t=0;t<yt.length;t++){const e=yt[t];this.registerType(e.typeId,e.ctor)}}__resolveCanvasEl(t){return t&&"function"==typeof t.getContext?t:t&&t.canvas&&"function"==typeof t.canvas.getContext?t.canvas:null}readCanvasRect(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.canvasEl;if(t&&"function"==typeof t.getBoundingClientRect)return t.getBoundingClientRect();const e=t&&t.width||0,i=t&&t.height||0;return{left:0,top:0,width:e,height:i,right:e,bottom:i,x:0,y:0}}init(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t)throw iceError(d.INIT_TARGET_REQUIRED,"ICE.init() failed...");const i=this.__resolveCanvasEl(t);if(this.__initialized){if(i&&i===this.canvasEl)return this;throw iceError(d.INIT_ALREADY_BOUND,"同一个 ICE 实例已经绑定到其它 canvas,如需重新初始化请先调用 destroy()。")}return this.root=p,isString(t)?this.canvasEl=this.root.document.getElementById(t):i&&(this.canvasEl=i),e&&"number"==typeof e.dpr&&e.dpr>0&&(this.dpr=e.dpr),this.canvasEl?(this.canvasEl.oncontextmenu=function(t){t.preventDefault()},this.canvasWidth=this.canvasEl.width,this.canvasHeight=this.canvasEl.height,this.canvasBoundingClientRect=this.readCanvasRect(),this.__rememberInputRect(this.canvasBoundingClientRect),this.__contentBox=this.__readContentBox(this.canvasBoundingClientRect),this.ctx=this.canvasEl.getContext("2d"),this.canvasEl.style&&(this.canvasEl.style.touchAction="none"),1!==this.dpr&&this.__applyDevicePixelRatio()):this.ctx=t,this.evtBus=new U,Bt.registerEvtBus(this.evtBus),Bt.start(),j.registerEvtBus(this.evtBus),j.start(),this.eventDispatcher=new Y(this).start(),this.animationManager=new l(this).start(),this.controlPanelManager=new w(this).start(),this.renderer=new Pt(this,e).start(),this.alignmentGuide=new I(this),this.linkSlotManager=new ICELinkSlotManager(this).start(),this.serializer=new Serializer(this),this.deserializer=new Deserializer(this),this.imageCache=new ImageCache(this),this.__initialized=!0,this}destroy(){if(!this.__initialized)return;const t=[this.renderer,this.animationManager,this.controlPanelManager,this.linkSlotManager];for(let e=0;e<t.length;e++){const i=t[e];i&&"function"==typeof i.stop&&i.stop()}this.eventDispatcher&&(this.eventDispatcher.stopped=!0),this.canvasEl&&this.canvasEl.oncontextmenu&&(this.canvasEl.oncontextmenu=null),this.evtBus&&(Bt.delEvtBus(this.evtBus),j.delEvtBus(this.evtBus)),0===Bt.evtBuses.length&&Bt.stop(),this.plugins&&this.plugins.clear(),this.clearAll(),this.renderer=null,this.animationManager=null,this.controlPanelManager=null,this.linkSlotManager=null,this.eventDispatcher=null,this.alignmentGuide=null,this.serializer=null,this.deserializer=null,this.imageCache=null,this.ctx=null,this.canvasEl=null,this.canvasBoundingClientRect=null,this.dpr=1,this.__renderVp=null,this.__contentBox=null,this.__inputRectSnapshot=null,this.__initialized=!1}addTool(e){this.__toolSet.has(e)||(this.evtBus.trigger(t.BEFORE_ADD,null,{component:e}),e.trigger(t.BEFORE_ADD),e.ice=this,e.ctx=this.ctx,e.evtBus=this.evtBus,this.toolNodes.push(e),this.__toolSet.add(e),this.dirty=!0,this.renderer&&this.renderer.markQueueDirty(),e&&"function"==typeof e.__reapplyPreset&&e.__reapplyPreset(this.theme),this.evtBus.trigger(t.AFTER_ADD,null,{component:e}),e.trigger(t.AFTER_ADD))}removeTool(e){if(!this.__toolSet.has(e))return;this.evtBus.trigger(t.BEFORE_REMOVE,null,{component:e}),e.trigger(t.BEFORE_REMOVE);const i=this.toolNodes.indexOf(e);-1!==i&&this.toolNodes.splice(i,1),this.__toolSet.delete(e),this.evtBus.trigger(t.AFTER_REMOVE,null,{component:e}),e.trigger(t.AFTER_REMOVE),this.dirty=!0,this.renderer&&this.renderer.markQueueDirty(),e.destory()}addChild(e){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.__childSet.has(e))return;this.evtBus.trigger(t.BEFORE_ADD,null,{component:e}),e.trigger(t.BEFORE_ADD),e.ice=this,e.ctx=this.ctx,e.evtBus=this.evtBus,e.parentNode=null,this.childNodes.push(e),this.__childSet.add(e);let s=!1;const o=e.props.animations;if(o)for(const t in o){s=!0;break}s&&this.animationManager.add(e),this.dirty=i,this.renderer&&this.renderer.markQueueDirty(),e&&"function"==typeof e.__reapplyPreset&&e.__reapplyPreset(this.theme),this.evtBus.trigger(t.AFTER_ADD,null,{component:e}),e.trigger(t.AFTER_ADD)}addChildren(t){for(let e=0;e<t.length;e++)this.addChild(t[e],!1);this.dirty=!0}removeChild(e){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.__childSet.has(e))return;this.evtBus.trigger(t.BEFORE_REMOVE,null,{component:e}),e.trigger(t.BEFORE_REMOVE);const s=this.childNodes.indexOf(e);-1!==s&&this.childNodes.splice(s,1),this.__childSet.delete(e),this.evtBus.trigger(t.AFTER_REMOVE,null,{component:e}),e.trigger(t.AFTER_REMOVE),this.dirty=i,this.renderer&&this.renderer.markQueueDirty(),e.destory()}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e],!1);this.dirty=!0}clearAll(){this.removeChildren([...this.childNodes]),this.documentMeta={}}findComponent(t){if(!t)return;return this.childNodes.filter(e=>e.props.id===t)[0]||this.__findComponentInTree(this.childNodes,t)}__findComponentInTree(t,e){for(let i=0;i<t.length;i++){const s=t[i];if(s.props&&s.props.id===e)return s;if(s.childNodes&&s.childNodes.length){const t=this.__findComponentInTree(s.childNodes,e);if(t)return t}}}set dirty(t){this.__dirty=t}get dirty(){return this.__dirty}registerType(t,e){if(assertTypeId(t,"registerType 的 typeId"),"function"!=typeof e)throw iceError(d.TYPE_CTOR_INVALID,'registerType("'.concat(t,'") 失败:Clazz 必须是构造函数。'),{typeId:t});const i=this.typeMapping[t];if(i){if(i===e)return;throw iceError(d.TYPE_ID_CONFLICT,'typeId "'.concat(t,'" 已注册为 ').concat(i.name||"匿名构造函数",",不能再注册 ").concat(e.name||"匿名构造函数","。"),{typeId:t,registered:i.name||"anonymous",incoming:e.name||"anonymous"})}const s=this.getTypeId(e);if(s&&s!==t)throw iceError(d.TYPE_CTOR_CONFLICT,"构造函数 ".concat(e.name||"匿名构造函数",' 已注册为 "').concat(s,'",不能同时注册为 "').concat(t,'"(反查会歧义)。'),{typeId:t,existingTypeId:s});this.typeMapping[t]=e,this.__typeIdMapping=null}hasType(t){return"string"==typeof t&&!!this.typeMapping[t]}getRegisteredTypeIds(){return Object.keys(this.typeMapping)}getTypeId(t){if(!t)return;let e=this.__typeIdMapping;if(!e){e=new Map;for(const t in this.typeMapping){const i=this.typeMapping[t];"function"!=typeof i||e.has(i)||e.set(i,t)}this.__typeIdMapping=e}return e.get(t)}use(t){return this.plugins.use(t)}unuse(t){return this.plugins.unuse(t)}getPlugins(){return this.plugins.names}setSelection(t){return this.selectionList=null==t?[]:Array.isArray(t)?t:[t],!!this.plugins&&this.plugins.syncTools(this.selectionList[0]||null)}getAccessibilityTree(t){return buildAccessibilityTree(this,t)}setFocusedComponent(t){let e=t;if("string"==typeof t){e=flattenAllComponents(this).filter(e=>e.props&&e.props.id===t)[0]||null}return this.eventDispatcher&&(this.eventDispatcher.focusedComponent=e||null),this}getFocusedComponent(){return this.eventDispatcher?this.eventDispatcher.focusedComponent:null}getType(t){if("string"==typeof t&&t)return this.typeMapping[t]}loadFont(t,e){return Promise.resolve(p.loadFont(t,e)).then(t=>(this.remeasureTexts(),t))}remeasureTexts(){const t=flattenAllComponents(this);let e=!1;for(let i=0;i<t.length;i++){const s=t[i];s&&"function"==typeof s.remeasureText&&(s.remeasureText(),e=!0)}return e&&(this.dirty=!0),this}setTheme(t){return this.theme=resolveTheme(t,this.theme),this.__reapplyPresets(),this}setViewport(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const s=Number(t);return this.viewport={scale:s>0?s:1,tx:Number(e)||0,ty:Number(i)||0},this.dirty=!0,this.renderer&&this.renderer.markQueueDirty(),this}screenToWorld(t,e){const i=this.viewport;return[(t-i.tx)/i.scale,(e-i.ty)/i.scale]}worldToScreen(t,e){const i=this.viewport;return[t*i.scale+i.tx,e*i.scale+i.ty]}getRenderViewport(){const t=this.viewport;if(1===this.dpr)return t;let e=this.__renderVp;return e||(e=this.__renderVp={scale:1,tx:0,ty:0,__d:1,__s:1,__tx:0,__ty:0}),e.__d===this.dpr&&e.__s===t.scale&&e.__tx===t.tx&&e.__ty===t.ty||(e.__d=this.dpr,e.__s=t.scale,e.__tx=t.tx,e.__ty=t.ty,e.scale=t.scale*this.dpr,e.tx=t.tx*this.dpr,e.ty=t.ty*this.dpr),e}__applyDevicePixelRatio(){const t=this.canvasEl;if(!t)return;const e=this.__readContentBox("function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():null),i=e.width||t.width,s=e.height||t.height;t.width=Math.round(i*this.dpr),t.height=Math.round(s*this.dpr),t.style&&(t.style.width=i+"px",t.style.height=s+"px"),this.canvasWidth=t.width,this.canvasHeight=t.height,this.updateCanvasBoundingRect()}updateCanvasBoundingRect(){return this.canvasEl&&"function"==typeof this.canvasEl.getBoundingClientRect&&(this.canvasBoundingClientRect=this.canvasEl.getBoundingClientRect(),this.__rememberInputRect(this.canvasBoundingClientRect),this.__contentBox=this.__readContentBox(this.canvasBoundingClientRect)),this.canvasBoundingClientRect}__rememberInputRect(t){if(!t)return;const e=this.__inputRectSnapshot||(this.__inputRectSnapshot={left:0,top:0,width:0,height:0});e.left=t.left||0,e.top=t.top||0,e.width=t.width||0,e.height=t.height||0}refreshInputRect(){const t=this.canvasEl;if(!t||"function"!=typeof t.getBoundingClientRect)return this.canvasBoundingClientRect;const e=t.getBoundingClientRect(),i=this.__inputRectSnapshot,s=!!i,o=s?i.left:0,r=s?i.top:0,u=s?i.width:0,a=s?i.height:0;this.canvasBoundingClientRect=e,this.__rememberInputRect(e);const h=this.__contentBox;return s&&!!h&&Math.abs(e.width-u)<.01&&Math.abs(e.height-a)<.01?(h.left+=e.left-o,h.top+=e.top-r):this.__contentBox=this.__readContentBox(e),e}__readContentBox(t){const e=this.canvasEl;let i=0,s=0,o=0,r=0,u=0,a=0,h=0,l=0;const c=this.root&&"function"==typeof this.root.getComputedStyle&&e?this.root.getComputedStyle(e):null;if(c){const num=t=>{const e=parseFloat(t);return isFinite(e)?e:0};i=num(c.borderLeftWidth),s=num(c.borderRightWidth),o=num(c.borderTopWidth),r=num(c.borderBottomWidth),u=num(c.paddingLeft),a=num(c.paddingRight),h=num(c.paddingTop),l=num(c.paddingBottom)}const d=t&&t.left||0,D=t&&t.top||0,p=t&&t.width||0,f=t&&t.height||0;return{left:d+i+u,top:D+o+h,width:Math.max(0,p-i-s-u-a),height:Math.max(0,f-o-r-h-l)}}getInputRect(){return this.__contentBox||this.updateCanvasBoundingRect(),this.__contentBox||this.canvasBoundingClientRect||{left:0,top:0,width:0,height:0}}zoomAt(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.05,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:20;const r=Number(i);if(!isFinite(r)||r<=0)return this;const[u,a]=this.screenToWorld(t,e),h=this.viewport.scale,l=Math.min(s,o),c=Math.max(s,o),d=Math.min(c,Math.max(l,h*r));return d===h?this:this.setViewport(d,t-u*d,e-a*d)}hitTest(t,e){const[i,s]=this.screenToWorld(t,e);return hitTestComponents(this,i,s,1)}registerTheme(t,e){return registerTheme(t,e),this}getTheme(){return this.theme}__reapplyPresets(){const t=flattenAllComponents(this);for(const e of t)"function"==typeof e.__reapplyPreset&&e.__reapplyPreset(this.theme)}createLinearGradient(t,e,i,s){return tagGradient(this.ctx.createLinearGradient(t,e,i,s),{type:"linear",from:[t,e],to:[i,s],stops:[]})}createRadialGradient(t,e,i,s,o,r){return tagGradient(this.ctx.createRadialGradient(t,e,i,s,o,r),{type:"radial",center:[s,o],radius:r,stops:[]})}createConicGradient(t,e,i){return"function"==typeof this.ctx.createConicGradient?tagGradient(this.ctx.createConicGradient(t,e,i),{type:"conic",startAngle:t,center:[e,i],stops:[]}):null}createPattern(t,e){return this.ctx.createPattern(t,e)}getImageData(t,e,i,s){return this.ctx.getImageData(t,e,i,s)}putImageData(t,e,i){this.ctx.putImageData(t,e,i)}createImageData(t,e){return this.ctx.createImageData(t,e)}toDataURL(t,e){return this.canvasEl.toDataURL(t,e)}toBlob(t,e,i){this.canvasEl.toBlob(t,e,i)}toSvg(){return exportSvg(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}static headless(){const t=new ICE;return t.childNodes=[],t.toolNodes=[],t.evtBus=new U,t.dirty=!0,t}toSvgResult(){return exportSvgResult(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}toJSONString(){return this.serializer.toJSONString()}toJSONObject(){return this.serializer.toJSONObject()}fromJSONObject(t){Bt.stop(),this.renderer.stop(),this.eventDispatcher.stopped=!0,this.animationManager.stop(),this.controlPanelManager.stop(),this.linkSlotManager.stop(),this.clearAll(),this.deserializer.fromJSONObject(t),Bt.start(),this.renderer.start(),this.animationManager.start(),this.controlPanelManager.start(),this.linkSlotManager.start(),setTimeout(()=>{this.eventDispatcher&&(this.eventDispatcher.stopped=!1)},300)}fromJSONString(t){const e=JSON.parse(t);this.fromJSONObject(e)}}var Tt=ICE;exports.AlignmentGuideManager=I,exports.AnimationManager=l,exports.CanvasRenderer=Pt,exports.DARK_THEME=o,exports.DEFAULT_THEME=s,exports.DOMEventDispatcher=Y,exports.DOMEventInterceptor=j,exports.Deserializer=Deserializer,exports.EventBus=U,exports.GeoLine=GeoLine,exports.GeoPoint=GeoPoint,exports.GeoUtil=GeoUtil,exports.ICE=Tt,exports.ICEBezier=ICEBezier,exports.ICEBorderLayout=Et,exports.ICEBoundingBox=C,exports.ICEBoxLayout=_t,exports.ICECardLayout=Ct,exports.ICECircle=M,exports.ICEComponent=B,exports.ICEControlPanel=ICEControlPanel,exports.ICEControlPanelManager=w,exports.ICEDotPath=ICEDotPath,exports.ICEEllipse=P,exports.ICEEventTarget=_,exports.ICEFlowLayout=ft,exports.ICEGridLayout=gt,exports.ICEGroup=S,exports.ICEImage=K,exports.ICEIsogon=J,exports.ICELayeredLayout=mt,exports.ICELayoutManager=pt,exports.ICELinkHook=ICELinkHook,exports.ICELinkSlot=Q,exports.ICEOverlayLayout=Ft,exports.ICEPath=v,exports.ICEPolyLine=q,exports.ICERect=b,exports.ICERose=Z,exports.ICEStar=$,exports.ICEText=Dt,exports.ICETheme=h,exports.ICEVisioLink=ICEVisioLink,exports.ICE_ERROR_CODES=d,exports.LineControlPanel=LineControlPanel,exports.PluginHost=PluginHost,exports.ResizeControl=ResizeControl,exports.RotateControl=RotateControl,exports.SERIALIZATION_MIGRATIONS=bt,exports.SERIALIZATION_VERSION=1,exports.STYLE_PRESETS=a,exports.Serializer=Serializer,exports.TYPE_ID_PATTERN=It,exports.TransformControlPanel=TransformControlPanel,exports.assertTypeId=assertTypeId,exports.baseTokens=i,exports.buildAccessibilityTree=buildAccessibilityTree,exports.exportSvg=exportSvg,exports.exportSvgResult=exportSvgResult,exports.getICEErrorCode=getICEErrorCode,exports.getTheme=getTheme,exports.iceError=iceError,exports.isICEError=function isICEError(t,e){const i=getICEErrorCode(t);return void 0===e?void 0!==i:i===e},exports.isTypeId=isTypeId,exports.makeTypeId=function makeTypeId(t,e){const i="".concat(t,":").concat(e);return assertTypeId(i),i},exports.parseTypeId=function parseTypeId(t){assertTypeId(t);const e=t.indexOf(":");return{namespace:t.slice(0,e),type:t.slice(e+1)}},exports.registerTheme=registerTheme,exports.setTheme=setTheme,exports.toIsoTime=toIsoTime;