ice-web-components 1.0.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.
Files changed (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +487 -0
  3. package/dist/index.cjs +1 -0
  4. package/dist/index.mjs +1 -0
  5. package/dist/index.umd.js +1 -0
  6. package/dist/types/components/ICEAlert.d.ts +28 -0
  7. package/dist/types/components/ICEAnchor.d.ts +69 -0
  8. package/dist/types/components/ICEAutoComplete.d.ts +71 -0
  9. package/dist/types/components/ICEAvatar.d.ts +11 -0
  10. package/dist/types/components/ICEAvatarGroup.d.ts +40 -0
  11. package/dist/types/components/ICEBackTop.d.ts +39 -0
  12. package/dist/types/components/ICEBadge.d.ts +17 -0
  13. package/dist/types/components/ICEBreadcrumb.d.ts +82 -0
  14. package/dist/types/components/ICEButton.d.ts +25 -0
  15. package/dist/types/components/ICECalendar.d.ts +84 -0
  16. package/dist/types/components/ICECard.d.ts +22 -0
  17. package/dist/types/components/ICECarousel.d.ts +86 -0
  18. package/dist/types/components/ICECascader.d.ts +84 -0
  19. package/dist/types/components/ICECheckBox.d.ts +21 -0
  20. package/dist/types/components/ICECheckboxGroup.d.ts +75 -0
  21. package/dist/types/components/ICECollapse.d.ts +49 -0
  22. package/dist/types/components/ICEColorPicker.d.ts +52 -0
  23. package/dist/types/components/ICEComment.d.ts +36 -0
  24. package/dist/types/components/ICEDatePicker.d.ts +90 -0
  25. package/dist/types/components/ICEDescriptions.d.ts +40 -0
  26. package/dist/types/components/ICEDrawer.d.ts +59 -0
  27. package/dist/types/components/ICEDropdown.d.ts +63 -0
  28. package/dist/types/components/ICEEmpty.d.ts +28 -0
  29. package/dist/types/components/ICEFloatButton.d.ts +63 -0
  30. package/dist/types/components/ICEForm.d.ts +48 -0
  31. package/dist/types/components/ICEFormItem.d.ts +65 -0
  32. package/dist/types/components/ICEGrid.d.ts +59 -0
  33. package/dist/types/components/ICEIcon.d.ts +9 -0
  34. package/dist/types/components/ICEIconTile.d.ts +53 -0
  35. package/dist/types/components/ICEImagePreview.d.ts +91 -0
  36. package/dist/types/components/ICEImageView.d.ts +62 -0
  37. package/dist/types/components/ICEInputNumber.d.ts +54 -0
  38. package/dist/types/components/ICEKanban.d.ts +85 -0
  39. package/dist/types/components/ICELabel.d.ts +28 -0
  40. package/dist/types/components/ICEList.d.ts +59 -0
  41. package/dist/types/components/ICEMenu.d.ts +48 -0
  42. package/dist/types/components/ICEModal.d.ts +73 -0
  43. package/dist/types/components/ICEPagination.d.ts +62 -0
  44. package/dist/types/components/ICEPanel.d.ts +7 -0
  45. package/dist/types/components/ICEPasswordField.d.ts +18 -0
  46. package/dist/types/components/ICEPopconfirm.d.ts +21 -0
  47. package/dist/types/components/ICEPopover.d.ts +48 -0
  48. package/dist/types/components/ICEProgressBar.d.ts +37 -0
  49. package/dist/types/components/ICERadioButton.d.ts +21 -0
  50. package/dist/types/components/ICERadioGroup.d.ts +71 -0
  51. package/dist/types/components/ICERate.d.ts +43 -0
  52. package/dist/types/components/ICEResult.d.ts +30 -0
  53. package/dist/types/components/ICEScrollPane.d.ts +72 -0
  54. package/dist/types/components/ICESegmented.d.ts +34 -0
  55. package/dist/types/components/ICESelect.d.ts +85 -0
  56. package/dist/types/components/ICESeparator.d.ts +7 -0
  57. package/dist/types/components/ICESkeleton.d.ts +29 -0
  58. package/dist/types/components/ICESlider.d.ts +63 -0
  59. package/dist/types/components/ICESpace.d.ts +51 -0
  60. package/dist/types/components/ICESpin.d.ts +33 -0
  61. package/dist/types/components/ICESplitter.d.ts +85 -0
  62. package/dist/types/components/ICEStatCard.d.ts +14 -0
  63. package/dist/types/components/ICEStatistic.d.ts +78 -0
  64. package/dist/types/components/ICESteps.d.ts +31 -0
  65. package/dist/types/components/ICESvgIcon.d.ts +9 -0
  66. package/dist/types/components/ICESwitch.d.ts +23 -0
  67. package/dist/types/components/ICETable.d.ts +250 -0
  68. package/dist/types/components/ICETabs.d.ts +17 -0
  69. package/dist/types/components/ICETag.d.ts +15 -0
  70. package/dist/types/components/ICETextArea.d.ts +8 -0
  71. package/dist/types/components/ICETextField.d.ts +80 -0
  72. package/dist/types/components/ICETileMap.d.ts +152 -0
  73. package/dist/types/components/ICETimePicker.d.ts +81 -0
  74. package/dist/types/components/ICETimeline.d.ts +33 -0
  75. package/dist/types/components/ICETooltip.d.ts +55 -0
  76. package/dist/types/components/ICETour.d.ts +97 -0
  77. package/dist/types/components/ICETransfer.d.ts +68 -0
  78. package/dist/types/components/ICETree.d.ts +107 -0
  79. package/dist/types/components/ICETreeSelect.d.ts +64 -0
  80. package/dist/types/components/ICETypography.d.ts +67 -0
  81. package/dist/types/components/ICEUpload.d.ts +75 -0
  82. package/dist/types/components/ICEVirtualList.d.ts +100 -0
  83. package/dist/types/components/ICEWatermark.d.ts +49 -0
  84. package/dist/types/components/ICEWindow.d.ts +159 -0
  85. package/dist/types/core/ICEContainer.d.ts +10 -0
  86. package/dist/types/core/ICEFocusManager.d.ts +70 -0
  87. package/dist/types/core/ICEHoverManager.d.ts +26 -0
  88. package/dist/types/core/ICEManager.d.ts +24 -0
  89. package/dist/types/core/ICEMessageManager.d.ts +80 -0
  90. package/dist/types/core/ICEOverlayManager.d.ts +92 -0
  91. package/dist/types/core/ICEPainter.d.ts +12 -0
  92. package/dist/types/core/ICEWidget.d.ts +86 -0
  93. package/dist/types/i18n/ICEI18n.d.ts +35 -0
  94. package/dist/types/index.d.ts +111 -0
  95. package/dist/types/model/ICE2048Model.d.ts +90 -0
  96. package/dist/types/model/ICEBoundedRangeModel.d.ts +20 -0
  97. package/dist/types/model/ICEButtonModel.d.ts +16 -0
  98. package/dist/types/model/ICEFormModel.d.ts +105 -0
  99. package/dist/types/model/ICEHighScoreModel.d.ts +60 -0
  100. package/dist/types/model/ICEMinesweeperModel.d.ts +102 -0
  101. package/dist/types/model/ICESelectionModel.d.ts +31 -0
  102. package/dist/types/model/ICESnakeModel.d.ts +90 -0
  103. package/dist/types/model/ICETetrisModel.d.ts +118 -0
  104. package/dist/types/model/ICEToggleModel.d.ts +14 -0
  105. package/dist/types/theme/ICEArcadeTheme.d.ts +22 -0
  106. package/dist/types/theme/ICETheme.d.ts +120 -0
  107. package/dist/types/util/ICEAccessibilityMirror.d.ts +55 -0
  108. package/dist/types/util/ICEAnimation.d.ts +71 -0
  109. package/dist/types/util/ICEDragReorder.d.ts +102 -0
  110. package/dist/types/util/ICENativeInput.d.ts +65 -0
  111. package/dist/types/util/ICEOverlayPosition.d.ts +52 -0
  112. package/dist/types/util/ICEStyle.d.ts +60 -0
  113. package/dist/types/util/ICEWorldBox.d.ts +14 -0
  114. package/package.json +56 -0
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("ice-render")):"function"==typeof define&&define.amd?define(["exports","ice-render"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ICEWEB={},t.ICE)}(this,(function(t,e){"use strict";const i={colors:{primary:"#0d6efd",primaryHover:"#0b5ed7",primaryActive:"#0a58ca",primaryBg:"#cfe2ff",primaryBorder:"#9ec5fe",primaryText:"#ffffff",background:"#f8f9fa",surface:"#ffffff",elevated:"#ffffff",border:"#dee2e6",borderSecondary:"#e9ecef",text:"#212529",textSecondary:"#6c757d",textTertiary:"#adb5bd",textDisabled:"#adb5bd",muted:"#6c757d",disabled:"#e9ecef",disabledText:"#adb5bd",success:"#198754",successBg:"#d1e7dd",successBorder:"#a3cfbb",warning:"#ffc107",warningBg:"#fff3cd",warningBorder:"#ffe69c",error:"#dc3545",errorBg:"#f8d7da",errorBorder:"#f1aeb5",info:"#0dcaf0",infoBg:"#cff4fc",infoBorder:"#9eeaf9",primaryTextEmphasis:"#052c65",successTextEmphasis:"#0a3622",warningTextEmphasis:"#664d03",errorTextEmphasis:"#58151c",infoTextEmphasis:"#055160",focusRing:"#86b7fe"},spacing:{xxs:4,xs:8,sm:12,md:16,lg:24,xl:32,xxl:48},radius:{xs:2,sm:4,md:6,lg:8,xl:16,pill:999},font:{family:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",size:14,sizeSmall:12,sizeLarge:16,weightNormal:"normal",weightMedium:"500",weightSemibold:"600",weightBold:"bold"},control:{heightSmall:24,height:32,heightLarge:40,paddingXXS:4,paddingXS:8,paddingSmall:12,padding:16,paddingLarge:24,lineWidth:1,lineWidthFocused:2,switchWidth:44,switchHeight:22,switchHandle:18,checkboxSize:18,radioSize:18,progressHeight:8,sliderTrackHeight:6,sliderHandle:18},shadows:{sm:{shadowColor:"rgba(0, 0, 0, 0.075)",shadowBlur:6,shadowOffsetX:0,shadowOffsetY:2},md:{shadowColor:"rgba(0, 0, 0, 0.15)",shadowBlur:16,shadowOffsetX:0,shadowOffsetY:8},lg:{shadowColor:"rgba(0, 0, 0, 0.175)",shadowBlur:48,shadowOffsetX:0,shadowOffsetY:16}}},s={...i,colors:{primary:"#0d6efd",primaryHover:"#3d8bfd",primaryActive:"#0a58ca",primaryBg:"#031633",primaryBorder:"#084298",primaryText:"#ffffff",background:"#212529",surface:"#2b3035",elevated:"#343a40",border:"#495057",borderSecondary:"#343a40",text:"#dee2e6",textSecondary:"#adb5bd",textTertiary:"#6c757d",textDisabled:"#6c757d",muted:"#adb5bd",disabled:"#343a40",disabledText:"#6c757d",success:"#198754",successBg:"#051b11",successBorder:"#0f5132",warning:"#ffc107",warningBg:"#332701",warningBorder:"#664d03",error:"#dc3545",errorBg:"#2c0b0e",errorBorder:"#842029",info:"#0dcaf0",infoBg:"#032830",infoBorder:"#087990",primaryTextEmphasis:"#cfe2ff",successTextEmphasis:"#d1e7dd",warningTextEmphasis:"#fff3cd",errorTextEmphasis:"#f8d7da",infoTextEmphasis:"#cff4fc",focusRing:"#6ea8fe"}},o={...s,colors:{...s.colors,background:"#080a0f",surface:"#1b2130",elevated:"#232a36",border:"#39424f",borderSecondary:"#2b3340",textTertiary:"#6b7480"}};class n{themeName="light";themes=new Map([["light",i],["dark",s]]);setTheme(t){return"string"==typeof t&&this.themes.has(t)&&(this.themeName=t),this}getThemeName(){return this.themeName}registerTheme(t,e){return"string"==typeof t&&t&&e&&this.themes.set(t,e),this}hasTheme(t){return this.themes.has(t)}getThemeNames(){return[...this.themes.keys()]}getTheme(){return this.themes.get(this.themeName)||i}}const h=new n;class r extends e.ICEGroup{painter=null;preferredWidth=0;preferredHeight=0;enabled=!0;hovered=!1;focusable=!1;focused=!1;validateStatus="default";focusRingMode="keyboard";constructor(t={}){super({fill:!1,stroke:!1,draggable:!1,transformable:!1,interactive:!0,...t}),void 0!==t.focusable&&(this.focusable=!!t.focusable),"always"!==t.focusRing&&"never"!==t.focusRing&&"keyboard"!==t.focusRing||(this.focusRingMode=t.focusRing)}getFocusRingMode(){return this.focusRingMode}setFocusRingMode(t){return this.focusRingMode="always"===t||"never"===t?t:"keyboard",this}shouldShowFocusRing(t){return"never"!==this.focusRingMode&&("always"===this.focusRingMode||"keyboard"===t)}setEnabled(t){return this.enabled=!!t,this.setState({interactive:this.enabled}),this.revalidate(),this}setAriaLabel(t){return this.setState({ariaLabel:String(t??"")}),this}getAriaLabel(){const t=this.state&&this.state.ariaLabel;return"string"==typeof t?t:""}isEnabled(){return this.enabled}isHovered(){return this.hovered}isFocusable(){return this.focusable&&this.enabled&&!1!==this.state.interactive&&this.isEffectivelyVisible()}setFocusable(t){return this.focusable=!!t,this}isFocused(){return this.focused}setFocused(t){const e=!!t&&this.enabled;return e===this.focused||(this.focused=e,this.__applyFocusState(),this.revalidate()),this}activate(){this.enabled&&this.trigger("click",null,{source:"keyboard"})}__applyFocusState(){}getValidateStatus(){return this.validateStatus}setValidateStatus(t){const e=t||"default";return e===this.validateStatus||(this.validateStatus=e,this.__applyValidateState(),this.revalidate()),this}__applyValidateState(){}getFormValue(){return this.state.value}setFormValue(t){this.setState({value:t})}setHovered(t){const e=!!t&&this.enabled;return e===this.hovered||(this.hovered=e,this.__applyHoverState(),this.revalidate(),this.trigger("hoverchange",null,{hovered:e})),this}setPreferredSize(t,e){return this.preferredWidth=Math.max(0,t||0),this.preferredHeight=Math.max(0,e||0),this.revalidate(),this}getPreferredSize(){return this.painter&&"function"==typeof this.painter.getPreferredSize?this.painter.getPreferredSize(this):[this.preferredWidth,this.preferredHeight]}setPainter(t){return this.painter&&"function"==typeof this.painter.uninstall&&this.painter.uninstall(this),this.painter=t,t&&"function"==typeof t.install&&t.install(this),this.revalidate(),this}getPainter(){return this.painter}__applyHoverState(){}addChild(t,e=!0){t instanceof r||!t||!t.state||(t.state.interactive=!1,t.state.draggable=!1,t.state.transformable=!1,t.state.linkable=!1),super.addChild(t,e)}revalidate(){return this.requestLayout(),this.ice&&(this.ice.dirty=!0),this}theme(){return h.getTheme()}}const l={top:"bottom",topLeft:"bottomLeft",topRight:"bottomRight",bottom:"top",bottomLeft:"topLeft",bottomRight:"topRight",left:"right",leftTop:"rightTop",leftBottom:"rightBottom",right:"left",rightTop:"leftTop",rightBottom:"leftBottom"};function a(t){return t.replace(/(Left|Right|Top|Bottom)$/,"")||t}function d(t,e){const{anchor:i,content:s}=t,o=t.offset??8,n=a(e),h=function(t){const e=/(Left|Right|Top|Bottom)$/.exec(t);return e?e[1]:""}(e),r=i.left+i.width/2,l=i.top+i.height/2,d=i.left+i.width,c=i.top+i.height;if("bottom"===n||"top"===n){const t="bottom"===n?c+o:i.top-o-s.height;let e=r-s.width/2;return"Left"===h?e=i.left:"Right"===h&&(e=d-s.width),{left:e,top:t}}const u="right"===n?d+o:i.left-o-s.width;let f=l-s.height/2;return"Top"===h?f=i.top:"Bottom"===h&&(f=c-s.height),{left:u,top:f}}function c(t,e,i){const s=t.padding??4,{content:o,container:n}=t,h=a(e),r="top"===h||"bottom"===h,l=Math.max(s,n.width-s-o.width),d=Math.max(s,n.height-s-o.height),c=r?Math.min(Math.max(i.left,s),l):i.left,u=r?i.top:Math.min(Math.max(i.top,s),d);return c>=s&&u>=s&&c+o.width<=n.width-s&&u+o.height<=n.height-s}function u(t){const e=t.container.left??0,i=t.container.top??0,s={...t,anchor:{left:t.anchor.left-e,top:t.anchor.top-i,width:t.anchor.width,height:t.anchor.height},container:{width:t.container.width,height:t.container.height}},o=s.placement||"bottom",n=s.padding??4,h=!1!==s.flip,{content:r,container:a}=s;let u=o,f=d(s,u),g=!1;if(!c(s,u,f)&&h){const t=l[o];if(t){const e=d(s,t);!c(s,t,e)&&c(s,o,f)||(u=t,f=e,g=!0)}}const m=Math.max(n,a.width-n-r.width),p=Math.max(n,a.height-n-r.height);return{left:Math.min(Math.max(f.left,n),m)+e,top:Math.min(Math.max(f.top,n),p)+i,placement:u,flipped:g}}const f={request(t){const e=globalThis.requestAnimationFrame;return"function"==typeof e?e(t):setTimeout(()=>t(Date.now()),16)},cancel(t){const e=globalThis.cancelAnimationFrame;"function"!=typeof e?clearTimeout(t):e(t)}};function g(t){return t*t}function m(t){const e=1-t;return 1-e*e*e}function p(t){return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}function y(t){return"function"==typeof t?t:"easeIn"===t?g:"easeOut"===t?m:"easeInOut"===t?p:t=>t}function _(t){const e=t.driver||f,i=Number(t.duration),s=Number.isFinite(i)&&i>0?i:0,o=Number(t.delay)||0,n=y(t.easing),h=Number.isFinite(Number(t.from))?Number(t.from):0,r=Number(t.to);let l=null,a=null,d=!1,c=!1;const u={cancel(){c=!0,null!==a&&(e.cancel(a),a=null)}},g=()=>{d||(d=!0,a=null,t.onFinish&&t.onFinish())},m=i=>{if(a=null,c||d)return;null===l&&(l=i);const u=i-l-o;return u<0?(t.onUpdate(h),void(a=e.request(m))):u>=s?(t.onUpdate(r),void g()):(t.onUpdate(h+(r-h)*n(u/s)),void(a=e.request(m)))};return 0===s?(t.onUpdate(r),g(),u):(a=e.request(m),u)}function w(t,e){t.setState({opacity:e})}function b(t,e,i={}){const s=Number(t.state.opacity);return _({from:Number.isFinite(s)?s:1,to:e,duration:i.duration??200,delay:i.delay,easing:i.easing??"easeOut",driver:i.driver,onUpdate:e=>w(t,e),onFinish:i.onFinish})}function v(t,e={}){return w(t,0),_({from:0,to:1,duration:e.duration??200,delay:e.delay,easing:e.easing??"easeOut",driver:e.driver,onUpdate:e=>w(t,e),onFinish:e.onFinish})}function x(t,e={}){return b(t,0,{duration:150,...e})}function S(t,e){const i=Number(e.distance??12),s=Number(t.state.left)||0,o=Number(t.state.top)||0,n="left"===e.from?s-i:"right"===e.from?s+i:s,h="top"===e.from?o-i:"bottom"===e.from?o+i:o;!1!==e.fade&&w(t,0),t.setState({left:n,top:h});let r=null;!1!==e.fade&&(r=_({from:0,to:1,duration:e.duration??200,delay:e.delay,easing:e.easing??"easeOut",driver:e.driver,onUpdate:e=>w(t,e)}));const l=_({from:0,to:1,duration:e.duration??200,delay:e.delay,easing:e.easing??"easeOut",driver:e.driver,onUpdate:e=>{t.setState({left:n+(s-n)*e,top:h+(o-h)*e})},onFinish:e.onFinish});return{cancel(){l.cancel(),r&&r.cancel()}}}function C(t,e={}){const i=Number(e.from??.96),s=t.state.transform||{};!1!==e.fade&&w(t,0),t.setState({transform:{...s,scale:[i,i]}});let o=null;!1!==e.fade&&(o=_({from:0,to:1,duration:e.duration??200,delay:e.delay,easing:e.easing??"easeOut",driver:e.driver,onUpdate:e=>w(t,e)}));const n=_({from:i,to:1,duration:e.duration??200,delay:e.delay,easing:e.easing??"easeOut",driver:e.driver,onUpdate:e=>{t.setState({transform:{...s,scale:[e,e]}})},onFinish:e.onFinish});return{cancel(){n.cancel(),o&&o.cancel()}}}function N(t){let e=0,i=0,s=t;for(;s&&s.state;)e+=Number(s.state.left)||0,i+=Number(s.state.top)||0,s=s.parentNode;return{left:e,top:i,width:Number(t&&t.state&&t.state.width)||0,height:Number(t&&t.state&&t.state.height)||0}}function M(t,e,i){return e>=t.left&&e<=t.left+t.width&&i>=t.top&&i<=t.top+t.height}class k{layer=null;entries=[];bound=!1;constructor(t){this.ice=t}start(){if(this.bound||!this.ice)return this;this.layer||(this.layer=new r({id:"ice-ui-overlay-layer",fill:!1,stroke:!1,interactive:!1,draggable:!1,transformable:!1,left:0,top:0,width:Number(this.ice.canvasWidth)||0,height:Number(this.ice.canvasHeight)||0})),"function"==typeof this.ice.addTool&&this.ice.addTool(this.layer);const t=this.ice.evtBus;return t&&"function"==typeof t.on&&(t.on("mousedown",this.__onMouseDown,this),t.on("keydown",this.__onKeyDown,this)),this.bound=!0,this}stop(){if(this.closeAll("api"),!this.bound)return this;const t=this.ice&&this.ice.evtBus;return t&&"function"==typeof t.off&&(t.off("mousedown",this.__onMouseDown,this),t.off("keydown",this.__onKeyDown,this)),this.layer&&this.ice&&"function"==typeof this.ice.removeTool&&this.ice.removeTool(this.layer),this.layer=null,this.bound=!1,this}open(t){const e=t&&t.content;if(!e)throw new Error("ICEOverlayManager.open() 需要 content");if(this.start(),!1!==t.exclusive)if(t.blocking)this.closeAll("exclusive");else{this.entries.filter(t=>!t.options.blocking).forEach(t=>this.close(t.handle,"exclusive"))}const i={handle:null,anchor:t.anchor,content:e,options:t},s={close:()=>this.close(s,"api"),isOpen:()=>-1!==this.entries.indexOf(i),update:()=>{-1!==this.entries.indexOf(i)&&this.__place(i)}};i.handle=s,this.layer.addChild(e),this.entries.push(i),this.__place(i);const o=t.enterAnimation||"none";return"fade"===o?v(e,t.animation):"scale"===o&&C(e,t.animation),this.__markDirty(),s}close(t,e="api"){const i=this.entries.findIndex(e=>e.handle===t);if(-1===i)return;const s=this.entries[i];this.entries.splice(i,1),"fade"!==s.options.exitAnimation?this.__destroyEntry(s,e):x(s.content,{...s.options.animation||{},onFinish:()=>this.__destroyEntry(s,e)})}closeAll(t="api"){if(!this.entries.length)return;this.entries.splice(0,this.entries.length).forEach(e=>this.__destroyEntry(e,t))}isOpen(){return this.entries.length>0}isKeyboardCaptured(){return this.entries.some(t=>!0===t.options.keyboardCaptured)}getLayer(){return this.layer}__destroyEntry(t,e){const{layer:i}=this;i&&i.childNodes&&-1!==i.childNodes.indexOf(t.content)&&i.removeChild(t.content),this.__markDirty(),"function"==typeof t.options.onClose&&t.options.onClose(e)}__place(t){const{options:e,anchor:i,content:s}=t,o=this.__visibleWorldRect();if(e.centered||!i){const t=Number(s.state&&s.state.width)||0,e=Number(s.state&&s.state.height)||0;return void s.setState({left:o.left+(o.width-t)/2,top:o.top+(o.height-e)/2})}const n=u({anchor:N(i),content:{width:Number(s.state&&s.state.width)||0,height:Number(s.state&&s.state.height)||0},container:o,placement:e.placement,offset:e.offset,padding:e.padding,flip:e.flip});s.setState({left:n.left,top:n.top})}__visibleWorldRect(){const t=Number(this.ice&&this.ice.canvasWidth)||0,e=Number(this.ice&&this.ice.canvasHeight)||0,i=this.ice&&"function"==typeof this.ice.getRenderViewport?this.ice.getRenderViewport():null,s=i&&i.scale?i.scale:1;return{left:i?-(i.tx||0)/s:0,top:i?-(i.ty||0)/s:0,width:t/s,height:e/s}}__markDirty(){this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}__onMouseDown(t){if(!this.entries.length||!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.entries.filter(t=>!1!==t.options.closeOnOutsideClick).length)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY);this.entries.some(t=>M(N(t.content),e,i)||!!t.anchor&&M(N(t.anchor),e,i))||this.closeAll("outside")}__onKeyDown(t){if(!this.entries.length)return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if("Escape"!==i&&"Esc"!==i)return;this.entries.filter(t=>!1!==t.options.closeOnEsc).forEach(t=>this.close(t.handle,"esc"))}}const T=new WeakMap;function z(t){if(!t||"object"!=typeof t)throw new Error("getICEOverlayManager(ice) 需要一个 ICE 实例");let e=T.get(t);return e||(e=new k(t),T.set(t,e)),e}function E(t){let e=0,i=0,s=t;for(;s&&s.state;)e+=Number(s.state.left)||0,i+=Number(s.state.top)||0,s=s.parentNode;return{left:e,top:i,width:Number(t&&t.state&&t.state.width)||0,height:Number(t&&t.state&&t.state.height)||0}}class I{toolNode=null;ring=null;focused=null;focusOrigin="api";bound=!1;ringPadding=2;scope=null;constructor(t){this.ice=t}start(){if(this.bound||!this.ice)return this;const t=h.getTheme();this.toolNode=new r({id:"ice-ui-focus-layer",fill:!1,stroke:!1,interactive:!1,draggable:!1,transformable:!1,left:0,top:0,width:Number(this.ice.canvasWidth)||0,height:Number(this.ice.canvasHeight)||0}),this.ring=new r({left:0,top:0,width:0,height:0,radius:6,fill:!1,stroke:!0,interactive:!1,draggable:!1,transformable:!1,display:!1,style:{strokeStyle:t.colors.focusRing,lineWidth:2}}),this.toolNode.addChild(this.ring,!1),"function"==typeof this.ice.addTool&&this.ice.addTool(this.toolNode);const e=this.ice.evtBus;return e&&"function"==typeof e.on&&(e.on("keydown",this.__onKeyDown,this),e.on("mousedown",this.__onMouseDown,this)),this.bound=!0,this}stop(){if(!this.bound)return this;const t=this.ice&&this.ice.evtBus;return t&&"function"==typeof t.off&&(t.off("keydown",this.__onKeyDown,this),t.off("mousedown",this.__onMouseDown,this)),this.focus(null),this.toolNode&&this.ice&&"function"==typeof this.ice.removeTool&&this.ice.removeTool(this.toolNode),this.toolNode=null,this.ring=null,this.bound=!1,this}getFocused(){return this.focused}getRing(){return this.ring}getFocusOrigin(){return this.focusOrigin}isRingVisible(){return!(!this.ring||!this.ring.state.display)}getFocusables(){const t=[],e=i=>{i&&i.state&&("function"!=typeof i.isEffectivelyVisible||i.isEffectivelyVisible())&&("function"==typeof i.isFocusable&&i.isFocusable()&&t.push(i),(i.childNodes||[]).forEach(e))};return this.scope?e(this.scope):(this.ice.childNodes||[]).forEach(e),t}setFocusScope(t){return this.scope=t||null,this.focused&&this.scope&&!function(t,e){let i=t;for(;i;){if(i===e)return!0;i=i.parentNode}return!1}(this.focused,this.scope)&&this.focus(null),this}getFocusScope(){return this.scope}focus(t,e={}){const i=t&&"function"==typeof t.isFocusable&&t.isFocusable()?t:null;return this.focusOrigin=e.origin||"api",i===this.focused?(this.__syncRing(),this):(this.focused&&"function"==typeof this.focused.setFocused&&(this.focused.setFocused(!1),this.__watchMove(this.focused,!1)),this.focused=i,i&&("function"==typeof i.setFocused&&i.setFocused(!0),this.__watchMove(i,!0)),this.ice&&"function"==typeof this.ice.setFocusedComponent&&this.ice.setFocusedComponent(i),this.__syncRing(),this)}focusNext(){const t=this.getFocusables();if(!t.length)return this.focus(null);const e=this.focused?t.indexOf(this.focused):-1;return this.focus(t[(e+1)%t.length],{origin:"keyboard"})}focusPrev(){const t=this.getFocusables();if(!t.length)return this.focus(null);const e=this.focused?t.indexOf(this.focused):0;return this.focus(t[(e-1+t.length)%t.length],{origin:"keyboard"})}__onKeyDown(t){const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if(!this.ice||!z(this.ice).isKeyboardCaptured())if("Tab"!==i)if("Escape"!==i&&"Esc"!==i){if("Enter"===i||" "===i||"Spacebar"===i){const t=this.focused;t&&"function"==typeof t.activate&&t.activate()}}else this.focus(null);else e.shiftKey?this.focusPrev():this.focusNext()}__onMouseDown(t){if(!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.ice||"function"!=typeof this.ice.hitTest)return;let e=this.ice.hitTest(t.offsetX,t.offsetY);for(;e&&"function"==typeof e.isFocusable&&!e.isFocusable();)e=e.parentNode;this.focus(e&&"function"==typeof e.isFocusable?e:null,{origin:"mouse"})}__watchMove(t,e){t&&"function"==typeof t.on&&"function"==typeof t.off&&(e?t.on("AFTER_MOVE",this.__onFocusedMoved,this):t.off("AFTER_MOVE",this.__onFocusedMoved,this))}__onFocusedMoved(){this.__syncRing()}__syncRing(){const t=this.ring;if(!t)return;const e=this.focused,i=!!e&&("function"==typeof e.shouldShowFocusRing?e.shouldShowFocusRing(this.focusOrigin):"keyboard"===this.focusOrigin);if(!e||!i)return void t.setState({display:!1});const s=E(e),o=this.ringPadding;t.setState({display:!0,left:s.left-o,top:s.top-o,width:s.width+2*o,height:s.height+2*o,radius:(Number(e.state&&e.state.radius)||0)+o}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}}const A=new WeakMap;function B(t){if(!t||"object"!=typeof t)throw new Error("getICEFocusManager(ice) 需要一个 ICE 实例");let e=A.get(t);return e||(e=new I(t),A.set(t,e)),e}class H extends r{constructor(t={}){const i=h.getTheme(),s={fillStyle:i.colors.text,fontFamily:i.font.family,fontSize:i.font.size,fontWeight:i.font.weightNormal};super({fill:!1,stroke:!1,...t});const o=t.verticalAlign,n=t.align,r="top"===o?"top":"bottom"===o?"bottom":void 0!==t.height?"middle":void 0,l={left:0,top:0,text:t.text??"",stroke:!1,style:{...s,..."center"===n?{textAlign:"center"}:{},..."right"===n?{textAlign:"right"}:{},...r?{textBaseline:r}:{},...t.style||{}}};void 0!==t.width&&(l.width=t.width),void 0!==t.height&&(l.height=t.height),this.textNode=new e.ICEText(l),this.addChild(this.textNode,!1),this.__adoptTextSize(!1)}setText(t){return this.textNode.setText(t??""),this.__adoptTextSize(!0),this.revalidate(),this}getText(){return this.textNode.getText()}__adoptTextSize(t){if(!this.textNode)return;t&&"function"==typeof this.textNode.refreshParams&&this.textNode.refreshParams();const e=Number(this.textNode.state.width),i=Number(this.textNode.state.height);let s=!1;10===this.props.width&&e>0&&this.state.width!==e&&(this.state.width=e,s=!0),10===this.props.height&&i>0&&this.state.height!==i&&(this.state.height=i,s=!0),s&&(this.dirty=!0,this.parentNode&&"function"==typeof this.parentNode.requestLayout&&this.parentNode.requestLayout())}getPreferredSize(){return[Number(this.state.width)||0,Number(this.state.height)||0]}}class W extends r{constructor(t={}){super(t)}setLayout(t){return super.setLayout(t),this}}class O extends W{constructor(t={}){const e=h.getTheme();super({...t,fill:!0,stroke:!0,radius:t.radius??e.radius.lg,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth,...e.shadows.sm,...t.style||{}}})}}function F(t,e){let i=0;for(const s of String(t??""))i+=/[\u2e80-\u9fff\u3000-\u303f\uff00-\uffef]/.test(s)?e:.6*e;return Math.ceil(i)}function R(t){return!!t&&!!(t.param?t.param.hovered:t.hovered)}function D(t,e="default"){return"success"===e?{background:t.colors.successBg,border:t.colors.successBorder,text:t.colors.success,strong:t.colors.successTextEmphasis,solid:t.colors.success,onSolid:"#ffffff"}:"warning"===e?{background:t.colors.warningBg,border:t.colors.warningBorder,text:t.colors.warning,strong:t.colors.warningTextEmphasis,solid:t.colors.warning,onSolid:"#000000"}:"error"===e?{background:t.colors.errorBg,border:t.colors.errorBorder,text:t.colors.error,strong:t.colors.errorTextEmphasis,solid:t.colors.error,onSolid:"#ffffff"}:"info"===e?{background:t.colors.infoBg,border:t.colors.infoBorder,text:t.colors.info,strong:t.colors.infoTextEmphasis,solid:t.colors.info,onSolid:"#000000"}:"primary"===e?{background:t.colors.primaryBg,border:t.colors.primaryBorder,text:t.colors.primary,strong:t.colors.primaryTextEmphasis,solid:t.colors.primary,onSolid:"#ffffff"}:{background:t.colors.surface,border:t.colors.border,text:t.colors.textSecondary,strong:t.colors.text,solid:t.colors.textSecondary,onSolid:"#ffffff"}}function V(t){const{text:i="",left:s=0,top:o=0,width:n,height:h,fillStyle:r,fontFamily:l,fontSize:a,fontWeight:d,align:c="left",verticalAlign:u="top"}=t,f={fillStyle:r,fontFamily:l,fontSize:a,fontWeight:d};return"center"===c?f.textAlign="center":"right"===c&&(f.textAlign="right"),"middle"===u?f.textBaseline="middle":"bottom"===u&&(f.textBaseline="bottom"),new e.ICEText({left:s,top:o,text:i,width:n,height:h,stroke:!1,style:f})}function L(t,e,i,s,o={}){return V({text:t,left:0,top:0,width:i,height:s,fillStyle:o.fillStyle??e.colors.text,fontFamily:e.font.family,fontSize:o.fontSize??e.font.size,fontWeight:o.fontWeight??e.font.weightNormal,align:"center",verticalAlign:"middle"})}function P(t,e){return"small"===e?t.font.sizeSmall:"large"===e?t.font.sizeLarge:t.font.size}function K(t,e,i,s,o,n,h){if("text"===e||"link"===e)return{fill:!1,stroke:!1,fillStyle:"rgba(0,0,0,0)",strokeStyle:"rgba(0,0,0,0)",shadow:void 0};if("default"===e){const e=s||o?i?t.colors.error:t.colors.primary:t.colors.border;return{fill:!0,stroke:!0,fillStyle:n?t.colors.surface:t.colors.disabled,strokeStyle:e,shadow:void 0}}const r=i?t.colors.error:s?t.colors.primaryActive:o?t.colors.primaryHover:n?t.colors.primary:t.colors.disabled;return{fill:!0,stroke:!0,fillStyle:r,strokeStyle:r,...n?t.shadows.sm:{}}}function X(t,e,i,s,o=!1){return"primary"===e?t.colors.primaryText:i?t.colors.error:"text"===e||"link"===e?o?t.colors.primaryHover:t.colors.primary:s?o?t.colors.primary:t.colors.text:t.colors.textDisabled}class Y extends r{explicitAriaLabel=!1;pressed=!1;constructor(t={}){const e=h.getTheme(),i=t.variant||"primary",s=t.size||"middle",o=!0===t.danger,n=t.height||function(t,e){return"small"===e?t.control.heightSmall:"large"===e?t.control.heightLarge:t.control.height}(e,s),r=t.width||96,l=K(e,i,o,!1,!1,!0,t.style);super({fill:!1!==l.fill,stroke:!1!==l.stroke,draggable:void 0!==t.draggable&&t.draggable,transformable:void 0!==t.transformable&&t.transformable,interactive:!0,...t,width:r,height:n,radius:t.radius??e.radius.md,style:{fillStyle:l.fillStyle,strokeStyle:l.strokeStyle,lineWidth:e.control.lineWidth,shadow:l.shadow,...t.style||{}}}),this.focusable=!1!==t.focusable,this.variant=i,this.size=s,this.danger=o;const a=P(e,s);this.label=L(t.text??"Button",e,r,n,{fontSize:a,fontWeight:e.font.weightMedium,fillStyle:X(e,i,o,!0,!1)}),this.addChild(this.label,!1),void 0!==t.ariaLabel?(this.explicitAriaLabel=!0,super.setAriaLabel(String(t.ariaLabel))):super.setAriaLabel(String(t.text??"Button"))}setAriaLabel(t){return super.setAriaLabel(t),this.explicitAriaLabel=!0,this}setText(t){return this.label.setText(t??""),this.explicitAriaLabel||super.setAriaLabel(t??""),this.revalidate(),this}getText(){return this.label.getText()}initEvents(){super.initEvents(),this.on("mousedown",()=>{this.enabled&&(this.pressed=!0,this.__sync())}),this.on("mouseup",()=>{this.pressed=!1,this.__sync()}),this.on("mouseleave",()=>{this.pressed=!1,this.__sync()})}setEnabled(t){return super.setEnabled(t),this.__sync(),this}__applyHoverState(){this.__sync()}__sync(){const t=h.getTheme(),e=!!this.enabled&&this.pressed,i=K(t,this.variant,this.danger,e,this.hovered,this.enabled,this.state.style);this.setState({style:{...this.state.style,fillStyle:i.fillStyle,strokeStyle:i.strokeStyle,lineWidth:t.control.lineWidth,shadow:i.shadow}}),this.label.setState({style:{fillStyle:X(t,this.variant,this.danger,this.enabled,this.hovered),fontFamily:t.font.family,fontSize:P(t,this.size),fontWeight:t.font.weightMedium,textAlign:"center",textBaseline:"middle"}}),this.revalidate()}}class G{layer=null;entries=[];bound=!1;constructor(t){this.ice=t}start(){return this.bound||!this.ice||(this.layer=new r({id:"ice-ui-message-layer",fill:!1,stroke:!1,interactive:!1,draggable:!1,transformable:!1,left:0,top:0,width:Number(this.ice.canvasWidth)||0,height:Number(this.ice.canvasHeight)||0}),"function"==typeof this.ice.addTool&&this.ice.addTool(this.layer),this.bound=!0),this}stop(){return this.closeAll(),this.bound&&this.layer&&"function"==typeof this.ice.removeTool&&this.ice.removeTool(this.layer),this.layer=null,this.bound=!1,this}getLayer(){return this.layer}show(t){const e=String(t.text??"");return this.__push("message",t,i=>{const s=Math.min(320,Math.max(160,Math.round(7*e.length)+48)),o=new O({width:s,height:34,radius:i.radius.md,style:{fillStyle:i.colors.surface,strokeStyle:i.colors.border,shadow:"md"}}),n=this.__typeColor(t.type);return o.addChild(new H({left:12,top:0,width:18,height:34,verticalAlign:"middle",text:this.__typeIcon(t.type),style:{fontSize:14,fillStyle:n}}),!1),o.addChild(new H({left:34,top:0,width:s-46,height:34,verticalAlign:"middle",text:e,style:{fontSize:13,fillStyle:i.colors.text}}),!1),o})}notification(t){const e=String(t.title??""),i=String(t.description??"");return this.__push("notification",{...t,text:e},(t,s)=>{const o=i?20:0,n=new O({width:300,height:38+o+14,radius:t.radius.md,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"lg"}});n.addChild(new H({left:14,top:14,width:240,height:22,verticalAlign:"middle",text:e,style:{fontSize:14,fontWeight:"600",fillStyle:t.colors.text}}),!1),i&&n.addChild(new H({left:14,top:36,width:272,height:o,verticalAlign:"middle",text:i,style:{fontSize:12,fillStyle:t.colors.textSecondary}}),!1);const h=new Y({left:256,top:12,width:32,height:24,text:"✕",variant:"text",size:"small"});return h.on("click",()=>this.__closeEntry(s)),n.addChild(h,!1),n},!0)}closeAll(){this.entries.slice().forEach(t=>this.__closeEntry(t))}isOpen(){return this.entries.length>0}__push(t,e,i,s=!1){this.start();const o=h.getTheme(),n={handle:null,node:null,options:e,kind:t,timer:null},r=i(o,n);n.node=r;const l={close:()=>this.__closeEntry(n),isOpen:()=>-1!==this.entries.indexOf(n),getNode:()=>r};n.handle=l,this.layer.addChild(r),this.entries.push(n),this.__relayout();const a="notification"===t?"right":"top",d=Number(r.state.left)||0,c=Number(r.state.top)||0;e.animation&&0===e.animation.duration?r.setState({left:d,top:c,opacity:1}):(S(r,{from:a,distance:"notification"===t?16:8,duration:180,...e.animation||{}}),r.setState({left:d,top:c}));const u=void 0===e.duration?3e3:Number(e.duration);return u>0&&(n.timer=setTimeout(()=>this.__closeEntry(n,!0),u)),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0),l}__closeEntry(t,e=!1){const i=this.entries.indexOf(t);if(-1===i)return;this.entries.splice(i,1),t.timer&&(clearTimeout(t.timer),t.timer=null);const s=()=>{this.layer&&-1!==this.layer.childNodes.indexOf(t.node)&&this.layer.removeChild(t.node),this.__relayout(),t.options.onClose&&t.options.onClose()};!e||t.options.animation&&0===t.options.animation.duration?s():x(t.node,{duration:120,...t.options.animation||{},onFinish:s})}__relayout(){if(!this.layer)return;const t=Number(this.ice.canvasWidth)||0,e=Number(this.ice.canvasHeight)||0,i=this.entries.filter(t=>"message"===t.kind),s=this.entries.filter(t=>"notification"===t.kind);let o=16;i.forEach(e=>{const i=Number(e.node.state.width)||160;e.node.setState({left:Math.round((t-i)/2),top:o}),o+=Number(e.node.state.height)+12});let n=e-16;s.forEach(e=>{const i=Number(e.node.state.height)||40,s=Number(e.node.state.width)||300;e.node.setState({left:t-16-s,top:n-i}),n-=i+12})}__typeColor(t){const e=h.getTheme();return"success"===t?e.colors.success:"warning"===t?e.colors.warning:"error"===t?e.colors.error:"loading"===t?e.colors.primary:e.colors.info}__typeIcon(t){return"success"===t?"✓":"warning"===t?"!":"error"===t?"✕":"loading"===t?"◌":"ℹ"}}const $=new WeakMap;function q(t){if(!t||"object"!=typeof t)throw new Error("getICEMessageManager(ice) 需要一个 ICE 实例");let e=$.get(t);return e||(e=new G(t),$.set(t,e)),e}const U={show:(t,e,i={})=>q(t).show({text:e,...i}),success:(t,e,i={})=>q(t).show({text:e,type:"success",...i}),error:(t,e,i={})=>q(t).show({text:e,type:"error",...i}),warning:(t,e,i={})=>q(t).show({text:e,type:"warning",...i}),info:(t,e,i={})=>q(t).show({text:e,type:"info",...i}),loading:(t,e,i={})=>q(t).show({text:e,type:"loading",...i})},j={open:(t,e)=>q(t).notification(e)};function Z(t){const e=Math.floor(Number(t.itemHeight)||0),i=Math.max(0,Math.floor(Number(t.itemCount)||0));if(e<=0||i<=0)return null;const s=Number(t.pointerY),o=Number.isFinite(s)?s:0;if(o<0)return{index:0,position:"before"};if(o>=i*e)return{index:i-1,position:"after"};const n=Math.min(i-1,Math.floor(o/e));return{index:n,position:o-n*e<e/2?"before":"after"}}function Q(t,e,i){const s=Array.isArray(t)?t:[],o=s.length,n=Math.floor(Number(e));if(!Number.isFinite(n)||n<0||n>=o)return{items:s.slice(),to:-1,moved:!1};const h=Math.floor(Number(i&&i.index));if(!Number.isFinite(h)||h<0||h>=o)return{items:s.slice(),to:-1,moved:!1};const r=i&&"after"===i.position?"after":"before",l=s.slice(),[a]=l.splice(n,1);let d=h+("after"===r?1:0);return n<d&&(d-=1),l.splice(d,0,a),{items:l,to:d,moved:d!==n}}function J(t){const e=Math.floor(Number(t.itemHeight)||0),i=Math.max(0,Math.floor(Number(t.itemCount)||0));if(e<=0||i<=0)return null;const s=Number(t.pointerY),o=Number.isFinite(s)?s:0;if(o<0)return{index:0,position:"before"};if(o>=i*e)return{index:i-1,position:"after"};const n=Math.min(i-1,Math.floor(o/e)),h=(o-n*e)/e;return{index:n,position:h<1/3?"before":h<2/3?"inside":"after"}}function tt(t,e,i){for(const s of t||[]){if(s.key===e)return s;if(Array.isArray(s[i])){const t=tt(s[i],e,i);if(t)return t}}return null}function et(t,e,i,s,o="children"){const n=Array.isArray(t)?t:[],h={nodes:n.slice(),moved:!1,parentKey:null};if(!e||!i||e===i)return h;const r=tt(n,e,o),l=tt(n,i,o);if(!r||!l)return h;if(Array.isArray(r[o])&&function t(e,i,s){return(e||[]).some(e=>e.key===i||Array.isArray(e[s])&&t(e[s],i,s))}(r[o],i,o))return h;const a=function t(e,i,s){const o=[];let n=null;return(e||[]).forEach(e=>{if(e.key===i)return void(n=e);const h={...e};if(Array.isArray(e[s])){const o=t(e[s],i,s);h[s]=o.nodes,o.detached&&(n=o.detached)}o.push(h)}),{nodes:o,detached:n}}(function t(e,i){return(e||[]).map(e=>{const s={...e};return Array.isArray(e[i])&&(s[i]=t(e[i],i)),s})}(n,o),e,o);if(!a.detached)return h;const d=a.detached;let c=!1,u=null;const f=(t,e)=>{const n=t.findIndex(t=>t.key===i);if(n>=0){const i="after"===s?n+1:n;if("inside"===s){const e=t[n];e[o]=Array.isArray(e[o])?e[o].concat([d]):[d],u=e.key}else t.splice(i,0,d),u=e;c=!0}else t.forEach(t=>{!c&&Array.isArray(t[o])&&f(t[o],t.key)})};if(f(a.nodes,null),!c)return h;return it(n,o)===it(a.nodes,o)?h:{nodes:a.nodes,moved:!0,parentKey:u}}function it(t,e){return(t||[]).map(t=>{const i=Array.isArray(t[e])?`(${it(t[e],e)})`:"";return`${t.key}${i}`}).join(",")}function st(t,e,i,s){const o=Array.isArray(t)?t:[],n={columns:o.slice(),moved:!1,columnKey:null,index:-1},h=o.find(t=>t.key===i);if(!h)return n;let r=null,l=-1;if(o.forEach(t=>{const i=(t.cards||[]).findIndex(t=>t&&t.key===e);i>=0&&(r=t,l=i)}),!r||l<0)return n;const a=(h.cards||[]).length,d=Math.min(Math.max(Math.floor(Number(s)||0),0),r===h?a-1:a);if(r===h&&l===d)return n;const c=o.map(t=>({...t,cards:(t.cards||[]).slice()})),u=c.find(t=>t.key===r.key),[f]=u.cards.splice(l,1),g=c.find(t=>t.key===i),m=Math.min(Math.max(Math.floor(Number(s)||0),0),g.cards.length);return g.cards.splice(m,0,f),{columns:c,moved:!0,columnKey:i,index:m}}const ot={"common.ok":"确定","common.cancel":"取消","common.confirm":"确认操作?","common.loading":"加载中…","table.empty":"暂无数据","pagination.total":"共 {total} 条","form.validating":"校验中…","upload.hint":"点击或拖拽文件到此处上传","transfer.pending":"待选","transfer.selected":"已选","tour.skip":"跳过","tour.prev":"上一步","tour.next":"下一步","tour.done":"完成"},nt={"common.ok":"OK","common.cancel":"Cancel","common.confirm":"Are you sure?","common.loading":"Loading…","table.empty":"No data","pagination.total":"{total} in total","form.validating":"Validating…","upload.hint":"Click or drag files here to upload","transfer.pending":"Available","transfer.selected":"Selected","tour.skip":"Skip","tour.prev":"Previous","tour.next":"Next","tour.done":"Done"},ht={"zh-CN":ot,"en-US":nt};let rt="zh-CN";function lt(t,e){const i=ht[rt]||{},s=ht["zh-CN"]||{},o=void 0!==i[t]?i[t]:void 0!==s[t]?s[t]:t;return e?o.replace(/\{(\w+)\}/g,(t,i)=>Object.prototype.hasOwnProperty.call(e,i)?String(e[i]):t):o}class at extends r{constructor(t={}){const e=h.getTheme(),i=!0===t.dot,s=D(e,t.status||t.color||(i?"error":"primary")),o="soft"===t.variant?"soft":"solid",n=Number(t.dotSize)||8,r=void 0!==t.text?String(t.text):void 0!==t.count?at.__countText(t):"0",l=i?n:t.height||20,a=i?n:t.width||Math.max(24,l);if(super({...t,fill:!0,stroke:!0,width:a,height:l,radius:i?n/2:e.radius.pill,style:{fillStyle:i||"solid"===o?s.solid:s.background,strokeStyle:i||"solid"===o?s.solid:s.border,lineWidth:e.control.lineWidth,...t.style||{}}}),this.dot=i,this.variant=o,i)return;const d=e.spacing.sm;this.textNode=V({left:d,top:0,width:Math.max(0,a-2*d),height:l,text:r,fillStyle:"solid"===o?s.onSolid:s.strong,fontFamily:e.font.family,fontSize:e.font.sizeSmall,fontWeight:e.font.weightSemibold,align:"center",verticalAlign:"middle"}),this.addChild(this.textNode,!1)}setText(t){return this.dot||(this.textNode.setText(t??"0"),this.revalidate()),this}isDot(){return this.dot}getText(){return this.dot||!this.textNode?"":this.textNode.getText()}static __countText(t){const e=Number(t.count)||0,i=Number(t.overflowCount)||99;return e>i?i+"+":String(e)}}function dt(t){return Math.max(32,F(t,12)+16)}class ct{handle=null;enterTimer=null;leaveTimer=null;running=!1;constructor(t,e,i={}){this.ice=t,this.target=e,this.options=i,this.manager=i.manager||z(t)}start(){return this.running||!this.target||"function"!=typeof this.target.on||(this.target.on("hoverchange",this.__onHoverChange,this),this.running=!0),this}destroy(){return this.running?("function"==typeof this.target.off&&this.target.off("hoverchange",this.__onHoverChange,this),this.__clearTimers(),this.hide(),this.running=!1,this):this}isOpen(){return!!this.handle&&this.handle.isOpen()}show(){if(this.isOpen())return this;const t=this.__createContent();return t?(this.handle=this.manager.open({anchor:this.target,content:t,placement:this.options.placement||"bottomLeft",offset:this.options.offset??8,closeOnOutsideClick:!1,closeOnEsc:!0,enterAnimation:this.options.enterAnimation||"none"}),this):this}hide(){return this.__clearTimers(),this.handle&&(this.handle.close(),this.handle=null),this}__onHoverChange(t){if(R(t)){this.__clearTimers();const t=Number(this.options.mouseEnterDelay??100);return t<=0?void this.show():void(this.enterTimer=setTimeout(()=>{this.enterTimer=null,this.show()},t))}if(this.enterTimer&&(clearTimeout(this.enterTimer),this.enterTimer=null),!this.isOpen())return;this.__clearTimers();const e=Number(this.options.mouseLeaveDelay??100);e<=0?this.hide():this.leaveTimer=setTimeout(()=>{this.leaveTimer=null,this.hide()},e)}__createContent(){if("function"==typeof this.options.content)return this.options.content();const t=h.getTheme(),e=String(this.options.title??""),i=dt(e),s=new O({width:i,height:26,radius:4,style:{fillStyle:t.colors.text,strokeStyle:t.colors.text,shadow:"md"}}),o=new H({left:8,top:0,height:26,verticalAlign:"middle",text:e,style:{fontSize:12,fillStyle:t.colors.surface}});return s.addChild(o,!1),s}__clearTimers(){this.enterTimer&&(clearTimeout(this.enterTimer),this.enterTimer=null),this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null)}}class ut{handle=null;enterTimer=null;leaveTimer=null;running=!1;constructor(t,e,i={}){this.ice=t,this.target=e,this.options=i,this.manager=i.manager||z(t)}start(){return this.running||!this.target||"function"!=typeof this.target.on||("hover"===this.options.trigger?this.target.on("hoverchange",this.__onHoverChange,this):this.target.on("click",this.__onClick,this),this.running=!0),this}destroy(){return this.running?("function"==typeof this.target.off&&(this.target.off("hoverchange",this.__onHoverChange,this),this.target.off("click",this.__onClick,this)),this.__clearTimers(),this.hide(),this.running=!1,this):this}isOpen(){return!!this.handle&&this.handle.isOpen()}show(){if(this.isOpen())return this;const t=this.__createContent();return t?(this.handle=this.manager.open({anchor:this.target,content:t,placement:this.options.placement||"bottomLeft",offset:this.options.offset??8,enterAnimation:this.options.enterAnimation||"scale",exitAnimation:this.options.exitAnimation??"fade"}),this.options.onOpenChange&&this.options.onOpenChange(!0),this):this}hide(){return this.__clearTimers(),this.handle&&(this.handle.close(),this.handle=null,this.options.onOpenChange&&this.options.onOpenChange(!1)),this}toggle(){return this.isOpen()?this.hide():this.show()}__createContent(){const t=h.getTheme(),{title:e,content:i}=this.options;if("function"==typeof i)return i();const s=String(i??""),o=e?22:0,n=new O({width:240,height:o+22+16,radius:6,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"md"}});return e&&n.addChild(new H({left:12,top:8,height:o,verticalAlign:"middle",text:e,style:{fontSize:13,fontWeight:"600",fillStyle:t.colors.text}}),!1),n.addChild(new H({left:12,top:8+o,width:216,height:22,verticalAlign:"middle",text:s,style:{fontSize:12,fillStyle:t.colors.textSecondary}}),!1),n}__onClick(){this.toggle()}__onHoverChange(t){if(R(t)){this.__clearTimers();const t=Number(this.options.mouseEnterDelay??100);return t<=0?void this.show():void(this.enterTimer=setTimeout(()=>{this.enterTimer=null,this.show()},t))}if(this.enterTimer&&(clearTimeout(this.enterTimer),this.enterTimer=null),!this.isOpen())return;this.__clearTimers();const e=Number(this.options.mouseLeaveDelay??100);e<=0?this.hide():this.leaveTimer=setTimeout(()=>{this.leaveTimer=null,this.hide()},e)}__clearTimers(){this.enterTimer&&(clearTimeout(this.enterTimer),this.enterTimer=null),this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null)}}class ft extends ut{constructor(t,e,i={}){super(t,e,{placement:"topRight",trigger:"click",...i}),this.confirmOptions=i}__createContent(){const t=h.getTheme(),e=this.confirmOptions.title||lt("common.confirm"),i=this.confirmOptions.description,s=i?18:0,o=32+s+4,n=new O({width:220,height:o+32+12,radius:6,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"md"}});n.addChild(new H({left:12,top:10,height:20,verticalAlign:"middle",text:e,style:{fontSize:13,fontWeight:"600",fillStyle:t.colors.text}}),!1),i&&n.addChild(new H({left:12,top:30,width:196,height:s,verticalAlign:"middle",text:i,style:{fontSize:12,fillStyle:t.colors.textSecondary}}),!1);const r=new Y({left:56,top:o,width:72,height:32,text:this.confirmOptions.cancelText||lt("common.cancel"),variant:"default",size:"small"}),l=new Y({left:136,top:o,width:72,height:32,text:this.confirmOptions.confirmText||lt("common.ok"),variant:"primary",size:"small",danger:!0===this.confirmOptions.danger});return r.on("click",()=>{this.hide(),this.confirmOptions.onCancel&&this.confirmOptions.onCancel()}),l.on("click",()=>{this.hide(),this.confirmOptions.onConfirm&&this.confirmOptions.onConfirm()}),n.addChild(r,!1),n.addChild(l,!1),n}}class gt{handle=null;mask=null;dialog=null;confirmButton=null;cancelButton=null;previousFocus=null;pendingReason=null;constructor(t,e={}){this.ice=t,this.options=e,this.manager=e.manager||z(t),this.focus=e.focusManager||B(t)}isOpen(){return!!this.handle&&this.handle.isOpen()}getMask(){return this.mask}getDialog(){return this.dialog}getConfirmButton(){return this.confirmButton}getCancelButton(){return this.cancelButton}open(){if(this.isOpen())return this;h.getTheme();const t=this.__visibleWorldRect(),e=new O({left:0,top:0,width:t.width,height:t.height,radius:0,fill:!0,stroke:!1,style:{fillStyle:"rgba(0, 0, 0, 0.5)"}});e.on("click",()=>{!1!==this.options.maskClosable&&this.close("mask")});const i=this.__createDialog();e.addChild(i,!1),i.setState({left:Math.max(0,(t.width-Number(i.state.width))/2),top:Math.max(0,(t.height-Number(i.state.height))/2)}),this.mask=e,this.dialog=i,this.previousFocus=this.focus.getFocused(),this.handle=this.manager.open({centered:!0,blocking:!0,content:e,closeOnOutsideClick:!1,closeOnEsc:!1!==this.options.closeOnEsc,enterAnimation:"scale",animation:this.options.animation,onClose:t=>{const e=this.pendingReason||("esc"===t?"esc":"outside"===t?"mask":"api");this.pendingReason=null,this.__handleClosed(e)}}),this.focus.setFocusScope(i);const s=this.confirmButton||this.cancelButton;return s&&this.focus.focus(s),this}close(t="api"){if(!this.handle||!this.handle.isOpen())return this;const e=this.handle;return this.pendingReason=t,this.handle=null,this.mask=null,this.dialog=null,this.confirmButton=null,this.cancelButton=null,e.close(),this}__handleClosed(t){this.focus.setFocusScope(null),this.previousFocus&&(this.focus.focus(this.previousFocus),this.previousFocus=null),this.options.onClose&&this.options.onClose(t)}__createDialog(){const t=h.getTheme(),e=this.options.width??420,i=this.options.title?24:0,s=!1===this.options.showFooter?0:48,o=this.options.height??20+i+(i?8:0)+48+s,n=new O({left:0,top:0,width:e,height:o,radius:t.radius.lg,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"lg"}});n.on("click",t=>{t&&"function"==typeof t.stopPropagation&&t.stopPropagation()});let r=20;if(this.options.title&&(n.addChild(new H({left:20,top:r,height:i,verticalAlign:"middle",text:this.options.title,style:{fontSize:16,fontWeight:"600",fillStyle:t.colors.text}}),!1),r+=i+8),"function"==typeof this.options.content){const t=this.options.content();t&&(t.setState({left:20,top:r}),n.addChild(t,!1))}else n.addChild(new H({left:20,top:r,width:e-40,height:48,verticalAlign:"middle",text:String(this.options.content??""),style:{fontSize:13,fillStyle:t.colors.textSecondary}}),!1);if(!1!==this.options.showFooter){const t=o-20-32,i=new Y({left:e-20-172,top:t,width:80,height:32,text:this.options.cancelText||lt("common.cancel"),variant:"default",size:"small"}),s=new Y({left:e-20-84,top:t,width:84,height:32,text:this.options.confirmText||lt("common.ok"),variant:"primary",size:"small"});i.on("click",()=>{this.options.onCancel&&this.options.onCancel(),this.close("cancel")}),s.on("click",()=>{this.options.onConfirm&&this.options.onConfirm(),!1!==this.options.closeOnConfirm&&this.close("confirm")}),n.addChild(i,!1),n.addChild(s,!1),this.cancelButton=i,this.confirmButton=s}return n}__visibleWorldRect(){const t=Number(this.ice&&this.ice.canvasWidth)||0,e=Number(this.ice&&this.ice.canvasHeight)||0,i=this.ice&&"function"==typeof this.ice.getRenderViewport?this.ice.getRenderViewport():null,s=i&&i.scale?i.scale:1;return{left:i?-(i.tx||0)/s:0,top:i?-(i.ty||0)/s:0,width:t/s,height:e/s}}}class mt extends W{prevButton=null;nextButton=null;pageButtons=new Map;sizeChanger=null;constructor(t={}){super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:t.width??420,height:8+("small"===t.size?28:32)}),this.total=Math.max(0,Number(t.total)||0),this.pageSize=Math.max(1,Number(t.pageSize)||10),this.current=Math.min(Math.max(1,Number(t.current)||1),this.getPageCount()||1),this.maxPageButtons=Math.max(5,Number(t.maxPageButtons)||7),this.showTotal=!0===t.showTotal,this.showSizeChanger=!0===t.showSizeChanger,this.pageSizeOptions=t.pageSizeOptions&&t.pageSizeOptions.length?t.pageSizeOptions.slice():[10,20,50,100],this.size=t.size||"default",this.onChange="function"==typeof t.onChange?t.onChange:null,this.__render()}getTotal(){return this.total}getPageCount(){return Math.max(1,Math.ceil(this.total/this.pageSize))}getCurrent(){return this.current}getPageSize(){return this.pageSize}getPrevButton(){return this.prevButton}getNextButton(){return this.nextButton}getPageButton(t){return this.pageButtons.get(t)||null}getSizeChanger(){return this.sizeChanger}setTotal(t){return this.total=Math.max(0,Number(t)||0),this.current=Math.min(this.current,this.getPageCount()),this.__render(),this}setCurrent(t,e={}){const i=Math.min(Math.max(1,Math.floor(Number(t)||1)),this.getPageCount());return i===this.current||(this.current=i,this.__render(),!e.silent&&this.onChange&&this.onChange(this.current,this.pageSize)),this}setPageSize(t,e={}){const i=Math.max(1,Math.floor(Number(t)||1));return i===this.pageSize||(this.pageSize=i,this.current=Math.min(this.current,this.getPageCount()),this.__render(),!e.silent&&this.onChange&&this.onChange(this.current,this.pageSize)),this}__render(){this.removeChildren([...this.childNodes]),this.pageButtons.clear();const t=h.getTheme(),e="small"===this.size?28:32,i="small"===this.size?6:8;let s=0;if(this.showTotal){const i=new H({left:s,top:0,height:e,verticalAlign:"middle",text:`共 ${this.total} 条`,style:{fontSize:12,fillStyle:t.colors.textSecondary}});this.addChild(i,!1),s+=76}const o=(t,o)=>{const n=o.width??e,h=new Y({left:s,top:0,width:n,height:e,text:t,size:"small"===this.size?"small":"middle",variant:o.primary?"primary":"default"});return!1===o.enabled&&h.setEnabled(!1),o.onClick&&h.on("click",o.onClick),this.addChild(h,!1),s+=n+i,h},n=this.getPageCount();this.prevButton=o("‹",{enabled:this.current>1,onClick:()=>this.setCurrent(this.current-1)}),this.__pageWindow(n).forEach(n=>{if(-1===n){const o=new H({left:s,top:0,width:24,height:e,verticalAlign:"middle",text:"...",style:{fontSize:12,fillStyle:t.colors.textSecondary}});return this.addChild(o,!1),void(s+=24+i)}const h=o(String(n),{primary:n===this.current,onClick:()=>this.setCurrent(n)});this.pageButtons.set(n,h)}),this.nextButton=o("›",{enabled:this.current<n,onClick:()=>this.setCurrent(this.current+1)}),this.showSizeChanger?this.sizeChanger=o(this.pageSize+" 条/页",{width:88,onClick:()=>{const t=this.pageSizeOptions.indexOf(this.pageSize),e=this.pageSizeOptions[(t+1)%this.pageSizeOptions.length];this.setPageSize(e)}}):this.sizeChanger=null,this.setState({width:Math.max(Number(this.state.width)||0,s-i),height:e+8}),this.revalidate()}__pageWindow(t){const e=this.maxPageButtons;if(t<=e)return Array.from({length:t},(t,e)=>e+1);const i=this.current,s=[1];let o=Math.max(2,i-1),n=Math.min(t-1,i+1);const h=e-4;for(;n-o+1<h;)if(o>2)o-=1;else{if(!(n<t-1))break;n+=1}o>2&&s.push(-1);for(let t=o;t<=n;t++)s.push(t);return n<t-1&&s.push(-1),s.push(t),s}}class pt{handle=null;panel=null;itemNodes=[];activeIndex=0;running=!1;constructor(t,e,i){this.ice=t,this.target=e,this.options=i,this.manager=i.manager||z(t),this.items=(i.items||[]).slice(),this.selectedKey=i.selectedKey??null}start(){return this.running||!this.target||"function"!=typeof this.target.on||(this.target.on("click",this.__onTargetClick,this),this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.running=!0),this}destroy(){return this.running?("function"==typeof this.target.off&&this.target.off("click",this.__onTargetClick,this),this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.off&&this.ice.evtBus.off("keydown",this.__onKeyDown,this),this.close(),this.running=!1,this):this}isOpen(){return!!this.handle&&this.handle.isOpen()}getSelectedKey(){return this.selectedKey}setSelectedKey(t){return this.selectedKey=t,this.isOpen()&&this.__buildMenu(),this}getActiveIndex(){return this.activeIndex}getItemNode(t){return this.itemNodes[t]||null}setItems(t){return this.items=(t||[]).slice(),this.isOpen()&&this.__buildMenu(),this}open(){return this.isOpen()||(this.panel=this.__createPanel(),this.activeIndex=this.__initialActiveIndex(),this.__buildMenu(),this.handle=this.manager.open({anchor:this.target,content:this.panel,placement:this.options.placement||"bottomLeft",offset:this.options.offset??6,enterAnimation:"scale",exitAnimation:"fade",keyboardCaptured:!0})),this}close(){return this.handle&&(this.handle.close(),this.handle=null),this.panel=null,this.itemNodes=[],this}toggle(){return this.isOpen()?this.close():this.open()}__onKeyDown(t){if(!this.isOpen())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if("ArrowDown"!==i&&"ArrowUp"!==i){if("Enter"===i||" "===i){const t=this.items[this.activeIndex];t&&!t.disabled&&this.__select(this.activeIndex)}}else this.__moveActive("ArrowDown"===i?1:-1)}__moveActive(t){const e=this.items.length;if(!e)return;let i=this.activeIndex;for(let s=0;s<e;s++)if(i=(i+t+e)%e,!this.items[i].disabled)return this.activeIndex=i,void this.__buildMenu()}__initialActiveIndex(){const t=this.items.findIndex(t=>t.key===this.selectedKey&&!t.disabled);if(-1!==t)return t;const e=this.items.findIndex(t=>!t.disabled);return-1===e?0:e}__onTargetClick(){this.toggle()}__createPanel(){const t=h.getTheme(),e=this.items.reduce((t,e)=>Math.max(t,F(String(e.label??""),14)+56),0),i=this.options.width??Math.min(360,Math.max(180,Math.round(e))),s=this.options.itemHeight??34;return new O({width:i,height:this.items.length*s+8,radius:t.radius.md,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"md"}})}__buildMenu(){const t=this.panel;if(!t)return;const e=h.getTheme();t.removeChildren([...t.childNodes]),this.itemNodes=[];const i=Number(t.state.width)||180,s=this.options.itemHeight??34;this.items.forEach((o,n)=>{const h=o.key===this.selectedKey,l=n===this.activeIndex,a=new r({left:4,top:4+n*s,width:i-8,height:s,radius:e.radius.sm,fill:!0,stroke:!1,style:{fillStyle:h?e.colors.primaryBg:l?e.colors.background:"rgba(0,0,0,0)"}});a.setState({interactive:!o.disabled});const d=o.disabled?e.colors.textDisabled:o.danger?e.colors.error:h?e.colors.primary:e.colors.text;a.addChild(new H({interactive:!1,left:12,top:0,height:s,verticalAlign:"middle",text:o.label,style:{fontSize:13,fillStyle:d}}),!1),h&&a.addChild(new H({interactive:!1,left:i-34,top:0,width:18,height:s,verticalAlign:"middle",text:"✓",style:{fontSize:12,fillStyle:e.colors.primary}}),!1),o.disabled||a.on("click",()=>this.__select(n)),t.addChild(a,!1),this.itemNodes.push(a)}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}__select(t){const e=this.items[t];e&&!e.disabled&&(this.selectedKey=e.key,this.close(),this.options.onSelect&&this.options.onSelect(e,t))}}class yt{handle=null;mask=null;panel=null;closeButton=null;previousFocus=null;pendingReason=null;constructor(t,e={}){this.ice=t,this.options=e,this.manager=e.manager||z(t),this.focus=e.focusManager||B(t)}isOpen(){return!!this.handle&&this.handle.isOpen()}getMask(){return this.mask}getPanel(){return this.panel}getCloseButton(){return this.closeButton}open(){if(this.isOpen())return this;const t=this.__visibleWorldRect(),e=this.options.placement||"right",i=new O({left:0,top:0,width:t.width,height:t.height,radius:0,fill:!0,stroke:!1,style:{fillStyle:"rgba(0, 0, 0, 0.5)"}});i.on("click",()=>{!1!==this.options.maskClosable&&this.close("mask")});const s=this.__createPanel(t,e);return i.addChild(s,!1),this.mask=i,this.panel=s,this.previousFocus=this.focus.getFocused(),this.handle=this.manager.open({centered:!0,blocking:!0,content:i,closeOnOutsideClick:!1,closeOnEsc:!1!==this.options.closeOnEsc,enterAnimation:"none",animation:this.options.animation,onClose:t=>{const e=this.pendingReason||("esc"===t?"esc":"outside"===t?"mask":"api");this.pendingReason=null,this.__handleClosed(e)}}),s.setState({left:s.state.left,top:s.state.top}),this.options.animation&&0===this.options.animation.duration||S(s,{from:e,distance:Number("left"===e||"right"===e?s.state.width:s.state.height),duration:220,...this.options.animation||{}}),this.focus.setFocusScope(s),this.closeButton&&this.focus.focus(this.closeButton),this}close(t="api"){if(!this.handle||!this.handle.isOpen())return this;const e=this.handle;return this.pendingReason=t,this.handle=null,this.mask=null,this.panel=null,this.closeButton=null,e.close(),this}__handleClosed(t){this.focus.setFocusScope(null),this.previousFocus&&(this.focus.focus(this.previousFocus),this.previousFocus=null),this.options.onClose&&this.options.onClose(t)}__createPanel(t,e){const i=h.getTheme(),s="left"===e||"right"===e,o=s?this.options.width??360:t.width,n=s?t.height:this.options.height??240,r="right"===e?t.width-o:0,l="bottom"===e?t.height-n:0,a=new O({left:r,top:l,width:o,height:n,radius:0,style:{fillStyle:i.colors.surface,strokeStyle:i.colors.border,shadow:"lg"}});a.on("click",t=>{t&&"function"==typeof t.stopPropagation&&t.stopPropagation()});const d=this.options.title?48:16;if(this.options.title&&a.addChild(new H({left:20,top:0,height:d,verticalAlign:"middle",text:this.options.title,style:{fontSize:15,fontWeight:"600",fillStyle:i.colors.text}}),!1),!1!==this.options.closable){const t=new Y({left:o-48,top:12,width:32,height:28,text:"✕",variant:"text",size:"small"});t.on("click",()=>this.close("close")),a.addChild(t,!1),this.closeButton=t}else this.closeButton=null;if("function"==typeof this.options.content){const t=this.options.content();t&&(t.setState({left:20,top:d}),a.addChild(t,!1))}else a.addChild(new H({left:20,top:d,width:Math.max(0,o-40),height:24,verticalAlign:"middle",text:String(this.options.content??""),style:{fontSize:13,fillStyle:i.colors.textSecondary}}),!1);return a}__visibleWorldRect(){const t=Number(this.ice&&this.ice.canvasWidth)||0,e=Number(this.ice&&this.ice.canvasHeight)||0,i=this.ice&&"function"==typeof this.ice.getRenderViewport?this.ice.getRenderViewport():null,s=i&&i.scale?i.scale:1;return{left:i?-(i.tx||0)/s:0,top:i?-(i.ty||0)/s:0,width:t/s,height:e/s}}}class _t extends W{contentNode=null;scrollX=0;scrollY=0;contentWidth=0;contentHeight=0;explicitContentSize=!1;__bound=!1;constructor(t={}){const e=h.getTheme(),i=t.width??240,s=t.height??160;super({...t,width:i,height:s,clipChildren:!0,fill:void 0===t.fill||t.fill,stroke:void 0===t.stroke||t.stroke,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth,...t.style||{}}}),this.wheelStep=t.wheelStep??1,this.scrollbarMode=!0===t.scrollbar?"always":!1===t.scrollbar?"never":"auto",this.scrollX=0,this.scrollY=0,this.contentBox=new r({left:0,top:0,width:0,height:0,fill:!1,stroke:!1}),this.addChild(this.contentBox,!1),this.scrollbarTrack=new r({left:i-6-4,top:4,width:6,height:Math.max(0,s-8),radius:3,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:e.colors.disabled}}),this.scrollbarThumb=new r({left:0,top:0,width:6,height:0,radius:3,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:e.colors.borderSecondary}}),this.scrollbarTrack.addChild(this.scrollbarThumb,!1),this.addChild(this.scrollbarTrack,!1),this.setScroll(this.scrollX,this.scrollY)}setContent(t){return this.contentNode&&this.contentNode!==t&&this.contentBox.removeChild(this.contentNode),this.contentNode=t,t&&(this.contentBox.addChild(t,!1),this.__raiseAboveSelf(t),this.explicitContentSize||this.__syncContentSizeFromNode()),this.__raiseAboveSelf(this.contentBox),this.scrollbarTrack.state.zIndex=(Number(this.state.zIndex)||0)+2,this.setScroll(this.scrollX,this.scrollY),this.revalidate(),this}getContent(){return this.contentNode}setContentSize(t,e){return this.explicitContentSize=!0,this.contentWidth=Math.max(0,Number(t)||0),this.contentHeight=Math.max(0,Number(e)||0),this.contentBox.setState({width:this.contentWidth,height:this.contentHeight}),this.setScroll(this.scrollX,this.scrollY),this}getContentSize(){return[this.contentWidth,this.contentHeight]}getViewportSize(){return[Number(this.state.width)||0,Number(this.state.height)||0]}getScrollRange(){const[t,e]=this.getViewportSize();return[Math.max(0,this.contentWidth-t),Math.max(0,this.contentHeight-e)]}getScroll(){return[this.scrollX,this.scrollY]}setScroll(t,e){const[i,s]=this.getScrollRange(),o=Math.min(Math.max(Number(t)||0,0),i),n=Math.min(Math.max(Number(e)||0,0),s),h=o!==this.scrollX||n!==this.scrollY;return this.scrollX=o,this.scrollY=n,this.contentBox.setState({left:0===o?0:-o,top:0===n?0:-n}),this.__syncScrollbar(),h&&this.ice&&(this.ice.dirty=!0),h&&this.trigger("scroll",null,{x:o,y:n}),this}scrollBy(t,e){return this.setScroll(this.scrollX+(Number(t)||0),this.scrollY+(Number(e)||0))}isScrollbarVisible(){return"never"!==this.scrollbarMode&&("always"===this.scrollbarMode||this.contentHeight>this.getViewportSize()[1])}getScrollbarThumb(){return this.scrollbarThumb}afterAddHandler(){super.afterAddHandler(),this.__bindGlobalEvents()}__bindGlobalEvents(){!this.__bound&&this.ice&&this.ice.evtBus&&(this.__bound=!0,this.ice.evtBus.on("wheel",this.__onWheel,this))}__onWheel(t){if(!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const e=t.originalEvent||t,i=Number(e&&e.deltaY)||0;if(!i)return;const[s,o]=this.getScrollRange();if(s<=0&&o<=0)return;const[n,h]=this.ice.screenToWorld(t.offsetX,t.offsetY),r=this.__paneWorldBox();if(n<r.left||n>r.left+r.width||h<r.top||h>r.top+r.height)return;const l=Number(e&&e.deltaX)||0;this.scrollBy(l*this.wheelStep,i*this.wheelStep)}__paneWorldBox(){let t=0,e=0,i=this;for(;i&&i.state;)t+=Number(i.state.left)||0,e+=Number(i.state.top)||0,i=i.parentNode;return{left:t,top:e,width:Number(this.state.width)||0,height:Number(this.state.height)||0}}__syncContentSizeFromNode(){const t=this.contentNode,e=Number(t&&t.state&&t.state.width)||0,i=Number(t&&t.state&&t.state.height)||0;this.contentWidth=e,this.contentHeight=i,this.contentBox.setState({width:e,height:i})}__raiseAboveSelf(t){if(!t)return;const e=(Number(this.state.zIndex)||0)+1,i=t=>{t&&t.state&&(t.state.zIndex=e,(t.childNodes||[]).forEach(i))};i(t)}__syncScrollbar(){const[t,e]=this.getViewportSize(),i=Math.max(0,e-8),s=this.isScrollbarVisible()&&this.contentHeight>e&&i>0;if(this.scrollbarTrack.setState({left:t-6-4,top:4,width:6,height:i,display:s}),!s)return void this.scrollbarThumb.setState({display:!1});const o=e/this.contentHeight,n=Math.max(12,Math.round(i*o)),[h,r]=this.getScrollRange(),l=r>0?this.scrollY/r:0;this.scrollbarThumb.setState({display:!0,left:0,top:Math.round((i-n)*l),width:6,height:n})}}class wt{listeners=new Set;constructor(t={}){this.mode=t.mode||"single",this.selected=this.__normalize(t.selected||[])}getMode(){return this.mode}setMode(t){return t===this.mode||(this.mode=t,this.selected=this.__normalize(this.selected),this.__notify()),this}getSelectedKeys(){return this.selected.slice()}isSelected(t){return-1!==this.selected.indexOf(t)}select(t){return"single"===this.mode?(1===this.selected.length&&this.selected[0]===t||(this.selected=[t],this.__notify()),this):(-1===this.selected.indexOf(t)&&(this.selected=this.selected.concat([t]),this.__notify()),this)}toggle(t){if("single"===this.mode)return this.select(t);const e=this.selected.indexOf(t);return this.selected=-1===e?this.selected.concat([t]):this.selected.filter(e=>e!==t),this.__notify(),this}setSelected(t){const e=this.__normalize(t||[]);return e.length===this.selected.length&&e.every((t,e)=>t===this.selected[e])||(this.selected=e,this.__notify()),this}clear(){return this.selected.length?(this.selected=[],this.__notify(),this):this}addChangeListener(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}__normalize(t){const e=[];return t.forEach(t=>{const i=String(t);-1===e.indexOf(i)&&e.push(i)}),"single"===this.mode?e.slice(-1):e}__notify(){this.listeners.forEach(t=>t(this))}}class bt extends r{pane=null;draggable=!1;dragState=null;onDrop=null;rows=[];rowNodes=new Map;activeKey=null;running=!1;constructor(t){const e=h.getTheme(),i=t.width??240,s=t.height??200;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:i,height:s,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.nodes=t.nodes||[],this.itemHeight=t.itemHeight??32,this.indent=t.indent??16,this.onSelect="function"==typeof t.onSelect?t.onSelect:null,this.onExpand="function"==typeof t.onExpand?t.onExpand:null,this.draggable=!0===t.draggable,this.onDrop="function"==typeof t.onDrop?t.onDrop:null,this.model=new wt({mode:t.mode||"single",selected:t.value||[]}),this.model.addChangeListener(()=>this.__syncRows()),this.expanded=t.defaultExpandAll?this.__collectExpandableKeys(this.nodes):(t.expandedKeys||[]).slice(),this.content=new r({left:0,top:0,width:i-8,height:s}),this.focusable=!0,this.__render()}afterAddHandler(){super.afterAddHandler(),!this.running&&this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this),this.ice.evtBus.on("mousemove",this.__onGlobalMouseMove,this),this.ice.evtBus.on("mouseup",this.__onGlobalMouseUp,this),this.running=!0)}getExpandedKeys(){return this.expanded.slice()}setExpandedKeys(t){return this.expanded=(t||[]).slice(),this.__render(),this}expandAll(){return this.expanded=this.__collectExpandableKeys(this.nodes),this.__render(),this}collapseAll(){return this.expanded=[],this.__render(),this}getSelectedKeys(){return this.model.getSelectedKeys()}setSelectedKeys(t){return this.model.setSelected(t),this}getActiveKey(){return this.activeKey}getRowNode(t){return this.rowNodes.get(t)||null}getVisibleNodes(){return this.rows.map(t=>t.node)}getRowDepth(t){const e=this.rows.find(e=>e.node.key===t);return e?e.depth:-1}getScrollPane(){return this.pane}isDraggable(){return this.draggable}isDragging(){return!!this.dragState}getDropTarget(){return this.dragState?this.dragState.target:null}moveNode(t,e,i){const s=et(this.nodes,t,e,i);return!!s.moved&&(this.nodes=s.nodes,"inside"===i&&-1===this.expanded.indexOf(e)&&(this.expanded=this.expanded.concat([e])),this.__render(),this.trigger("nodedrop",null,{key:t,targetKey:e,position:i,nodes:this.nodes}),this.onDrop&&this.onDrop({key:t,targetKey:e,position:i,nodes:this.nodes}),!0)}__rowIndexAt(t){const e=t-1+(this.pane?this.pane.getScroll()[1]:0);return Math.min(Math.max(Math.floor(e/this.itemHeight),0),Math.max(0,this.rows.length-1))}__onGlobalMouseDown(t){if(!this.draggable||!t||"number"!=typeof t.offsetX||!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=this.getMinBoundingBox(!0);if(e<s.tl[0]||e>s.br[0]||i<s.tl[1]||i>s.br[1])return;const o=this.rows[this.__rowIndexAt(i-s.tl[1])];if(!o||o.node.disabled)return;const n=h.getTheme(),l=new r({left:0,top:0,width:Number(this.content.state.width)||0,height:2,fill:!0,stroke:!1,display:!1,interactive:!1,style:{fillStyle:n.colors.primary}}),a=new r({left:0,top:0,width:Number(this.content.state.width)||0,height:this.itemHeight,radius:3,fill:!0,stroke:!1,display:!1,interactive:!1,style:{fillStyle:"rgba(13,110,253,0.14)"}});this.content.addChild(a,!1),this.content.addChild(l,!1),this.dragState={key:o.node.key,target:null,indicator:l,highlight:a},this.__updateDrag(i-s.tl[1])}__onGlobalMouseMove(t){if(!this.dragState||!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[,e]=this.ice.screenToWorld(t.offsetX,t.offsetY),i=this.getMinBoundingBox(!0);this.__updateDrag(e-i.tl[1])}__onGlobalMouseUp(){if(!this.dragState)return;const t=this.dragState;this.dragState=null,t.indicator.setState({display:!1}),t.highlight.setState({display:!1});const e=t.target;e&&this.rows[e.index]&&this.moveNode(t.key,this.rows[e.index].node.key,e.position)}__updateDrag(t){if(!this.dragState)return;const e=this.pane?this.pane.getScroll()[1]:0,i=this.__rowIndexAt(t),s=J({pointerY:t-1+e,itemHeight:this.itemHeight,itemCount:this.rows.length});if(this.dragState.target=s&&this.rows[i]?{index:s.index,position:s.position}:null,!s)return this.dragState.indicator.setState({display:!1}),void this.dragState.highlight.setState({display:!1});const o=Number(this.content.state.width)||0;if("inside"===s.position)this.dragState.highlight.setState({display:!0,left:0,top:s.index*this.itemHeight,width:o}),this.dragState.indicator.setState({display:!1});else{const t=s.index*this.itemHeight+("after"===s.position?this.itemHeight-2:0);this.dragState.indicator.setState({display:!0,left:0,top:t,width:o}),this.dragState.highlight.setState({display:!1})}}__onKeyDown(t){if(!this.isFocused()||!this.rows.length)return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code),s=this.__activeIndex();if("ArrowDown"===i||"ArrowUp"===i){if(null===this.activeKey){const t=("ArrowDown"===i?this.rows.find(t=>!t.node.disabled):void 0)||this.rows[this.rows.length-1];return void(t&&!t.node.disabled&&(this.activeKey=t.node.key,this.__syncRows()))}const t="ArrowDown"===i?1:-1;let e=s;for(let i=0;i<this.rows.length;i++)if(e=(e+t+this.rows.length)%this.rows.length,!this.rows[e].node.disabled)return this.activeKey=this.rows[e].node.key,void this.__syncRows();return}const o=this.rows[s];if(o)if("ArrowRight"!==i)"ArrowLeft"!==i?"Enter"!==i&&" "!==i||o.node.disabled||this.__pick(o.node):o.hasChildren&&-1!==this.expanded.indexOf(o.node.key)?this.__toggleExpand(o.node.key):o.parentKey&&(this.activeKey=o.parentKey,this.__syncRows());else if(o.hasChildren&&-1===this.expanded.indexOf(o.node.key))this.__toggleExpand(o.node.key);else if(o.hasChildren){const t=this.rows.slice(s+1).find(t=>t.parentKey===o.node.key);t&&(this.activeKey=t.node.key,this.__syncRows())}}__activeIndex(){if(!this.activeKey)return this.rows.length?0:-1;const t=this.rows.findIndex(t=>t.node.key===this.activeKey);return-1===t?0:t}__toggleExpand(t){const e=this.expanded.indexOf(t);this.expanded=-1===e?this.expanded.concat([t]):this.expanded.filter(e=>e!==t),this.__render(),this.onExpand&&this.onExpand(this.getExpandedKeys())}__pick(t){if(t.disabled)return;const e=this.model.getSelectedKeys();this.model.toggle(t.key),"single"===this.model.getMode()&&e[0]===t.key||this.onSelect&&this.onSelect(this.model.getSelectedKeys(),t)}__flatten(){const t=[],e=(i,s,o)=>{i.forEach(i=>{const n=!(!i.children||!i.children.length);t.push({node:i,depth:s,parentKey:o,hasChildren:n}),n&&-1!==this.expanded.indexOf(i.key)&&e(i.children,s+1,i.key)})};return e(this.nodes,0,null),t}__collectExpandableKeys(t){const e=[],i=t=>{t.forEach(t=>{t.children&&t.children.length&&(e.push(t.key),i(t.children))})};return i(t),e}__render(){this.removeChildren([...this.childNodes]),this.pane=null;const t=Number(this.state.width)||240,e=Number(this.state.height)||200;this.rows=this.__flatten();const i=Math.max(this.itemHeight,this.rows.length*this.itemHeight),s=i>e,o=t-2;if(this.content.setState({width:o-(s?10:0),height:i}),this.__syncRows(),s){const t=new _t({left:1,top:1,width:o,height:e-2,scrollbar:!0,style:{fillStyle:"rgba(0,0,0,0)",strokeStyle:"rgba(0,0,0,0)"}});t.setContent(this.content),t.setContentSize(Number(this.content.state.width),i),this.addChild(t,!1),this.pane=t}else this.addChild(this.content,!1);this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}__syncRows(){const t=h.getTheme(),e=Number(this.content.state.width)||220;this.content.removeChildren([...this.content.childNodes]),this.rowNodes.clear(),this.rows.forEach((i,s)=>{const o=this.model.isSelected(i.node.key),n=i.node.key===this.activeKey,h=new r({left:4,top:s*this.itemHeight,width:e-8,height:this.itemHeight,radius:t.radius.sm,fill:!0,stroke:!1,interactive:!i.node.disabled,style:{fillStyle:o?t.colors.primaryBg:n?t.colors.background:"rgba(0,0,0,0)"}}),l=6+i.depth*this.indent;if(i.hasChildren){const e=new H({interactive:!1,left:l,top:0,width:14,height:this.itemHeight,verticalAlign:"middle",text:-1!==this.expanded.indexOf(i.node.key)?"▾":"▸",style:{fontSize:11,fillStyle:t.colors.textSecondary}});h.addChild(e,!1)}h.addChild(new H({interactive:!1,left:l+(i.hasChildren?16:14),top:0,height:this.itemHeight,verticalAlign:"middle",text:i.node.label,style:{fontSize:13,fillStyle:i.node.disabled?t.colors.textDisabled:o?t.colors.primary:t.colors.text}}),!1),i.node.disabled||(h.on("click",()=>this.__pick(i.node)),h.on("expand-click",()=>this.__toggleExpand(i.node.key))),h.on("hoverchange",e=>{const i=R(e);h.setState({style:{...h.state.style,fillStyle:o?t.colors.primaryBg:i||n?t.colors.background:"rgba(0,0,0,0)"}})},this);const a=new r({left:l-2,top:0,width:i.hasChildren?18:0,height:this.itemHeight,fill:!1,stroke:!1,interactive:i.hasChildren&&!i.node.disabled});i.hasChildren&&!i.node.disabled&&a.on("click",()=>this.__toggleExpand(i.node.key)),h.addChild(a,!1),this.content.addChild(h,!1),this.rowNodes.set(i.node.key,h)}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}}class vt extends r{actionButton=null;descriptionText="";constructor(t){const e=h.getTheme(),i=t.width??240,s=t.height??140;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:i,height:s});const o=t.icon??"◌",n=!!t.actionText;if(this.descriptionText=String(t.description??""),this.addChild(new H({interactive:!1,left:0,top:Math.max(8,s/2-46),width:i,height:32,align:"center",verticalAlign:"middle",text:o,style:{fontSize:26,fillStyle:e.colors.textDisabled}}),!1),this.addChild(new H({interactive:!1,left:0,top:Math.max(44,s/2-8),width:i,height:20,align:"center",verticalAlign:"middle",text:t.description??"",style:{fontSize:13,fillStyle:e.colors.textSecondary}}),!1),n){const e=new Y({left:(i-96)/2,top:Math.max(72,s/2+20),width:96,height:30,text:t.actionText,size:"small",variant:"default"});e.on("click",()=>{t.onAction&&t.onAction()}),this.addChild(e,!1),this.actionButton=e}}getActionButton(){return this.actionButton}getDescription(){return this.descriptionText}}function xt(t,e){const i=String(t??""),s=Math.max(0,Number(e.maxWidth)||0),o=Math.max(1,Number(e.fontSize)||1),n=Math.max(1,Math.floor(Number(e.maxLines)||1));if(s<=0||""===i)return[i];if(F(i,o)<=s)return[i];const h=Array.from(i),r=[];let l="";for(let t=0;t<h.length;t+=1){const e=h[t],i=l+e;if(F(i,o)>s&&""!==l){if(r.push(l),l=e,r.length===n){const e=l+h.slice(t+1).join("");return r[n-1]=St(r[n-1]+e,s,o),r.slice(0,n)}}else l=i}return""!==l&&r.push(l),r.slice(0,n)}function St(t,e,i){const s=Array.from(t);let o="";for(const t of s){if(F(o+t+"…",i)>e)break;o+=t}return""===o?"…":o+"…"}const Ct=[28,24,20,17,15];class Nt extends e.ICEPath{constructor(t={}){super({fill:!1,stroke:!0,...t})}createPathObject(){const t=Number(this.state.width)||24,e=Number(this.state.style.lineWidth)||2,i=Math.max(1,t/2-e/2),s=new Path2D;return"function"==typeof s.arc&&s.arc(0,0,i,0,1.5*Math.PI),this.path2D=s,this.path2D}}class Mt{element=null;doc=null;constructor(t){this.options=t,this.doc=void 0===t.doc?globalThis.document:t.doc,this.value=void 0===t.value?"":String(t.value),this.maxLength=Math.max(0,Number(t.maxLength)||0),this.multiline=!0===t.multiline}isMounted(){return!!this.element}getElement(){return this.element}getValue(){return this.value}mount(){if(this.element||!this.doc||!this.doc.body||"function"!=typeof this.doc.createElement)return this;const t=this.options.box,e=this.doc.createElement(this.multiline?"textarea":"input");return e.style.position="absolute",e.style.left=t.left+"px",e.style.top=t.top+"px",e.style.width=t.width+"px",e.style.height=t.height+"px",this.options.font&&(e.style.font=this.options.font),e.style.color="transparent",e.style.caretColor=this.options.caretColor||"#212529",e.style.background="transparent",e.style.border="none",e.style.outline="none",e.style.margin="0",e.style.padding="0",e.style.boxSizing="border-box",e.style.zIndex="9999",e.value=this.value,e.setAttribute&&(e.setAttribute("autocomplete","off"),e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false")),e.addEventListener("input",this.__handleInput),e.addEventListener("compositionend",this.__handleInput),e.addEventListener("keydown",this.__handleKeyDown),e.addEventListener("blur",this.__handleBlur),this.doc.body.appendChild(e),this.element=e,"function"==typeof e.focus&&e.focus(),this.__moveCaretToEnd(),this}unmount(){const t=this.element;t&&(t.removeEventListener("input",this.__handleInput),t.removeEventListener("compositionend",this.__handleInput),t.removeEventListener("keydown",this.__handleKeyDown),t.removeEventListener("blur",this.__handleBlur),t.parentNode&&"function"==typeof t.parentNode.removeChild&&t.parentNode.removeChild(t),this.element=null)}setValue(t){return this.value=this.__normalize(t),this.element&&(this.element.value=this.value,this.__moveCaretToEnd()),this}focus(){return this.element&&"function"==typeof this.element.focus&&this.element.focus(),this}__normalize(t){const e=null==t?"":String(t);return this.maxLength>0?e.slice(0,this.maxLength):e}__moveCaretToEnd(){if(!this.element||"function"!=typeof this.element.setSelectionRange)return;const t=String(this.element.value||"").length;this.element.setSelectionRange(t,t)}__handleInput=()=>{if(!this.element)return;const t=this.__normalize(this.element.value);this.element.value!==t&&(this.element.value=t,this.__moveCaretToEnd()),this.value=t,this.options.onInput&&this.options.onInput(t)};__handleKeyDown=t=>{const e=t&&t.key,i=!(!t||!t.isComposing&&229!==t.keyCode);"Enter"!==e||this.multiline?"Escape"===e&&this.options.onEscape&&this.options.onEscape():!i&&this.options.onEnter&&this.options.onEnter()};__handleBlur=()=>{this.options.onBlur&&this.options.onBlur()}}class kt extends r{__bound=!1;__pointerDown=!1;allowNewline=!1;nativeInput=null;constructor(t={}){const e=h.getTheme(),i=t.width||200,s=t.height||e.control.height,o=void 0===t.value?"":String(t.value),n=t.placeholder||"",r=Number.isFinite(t.maxLength)?t.maxLength:0;super({...t,fill:!0,stroke:!0,width:i,height:s,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth,...t.style||{}}}),this.value=o,this.placeholder=n,this.maxLength=Math.max(0,r),this.textNode=V({left:e.spacing.sm,top:0,width:Math.max(0,i-2*e.spacing.sm),height:s,text:o||n,fillStyle:o?e.colors.text:e.colors.textTertiary,fontFamily:e.font.family,fontSize:e.font.size,fontWeight:e.font.weightNormal,align:"left",verticalAlign:"middle"}),this.addChild(this.textNode,!1),this.focusable=!1!==t.focusable,void 0!==t.ariaLabel?this.setAriaLabel(String(t.ariaLabel)):n&&this.setAriaLabel(n),this.focusRingMode="always"}getValue(){return this.value}getFormValue(){return this.value}setFormValue(t){this.setValue(t)}setValue(t){return this.value=this.__normalize(String(t??"")),this.nativeInput&&this.nativeInput.setValue(this.value),this.__sync(),this.__emitChange(),this}getPlaceholder(){return this.placeholder}setPlaceholder(t){return this.placeholder=String(t??""),this.__sync(),this}focus(){return this.setFocused(!0),this}blur(){return this.setFocused(!1),this}activate(){}afterAddHandler(){super.afterAddHandler(),this.__bindGlobalEvents(),this.once("AFTER_REMOVE",()=>this.__unmountNativeInput(),this)}__bindGlobalEvents(){!this.__bound&&this.ice&&this.ice.evtBus&&(this.__bound=!0,this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this),this.ice.evtBus.on("mouseup",this.__onGlobalMouseUp,this),this.ice.evtBus.on("keydown",this.__onGlobalKeyDown,this))}__onGlobalMouseDown(t){this.enabled&&(this.__pointerDown=!0,this.setFocused(this.__isPointInside(t)))}__onGlobalMouseUp(){this.__pointerDown=!1,this.focused&&!this.nativeInput&&("function"==typeof setTimeout?setTimeout(()=>{this.focused&&!this.nativeInput&&this.__mountNativeInput()},0):this.__mountNativeInput())}__onGlobalKeyDown(t){if(!this.enabled||!this.focused)return;if(this.nativeInput)return;const e=t&&t.key;if("Enter"===e&&this.allowNewline)return this.value=this.__normalize(this.value+"\n"),this.__sync(),void this.__emitChange();"Enter"!==e?"Backspace"===e?(this.value=this.value.slice(0,-1),this.__sync(),this.__emitChange()):"Delete"===e?(this.value=this.value.slice(1),this.__sync(),this.__emitChange()):"Escape"===e?this.blur():"string"!=typeof e||1!==e.length||t.metaKey||t.ctrlKey||(this.value=this.__normalize(this.value+e),this.__sync(),this.__emitChange()):this.trigger("submit",null,{value:this.value})}__emitChange(){this.trigger("change",null,{value:this.value})}__mountNativeInput(){if(this.nativeInput||!this.enabled)return;const t=this.ice&&this.ice.root?this.ice.root.document:null;if(!t||!t.body)return;const e=h.getTheme();let i=0,s=0;try{const t=this.getMinBoundingBox(!0);t&&t.tl&&(i=Number(t.tl[0])||0,s=Number(t.tl[1])||0)}catch(t){}const o=this.ice&&this.ice.canvasEl&&"function"==typeof this.ice.canvasEl.getBoundingClientRect?this.ice.canvasEl.getBoundingClientRect():{left:0,top:0};this.nativeInput=new Mt({doc:t,box:{left:(Number(o.left)||0)+i,top:(Number(o.top)||0)+s,width:Number(this.state.width)||0,height:Number(this.state.height)||0},value:this.value,font:`${e.font.weightNormal} ${e.font.size}px ${e.font.family}`,caretColor:e.colors.text,maxLength:this.maxLength,multiline:this.allowNewline,onInput:t=>this.__applyNativeValue(t),onEnter:()=>this.trigger("submit",null,{value:this.value}),onEscape:()=>this.blur(),onBlur:()=>this.__handleNativeBlur()}),this.nativeInput.mount()}__handleNativeBlur(){this.focused&&this.nativeInput&&this.nativeInput.focus()}__unmountNativeInput(){this.nativeInput&&(this.nativeInput.unmount(),this.nativeInput=null)}__applyNativeValue(t){const e=this.__normalize(String(t??""));e!==this.value&&(this.value=e,this.__sync(),this.__emitChange())}__isPointInside(t){if(!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return!1;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return!1;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=this.getMinBoundingBox(!0);return e>=s.tl[0]&&e<=s.br[0]&&i>=s.tl[1]&&i<=s.br[1]}getFieldText(){return this.textNode.getText()}refresh(){this.__sync()}formatDisplayValue(t){return t}__normalize(t){return this.maxLength>0?t.slice(0,this.maxLength):t}__applyFocusState(){this.focused?this.__pointerDown||this.__mountNativeInput():this.__unmountNativeInput(),this.__sync()}__applyValidateState(){this.__sync()}__sync(){const t=h.getTheme(),e="error"===this.validateStatus?t.colors.error:this.focused?t.colors.focusRing:t.colors.border;this.setState({style:{...this.state.style,fillStyle:t.colors.surface,strokeStyle:e,lineWidth:this.focused||"error"===this.validateStatus?t.control.lineWidthFocused:t.control.lineWidth}});const i=this.formatDisplayValue(this.value),s=i||this.placeholder;this.textNode.setText(this.focused&&i?i+"|":s),this.textNode.setState({style:{fillStyle:this.value?t.colors.text:t.colors.textTertiary,fontFamily:t.font.family,fontSize:t.font.size,fontWeight:t.font.weightNormal,textAlign:"left",textBaseline:"middle"}}),this.revalidate()}}const Tt={setInterval:(t,e)=>globalThis.setInterval(t,e),clearInterval(t){globalThis.clearInterval(t)}};const zt=["一","二","三","四","五","六","日"];function Et(t){return t<10?"0"+t:String(t)}function It(t){return`${t.getFullYear()}-${Et(t.getMonth()+1)}-${Et(t.getDate())}`}function At(t){return t<10?"0"+t:String(t)}function Bt(t){const e=Math.floor(Number(t));return Number.isFinite(e)&&e>=1?e:1}class Ht extends r{actionButtons=new Map;replyNodes=[];constructor(t){const e=h.getTheme(),i=t.width??400,s=t.replies||[],o=!(!t.actions||!t.actions.length);let n=58;o&&(n+=34);const l=s.reduce((t,e)=>t+function t(e){const i=!(!e.actions||!e.actions.length),s=e.replies||[];let o=58+(i?34:0);return o+=s.reduce((e,i)=>e+t(i),0),o}(e),0);n+=l,super({id:t.id,fill:!0,stroke:!1,left:t.left,top:t.top,width:i,height:n,radius:e.radius.md,style:{fillStyle:"rgba(0,0,0,0)"}});const a=t.avatarText||t.author.slice(0,1).toUpperCase(),d=new r({left:0,top:0,width:32,height:32,radius:16,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:t.avatarColor||e.colors.primary}});d.addChild(new H({interactive:!1,left:0,top:0,width:32,height:32,align:"center",verticalAlign:"middle",text:a,style:{fontSize:13,fontWeight:"600",fillStyle:e.colors.primaryText}}),!1),this.addChild(d,!1);const c=Math.max(0,i-44);this.addChild(new H({interactive:!1,left:44,top:2,width:c-80,height:20,verticalAlign:"middle",text:t.author,style:{fontSize:13,fontWeight:"600",fillStyle:e.colors.text}}),!1),t.time&&this.addChild(new H({interactive:!1,left:i-80,top:2,width:80,height:20,align:"right",verticalAlign:"middle",text:t.time,style:{fontSize:12,fillStyle:e.colors.textTertiary}}),!1),this.addChild(new H({interactive:!1,left:44,top:34,width:c,height:20,verticalAlign:"middle",text:t.content,style:{fontSize:13,fillStyle:e.colors.textSecondary}}),!1);let u=58;if(o){let e=44;t.actions.forEach(i=>{const s=new Y({left:e,top:u,width:Math.max(48,14*i.text.length+16),height:26,text:i.text,variant:"text",size:"small"});s.on("click",()=>{t.onAction&&t.onAction(i.key)}),this.addChild(s,!1),this.actionButtons.set(i.key,s),e+=Math.max(48,14*i.text.length+16)+8}),u+=34}const f=t.indent??44;s.forEach(t=>{const e=new Ht({...t,left:f,top:u,width:Math.max(0,i-f)});this.addChild(e,!1),this.replyNodes.push(e),u+=Number(e.state.height)||0})}getActionButton(t){return this.actionButtons.get(t)||null}getReplyNodes(){return this.replyNodes.slice()}}class Wt extends r{cells=[];running=!1;constructor(t={}){const e=h.getTheme(),i=(t.colors&&t.colors.length?t.colors:Wt.__defaultPalette()).slice(),s=Math.max(1,Math.floor(t.columns??6)),o=t.gap??8,n=0===i.length?0:Math.ceil(i.length/s),r=Wt.__resolveSwatchSize(t,s,o,8),l=t.width??s*r+(s-1)*o+16,a=t.height??16+n*r+Math.max(0,n-1)*o;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:l,height:a,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.colors=i,this.columns=s,this.value=void 0===t.value?void 0:String(t.value),this.swatchSize=r,this.gap=o,this.padding=8,this.disabled=!0===t.disabled,this.onChange="function"==typeof t.onChange?t.onChange:null,this.focusable=!this.disabled,this.focusRingMode="always",this.disabled&&this.setEnabled(!1),this.__render()}afterAddHandler(){super.afterAddHandler(),!this.running&&this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.running=!0)}getValue(){return this.value}setValue(t){const e=String(t);return this.value===e||(this.value=e,this.__render()),this}isSelected(t){return this.value===t}getSwatchNodes(){return this.cells.slice()}getSwatchNode(t){const e=this.colors.indexOf(t);return e>=0&&this.cells[e]||null}getRowCount(){return 0===this.colors.length?0:Math.ceil(this.colors.length/this.columns)}getFormValue(){return this.value}setFormValue(t){this.setValue(String(t))}__applyValidateState(){this.__render()}__pick(t){this.disabled||this.value===t||(this.value=t,this.__render(),this.onChange&&this.onChange(t))}__onKeyDown(t){if(this.disabled||!this.isFocused()||0===this.colors.length)return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code),s=void 0===this.value?-1:this.colors.indexOf(this.value),o=s<0?0:s;let n=-1;"ArrowRight"===i?n=Math.min(this.colors.length-1,o+1):"ArrowLeft"===i?n=Math.max(0,o-1):"ArrowDown"===i?n=Math.min(this.colors.length-1,o+this.columns):"ArrowUp"===i&&(n=Math.max(0,o-this.columns)),n>=0&&this.__pick(this.colors[n])}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]),this.cells=[];const e="error"===this.validateStatus?t.colors.error:t.colors.border;this.setState({style:{...this.state.style,fillStyle:this.disabled?t.colors.disabled:t.colors.surface,strokeStyle:e}}),this.colors.forEach((i,s)=>{const o=s%this.columns,n=Math.floor(s/this.columns),h=this.value===i,l=this.padding+o*(this.swatchSize+this.gap),a=this.padding+n*(this.swatchSize+this.gap),d=new r({left:l,top:a,width:this.swatchSize,height:this.swatchSize,radius:t.radius.sm,fill:!0,stroke:!0,interactive:!this.disabled,style:{fillStyle:t.colors.surface,strokeStyle:h?t.colors.primary:e,lineWidth:h?2:1}});d.addChild(new r({left:3,top:3,width:Math.max(0,this.swatchSize-6),height:Math.max(0,this.swatchSize-6),radius:t.radius.xs,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:i}}),!1),d.on("click",()=>this.__pick(i)),this.addChild(d,!1),this.cells.push(d)}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}static __resolveSwatchSize(t,e,i,s){if(void 0!==t.swatchSize)return Math.max(12,Number(t.swatchSize));if(void 0!==t.width){const o=Number(t.width)-2*s-i*(e-1);return Math.max(12,Math.floor(o/e))}return 28}static __defaultPalette(){return["#0d6efd","#6610f2","#6f42c1","#d63384","#dc3545","#fd7e14","#ffc107","#198754","#20c997","#0dcaf0","#6c757d","#212529"]}}class Ot extends r{natural=null;errored=!1;viewport=null;imageNode=null;hookedSrc=null;constructor(t={}){const e=h.getTheme(),i=t.width??120,s=t.height??80;super({id:t.id,fill:!0,stroke:!1,left:t.left,top:t.top,width:i,height:s,style:{fillStyle:t.placeholder||e.colors.borderSecondary}}),this.src=t.src??"",this.fit=t.fit||"fill",this.__render()}afterAddHandler(){super.afterAddHandler(),this.__syncFromCache()}static computeFit(t,e,i,s,o){if("fill"===o||!t||!e)return{left:0,top:0,width:i,height:s};const n="contain"===o?Math.min(i/t,s/e):Math.max(i/t,s/e),h=t*n,r=e*n;return{left:(i-h)/2,top:(s-r)/2,width:h,height:r}}getSrc(){return this.src}setSrc(t){const e=t??"";return this.src===e||(this.src=e,this.natural=null,this.errored=!1,this.hookedSrc=null,this.imageNode&&this.imageNode.setState({src:e}),this.__layout(),this.__syncFromCache(),this.revalidate()),this}getFit(){return this.fit}setFit(t){return this.fit===t||(this.fit=t,this.__layout(),this.revalidate()),this}isLoaded(){return!this.errored&&null!==this.natural}isErrored(){return this.errored}markError(){return this.errored=!0,this.natural=null,this.__layout(),this.revalidate(),this}setNaturalSize(t,e){const i=Number(t)||0,s=Number(e)||0;return i&&s?(this.natural={width:i,height:s},this.errored=!1,this.__layout(),this.revalidate(),this):this}getContentBox(){return this.__computeContentBox()}getViewportNode(){return this.viewport}getImageNode(){return this.imageNode}__render(){this.removeChildren([...this.childNodes]);const t=Number(this.state.width)||120,i=Number(this.state.height)||80,s=new r({left:0,top:0,width:t,height:i,fill:!1,stroke:!1,interactive:!1,clipChildren:!0}),o=new e.ICEImage({left:0,top:0,width:t,height:i,src:this.src});s.addChild(o,!1),this.addChild(s,!1),this.viewport=s,this.imageNode=o,this.__layout()}__layout(){if(!this.imageNode)return;const t=this.__computeContentBox();this.imageNode.setState({left:t.left,top:t.top,width:t.width,height:t.height})}__computeContentBox(){const t=Number(this.state.width)||120,e=Number(this.state.height)||80,i=this.natural;return i?Ot.computeFit(i.width,i.height,t,e,this.fit):{left:0,top:0,width:t,height:e}}__syncFromCache(){const t=this.ice;if(!this.src||!t||!t.imageCache||this.hookedSrc===this.src)return;this.hookedSrc=this.src;const e=this.src,{loaded:i,image:s}=t.imageCache.setImage(this.src),o=()=>{this.src===e&&s.naturalWidth>0&&this.setNaturalSize(s.naturalWidth,s.naturalHeight)};i?o():s&&"function"==typeof s.addEventListener&&(s.addEventListener("load",o),s.addEventListener("error",()=>{this.src===e&&this.markError()}))}}class Ft extends r{constructor(t={}){const i=h.getTheme(),s=t.size||40;super({fill:!1,stroke:!1,width:s,height:s,...t}),this.circle=new e.ICECircle({left:0,top:0,radius:s/2,style:{fillStyle:t.backgroundColor||i.colors.primary,strokeStyle:i.colors.surface,lineWidth:2}}),this.textNode=L(t.text||"U",i,s,s,{fontSize:Math.round(.4*s),fontWeight:i.font.weightSemibold,fillStyle:i.colors.primaryText}),this.addChild(this.circle,!1),this.addChild(this.textNode,!1)}setText(t){return this.textNode.setText(t||"U"),this.revalidate(),this}getText(){return this.textNode.getText()}}class Rt extends e.ICEPath{constructor(t={}){super({fill:!1,stroke:!0,...t}),this.pathData=t.pathData||t.d||"",this.viewBoxSize=Number(t.viewBox)||24}createPathObject(){if("function"!=typeof globalThis.Path2D)return this.path2D={_isPolyfill:!0,_commands:[]},this.path2D;const t=new globalThis.Path2D(this.pathData),e=(Number(this.state.width)||this.viewBoxSize)/this.viewBoxSize;if(1===e||"function"!=typeof t.addPath)return this.path2D=t,this.path2D;const i=new globalThis.Path2D,s=globalThis.DOMMatrix;return s?i.addPath(t,(new s).scale(e)):i.addPath(t,{a:e,b:0,c:0,d:e,e:0,f:0}),this.path2D=i,this.path2D}}class Dt extends r{constructor(t={}){const e=h.getTheme(),i=t.size||24;super({fill:!1,stroke:!1,width:i,height:i,...t}),this.pathNode=new Rt({origin:"top-left",left:0,top:0,width:i,height:i,pathData:t.d||t.path||"",viewBox:t.viewBox||24,style:{strokeStyle:t.color||e.colors.text,lineWidth:t.strokeWidth||1.6,fillStyle:"none",...t.style||{}}}),this.addChild(this.pathNode,!1)}setColor(t){return this.pathNode.setState({style:{...this.pathNode.state.style,strokeStyle:t}}),this.revalidate(),this}}class Vt{listeners=new Set;constructor(t={}){this.selected=!0===t.selected}isSelected(){return this.selected}setSelected(t){const e=!!t;return e===this.selected||(this.selected=e,this.__notify()),this}toggle(){return this.setSelected(!this.selected)}addChangeListener(t){return this.listeners.add(t),this}removeChangeListener(t){return this.listeners.delete(t),this}__notify(){this.listeners.forEach(t=>t(this))}}class Lt extends r{constructor(t={}){const i=h.getTheme(),s=!0===t.selected,o=t.boxSize||i.control.checkboxSize,n=t.width||o,r=t.height||o,l=(n-o)/2,a=(r-o)/2;super({fill:!1,stroke:!1,draggable:!1,width:n,height:r,...t}),this.focusable=!1!==t.focusable,void 0===t.ariaLabel&&void 0===t.label||this.setAriaLabel(String(void 0!==t.ariaLabel?t.ariaLabel:t.label)),this.model=new Vt({selected:s}),this.box=new e.ICERect({left:l,top:a,width:o,height:o,radius:i.radius.xs,style:{fillStyle:s?i.colors.primary:i.colors.surface,strokeStyle:s?i.colors.primary:i.colors.borderSecondary,lineWidth:i.control.lineWidth}}),this.mark=L(s?"✓":"",i,o,o,{fontSize:Math.max(12,.72*o),fontWeight:i.font.weightBold,fillStyle:i.colors.primaryText}),this.mark.setState({left:l,top:a,width:o,height:o}),this.addChild(this.box,!1),this.addChild(this.mark,!1),this.model.addChangeListener(()=>{this.__sync(),this.trigger("change",null,{value:this.isSelected()})})}isSelected(){return this.model.isSelected()}setSelected(t){return this.model.setSelected(t),this}getFormValue(){return this.isSelected()}setFormValue(t){this.setSelected(!!t)}activate(){this.enabled&&this.model.toggle()}initEvents(){super.initEvents(),this.on("mousedown",()=>this.__toggle(),this)}__toggle(){this.enabled&&this.model.toggle()}__applyHoverState(){this.__sync()}__sync(){const t=h.getTheme(),e=this.model.isSelected();this.box.setState({style:{fillStyle:e?this.hovered?t.colors.primaryHover:t.colors.primary:this.hovered?t.colors.primaryBg:t.colors.surface,strokeStyle:e||this.hovered?t.colors.primary:t.colors.borderSecondary,lineWidth:t.control.lineWidth}}),this.mark.setText(e?"✓":""),this.revalidate()}}class Pt extends r{constructor(t={}){const i=h.getTheme(),s=!0===t.selected,o=t.size||i.control.radioSize,n=t.width||o,r=t.height||o,l=(n-o)/2,a=(r-o)/2,d=o/2,c=o/4;super({fill:!1,stroke:!1,draggable:!1,width:n,height:r,...t}),this.focusable=!1!==t.focusable,this.model=new Vt({selected:s}),this.outer=new e.ICECircle({left:l,top:a,radius:d,style:{fillStyle:i.colors.surface,strokeStyle:s?i.colors.primary:i.colors.borderSecondary,lineWidth:i.control.lineWidth}}),this.inner=new e.ICECircle({left:l+o/2-c,top:a+o/2-c,radius:c,style:{fillStyle:s?i.colors.primary:"transparent",strokeStyle:s?i.colors.primary:"transparent"}}),this.addChild(this.outer,!1),this.addChild(this.inner,!1),this.model.addChangeListener(()=>{this.__sync(),this.trigger("change",null,{value:this.isSelected()})})}isSelected(){return this.model.isSelected()}setSelected(t){return this.model.setSelected(t),this}getFormValue(){return this.isSelected()}setFormValue(t){this.setSelected(!!t)}activate(){this.enabled&&this.model.setSelected(!0)}initEvents(){super.initEvents(),this.on("mousedown",()=>this.__select(),this)}__select(){this.enabled&&this.model.setSelected(!0)}__applyHoverState(){this.__sync()}__sync(){const t=h.getTheme(),e=this.model.isSelected();this.outer.setState({style:{fillStyle:this.hovered&&!e?t.colors.primaryBg:t.colors.surface,strokeStyle:e||this.hovered?t.colors.primary:t.colors.borderSecondary,lineWidth:t.control.lineWidth}}),this.inner.setState({style:{fillStyle:e?this.hovered?t.colors.primaryHover:t.colors.primary:"transparent",strokeStyle:e?this.hovered?t.colors.primaryHover:t.colors.primary:"transparent"}}),this.revalidate()}}class Kt{listeners=new Set;constructor(t={}){this.min=t.min??0,this.max=t.max??100,this.value=this.__clamp(t.value??this.min)}getValue(){return this.value}getMinimum(){return this.min}getMaximum(){return this.max}setValue(t){const e=this.__clamp(t);return e===this.value||(this.value=e,this.__notify()),this}addChangeListener(t){return this.listeners.add(t),this}removeChangeListener(t){return this.listeners.delete(t),this}__clamp(t){const e=Math.min(this.min,this.max),i=Math.max(this.min,this.max);return Number.isFinite(t)?Math.min(i,Math.max(e,t)):e}__notify(){this.listeners.forEach(t=>t(this))}}class Xt extends e.ICEPath{constructor(t={}){super({fill:!1,stroke:!0,closePath:!1,sweep:1,full:!1,...t})}createPathObject(){const t=Number(this.state.width)||120,e=Number(this.state.style.lineWidth)||8,i=Math.max(1,t/2-e/2),s="function"==typeof globalThis.Path2D?new globalThis.Path2D:{_isPolyfill:!0,_commands:[]},o=Math.max(0,Math.min(1,Number(this.state.sweep)));if("function"==typeof s.arc)if(!0===this.state.full)s.arc(0,0,i,0,2*Math.PI);else{const t=-Math.PI/2;s.arc(0,0,i,t,t+2*Math.PI*o)}return this.path2D=s,s}}function Yt(t){return null==t||("string"==typeof t?""===t.trim():Array.isArray(t)?0===t.length:!1===t)}function Gt(t){return"string"==typeof t||Array.isArray(t)?t.length:null==t?0:String(t).length}class $t{fields=[];listeners=new Set;constructor(t={}){this.validateTrigger=t.validateTrigger||"change"}addField(t){const e={name:t.name,label:t.label||t.name,rules:t.rules?t.rules.slice():[],dependencies:t.dependencies?t.dependencies.slice():[],value:t.value,initialValue:t.value,error:null,validating:!1},i=this.fields.findIndex(e=>e.name===t.name);return-1===i?this.fields.push(e):this.fields[i]=e,this}removeField(t){return this.fields=this.fields.filter(e=>e.name!==t),this}getField(t){return this.fields.find(e=>e.name===t)}getFieldNames(){return this.fields.map(t=>t.name)}getDependents(t){return this.fields.filter(e=>-1!==e.dependencies.indexOf(t)).map(t=>t.name)}getLabel(t){const e=this.getField(t);return e?e.label:t}getValue(t){const e=this.getField(t);return e?e.value:void 0}getValues(){const t={};return this.fields.forEach(e=>{t[e.name]=e.value}),t}setValue(t,e,i={}){const s=this.getField(t);return s?(s.value=e,i.silent||("change"===this.validateTrigger&&(this.validateField(t,{silent:!0}),this.__validateDependents(t)),this.__notify()),this):this}setValues(t,e={}){return Object.keys(t).forEach(e=>{const i=this.getField(e);i&&(i.value=t[e])}),e.silent||("change"===this.validateTrigger&&(Object.keys(t).forEach(t=>this.validateField(t,{silent:!0})),Object.keys(t).forEach(t=>this.__validateDependents(t))),this.__notify()),this}__validateDependents(t){this.getDependents(t).forEach(t=>this.validateField(t,{silent:!0}))}getError(t){const e=this.getField(t);return e?e.error:void 0}getErrors(){const t={};return this.fields.forEach(e=>{e.error&&(t[e.name]=e.error)}),t}hasErrors(){return this.fields.some(t=>!!t.error)}validateField(t,e={}){const i=this.getField(t);return i?(i.error=this.__check(i),e.silent||this.__notify(),i.error):null}validate(){return this.fields.forEach(t=>{t.error=this.__check(t)}),this.__notify(),!this.hasErrors()}isValidating(t){const e=this.getField(t);return!!e&&e.validating}async validateFieldAsync(t){const e=this.getField(t);if(!e)return null;const i=this.__check(e);if(e.error=i,i)return this.__notify(),i;const s=e.rules.filter(t=>"function"==typeof t.asyncValidator);if(!s.length)return this.__notify(),null;e.validating=!0,this.__notify();try{for(const t of s){const i=await t.asyncValidator(e.value,this.getValues());if(i)return e.error=i,i}return e.error=null,null}finally{e.validating=!1,this.__notify()}}async validateAsync(){return await Promise.all(this.fields.map(t=>this.validateFieldAsync(t.name))),!this.hasErrors()}reset(){return this.fields.forEach(t=>{t.value=t.initialValue,t.error=null}),this.__notify(),this}addChangeListener(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}__check(t){const e=t.label,i=t.value,s=this.getValues();for(const o of t.rules){if(o.required&&Yt(i))return o.message||e+"不能为空";if(Yt(i)&&!o.validator)continue;const t=Number(i);if(void 0!==o.min&&Number.isFinite(t)&&t<o.min)return o.message||`${e}不能小于 ${o.min}`;if(void 0!==o.max&&Number.isFinite(t)&&t>o.max)return o.message||`${e}不能大于 ${o.max}`;const n=Gt(i);if(void 0!==o.minLength&&n<o.minLength)return o.message||`${e}长度不能少于 ${o.minLength}`;if(void 0!==o.maxLength&&n>o.maxLength)return o.message||`${e}长度不能超过 ${o.maxLength}`;if(o.pattern&&!o.pattern.test(String(i)))return o.message||e+"格式不正确";if(o.validator){const t=o.validator(i,s);if(t)return t}}return null}__notify(){this.listeners.forEach(t=>t(this))}}class qt extends r{closed=!1;closeButton=null;iconNode=null;constructor(t={}){const e=h.getTheme(),i=t.type||"info",s=D(e,i),o=t.width||420,n=t.height||60,l=!0===t.closable,a=!1!==t.showIcon;super({...t,fill:!0,stroke:!0,width:o,height:n,radius:e.radius.md,style:{fillStyle:s.background,strokeStyle:s.border,lineWidth:e.control.lineWidth,...t.style||{}}}),this.type=i,this.closable=l,this.onCloseCallback="function"==typeof t.onClose?t.onClose:null;const d=a?24:0,c=Math.max(0,o-2*e.spacing.md-d-(l?24:0));if(a&&(this.iconNode=new H({interactive:!1,left:e.spacing.md,top:e.spacing.xs,width:18,height:20,align:"center",verticalAlign:"middle",text:qt.__iconOf(i),style:{fontSize:e.font.size,fontWeight:e.font.weightSemibold,fillStyle:s.strong}}),this.addChild(this.iconNode,!1)),this.titleNode=V({left:e.spacing.md+d,top:e.spacing.xs,width:c,height:20,text:t.title||"",fillStyle:s.strong,fontFamily:e.font.family,fontSize:e.font.size,fontWeight:e.font.weightSemibold,align:"left",verticalAlign:"middle"}),this.messageNode=V({left:e.spacing.md+d,top:e.spacing.md+16,width:c,height:18,text:t.message||"",fillStyle:e.colors.textSecondary,fontFamily:e.font.family,fontSize:e.font.sizeSmall,fontWeight:e.font.weightNormal,align:"left",verticalAlign:"middle"}),this.addChild(this.titleNode,!1),this.addChild(this.messageNode,!1),l){const t=new r({left:o-30,top:10,width:20,height:20,radius:e.radius.sm,fill:!1,stroke:!1});t.addChild(V({left:0,top:0,width:20,height:20,text:"✕",fillStyle:s.strong,fontFamily:e.font.family,fontSize:e.font.sizeSmall,align:"center",verticalAlign:"middle"}),!1),t.on("click",()=>this.close()),this.addChild(t,!1),this.closeButton=t}}setTitle(t){return this.titleNode.setText(t??""),this.revalidate(),this}setMessage(t){return this.messageNode.setText(t??""),this.revalidate(),this}getType(){return this.type}getIconNode(){return this.iconNode}getTitleNode(){return this.titleNode}static __iconOf(t){return"success"===t?"✓":"warning"===t?"!":"error"===t?"✕":"ℹ"}close(){return this.closed||(this.closed=!0,this.setState({display:!1}),this.onCloseCallback&&this.onCloseCallback()),this}isClosed(){return this.closed}isClosable(){return this.closable}getCloseButton(){return this.closeButton}}function Ut(t){const e=Math.floor(Number(t.itemHeight)||0),i=Math.floor(Number(t.viewportHeight)||0),s=Math.max(0,Math.floor(Number(t.itemCount)||0)),o=Math.max(0,Math.floor(Number(t.buffer)||0));if(e<=0||i<=0||s<=0)return{start:0,end:0,count:0};const n=s*e,h=Number(t.scrollTop),r=Math.min(Math.max(Number.isFinite(h)?h:0,0),n),l=Math.floor(r/e),a=Math.floor((r+i-1)/e),d=Math.max(0,l-o),c=Math.min(s,Math.max(a,l)+o+1);return{start:d,end:c,count:Math.max(0,c-d)}}function jt(t,e,i=60){if(!(t||[]).length)return[];const s=t.map(t=>Math.max(1,Math.floor(Number(t.minWidth)||i))),o=t.map((t,e)=>{const i=Math.floor(Number(t.width)||0);return i>0?Math.max(s[e],i):0}),n=o.map((t,e)=>0===t?e:-1).filter(t=>t>=0);if(n.length){const t=o.reduce((t,e)=>t+e,0),i=Math.max(0,Math.floor(Number(e)||0)-t),h=Math.max(1,Math.floor(i/n.length));n.forEach(t=>{o[t]=Math.max(s[t],h)})}return o}class Zt extends r{pageSize=0;page=1;paginationOptions=null;paginationNode=null;sortKey=null;sortOrder=null;rowPanels=[];cellNodes=[];selectedIndex=-1;selectedIndexes=[];selectionMode="single";selectionNodes=[];headerCheckbox=null;onSelectionChange=null;static SELECTION_WIDTH=40;renderedWidth=0;hoveredIndex=-1;columnWidthOverrides={};resizable=!1;onColumnResize=null;resizeState=null;scrollable=!1;virtual=!1;bodyPane=null;headerPane=null;bodyContent=null;frozenLayer=null;frozenContent=null;rowWindow={start:0,end:0,count:0};virtualScrollTop=0;virtualScrollLeft=0;rowNodes=new Map;frozenRowNodes=new Map;virtualBuffer=2;renderedContentWidth=0;rowDraggable=!1;onRowReorder=null;dragRow=null;__bound=!1;constructor(t={}){const e=h.getTheme(),i=t.width||720,s=t.rowHeight||40,o=t.headerHeight||36,n=(t.columns||[]).some(t=>!0===t.fixed),r=!0===t.virtual||n?t.height||400:o+s*(t.data?t.data.length:0);if(super({...t,fill:!0,stroke:!0,width:i,height:r,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth,...t.style||{}}}),this.columns=t.columns||[],this.sourceData=t.data||[],this.sortedData=(t.data||[]).slice(),this.data=this.sortedData,this.rowHeight=s,this.headerHeight=o,this.onSelect="function"==typeof t.onSelect?t.onSelect:null,this.resizable=!0===t.resizable,this.minColumnWidth=Math.max(20,Math.floor(Number(t.minColumnWidth)||60)),this.onColumnResize="function"==typeof t.onColumnResize?t.onColumnResize:null,this.virtual=!0===t.virtual,this.virtualBuffer=Math.max(0,Math.floor(Number(void 0===t.virtualBuffer?2:t.virtualBuffer)||0)),this.scrollable=this.virtual||(this.columns||[]).some(t=>!0===t.fixed),this.rowDraggable=!0===t.rowDraggable,this.onRowReorder="function"==typeof t.onRowReorder?t.onRowReorder:null,this.selectionMode="multiple"===t.rowSelection?"multiple":"none"===t.rowSelection?"none":"single",this.onSelectionChange="function"==typeof t.onSelectionChange?t.onSelectionChange:null,t.pagination&&"object"==typeof t.pagination)return this.paginationOptions=t.pagination,this.pageSize=Math.max(1,Number(t.pagination.pageSize)||10),this.page=Math.max(1,Number(t.pagination.page)||1),void this.__applyPage();this.__render()}setData(t){return this.sourceData=t||[],this.sortedData=this.sourceData.slice(),this.sortKey=null,this.sortOrder=null,this.selectedIndex=-1,this.selectedIndexes=[],this.page=1,this.__applyPage(),this}getTotalRows(){return this.sortedData.length}getPageCount(){return this.pageSize?Math.max(1,Math.ceil(this.sortedData.length/this.pageSize)):1}getPage(){return this.page}getPageSize(){return this.pageSize}setPage(t){if(!this.pageSize)return this;const e=Math.min(this.getPageCount(),Math.max(1,Math.floor(Number(t)||1)));return e===this.page||(this.page=e,this.selectedIndex=-1,this.__applyPage(),this.trigger("pagechange",null,{page:e,pageSize:this.pageSize}),this.paginationOptions&&this.paginationOptions.onChange&&this.paginationOptions.onChange(e,this.pageSize)),this}setPageSize(t){const e=Math.max(1,Math.floor(Number(t)||10));return this.pageSize&&e!==this.pageSize?(this.pageSize=e,this.page=1,this.__applyPage(),this):this}getPaginationNode(){return this.paginationNode}getRows(){return this.data.slice()}getSortState(){return this.sortKey&&this.sortOrder?{key:this.sortKey,order:this.sortOrder}:null}getHeaderLabel(t){const e=this.columns.find(e=>e.key===t);return e?this.sortKey===t&&this.sortOrder?`${e.title} ${"asc"===this.sortOrder?"▲":"▼"}`:e.title:""}toggleSort(t){const e=this.columns.find(e=>e.key===t);if(!e||!e.sorter)return this;let i;return i=this.sortKey!==t?"asc":"asc"===this.sortOrder?"desc":null,this.sortBy(t,i)}sortBy(t,e){const i=this.columns.find(e=>e.key===t);if(!i||!i.sorter||!e)return this.sortKey=null,this.sortOrder=null,this.sortedData=this.sourceData.slice(),this.__applyPage(),this;this.sortKey=t,this.sortOrder=e;const s="asc"===e?1:-1;return this.sortedData=this.sourceData.slice().sort((t,e)=>s*this.__compareRows(t,e,i)),this.__applyPage(),this}__applyPage(){const t=this.sortedData.length;if(this.page=Math.min(this.getPageCount(),Math.max(1,this.page)),this.pageSize){const t=(this.page-1)*this.pageSize;this.data=this.sortedData.slice(t,t+this.pageSize)}else this.data=this.sortedData.slice();const e=this.pageSize>0&&t>0,i=this.data.length>0?this.rowHeight*this.data.length:120;this.setState({height:this.headerHeight+i+(e?this.__footerHeight():0)}),this.__render()}__footerHeight(){return 48}setSelectedRow(t){return"multiple"===this.selectionMode?this.setSelectedIndexes(t>=0?[t]:[]):(this.selectedIndex=t,this.selectedIndexes=t>=0?[t]:[],this.__syncSelection(),this)}getSelectedIndex(){return this.selectedIndex}getSelectionMode(){return this.selectionMode}getSelectedIndexes(){return"multiple"===this.selectionMode?this.selectedIndexes.slice():this.selectedIndex>=0?[this.selectedIndex]:[]}getSelectedRows(){return this.getSelectedIndexes().map(t=>this.data[t]).filter(Boolean)}setSelectedIndexes(t){const e=(t||[]).map(t=>Math.floor(Number(t))).filter(t=>t>=0&&t<this.data.length).filter((t,e,i)=>i.indexOf(t)===e).sort((t,e)=>t-e);return"multiple"!==this.selectionMode?this.setSelectedRow(e.length?e[0]:-1):(this.selectedIndexes=e,this.selectedIndex=e.length?e[e.length-1]:-1,this.__syncSelection(),this.__emitSelection(),this)}selectAll(){return this.setSelectedIndexes(this.data.map((t,e)=>e))}clearSelection(){return this.setSelectedIndexes([])}getSelectionNode(t){return this.selectionNodes[t]||null}getHeaderCheckbox(){return this.headerCheckbox}afterAddHandler(){super.afterAddHandler(),this.__bindGlobalEvents(),this.__layoutCells()}__bindGlobalEvents(){!this.__bound&&this.ice&&this.ice.evtBus&&(this.__bound=!0,this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this),this.ice.evtBus.on("mousemove",this.__onGlobalMouseMove,this),this.ice.evtBus.on("mouseup",this.__onGlobalMouseUp,this))}__onGlobalMouseDown(t){if(!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=this.getMinBoundingBox(!0);if(e<s.tl[0]||e>s.br[0]||i<s.tl[1]||i>s.br[1])return;const o=e-s.tl[0],n=i-s.tl[1];if(n<this.headerHeight){const t="multiple"===this.selectionMode?Zt.SELECTION_WIDTH:0,e=this.__columnWidths((Number(this.state.width)||720)-t);let i=t;for(let t=0;t<this.columns.length;t++){if(o>=i&&o<=i+e[t])return void this.toggleSort(this.columns[t].key);i+=e[t]}return}const h=Math.floor((n-this.headerHeight)/this.rowHeight);if(h>=0&&h<this.data.length){!this.rowDraggable||"multiple"===this.selectionMode&&o<Zt.SELECTION_WIDTH||(this.__startRowDrag(h),this.__updateRowDrag(n));const e=t.target,i=this.rowPanels[h];if(e&&e!==i){let t=e.parentNode;for(;t&&t!==i;)t=t.parentNode;if(t===i)return}if(this.selectedIndex=h,"multiple"===this.selectionMode){const t=-1===this.selectedIndexes.indexOf(h)?this.selectedIndexes.concat(h).sort((t,e)=>t-e):this.selectedIndexes.filter(t=>t!==h);return this.selectedIndexes=t,this.selectedIndex=h,this.__syncSelection(),void this.__emitSelection()}this.__syncSelection(),this.onSelect&&this.onSelect(this.data[h],h)}}__toNumber(t){if("number"==typeof t)return Number.isFinite(t)?t:null;if("string"!=typeof t)return null;const e=t.replace(/[,\s]/g,"").replace(/^[¥$€£]/,"").replace(/%$/,"");if(!/^[-+]?(\d+\.?\d*|\.\d+)$/.test(e))return null;const i=Number(e);return Number.isFinite(i)?i:null}__compareRows(t,e,i){if("function"==typeof i.sorter)return i.sorter(t,e);const s=t[i.key],o=e[i.key],n=this.__toNumber(s),h=this.__toNumber(o);return null!==n&&null!==h?n-h:String(s??"").localeCompare(String(o??""))}__render(){this.removeChildren([...this.childNodes]);const t=h.getTheme(),i=Number(this.state.width)||720;this.renderedWidth=i;const s="multiple"===this.selectionMode?Zt.SELECTION_WIDTH:0,o=this.__columnWidths(i-s);if(this.cellNodes=[],this.selectionNodes=[],this.headerCheckbox=null,this.scrollable)return void this.__renderScrollable(o,s);const n=new r({fill:!0,stroke:!1,width:i,height:this.headerHeight,radius:t.radius.sm,style:{fillStyle:t.colors.background}});if(this.addChild(n,!1),"multiple"===this.selectionMode){const t=new Lt({left:(s-24)/2,top:(this.headerHeight-24)/2,width:24,height:24,selected:this.data.length>0&&this.selectedIndexes.length===this.data.length});t.on("change",()=>{t.isSelected()?this.selectAll():this.clearSelection()}),n.addChild(t,!1),this.headerCheckbox=t}this.__placeCells(n,o,this.columns.map(t=>this.getHeaderLabel(t.key)),!0,this.columns,void 0,s),this.resizable&&this.__createResizeHandles(n,o,s);const l=new e.ICERect({left:0,top:this.headerHeight-1,width:i,height:1,fill:!0,stroke:!1,style:{fillStyle:t.colors.border}});if(n.addChild(l,!1),this.rowPanels=[],this.data.forEach((t,e)=>{this.__createRowPanel(t,e,this,this.headerHeight+e*this.rowHeight,o,s)}),this.data.length||this.addChild(new vt({left:0,top:this.headerHeight,width:i,height:120,description:lt("table.empty")}),!1),this.paginationNode=null,this.pageSize>0&&this.data.length>0){const t=new mt({left:0,top:this.headerHeight+this.data.length*this.rowHeight+8,width:i,total:this.sortedData.length,pageSize:this.pageSize,current:this.page,showTotal:!this.paginationOptions||!1!==this.paginationOptions.showTotal,onChange:t=>this.setPage(t)});this.addChild(t,!1),this.paginationNode=t}this.__syncSelection(),this.ice&&this.ice.ctx&&this.__layoutCells(),this.revalidate()}__afterStateMerge(t){super.__afterStateMerge(t);const e=Number(this.state.width)||0;t&&e>0&&this.renderedWidth>0&&e!==this.renderedWidth&&this.__render()}__renderScrollable(t,i){const s=h.getTheme(),o=Number(this.state.width)||720,n=Number(this.state.height)||400,l=[];this.columns.forEach((t,e)=>{!0===t.fixed&&l.push(e)});const a=l.reduce((e,i)=>e+t[i],0),d=t.reduce((t,e)=>t+e,0),c=Math.max(o,d);this.renderedContentWidth=c;const u=this.__columnWidths(c-i),f=Math.max(0,n-this.headerHeight),g=new r({left:0,top:0,width:c,height:this.headerHeight,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:s.colors.background}});this.__placeCells(g,u,this.columns.map(t=>this.getHeaderLabel(t.key)),!0,this.columns,void 0,i),this.headerPane=new _t({left:0,top:0,width:o,height:this.headerHeight,scrollbar:!1}),this.headerPane.setContent(g),this.headerPane.setContentSize(c,this.headerHeight),this.addChild(this.headerPane,!1);const m=this.pageSize>0?this.data:this.sortedData;this.data=m;const p=m.length*this.rowHeight;if(this.bodyContent=new r({left:0,top:0,width:c,height:p,fill:!1,stroke:!1,interactive:!1}),this.bodyPane=new _t({left:0,top:this.headerHeight,width:o,height:f}),this.bodyPane.setContent(this.bodyContent),this.bodyPane.setContentSize(c,p),this.bodyPane.on("scroll",t=>{const e=t&&t.param&&Number(t.param.x)||0,i=t&&t.param&&Number(t.param.y)||0;this.virtualScrollLeft=e,this.virtualScrollTop=i,this.headerPane&&this.headerPane.setScroll(e,0),this.__syncRowWindow()}),this.addChild(this.bodyPane,!1),l.length){this.frozenLayer=new r({left:0,top:0,width:a,height:n,fill:!1,stroke:!1,interactive:!1,clipChildren:!0});const t=new r({left:0,top:0,width:a,height:this.headerHeight,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:s.colors.background}});this.frozenLayer.addChild(t,!1),this.__placeCells(t,u,this.columns.map(t=>this.getHeaderLabel(t.key)),!0,this.columns,void 0,i),this.frozenContent=new r({left:0,top:this.headerHeight,width:a,height:f,fill:!1,stroke:!1,interactive:!1}),this.frozenLayer.addChild(this.frozenContent,!1);const o=new e.ICERect({left:a-1,top:0,width:1,height:n,fill:!0,stroke:!1,style:{fillStyle:s.colors.border}});this.frozenLayer.addChild(o,!1),this.addChild(this.frozenLayer,!1)}this.rowNodes.clear(),this.frozenRowNodes.clear(),this.__syncRowWindow(),this.__syncSelection(),this.ice&&this.ice.ctx&&this.__layoutCells(),this.revalidate()}__syncRowWindow(){if(!this.scrollable||!this.bodyContent)return;const t=Math.max(0,(Number(this.state.height)||400)-this.headerHeight),e=this.data,i=Ut({scrollTop:this.virtualScrollTop,viewportHeight:t,itemHeight:this.rowHeight,itemCount:e.length,buffer:this.virtualBuffer});this.rowWindow=i;const s="multiple"===this.selectionMode?Zt.SELECTION_WIDTH:0,o=this.__columnWidths((this.bodyContent.state.width||0)-s);Array.from(this.rowNodes.keys()).forEach(t=>{if(t>=i.start&&t<i.end)return;const e=this.rowNodes.get(t);this.rowNodes.delete(t),e&&this.bodyContent.removeChild(e),this.__forgetRowCells(e);const s=this.frozenRowNodes.get(t);s&&this.frozenContent&&(this.frozenRowNodes.delete(t),this.frozenContent.removeChild(s),this.__forgetRowCells(s))});for(let t=i.start;t<i.end;t+=1){if(this.rowNodes.has(t))continue;const i=this.__createRowPanel(e[t],t,this.bodyContent,t*this.rowHeight,o,s);if(this.rowNodes.set(t,i),this.frozenContent){const i=this.__createRowPanel(e[t],t,this.frozenContent,t*this.rowHeight-this.headerHeight,o,s,this.frozenContent.state.width);this.frozenRowNodes.set(t,i)}}this.ice&&this.ice.ctx&&this.__layoutCells()}__forgetRowCells(t){if(!t||!t.childNodes)return;const e=new Set(t.childNodes);this.cellNodes=this.cellNodes.filter(t=>!e.has(t.node))}__createRowPanel(t,e,i,s,o,n,l){const a=h.getTheme(),d=new r({fill:!0,stroke:!1,left:0,top:s,width:void 0===l?Number(this.state.width)||0:l,height:this.rowHeight,style:{fillStyle:e%2==0?a.colors.surface:a.colors.background}});if(i.addChild(d,!1),this.rowPanels.push(d),"multiple"===this.selectionMode){const t=new Lt({left:(n-24)/2,top:(this.rowHeight-24)/2,width:24,height:24,selected:-1!==this.selectedIndexes.indexOf(e)});t.on("change",()=>{const i=t.isSelected();i!==(-1!==this.selectedIndexes.indexOf(e))&&(this.selectedIndexes=i?this.selectedIndexes.concat(e).sort((t,e)=>t-e):this.selectedIndexes.filter(t=>t!==e),this.__syncSelection(),this.__emitSelection())}),d.addChild(t,!1),this.selectionNodes.push(t)}d.on("hoverchange",t=>{R(t)?this.hoveredIndex=e:this.hoveredIndex===e&&(this.hoveredIndex=-1),this.__syncSelection()},this);const c=this.columns.map(e=>this.__format(t[e.key]));return this.__placeCells(d,o,c,!1,this.columns,t,n),d}__placeCells(t,e,i,s,o,n,r=0){const l=h.getTheme();l.spacing.sm;let a=r;const d=s?this.headerHeight:this.rowHeight;i.forEach((i,h)=>{const r=o?o[h]:void 0,c=r&&r.align||"left",u=e[h];if(r&&"function"==typeof r.renderCell&&n){const e=r.renderCell(i,n,r,{cellWidth:u,cellHeight:d,align:c});if(e)return e.setState({left:(e.state.left||0)+a}),t.addChild(e,!1),void(a+=u)}const f=V({left:a,top:0,width:1,height:d,text:i,fillStyle:s?l.colors.textSecondary:l.colors.text,fontFamily:l.font.family,fontSize:s?l.font.sizeSmall:l.font.size,fontWeight:s?l.font.weightSemibold:l.font.weightNormal,align:"left",verticalAlign:"middle"});t.addChild(f,!1),this.cellNodes.push({node:f,cellLeft:a,cellWidth:u,cellHeight:d,align:c}),a+=u})}__layoutCells(){if(!this.ice||!this.ice.ctx||"function"!=typeof this.ice.ctx.measureText)return;const t=h.getTheme().spacing.sm,e=this.ice.ctx;for(const i of this.cellNodes){const s=i.node.state.style||{},o=s.font||`${s.fontWeight||"normal"} ${s.fontSize||14}px ${s.fontFamily||"Arial"}`;e.font=o;const n=e.measureText(String(i.node.state.text||"")).width||0;let h=i.cellLeft+t;"right"===i.align?h=i.cellLeft+i.cellWidth-t-n:"center"===i.align&&(h=i.cellLeft+(i.cellWidth-n)/2),i.node.setState({left:h,top:0,width:Math.max(1,n),height:i.cellHeight})}this.revalidate()}__columnWidths(t){return jt(this.columns.map(t=>({width:this.columnWidthOverrides[t.key]||t.width,minWidth:t.minWidth})),t,this.minColumnWidth)}getColumnWidths(){const t=this.scrollable&&this.renderedContentWidth?this.renderedContentWidth:this.renderedWidth||Number(this.state.width)||720,e="multiple"===this.selectionMode?Zt.SELECTION_WIDTH:0,i=this.__columnWidths(t-e),s={};return this.columns.forEach((t,e)=>{s[t.key]=i[e]}),s}setColumnWidth(t,e){const i=this.columns.find(e=>e.key===t);if(!i)return!1;const s=Math.max(20,Math.floor(Number(i.minWidth)||this.minColumnWidth)),o=Math.max(s,Math.floor(Number(e)||0));if(this.getColumnWidths()[t]===o)return!1;this.columnWidthOverrides[t]=o,this.columns.forEach(e=>{e.key===t||Number(e.width)>0||!this.columnWidthOverrides[e.key]||delete this.columnWidthOverrides[e.key]}),this.__render();const n=this.getColumnWidths();return this.trigger("columnresize",null,{key:t,width:o,widths:n}),this.onColumnResize&&this.onColumnResize(t,o,n),!0}isResizable(){return this.resizable}isResizing(){return!!this.resizeState}isVirtual(){return this.virtual}isScrollable(){return this.scrollable}getRowRange(){return this.scrollable?(this.__syncRowWindow(),{...this.rowWindow}):{start:0,end:this.data.length,count:this.data.length}}getRenderedRowCount(){return this.scrollable?(this.__syncRowWindow(),this.rowNodes.size):this.data.length}getScroll(){return{x:this.virtualScrollLeft,y:this.virtualScrollTop}}getContentHeight(){return this.scrollable?this.data.length*this.rowHeight:this.headerHeight+this.data.length*this.rowHeight}getFrozenWidth(){const t=this.getColumnWidths();return this.columns.reduce((e,i)=>e+(!0===i.fixed?t[i.key]:0),0)}setScrollTop(t){if(!this.scrollable||!this.bodyPane)return this;const e=Math.max(0,this.getContentHeight()-Math.max(0,(Number(this.state.height)||400)-this.headerHeight)),i=Math.min(Math.max(Number(t)||0,0),e);return this.virtualScrollTop=i,this.bodyPane.setScroll(this.virtualScrollLeft,i),this.__syncRowWindow(),this}setScrollLeft(t){if(!this.scrollable||!this.bodyPane)return this;const e=Math.max(0,Number(t)||0);return this.virtualScrollLeft=e,this.bodyPane.setScroll(e,this.virtualScrollTop),this.headerPane&&this.headerPane.setScroll(e,0),this}scrollToRow(t){if(!this.scrollable)return this;const e=Math.min(Math.max(Math.floor(Number(t)||0),0),Math.max(0,this.data.length-1));return this.setScrollTop(e*this.rowHeight)}isRowDraggable(){return this.rowDraggable}isRowDragging(){return!!this.dragRow}getDropTarget(){return this.dragRow?this.dragRow.target:null}moveRow(t,e){const i=this.pageSize>0?(this.page-1)*this.pageSize:0,s=Q(this.sortedData,i+t,{index:i+e.index,position:e.position});if(!s.moved)return!1;this.sortedData=s.items,this.sortKey||(this.sourceData=s.items.slice()),this.data=this.pageSize>0?this.sortedData.slice((this.page-1)*this.pageSize,this.page*this.pageSize):this.sortedData,this.__render();const o=s.to-i;return this.trigger("rowreorder",null,{from:t,to:o,rows:this.sortedData.slice()}),this.onRowReorder&&this.onRowReorder(t,o,this.sortedData.slice()),!0}__rowIndexAt(t){const e=t-this.headerHeight+(this.scrollable?this.virtualScrollTop:0);return Math.min(Math.max(Math.floor(e/this.rowHeight),0),Math.max(0,this.data.length-1))}__startRowDrag(t){const e=h.getTheme(),i=new r({left:0,top:0,width:Number(this.state.width)||0,height:2,fill:!0,stroke:!1,display:!1,interactive:!1,style:{fillStyle:e.colors.primary}});this.__dropHost().addChild(i,!1),this.dragRow={from:t,target:null,indicator:i},this.trigger("rowdragstart",null,{from:t})}__dropHost(){return this.scrollable&&this.bodyContent?this.bodyContent:this}__updateRowDrag(t){if(!this.dragRow)return;const e=Z({pointerY:t-this.headerHeight+(this.scrollable?this.virtualScrollTop:0),itemHeight:this.rowHeight,itemCount:this.data.length});this.dragRow.target=e;const i=this.dragRow.indicator;if(!e)return void i.setState({display:!1});const s=e.index*this.rowHeight+("after"===e.position?this.rowHeight:0);i.setState({display:!0,top:this.scrollable?s:this.headerHeight+s,left:0,width:this.scrollable?Number(this.bodyContent.state.width)||0:Number(this.state.width)||0})}__endRowDrag(t){const e=this.dragRow;if(e)if(this.dragRow=null,e.indicator&&e.indicator.setState({display:!1}),t&&e.target){const t=this.moveRow(e.from,e.target);this.trigger("rowdragend",null,{from:e.from,to:e.target,moved:t})}else this.trigger("rowdragend",null,{from:e.from,to:null,moved:!1})}__createResizeHandles(t,e,i){let s=i;e.forEach((i,o)=>{if(s+=i,o>=e.length-1)return;const n=new r({left:s-4,top:0,width:8,height:this.headerHeight,fill:!1,stroke:!1,style:{fillStyle:"rgba(0,0,0,0)"}});n.on("mousedown",t=>this.__startResize(o,t)),n.on("hoverchange",t=>{const e=R(t);n.setState({fill:e,style:{...n.state.style,fillStyle:e?"rgba(13,110,253,0.12)":"rgba(0,0,0,0)"}})}),t.addChild(n,!1)})}__startResize(t,e){const i=this.columns[t];if(!i||!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[s]=this.ice.screenToWorld(e.offsetX,e.offsetY);this.resizeState={key:i.key,index:t,startX:s,startWidth:this.getColumnWidths()[i.key]},this.trigger("columnresizestart",null,{key:i.key})}__onGlobalMouseMove(t){if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY);if(this.resizeState){const t=this.resizeState.startWidth+(e-this.resizeState.startX);this.setColumnWidth(this.resizeState.key,t)}else if(this.dragRow){const t=this.getMinBoundingBox(!0);this.__updateRowDrag(i-t.tl[1])}}__onGlobalMouseUp(){if(this.resizeState){const t=this.resizeState.key;this.resizeState=null,this.trigger("columnresizeend",null,{key:t,widths:this.getColumnWidths()})}this.dragRow&&this.__endRowDrag(!0)}__format(t){return null==t?"":String(t)}__syncSelection(){const t=h.getTheme();this.rowPanels.forEach((e,i)=>{const s="multiple"===this.selectionMode?-1!==this.selectedIndexes.indexOf(i):i===this.selectedIndex,o=i===this.hoveredIndex;e.setState({style:{fillStyle:s?t.colors.primaryBg:o?t.colors.disabled:i%2==0?t.colors.surface:t.colors.background}});const n=this.selectionNodes[i];n&&n.isSelected()!==s&&n.setSelected(s)}),this.revalidate()}__emitSelection(){const t=this.getSelectedRows(),e=this.getSelectedIndexes();this.trigger("selectionchange",null,{rows:t,indexes:e}),this.onSelectionChange&&this.onSelectionChange(t,e)}}function Qt(t,e=0,i=!1){const s="number"==typeof t?t:Number(t);if(!Number.isFinite(s))return String(t??"");const o=Math.max(0,Math.floor(Number(e)||0)),n=s.toFixed(o);if(!i)return n;const h=n.startsWith("-"),[r,l]=(h?n.slice(1):n).split(".");return`${h?"-":""}${r.replace(/\B(?=(\d{3})+(?!\d))/g,",")}${l?"."+l:""}`}function Jt(t){const e=Math.max(0,Math.floor(Number(t)||0)),i=Math.floor(e/1e3),s=Math.floor(i/86400),o=Math.floor(i%86400/3600),n=Math.floor(i%3600/60),h=i%60,r=t=>String(t).padStart(2,"0"),l=`${r(o)}:${r(n)}:${r(h)}`;return s>0?`${s} 天 ${l}`:l}class te extends r{constructor(t){const e=h.getTheme();super({left:t.left,top:t.top,width:t.width,height:t.height,fill:!1,stroke:!1,interactive:t.clickable,focusable:!1}),this.restColor=t.fillStyle,this.hoverColor=e.colors.primary,this.label=new H({interactive:!1,left:0,top:0,width:t.width,height:t.height,text:t.text,verticalAlign:"middle",style:{fontSize:t.fontSize,fontFamily:e.font.family,fontWeight:t.fontWeight,fillStyle:t.fillStyle}}),this.addChild(this.label,!1),this.textNode=this.label.childNodes[0]}getLabel(){return this.label}getText(){return this.label.getText()}__applyHoverState(){this.textNode&&(this.textNode.setState({style:{...this.textNode.state.style,fillStyle:this.hovered?this.hoverColor:this.restColor}}),this.revalidate())}}class ee extends r{active=!1;constructor(t={}){const e=h.getTheme();super({fill:!0,stroke:!1,radius:0,...t,style:{fillStyle:e.colors.border,...t.style||{}}})}setActive(t){return this.active===!!t||(this.active=!!t,this.__sync()),this}__applyHoverState(){this.__sync()}__sync(){const t=h.getTheme();this.setState({style:{...this.state.style,fillStyle:this.active||this.hovered?t.colors.primary:t.colors.border}})}}class ie{handle=null;mask=null;frame=null;image=null;buttons=new Map;index=0;zoom=1;rotation=0;bound=!1;pendingReason=null;constructor(t,e){this.ice=t,this.options=e,this.manager=e.manager||z(t),this.focus=e.focusManager||B(t),this.index=this.__clampIndex(Number(e.index)||0)}isOpen(){return!!this.handle&&this.handle.isOpen()}getIndex(){return this.index}getZoom(){return this.zoom}getRotation(){return this.rotation}getMask(){return this.mask}getFrame(){return this.frame}getImageNode(){return this.image}getToolbarButton(t){return this.buttons.get(t)||null}getImages(){return(this.options.images||[]).slice()}open(t){if(this.isOpen())return void 0!==t&&this.setIndex(t),this;void 0!==t&&(this.index=this.__clampIndex(Number(t)||0));const e=this.__visibleRect(),i=new O({left:0,top:0,width:e.width,height:e.height,radius:0,fill:!0,stroke:!1,style:{fillStyle:"rgba(0, 0, 0, 0.85)"}});i.on("click",()=>{!1!==this.options.maskClosable&&this.close("mask")});const s=Math.max(80,Math.min(.8*e.width,960)),o=Math.max(60,Math.min(.68*e.height,640)),n=new r({left:(e.width-s)/2,top:Math.max(24,(e.height-o)/2-24),width:s,height:o,fill:!1,stroke:!1,interactive:!1,clipChildren:!0}),h=new Ot({left:0,top:0,width:s,height:o,fit:"contain",src:this.__currentSrc(),placeholder:"rgba(0, 0, 0, 0)"});n.addChild(h,!1),this.frame=n,this.image=h,i.addChild(n,!1);const l=this.__createToolbar(e,n);i.addChild(l,!1),this.mask=i,this.handle=this.manager.open({centered:!0,blocking:!0,content:i,closeOnOutsideClick:!1,closeOnEsc:!1!==this.options.closeOnEsc,enterAnimation:"fade",onClose:t=>{const e=this.pendingReason||("esc"===t?"esc":"outside"===t?"mask":"api");this.pendingReason=null,this.__handleClosed(e)}}),this.focus.setFocusScope(n);const a=this.buttons.get("close");return a&&this.focus.focus(a),this.__bindKeyboard(),this.__syncImage(),this}close(t="api"){if(!this.handle||!this.handle.isOpen())return this;const e=this.handle;return this.pendingReason=t,this.handle=null,this.__unbindKeyboard(),e.close(),this}setIndex(t){const e=this.__clampIndex(t);return e===this.index||(this.index=e,this.__syncImage(),this.trigger("change",null,{index:e}),this.options.onIndexChange&&this.options.onIndexChange(e)),this}next(){const t=(this.options.images||[]).length;return t<=1?this:this.setIndex((this.index+1)%t)}prev(){const t=(this.options.images||[]).length;return t<=1?this:this.setIndex((this.index-1+t)%t)}zoomIn(){return this.__setZoom(this.zoom+this.__zoomStep())}zoomOut(){return this.__setZoom(this.zoom-this.__zoomStep())}rotateLeft(){return this.__setRotation(this.rotation-90)}rotateRight(){return this.__setRotation(this.rotation+90)}reset(){return this.zoom=1,this.rotation=0,this.__syncImage(),this.trigger("zoom",null,{zoom:this.zoom}),this.trigger("rotate",null,{rotation:this.rotation}),this}listeners=new Map;on(t,e){const i=this.listeners.get(t)||[];return i.push(e),this.listeners.set(t,i),this}off(t,e){const i=this.listeners.get(t)||[];return this.listeners.set(t,i.filter(t=>t!==e)),this}trigger(t,e,i){const s=void 0===i?e:{param:i,...e||{}};return(this.listeners.get(t)||[]).forEach(t=>t(s)),this}__clampIndex(t){const e=(this.options.images||[]).length;return e<=0?0:Math.max(0,Math.min(e-1,Math.floor(t)||0))}__currentSrc(){return(this.options.images||[])[this.index]||""}__zoomStep(){return Number(this.options.zoomStep)||.25}__setZoom(t){const e=Number(this.options.minZoom)||.25,i=Number(this.options.maxZoom)||3,s=Math.max(e,Math.min(i,Number(t.toFixed(4))));return s===this.zoom||(this.zoom=s,this.__syncImage(),this.trigger("zoom",null,{zoom:s})),this}__setRotation(t){const e=(Math.round(t)%360+360)%360;return e===this.rotation||(this.rotation=e,this.__syncImage(),this.trigger("rotate",null,{rotation:e})),this}__syncImage(){if(!this.frame||!this.image)return;const t=Number(this.frame.state.width)||0,e=Number(this.frame.state.height)||0,i=t*this.zoom,s=e*this.zoom;this.image.setState({src:this.__currentSrc(),left:(t-i)/2,top:(e-s)/2,width:i,height:s,transform:{...this.image.state.transform||{},rotate:this.rotation}}),this.ice&&(this.ice.dirty=!0)}__createToolbar(t,e){const i=h.getTheme(),s=[{name:"zoomOut",icon:"−",onClick:()=>this.zoomOut()},{name:"zoomIn",icon:"+",onClick:()=>this.zoomIn()},{name:"rotateLeft",icon:"↺",onClick:()=>this.rotateLeft()},{name:"rotateRight",icon:"↻",onClick:()=>this.rotateRight()},{name:"prev",icon:"‹",onClick:()=>this.prev()},{name:"next",icon:"›",onClick:()=>this.next()},{name:"close",icon:"✕",onClick:()=>this.close("close")}],o=36*s.length+8*(s.length-1),n=new r({left:Math.max(0,(t.width-o)/2),top:Number(e.state.top)+Number(e.state.height)+16,width:o,height:36,fill:!1,stroke:!1,interactive:!1});return this.buttons.clear(),s.forEach((t,e)=>{const s=new Y({left:44*e,top:0,width:36,height:36,text:t.icon,variant:(t.name,"default"),size:"small"});s.setState({radius:18,style:{...s.state.style,fillStyle:i.colors.elevated}}),s.on("click",t.onClick),n.addChild(s,!1),this.buttons.set(t.name,s)}),n}__bindKeyboard(){!this.bound&&this.ice&&this.ice.evtBus&&(this.bound=!0,this.ice.evtBus.on("keydown",this.__onKeyDown,this))}__unbindKeyboard(){this.bound&&this.ice&&this.ice.evtBus&&(this.bound=!1,this.ice.evtBus.off("keydown",this.__onKeyDown,this))}__onKeyDown(t){if(!this.isOpen())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);"ArrowRight"===i?this.next():"ArrowLeft"===i?this.prev():"+"===i||"="===i?this.zoomIn():"-"!==i&&"_"!==i||this.zoomOut()}__handleClosed(t){this.focus.setFocusScope(null),this.mask=null,this.frame=null,this.image=null,this.buttons.clear(),this.options.onClose&&this.options.onClose(t)}__visibleRect(){const t=Number(this.ice&&this.ice.canvasWidth)||0,e=Number(this.ice&&this.ice.canvasHeight)||0,i=this.ice&&"function"==typeof this.ice.getRenderViewport?this.ice.getRenderViewport():null,s=i&&i.scale?i.scale:1;return{left:i?-(i.tx||0)/s:0,top:i?-(i.ty||0)/s:0,width:t/s,height:e/s}}}function se(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function oe(t,e={}){const[i,s]=ne(t),o=e.weekStart??1,n=(new Date(i,s,1).getDay()-o+7)%7,h=new Date(i,s,1-n),r=[];for(let t=0;t<42;t+=1){const e=new Date(h.getFullYear(),h.getMonth(),h.getDate()+t);r.push({date:se(e),day:e.getDate(),inMonth:e.getMonth()===s&&e.getFullYear()===i})}return r}function ne(t){if(t instanceof Date)return[t.getFullYear(),t.getMonth()];const e=String(t??""),i=/^(\d{4})-(\d{2})/.exec(e);if(i)return[Number(i[1]),Number(i[2])-1];const s=new Date;return[s.getFullYear(),s.getMonth()]}function he(t,e){const[i,s]=ne(t),o=new Date(i,s+e,1);return`${o.getFullYear()}-${String(o.getMonth()+1).padStart(2,"0")}`}function re(t){if(t instanceof Date)return new Date(t.getFullYear(),t.getMonth(),t.getDate());const e=/^(\d{4})-(\d{2})-(\d{2})/.exec(String(t??""));return e?new Date(Number(e[1]),Number(e[2])-1,Number(e[3])):null}class le extends r{constructor(t){const e=h.getTheme();super({left:t.left,top:t.top,width:t.size,height:t.size-4,radius:3,fill:!0,stroke:!1,style:{fillStyle:"rgba(255,255,255,0.45)"}}),this.baseColor="rgba(255,255,255,0.45)",this.glyph=new H({interactive:!1,left:0,top:0,width:t.size,height:t.size-4,text:t.text,align:"center",verticalAlign:"middle",style:{fontSize:11,fontWeight:e.font.weightBold,fillStyle:"#0a246a"}}),this.addChild(this.glyph,!1),this.on("click",t.onClick)}__applyHoverState(){this.setState({style:{...this.state.style,fillStyle:this.hovered?"rgba(255,255,255,0.85)":this.baseColor}}),this.revalidate()}}const ae={titleActive:["#0058ee","#3f8cf3"],titleInactive:["#7f9db9","#a8c0dd"],titleText:"#ffffff",titleTextInactive:"#e9eef5",body:"#ece9d8",border:"#0054e3"};function de(t,e,i){const s=t=>[1,3,5].map(e=>parseInt(t.slice(e,e+2),16)),[o,n,h]=s(t),[r,l,a]=s(e),d=(t,e)=>Math.round(t+(e-t)*i),c=t=>t.toString(16).padStart(2,"0");return`#${c(d(o,r))}${c(d(n,l))}${c(d(h,a))}`}const ce={I:["....","XXXX","....","...."],O:["XX","XX"],T:[".X.","XXX","..."],S:[".XX","XX.","..."],Z:["XX.",".XX","..."],J:["X..","XXX","..."],L:["..X","XXX","..."]};function ue(t,e){const i=[];for(let s=0;s<e;s+=1){let o="";for(let i=0;i<e;i+=1)o+=t[e-1-i][s];i.push(o)}return i}function fe(t){const e=[];return t.forEach((t,i)=>{for(let s=0;s<t.length;s+=1)"X"===t[s]&&e.push([i,s])}),e}const ge=(()=>{const t={};return Object.keys(ce).forEach(e=>{const i=ce[e].length,s=[];let o=ce[e];for(let t=0;t<4;t+=1)s.push(fe(o)),o=ue(o,i);t[e]=s}),t})(),me=[0,100,300,500,800];const pe={up:[-1,0],right:[0,1],down:[1,0],left:[0,-1]},ye={up:"down",right:"left",down:"up",left:"right"};const _e=["up","right","down","left"];t.ICE2048Model=class{cells=[];score=0;moves=0;won=!1;gameOver=!1;paused=!1;lastMerged=[];listeners=new Set;constructor(t={}){this.rows=Math.max(2,Math.floor(t.rows??4)),this.cols=Math.max(2,Math.floor(t.cols??4)),this.random=t.random||Math.random,this.target=Math.max(4,Math.floor(t.target??2048)),this.spawnFourChance=Math.min(1,Math.max(0,void 0===t.spawnFourChance?.1:t.spawnFourChance)),this.spawnAfterMove=!1!==t.spawnAfterMove,this.__resetBoard()}getRows(){return this.rows}getCols(){return this.cols}getCells(){return this.cells.slice()}getCell(t,e){return t<0||t>=this.rows||e<0||e>=this.cols?null:this.cells[t*this.cols+e]}getScore(){return this.score}getMoves(){return this.moves}getTarget(){return this.target}getBestTile(){return this.cells.reduce((t,e)=>Math.max(t,Number(e)||0),0)}isWon(){return this.won}isGameOver(){return this.gameOver}isPaused(){return this.paused}getLastMerged(){return this.lastMerged.map(([t,e])=>[t,e])}pause(){this.paused||this.gameOver||(this.paused=!0,this.notify())}resume(){this.paused&&(this.paused=!1,this.notify())}canMove(){return!this.gameOver&&!this.paused&&_e.some(t=>this.__wouldMove(t))}addChangeListener(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}move(t){if(this.gameOver||this.paused||-1===_e.indexOf(t))return!1;const e=this.cells.slice();let i=0;const s=[];for(let e=0;e<this.__lineCount();e+=1){const o=this.__lineIndices(t,e),n=o.map(t=>this.cells[t]).filter(t=>null!==t),h=[];for(let t=0;t<n.length;t+=1)if(t+1<n.length&&n[t]===n[t+1]){const e=2*n[t],r=o[h.length];void 0!==r&&s.push([Math.floor(r/this.cols),r%this.cols]),h.push(e),i+=e,t+=1}else h.push(n[t]);o.forEach((t,e)=>{this.cells[t]=void 0===h[e]?null:h[e]})}return this.cells.some((t,i)=>t!==e[i])?(this.score+=i,this.moves+=1,this.lastMerged=s,!this.won&&this.getBestTile()>=this.target&&(this.won=!0),this.spawnAfterMove&&this.__spawnTile(),this.__refreshGameOver(),this.notify(),!0):(this.cells=e,!1)}reset(t={}){void 0!==t.rows&&(this.rows=Math.max(2,Math.floor(t.rows))),void 0!==t.cols&&(this.cols=Math.max(2,Math.floor(t.cols))),t.random&&(this.random=t.random),void 0!==t.target&&(this.target=Math.max(4,Math.floor(t.target))),void 0!==t.spawnFourChance&&(this.spawnFourChance=Math.min(1,Math.max(0,t.spawnFourChance))),void 0!==t.spawnAfterMove&&(this.spawnAfterMove=!1!==t.spawnAfterMove),this.__resetBoard(),this.notify()}setCellsForTest(t){const e=this.rows*this.cols;if(!t||t.length!==e)throw new Error(`ICE2048Model: setCellsForTest 需要 ${e} 个格子,实际 ${t?t.length:0} 个`);this.cells=t.map(t=>null==t?null:Number(t)),this.__refreshGameOver(),this.notify()}__resetBoard(){this.cells=new Array(this.rows*this.cols).fill(null),this.score=0,this.moves=0,this.won=!1,this.gameOver=!1,this.paused=!1,this.lastMerged=[],this.__spawnTile(),this.__spawnTile()}__spawnTile(){const t=[];if(this.cells.forEach((e,i)=>{null===e&&t.push(i)}),!t.length)return;const e=Math.min(t.length-1,Math.floor(this.random()*t.length)),i=this.random()<this.spawnFourChance?4:2;this.cells[t[Math.max(0,e)]]=i}__lineCount(){return Math.max(this.rows,this.cols)}__lineIndices(t,e){const i=[];if("left"===t||"right"===t){if(e>=this.rows)return[];for(let t=0;t<this.cols;t+=1)i.push(e*this.cols+t);return"left"===t?i:i.reverse()}if(e>=this.cols)return[];for(let t=0;t<this.rows;t+=1)i.push(t*this.cols+e);return"up"===t?i:i.reverse()}__wouldMove(t){const e=this.cells.slice();for(let e=0;e<this.__lineCount();e+=1){const i=this.__lineIndices(t,e),s=i.map(t=>this.cells[t]).filter(t=>null!==t),o=[];for(let t=0;t<s.length;t+=1)t+1<s.length&&s[t]===s[t+1]?(o.push(2*s[t]),t+=1):o.push(s[t]);i.forEach((t,e)=>{this.cells[t]=void 0===o[e]?null:o[e]})}const i=this.cells.some((t,i)=>t!==e[i]);return this.cells=e,i}__refreshGameOver(){if(this.cells.some(t=>null===t))this.gameOver=!1;else{for(let t=0;t<this.rows;t+=1)for(let e=0;e<this.cols;e+=1){const i=this.getCell(t,e);if(e+1<this.cols&&i===this.getCell(t,e+1))return void(this.gameOver=!1);if(t+1<this.rows&&i===this.getCell(t+1,e))return void(this.gameOver=!1)}this.gameOver=!0}}notify(){this.listeners.forEach(t=>t(this))}},t.ICEAlert=qt,t.ICEAnchor=class extends r{activeKey=null;itemNodes=[];labelNodes=[];barNodes=[];bound=!1;ignoreNextScroll=!1;constructor(t){const e=h.getTheme(),i=t.itemHeight??32;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:t.width??160,height:i*Math.max(1,(t.items||[]).length)}),this.focusable=!0,this.target=t.target||null,this.items=(t.items||[]).slice(),this.itemHeight=i,this.fontSize=t.fontSize??e.font.size,this.onChange="function"==typeof t.onChange?t.onChange:null,this.activeKey=t.activeKey??(this.items[0]?this.items[0].key:null),this.__render(),this.target&&"function"==typeof this.target.on&&this.target.on("scroll",()=>this.__syncFromScroll(),this)}getActiveKey(){return this.activeKey}getLabelTexts(){return this.labelNodes.map(t=>t.getText())}getItemNode(t){const e=this.items.findIndex(e=>e.key===t);return-1===e?null:this.itemNodes[e]}getLabelColor(t){const e=this.items.findIndex(e=>e.key===t),i=-1===e?null:this.labelNodes[e],s=i&&i.childNodes[0];return s?String(s.state.style.fillStyle):""}setActiveKey(t,e={}){const i=this.items.findIndex(e=>e.key===t);return-1===i||(this.activeKey=t,this.__syncActive(),e.scroll&&this.target&&"function"==typeof this.target.setScroll&&this.target.setScroll(0,this.items[i].top)),this}getItems(){return this.items.slice()}setItems(t){return this.items=(t||[]).slice(),this.activeKey=this.items[0]?this.items[0].key:null,this.__render(),this}afterAddHandler(){super.afterAddHandler(),!this.bound&&this.ice&&this.ice.evtBus&&(this.bound=!0,this.ice.evtBus.on("keydown",this.__onKeyDown,this))}__onKeyDown(t){if(!this.ice||!this.enabled||!this.isFocused())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code),s="ArrowDown"===i?1:"ArrowUp"===i?-1:0;if(!s)return;const o=this.items.findIndex(t=>t.key===this.activeKey),n=Math.min(this.items.length-1,Math.max(0,o+s));n!==o&&this.items[n]&&this.__select(this.items[n],!0)}__select(t,e){this.activeKey=t.key,this.__syncActive(),this.target&&"function"==typeof this.target.setScroll&&(e&&(this.ignoreNextScroll=!0),this.target.setScroll(0,t.top),e&&this.ignoreNextScroll&&(this.ignoreNextScroll=!1)),e&&(this.trigger("change",null,{key:t.key}),this.onChange&&this.onChange(t.key))}__syncFromScroll(){if(!this.target||"function"!=typeof this.target.getScroll||!this.items.length)return;if(this.ignoreNextScroll)return void(this.ignoreNextScroll=!1);const t=Number(this.target.getScroll()[1])||0;let e=this.items[0].key;for(const i of this.items)i.top<=t+1&&(e=i.key);e!==this.activeKey&&(this.activeKey=e,this.__syncActive())}__syncActive(){const t=h.getTheme();this.items.forEach((e,i)=>{const s=e.key===this.activeKey,o=this.barNodes[i],n=this.labelNodes[i];o&&o.setState({style:{...o.state.style,fillStyle:s?t.colors.primary:"rgba(0,0,0,0)"}});const h=n&&n.childNodes[0];h&&h.setState({style:{...h.state.style,fillStyle:s?t.colors.primary:t.colors.textSecondary}})}),this.revalidate(),this.ice&&(this.ice.dirty=!0)}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]),this.itemNodes=[],this.labelNodes=[],this.barNodes=[];const e=Number(this.state.width)||160;this.items.forEach((i,s)=>{const o=new r({left:0,top:s*this.itemHeight,width:e,height:this.itemHeight,fill:!1,stroke:!1,interactive:!0,focusable:!1}),n=new r({left:0,top:0,width:2,height:this.itemHeight,fill:!0,stroke:!1,style:{fillStyle:"rgba(0,0,0,0)"}}),h=new H({interactive:!1,left:t.spacing.sm,top:0,width:Math.max(0,e-t.spacing.sm),height:this.itemHeight,text:i.label,verticalAlign:"middle",style:{fontSize:this.fontSize,fontFamily:t.font.family,fillStyle:t.colors.textSecondary}});o.addChild(n,!1),o.addChild(h,!1),o.on("click",()=>this.__select(i,!0)),this.addChild(o,!1),this.itemNodes.push(o),this.labelNodes.push(h),this.barNodes.push(n)}),this.state.height=this.itemHeight*Math.max(1,this.items.length),this.__syncActive()}},t.ICEAutoComplete=class extends r{handle=null;panel=null;visibleOptions=[];optionNodes=new Map;activeIndex=0;running=!1;__panelBound=!1;constructor(t){const e=h.getTheme(),i=t.width??200,s=t.height??e.control.height;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:i,height:s}),this.allOptions=(t.options||[]).slice(),this.optionHeight=t.optionHeight??32,this.manager=t.manager||null,this.onSelectCallback="function"==typeof t.onSelect?t.onSelect:null,this.onChangeCallback="function"==typeof t.onChange?t.onChange:null,this.field=new kt({left:0,top:0,width:i,height:s,value:t.value??"",placeholder:t.placeholder??""}),this.field.on("click",t=>this.__onAnchorClick(t)),this.field.on("change",()=>{this.__refresh(this.field.getValue()),this.onChangeCallback&&this.onChangeCallback(this.field.getValue())}),this.addChild(this.field,!1),this.focusable=!0,this.focusRingMode="always"}afterAddHandler(){super.afterAddHandler(),this.running||(!this.manager&&this.ice&&(this.manager=z(this.ice)),this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this)),this.running=!0)}getValue(){return this.field.getValue()}setValue(t){const e=String(t??"");return this.field.setValue(e),this.__refresh(e),this}getFormValue(){return this.getValue()}setFormValue(t){this.setValue(String(t??""))}getFieldText(){return this.field.getFieldText()}setValidateStatus(t){return this.field.setValidateStatus(t),this}getValidateStatus(){return this.field.getValidateStatus()}isOpen(){return!!this.handle&&this.handle.isOpen()}getVisibleOptions(){return this.visibleOptions.slice()}getActiveIndex(){return this.activeIndex}getOptionNode(t){return this.optionNodes.get(t)||null}getPanel(){return this.panel}activate(){this.__refresh(this.getValue())}__overlayManager(){if(!this.manager){if(!this.ice)throw new Error("ICEAutoComplete 需要先加入 ICE 场景");this.manager=z(this.ice)}return this.manager}__refresh(t){const e=String(t??"").trim().toLowerCase();this.visibleOptions=this.allOptions.filter(t=>!e||-1!==t.toLowerCase().indexOf(e)),this.activeIndex=0,this.visibleOptions.length?(this.isOpen()||(this.panel=this.__createPanel(),this.__panelBound=!1,this.handle=this.__overlayManager().open({anchor:this,content:this.panel,placement:"bottomLeft",offset:4,enterAnimation:"scale",exitAnimation:"fade",keyboardCaptured:!0,closeOnOutsideClick:!1})),this.__buildOptions()):this.close()}close(){return this.handle&&(this.handle.close(),this.handle=null),this.panel=null,this.optionNodes.clear(),this}__onAnchorClick(t){if(!this.isOpen()||!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=this.__worldBox(this.panel);if(e<s.left||e>s.left+s.width||i<s.top||i>s.top+s.height)return;const o=Math.floor((i-s.top-4)/this.optionHeight),n=this.visibleOptions[o];n&&this.__pick(n)}__onGlobalMouseDown(t){if(!this.isOpen()||!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=t=>e>=t.left&&e<=t.left+t.width&&i>=t.top&&i<=t.top+t.height;s(this.__worldBox(this))||s(this.__worldBox(this.panel))||this.close()}__onKeyDown(t){if(!this.isOpen())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if("Escape"!==i){if("ArrowDown"===i||"ArrowUp"===i){const t="ArrowDown"===i?1:-1;return this.activeIndex=(this.activeIndex+t+this.visibleOptions.length)%this.visibleOptions.length,void this.__buildOptions()}if("Enter"===i){const t=this.visibleOptions[this.activeIndex];t&&this.__pick(t)}}else this.close()}__onPanelClick(t){if(!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;const e=this.__worldBox(this.panel),i=Math.floor((t.offsetY-e.top-4)/this.optionHeight),s=this.visibleOptions[i];s&&this.__pick(s)}__worldBox(t){let e=0,i=0,s=t;for(;s&&s.state;)e+=Number(s.state.left)||0,i+=Number(s.state.top)||0,s=s.parentNode;return{left:e,top:i,width:Number(t&&t.state&&t.state.width)||0,height:Number(t&&t.state&&t.state.height)||0}}__pick(t){this.field.setValue(t),this.close(),this.onSelectCallback&&this.onSelectCallback(t)}__createPanel(){const t=h.getTheme(),e=Number(this.state.width)||200;return new O({width:e,height:Math.min(6,this.visibleOptions.length)*this.optionHeight+8,radius:t.radius.md,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"md"}})}__buildOptions(){const t=this.panel;if(!t)return;const e=h.getTheme();t.removeChildren([...t.childNodes]),this.optionNodes.clear();const i=Number(t.state.width)||Number(this.state.width)||200,s=Math.min(6,this.visibleOptions.length)*this.optionHeight,o=new _t({left:4,top:4,width:i-8,height:s,fill:!1,stroke:!1,style:{fillStyle:"rgba(0,0,0,0)",strokeStyle:"rgba(0,0,0,0)"}}),n=new r({left:0,top:0,width:i-8,height:Math.max(s,this.visibleOptions.length*this.optionHeight),fill:!1,stroke:!1});if(this.visibleOptions.forEach((t,s)=>{const o=s===this.activeIndex,h=new r({left:0,top:s*this.optionHeight,width:i-8,height:this.optionHeight,radius:e.radius.sm,fill:!0,stroke:!1,style:{fillStyle:o?e.colors.background:"rgba(0,0,0,0)"}});h.setState({interactive:!0}),h.on("click",()=>this.__pick(t)),h.addChild(new H({interactive:!1,left:10,top:0,height:this.optionHeight,verticalAlign:"middle",text:t,style:{fontSize:13,fillStyle:e.colors.text}}),!1),n.addChild(h,!1),this.optionNodes.set(t,h)}),o.setContent(n),t.addChild(o,!1),this.activeIndex>=0){const t=this.activeIndex*this.optionHeight;(t<o.getScroll()[1]||t+this.optionHeight>o.getScroll()[1]+s)&&o.setScroll(0,Math.max(0,t-(s-this.optionHeight)/2))}t.setState({height:s+8}),t.setState({interactive:!0}),this.__panelBound||(t.on("click",t=>this.__onPanelClick(t)),this.__panelBound=!0),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}},t.ICEAvatar=Ft,t.ICEAvatarGroup=class extends r{avatarNodes=[];restNode=null;constructor(t){const e=Number(t.size)||32;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:0,height:e}),this.avatars=(t.avatars||[]).slice(),this.size=e,this.max=Math.max(0,Number(t.max??4)),this.overlap=void 0===t.overlap?Math.round(e/4):Math.max(0,Number(t.overlap)),this.__render()}getCount(){return this.avatars.length}getVisibleCount(){return Math.min(this.max,this.avatars.length)}getRestCount(){return Math.max(0,this.avatars.length-this.getVisibleCount())}getAvatarNodes(){return this.avatarNodes.slice()}getRestNode(){return this.restNode}setAvatars(t){return this.avatars=(t||[]).slice(),this.__render(),this}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]),this.avatarNodes=[],this.restNode=null;const e=this.getVisibleCount(),i=this.getRestCount(),s=this.size-this.overlap,o=e+(i>0?1:0);if(this.avatars.slice(0,e).forEach((t,e)=>{const i=new Ft({left:e*s,top:0,size:this.size,text:t.text,backgroundColor:t.backgroundColor});this.addChild(i,!1),this.avatarNodes.push(i)}),i>0){const o=new Ft({left:e*s,top:0,size:this.size,text:"+"+i,backgroundColor:t.colors.borderSecondary});this.addChild(o,!1),this.restNode=o}this.setState({width:0===o?0:(o-1)*s+this.size,height:0===o?0:this.size}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}},t.ICEBackTop=class extends r{visible=!1;constructor(t){const e=h.getTheme(),i=t.size??36;super({id:t.id,fill:!0,stroke:!1,radius:i/2,interactive:!0,left:t.left,top:t.top,width:i,height:i,opacity:0,style:{fillStyle:e.colors.primary,...e.shadows.md}}),this.focusable=!0,this.target=t.target||null,this.visibilityHeight=Number(t.visibilityHeight)||200,this.onClick="function"==typeof t.onClick?t.onClick:null,this.iconNode=L(t.icon??"↑",e,i,i,{fontSize:Math.round(.5*i),fillStyle:e.colors.primaryText}),this.addChild(this.iconNode,!1),this.on("click",()=>this.__click()),this.target&&"function"==typeof this.target.on&&this.target.on("scroll",()=>this.__syncVisibility(),this),this.__syncVisibility()}isVisible(){return this.visible}getButtonColor(){return String(this.state.style.fillStyle)}setTarget(t){return this.target=t||null,this.__syncVisibility(),this}__applyHoverState(){const t=h.getTheme();this.setState({style:{...this.state.style,fillStyle:this.hovered?t.colors.primaryHover:t.colors.primary}}),this.revalidate()}__click(){this.visible&&this.enabled&&(this.target&&"function"==typeof this.target.setScroll&&this.target.setScroll(0,0),this.onClick&&this.onClick(),this.__syncVisibility())}__syncVisibility(){const t=this.target&&"function"==typeof this.target.getScroll?this.target.getScroll():[0,0],e=(Number(t&&t[1])||0)>this.visibilityHeight;e!==this.visible&&(this.visible=e,this.setState({opacity:e?1:0}),this.revalidate())}},t.ICEBadge=at,t.ICEBoundedRangeModel=Kt,t.ICEBreadcrumb=class extends r{userExpanded=!1;collapsed=!1;itemNodes=[];separatorNodes=[];constructor(t){const e=h.getTheme();super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:t.width??100,height:t.height??24}),this.items=(t.items||[]).slice(),this.separator=t.separator??"›",this.maxItems=Number(t.maxItems)||0,this.fontSize=t.fontSize??e.font.size,this.onNavigate="function"==typeof t.onNavigate?t.onNavigate:null,this.__render(void 0!==t.width)}getLabelTexts(){return this.itemNodes.map(t=>t.getText())}getItemNodes(){return this.itemNodes.slice()}getSeparatorNodes(){return this.separatorNodes.slice()}getItems(){return this.items.slice()}isCollapsed(){return this.collapsed}expand(){return this.collapsed?(this.userExpanded=!0,this.collapsed=!1,this.__render(!0),this):this}setItems(t){return this.items=(t||[]).slice(),this.userExpanded=!1,this.__render(!0),this}__displayed(){const t=this.items;if(!(this.maxItems>0&&t.length>this.maxItems&&!this.userExpanded))return t.map((t,e)=>({item:t,index:e}));const e=t.slice(t.length-(this.maxItems-1)),i=t.length-e.length;return this.collapsed=!0,[{item:t[0],index:0},{item:{label:"…"},index:1,ellipsis:!0},...e.map((t,e)=>({item:t,index:i+e}))]}__render(t){const e=h.getTheme();this.removeChildren([...this.childNodes]),this.itemNodes=[],this.separatorNodes=[],this.collapsed=!1;const i=this.__displayed(),s=Number(this.state.height)||24,o=e.spacing.xs,n=F(this.separator,this.fontSize);let r=0;i.forEach((t,h)=>{const l=h===i.length-1,a=!t.ellipsis&&t.index===this.items.length-1&&l,d=!t.ellipsis&&!!t.item.disabled,c=String(t.item.label??""),u=F(c,this.fontSize),f=new te({left:r,top:0,width:u,height:s,text:c,fontSize:this.fontSize,fillStyle:d?e.colors.textDisabled:a?e.colors.text:e.colors.textSecondary,fontWeight:a?e.font.weightSemibold:e.font.weightNormal,clickable:!a&&!d});if(t.ellipsis?(f.on("click",()=>this.expand()),f.on("mousedown",()=>this.expand())):a||d||(f.on("click",()=>this.__navigate(t.item,t.index)),f.on("mousedown",()=>this.__navigate(t.item,t.index))),this.addChild(f,!1),this.itemNodes.push(f),r+=u,!l){const t=new H({interactive:!1,left:r+o,top:0,width:n,height:s,text:this.separator,verticalAlign:"middle",style:{fontSize:this.fontSize,fontFamily:e.font.family,fillStyle:e.colors.textTertiary}});this.addChild(t,!1),this.separatorNodes.push(t),r+=2*o+n}}),this.state.width=t?Math.max(Number(this.state.width)||0,r):r,this.revalidate(),this.ice&&(this.ice.dirty=!0)}__navigate(t,e){this.trigger("navigate",null,{item:t,index:e}),this.onNavigate&&this.onNavigate(t,e)}},t.ICEButton=Y,t.ICEButtonModel=class{listeners=new Set;constructor(t={}){this.enabled=!1!==t.enabled,this.pressed=!1}isEnabled(){return this.enabled}setEnabled(t){return this.enabled=!!t,this.__notify(),this}isPressed(){return this.pressed}setPressed(t){return this.pressed=!!t,this.__notify(),this}addChangeListener(t){return this.listeners.add(t),this}removeChangeListener(t){return this.listeners.delete(t),this}__notify(){this.listeners.forEach(t=>t(this))}},t.ICECalendar=class extends r{value=null;headerHeight=40;weekHeight=24;titleNode=null;weekdayNodes=[];cellNodes=[];cellLabels=new Map;cellNodeMap=new Map;bound=!1;constructor(t={}){const e=h.getTheme(),i=t.width??280,s=Math.round(Math.min(40,Math.max(28,(i-16)/7/1.4))),o=re(t.value),n=t.month??(o?se(o).slice(0,7):se(new Date).slice(0,7)),r=t.today??se(new Date),l=t.height??6*s+64;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:i,height:l,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.focusable=!0,this.value=o?se(o):null,this.visibleMonth=n,this.today=r,this.cellHeight=s,this.onSelect="function"==typeof t.onSelect?t.onSelect:null,this.onChangeMonth="function"==typeof t.onChangeMonth?t.onChangeMonth:null,this.__render()}getValue(){return this.value}setValue(t,e={}){const i=re(t);if(!i)return this;const s=se(i);return s===this.value||(this.value=s,this.visibleMonth=s.slice(0,7),this.__render(),e.silent||(this.trigger("select",null,{date:s}),this.onSelect&&this.onSelect(s))),this}getFormValue(){return this.value}setFormValue(t){if(null==t||""===t)return this.value=null,void this.__render();this.setValue(t,{silent:!0})}getVisibleMonth(){return this.visibleMonth}setVisibleMonth(t,e={}){const i=`${ne(t)[0]}-${String(ne(t)[1]+1).padStart(2,"0")}`;return i===this.visibleMonth||(this.visibleMonth=i,this.__render(),e.silent||(this.trigger("changeMonth",null,{month:i}),this.onChangeMonth&&this.onChangeMonth(i))),this}prevMonth(){return this.setVisibleMonth(he(this.visibleMonth,-1))}nextMonth(){return this.setVisibleMonth(he(this.visibleMonth,1))}getTitleText(){return this.titleNode?this.titleNode.getText():""}getWeekdayTexts(){return this.weekdayNodes.map(t=>t.getText())}getCellNodes(){return this.cellNodes.slice()}getCellNode(t){return this.cellNodeMap.get(t)||null}getCellBackground(t){const e=this.cellNodeMap.get(t);return e?String(e.state.style.fillStyle):""}getCellTextColor(t){const e=this.cellLabels.get(t),i=e&&e.childNodes[0];return i?String(i.state.style.fillStyle):""}isToday(t){return t===this.today}selectDate(t){const e=re(t);return e?(this.value=se(e),this.visibleMonth=this.value.slice(0,7),this.__render(),this):this}getPrevButton(){return this.prevButton||null}getNextButton(){return this.nextButton||null}afterAddHandler(){super.afterAddHandler(),!this.bound&&this.ice&&this.ice.evtBus&&(this.bound=!0,this.ice.evtBus.on("keydown",this.__onKeyDown,this))}__shiftSelected(t){const e=re(this.value)||re(this.visibleMonth+"-01")||new Date,i=new Date(e.getFullYear(),e.getMonth(),e.getDate()+t);this.setValue(se(i))}__onKeyDown(t){if(!this.ice||!this.enabled||!this.isFocused())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if("ArrowLeft"===i)this.__shiftSelected(-1);else if("ArrowRight"===i)this.__shiftSelected(1);else if("ArrowUp"===i)this.__shiftSelected(-7);else if("ArrowDown"===i)this.__shiftSelected(7);else if("PageUp"===i){const t=re(this.value)||re(this.visibleMonth+"-01")||new Date;this.setValue(se(new Date(t.getFullYear(),t.getMonth()-1,t.getDate())))}else if("PageDown"===i){const t=re(this.value)||re(this.visibleMonth+"-01")||new Date;this.setValue(se(new Date(t.getFullYear(),t.getMonth()+1,t.getDate())))}}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]),this.weekdayNodes=[],this.cellNodes=[],this.cellLabels=new Map,this.cellNodeMap=new Map;const e=Number(this.state.width)||280,[i,s]=ne(this.visibleMonth),o=e-16,n=o/7,l=new r({left:8,top:8,width:28,height:28,fill:!1,stroke:!1});l.addChild(new H({interactive:!1,left:0,top:0,width:28,height:28,text:"‹",align:"center",verticalAlign:"middle",style:{fontSize:16,fillStyle:t.colors.textSecondary}}),!1),l.on("click",()=>this.prevMonth());const a=new r({left:e-8-28,top:8,width:28,height:28,fill:!1,stroke:!1});a.addChild(new H({interactive:!1,left:0,top:0,width:28,height:28,text:"›",align:"center",verticalAlign:"middle",style:{fontSize:16,fillStyle:t.colors.textSecondary}}),!1),a.on("click",()=>this.nextMonth()),this.prevButton=l,this.nextButton=a,this.titleNode=new H({interactive:!1,left:40,top:8,width:o-64,height:28,text:`${i} 年 ${s+1} 月`,align:"center",verticalAlign:"middle",style:{fontSize:14,fontWeight:t.font.weightSemibold,fillStyle:t.colors.text}}),this.addChild(l,!1),this.addChild(this.titleNode,!1),this.addChild(a,!1);["一","二","三","四","五","六","日"].forEach((e,i)=>{const s=new H({interactive:!1,left:8+i*n,top:this.headerHeight,width:n,height:this.weekHeight,text:e,align:"center",verticalAlign:"middle",style:{fontSize:12,fillStyle:t.colors.textTertiary}});this.addChild(s,!1),this.weekdayNodes.push(s)});oe(this.visibleMonth).forEach((e,i)=>{const s=Math.floor(i/7),o=i%7,h=e.date===this.value,l=e.date===this.today,a=new r({left:8+o*n,top:this.headerHeight+this.weekHeight+s*this.cellHeight,width:n,height:this.cellHeight,fill:h,stroke:l&&!h,radius:t.radius.sm,style:{fillStyle:h?t.colors.primary:"rgba(0,0,0,0)",strokeStyle:t.colors.primary,lineWidth:1}}),d=new H({interactive:!1,left:0,top:0,width:n,height:this.cellHeight,text:String(e.day),align:"center",verticalAlign:"middle",style:{fontSize:13,fillStyle:h?t.colors.primaryText:e.inMonth?t.colors.text:t.colors.textDisabled}});a.addChild(d,!1),a.on("click",()=>this.setValue(e.date)),this.addChild(a,!1),this.cellNodes.push(a),this.cellLabels.set(e.date,d),this.cellNodeMap.set(e.date,a)}),this.revalidate(),this.ice&&(this.ice.dirty=!0)}},t.ICECard=class extends O{extraNode=null;constructor(t={}){const{extra:e,...i}=t;super({...i,style:{shadow:"md",...t.style||{}}});const s=h.getTheme();t.title&&(this.titleNode=V({left:t.paddingLeft??s.spacing.md,top:t.paddingTop??s.spacing.sm,text:t.title,fillStyle:s.colors.text,fontFamily:s.font.family,fontSize:s.font.sizeLarge,fontWeight:s.font.weightSemibold}),this.addChild(this.titleNode,!1)),e&&this.setExtra(e)}setTitle(t){return this.titleNode?(this.titleNode.setText(t),this.revalidate(),this):this}setExtra(t){const e=h.getTheme();if(this.extraNode&&(this.removeChild(this.extraNode),this.extraNode=null),!t)return this.revalidate(),this;const i="function"==typeof t?t():t,s=Number(this.state.width)||0,o=Number(i.state&&i.state.width)||0,n=Number(this.titleNode?this.titleNode.state.top:e.spacing.sm);return i.setState({left:s-e.spacing.md-o,top:n}),this.addChild(i,!1),this.__raiseSubtree(i,(Number(this.state.zIndex)||0)+1),this.extraNode=i,this.revalidate(),this}getExtraNode(){return this.extraNode}getTitleNode(){return this.titleNode}__raiseSubtree(t,e){t&&t.state&&(t.state.zIndex=e,(t.childNodes||[]).forEach(t=>this.__raiseSubtree(t,e)))}},t.ICECarousel=class extends r{index=0;viewport=null;track=null;prevButton=null;nextButton=null;dots=[];tweenHandle=null;timer=null;running=!1;constructor(t={}){const e=h.getTheme();super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:t.width??320,height:t.height??180,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border}}),this.slides=(t.slides||[]).slice(),this.loop=!1!==t.loop,this.duration=t.duration??260,this.autoplayMs=Math.max(0,Number(t.autoplay)||0),this.showArrows=!1!==t.arrows,this.showDots=!1!==t.dots,this.driver=t.driver,this.scheduler=t.scheduler||Tt,this.onChangeCallback="function"==typeof t.onChange?t.onChange:null,this.index=this.__clampIndex(Number(t.initialIndex)||0),this.focusable=!0,this.__render()}afterAddHandler(){super.afterAddHandler(),this.autoplayMs>0&&this.play(),!this.running&&this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.running=!0)}getCount(){return this.slides.length}getIndex(){return this.index}setSlides(t){return this.slides=(t||[]).slice(),this.index=this.__clampIndex(this.index),this.__render(),this}getSlideNode(t){return this.slides[t]||null}getTrackNode(){return this.track}getPrevButton(){return this.prevButton}getNextButton(){return this.nextButton}getDotNode(t){return this.dots[t]||null}isPlaying(){return null!==this.timer}play(){return this.autoplayMs<=0||null!==this.timer||this.slides.length<=1||(this.timer=this.scheduler.setInterval(()=>this.next(),this.autoplayMs)),this}pause(){return null!==this.timer&&(this.scheduler.clearInterval(this.timer),this.timer=null),this}setAutoplay(t){const e=this.isPlaying();return this.pause(),this.autoplayMs=Math.max(0,Number(t)||0),e&&this.play(),this}goTo(t,e=!0){if(!this.slides.length)return this.index=0,this;const i=this.__clampIndex(t);return i===this.index?(this.__updateControls(),this):(this.index=i,this.__moveTrack(e),this.__updateControls(),this.onChangeCallback&&this.onChangeCallback(i),this)}next(){return this.goTo(this.index+1)}prev(){return this.goTo(this.index-1)}activate(){}__clampIndex(t){const e=this.slides.length;if(!e)return 0;const i=Math.floor(Number(t)||0);return this.loop?(i%e+e)%e:Math.min(e-1,Math.max(0,i))}__onKeyDown(t){if(!this.isFocused())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);"ArrowRight"===i?this.next():"ArrowLeft"===i&&this.prev()}__moveTrack(t){const e=this.track;if(!e)return;const i=Number(this.state.width)||320,s=0===this.index?0:-this.index*i;this.tweenHandle&&(this.tweenHandle.cancel(),this.tweenHandle=null),!t||this.duration<=0?e.setState({left:s}):this.tweenHandle=_({from:Number(e.state.left)||0,to:s,duration:this.duration,driver:this.driver,onUpdate:t=>e.setState({left:t}),onFinish:()=>{this.tweenHandle=null,e.setState({left:s})}})}__updateControls(){const t=h.getTheme();this.dots.forEach((e,i)=>{const s=i===this.index;e.setState({style:{...e.state.style,fillStyle:s?t.colors.primary:t.colors.borderSecondary}})});const e=this.slides.length>1;this.prevButton&&this.prevButton.setState({display:this.showArrows&&e}),this.nextButton&&this.nextButton.setState({display:this.showArrows&&e})}__render(){const t=h.getTheme(),e=Number(this.state.width)||320,i=Number(this.state.height)||180;this.removeChildren([...this.childNodes]),this.dots=[],this.tweenHandle=null;const s=(Number(this.state.zIndex)||0)+1,o=new r({left:0,top:0,width:e,height:i,fill:!1,stroke:!1,interactive:!1,clipChildren:!0}),n=new r({left:0===this.index?0:-this.index*e,top:0,width:Math.max(e,this.slides.length*e),height:i,fill:!1,stroke:!1,interactive:!1});if(this.slides.forEach((t,s)=>{t.setState({left:s*e,top:0,width:e,height:i}),n.addChild(t,!1)}),o.addChild(n,!1),this.addChild(o,!1),this.viewport=o,this.track=n,this.__raiseSubtree(o,s),this.showArrows&&this.slides.length>1){const t=this.__makeArrow("‹",8);t.on("click",()=>this.prev());const i=this.__makeArrow("›",e-8-26);i.on("click",()=>this.next()),this.prevButton=t,this.nextButton=i,this.addChild(t,!1),this.addChild(i,!1),this.__raiseSubtree(t,s+1),this.__raiseSubtree(i,s+1)}else this.prevButton=null,this.nextButton=null;if(this.showDots&&this.slides.length>1){const o=8*this.slides.length+10*(this.slides.length-1),n=(e-o)/2;this.slides.forEach((e,o)=>{const h=new r({left:n+18*o,top:i-8-10,width:8,height:8,radius:4,fill:!0,stroke:!1,style:{fillStyle:o===this.index?t.colors.primary:t.colors.borderSecondary}});h.on("click",()=>this.goTo(o)),this.addChild(h,!1),this.__raiseSubtree(h,s+2),this.dots.push(h)})}const l=new r({left:0,top:0,width:e,height:i,radius:t.radius.md,fill:!1,stroke:!0,interactive:!1,style:{strokeStyle:t.colors.border}});this.addChild(l,!1),this.__raiseSubtree(l,s+3),this.__updateControls(),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}__makeArrow(t,e){const i=h.getTheme(),s=new r({left:e,top:(Number(this.state.height)||180)/2-17,width:26,height:34,radius:i.radius.sm,fill:!0,stroke:!1,style:{fillStyle:"rgba(255, 255, 255, 0.82)"}});return s.addChild(new H({interactive:!1,left:0,top:0,width:26,height:34,align:"center",verticalAlign:"middle",text:t,style:{fontSize:16,fillStyle:i.colors.text}}),!1),s}__raiseSubtree(t,e){t&&t.state&&(t.state.zIndex=e,(t.childNodes||[]).forEach(t=>this.__raiseSubtree(t,e)))}},t.ICECascader=class extends r{handle=null;panel=null;fieldLabel=null;columns=[];optionNodes=new Map;activePath=[];running=!1;constructor(t){const e=h.getTheme(),i=t.width??220,s=t.height??e.control.height;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:i,height:s,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.options=(t.options||[]).slice(),this.value=void 0===t.value||null===t.value?void 0:String(t.value),this.placeholder=t.placeholder||"",this.disabled=!0===t.disabled,this.separator=t.separator??" / ",this.placement=t.placement||"bottomLeft",this.manager=t.manager||null,this.onChangeCallback="function"==typeof t.onChange?t.onChange:null,this.focusable=!this.disabled,this.focusRingMode="always",this.activePath=this.__findPath(this.value),this.__syncField()}afterAddHandler(){super.afterAddHandler(),this.running||(!this.manager&&this.ice&&(this.manager=z(this.ice)),this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this)),this.on("click",this.__onClick,this),this.running=!0)}getValue(){return this.value}setValue(t){return this.value=null==t||""===t?void 0:String(t),this.activePath=this.__findPath(this.value),this.__syncField(),this.isOpen()&&this.__renderPanel(),this}getFormValue(){return this.value}setFormValue(t){this.setValue(t)}getPath(){return this.__findPath(this.value)}getFieldLabel(){return this.fieldLabel?this.fieldLabel.getText():""}isOpen(){return!!this.handle&&this.handle.isOpen()}getPanel(){return this.panel}getColumnNodes(){return this.columns.slice()}getColumnNode(t){return this.columns[t]||null}getOptionNode(t,e){return this.optionNodes.get(`${t}:${e}`)||null}activate(){this.toggle()}toggle(){return this.isOpen()?this.close():this.open()}open(){if(this.disabled||this.isOpen())return this;if(!this.manager){if(!this.ice)throw new Error("ICECascader 需要先加入 ICE 场景");this.manager=z(this.ice)}this.activePath=this.__findPath(this.value);const t=h.getTheme(),e=new O({width:12+104*Math.max(1,this.__maxDepth()),height:12+30*Math.max(1,this.__maxRows()),radius:t.radius.md,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"md"}});return this.panel=e,this.__renderPanel(),this.handle=this.manager.open({anchor:this,content:e,placement:this.placement,offset:4,enterAnimation:"scale",exitAnimation:"fade",keyboardCaptured:!0,closeOnOutsideClick:!1}),this}close(){return this.handle&&(this.handle.close(),this.handle=null),this.panel=null,this.columns=[],this.optionNodes.clear(),this}__applyValidateState(){this.__syncField()}__findPath(t){if(void 0===t)return[];const e=(i,s)=>{for(const o of i){const i=s.concat(o);if(o.value===t)return i;if(o.children&&o.children.length){const t=e(o.children,i);if(t)return t}}return null};return e(this.options,[])||[]}__maxDepth(){const t=e=>{let i=1;for(const s of e)s.children&&s.children.length&&(i=Math.max(i,1+t(s.children)));return i};return this.options.length?t(this.options):1}__maxRows(){const t=e=>{let i=e.length;for(const s of e)s.children&&s.children.length&&(i=Math.max(i,t(s.children)));return i};return this.options.length?Math.min(6,t(this.options)):1}__pick(t,e){if(t.disabled)return;if(this.activePath=this.activePath.slice(0,e).concat(t),t.children&&t.children.length)return void this.__renderPanel();this.value=t.value,this.__syncField();const i=this.activePath.slice();this.close(),this.onChangeCallback&&this.onChangeCallback(t.value,i)}__onClick(){this.disabled||this.toggle()}__onKeyDown(t){if(!this.isOpen())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);"Escape"!==i&&"Esc"!==i||this.close()}__onGlobalMouseDown(t){if(!this.isOpen()||!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=t=>e>=t.left&&e<=t.left+t.width&&i>=t.top&&i<=t.top+t.height;s(this.__worldBox(this))||s(this.__worldBox(this.panel))||this.close()}__worldBox(t){let e=0,i=0,s=t;for(;s&&s.state;)e+=Number(s.state.left)||0,i+=Number(s.state.top)||0,s=s.parentNode;return{left:e,top:i,width:Number(t&&t.state&&t.state.width)||0,height:Number(t&&t.state&&t.state.height)||0}}__syncField(){const t=h.getTheme(),e=Number(this.state.width)||220,i=Number(this.state.height)||32,s="error"===this.validateStatus?t.colors.error:t.colors.border;this.setState({style:{...this.state.style,fillStyle:this.disabled?t.colors.disabled:t.colors.surface,strokeStyle:s}}),this.removeChildren([...this.childNodes]);const o=this.getPath(),n=o.length?o.map(t=>t.label).join(this.separator):this.placeholder;this.fieldLabel=new H({interactive:!1,left:10,top:0,width:Math.max(0,e-34),height:i,verticalAlign:"middle",text:n,style:{fontSize:13,fillStyle:o.length?t.colors.text:t.colors.textTertiary}}),this.addChild(this.fieldLabel,!1),this.addChild(new H({interactive:!1,left:e-22,top:0,width:14,height:i,align:"center",verticalAlign:"middle",text:"▾",style:{fontSize:12,fillStyle:t.colors.textTertiary}}),!1)}__renderPanel(){const t=this.panel;if(!t)return;const e=h.getTheme();t.removeChildren([...t.childNodes]),this.columns=[],this.optionNodes.clear();const i=30*Math.max(1,this.__maxRows()),s=[this.options];for(const t of this.activePath){if(!t.children||!t.children.length)break;s.push(t.children)}s.forEach((s,o)=>{const n=new _t({left:6+104*o,top:6,width:104,height:i,fill:!1,stroke:!1,style:{fillStyle:"transparent",strokeStyle:"transparent"}}),h=new r({width:104,height:Math.max(i,30*s.length),fill:!1,stroke:!1}),l=this.activePath[o];s.forEach((t,i)=>{const s=!!l&&l.value===t.value,n=new r({left:0,top:30*i,width:104,height:30,radius:e.radius.sm,fill:!0,stroke:!1,style:{fillStyle:s?e.colors.primaryBg:"transparent"}});n.addChild(new H({interactive:!1,left:8,top:0,width:78,height:30,verticalAlign:"middle",text:t.label,style:{fontSize:13,fillStyle:t.disabled?e.colors.textDisabled:s?e.colors.primary:e.colors.text}}),!1),t.children&&t.children.length&&n.addChild(new H({interactive:!1,left:86,top:0,width:12,height:30,align:"center",verticalAlign:"middle",text:"›",style:{fontSize:12,fillStyle:e.colors.textTertiary}}),!1),n.on("click",()=>this.__pick(t,o)),h.addChild(n,!1),this.optionNodes.set(`${o}:${t.value}`,n)}),n.setContent(h),t.addChild(n,!1),this.columns.push(n)})}},t.ICECheckBox=Lt,t.ICECheckboxGroup=class extends r{itemNodes=[];checkboxNodes=[];labelNodes=[];activeIndex=0;bound=!1;constructor(t){const e=h.getTheme(),i="vertical"===t.direction?"vertical":"horizontal",s=t.height??e.control.height;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:t.width??200,height:"vertical"===i?s*Math.max(1,(t.options||[]).length):s}),this.focusable=!0,this.options=(t.options||[]).slice(),this.direction=i,this.itemGap=t.itemGap??e.spacing.md,this.fontSize=t.fontSize??e.font.size,this.itemHeight=s,this.max=Math.max(0,Number(t.max)||0),this.onChange="function"==typeof t.onChange?t.onChange:null,this.selected=this.__normalize(t.value),this.__render(void 0!==t.width)}getValue(){return this.selected.slice()}getCheckedCount(){return this.selected.length}isChecked(t){return-1!==this.selected.indexOf(t)}setValue(t){const e=this.__normalize(t);return e.join("\0")===this.selected.join("\0")||(this.selected=e,this.__syncSelection(),this.trigger("change",null,{value:this.getValue()})),this}checkAll(){const t=this.options.filter(t=>!t.disabled).slice(0,this.max>0?this.max:void 0).map(t=>t.value);return this.setValue(t)}clear(){return this.setValue([])}getFormValue(){return this.getValue()}setFormValue(t){null!=t&&""!==t?this.setValue(Array.isArray(t)?t.map(t=>String(t)):[String(t)]):this.setValue([])}getOptionNodes(){return this.itemNodes.slice()}getItemNode(t){const e=this.options.findIndex(e=>e.value===t);return-1===e?null:this.itemNodes[e]}getCheckboxNode(t){const e=this.options.findIndex(e=>e.value===t);return-1===e?null:this.checkboxNodes[e]}getLabelTexts(){return this.labelNodes.map(t=>t.getText())}getActiveIndex(){return this.activeIndex}setOptions(t){return this.options=(t||[]).slice(),this.selected=this.__normalize(this.selected),this.activeIndex=0,this.__render(!0),this}afterAddHandler(){super.afterAddHandler(),!this.bound&&this.ice&&this.ice.evtBus&&(this.bound=!0,this.ice.evtBus.on("keydown",this.__onKeyDown,this))}__normalize(t){const e=new Set((Array.isArray(t)?t:t?[t]:[]).map(t=>String(t)));return this.options.filter(t=>e.has(t.value)&&!t.disabled).map(t=>t.value)}__onKeyDown(t){if(!this.ice||!this.enabled||!this.isFocused())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if("ArrowRight"===i||"ArrowDown"===i)this.__moveActive(1);else if("ArrowLeft"===i||"ArrowUp"===i)this.__moveActive(-1);else if(" "===i||"Spacebar"===i||"Enter"===i){const t=this.options[this.activeIndex];t&&this.__toggle(t,!1)}}__moveActive(t){let e=this.activeIndex;for(let i=0;i<this.options.length;i+=1){if(e+=t,e<0||e>=this.options.length)return;if(!this.options[e].disabled)return void(this.activeIndex=e)}}__toggle(t,e){if(!t||t.disabled||!this.enabled)return;this.activeIndex=this.options.indexOf(t);const i=this.isChecked(t.value);if(!i&&this.max>0&&this.selected.length>=this.max)return void this.trigger("exceed",null,{value:t.value,max:this.max});const s=i?this.selected.filter(e=>e!==t.value):this.__normalize([...this.selected,t.value]);this.selected=s,this.__syncSelection(),this.trigger("change",null,{value:this.getValue()}),e&&this.onChange&&this.onChange(this.getValue())}__syncSelection(){this.options.forEach((t,e)=>{const i=this.checkboxNodes[e];i&&i.setSelected(this.isChecked(t.value))}),this.revalidate(),this.ice&&(this.ice.dirty=!0)}__render(t){const e=h.getTheme();this.removeChildren([...this.childNodes]),this.itemNodes=[],this.checkboxNodes=[],this.labelNodes=[];const i=e.control.checkboxSize,s=e.spacing.xs;let o=0,n=0;this.options.forEach((t,h)=>{const l=String(t.label??t.value),a=F(l,this.fontSize),d=i+s+a,c="vertical"===this.direction?0:o,u="vertical"===this.direction?h*this.itemHeight:0,f=new r({left:c,top:u,width:d,height:this.itemHeight,fill:!1,stroke:!1,interactive:!t.disabled,focusable:!1}),g=new Lt({left:0,top:0,width:i,height:this.itemHeight,selected:this.isChecked(t.value),focusable:!1,interactive:!1});t.disabled&&g.setEnabled(!1);const m=new H({interactive:!1,left:i+s,top:0,width:a,height:this.itemHeight,text:l,verticalAlign:"middle",style:{fontSize:this.fontSize,fontFamily:e.font.family,fillStyle:t.disabled?e.colors.textDisabled:e.colors.text}});f.addChild(g,!1),f.addChild(m,!1),f.on("click",()=>this.__toggle(t,!0)),this.addChild(f,!1),this.itemNodes.push(f),this.checkboxNodes.push(g),this.labelNodes.push(m),n=Math.max(n,d),o+=d+this.itemGap}),"vertical"===this.direction&&(this.state.height=this.itemHeight*Math.max(1,this.options.length)),this.state.width=t?Math.max(Number(this.state.width)||0,n):n,this.__syncSelection()}},t.ICECollapse=class extends r{headerNodes=new Map;contentNodes=new Map;offsetMap=new Map;constructor(t){h.getTheme();const e=t.width??280;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:e,height:0}),this.items=(t.items||[]).slice(),this.active=(t.activeKeys||[]).slice(),this.accordion=!0===t.accordion,this.headerHeight=t.headerHeight??36,this.contentHeight=t.contentHeight??48,this.expandCallback=("function"==typeof t.onExpand?t.onExpand:null)||("function"==typeof t.onChange?t.onChange:null),this.__render()}getActiveKeys(){return this.active.slice()}setActiveKeys(t){return this.active=(t||[]).slice(),this.__render(),this}getHeaderNode(t){return this.headerNodes.get(t)||null}getContentNode(t){return this.contentNodes.get(t)||null}getItemTop(t){return this.offsetMap.has(t)?this.offsetMap.get(t):-1}__toggle(t){-1!==this.active.indexOf(t)?this.active=this.active.filter(e=>e!==t):this.accordion?this.active=[t]:this.active=this.active.concat([t]),this.__render(),this.expandCallback&&this.expandCallback(this.getActiveKeys())}__render(){this.removeChildren([...this.childNodes]),this.headerNodes.clear(),this.contentNodes.clear(),this.offsetMap.clear();const t=h.getTheme(),e=Number(this.state.width)||280;let i=0;this.items.forEach(s=>{const o=-1!==this.active.indexOf(s.key);this.offsetMap.set(s.key,i);const n=new r({left:0,top:i,width:e,height:this.headerHeight,radius:t.radius.sm,fill:!0,stroke:!1,interactive:!s.disabled,style:{fillStyle:t.colors.background}});if(n.addChild(new H({interactive:!1,left:12,top:0,width:16,height:this.headerHeight,align:"center",verticalAlign:"middle",text:o?"▾":"▸",style:{fontSize:12,fillStyle:t.colors.textSecondary}}),!1),n.on("hoverchange",e=>{const i=R(e);n.setState({style:{...n.state.style,fillStyle:i?t.colors.disabled:t.colors.background}})},this),n.addChild(new H({interactive:!1,left:32,top:0,width:e-44,height:this.headerHeight,verticalAlign:"middle",text:s.title,style:{fontSize:13,fontWeight:"600",fillStyle:s.disabled?t.colors.textDisabled:t.colors.text}}),!1),s.disabled||n.on("click",()=>this.__toggle(s.key)),this.addChild(n,!1),this.headerNodes.set(s.key,n),i+=this.headerHeight,o){const o=new r({left:0,top:i,width:e,height:this.contentHeight,fill:!0,stroke:!1,style:{fillStyle:t.colors.surface}});if("function"==typeof s.content){const t=s.content();t&&(t.setState({left:32,top:4}),o.addChild(t,!1))}else o.addChild(V({left:32,top:0,width:e-44,height:this.contentHeight,text:String(s.content??""),fillStyle:t.colors.textSecondary,fontFamily:t.font.family,fontSize:12,align:"left",verticalAlign:"middle"}),!1);this.addChild(o,!1),this.contentNodes.set(s.key,o),i+=this.contentHeight}}),this.setState({height:i}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}__afterStateMerge(t){super.__afterStateMerge(t),t&&this.__render()}},t.ICEColorPicker=Wt,t.ICEComment=Ht,t.ICEContainer=W,t.ICEDatePicker=class extends r{handle=null;panel=null;fieldLabel=null;monthLabel=null;grid=null;dayNodes=new Map;viewYear=1970;viewMonth=1;running=!1;constructor(t={}){const e=h.getTheme(),i=t.width??200,s=t.height??e.control.height;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:i,height:s,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.value=t.value??null,this.placeholder=t.placeholder||"",this.disabled=!0===t.disabled,this.formatFn="function"==typeof t.format?t.format:t=>t,this.today=t.today||It(new Date),this.cellSize=t.cellSize??30,this.placement=t.placement||"bottomLeft",this.manager=t.manager||null,this.onChangeCallback="function"==typeof t.onChange?t.onChange:null,this.focusable=!this.disabled,this.focusRingMode="always",this.__setViewFromValue(),this.__syncField()}afterAddHandler(){super.afterAddHandler(),this.running||(!this.manager&&this.ice&&(this.manager=z(this.ice)),this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this)),this.on("click",this.__onClick,this),this.running=!0)}getValue(){return this.value}setValue(t){return this.value=t,this.__setViewFromValue(),this.__syncField(),this.isOpen()&&this.__renderPanel(),this}getFormValue(){return this.value}setFormValue(t){this.setValue(null==t||""===t?null:String(t))}getFieldLabel(){return this.fieldLabel?this.fieldLabel.getText():""}isOpen(){return!!this.handle&&this.handle.isOpen()}getPanel(){return this.panel}getViewMonth(){return{year:this.viewYear,month:this.viewMonth}}setViewMonth(t,e){return this.viewYear=Number(t),this.viewMonth=Math.min(12,Math.max(1,Number(e))),this.isOpen()&&this.__renderPanel(),this}prevMonth(){const t=this.viewMonth-1;return t<1?this.setViewMonth(this.viewYear-1,12):this.setViewMonth(this.viewYear,t)}nextMonth(){const t=this.viewMonth+1;return t>12?this.setViewMonth(this.viewYear+1,1):this.setViewMonth(this.viewYear,t)}getDayNode(t){return this.dayNodes.get(t)||null}getDayCells(){const t=(new Date(this.viewYear,this.viewMonth-1,1).getDay()+6)%7,e=new Date(this.viewYear,this.viewMonth-1,1-t),i=[];for(let t=0;t<42;t++){const s=new Date(e.getFullYear(),e.getMonth(),e.getDate()+t),o=It(s);i.push({date:o,day:s.getDate(),inMonth:s.getMonth()===this.viewMonth-1&&s.getFullYear()===this.viewYear,isToday:o===this.today,isSelected:o===this.value})}return i}activate(){this.toggle()}toggle(){return this.isOpen()?this.close():this.open()}open(){if(this.disabled||this.isOpen())return this;if(!this.manager){if(!this.ice)throw new Error("ICEDatePicker 需要先加入 ICE 场景");this.manager=z(this.ice)}const t=7*this.cellSize+16,e=h.getTheme(),i=new O({width:t,height:64+6*this.cellSize+12,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,shadow:"md"}});return this.panel=i,this.__renderPanel(),this.handle=this.manager.open({anchor:this,content:i,placement:this.placement,offset:4,enterAnimation:"scale",exitAnimation:"fade",keyboardCaptured:!0,closeOnOutsideClick:!1}),this}close(){return this.handle&&(this.handle.close(),this.handle=null),this.panel=null,this.monthLabel=null,this.grid=null,this.dayNodes.clear(),this}__setViewFromValue(){const t=this.value||this.today,[e,i]=t.split("-").map(t=>Number(t));Number.isFinite(e)&&Number.isFinite(i)&&(this.viewYear=e,this.viewMonth=i)}__pick(t){this.value=t,this.__syncField(),this.close(),this.onChangeCallback&&this.onChangeCallback(t)}__onClick(){this.disabled||this.toggle()}__onKeyDown(t){if(!this.isOpen())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);"Escape"===i||"Esc"===i?this.close():"ArrowLeft"===i?this.prevMonth():"ArrowRight"===i&&this.nextMonth()}__onGlobalMouseDown(t){if(!this.isOpen()||!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=t=>e>=t.left&&e<=t.left+t.width&&i>=t.top&&i<=t.top+t.height;s(this.__worldBox(this))||s(this.__worldBox(this.panel))||this.close()}__worldBox(t){let e=0,i=0,s=t;for(;s&&s.state;)e+=Number(s.state.left)||0,i+=Number(s.state.top)||0,s=s.parentNode;return{left:e,top:i,width:Number(t&&t.state&&t.state.width)||0,height:Number(t&&t.state&&t.state.height)||0}}__syncField(){const t=h.getTheme(),e=Number(this.state.width)||200,i=Number(this.state.height)||32,s="error"===this.validateStatus?t.colors.error:t.colors.border;this.setState({style:{...this.state.style,fillStyle:this.disabled?t.colors.disabled:t.colors.surface,strokeStyle:s}}),this.removeChildren([...this.childNodes]);const o=this.value?this.formatFn(this.value):this.placeholder;this.fieldLabel=new H({interactive:!1,left:10,top:0,width:Math.max(0,e-34),height:i,verticalAlign:"middle",text:o,style:{fontSize:13,fillStyle:this.value?t.colors.text:t.colors.textTertiary}}),this.addChild(this.fieldLabel,!1),this.addChild(new H({interactive:!1,left:e-22,top:0,width:14,height:i,align:"center",verticalAlign:"middle",text:"▾",style:{fontSize:12,fillStyle:t.colors.textTertiary}}),!1)}__renderPanel(){const t=this.panel;if(!t)return;const e=h.getTheme();t.removeChildren([...t.childNodes]),this.dayNodes.clear();const i=Number(t.state.width)||7*this.cellSize+16,s=new r({left:8,top:6,width:24,height:24,radius:e.radius.sm,fill:!0,stroke:!1,style:{fillStyle:e.colors.background}});s.addChild(new H({interactive:!1,left:0,top:0,width:24,height:24,align:"center",verticalAlign:"middle",text:"‹",style:{fontSize:14,fillStyle:e.colors.text}}),!1),s.on("click",()=>this.prevMonth());const o=new r({left:i-8-24,top:6,width:24,height:24,radius:e.radius.sm,fill:!0,stroke:!1,style:{fillStyle:e.colors.background}});o.addChild(new H({interactive:!1,left:0,top:0,width:24,height:24,align:"center",verticalAlign:"middle",text:"›",style:{fontSize:14,fillStyle:e.colors.text}}),!1),o.on("click",()=>this.nextMonth()),this.monthLabel=new H({interactive:!1,left:36,top:6,width:i-16-56,height:24,align:"center",verticalAlign:"middle",text:`${this.viewYear} 年 ${this.viewMonth} 月`,style:{fontSize:13,fontWeight:"600",fillStyle:e.colors.text}}),t.addChild(s,!1),t.addChild(this.monthLabel,!1),t.addChild(o,!1),zt.forEach((i,s)=>{t.addChild(new H({interactive:!1,left:8+s*this.cellSize,top:38,width:this.cellSize,height:20,align:"center",verticalAlign:"middle",text:i,style:{fontSize:11,fillStyle:e.colors.textTertiary}}),!1)});const n=new r({left:0,top:0,width:Number(t.state.width)||i,height:Number(t.state.height)||0,fill:!1,stroke:!1});this.grid=n,this.getDayCells().forEach((i,s)=>{const o=Math.floor(s/7),n=new r({left:8+s%7*this.cellSize,top:60+o*this.cellSize,width:this.cellSize,height:this.cellSize,radius:this.cellSize/2,fill:!0,stroke:!1,interactive:!0,style:{fillStyle:i.isSelected?e.colors.primary:i.isToday?e.colors.primaryBg:"rgba(0,0,0,0)"}});n.addChild(new H({interactive:!1,left:0,top:0,width:this.cellSize,height:this.cellSize,align:"center",verticalAlign:"middle",text:String(i.day),style:{fontSize:12,fillStyle:i.isSelected?e.colors.primaryText:i.inMonth?e.colors.text:e.colors.textDisabled}}),!1),n.on("click",()=>this.__pick(i.date)),t.addChild(n,!1),this.dayNodes.set(i.date,n)}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}},t.ICEDescriptions=class extends r{rowNodes=[];constructor(t){const e=t.width??320,i=Math.max(1,t.column??1),s=t.itemHeight??32,o=Math.ceil((t.items||[]).length/i);super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:e,height:o*s+8,radius:h.getTheme().radius.md,style:{fillStyle:h.getTheme().colors.surface,strokeStyle:h.getTheme().colors.border}}),this.items=(t.items||[]).slice(),this.column=i,this.itemHeight=s,this.labelWidth=t.labelWidth??72,this.__render()}getRowNodes(){return this.rowNodes.slice()}setItems(t){this.items=(t||[]).slice();const e=Math.ceil(this.items.length/this.column);return this.setState({height:e*this.itemHeight+8}),this.__render(),this}__afterStateMerge(t){super.__afterStateMerge(t),t&&this.__render()}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]);const e=(Number(this.state.width)||320)/this.column;this.rowNodes=[],this.items.forEach((i,s)=>{const o=s%this.column,n=Math.floor(s/this.column),h=o*e+12,l=4+n*this.itemHeight,a=e-24,d=Math.max(0,this.labelWidth-6),c=Math.max(0,a-this.labelWidth-4),u=new r({left:h,top:l,width:a,height:this.itemHeight,fill:!1,stroke:!1}),f=xt(i.label,{maxWidth:d,fontSize:12,maxLines:1})[0],g=xt(String(i.value??""),{maxWidth:c,fontSize:13,maxLines:1})[0];u.addChild(new H({interactive:!1,left:0,top:0,width:this.labelWidth,height:this.itemHeight,verticalAlign:"middle",text:f,style:{fontSize:12,fillStyle:t.colors.textSecondary}}),!1),u.addChild(new H({interactive:!1,left:this.labelWidth,top:0,width:c,height:this.itemHeight,verticalAlign:"middle",text:g,style:{fontSize:13,fillStyle:t.colors.text}}),!1),this.addChild(u,!1),this.rowNodes.push(u)})}},t.ICEDrawer=yt,t.ICEDropdown=pt,t.ICEEmpty=vt,t.ICEFloatButton=class extends r{itemNodes=new Map;expanded=!1;constructor(t={}){const e=h.getTheme(),i=t.size??44;super({id:t.id,fill:!0,stroke:!1,radius:i/2,left:t.left,top:t.top,width:i,height:i,style:{fillStyle:"default"===t.type?e.colors.surface:e.colors.primary,strokeStyle:e.colors.border,...e.shadows.md}}),this.focusable=!0,this.size=i,this.gap=t.gap??e.spacing.sm,this.direction="down"===t.direction?"down":"up",this.type="default"===t.type?"default":"primary",this.items=(t.items||[]).slice(),this.iconClosed=t.icon??"+",this.iconExpanded=t.expandedIcon??"×",this.onClick="function"==typeof t.onClick?t.onClick:null,this.onItemClick="function"==typeof t.onItemClick?t.onItemClick:null,this.iconNode=L(this.iconClosed,e,i,i,{fontSize:Math.round(.42*i),fillStyle:this.__iconColor()}),this.addChild(this.iconNode,!1),this.__renderItems(),this.on("click",()=>this.toggle())}isExpanded(){return this.expanded}getItemNode(t){return this.itemNodes.get(t)||null}getItems(){return this.items.slice()}getButtonColor(){return String(this.state.style.fillStyle)}expand(){return this.expanded||!this.items.length||(this.expanded=!0,this.__sync()),this}collapse(){return this.expanded?(this.expanded=!1,this.__sync(),this):this}toggle(){return this.expanded?this.collapse():this.expand(),this.onClick&&this.onClick(),this}activate(){this.enabled&&this.toggle()}__applyHoverState(){const t=h.getTheme(),e="default"===this.type?t.colors.surface:t.colors.primary,i="default"===this.type?t.colors.background:t.colors.primaryHover;this.setState({style:{...this.state.style,fillStyle:this.hovered?i:e}}),this.revalidate()}__iconColor(){const t=h.getTheme();return"default"===this.type?t.colors.text:t.colors.primaryText}__renderItems(){const t=h.getTheme();this.itemNodes.clear(),this.items.forEach((e,i)=>{const s=(i+1)*(this.size+this.gap),o=new r({left:0,top:"up"===this.direction?-s:s,width:this.size,height:this.size,fill:!0,stroke:!0,radius:this.size/2,display:!1,style:{fillStyle:t.colors.elevated,strokeStyle:t.colors.border,...t.shadows.sm}});o.addChild(L(e.icon,t,this.size,this.size,{fontSize:Math.round(.4*this.size),fillStyle:t.colors.text}),!1),o.on("click",()=>{this.onItemClick&&this.onItemClick(e.key),e.onClick&&e.onClick(),this.trigger("itemclick",null,{key:e.key}),this.collapse()}),this.addChild(o,!1),this.itemNodes.set(e.key,o)})}__sync(){this.itemNodes.forEach(t=>t.setState({display:this.expanded})),this.iconNode.setText(this.expanded?this.iconExpanded:this.iconClosed),this.revalidate(),this.ice&&(this.ice.dirty=!0)}},t.ICEFocusManager=I,t.ICEForm=class extends W{items=[];submitHandlers=[];muted=!1;constructor(t={}){const e=t.width??320;super({id:t.id,fill:!1,stroke:!1,interactive:!1,left:t.left,top:t.top,width:e,height:0}),this.itemGap=t.gap??16,this.model=t.model||new $t,this.model.addChangeListener(()=>this.__syncErrors()),t.items&&this.addItems(t.items)}getModel(){return this.model}getItems(){return this.items.slice()}addItems(t){return t.forEach(t=>this.addItem(t)),this}addItem(t){this.items.push(t);const e=t.getName(),i=t.getControl();return this.model.addField({name:e,label:t.getLabel(),rules:t.getRules(),dependencies:t.getDependencies?t.getDependencies():[],value:i.getFormValue?i.getFormValue():void 0}),i&&"function"==typeof i.on&&i.on("change",()=>{this.muted||this.model.setValue(e,i.getFormValue?i.getFormValue():void 0)}),this.addChild(t,!1),this.__layout(),this.__syncErrors(),this}getValues(){return this.model.getValues()}setValues(t){return this.items.forEach(e=>{const i=e.getName();if(Object.prototype.hasOwnProperty.call(t,i)){const s=e.getControl();s&&"function"==typeof s.setFormValue&&s.setFormValue(t[i])}}),this.model.setValues(t,{silent:!0}),this.model.validate(),this.__syncErrors(),this}reset(){this.muted=!0;try{this.model.reset(),this.items.forEach(t=>{const e=t.getControl();e&&"function"==typeof e.setFormValue&&e.setFormValue(this.model.getValue(t.getName()))})}finally{this.muted=!1}return this.__syncErrors(),this}validate(){const t=this.model.validate();return this.__syncErrors(),t}async validateAsync(){const t=await this.model.validateAsync();return this.__syncErrors(),t}onSubmit(t){return this.submitHandlers.push(t),this}submit(){if(!this.validate())return!1;const t=this.getValues();return this.submitHandlers.forEach(e=>e(t)),!0}async submitAsync(){if(!await this.validateAsync())return!1;const t=this.getValues();return this.submitHandlers.forEach(e=>e(t)),!0}__syncErrors(){this.items.forEach(t=>{const e=this.model.isValidating(t.getName());t.setValidating(e),e||t.setError(this.model.getError(t.getName())||null)})}__layout(){let t=0;this.items.forEach(e=>{e.setState({left:0,top:t,width:Number(this.state.width)||void 0}),t+=(Number(e.state.height)||0)+this.itemGap}),this.setState({height:Math.max(0,t-this.itemGap)})}},t.ICEFormItem=class extends r{validating=!1;constructor(t){const e=h.getTheme(),i=t.control;if(!i)throw new Error("ICEFormItem 需要 control");const s=t.layout||"vertical",o=t.labelHeight??18,n=t.errorHeight??16,r=t.gap??6,l=Number(i.state&&i.state.width)||200,a=Number(i.state&&i.state.height)||e.control.height,d="horizontal"===s?t.labelWidth??80:0,c=t.width??("horizontal"===s?d+l:Math.max(l,120)),u="horizontal"===s?a+r+n:o+r+a+r+n;super({id:t.id,fill:!1,stroke:!1,interactive:!1,left:t.left,top:t.top,width:c,height:u}),this.name=t.name,this.labelText=t.label||t.name,this.control=i,this.rules=t.rules?t.rules.slice():[],this.dependencies=t.dependencies?t.dependencies.slice():[],this.itemLayout=s,this.labelWidth=d,this.labelHeight=o,this.errorHeight=n,this.itemGap=r,this.labelNode=new H({left:0,top:0,height:o,verticalAlign:"middle",text:this.labelText,style:{fontSize:12,fillStyle:e.colors.textSecondary}}),this.errorNode=new H({left:0,top:0,height:n,verticalAlign:"middle",text:"",display:!1,style:{fontSize:12,fillStyle:e.colors.error}}),this.addChild(this.labelNode,!1),this.addChild(this.control,!1),this.addChild(this.errorNode,!1),this.__layoutChildren()}getName(){return this.name}getLabel(){return this.labelText}getRules(){return this.rules.slice()}getDependencies(){return this.dependencies.slice()}getControl(){return this.control}getLabelNode(){return this.labelNode}getErrorNode(){return this.errorNode}getErrorText(){return this.errorNode.getText()}isValidating(){return this.validating}setValidating(t){const e=!!t;return e===this.validating||(this.validating=e,e?(this.errorNode.setText(lt("form.validating")),this.errorNode.setState({display:!0}),this.control&&"function"==typeof this.control.setValidateStatus&&this.control.setValidateStatus("default")):this.errorNode.getText()===lt("form.validating")&&(this.errorNode.setText(""),this.errorNode.setState({display:!1}))),this}setError(t){const e=t||"";return this.errorNode.setText(e),this.errorNode.setState({display:!!e}),this.control&&"function"==typeof this.control.setValidateStatus&&this.control.setValidateStatus(e?"error":"default"),this}__layoutChildren(){const t=Number(this.control.state&&this.control.state.width)||200,e=Number(this.control.state&&this.control.state.height)||32;if("horizontal"===this.itemLayout)return this.labelNode.setState({left:0,top:Math.max(0,(e-this.labelHeight)/2),width:this.labelWidth-8}),this.control.setState({left:this.labelWidth,top:0}),void this.errorNode.setState({left:this.labelWidth,top:e+this.itemGap,width:t});this.labelNode.setState({left:0,top:0,width:Math.max(0,t)}),this.control.setState({left:0,top:this.labelHeight+this.itemGap}),this.errorNode.setState({left:0,top:this.labelHeight+this.itemGap+e+this.itemGap})}},t.ICEFormModel=$t,t.ICEGrid=class extends W{cols=[];constructor(t={}){const e=h.getTheme();super({id:t.id,fill:!1,stroke:!1,interactive:!1,left:t.left,top:t.top,width:t.width??480,height:t.height??0}),this.gutter=t.gutter??e.spacing.md,this.gutterY=t.gutterY??this.gutter,this.autoHeight=void 0===t.height}getCols(){return this.cols.slice()}addCol(t){return super.addChild(t,!1),this.cols.push(t),this.__layout(),this}setGutter(t,e){return this.gutter=Number(t)||0,this.gutterY=void 0===e?this.gutter:Number(e)||0,this.__layout(),this}__rows(){const t=[[]];let e=0;return this.cols.forEach(i=>{const s=i.span+i.offset;t[t.length-1].length>0&&e+s>24&&(t.push([]),e=0),t[t.length-1].push(i),e+=s}),t}__layout(){const t=Number(this.state.width)||0;let e=0;this.__rows().forEach(i=>{const s=(t-this.gutter*Math.max(0,i.length-1))/24;let o=0,n=0;i.forEach((t,i)=>{const h=(o+t.offset)*s+this.gutter*i,r=t.span*s;t.applyLayout(h,e,r),o+=t.span,n=Math.max(n,Number(t.state.height)||this.__contentHeight(t))}),e+=n+this.gutterY}),this.autoHeight&&(this.state.height=Math.max(0,e-this.gutterY)),this.ice&&(this.ice.dirty=!0)}__contentHeight(t){const e=t.getContent();return e&&Number(e.state.height)||0}revalidate(){return super.revalidate(),this.__layout(),this}},t.ICEGridCol=class extends W{content=null;constructor(t={}){super({id:t.id,fill:!1,stroke:!1,interactive:!1,width:0,height:t.height??0}),this.span=Math.max(1,Math.min(24,Math.floor(Number(t.span)||24))),this.offset=Math.max(0,Math.min(23,Math.floor(Number(t.offset)||0))),this.content=t.content||null,this.content&&this.addChild(this.content,!1)}getContent(){return this.content}applyLayout(t,e,i){this.setState({left:t,top:e,width:i}),this.content&&this.content.setState({left:0,top:0,width:i})}},t.ICEHighScoreModel=class{entries=[];constructor(t){this.key=String(t.key||"default"),this.maxEntries=Math.max(1,Math.floor(void 0===t.maxEntries?5:t.maxEntries)),this.prefix=t.prefix||"ice-arcade-scores-",this.storage=void 0===t.storage?this.__defaultStorage():t.storage,this.entries=this.__load()}getKey(){return this.key}getStorageKey(){return`${this.prefix}${this.key}`}getMaxEntries(){return this.maxEntries}getScores(){return this.entries.map(t=>({...t}))}getBest(){return this.entries.length?this.entries[0].score:0}isInTop(t){const e=Number(t);return!(!Number.isFinite(e)||e<=0)&&(this.entries.length<this.maxEntries||e>=this.entries[this.entries.length-1].score)}add(t,e={}){const i=Number(t);if(!Number.isFinite(i)||i<=0)return this.getScores();const s={score:i};void 0!==e.label&&(s.label=String(e.label)),s.at=Number.isFinite(Number(e.at))?Number(e.at):Date.now();const o=this.entries.concat([s]);return o.sort((t,e)=>e.score-t.score),this.entries=o.slice(0,this.maxEntries),this.__save(),this.getScores()}clear(){this.entries=[],this.__save()}reload(){return this.entries=this.__load(),this.getScores()}__defaultStorage(){const t=globalThis.localStorage;return t&&"function"==typeof t.getItem?t:null}__load(){if(!this.storage)return[];let t=null;try{t=this.storage.getItem(this.getStorageKey())}catch(t){return[]}if(!t)return[];let e=null;try{e=JSON.parse(t)}catch(t){return[]}const i=e&&Array.isArray(e.entries)?e.entries:null;if(!i)return[];const s=[];return i.forEach(t=>{if(!t||"object"!=typeof t)return;const e=Number(t.score);if(!Number.isFinite(e)||e<=0)return;const i={score:e};void 0!==t.label&&(i.label=String(t.label)),i.at=Number.isFinite(Number(t.at))?Number(t.at):void 0,s.push(i)}),s.sort((t,e)=>e.score-t.score),s.slice(0,this.maxEntries)}__save(){if(this.storage)try{this.storage.setItem(this.getStorageKey(),JSON.stringify({entries:this.entries}))}catch(t){}}},t.ICEHoverManager=class{current=null;running=!1;lastX=0;lastY=0;rafId=null;constructor(t){this.ice=t,this.__onMouseMove=t=>{t&&"number"==typeof t.offsetX&&"number"==typeof t.offsetY&&(this.lastX=t.offsetX,this.lastY=t.offsetY,this.__schedule())},this.__onLeave=()=>this.setHovered(null)}start(){if(this.running||!this.ice||!this.ice.evtBus)return this;this.running=!0,this.ice.evtBus.on("mousemove",this.__onMouseMove,this);const t=this.ice.canvasEl;return t&&"function"==typeof t.addEventListener&&(t.addEventListener("mouseleave",this.__onLeave),t.addEventListener("pointerleave",this.__onLeave)),this}stop(){if(!this.running)return this;this.ice&&this.ice.evtBus&&this.ice.evtBus.off("mousemove",this.__onMouseMove,this);const t=this.ice&&this.ice.canvasEl;return t&&"function"==typeof t.removeEventListener&&(t.removeEventListener("mouseleave",this.__onLeave),t.removeEventListener("pointerleave",this.__onLeave)),null!==this.rafId&&(this.__cancelRaf(this.rafId),this.rafId=null),this.setHovered(null),this.running=!1,this}getHoveredComponent(){return this.current}__schedule(){if(null!==this.rafId)return;const t=this.ice&&this.ice.root?this.ice.root:null,e=t&&"function"==typeof t.requestAnimationFrame?t.requestAnimationFrame.bind(t):null;this.rafId=e?e(()=>{this.rafId=null,this.__flush()}):setTimeout(()=>{this.rafId=null,this.__flush()},16)}__cancelRaf(t){const e=this.ice&&this.ice.root?this.ice.root:null;e&&"function"==typeof e.cancelAnimationFrame&&"number"==typeof t?e.cancelAnimationFrame(t):"function"==typeof clearTimeout&&clearTimeout(t)}__flush(){if(!this.running||!this.ice)return;const t=this.__findHoverTarget();this.setHovered(t||null)}__findHoverTarget(){const t=this.ice;if(!t||"function"!=typeof t.screenToWorld)return null;const[e,i]=t.screenToWorld(this.lastX,this.lastY),s=[],o=t=>{for(const e of t||[])e&&"function"==typeof e.setHovered&&e.state&&e.state.interactive&&s.push(e),e&&e.childNodes&&e.childNodes.length&&o(e.childNodes)};o(t.childNodes||[]),o(t.toolNodes||[]),s.sort((t,e)=>(t.state.zIndex||0)-(e.state.zIndex||0));let n=null;for(const t of s)t.containsPoint&&t.containsPoint(e,i)&&(n=t);return n}setHovered(t){t!==this.current&&(this.current&&"function"==typeof this.current.setHovered&&this.current.setHovered(!1),this.current=t,t&&"function"==typeof t.setHovered&&t.setHovered(!0))}},t.ICEIcon=class extends r{constructor(t={}){const e=h.getTheme(),i=t.size||t.fontSize||e.font.sizeLarge;super({fill:!1,stroke:!1,width:i,height:i,...t}),this.textNode=L(t.icon||t.text||"★",e,i,i,{fontSize:i,fontWeight:e.font.weightNormal,fillStyle:t.color||e.colors.text}),this.addChild(this.textNode,!1)}setIcon(t){return this.textNode.setText(t||"★"),this.revalidate(),this}},t.ICEIconTile=class extends r{constructor(t){h.getTheme();const e=t.width??84,i=t.height??78;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:e,height:i,interactive:!0,focusable:!0}),this.labelText=t.label,this.selected=!0===t.selected,this.onSelect="function"==typeof t.onSelect?t.onSelect:null,this.onOpen="function"==typeof t.onOpen?t.onOpen:null;const s=t.iconSize??34;if(t.iconNode){const i=t.iconNode,o=Number(i.state&&i.state.width)||s,n=Number(i.state&&i.state.height)||s;i.setState({left:Math.round((e-o)/2),top:4+Math.max(0,Math.round((s+6-n)/2))}),this.iconNode=i}else this.iconNode=new H({interactive:!1,left:0,top:4,width:e,height:s+6,text:t.icon,align:"center",verticalAlign:"middle",style:{fontSize:s,fillStyle:"#ffffff"}});this.labelNode=new H({interactive:!1,left:4,top:s+12,width:e-8,height:18,text:t.label,align:"center",verticalAlign:"middle",style:{fontSize:t.fontSize??11,fillStyle:"#ffffff"}}),this.labelBackground=new r({left:2,top:s+10,width:e-4,height:22,fill:!0,stroke:!1,style:{fillStyle:"rgba(0,0,0,0)"}}),this.addChild(this.labelBackground,!1),this.addChild(this.iconNode,!1),this.addChild(this.labelNode,!1),this.on("click",()=>this.toggle()),this.on("dblclick",()=>this.open()),this.__sync()}getLabel(){return this.labelText}isSelected(){return this.selected}setSelected(t){const e=!!t;return e===this.selected||(this.selected=e,this.__sync(),this.trigger("select",null,{selected:e}),this.onSelect&&this.onSelect(e)),this}toggle(){return this.setSelected(!this.selected)}open(){return this.trigger("open",null,{label:this.labelText}),this.onOpen&&this.onOpen(this.labelText),this}activate(){this.enabled&&this.open()}getLabelColor(){const t=this.labelNode.childNodes[0];return t?String(t.state.style.fillStyle):""}getLabelBackground(){return String(this.labelBackground.state.style.fillStyle??"rgba(0,0,0,0)")}__applyHoverState(){this.__sync()}__sync(){const t=this.selected;this.labelBackground.setState({display:t,style:{...this.labelBackground.state.style,fillStyle:t?"#0a246a":"rgba(0,0,0,0)"}});const e=this.labelNode.childNodes[0];e&&e.setState({style:{...e.state.style,fillStyle:(t||this.hovered,"#ffffff")}}),this.iconNode.setState({opacity:t?.85:1}),this.revalidate()}},t.ICEImagePreview=ie,t.ICEImageView=Ot,t.ICEInputNumber=class extends r{textLabel=null;decreaseButton=null;increaseButton=null;buffer="";running=!1;constructor(t={}){const e=h.getTheme(),i=t.width??140,s=t.height??e.control.height;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:i,height:s,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.min=void 0===t.min?-1/0:Number(t.min),this.max=void 0===t.max?1/0:Number(t.max),this.step=Number(t.step)||1,this.precision=void 0===t.precision?null:Number(t.precision),this.disabled=!0===t.disabled,this.currentValue=this.__clamp(Number(t.value)||0),this.onChange="function"==typeof t.onChange?t.onChange:null,this.focusable=!this.disabled,this.focusRingMode="always",this.__render()}afterAddHandler(){super.afterAddHandler(),!this.running&&this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.running=!0)}getValue(){return this.currentValue}setValue(t){const e=this.__clamp(Number(t));return e===this.currentValue||(this.currentValue=e,this.__render()),this}getFormValue(){return this.currentValue}setFormValue(t){this.setValue(Number(t))}getText(){return this.__format(this.currentValue)}getIncreaseButton(){return this.increaseButton}getDecreaseButton(){return this.decreaseButton}setEnabled(t){return this.disabled=!t,this.focusable=!this.disabled,this.__render(),this}__applyValue(t){if(this.disabled)return;const e=this.__clamp(t);e!==this.currentValue&&(this.currentValue=e,this.__render(),this.onChange&&this.onChange(e))}__stepBy(t){this.disabled||this.__applyValue(this.currentValue+t*this.step)}__onKeyDown(t){if(this.disabled||!this.isFocused())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if("ArrowUp"===i)this.__stepBy(1);else if("ArrowDown"===i)this.__stepBy(-1);else if("Backspace"===i)this.buffer=this.buffer.slice(0,-1),this.__applyValue(""===this.buffer||"-"===this.buffer?0:Number(this.buffer));else if("Enter"===i)this.buffer="";else if("string"==typeof i&&/^[0-9.-]$/.test(i)){this.buffer=(this.buffer+i).slice(-12);const t=Number(this.buffer);Number.isFinite(t)&&this.__applyValue(t)}}__clamp(t){const e=Number.isFinite(t)?t:0,i=Math.min(this.max,Math.max(this.min,e));return null===this.precision||void 0===this.precision?i:Number(i.toFixed(this.precision))}__format(t){return null===this.precision||void 0===this.precision?String(t):t.toFixed(this.precision)}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]);const e=Number(this.state.width)||140,i=Number(this.state.height)||32,s="error"===this.validateStatus?t.colors.error:t.colors.border;this.setState({style:{...this.state.style,fillStyle:this.disabled?t.colors.disabled:t.colors.surface,strokeStyle:s}});const o=new Y({left:2,top:2,width:26,height:i-4,text:"−",variant:"text",size:"small",focusable:!1});o.on("click",()=>this.__stepBy(-1));const n=new Y({left:e-28,top:2,width:26,height:i-4,text:"+",variant:"text",size:"small",focusable:!1});n.on("click",()=>this.__stepBy(1));const r=new H({interactive:!1,left:32,top:0,width:Math.max(0,e-64),height:i,align:"center",verticalAlign:"middle",text:this.__format(this.currentValue),style:{fontSize:13,fillStyle:this.disabled?t.colors.textDisabled:t.colors.text}});this.disabled&&(o.setEnabled(!1),n.setEnabled(!1)),this.addChild(o,!1),this.addChild(r,!1),this.addChild(n,!1),this.decreaseButton=o,this.increaseButton=n,this.textLabel=r,this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}},t.ICEKanban=class extends r{cardNodes=new Map;columnNodes=new Map;dragState=null;__bound=!1;running=!1;constructor(t){super({fill:!1,stroke:!1,width:t.width||640,height:t.height||260,...t}),this.columns=(t.columns||[]).map(t=>({...t,cards:(t.cards||[]).slice()})),this.columnWidth=Math.max(80,Math.floor(Number(t.columnWidth)||200)),this.cardHeight=Math.max(28,Math.floor(Number(t.cardHeight)||56)),this.gap=Math.max(4,Math.floor(Number(t.gap)||12)),this.draggable=!0===t.draggable,this.onCardMove="function"==typeof t.onCardMove?t.onCardMove:null,this.__render()}afterAddHandler(){super.afterAddHandler(),!this.running&&this.ice&&this.ice.evtBus&&(this.running=!0,this.ice.evtBus.on("mousedown",this.__onMouseDown,this),this.ice.evtBus.on("mousemove",this.__onMouseMove,this),this.ice.evtBus.on("mouseup",this.__onMouseUp,this))}getColumns(){return this.columns.map(t=>({...t,cards:t.cards.slice()}))}getCardNode(t){return this.cardNodes.get(t)||null}getColumnNode(t){return this.columnNodes.get(t)||null}isDraggable(){return this.draggable}isDragging(){return!!this.dragState}getDropTarget(){return this.dragState?this.dragState.target:null}moveCard(t,e,i){const s=st(this.columns,t,e,i);if(!s.moved)return!1;this.columns=s.columns,this.__render();const o={cardKey:t,columnKey:s.columnKey,index:s.index,columns:this.getColumns()};return this.trigger("cardmove",null,o),this.onCardMove&&this.onCardMove(o),!0}__columnX(t){return t*(this.columnWidth+this.gap)}__cardY(t){return 36+t*(this.cardHeight+8)}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]),this.cardNodes.clear(),this.columnNodes.clear(),this.columns.forEach((e,i)=>{const s=new r({id:"kanban-col-"+e.key,left:this.__columnX(i),top:0,width:this.columnWidth,height:Number(this.state.height)||0,radius:t.radius.md,fill:!0,stroke:!0,interactive:!1,style:{fillStyle:t.colors.background,strokeStyle:t.colors.border,lineWidth:1}});s.addChild(new H({interactive:!1,left:10,top:0,width:this.columnWidth-20,height:30,text:`${e.title} · ${e.cards.length}`,verticalAlign:"middle",style:{fontSize:13,fontWeight:t.font.weightSemibold,fillStyle:t.colors.text}}),!1),e.cards.forEach((e,i)=>{const o=new r({id:"kanban-card-"+e.key,left:8,top:this.__cardY(i),width:this.columnWidth-16,height:this.cardHeight,radius:t.radius.sm,fill:!0,stroke:!0,interactive:!0,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,lineWidth:1,...t.shadows.sm}});o.addChild(new H({interactive:!1,left:10,top:0,width:this.columnWidth-36,height:this.cardHeight,text:e.title,verticalStyle:void 0,verticalAlign:"middle",style:{fontSize:13,fillStyle:t.colors.text}}),!1),s.addChild(o,!1),this.cardNodes.set(e.key,o)});const o=new r({left:6,top:0,width:this.columnWidth-12,height:2,fill:!0,stroke:!1,display:!1,interactive:!1,style:{fillStyle:t.colors.primary}});s.addChild(o,!1),s.setState({indicator:o}),this.columnNodes.set(e.key,s),this.addChild(s,!1)}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}__localPoint(t){if(!t||"number"!=typeof t.offsetX||!this.ice||"function"!=typeof this.ice.screenToWorld)return null;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=this.getMinBoundingBox(!0);return{x:e-s.tl[0],y:i-s.tl[1]}}__columnIndexAt(t){const e=this.columnWidth+this.gap;return Math.min(Math.max(Math.floor(t/e),0),Math.max(0,this.columns.length-1))}__targetAt(t,e){if(!this.columns.length)return null;const i=this.columns[this.__columnIndexAt(t)];if(!i)return null;const s=Z({pointerY:e-30-6,itemHeight:this.cardHeight+8,itemCount:i.cards.length||1});return s?{columnKey:i.key,index:s.index,position:s.position}:{columnKey:i.key,index:0,position:"before"}}__onMouseDown(t){if(!this.draggable)return;const e=this.__localPoint(t);if(!e)return;const i=this.getMinBoundingBox(!0);if(e.x<0||e.y<0||e.x>i.br[0]-i.tl[0]||e.y>i.br[1]-i.tl[1])return;const s=this.columns[this.__columnIndexAt(e.x)];if(!s)return;const o=Math.floor((e.y-30-6)/(this.cardHeight+8)),n=s.cards[o];n&&(this.dragState={cardKey:n.key,target:null,indicator:this.columnNodes.get(s.key)},this.__updateDrag(e.x,e.y))}__onMouseMove(t){const e=this.__localPoint(t);e&&this.dragState&&this.__updateDrag(e.x,e.y)}__onMouseUp(){const t=this.dragState;t&&(this.dragState=null,this.__hideIndicators(),t.target&&this.moveCard(t.cardKey,t.target.columnKey,t.target.index),this.trigger("dragend",null,{cardKey:t.cardKey,target:t.target}))}__hideIndicators(){this.columnNodes.forEach(t=>{t.state&&t.state.indicator&&t.state.indicator.setState({display:!1})})}__updateDrag(t,e){if(!this.dragState)return;const i=this.__targetAt(t,e);if(this.dragState.target=i,this.__hideIndicators(),!i)return;const s=this.columnNodes.get(i.columnKey);if(!s||!s.state||!s.state.indicator)return;const o=this.columns.find(t=>t.key===i.columnKey),n=o?o.cards.length:0,h=Math.min(i.index+("after"===i.position?1:0),Math.max(0,n));s.state.indicator.setState({display:!0,top:Math.max(30,this.__cardY(h)-4)})}},t.ICELabel=H,t.ICEList=class extends r{pane=null;rowNodes=new Map;activeIndex=-1;running=!1;constructor(t){const e=h.getTheme(),i=t.width??200,s=t.height??160;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:i,height:s,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.items=(t.items||[]).slice(),this.itemHeight=t.itemHeight??34,this.onChange="function"==typeof t.onChange?t.onChange:null,this.model=new wt({mode:t.mode||"single",selected:t.value||[]}),this.model.addChangeListener(()=>this.__syncRows()),this.content=new r({left:0,top:0,width:i-8,height:this.items.length*this.itemHeight}),this.focusable=!0,this.__render()}afterAddHandler(){super.afterAddHandler(),!this.running&&this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.running=!0)}getSelectedKeys(){return this.model.getSelectedKeys()}setSelectedKeys(t){return this.model.setSelected(t),this}getSelectionModel(){return this.model}getActiveIndex(){return this.activeIndex}getRowNode(t){return this.rowNodes.get(t)||null}getScrollPane(){return this.pane}getItems(){return this.items.slice()}setItems(t){return this.items=(t||[]).slice(),this.activeIndex=-1,this.model.setSelected([]),this.__render(),this}__afterStateMerge(t){super.__afterStateMerge(t),t&&this.__render()}__onKeyDown(t){if(!this.isFocused()||!this.items.length)return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if("ArrowDown"!==i&&"ArrowUp"!==i){if("Enter"===i||" "===i){const t=this.items[this.activeIndex];t&&!t.disabled&&this.__pick(t)}}else this.__moveActive("ArrowDown"===i?1:-1)}__moveActive(t){const e=this.items.length;let i=this.activeIndex;for(let s=0;s<e;s++)if(i=(i+t+e)%e,!this.items[i].disabled)return this.activeIndex=i,void this.__syncRows()}__pick(t){if(t.disabled)return;const e=this.model.getSelectedKeys();this.model.toggle(t.key),"single"===this.model.getMode()&&e[0]===t.key||this.onChange&&this.onChange(this.model.getSelectedKeys(),t)}__render(){this.removeChildren([...this.childNodes]),this.pane=null;const t=Number(this.state.width)||200,e=Number(this.state.height)||160,i=this.items.length*this.itemHeight,s=i>e,o=t-2;if(this.content.setState({width:o-(s?10:0),height:i}),this.__syncRows(),s){const t=new _t({left:1,top:1,width:o,height:e-2,scrollbar:!0,style:{fillStyle:"rgba(0,0,0,0)",strokeStyle:"rgba(0,0,0,0)"}});t.setContent(this.content),t.setContentSize(Number(this.content.state.width),i),this.addChild(t,!1),this.pane=t}else this.addChild(this.content,!1);this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}__syncRows(){const t=h.getTheme(),e=Number(this.content.state.width)||180;this.content.removeChildren([...this.content.childNodes]),this.rowNodes.clear(),this.items.forEach((i,s)=>{const o=this.model.isSelected(i.key),n=s===this.activeIndex,h=new r({left:4,top:s*this.itemHeight,width:e-8,height:this.itemHeight,radius:t.radius.sm,fill:!0,stroke:!1,interactive:!i.disabled,style:{fillStyle:o?t.colors.primaryBg:n?t.colors.background:"rgba(0,0,0,0)"}});h.addChild(new H({interactive:!1,left:10,top:0,height:this.itemHeight,verticalAlign:"middle",text:i.label,style:{fontSize:13,fillStyle:i.disabled?t.colors.textDisabled:o?t.colors.primary:t.colors.text}}),!1),i.disabled||h.on("click",()=>this.__pick(i)),this.content.addChild(h,!1),this.rowNodes.set(i.key,h)}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}},t.ICEManager=n,t.ICEMenu=class extends W{rows=[];hoverKey=null;expanded=new Set;itemPanels=[];itemNodes=new Map;itemIcons=[];__bound=!1;constructor(t={}){const e=h.getTheme(),i=t.width||240,s=t.itemHeight||40,o=t.items||[],n=s*o.length;super({...t,fill:!0,stroke:!1,width:i,height:n,style:{fillStyle:e.colors.surface,...t.style||{}}}),this.items=o,this.itemHeight=s,this.selectedKey=t.selectedKey??null,this.onSelect="function"==typeof t.onSelect?t.onSelect:null,Array.isArray(t.defaultExpandedKeys)&&t.defaultExpandedKeys.forEach(t=>this.expanded.add(t)),this.__render()}setSelectedKey(t){return this.selectedKey=t,this.__syncSelection(),this}getSelectedKey(){return this.selectedKey}getVisibleItems(){return this.rows.map(t=>t.item)}getItemNode(t){return this.itemNodes.get(t)||null}isExpanded(t){return this.expanded.has(t)}toggleExpand(t){return this.expanded.has(t)?this.expanded.delete(t):this.expanded.add(t),this.__render(),this}setExpandedKeys(t){return this.expanded=new Set(t||[]),this.__render(),this}activateItem(t){const e=this.rows.find(e=>e.item.key===t);return e?this.__hasChildren(e.item)?(this.toggleExpand(t),this):(this.selectedKey=t,this.__syncSelection(),this.onSelect&&this.onSelect(e.item,this.rows.indexOf(e)),this):this}__hasChildren(t){return!!t.children&&t.children.length>0}__flatten(t,e,i){t.forEach(t=>{i.push({item:t,depth:e}),this.__hasChildren(t)&&this.expanded.has(t.key)&&this.__flatten(t.children,e+1,i)})}afterAddHandler(){super.afterAddHandler(),this.__bindGlobalEvents()}__bindGlobalEvents(){!this.__bound&&this.ice&&this.ice.evtBus&&(this.__bound=!0,this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this))}__onGlobalMouseDown(t){if(!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=this.getMinBoundingBox(!0);if(e<s.tl[0]||e>s.br[0]||i<s.tl[1]||i>s.br[1])return;const o=Math.floor((i-s.tl[1])/this.itemHeight);o>=0&&o<this.rows.length&&this.activateItem(this.rows[o].item.key)}__render(){this.removeChildren([...this.childNodes]);const t=h.getTheme(),e=Number(this.state.width)||240;this.itemPanels=[],this.itemIcons=[],this.itemNodes=new Map;const i=t.spacing.xxs;this.rows=[],this.__flatten(this.items,0,this.rows),this.setState({height:this.rows.length*this.itemHeight}),this.rows.forEach((s,o)=>{const n=s.item,h=s.depth*t.spacing.md,l=new r({fill:!0,stroke:!1,width:Math.max(0,e-2*i-h),height:this.itemHeight,left:i+h,top:o*this.itemHeight,radius:t.radius.md,style:{fillStyle:n.key===this.selectedKey?t.colors.primaryBg:"rgba(0,0,0,0)"}});if(this.addChild(l,!1),this.itemPanels.push(l),this.itemNodes.set(n.key,l),l.on("hoverchange",t=>{const e=R(t)?n.key:this.hoverKey===n.key?null:this.hoverKey;e!==this.hoverKey&&(this.hoverKey=e,this.__syncSelection())},this),n.iconPath){const e=new Dt({left:t.spacing.md,top:Math.round((this.itemHeight-18)/2),size:18,d:n.iconPath,color:n.key===this.selectedKey?t.colors.primary:t.colors.textSecondary,strokeWidth:1.6});l.addChild(e,!1),this.itemIcons.push(e)}else n.icon?(l.addChild(V({left:t.spacing.md,top:0,width:24,height:this.itemHeight,text:n.icon,fillStyle:n.key===this.selectedKey?t.colors.primary:t.colors.textSecondary,fontFamily:t.font.family,fontSize:t.font.sizeLarge,fontWeight:t.font.weightNormal,align:"center",verticalAlign:"middle"}),!1),this.itemIcons.push(null)):this.itemIcons.push(null);const a=n.icon||n.iconPath?t.spacing.xl+8:t.spacing.md;l.addChild(V({left:a,top:0,width:Math.max(0,e-a-t.spacing.sm-h),height:this.itemHeight,text:n.label,fillStyle:n.key===this.selectedKey?t.colors.primary:t.colors.text,fontFamily:t.font.family,fontSize:t.font.size,fontWeight:n.key===this.selectedKey?t.font.weightSemibold:t.font.weightNormal,align:"left",verticalAlign:"middle"}),!1),this.__hasChildren(n)&&l.addChild(V({left:Math.max(0,e-h-t.spacing.md-14),top:0,width:14,height:this.itemHeight,text:this.expanded.has(n.key)?"⌄":"›",fillStyle:t.colors.textTertiary,fontFamily:t.font.family,fontSize:t.font.size,align:"center",verticalAlign:"middle"}),!1)}),this.__syncSelection()}__syncSelection(){const t=h.getTheme(),e=this.__ancestorKeys(this.selectedKey);this.itemPanels.forEach((i,s)=>{const o=this.rows[s]&&this.rows[s].item.key===this.selectedKey,n=this.rows[s]&&this.rows[s].item.key===this.hoverKey,h=!!this.rows[s]&&-1!==e.indexOf(this.rows[s].item.key);i.setState({style:{fillStyle:o?t.colors.primaryBg:n?t.colors.background:"rgba(0,0,0,0)"}}),(i.childNodes||[]).forEach(e=>{e.setState({style:{...e.state.style,fillStyle:o||h?t.colors.primary:t.colors.text}})});const r=this.itemIcons[s];r&&"function"==typeof r.setColor&&r.setColor(o||h?t.colors.primary:t.colors.textSecondary)}),this.revalidate()}__ancestorKeys(t){if(!t)return[];const e=(i,s)=>{for(const o of i){if(o.key===t)return s;if(o.children&&o.children.length){const t=e(o.children,s.concat(o.key));if(t)return t}}return null};return e(this.items,[])||[]}},t.ICEMessage=U,t.ICEMessageManager=G,t.ICEMinesweeperModel=class{grid=[];state="ready";minesPlaced=!1;elapsed=0;listeners=new Set;constructor(t={}){this.rows=Math.max(1,Math.floor(t.rows??9)),this.cols=Math.max(1,Math.floor(t.cols??9)),this.mineCount=Math.max(1,Math.min(this.rows*this.cols-1,Math.floor(t.mines??10))),this.random=t.random||Math.random,this.firstClickSafe=!1!==t.firstClickSafe,this.questionMarks=!1!==t.questionMarks,this.__resetGrid()}getRows(){return this.rows}getCols(){return this.cols}getMineCount(){return this.mineCount}getState(){return this.state}isWon(){return"won"===this.state}isLost(){return"lost"===this.state}isOver(){return"won"===this.state||"lost"===this.state}getElapsed(){return this.elapsed}getFlags(){return this.grid.filter(t=>t.flagged).length}getMinesLeft(){return this.mineCount-this.getFlags()}getRevealedCount(){return this.grid.filter(t=>t.revealed).length}getCells(){return this.grid.map(t=>({...t}))}getCell(t,e){return this.__inBounds(t,e)?{...this.grid[t*this.cols+e]}:null}areMinesPlaced(){return this.minesPlaced}neighbors(t,e){const i=[];for(let s=-1;s<=1;s+=1)for(let o=-1;o<=1;o+=1){if(!s&&!o)continue;const n=t+s,h=e+o;this.__inBounds(n,h)&&i.push([n,h])}return i}reveal(t,e){if(this.isOver()||!this.__inBounds(t,e))return this;const i=this.__at(t,e);return i.flagged||i.revealed||(this.minesPlaced||(this.__placeMines(this.firstClickSafe?[t,e]:null),this.state="playing"),this.__revealCell(t,e),this.__checkFinish(),this.__notify()),this}toggleFlag(t,e){if(this.isOver()||!this.__inBounds(t,e))return this;const i=this.__at(t,e);return i.revealed||(i.flagged?(i.flagged=!1,i.question=this.questionMarks):i.question?i.question=!1:i.flagged=!0,this.__notify()),this}chord(t,e){if(this.isOver()||!this.__inBounds(t,e))return this;const i=this.__at(t,e);if(!i.revealed||0===i.adjacent)return this;const s=this.neighbors(t,e);return s.filter(([t,e])=>this.__at(t,e).flagged).length!==i.adjacent||(s.filter(([t,e])=>!this.__at(t,e).flagged&&!this.__at(t,e).revealed).forEach(([t,e])=>this.__revealCell(t,e)),this.__checkFinish(),this.__notify()),this}tick(){return"playing"===this.state&&(this.elapsed+=1),this}reset(t={}){return void 0!==t.rows&&(this.rows=Math.max(1,Math.floor(t.rows))),void 0!==t.cols&&(this.cols=Math.max(1,Math.floor(t.cols))),void 0!==t.mines&&(this.mineCount=Math.max(1,Math.min(this.rows*this.cols-1,Math.floor(t.mines)))),this.__resetGrid(),this.__notify(),this}addChangeListener(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}__inBounds(t,e){return t>=0&&t<this.rows&&e>=0&&e<this.cols}__at(t,e){return this.grid[t*this.cols+e]}__resetGrid(){this.grid=[];for(let t=0;t<this.rows;t+=1)for(let e=0;e<this.cols;e+=1)this.grid.push({row:t,col:e,mine:!1,revealed:!1,flagged:!1,question:!1,adjacent:0});this.state="ready",this.minesPlaced=!1,this.elapsed=0,this.firstClickSafe||this.__placeMines(null)}__placeMines(t){const e=new Set;t&&(e.add(t[0]*this.cols+t[1]),this.neighbors(t[0],t[1]).forEach(([t,i])=>e.add(t*this.cols+i)));const i=this.grid.map((t,e)=>e).filter(t=>!e.has(t)),s=i.length>=this.mineCount?i:this.grid.map((t,e)=>e).filter(e=>!t||e!==t[0]*this.cols+t[1]);for(let t=0;t<this.mineCount&&s.length;t+=1){const t=Math.min(s.length-1,Math.floor(this.random()*s.length)),e=s.splice(t,1)[0];this.grid[e].mine=!0}this.grid.forEach(t=>{t.adjacent=this.neighbors(t.row,t.col).filter(([t,e])=>this.__at(t,e).mine).length}),this.minesPlaced=!0}__revealCell(t,e){const i=this.__at(t,e);if(!i.revealed&&!i.flagged){if(i.revealed=!0,i.question=!1,i.mine)return this.state="lost",void this.grid.filter(t=>t.mine).forEach(t=>t.revealed=!0);0===i.adjacent&&this.neighbors(t,e).forEach(([t,e])=>{const i=this.__at(t,e);i.revealed||i.flagged||i.mine||this.__revealCell(t,e)})}}__checkFinish(){if(this.isOver())return;this.rows*this.cols-this.mineCount-this.getRevealedCount()<=0&&(this.state="won",this.grid.filter(t=>t.mine).forEach(t=>t.flagged=!0))}__notify(){this.listeners.forEach(t=>t(this))}},t.ICEModal=gt,t.ICENotification=j,t.ICEOverlayManager=k,t.ICEPagination=mt,t.ICEPanel=O,t.ICEPasswordField=class extends kt{visible=!1;toggleButton=null;constructor(t={}){if(super(t),this.showToggle=!0===t.showToggle,this.showToggle){const t=h.getTheme(),e=Number(this.state.width)||200,i=Number(this.state.height)||t.control.height,s=new Y({left:e-34,top:Math.max(0,(i-24)/2),width:28,height:24,text:"👁",variant:"text",size:"small",focusable:!1});s.on("click",()=>this.setVisible(!this.visible)),this.addChild(s,!1),this.toggleButton=s}this.refresh()}isVisible(){return this.visible}setVisible(t){return this.visible=!!t,this.refresh(),this}getToggleButton(){return this.toggleButton}formatDisplayValue(t){return this.visible?t:t.replace(/[\s\S]/g,"•")}},t.ICEPopconfirm=ft,t.ICEPopover=ut,t.ICEProgressBar=class extends r{track=null;fill=null;trackRing=null;ring=null;textNode=null;constructor(t={}){const i=h.getTheme(),s="circle"===t.type?"circle":"line",o="circle"===s,n=Number(t.size)||120,r=Math.max(1,Number(t.strokeWidth)||8),l=t.height||i.control.progressHeight;super({fill:!1,stroke:!1,draggable:!1,...t,width:o?t.width||n:t.width||160,height:o?t.height||n:l}),this.type=s,this.strokeWidth=r,this.showText=!1!==t.showText,this.formatFn="function"==typeof t.format?t.format:null,this.model=new Kt({value:t.value,min:t.min,max:t.max});const a="success"===t.status?i.colors.success:"error"===t.status?i.colors.error:t.color||i.colors.primary;if(o){const t=Math.min(Number(this.state.width)||n,Number(this.state.height)||n);this.trackRing=new Xt({left:0,top:0,width:t,height:t,full:!0,style:{strokeStyle:i.colors.borderSecondary,lineWidth:r,lineCap:"round"}}),this.ring=new Xt({left:0,top:0,width:t,height:t,sweep:this.__ratio(),style:{strokeStyle:a,lineWidth:r,lineCap:"round"}}),this.addChild(this.trackRing,!1),this.addChild(this.ring,!1),this.showText&&(this.textNode=new H({interactive:!1,left:0,top:0,width:t,height:t,align:"center",verticalAlign:"middle",text:this.__format(this.__ratio()),style:{fontSize:Math.max(12,Math.round(.18*t)),fillStyle:i.colors.text}}),this.addChild(this.textNode,!1))}else{const t=Number(this.state.width)||160,s=Number(this.state.height)||i.control.progressHeight;this.track=new e.ICERect({left:0,top:0,width:t,height:s,radius:s/2,style:{fillStyle:i.colors.disabled,strokeStyle:i.colors.borderSecondary,lineWidth:i.control.lineWidth}}),this.fill=new e.ICERect({left:0,top:0,width:this.__fillWidth(t),height:s,radius:s/2,style:{fillStyle:a,strokeStyle:a,lineWidth:i.control.lineWidth}}),this.addChild(this.track,!1),this.addChild(this.fill,!1)}this.model.addChangeListener(()=>this.__sync())}setValue(t){return this.model.setValue(t),this}getValue(){return this.model.getValue()}isCircle(){return"circle"===this.type}getPercent(){return this.__ratio()}getSweepRatio(){return this.__ratio()}getRingNode(){return this.ring}getTrackRingNode(){return this.trackRing}getTextNode(){return this.textNode}__ratio(){const t=this.model.getMinimum(),e=this.model.getMaximum(),i=(this.model.getValue()-t)/Math.max(1,e-t);return Math.max(0,Math.min(1,i))}__format(t){return this.formatFn?this.formatFn(t):Math.round(100*t)+"%"}__fillWidth(t){return Math.max(0,Math.min(t,t*this.__ratio()))}__sync(){if(this.isCircle()){const t=this.__ratio();this.ring&&this.ring.setState({sweep:t}),this.textNode&&this.textNode.setText(this.__format(t))}else this.fill&&this.fill.setState({width:this.__fillWidth(this.track.state.width)});this.revalidate()}},t.ICERadioButton=Pt,t.ICERadioGroup=class extends r{itemNodes=[];radioNodes=[];labelNodes=[];activeIndex=0;bound=!1;constructor(t){const e=h.getTheme(),i="vertical"===t.direction?"vertical":"horizontal",s=t.height??e.control.height;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:t.width??200,height:"vertical"===i?s*Math.max(1,(t.options||[]).length):s}),this.focusable=!0,this.options=(t.options||[]).slice(),this.direction=i,this.itemGap=t.itemGap??e.spacing.md,this.fontSize=t.fontSize??e.font.size,this.itemHeight=s,this.onChange="function"==typeof t.onChange?t.onChange:null,this.value=this.__isKnown(t.value)?String(t.value):null,this.activeIndex=this.value?Math.max(0,this.options.findIndex(t=>t.value===this.value)):0,this.__render(void 0!==t.width)}getValue(){return this.value}setValue(t){return this.__isKnown(t)&&t!==this.value?(this.value=String(t),this.activeIndex=Math.max(0,this.options.findIndex(t=>t.value===this.value)),this.__syncSelection(),this.trigger("change",null,{value:this.value}),this):this}getFormValue(){return this.value}setFormValue(t){null!=t&&""!==t&&this.setValue(String(t))}getOptionNodes(){return this.itemNodes.slice()}getItemNode(t){const e=this.options.findIndex(e=>e.value===t);return-1===e?null:this.itemNodes[e]}getRadioNode(t){const e=this.options.findIndex(e=>e.value===t);return-1===e?null:this.radioNodes[e]}getLabelTexts(){return this.labelNodes.map(t=>t.getText())}getActiveIndex(){return this.activeIndex}setOptions(t){return this.options=(t||[]).slice(),this.__isKnown(this.value)||(this.value=null),this.activeIndex=0,this.__render(!0),this}afterAddHandler(){super.afterAddHandler(),!this.bound&&this.ice&&this.ice.evtBus&&(this.bound=!0,this.ice.evtBus.on("keydown",this.__onKeyDown,this))}__isKnown(t){return this.options.some(e=>e.value===t)}__nextEnabled(t,e){let i=t;for(let s=0;s<this.options.length;s+=1){if(i+=e,i<0||i>=this.options.length)return t;if(!this.options[i].disabled)return i}return t}__onKeyDown(t){if(!this.ice||!this.enabled||!this.isFocused())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if("ArrowRight"===i||"ArrowDown"===i)this.__moveActive(1);else if("ArrowLeft"===i||"ArrowUp"===i)this.__moveActive(-1);else if("Enter"===i||" "===i||"Spacebar"===i){const t=this.options[this.activeIndex];t&&this.__select(t,!1)}}__moveActive(t){const e=this.__nextEnabled(this.activeIndex,t);e!==this.activeIndex&&(this.activeIndex=e,this.__select(this.options[e],!1))}__select(t,e){t&&!t.disabled&&this.enabled&&t.value!==this.value&&(this.value=t.value,this.activeIndex=this.options.indexOf(t),this.__syncSelection(),this.trigger("change",null,{value:this.value}),e&&this.onChange&&this.onChange(this.value))}__syncSelection(){this.options.forEach((t,e)=>{const i=this.radioNodes[e];i&&i.setSelected(t.value===this.value)}),this.revalidate(),this.ice&&(this.ice.dirty=!0)}__render(t){const e=h.getTheme();this.removeChildren([...this.childNodes]),this.itemNodes=[],this.radioNodes=[],this.labelNodes=[];const i=e.control.radioSize,s=e.spacing.xs;let o=0,n=0;this.options.forEach((t,h)=>{const l=String(t.label??t.value),a=F(l,this.fontSize),d=i+s+a,c="vertical"===this.direction?0:o,u="vertical"===this.direction?h*this.itemHeight:0,f=new r({left:c,top:u,width:d,height:this.itemHeight,fill:!1,stroke:!1,interactive:!t.disabled,focusable:!1}),g=new Pt({left:0,top:0,width:i,height:this.itemHeight,selected:t.value===this.value,focusable:!1,interactive:!1});t.disabled&&g.setEnabled(!1);const m=new H({interactive:!1,left:i+s,top:0,width:a,height:this.itemHeight,text:l,verticalAlign:"middle",style:{fontSize:this.fontSize,fontFamily:e.font.family,fillStyle:t.disabled?e.colors.textDisabled:e.colors.text}});f.addChild(g,!1),f.addChild(m,!1),f.on("click",()=>this.__select(t,!0)),this.addChild(f,!1),this.itemNodes.push(f),this.radioNodes.push(g),this.labelNodes.push(m),n=Math.max(n,d),o+=d+this.itemGap}),"vertical"===this.direction&&(this.state.height=this.itemHeight*Math.max(1,this.options.length)),this.state.width=t?Math.max(Number(this.state.width)||0,n):n,this.__syncSelection()}},t.ICERate=class extends r{preview=0;starNodes=[];running=!1;constructor(t={}){const e=h.getTheme(),i=Math.max(1,t.count??5),s=t.size??24;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:i*(s+4),height:s,interactive:!(!0===t.disabled)}),this.count=i,this.value=Math.min(i,Math.max(0,Number(t.value)||0)),this.disabled=!0===t.disabled,this.size=s,this.color=t.color||e.colors.warning,this.onChange="function"==typeof t.onChange?t.onChange:null,this.focusable=!this.disabled,this.__render()}afterAddHandler(){super.afterAddHandler(),!this.running&&this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("mousemove",this.__onMouseMove,this),this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.on("click",this.__onClick,this),this.running=!0)}getValue(){return this.value}setValue(t){const e=Math.min(this.count,Math.max(0,Math.round(Number(t)||0)));return e===this.value||(this.value=e,this.__render()),this}getPreviewValue(){return this.preview}getStarNodes(){return this.starNodes.slice()}setDisabled(t){return this.disabled=!!t,this.focusable=!this.disabled,this.__render(),this}__starIndexAt(t){const e=this.__worldBox();if(!(t>=e.left&&t<=e.left+e.width))return 0;const i=Math.ceil((t-e.left)/(this.size+4));return Math.min(this.count,Math.max(1,i))}__onClick(t){if(this.disabled||!t||"number"!=typeof t.offsetX)return;const e=this.__starIndexAt(t.offsetX);e>0&&this.__applyValue(e)}__onMouseMove(t){if(this.disabled||!t||"number"!=typeof t.offsetX)return;const e=this.__starIndexAt(t.offsetX);e&&e!==this.preview&&(this.preview=e,this.__render())}__onMouseLeave(){this.preview&&(this.preview=0,this.__render())}__onKeyDown(t){if(this.disabled||!this.isFocused())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);"ArrowRight"===i||"ArrowUp"===i?this.__applyValue(this.value+1):"ArrowLeft"!==i&&"ArrowDown"!==i||this.__applyValue(this.value-1)}__applyValue(t){const e=Math.min(this.count,Math.max(0,t));e!==this.value&&(this.value=e,this.__render(),this.onChange&&this.onChange(e))}__worldBox(){let t=0,e=0,i=this;for(;i&&i.state;)t+=Number(i.state.left)||0,e+=Number(i.state.top)||0,i=i.parentNode;return{left:t,top:e,width:Number(this.state.width)||0,height:Number(this.state.height)||0}}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]),this.starNodes=[];const e=this.preview||this.value;for(let i=0;i<this.count;i++){const s=i<e,o=new r({left:i*(this.size+4),top:0,width:this.size,height:this.size,fill:!1,stroke:!1,interactive:!1});o.addChild(new H({interactive:!1,left:0,top:0,width:this.size,height:this.size,align:"center",verticalAlign:"middle",text:s?"★":"☆",style:{fontSize:this.size-4,fillStyle:s?this.color:t.colors.disabled}}),!1),this.addChild(o,!1),this.starNodes.push(o)}this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}},t.ICEResult=class extends r{buttons=new Map;constructor(t){const e=h.getTheme(),i=t.width??320,s=t.height??200;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:i,height:s});const o=t.status||"info",n="success"===o?e.colors.success:"error"===o?e.colors.error:"warning"===o?e.colors.warning:e.colors.info,r="success"===o?"✓":"error"===o?"✕":"warning"===o?"!":"ℹ";this.addChild(new H({interactive:!1,left:0,top:Math.max(8,s/2-72),width:i,height:44,align:"center",verticalAlign:"middle",text:r,style:{fontSize:36,fillStyle:n}}),!1),t.title&&this.addChild(new H({interactive:!1,left:0,top:Math.max(56,s/2-28),width:i,height:24,align:"center",verticalAlign:"middle",text:t.title,style:{fontSize:16,fontWeight:"600",fillStyle:e.colors.text}}),!1),t.subtitle&&this.addChild(new H({interactive:!1,left:0,top:Math.max(82,s/2-2),width:i,height:20,align:"center",verticalAlign:"middle",text:t.subtitle,style:{fontSize:12,fillStyle:e.colors.textSecondary}}),!1);const l=t.actions||[];if(l.length){const e=110,o=12,n=(i-(l.length*e+(l.length-1)*o))/2;l.forEach((i,h)=>{const r=new Y({left:n+h*(e+o),top:Math.max(110,s/2+26),width:e,height:32,text:i.text,size:"small",variant:i.primary?"primary":"default"});r.on("click",()=>{t.onAction&&t.onAction(i.key)}),this.addChild(r,!1),this.buttons.set(i.key,r)})}}getActionButton(t){return this.buttons.get(t)||null}},t.ICEScrollPane=_t,t.ICESegmented=class extends W{nodes=new Map;constructor(t){const e=h.getTheme(),i=t.height??32;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:t.width??240,height:i,radius:e.radius.md,style:{fillStyle:e.colors.background,strokeStyle:e.colors.border}}),this.options=(t.options||[]).slice(),this.value=t.value??(this.options.length?this.options[0].value:null),this.heightValue=i,this.onChange="function"==typeof t.onChange?t.onChange:null,this.__render()}getValue(){return this.value}setValue(t){return this.value===t||(this.value=t,this.__render()),this}getSegmentNode(t){return this.nodes.get(t)||null}__render(){this.removeChildren([...this.childNodes]),this.nodes.clear();const t=Number(this.state.width)||240,e=Math.max(1,this.options.length),i=(t-4-2*(e-1))/e;this.options.forEach((t,e)=>{const s=t.value===this.value,o=new Y({left:2+e*(i+2),top:2,width:i,height:this.heightValue-4,text:t.label,size:"small",variant:s?"primary":"text",focusable:!t.disabled});t.disabled&&o.setEnabled(!1),o.on("click",()=>{if(t.disabled)return;const e=this.value!==t.value;this.value=t.value,this.__render(),e&&this.onChange&&this.onChange(t.value)}),this.addChild(o,!1),this.nodes.set(t.value,o)}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}},t.ICESelect=class extends r{handle=null;fieldLabel=null;panel=null;optionNodes=new Map;visible=[];query="";activeIndex=0;running=!1;constructor(t){const e=h.getTheme(),i=t.width??200,s=t.height??e.control.height;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:i,height:s,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.options=(t.options||[]).slice(),this.mode=t.mode||"single",this.showSearch=!0===t.showSearch,this.placeholder=t.placeholder||"",this.disabled=!0===t.disabled,this.optionHeight=t.optionHeight??34,this.onChange="function"==typeof t.onChange?t.onChange:null,this.manager=t.manager||null,this.selected=this.__normalizeValue(t.value),this.focusable=!1!==t.focusable&&!this.disabled,this.focusRingMode="always",this.__syncField()}afterAddHandler(){super.afterAddHandler(),this.running||(!this.manager&&this.ice&&(this.manager=z(this.ice)),this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.on("click",this.__onClick,this),this.running=!0)}setOverlayManager(t){return this.manager=t,this}__overlayManager(){if(!this.manager){if(!this.ice)throw new Error("ICESelect 需要先加入 ICE 场景(或显式 setOverlayManager)");this.manager=z(this.ice)}return this.manager}getValue(){return"multiple"===this.mode?this.selected.slice():this.selected.length?this.selected[0]:void 0}setValue(t){return this.selected=this.__normalizeValue(t),this.__syncField(),this}getFormValue(){return this.getValue()}setFormValue(t){this.setValue(t)}isOpen(){return!!this.handle&&this.handle.isOpen()}getFieldLabel(){return this.fieldLabel?this.fieldLabel.getText():""}getQuery(){return this.query}getVisibleOptions(){return this.visible.slice()}getOptionNode(t){return this.optionNodes.get(t)||null}setOptions(t){return this.options=(t||[]).slice(),this.isOpen()&&this.__buildPanel(),this}activate(){this.toggle()}toggle(){return this.isOpen()?this.close():this.open()}__onClick(){this.disabled||this.toggle()}open(){if(this.disabled||this.isOpen())return this;const t=this.__overlayManager();return this.panel=this.__createPanel(),this.__buildPanel(),this.handle=t.open({anchor:this,content:this.panel,placement:"bottomLeft",offset:4,enterAnimation:"scale",exitAnimation:"fade",keyboardCaptured:!0}),this}close(){return this.handle&&(this.handle.close(),this.handle=null),this.panel=null,this.optionNodes.clear(),this.query="",this.visible=[],this}__onKeyDown(t){if(!this.isOpen())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if("Escape"!==i&&"Esc"!==i)if("ArrowDown"!==i&&"ArrowUp"!==i)if("Enter"!==i)this.showSearch&&"string"==typeof i&&("Backspace"===i?this.__setQuery(this.query.slice(0,-1)):1!==i.length||e.metaKey||e.ctrlKey||this.__setQuery(this.query+i));else{const t=this.visible[this.activeIndex];t&&this.__pick(t)}else this.__moveActive("ArrowDown"===i?1:-1);else this.close()}__moveActive(t){const e=this.visible.length;if(!e)return;let i=this.activeIndex;for(let s=0;s<e;s++)if(i=(i+t+e)%e,!this.visible[i].disabled)return this.activeIndex=i,void this.__buildPanel()}__setQuery(t){this.query=t,this.activeIndex=0,this.__buildPanel()}__pick(t){if(t&&!t.disabled){if("multiple"===this.mode){const e=this.selected.indexOf(t.value);return-1===e?this.selected.push(t.value):this.selected.splice(e,1),this.__syncField(),this.__buildPanel(),void(this.onChange&&this.onChange(this.getValue(),t))}this.selected=[t.value],this.__syncField(),this.close(),this.onChange&&this.onChange(t.value,t)}}__normalizeValue(t){return"multiple"===this.mode&&Array.isArray(t)?t.map(String):null==t||""===t?[]:[String(t)]}__syncField(){const t=h.getTheme(),e=Number(this.state.width)||200,i=Number(this.state.height)||32,s="error"===this.validateStatus?t.colors.error:this.disabled?t.colors.borderSecondary:t.colors.border;this.setState({style:{...this.state.style,fillStyle:this.disabled?t.colors.disabled:t.colors.surface,strokeStyle:s}}),this.removeChildren([...this.childNodes]);const o=this.selected.map(t=>{const e=this.options.find(e=>e.value===t);return e?e.label:t}).join("、");this.fieldLabel=new H({interactive:!1,left:10,top:0,width:Math.max(0,e-34),height:i,verticalAlign:"middle",text:o||this.placeholder,style:{fontSize:13,fillStyle:o?t.colors.text:t.colors.textTertiary}}),this.addChild(this.fieldLabel,!1),this.addChild(new H({interactive:!1,left:e-22,top:0,width:14,height:i,verticalAlign:"middle",align:"center",text:"▾",style:{fontSize:12,fillStyle:t.colors.textTertiary}}),!1)}__createPanel(){const t=h.getTheme(),e=Number(this.state.width)||200,i=this.showSearch?30:0;return new O({width:e,height:i+Math.min(6,this.options.length)*this.optionHeight+8,radius:t.radius.md,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"md"}})}__buildPanel(){const t=this.panel;if(!t)return;const e=h.getTheme();t.removeChildren([...t.childNodes]),this.optionNodes.clear();const i=Number(t.state.width)||Number(this.state.width)||200,s=this.showSearch?30:0,o=this.query.trim().toLowerCase();this.visible=this.options.filter(t=>!o||-1!==t.label.toLowerCase().indexOf(o)||-1!==t.value.toLowerCase().indexOf(o)),this.activeIndex>=this.visible.length&&(this.activeIndex=0),this.showSearch&&t.addChild(new H({interactive:!1,left:10,top:0,width:i-20,height:s,verticalAlign:"middle",text:this.query?this.query+"|":"搜索…",style:{fontSize:12,fillStyle:this.query?e.colors.text:e.colors.textTertiary}}),!1),this.visible.forEach((o,n)=>{const h=-1!==this.selected.indexOf(o.value),l=n===this.activeIndex,a=new r({left:4,top:6+s+n*this.optionHeight,width:i-8,height:this.optionHeight,radius:e.radius.sm,fill:!0,stroke:!1,style:{fillStyle:h?e.colors.primaryBg:l?e.colors.background:"rgba(0,0,0,0)"}});a.setState({interactive:!o.disabled});const d=o.disabled?e.colors.textDisabled:h?e.colors.primary:e.colors.text;a.addChild(new H({interactive:!1,left:10,top:0,height:this.optionHeight,verticalAlign:"middle",text:o.label,style:{fontSize:13,fillStyle:d}}),!1),h&&a.addChild(new H({interactive:!1,left:i-32,top:0,width:16,height:this.optionHeight,verticalAlign:"middle",text:"✓",style:{fontSize:12,fillStyle:e.colors.primary}}),!1),o.disabled||a.on("click",()=>this.__pick(o)),t.addChild(a,!1),this.optionNodes.set(o.value,a)}),t.setState({height:6+s+Math.max(1,this.visible.length)*this.optionHeight+6}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}},t.ICESelectionModel=wt,t.ICESeparator=class extends r{constructor(t={}){const i=h.getTheme();super({fill:!1,stroke:!1,...t}),this.addChild(new e.ICERect({left:0,top:0,width:t.width||1,height:t.height||1,style:{fillStyle:i.colors.border,strokeStyle:i.colors.border}}),!1)}},t.ICESkeleton=class extends r{placeholders=[];pulse=null;constructor(t){const e=h.getTheme(),i=t.width??240,s=Math.max(0,t.rows??3),o=!0===t.avatar,n=!0===t.title,l=n?20:0,a=o?52:0,d=l+(n&&s?10:0)+14*s+10*Math.max(0,s-1),c=t.height??Math.max(o?40:0,d);super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:i,height:c}),this.active=!0===t.active;const u=(t,i,s,o)=>{const n=new r({left:t,top:i,width:s,height:o,radius:4,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:e.colors.disabled}});this.addChild(n,!1),this.placeholders.push(n)};if(o){const t=new r({left:0,top:0,width:40,height:40,radius:20,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:e.colors.disabled}});this.addChild(t,!1),this.placeholders.push(t)}n&&u(a,0,Math.min(i-a,Math.round(.4*i)),l);for(let t=0;t<s;t++){const e=l+(n?10:0)+24*t,o=t===s-1?Math.round(.6*(i-a)):i-a;u(a,e,Math.max(24,o),14)}this.active&&this.__startPulse()}isActive(){return this.active}getPlaceholderCount(){return this.placeholders.length}setActive(t){const e=!!t;return e===this.active||(this.active=e,e?this.__startPulse():(this.__stopPulse(),this.setState({opacity:1}))),this}__startPulse(){if(this.pulse)return;const t=()=>{this.pulse=_({from:.55,to:1,duration:700,easing:"easeInOut",onUpdate:t=>this.setState({opacity:t}),onFinish:()=>{this.active&&(this.pulse=_({from:1,to:.55,duration:700,easing:"easeInOut",onUpdate:t=>this.setState({opacity:t}),onFinish:()=>{this.pulse=null,this.active&&t()}}))}})};t()}__stopPulse(){this.pulse&&(this.pulse.cancel(),this.pulse=null)}},t.ICESlider=class extends r{upperThumb=null;rangeValue=null;activeThumb="lower";dragThumb=null;dragging=!1;__bound=!1;constructor(t={}){const i=h.getTheme();super({fill:!1,stroke:!1,draggable:!1,...t}),this.focusable=!1!==t.focusable,this.range=!0===t.range,this.step=Math.max(0,Number(t.step)||0),this.minValue=void 0===t.min?0:Number(t.min),this.maxValue=void 0===t.max?100:Number(t.max);const s=this.__normalizeRange(t.value);this.model=new Kt({value:s[0],min:t.min,max:t.max}),this.range&&(this.rangeValue=[this.model.getValue(),s[1]]);const o=t.width||160,n=t.trackHeight||i.control.sliderTrackHeight,r=t.thumbSize||i.control.sliderHandle,l=Math.max(t.height||i.control.sliderHandle,r),a=(l-n)/2;this.track=new e.ICERect({left:0,top:a,width:o,height:n,radius:n/2,style:{fillStyle:i.colors.borderSecondary,strokeStyle:i.colors.borderSecondary,lineWidth:i.control.lineWidth}}),this.fill=new e.ICERect({left:0,top:a,width:this.__fillWidth(o),height:n,radius:n/2,style:{fillStyle:i.colors.primary,strokeStyle:i.colors.primary,lineWidth:i.control.lineWidth}}),this.thumb=new e.ICECircle({left:this.__thumbLeft(o,r),top:(l-r)/2,radius:r/2,style:{fillStyle:i.colors.primary,strokeStyle:i.colors.surface,lineWidth:i.control.lineWidth+1,...i.shadows.sm}}),this.addChild(this.track,!1),this.addChild(this.fill,!1),this.addChild(this.thumb,!1),this.range&&(this.upperThumb=new e.ICECircle({left:this.__upperThumbLeft(o,r),top:(l-r)/2,radius:r/2,style:{fillStyle:i.colors.primary,strokeStyle:i.colors.surface,lineWidth:i.control.lineWidth+1,...i.shadows.sm}}),this.addChild(this.upperThumb,!1)),this.model.addChangeListener(()=>{this.range&&this.rangeValue&&(this.rangeValue=[this.model.getValue(),Math.max(this.model.getValue(),this.rangeValue[1])]),this.__sync(),this.trigger("change",null,{value:this.getValue()})}),this.__sync()}isRange(){return this.range}setValue(t){return this.model.setValue(this.__quantize(t)),this}getValue(){return this.model.getValue()}getRangeValue(){return this.rangeValue?[...this.rangeValue]:null}setRangeValue(t){if(!this.range)return this;const[e,i]=this.__normalizeRange(t);return this.rangeValue=[e,i],this.model.setValue(e),this.__sync(),this}getThumbs(){return this.upperThumb?[this.thumb,this.upperThumb]:[this.thumb]}getActiveThumb(){return this.activeThumb}setActiveThumb(t){return this.activeThumb="upper"===t?"upper":"lower",this.__sync(),this}setValueFromRatio(t,e){const i=Math.max(0,Math.min(1,Number(t)||0)),s=this.model.getMinimum(),o=this.model.getMaximum(),n=s+i*(o-s);if(!this.range)return this.model.setValue(n),this;const[h,r]=this.rangeValue||[s,o],l=Math.max(1,o-s),a="lower"===e||"upper"===e?e:Math.abs(i-(h-s)/l)<=Math.abs(i-(r-s)/l)?"lower":"upper";if(this.activeThumb=a,"lower"===a){const t=Math.min(this.__quantize(n),r);this.rangeValue=[t,r],this.model.setValue(t)}else{const t=Math.max(this.__quantize(n),h);this.rangeValue=[h,t],this.model.setValue(h)}return this.__sync(),this}getFormValue(){return this.range?this.getRangeValue():this.getValue()}setFormValue(t){if(this.range)if(Array.isArray(t))this.setRangeValue(t.map(t=>Number(t)));else{const e=Number(t);this.setRangeValue([e,e])}else this.setValue(Number(t))}afterAddHandler(){super.afterAddHandler(),this.__bindGlobalEvents(),this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&this.ice.evtBus.on("keydown",this.__onKeyDown,this)}__bindGlobalEvents(){!this.__bound&&this.ice&&this.ice.evtBus&&(this.__bound=!0,this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this),this.ice.evtBus.on("mousemove",this.__onGlobalMouseMove,this),this.ice.evtBus.on("mouseup",this.__onGlobalMouseUp,this))}__onGlobalMouseDown(t){this.enabled&&this.__isPointInside(t)&&(this.dragging=!0,this.__updateFromEvent(t),this.dragThumb=this.range?this.activeThumb:null)}__onGlobalMouseMove(t){this.dragging&&this.__updateFromEvent(t)}__onGlobalMouseUp(){this.dragging=!1,this.dragThumb=null}__onKeyDown(t){if(!this.enabled||!this.isFocused())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);if("ArrowRight"!==i&&"ArrowUp"!==i&&"ArrowLeft"!==i&&"ArrowDown"!==i)return;const s=this.step>0?this.step:Math.max((this.maxValue-this.minValue)/100,Number.EPSILON),o="ArrowRight"===i||"ArrowUp"===i?1:-1;if(this.range&&this.rangeValue){const[t,e]=this.rangeValue;"upper"===this.activeThumb?this.setRangeValue([t,e+o*s]):this.setRangeValue([t+o*s,e])}else this.setValue(this.getValue()+o*s)}__isPointInside(t){if(!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return!1;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return!1;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=this.getMinBoundingBox(!0);return e>=s.tl[0]&&e<=s.br[0]&&i>=s.tl[1]&&i<=s.br[1]}__updateFromEvent(t){if(!t||"number"!=typeof t.offsetX)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e]=this.ice.screenToWorld(t.offsetX,t.offsetY),i=this.getMinBoundingBox(!0),s=i.br[0]-i.tl[0]||1,o=Math.max(0,Math.min(1,(e-i.tl[0])/s));this.setValueFromRatio(o,this.dragThumb||void 0)}__applyHoverState(){this.__sync()}__quantize(t){const e=Math.min(this.minValue,this.maxValue),i=Math.max(this.minValue,this.maxValue),s=Number(t),o=Math.min(i,Math.max(e,Number.isFinite(s)?s:e));if(this.step<=0)return o;const n=e+Math.round((o-e)/this.step)*this.step;return Number(Math.min(i,Math.max(e,n)).toFixed(6))}__normalizeRange(t){const e=Math.min(this.minValue,this.maxValue);let i,s;Array.isArray(t)?(i=Number(t[0]),s=Number(t[1])):null==t?(i=e,s=e):(i=Number(t),s=Number(t));const o=this.__quantize(i),n=this.__quantize(s);return o<=n?[o,n]:[n,o]}__ratio(t){const e=this.model.getMinimum(),i=this.model.getMaximum();return Math.max(0,Math.min(1,(t-e)/Math.max(1,i-e)))}__thumbStyle(t){const e=h.getTheme(),i=this.hovered||this.dragging&&this.activeThumb===t;return{fillStyle:i?e.colors.primaryHover:e.colors.primary,strokeStyle:e.colors.surface,lineWidth:e.control.lineWidth+(i?2:1),...e.shadows.sm}}__thumbLeft(t,e){const i=e??(2*Number(this.thumb.state.radius)||0);return t*this.__ratio(this.model.getValue())-i/2}__upperThumbLeft(t,e){const i=this.rangeValue?this.rangeValue[1]:this.model.getValue();return t*this.__ratio(i)-e/2}__fillWidth(t){return this.range&&this.rangeValue?t*Math.max(0,this.__ratio(this.rangeValue[1])-this.__ratio(this.rangeValue[0])):t*this.__ratio(this.model.getValue())}__sync(){const t=h.getTheme(),e=Number(this.track.state.width),i=2*Number(this.thumb.state.radius)||0;this.thumb.setState({left:this.__thumbLeft(e),style:this.__thumbStyle("lower")}),this.upperThumb&&this.upperThumb.setState({left:this.__upperThumbLeft(e,i),style:this.__thumbStyle("upper")});const s=this.range&&this.rangeValue?e*this.__ratio(this.rangeValue[0]):0,o=this.hovered?t.colors.primaryHover:t.colors.primary;this.fill.setState({left:s,width:this.__fillWidth(e),style:{fillStyle:o,strokeStyle:o,lineWidth:t.control.lineWidth}}),this.revalidate()}},t.ICESnakeModel=class{body=[];food=null;direction="right";queue=[];score=0;eaten=0;gameOver=!1;paused=!1;listeners=new Set;constructor(t={}){this.rows=Math.max(4,Math.floor(t.rows??20)),this.cols=Math.max(4,Math.floor(t.cols??20)),this.random=t.random||Math.random,this.wrap=!0===t.wrap,this.initialLength=Math.max(2,Math.floor(t.initialLength??3)),this.__resetBoard()}getRows(){return this.rows}getCols(){return this.cols}getBody(){return this.body.map(([t,e])=>[t,e])}getHead(){return[this.body[0][0],this.body[0][1]]}getLength(){return this.body.length}getFood(){return this.food?[this.food[0],this.food[1]]:null}getDirection(){return this.direction}getPendingDirections(){return this.queue.slice()}getScore(){return this.score}getEaten(){return this.eaten}getLevel(){return 1+Math.floor(this.eaten/5)}getTickInterval(){return Math.max(70,Math.round(170*.88**(this.getLevel()-1)))}isGameOver(){return this.gameOver}isPaused(){return this.paused}addChangeListener(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}setDirection(t){if(!pe[t]||this.gameOver||this.paused)return!1;const e=this.queue.length?this.queue[this.queue.length-1]:this.direction;return t===e||t!==ye[e]&&(!(this.queue.length>=2)&&(this.queue.push(t),this.notify(),!0))}tick(){if(this.gameOver||this.paused)return!1;this.queue.length&&(this.direction=this.queue.shift());const[t,e]=this.body[0],[i,s]=pe[this.direction];let o=t+i,n=e+s;if(this.wrap)o=(o+this.rows)%this.rows,n=(n+this.cols)%this.cols;else if(o<0||o>=this.rows||n<0||n>=this.cols)return this.__die();const h=!!this.food&&this.food[0]===o&&this.food[1]===n;return(h?this.body:this.body.slice(0,this.body.length-1)).some(([t,e])=>t===o&&e===n)?this.__die():(this.body.unshift([o,n]),h?(this.score+=10*this.getLevel(),this.eaten+=1,this.__spawnFood(),this.food||(this.gameOver=!0)):this.body.pop(),this.notify(),!0)}pause(){this.paused||this.gameOver||(this.paused=!0,this.notify())}resume(){this.paused&&(this.paused=!1,this.notify())}reset(t={}){void 0!==t.rows&&(this.rows=Math.max(4,Math.floor(t.rows))),void 0!==t.cols&&(this.cols=Math.max(4,Math.floor(t.cols))),t.random&&(this.random=t.random),void 0!==t.wrap&&(this.wrap=!0===t.wrap),void 0!==t.initialLength&&(this.initialLength=Math.max(2,Math.floor(t.initialLength))),this.__resetBoard(),this.notify()}setBodyForTest(t,e){t.length&&(this.body=t.map(([t,e])=>[t,e]),e&&(this.direction=e),this.queue=[],this.gameOver=!1,this.notify())}setFoodForTest(t,e){this.food=[t,e],this.notify()}__resetBoard(){const t=Math.floor(this.rows/2),e=Math.floor(this.cols/2);this.body=[];for(let i=0;i<this.initialLength;i+=1)this.body.push([t,e-i]);this.direction="right",this.queue=[],this.score=0,this.eaten=0,this.gameOver=!1,this.paused=!1,this.food=null,this.__spawnFood()}__die(){return this.gameOver=!0,this.notify(),!1}__spawnFood(){const t=[];for(let e=0;e<this.rows;e+=1)for(let i=0;i<this.cols;i+=1)this.body.some(([t,s])=>t===e&&s===i)||t.push([e,i]);if(!t.length)return void(this.food=null);const e=Math.min(t.length-1,Math.floor(this.random()*t.length));this.food=t[Math.max(0,e)]}notify(){this.listeners.forEach(t=>t(this))}},t.ICESpace=class extends W{items=[];constructor(t={}){super({id:t.id,fill:!1,stroke:!1,interactive:!1,left:t.left,top:t.top,width:t.width??0,height:t.height??0}),this.direction="vertical"===t.direction?"vertical":"horizontal",this.gap=t.size??8,this.align=t.align||"start",this.wrap=!0===t.wrap,this.autoWidth=void 0===t.width,this.autoHeight=void 0===t.height}getItems(){return this.items.slice()}setSize(t){return this.gap=Number(t)||0,this.__layout(),this}getSize(){return this.gap}setAlign(t){return this.align=t,this.__layout(),this}addItem(t){return super.addChild(t),this.items.push(t),this.__layout(),this}addChild(t,e=!0){super.addChild(t,e),-1===this.items.indexOf(t)&&(this.items.push(t),this.__layout())}removeItem(t){const e=this.items.indexOf(t);return-1!==e&&(this.items.splice(e,1),this.removeChild(t),this.__layout()),this}revalidate(){return super.revalidate(),this.__layout(),this}__crossOffset(t,e){return"center"===this.align?Math.max(0,(e-t)/2):"end"===this.align?Math.max(0,e-t):0}__layout(){if(!this.items.length)return;const t=Number(this.state.width)||0;if(Number(this.state.height),"vertical"===this.direction){const e=this.items.reduce((t,e)=>Math.max(t,Number(e.state.width)||0),0),i=this.autoWidth?e:t;let s=0;this.items.forEach(t=>{t.setState({left:this.__crossOffset(Number(t.state.width)||0,i),top:s}),s+=(Number(t.state.height)||0)+this.gap});const o=Math.max(0,s-this.gap);return this.state.width=i,this.autoHeight&&(this.state.height=o),void this.__markDirty()}const e=t,i=[[]];let s=0,o=0;this.items.forEach(t=>{const n=Number(t.state.width)||0;this.wrap&&e>0&&i[i.length-1].length>0&&s+this.gap+n>e&&(i.push([]),s=0,o=0),i[i.length-1].push(t),s+=(i[i.length-1].length>1?this.gap:0)+n,o=Math.max(o,Number(t.state.height)||0)});let n=0,h=0;i.forEach(t=>{const e=t.reduce((t,e)=>Math.max(t,Number(e.state.height)||0),0);let i=0;t.forEach(t=>{t.setState({left:i,top:n+this.__crossOffset(Number(t.state.height)||0,e)}),i+=(Number(t.state.width)||0)+this.gap,h=Math.max(h,i-this.gap)}),n+=e+this.gap});const r=Math.max(0,n-this.gap);this.autoWidth&&(this.state.width=h),this.autoHeight&&(this.state.height=r),this.__markDirty()}__markDirty(){this.ice&&(this.ice.dirty=!0)}},t.ICESpin=class extends r{constructor(t={}){const e=h.getTheme(),i=t.size??24,s=t.tip||"";super({fill:!1,stroke:!1,left:t.left,top:t.top,width:i,height:i,interactive:!1}),this.spinning=!1!==t.spinning,this.arc=new Nt({left:0,top:0,width:i,height:i,style:{strokeStyle:t.color||e.colors.primary,lineWidth:Math.max(2,Math.round(i/10)),lineCap:"round",fillStyle:"rgba(0,0,0,0)"}}),this.addChild(this.arc,!1),s&&(this.addChild(new H({interactive:!1,left:i+8,top:0,height:i,verticalAlign:"middle",text:s,style:{fontSize:12,fillStyle:e.colors.textSecondary}}),!1),this.setState({width:i+8+12*s.length+4})),this.spinning&&this.__startSpin()}afterAddHandler(){super.afterAddHandler(),this.spinning&&this.__startSpin()}isSpinning(){return this.spinning}getArcNode(){return this.arc}setSpinning(t){const e=!!t;return e===this.spinning||(this.spinning=e,e?this.__startSpin():this.__stopSpin()),this}__startSpin(){this.arc.setState({transform:{...this.arc.state.transform||{},rotate:0}}),this.arc.props.animations={...this.arc.props.animations||{},"transform.rotate":{from:0,to:360,duration:900,loop:!0}},this.ice&&this.ice.animationManager&&this.ice.animationManager.add(this.arc)}__stopSpin(){if(this.arc.props.animations){const t={...this.arc.props.animations};delete t["transform.rotate"],this.arc.props.animations=t}this.ice&&this.ice.animationManager&&"function"==typeof this.ice.animationManager.remove&&this.ice.animationManager.remove(this.arc)}},t.ICESplitter=class extends r{first=null;second=null;dragging=!1;bound=!1;laying=!1;constructor(t){h.getTheme();const e=t.dividerSize??6,i="vertical"===t.direction?"vertical":"horizontal";super({id:t.id,fill:!1,stroke:!1,interactive:!1,left:t.left,top:t.top,width:t.width??320,height:t.height??200}),this.direction=i,this.dividerSize=Math.max(2,e),this.min=Math.max(0,Number(t.min)||40),this.onResize="function"==typeof t.onResize?t.onResize:null,this.requestedSize=Number(t.size)||0,this.size=this.__clamp(this.requestedSize),this.first=t.first??null,this.second=t.second??null,this.divider=new ee({left:0,top:0,width:"horizontal"===i?this.dividerSize:Number(this.state.width),height:"horizontal"===i?Number(this.state.height):this.dividerSize}),this.first&&this.addChild(this.first,!1),this.second&&this.addChild(this.second,!1),this.addChild(this.divider,!1),this.__layout()}getSize(){return this.size}getRatio(){const t=this.__total();return t>0?this.size/t:0}setRatio(t){const e=Math.max(0,Math.min(1,Number(t)||0));return this.setSize(e*this.__total())}setSize(t){this.requestedSize=Number(t)||0;const e=this.__clamp(this.requestedSize);return e===this.size||(this.size=e,this.__layout(),this.trigger("resize",null,{size:this.size}),this.onResize&&this.onResize(this.size)),this}getDividerNode(){return this.divider}getFirstNode(){return this.first}getSecondNode(){return this.second}afterAddHandler(){super.afterAddHandler(),!this.bound&&this.ice&&this.ice.evtBus&&(this.bound=!0,this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this),this.ice.evtBus.on("mousemove",this.__onGlobalMouseMove,this),this.ice.evtBus.on("mouseup",this.__onGlobalMouseUp,this))}revalidate(){return super.revalidate(),this.__layout(),this}__afterStateMerge(t){super.__afterStateMerge(t),t&&this.__layout()}__applyHoverState(){}__syncDivider(){this.divider.setActive(this.dragging)}__max(){return Math.max(this.min,this.__total()-this.dividerSize-this.min)}__total(){return"horizontal"===this.direction?Number(this.state.width)||0:Number(this.state.height)||0}__clamp(t){return Math.max(this.min,Math.min(this.__max(),Number(t)||0))}__layout(){if(this.laying)return;this.laying=!0;const t=Number(this.state.width)||0,e=Number(this.state.height)||0;this.size=this.__clamp(this.requestedSize);"horizontal"===this.direction?(this.first&&this.first.setState({left:0,top:0,width:this.size,height:e}),this.divider.setState({left:this.size,top:0,width:this.dividerSize,height:e}),this.second&&this.second.setState({left:this.size+this.dividerSize,top:0,width:Math.max(0,t-this.size-this.dividerSize),height:e})):(this.first&&this.first.setState({left:0,top:0,width:t,height:this.size}),this.divider.setState({left:0,top:this.size,width:t,height:this.dividerSize}),this.second&&this.second.setState({left:0,top:this.size+this.dividerSize,width:t,height:Math.max(0,e-this.size-this.dividerSize)})),this.__syncDivider(),this.laying=!1}__onGlobalMouseDown(t){this.enabled&&this.__isOnDivider(t)&&(this.dragging=!0,this.__updateFromEvent(t),this.__syncDivider())}__onGlobalMouseMove(t){this.dragging&&this.__updateFromEvent(t)}__onGlobalMouseUp(){this.dragging&&(this.dragging=!1,this.__syncDivider())}isDragging(){return this.dragging}__isOnDivider(t){if(!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return!1;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return!1;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=E(this.divider);return e>=s.left-2&&e<=s.left+s.width+2&&i>=s.top-2&&i<=s.top+s.height+2}__updateFromEvent(t){if(!t||"number"!=typeof t.offsetX)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=E(this),o=("horizontal"===this.direction?e-s.left:i-s.top)-this.dividerSize/2;this.setSize(o)}},t.ICEStatCard=class extends O{constructor(t={}){super({...t,style:{shadow:"sm",...t.style||{}}});const i=h.getTheme(),s=t.width||220,o=t.height||120,n=t.iconColor||i.colors.primary,r=t.iconBg||i.colors.primaryBg,l=t.trendType||"success",a=void 0===t.trend?"":String(t.trend),d=Math.round((o-72)/2),c=Math.round((o-36)/2),u=new e.ICERect({left:i.spacing.md,top:c,width:36,height:36,radius:i.radius.md,style:{fillStyle:r,strokeStyle:r,lineWidth:i.control.lineWidth}});this.iconNode=V({left:i.spacing.md,top:c,width:36,height:36,text:t.icon||"●",fillStyle:n,fontFamily:i.font.family,fontSize:18,fontWeight:i.font.weightSemibold,align:"center",verticalAlign:"middle"});const f=i.spacing.md+36+i.spacing.sm,g=Math.max(0,s-f-i.spacing.sm);this.titleNode=V({left:f,top:d,width:g,height:18,text:t.title||"",fillStyle:i.colors.textSecondary,fontFamily:i.font.family,fontSize:i.font.sizeSmall,fontWeight:i.font.weightNormal,align:"left",verticalAlign:"middle"}),this.valueNode=V({left:f,top:d+22,width:g,height:30,text:String(t.value??"0"),fillStyle:i.colors.text,fontFamily:i.font.family,fontSize:24,fontWeight:i.font.weightSemibold,align:"left",verticalAlign:"middle"}),this.trendNode=V({left:f,top:d+54,width:g,height:18,text:a,fillStyle:D(i,l).text,fontFamily:i.font.family,fontSize:i.font.sizeSmall,fontWeight:i.font.weightSemibold,align:"left",verticalAlign:"middle"}),this.addChild(u,!1),this.addChild(this.iconNode,!1),this.addChild(this.titleNode,!1),this.addChild(this.valueNode,!1),this.addChild(this.trendNode,!1)}setValue(t){return this.valueNode.setText(String(t??"0")),this.revalidate(),this}setTitle(t){return this.titleNode.setText(t??""),this.revalidate(),this}setTrend(t){return this.trendNode.setText(t??""),this.revalidate(),this}},t.ICEStatistic=class extends r{remaining=0;running=!1;handle=null;constructor(t){const e=h.getTheme(),i=t.fontSize??24,s=t.height??22+i+8;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:t.width??200,height:s}),this.precision=Math.max(0,Math.floor(Number(t.precision)||0)),this.group=!0===t.groupSeparator,this.prefix=t.prefix??"",this.suffix=t.suffix??"",this.countdownMode=void 0!==t.countdown,this.rawValue=t.value??0,this.onFinish="function"==typeof t.onFinish?t.onFinish:null;const o=t.status?D(e,t.status).text:e.colors.text;this.titleNode=new H({interactive:!1,left:0,top:0,width:Number(this.state.width)||200,height:20,text:t.title??"",verticalAlign:"middle",style:{fontSize:e.font.sizeSmall,fontFamily:e.font.family,fillStyle:e.colors.textSecondary}}),this.valueNode=new H({interactive:!1,left:0,top:22,width:Number(this.state.width)||200,height:i+8,text:"",verticalAlign:"middle",style:{fontSize:i,fontFamily:e.font.family,fontWeight:e.font.weightSemibold,fillStyle:o}}),this.addChild(this.titleNode,!1),this.addChild(this.valueNode,!1),this.countdownMode?(this.remaining=Math.max(0,Math.floor(Number(t.countdown)||0)),this.__syncCountdownText(),!1!==t.autoStart&&this.remaining>0&&this.start()):this.__syncValueText()}getTitleText(){return this.titleNode.getText()}getValueText(){return this.valueNode.getText()}setTitle(t){return this.titleNode.setText(t??""),this.revalidate(),this}setValue(t){return this.countdownMode||(this.rawValue=t,this.__syncValueText(),this.revalidate()),this}getValue(){return this.rawValue}isCountdown(){return this.countdownMode}getRemaining(){return this.remaining}isRunning(){return this.running}setCountdown(t){this.countdownMode=!0;const e=Math.max(0,Math.floor(Number(t)||0));return this.remaining=e,e<=0?(this.__stopTween(),this.running=!1,this.__syncCountdownText(),this.__finish(),this):(this.__syncCountdownText(),this.running&&this.start(),this)}start(){if(!this.countdownMode||this.remaining<=0)return this;this.__stopTween(),this.running=!0;const t=this.remaining;return this.handle=_({from:t,to:0,duration:t,easing:"linear",onUpdate:t=>{this.remaining=Math.max(0,Math.round(t)),this.__syncCountdownText()},onFinish:()=>{this.handle=null,this.running=!1,this.remaining=0,this.__syncCountdownText(),this.__finish()}}),this}stop(){return this.running?(this.__stopTween(),this.running=!1,this):this}__stopTween(){this.handle&&(this.handle.cancel(),this.handle=null)}__syncCountdownText(){this.valueNode.setText(`${this.prefix}${Jt(this.remaining)}${this.suffix}`)}__syncValueText(){const t="number"==typeof this.rawValue?Qt(this.rawValue,this.precision,this.group):String(this.rawValue??"");this.valueNode.setText(`${this.prefix}${t}${this.suffix}`)}__finish(){this.trigger("finish",null,{}),this.onFinish&&this.onFinish()}},t.ICESteps=class extends r{stepNodes=[];constructor(t){const e=t.width??420,i=t.circleSize??28;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:e,height:i+34}),this.items=(t.items||[]).slice(),this.current=Math.min(Math.max(0,Number(t.current)||0),Math.max(0,this.items.length-1)),this.circleSize=i,this.onChange="function"==typeof t.onChange?t.onChange:null,this.__render()}getCurrent(){return this.current}setCurrent(t){const e=Math.min(Math.max(0,Math.floor(Number(t)||0)),Math.max(0,this.items.length-1));return e===this.current||(this.current=e,this.__render(),this.onChange&&this.onChange(e)),this}getStepNode(t){return this.stepNodes[t]||null}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]),this.stepNodes=[];const e=Number(this.state.width)||420,i=Math.max(1,this.items.length),s=e/i;this.items.forEach((e,o)=>{const n=o<this.current,h=o===this.current,l=new r({left:o*s,top:0,width:s-8,height:Number(this.state.height)||62,fill:!0,stroke:!1,radius:t.radius.sm,style:{fillStyle:h?t.colors.primaryBg:"rgba(0,0,0,0)"}}),a=new r({left:0,top:6,width:this.circleSize,height:this.circleSize,radius:this.circleSize/2,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:n||h?t.colors.primary:t.colors.disabled}});a.addChild(new H({interactive:!1,left:0,top:0,width:this.circleSize,height:this.circleSize,align:"center",verticalAlign:"middle",text:n?"✓":String(o+1),style:{fontSize:12,fontWeight:"600",fillStyle:t.colors.primaryText}}),!1),l.addChild(a,!1),l.addChild(new H({interactive:!1,left:this.circleSize+8,top:6,width:Math.max(0,s-this.circleSize-20),height:20,verticalAlign:"middle",text:e.title,style:{fontSize:13,fontWeight:h?"600":"400",fillStyle:h?t.colors.primary:t.colors.text}}),!1),e.description&&l.addChild(new H({interactive:!1,left:this.circleSize+8,top:26,width:Math.max(0,s-this.circleSize-20),height:18,verticalAlign:"middle",text:e.description,style:{fontSize:12,fillStyle:t.colors.textSecondary}}),!1),o<i-1&&l.addChild(new r({left:this.circleSize+4,top:6+this.circleSize/2,width:Math.max(0,s-this.circleSize-12),height:1,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:n?t.colors.primary:t.colors.borderSecondary}}),!1),this.addChild(l,!1),this.stepNodes.push(l)}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}},t.ICESvgIcon=Dt,t.ICESwitch=class extends r{constructor(t={}){const i=h.getTheme(),s=!0===t.selected;super({fill:!1,stroke:!1,draggable:!1,...t}),this.focusable=!1!==t.focusable,this.model=new Vt({selected:s});const o=t.width||i.control.switchWidth,n=t.height||i.control.switchHeight,r=Math.max(12,Math.min(i.control.switchHandle,n-4)),l=(n-r)/2;this.knobTravel=o-r-2*l,this.track=new e.ICERect({left:0,top:0,width:o,height:n,radius:n/2,style:{fillStyle:s?i.colors.primary:i.colors.borderSecondary,strokeStyle:s?i.colors.primary:i.colors.borderSecondary,lineWidth:i.control.lineWidth}}),this.knob=new e.ICECircle({left:s?this.knobTravel:l,top:l,radius:r/2,style:{fillStyle:i.colors.surface,strokeStyle:i.colors.surface,...i.shadows.sm}}),this.addChild(this.track,!1),this.addChild(this.knob,!1),this.model.addChangeListener(()=>{this.__sync(),this.trigger("change",null,{value:this.isSelected()})})}isSelected(){return this.model.isSelected()}setSelected(t){return this.model.setSelected(t),this}getFormValue(){return this.isSelected()}setFormValue(t){this.setSelected(!!t)}activate(){this.enabled&&this.model.toggle()}initEvents(){super.initEvents(),this.on("mousedown",()=>this.__toggle(),this)}__toggle(){this.enabled&&this.model.toggle()}__applyHoverState(){this.__sync()}__sync(){const t=h.getTheme(),e=this.model.isSelected();this.track.setState({style:{fillStyle:e?this.hovered?t.colors.primaryHover:t.colors.primary:this.hovered?t.colors.primaryBorder:t.colors.borderSecondary,strokeStyle:e?this.hovered?t.colors.primaryHover:t.colors.primary:this.hovered?t.colors.primaryBorder:t.colors.borderSecondary,lineWidth:t.control.lineWidth}}),this.knob.setState({left:e?this.knobTravel:this.__knobGap()}),this.revalidate()}__knobGap(){return((Number(this.state.height)||h.getTheme().control.switchHeight)-(2*Number(this.knob.state.radius)||h.getTheme().control.switchHandle))/2}},t.ICETable=Zt,t.ICETabs=class extends W{buttons=[];activeIndex=0;tabs=[];onChangeCallback=null;constructor(t={}){const i=h.getTheme(),s=t.height||i.control.height;super({fill:!1,stroke:!1,...t}),this.setLayout(new e.ICEFlowLayout({gap:8,align:"left"}));const o=t.tabs||[];this.tabs=o.slice(),this.onChangeCallback="function"==typeof t.onChange?t.onChange:null;const n=8*Math.max(0,o.length-1),r=t.width?(t.width-n)/Math.max(1,o.length):90;o.forEach((t,e)=>{const i=new Y({text:t,width:Math.max(64,r),height:s,variant:0===e?"primary":"default"});this.buttons.push(i),this.addChild(i,!1)}),this.buttons.forEach((t,e)=>{t.on("mousedown",()=>this.__activate(e),this)}),this.setActiveIndex(0),this.doLayout()}getActiveIndex(){return this.activeIndex}setActiveIndex(t){return this.__applyActive(t)}getTabs(){return this.tabs.slice()}__activate(t){const e=t!==this.activeIndex;this.__applyActive(t),e&&this.onChangeCallback&&this.onChangeCallback(t,this.tabs[t])}__applyActive(t){return t<0||t>=this.buttons.length||(this.activeIndex=t,this.buttons.forEach((e,i)=>{const s=this.theme(),o=i===t;e.setState({style:{...e.state.style,fillStyle:o?s.colors.primary:s.colors.surface,strokeStyle:o?s.colors.primary:s.colors.border,...o?s.shadows.sm:{}}});const n=e.childNodes&&e.childNodes[0];n&&n.setState&&n.setState({style:{fillStyle:o?s.colors.primaryText:s.colors.text,fontFamily:s.font.family,fontSize:s.font.size,fontWeight:s.font.weightMedium,textAlign:"center",textBaseline:"middle"}})}),this.revalidate()),this}},t.ICETag=class extends r{constructor(t={}){const e=h.getTheme(),i=D(e,t.status||t.color||"default"),s="soft"===t.variant?"soft":"solid",o=t.height||24,n=t.width||56;super({...t,fill:!0,stroke:!0,width:n,height:o,radius:e.radius.sm,style:{fillStyle:"solid"===s?i.solid:i.background,strokeStyle:"solid"===s?i.solid:i.border,lineWidth:e.control.lineWidth,...t.style||{}}}),this.statusColors=i,this.variant=s;const r=e.spacing.sm;this.textNode=V({left:r,top:0,width:Math.max(0,n-2*r),height:o,text:t.text??"Tag",fillStyle:"solid"===s?i.onSolid:i.strong,fontFamily:e.font.family,fontSize:e.font.sizeSmall,fontWeight:e.font.weightMedium,align:"center",verticalAlign:"middle"}),this.addChild(this.textNode,!1)}setText(t){return this.textNode.setText(t??""),this.revalidate(),this}__applyHoverState(){const t=h.getTheme(),e="solid"===this.variant?this.statusColors.solid:this.statusColors.background,i="solid"===this.variant?this.__mix("#ffffff",this.statusColors.solid,.85):this.__mix(t.colors.surface,this.statusColors.background,.55);this.setState({style:{...this.state.style,fillStyle:this.hovered?i:e,strokeStyle:"solid"===this.variant?this.hovered?i:this.statusColors.solid:this.statusColors.border,lineWidth:t.control.lineWidth}}),this.revalidate()}__mix(t,e,i){if(i<=0)return e;if(i>=1)return t;const s=this.__hex(t),o=this.__hex(e);return s&&o?`rgba(${Math.round(s[0]*i+o[0]*(1-i))}, ${Math.round(s[1]*i+o[1]*(1-i))}, ${Math.round(s[2]*i+o[2]*(1-i))}, 1)`:e}__hex(t){const e=/^#([0-9a-f]{6})$/i.exec(t);return e?[parseInt(e[1].slice(0,2),16),parseInt(e[1].slice(2,4),16),parseInt(e[1].slice(4,6),16)]:null}},t.ICETetrisModel=class{board=[];queue=[];score=0;lines=0;gameOver=!1;paused=!1;lastCleared=0;listeners=new Set;constructor(t={}){this.rows=Math.max(4,Math.floor(t.rows??20)),this.cols=Math.max(4,Math.floor(t.cols??10)),this.random=t.random||Math.random,this.__resetBoard()}getRows(){return this.rows}getCols(){return this.cols}getBoard(){return this.board}getCurrent(){return this.current}getNextQueue(){return this.queue.slice()}isGameOver(){return this.gameOver}isPaused(){return this.paused}getScore(){return this.score}getLines(){return this.lines}getLastClearedLines(){return this.lastCleared}getLevel(){return 1+Math.floor(this.lines/10)}getDropInterval(){return Math.max(60,Math.round(800*.82**(this.getLevel()-1)))}getGhost(){let t=this.current.cells.slice();for(;;){const e=t.map(([t,e])=>[t+1,e]);if(this.collides(e))return t;t=e}}addChangeListener(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}moveLeft(){return this.tryMove(0,-1)}moveRight(){return this.tryMove(0,1)}rotateCW(){return this.tryRotate(1)}rotateCCW(){return this.tryRotate(3)}tick(){return this.stepDown(!1)}softDrop(){return this.stepDown(!0)}hardDrop(){if(this.blocked())return!1;let t=0;for(;this.tryMoveQuiet(1,0);)t+=1;return this.score+=2*t,this.lock(),this.notify(),!0}pause(){this.paused||this.gameOver||(this.paused=!0,this.notify())}resume(){this.paused&&(this.paused=!1,this.notify())}reset(t={}){void 0!==t.rows&&(this.rows=Math.max(4,Math.floor(t.rows))),void 0!==t.cols&&(this.cols=Math.max(4,Math.floor(t.cols))),t.random&&(this.random=t.random),this.__resetBoard(),this.notify()}setCellForTest(t,e,i){t<0||t>=this.rows||e<0||e>=this.cols||(this.board[t][e]=i,this.notify())}setLinesForTest(t){this.lines=Math.max(0,Math.floor(t)),this.notify()}__resetBoard(){this.board=Array.from({length:this.rows},()=>Array(this.cols).fill(null)),this.queue=[],this.score=0,this.lines=0,this.lastCleared=0,this.gameOver=!1,this.paused=!1,this.refillQueue(),this.spawn()}blocked(){return this.paused||this.gameOver}tryMove(t,e){return!!this.tryMoveQuiet(t,e)&&(this.notify(),!0)}tryMoveQuiet(t,e){if(this.blocked())return!1;const i=this.current.cells.map(([i,s])=>[i+t,s+e]);return!this.collides(i)&&(this.current.row+=t,this.current.col+=e,this.current.cells=i,!0)}tryRotate(t){if(this.blocked())return!1;const e=this.current,i=(e.rotation+t)%4,s=ge[e.type][i],o=[[0,0],[0,-1],[0,1],[0,-2],[0,2],[-1,0],[-1,-1],[-1,1]];for(let t=0;t<o.length;t+=1){const[n,h]=o[t],r=s.map(([t,i])=>[e.row+t+n,e.col+i+h]);if(!this.collides(r))return e.rotation=i,e.row+=n,e.col+=h,e.cells=r,this.notify(),!0}return!1}stepDown(t){return!this.blocked()&&(this.tryMoveQuiet(1,0)?(t&&(this.score+=1),this.notify(),!0):(this.lock(),this.notify(),!1))}lock(){const t=this.current;let e=!1;this.lastCleared=0,t.cells.forEach(([i,s])=>{i<0?e=!0:i<this.rows&&s>=0&&s<this.cols&&(this.board[i][s]=t.type)}),this.clearLines(),e?this.gameOver=!0:this.spawn()}clearLines(){const t=this.board.filter(t=>t.some(t=>!t)),e=this.rows-t.length;if(!(e<=0)){for(;t.length<this.rows;)t.unshift(Array(this.cols).fill(null));this.board=t,this.lastCleared=e,this.score+=(me[Math.min(e,4)]||0)*this.getLevel(),this.lines+=e}}spawn(){this.refillQueue();const t=this.queue.shift(),e=ge[t][0],i=Math.max(...e.map(([,t])=>t))+1,s=Math.floor((this.cols-i)/2),o={type:t,rotation:0,row:0,col:s,cells:e.map(([t,e])=>[0+t,s+e])};this.current=o,this.collides(o.cells)&&(this.gameOver=!0)}refillQueue(){for(;this.queue.length<14;){const t=Object.keys(ge);for(let e=t.length-1;e>0;e-=1){const i=Math.floor(this.random()*(e+1)),s=t[e];t[e]=t[i],t[i]=s}this.queue.push(...t)}}collides(t){for(let e=0;e<t.length;e+=1){const i=t[e][0],s=t[e][1];if(s<0||s>=this.cols)return!0;if(i>=this.rows)return!0;if(!(i<0)&&this.board[i][s])return!0}return!1}notify(){this.listeners.forEach(t=>t(this))}},t.ICETextArea=class extends kt{constructor(t={}){super({height:2*h.getTheme().control.height,...t}),this.allowNewline=!0}},t.ICETextField=kt,t.ICETileMap=class extends r{palette={};tiles=[];labels=[];tileKey="";labelKey="";highlights=[];pulses=[];pulseAlpha=0;pulseHandle=null;paintCount=0;constructor(t){const e=Math.max(1,Math.floor(t.rows||1)),i=Math.max(1,Math.floor(t.cols||1)),s=Math.max(2,Math.floor(t.cellSize||20)),o=Math.max(0,Math.floor(t.gap||0));super({fill:!1,stroke:!1,...t,width:t.width||i*s,height:t.height||e*s}),this.rows=e,this.cols=i,this.cellSize=s,this.gap=o,this.cellRadius=Math.max(0,Number(void 0===t.cellRadius?4:t.cellRadius)),this.pulseColor=t.pulseColor||"rgba(255, 255, 255, 0.42)",this.highlightColor=t.highlightColor||"rgba(255, 255, 255, 0.45)",this.labelFontSize=Math.max(6,Number(void 0===t.labelFontSize?12:t.labelFontSize)),this.labelColor=t.labelColor||"#ffffff",this.tiles=new Array(e*i).fill(null),this.labels=new Array(e*i).fill(null),this.setPalette(t.palette||{})}getRows(){return this.rows}getCols(){return this.cols}getCellSize(){return this.cellSize}getGap(){return this.gap}getCellRect(t,e){const i=this.gap/2;return{left:e*this.cellSize+i,top:t*this.cellSize+i,width:Math.max(1,this.cellSize-this.gap),height:Math.max(1,this.cellSize-this.gap)}}getCellAt(t,e){if(!Number.isFinite(t)||!Number.isFinite(e)||t<0||e<0)return null;const i=Math.floor(t/this.cellSize),s=Math.floor(e/this.cellSize);return i<0||i>=this.cols||s<0||s>=this.rows?null:{row:s,col:i}}setTiles(t){const e=this.__normalize(t).map(t=>null==t?null:String(t)),i=e.map(t=>null==t?"\0":String(t)).join("");return i===this.tileKey||(this.tileKey=i,this.tiles=e,this.requestPaint()),this}getTiles(){return this.tiles.slice()}setLabels(t){const e=this.__normalize(t).map(t=>null==t?null:String(t)),i=e.map(t=>null===t?"\0":t).join("");return i===this.labelKey||(this.labelKey=i,this.labels=e,this.requestPaint()),this}getLabels(){return this.labels.slice()}setPalette(t){const e={};return Object.keys(t||{}).forEach(i=>{e[i]={...t[i]}}),this.palette=e,this.requestPaint(),this}getPalette(){const t={};return Object.keys(this.palette).forEach(e=>{t[e]={...this.palette[e]}}),t}resolveCellStyle(t){if(null==t)return null;const e=this.palette[t];return e?{...e}:null}setHighlights(t){return this.highlights=(t||[]).map(t=>({...t})),this.requestPaint(),this}getHighlights(){return this.highlights.map(t=>({...t}))}pulse(t,e={}){return t&&t.length?(this.pulseHandle&&this.pulseHandle.cancel(),this.pulses=t.map(t=>({...t})),this.pulseAlpha=1,this.requestPaint(),e.color&&(this.pulseColor=e.color),this.pulseHandle=_({from:1,to:0,duration:void 0===e.duration?260:e.duration,easing:"linear",driver:e.driver,onUpdate:t=>{this.pulseAlpha=t,this.requestPaint()},onFinish:()=>{this.pulseAlpha=0,this.pulses=[],this.pulseHandle=null,this.requestPaint()}}),this):this}getPulses(){return this.pulses.map(t=>({...t}))}getPulseAlpha(){return this.pulses.length?this.pulseAlpha:0}getPaintCount(){return this.paintCount}paintBoard(){this.paintCount+=1;if(!this.ctx)return;for(let t=0;t<this.rows;t+=1)for(let e=0;e<this.cols;e+=1){const i=t*this.cols+e,s=this.resolveCellStyle(this.tiles[i]||null);if(!s)continue;this.__drawRect(t,e,s,1);const o=this.labels[i];null!=o&&""!==o&&this.__drawLabel(t,e,o,s)}const t=this.getPulseAlpha();t>0&&this.pulses.forEach(e=>{this.__drawRect(e.row,e.col,{fillStyle:e.color||this.pulseColor},t)}),this.highlights.forEach(t=>{this.__drawRect(t.row,t.col,{fillStyle:t.fillStyle||"rgba(0,0,0,0)",strokeStyle:t.strokeStyle||this.highlightColor,lineWidth:void 0===t.lineWidth?1.5:t.lineWidth,radius:t.radius},1)})}doRender(){super.doRender(),this.applyActiveTransform(),this.paintBoard()}initEvents(){super.initEvents(),this.on("click",t=>{const e=this.__cellFromEvent(t);e&&this.trigger("cellclick",null,e)})}requestPaint(){this.dirty=!0,this.ice&&(this.ice.dirty=!0)}__normalize(t){const e=[];if(!t)return e;Array.isArray(t[0])?t.forEach(t=>{(t||[]).forEach(t=>e.push(void 0===t?null:t))}):t.forEach(t=>e.push(void 0===t?null:t));const i=this.rows*this.cols;if(e.length!==i)throw new Error(`ICETileMap: setTiles 需要 ${i} 个格子(${this.rows}×${this.cols}),实际 ${e.length} 个`);return e}__drawLabel(t,e,i,s){const o=this.ctx;if(!o||"function"!=typeof o.fillText)return;const n=this.getCellRect(t,e),h=Number(this.state.localOrigin&&this.state.localOrigin[0])||0,r=Number(this.state.localOrigin&&this.state.localOrigin[1])||0,l=void 0===s.fontSize?this.labelFontSize:Number(s.fontSize),a=s.fontWeight||"700",d=s.fontFamily||'Tahoma, "Microsoft YaHei", sans-serif',c=s.textColor||this.labelColor,u="function"==typeof o.save&&"function"==typeof o.restore;u&&o.save(),o.font=`${a} ${l}px ${d}`,o.fillStyle=c,o.textAlign="center",o.textBaseline="middle",o.fillText(i,n.left-h+n.width/2,n.top-r+n.height/2),u&&o.restore()}__drawRect(t,e,i,s){const o=this.ctx;if(!o||t<0||t>=this.rows||e<0||e>=this.cols)return;const n=this.getCellRect(t,e),h=Number(this.state.localOrigin&&this.state.localOrigin[0])||0,r=Number(this.state.localOrigin&&this.state.localOrigin[1])||0,l=void 0===i.radius?this.cellRadius:i.radius,a=s<1&&"function"==typeof o.save;a&&(o.save(),o.globalAlpha=(Number(o.globalAlpha)||1)*Math.max(0,s)),function(t,e,i,s,o,n){const h=Math.max(0,Math.min(n,s/2,o/2));t.beginPath(),h<=0?t.rect(e,i,s,o):(t.moveTo(e+h,i),t.lineTo(e+s-h,i),t.arcTo(e+s,i,e+s,i+h,h),t.lineTo(e+s,i+o-h),t.arcTo(e+s,i+o,e+s-h,i+o,h),t.lineTo(e+h,i+o),t.arcTo(e,i+o,e,i+o-h,h),t.lineTo(e,i+h),t.arcTo(e,i,e+h,i,h),t.closePath())}(o,n.left-h,n.top-r,n.width,n.height,l),i.fillStyle&&(o.fillStyle=i.fillStyle,o.fill()),i.strokeStyle&&(o.lineWidth=void 0===i.lineWidth?1:i.lineWidth,o.strokeStyle=i.strokeStyle,o.stroke()),a&&"function"==typeof o.restore&&o.restore()}__cellFromEvent(t){if(!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return null;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return null;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=this.getMinBoundingBox(!0);return s?this.getCellAt(e-s.tl[0],i-s.tl[1]):null}},t.ICETimePicker=class extends r{handle=null;panel=null;fieldLabel=null;columnNodes=new Map;optionNodes=new Map;running=!1;constructor(t={}){const e=h.getTheme(),i=t.width??160,s=t.height??e.control.height;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:i,height:s,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.value=void 0===t.value||null===t.value?void 0:String(t.value),this.placeholder=t.placeholder||"",this.disabled=!0===t.disabled,this.format="HH:mm"===t.format?"HH:mm":"HH:mm:ss",this.steps={hour:Bt(t.hourStep),minute:Bt(t.minuteStep),second:Bt(t.secondStep)},this.placement=t.placement||"bottomLeft",this.manager=t.manager||null,this.onChangeCallback="function"==typeof t.onChange?t.onChange:null,this.focusable=!this.disabled,this.focusRingMode="always",this.__syncField()}afterAddHandler(){super.afterAddHandler(),this.running||(!this.manager&&this.ice&&(this.manager=z(this.ice)),this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this)),this.on("click",this.__onClick,this),this.running=!0)}getValue(){return this.value}setValue(t){return this.value=null==t||""===t?void 0:String(t),this.__syncField(),this.isOpen()&&this.__renderPanel(),this}getFormValue(){return this.value}setFormValue(t){this.setValue(t)}getUnits(){return"HH:mm"===this.format?["hour","minute"]:["hour","minute","second"]}getColumnValues(t){const e="hour"===t?23:59,i=this.steps[t]||1,s=[];for(let t=0;t<=e;t+=i)s.push(At(t));return s}getFieldLabel(){return this.fieldLabel?this.fieldLabel.getText():""}isOpen(){return!!this.handle&&this.handle.isOpen()}getPanel(){return this.panel}getColumnNode(t){return this.columnNodes.get(t)||null}getOptionNode(t,e){return this.optionNodes.get(`${t}:${e}`)||null}activate(){this.toggle()}toggle(){return this.isOpen()?this.close():this.open()}open(){if(this.disabled||this.isOpen())return this;if(!this.manager){if(!this.ice)throw new Error("ICETimePicker 需要先加入 ICE 场景");this.manager=z(this.ice)}const t=h.getTheme(),e=this.getUnits(),i=new O({width:12+56*e.length,height:152,radius:t.radius.md,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"md"}});return this.panel=i,this.__renderPanel(),this.handle=this.manager.open({anchor:this,content:i,placement:this.placement,offset:4,enterAnimation:"scale",exitAnimation:"fade",keyboardCaptured:!0,closeOnOutsideClick:!1}),this}close(){return this.handle&&(this.handle.close(),this.handle=null),this.panel=null,this.columnNodes.clear(),this.optionNodes.clear(),this}__applyValidateState(){this.__syncField()}__parse(){const t=(this.value||"").split(":"),e=(t,e)=>{const i=Number(t);return Number.isFinite(i)?Math.min(e,Math.max(0,Math.floor(i))):0};return{hour:e(t[0],23),minute:e(t[1],59),second:e(t[2],59)}}__format(t){const e=`${At(t.hour)}:${At(t.minute)}`;return"HH:mm"===this.format?e:`${e}:${At(t.second)}`}__pick(t,e){const i=this.__parse();i[t]=Number(e)||0,this.value=this.__format(i),this.__syncField(),this.close(),this.onChangeCallback&&this.onChangeCallback(this.value)}__onClick(){this.disabled||this.toggle()}__onKeyDown(t){if(!this.isOpen())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);"Escape"!==i&&"Esc"!==i||this.close()}__onGlobalMouseDown(t){if(!this.isOpen()||!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=t=>e>=t.left&&e<=t.left+t.width&&i>=t.top&&i<=t.top+t.height;s(this.__worldBox(this))||s(this.__worldBox(this.panel))||this.close()}__worldBox(t){let e=0,i=0,s=t;for(;s&&s.state;)e+=Number(s.state.left)||0,i+=Number(s.state.top)||0,s=s.parentNode;return{left:e,top:i,width:Number(t&&t.state&&t.state.width)||0,height:Number(t&&t.state&&t.state.height)||0}}__syncField(){const t=h.getTheme(),e=Number(this.state.width)||160,i=Number(this.state.height)||32,s="error"===this.validateStatus?t.colors.error:t.colors.border;this.setState({style:{...this.state.style,fillStyle:this.disabled?t.colors.disabled:t.colors.surface,strokeStyle:s}}),this.removeChildren([...this.childNodes]),this.fieldLabel=new H({interactive:!1,left:10,top:0,width:Math.max(0,e-34),height:i,verticalAlign:"middle",text:this.value||this.placeholder,style:{fontSize:13,fillStyle:this.value?t.colors.text:t.colors.textTertiary}}),this.addChild(this.fieldLabel,!1),this.addChild(new H({interactive:!1,left:e-22,top:0,width:14,height:i,align:"center",verticalAlign:"middle",text:"▾",style:{fontSize:12,fillStyle:t.colors.textTertiary}}),!1)}__renderPanel(){const t=this.panel;if(!t)return;const e=h.getTheme();t.removeChildren([...t.childNodes]),this.columnNodes.clear(),this.optionNodes.clear();const i=this.__parse(),s={hour:At(i.hour),minute:At(i.minute),second:At(i.second)};this.getUnits().forEach((i,o)=>{const n=this.getColumnValues(i),h=new _t({left:6+56*o,top:6,width:56,height:140,fill:!1,stroke:!1,style:{fillStyle:"transparent",strokeStyle:"transparent"}}),l=new r({width:56,height:28*n.length,fill:!1,stroke:!1});n.forEach((t,o)=>{const n=void 0!==this.value&&t===s[i],h=new r({left:0,top:28*o,width:56,height:28,radius:e.radius.sm,fill:!0,stroke:!1,style:{fillStyle:n?e.colors.primaryBg:"transparent"}});h.addChild(new H({interactive:!1,left:0,top:0,width:56,height:28,align:"center",verticalAlign:"middle",text:t,style:{fontSize:13,fontWeight:n?"600":"400",fillStyle:n?e.colors.primary:e.colors.text}}),!1),h.on("click",()=>this.__pick(i,t)),l.addChild(h,!1),this.optionNodes.set(`${i}:${t}`,h)}),h.setContent(l),t.addChild(h,!1),this.columnNodes.set(i,h);const a=n.indexOf(s[i]);a>=0&&h.setScroll(0,Math.max(0,28*a-56))})}},t.ICETimeline=class extends r{itemNodes=[];dots=[];constructor(t){const e=t.width??320,i=t.itemHeight??44,s=(t.items||[]).length*i;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:e,height:s}),this.items=(t.items||[]).slice(),this.itemHeight=i,this.__render()}getItemNodes(){return this.itemNodes.slice()}getDotColor(t){const e=this.dots[t];return e?String(e.state.style.fillStyle):""}setItems(t){return this.items=(t||[]).slice(),this.setState({height:this.items.length*this.itemHeight}),this.__render(),this}__afterStateMerge(t){super.__afterStateMerge(t),t&&this.__render()}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]);const e=Number(this.state.width)||320;this.items.forEach((i,s)=>{const o=s*this.itemHeight;s<this.items.length-1&&this.addChild(new r({left:6,top:o+16,width:1,height:this.itemHeight-8,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:t.colors.borderSecondary}}),!1);const n=new r({left:3,top:o+6,width:7,height:7,radius:4,fill:!0,stroke:!1,interactive:!1,style:{fillStyle:i.color||t.colors.primary}});this.addChild(n,!1),this.dots.push(n);const h=new r({left:0,top:o,width:e,height:this.itemHeight,fill:!1,stroke:!1});h.addChild(new H({interactive:!1,left:20,top:0,width:e-20,height:20,verticalAlign:"middle",text:i.title,style:{fontSize:13,fontWeight:"600",fillStyle:t.colors.text}}),!1),i.description&&h.addChild(new H({interactive:!1,left:20,top:20,width:e-20,height:18,verticalAlign:"middle",text:i.description,style:{fontSize:12,fillStyle:t.colors.textSecondary}}),!1),i.time&&h.addChild(new H({interactive:!1,left:Math.max(20,e-56),top:0,width:56,height:20,align:"right",verticalAlign:"middle",text:i.time,style:{fontSize:12,fillStyle:t.colors.textTertiary}}),!1),this.addChild(h,!1),this.itemNodes.push(h)})}},t.ICEToggleModel=Vt,t.ICETooltip=ct,t.ICETour=class{handle=null;mask=null;highlight=null;panel=null;titleNode=null;descriptionNode=null;counterNode=null;prevButton=null;nextButton=null;skipButton=null;current=0;finished=!1;bound=!1;pendingReason=null;constructor(t,e){this.ice=t,this.options=e,this.manager=e.manager||z(t),this.focus=e.focusManager||B(t),this.steps=(e.steps||[]).slice(),this.current=Math.max(0,Math.min(this.steps.length-1,Math.floor(Number(e.current)||0)))}isOpen(){return!!this.handle&&this.handle.isOpen()}isFinished(){return this.finished}getCurrent(){return this.current}getCurrentStep(){return this.steps[this.current]||null}getSteps(){return this.steps.slice()}getPanel(){return this.panel}getMask(){return this.mask}getHighlightNode(){return this.highlight}getTitleText(){return this.titleNode?this.titleNode.getText():""}getDescriptionText(){return this.descriptionNode?this.descriptionNode.getText():""}getCounterText(){return this.counterNode?this.counterNode.getText():""}getNextButton(){return this.nextButton}getPrevButton(){return this.prevButton}getSkipButton(){return this.skipButton}getHighlightBox(){const t=this.getCurrentStep();if(!t||!t.target)return null;const e=E(t.target);return{left:e.left,top:e.top,width:e.width,height:e.height}}setSteps(t){return this.steps=(t||[]).slice(),this.current=0,this.isOpen()&&this.__renderStep(),this}open(t){if(this.finished=!1,this.isOpen())return void 0!==t&&this.__goTo(t,{scroll:!1}),this;void 0!==t&&(this.current=Math.max(0,Math.min(this.steps.length-1,Math.floor(t)||0)));const e=this.__visibleRect(),i=new r({left:0,top:0,width:e.width,height:e.height,fill:!1,stroke:!1,interactive:!0});return this.mask=i,this.handle=this.manager.open({centered:!0,blocking:!0,content:i,closeOnOutsideClick:!1,closeOnEsc:!0,enterAnimation:"fade",onClose:t=>{const e=this.pendingReason||("esc"===t?"esc":"api");this.pendingReason=null,this.__handleClosed(e)}}),this.__renderStep(),this.__bindKeyboard(),this.focus.setFocusScope(i),this.nextButton&&this.focus.focus(this.nextButton),this}close(t="api"){if(!this.handle||!this.handle.isOpen())return this;const e=this.handle;return this.pendingReason=t,this.handle=null,this.__unbindKeyboard(),e.close(),this}next(){return this.current>=this.steps.length-1?this.finish():this.__goTo(this.current+1,{scroll:!0})}prev(){return this.__goTo(this.current-1,{scroll:!1})}finish(){return this.finished=!0,this.close("api"),this.options.onFinish&&this.options.onFinish(),this}skip(){return this.close("skip"),this}__goTo(t,e){const i=Math.max(0,Math.min(this.steps.length-1,Math.floor(t)||0));return i===this.current||(this.current=i,this.__renderStep(),e.scroll&&this.options.onNext?this.options.onNext(i):!e.scroll&&this.options.onPrev&&this.options.onPrev(i),this.options.onChange&&this.options.onChange(i)),this}__renderStep(){const t=h.getTheme(),e=this.mask,i=this.getCurrentStep();if(!e||!i)return;e.removeChildren([...e.childNodes]),this.highlight=null,this.titleNode=null,this.descriptionNode=null,this.counterNode=null,this.prevButton=null,this.nextButton=null,this.skipButton=null;const s=this.__visibleRect(),o=i.target?E(i.target):{left:0,top:0,width:0,height:0},n={left:o.left-s.left-6,top:o.top-s.top-6,width:o.width+12,height:o.height+12};[[0,0,s.width,Math.max(0,n.top)],[0,n.top+n.height,s.width,Math.max(0,s.height-n.top-n.height)],[0,n.top,Math.max(0,n.left),n.height],[n.left+n.width,n.top,Math.max(0,s.width-n.left-n.width),n.height]].forEach(([t,i,s,o])=>{s<=0||o<=0||e.addChild(new r({left:t,top:i,width:s,height:o,fill:!0,stroke:!1,style:{fillStyle:"rgba(0, 0, 0, 0.55)"}}),!1)});const l=new r({left:n.left,top:n.top,width:n.width,height:n.height,fill:!1,stroke:!0,radius:t.radius.sm,style:{strokeStyle:t.colors.primary,lineWidth:2}});e.addChild(l,!1),this.highlight=l;const a=Number(this.options.panelWidth)||260,d=i.description?40:20,c=36+(i.description?10:0)+d+12+32+16,u=new O({left:0,top:0,width:a,height:c,radius:t.radius.md,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"lg"}});this.titleNode=new H({interactive:!1,left:16,top:16,width:a-32,height:20,text:i.title,verticalAlign:"middle",style:{fontSize:14,fontWeight:t.font.weightSemibold,fillStyle:t.colors.text}}),u.addChild(this.titleNode,!1);let f=36;i.description&&(f+=10,this.descriptionNode=new H({interactive:!1,left:16,top:f,width:a-32,height:d,text:i.description,verticalAlign:"middle",style:{fontSize:12,fillStyle:t.colors.textSecondary}}),u.addChild(this.descriptionNode,!1),f+=d),f+=12;const g=f;this.counterNode=new H({interactive:!1,left:16,top:g,width:60,height:32,text:`${this.current+1}/${this.steps.length}`,verticalAlign:"middle",style:{fontSize:12,fillStyle:t.colors.textTertiary}}),u.addChild(this.counterNode,!1),this.skipButton=new Y({left:a-16-200,top:g,width:56,height:32,text:lt("tour.skip"),variant:"text",size:"small"}),this.prevButton=new Y({left:a-16-140,top:g,width:56,height:32,text:lt("tour.prev"),variant:"default",size:"small"}),this.nextButton=new Y({left:a-16-78,top:g,width:78,height:32,text:this.current===this.steps.length-1?lt("tour.done"):lt("tour.next"),variant:"primary",size:"small"}),0===this.current&&this.prevButton.setEnabled(!1),this.skipButton.on("click",()=>this.skip()),this.prevButton.on("click",()=>this.prev()),this.nextButton.on("click",()=>this.next()),u.addChild(this.skipButton,!1),u.addChild(this.prevButton,!1),u.addChild(this.nextButton,!1),u.on("click",t=>{t&&"function"==typeof t.stopPropagation&&t.stopPropagation()});const m=this.__resolvePlacement(n,a,c,s);u.setState({left:m.left,top:m.top}),e.addChild(u,!1),this.panel=u,this.ice&&(this.ice.dirty=!0)}__resolvePlacement(t,e,i,s){const o=Math.min(Math.max(8,t.left+t.width/2-e/2),s.width-e-8),n=t.top+t.height+12;return{left:o,top:n+i<=s.height-8?n:Math.max(8,t.top-12-i)}}__bindKeyboard(){!this.bound&&this.ice&&this.ice.evtBus&&(this.bound=!0,this.ice.evtBus.on("keydown",this.__onKeyDown,this))}__unbindKeyboard(){this.bound&&this.ice&&this.ice.evtBus&&(this.bound=!1,this.ice.evtBus.off("keydown",this.__onKeyDown,this))}__onKeyDown(t){if(!this.isOpen())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);"ArrowRight"===i||"Enter"===i?this.next():"ArrowLeft"===i&&this.prev()}__handleClosed(t){this.focus.setFocusScope(null),this.mask=null,this.panel=null,this.highlight=null,this.titleNode=null,this.descriptionNode=null,this.counterNode=null,this.prevButton=null,this.nextButton=null,this.skipButton=null,this.options.onClose&&this.options.onClose(t)}__visibleRect(){const t=Number(this.ice&&this.ice.canvasWidth)||0,e=Number(this.ice&&this.ice.canvasHeight)||0,i=this.ice&&"function"==typeof this.ice.getRenderViewport?this.ice.getRenderViewport():null,s=i&&i.scale?i.scale:1;return{left:i?-(i.tx||0)/s:0,top:i?-(i.ty||0)/s:0,width:t/s,height:e/s}}},t.ICETransfer=class extends r{checked=new Set;sourceRows=new Map;targetRows=new Map;moveRightButton=null;moveLeftButton=null;constructor(t){const e=h.getTheme();super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:t.width??420,height:t.height??220,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.dataSource=(t.dataSource||[]).slice(),this.titles=t.titles||[lt("transfer.pending"),lt("transfer.selected")],this.rowHeight=t.rowHeight??28,this.onChangeCallback="function"==typeof t.onChange?t.onChange:null,this.targetKeys=this.__sanitize(t.targetKeys||[]),this.__render()}getSourceKeys(){return this.dataSource.filter(t=>!this.targetKeys.includes(t.key)).map(t=>t.key)}getTargetKeys(){return this.targetKeys.slice()}setTargetKeys(t){return this.targetKeys=this.__sanitize(t),this.checked.clear(),this.__render(),this}getFormValue(){return this.getTargetKeys()}setFormValue(t){this.setTargetKeys(Array.isArray(t)?t:[])}getCheckedKeys(){return Array.from(this.checked)}isChecked(t){return this.checked.has(t)}getSourceNode(t){return this.sourceRows.get(t)||null}getTargetNode(t){return this.targetRows.get(t)||null}getMoveRightButton(){return this.moveRightButton}getMoveLeftButton(){return this.moveLeftButton}isMoveRightEnabled(){return this.__movable([...this.checked],"right").length>0}isMoveLeftEnabled(){return this.__movable([...this.checked],"left").length>0}moveRight(){const t=this.__movable([...this.checked],"right");t.length&&(this.targetKeys=this.targetKeys.concat(t),this.checked.clear(),this.__render(),this.__emit("right",t))}moveLeft(){const t=this.__movable([...this.checked],"left");t.length&&(this.targetKeys=this.targetKeys.filter(e=>!t.includes(e)),this.checked.clear(),this.__render(),this.__emit("left",t))}activate(){}__applyValidateState(){this.__render()}__emit(t,e){this.onChangeCallback&&this.onChangeCallback(this.getTargetKeys(),t,e)}__sanitize(t){const e=new Map(this.dataSource.map(t=>[t.key,t])),i=[];return t.forEach(t=>{e.get(t)&&!i.includes(t)&&i.push(t)}),i}__movable(t,e){const i=new Map(this.dataSource.map(t=>[t.key,t]));return t.filter(t=>{const s=i.get(t);return!(!s||s.disabled)&&("right"===e?!this.targetKeys.includes(t):this.targetKeys.includes(t))})}__toggleCheck(t){const e=this.dataSource.find(e=>e.key===t);e&&!e.disabled&&(this.checked.has(t)?this.checked.delete(t):this.checked.add(t),this.__render())}__render(){const t=h.getTheme(),e=Number(this.state.width)||420,i=Number(this.state.height)||220,s="error"===this.validateStatus?t.colors.error:t.colors.border;this.setState({style:{...this.state.style,fillStyle:t.colors.surface,strokeStyle:s}}),this.removeChildren([...this.childNodes]),this.sourceRows.clear(),this.targetRows.clear();const o=Math.max(80,(e-36-24)/2),n=i,r=this.getSourceKeys(),l=this.getTargetKeys(),a=this.__renderPanel(`${this.titles[0]}(${r.length})`,0,o,n,r,"source"),d=this.__renderPanel(`${this.titles[1]}(${l.length})`,o+12+36+12,o,n,l,"target");this.addChild(a,!1),this.addChild(d,!1);const c=o+12,u=this.isMoveRightEnabled(),f=this.isMoveLeftEnabled(),g=this.__renderMoveButton("›",c,i/2-34,u);g.on("click",()=>this.moveRight());const m=this.__renderMoveButton("‹",c,i/2+6,f);m.on("click",()=>this.moveLeft()),this.moveRightButton=g,this.moveLeftButton=m,this.addChild(g,!1),this.addChild(m,!1),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}__renderPanel(t,e,i,s,o,n){const l=h.getTheme(),a=new r({left:e,top:0,width:i,height:s,radius:l.radius.md,fill:!0,stroke:!0,interactive:!1,style:{fillStyle:l.colors.background,strokeStyle:l.colors.border}});a.addChild(new H({interactive:!1,left:10,top:0,width:Math.max(0,i-20),height:28,verticalAlign:"middle",text:t,style:{fontSize:12,fontWeight:"600",fillStyle:l.colors.textSecondary}}),!1);const d=new _t({left:1,top:28,width:i-2,height:Math.max(0,s-28-1),fill:!1,stroke:!1,style:{fillStyle:"transparent",strokeStyle:"transparent"}}),c=new r({width:i-2,height:Math.max(s-28-1,o.length*this.rowHeight),fill:!1,stroke:!1}),u=new Map(this.dataSource.map(t=>[t.key,t]));return o.forEach((t,e)=>{const s=u.get(t);if(!s)return;const o=this.__renderRow(s,e*this.rowHeight,i-2);o.on("click",()=>this.__toggleCheck(s.key)),c.addChild(o,!1),"source"===n?this.sourceRows.set(s.key,o):this.targetRows.set(s.key,o)}),d.setContent(c),a.addChild(d,!1),a}__renderRow(t,e,i){const s=h.getTheme(),o=this.checked.has(t.key),n=new r({left:0,top:e,width:i,height:this.rowHeight,fill:!0,stroke:!1,style:{fillStyle:o?s.colors.primaryBg:"transparent"}}),l=new r({left:8,top:(this.rowHeight-16)/2,width:16,height:16,radius:s.radius.xs,fill:!0,stroke:!0,interactive:!1,style:{fillStyle:o?s.colors.primary:s.colors.surface,strokeStyle:t.disabled?s.colors.disabled:o?s.colors.primary:s.colors.border}});return o&&l.addChild(new H({interactive:!1,left:0,top:0,width:16,height:16,align:"center",verticalAlign:"middle",text:"✓",style:{fontSize:11,fillStyle:"#ffffff"}}),!1),n.addChild(l,!1),n.addChild(new H({interactive:!1,left:32,top:0,width:Math.max(0,i-40),height:this.rowHeight,verticalAlign:"middle",text:t.title,style:{fontSize:13,fillStyle:t.disabled?s.colors.textDisabled:s.colors.text}}),!1),n}__renderMoveButton(t,e,i,s){const o=h.getTheme(),n=new r({left:e,top:i,width:36,height:28,radius:o.radius.sm,fill:!0,stroke:!0,style:{fillStyle:s?o.colors.surface:o.colors.background,strokeStyle:s?o.colors.border:o.colors.disabled}});return n.addChild(new H({interactive:!1,left:0,top:0,width:36,height:28,align:"center",verticalAlign:"middle",text:t,style:{fontSize:14,fillStyle:s?o.colors.text:o.colors.textDisabled}}),!1),n}},t.ICETree=bt,t.ICETreeSelect=class extends r{handle=null;panel=null;tree=null;fieldLabel=null;running=!1;constructor(t){const e=h.getTheme(),i=t.width??220,s=t.height??e.control.height;super({id:t.id,fill:!0,stroke:!0,left:t.left,top:t.top,width:i,height:s,radius:e.radius.md,style:{fillStyle:e.colors.surface,strokeStyle:e.colors.border,lineWidth:e.control.lineWidth}}),this.nodes=t.nodes||[],this.value=t.value??null,this.placeholder=t.placeholder||"",this.disabled=!0===t.disabled,this.treeHeight=t.treeHeight??160,this.defaultExpandAll=!0===t.defaultExpandAll,this.manager=t.manager||null,this.onChangeCallback="function"==typeof t.onChange?t.onChange:null,this.focusable=!this.disabled,this.focusRingMode="always",this.__syncField()}afterAddHandler(){super.afterAddHandler(),this.running||(!this.manager&&this.ice&&(this.manager=z(this.ice)),this.ice&&this.ice.evtBus&&"function"==typeof this.ice.evtBus.on&&(this.ice.evtBus.on("keydown",this.__onKeyDown,this),this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this)),this.on("click",this.__onClick,this),this.running=!0)}getValue(){return this.value}setValue(t){return this.value=t,this.__syncField(),this.isOpen()&&this.tree&&this.tree.setSelectedKeys(t?[t]:[]),this}getFormValue(){return this.value}setFormValue(t){this.setValue(null==t?null:String(t))}getFieldLabel(){return this.fieldLabel?this.fieldLabel.getText():""}isOpen(){return!!this.handle&&this.handle.isOpen()}getTree(){return this.tree}activate(){this.toggle()}toggle(){return this.isOpen()?this.close():this.open()}open(){if(this.disabled||this.isOpen())return this;if(!this.manager){if(!this.ice)throw new Error("ICETreeSelect 需要先加入 ICE 场景");this.manager=z(this.ice)}const t=h.getTheme(),e=Number(this.state.width)||220,i=new O({width:e,height:this.treeHeight+8,radius:t.radius.md,style:{fillStyle:t.colors.surface,strokeStyle:t.colors.border,shadow:"md"}}),s=new bt({nodes:this.nodes,left:4,top:4,width:e-8,height:this.treeHeight,defaultExpandAll:this.defaultExpandAll,value:this.value?[this.value]:[],onSelect:(t,e)=>{e&&this.__pick(e)}});return i.addChild(s,!1),this.panel=i,this.tree=s,this.handle=this.manager.open({anchor:this,content:i,placement:"bottomLeft",offset:4,enterAnimation:"scale",exitAnimation:"fade",keyboardCaptured:!0,closeOnOutsideClick:!1}),this}close(){return this.handle&&(this.handle.close(),this.handle=null),this.panel=null,this.tree=null,this}__pick(t){this.value=t.key,this.__syncField(),this.close(),this.onChangeCallback&&this.onChangeCallback(t.key,t)}__onClick(){this.disabled||this.toggle()}__onKeyDown(t){if(!this.isOpen())return;const e=t&&(t.originalEvent||t),i=e&&(e.key||e.code);"Escape"!==i&&"Esc"!==i||this.close()}__onGlobalMouseDown(t){if(!this.isOpen()||!t||"number"!=typeof t.offsetX||"number"!=typeof t.offsetY)return;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=t=>e>=t.left&&e<=t.left+t.width&&i>=t.top&&i<=t.top+t.height;s(this.__worldBox(this))||s(this.__worldBox(this.panel))||this.close()}__worldBox(t){let e=0,i=0,s=t;for(;s&&s.state;)e+=Number(s.state.left)||0,i+=Number(s.state.top)||0,s=s.parentNode;return{left:e,top:i,width:Number(t&&t.state&&t.state.width)||0,height:Number(t&&t.state&&t.state.height)||0}}__syncField(){const t=h.getTheme(),e=Number(this.state.width)||220,i=Number(this.state.height)||32,s="error"===this.validateStatus?t.colors.error:t.colors.border;this.setState({style:{...this.state.style,fillStyle:this.disabled?t.colors.disabled:t.colors.surface,strokeStyle:s}}),this.removeChildren([...this.childNodes]);const o=this.value?this.__findNode(this.value):null,n=o?o.label:this.placeholder;this.fieldLabel=new H({interactive:!1,left:10,top:0,width:Math.max(0,e-34),height:i,verticalAlign:"middle",text:n,style:{fontSize:13,fillStyle:o?t.colors.text:t.colors.textTertiary}}),this.addChild(this.fieldLabel,!1),this.addChild(new H({interactive:!1,left:e-22,top:0,width:14,height:i,align:"center",verticalAlign:"middle",text:"▾",style:{fontSize:12,fillStyle:t.colors.textTertiary}}),!1)}__findNode(t){const e=i=>{for(const s of i){if(s.key===t)return s;if(s.children){const t=e(s.children);if(t)return t}}return null};return e(this.nodes)}},t.ICETypography=class extends r{lines=[];labelNodes=[];constructor(t){const e=h.getTheme(),i=t.variant??"text",s=Math.min(5,Math.max(1,Math.floor(Number(t.level)||1))),o=Number(t.fontSize)||("title"===i?Ct[s-1]:e.font.size),n=Math.max(1,Math.floor(Number(t.rows)||1)),r=Math.round(o*("paragraph"===i?1.7:1.4)),l=t.height??n*r;super({id:t.id,fill:!1,stroke:!1,interactive:"link"===i,focusable:!1,left:t.left,top:t.top,width:t.width??240,height:l}),this.text=String(t.text??""),this.variant=i,this.type=t.type??"default",this.fontSize=o,this.rows=t.ellipsis||t.rows?n:1,this.lineHeight=r,this.onClick="function"==typeof t.onClick?t.onClick:null,this.focusable="link"===i,"link"===i&&this.on("click",()=>{this.onClick&&this.onClick()}),this.__render()}getText(){return this.text}getLines(){return this.lines.slice()}getFontSize(){return this.fontSize}getTextColor(){return this.__color()}getLabelNodes(){return this.labelNodes.slice()}setText(t){return this.text=String(t??""),this.__render(),this}setType(t){return this.type=t,this.__render(),this}__color(){const t=h.getTheme();return"secondary"===this.type?t.colors.textSecondary:"success"===this.type?t.colors.success:"warning"===this.type?t.colors.warningTextEmphasis:"danger"===this.type?t.colors.error:"primary"===this.type||"link"===this.variant?t.colors.primary:t.colors.text}__applyHoverState(){if("link"!==this.variant)return;const t=h.getTheme(),e=this.hovered?t.colors.primaryHover:this.__color();this.labelNodes.forEach(t=>{const i=t.childNodes[0];i&&i.setState({style:{...i.state.style,fillStyle:e}})}),this.revalidate()}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]),this.labelNodes=[];const e=Number(this.state.width)||240,i=this.__color();this.lines=xt(this.text,{maxWidth:e,fontSize:this.fontSize,maxLines:this.rows}),this.labelNodes=this.lines.map((s,o)=>{const n=new H({interactive:!1,left:0,top:o*this.lineHeight,width:e,height:this.lineHeight,text:s,verticalAlign:"middle",style:{fontSize:this.fontSize,fontFamily:t.font.family,fontWeight:"title"===this.variant?t.font.weightSemibold:t.font.weightNormal,fillStyle:i}});return this.addChild(n,!1),n}),this.revalidate(),this.ice&&(this.ice.dirty=!0)}},t.ICEUpload=class extends r{files=[];lastRejectReason=null;dropZone=null;fileNodes=new Map;inputEl=null;seq=0;constructor(t={}){h.getTheme();const e=t.width??320;super({id:t.id,fill:!1,stroke:!1,left:t.left,top:t.top,width:e,height:t.height??96}),this.accept=t.accept||"",this.multiple=!1!==t.multiple,this.maxCount=Math.max(0,Number(t.maxCount)||Number.MAX_SAFE_INTEGER),this.maxSize=Math.max(0,Number(t.maxSize)||Number.MAX_SAFE_INTEGER),this.disabled=!0===t.disabled,this.text=t.text||lt("upload.hint"),this.hint=t.hint||this.__defaultHint(),this.rowHeight=Math.max(20,Number(t.rowHeight)||28),this.beforeUpload="function"==typeof t.beforeUpload?t.beforeUpload:null,this.onChangeCallback="function"==typeof t.onChange?t.onChange:null,this.focusable=!this.disabled,this.__render()}getFileList(){return this.files.map(t=>({...t}))}isDisabled(){return this.disabled}getLastRejectReason(){return this.lastRejectReason}getDropZoneNode(){return this.dropZone}getHintText(){return this.text}getFileNode(t){return this.fileNodes.get(t)||null}addFile(t){const e={uid:t.uid||"upload-"+ ++this.seq,name:String(t.name??""),size:Number(t.size)||0,type:t.type,url:t.url},i=this.__rejectReason(e);return i?(this.lastRejectReason=i,!1):(this.lastRejectReason=null,this.files.push(e),this.__render(),this.__emit(),!0)}removeFile(t){const e=this.files.filter(e=>e.uid!==t);return e.length===this.files.length||(this.files=e,this.__render(),this.__emit()),this}clear(){return this.files.length?(this.files=[],this.__render(),this.__emit(),this):this}setDisabled(t){return this.disabled=!!t,this.focusable=!this.disabled,this.__render(),this}openPicker(){if(this.disabled)return!1;const t="undefined"==typeof document?null:document;if(!t||"function"!=typeof t.createElement)return!1;if(!this.inputEl){const e=t.createElement("input");e.type="file",this.accept&&(e.accept=this.accept),e.multiple=this.multiple,e.style.position="fixed",e.style.left="-9999px",e.addEventListener("change",()=>{Array.from(e.files||[]).forEach(t=>this.addFile({name:t.name,size:t.size,type:t.type})),e.value=""}),t.body&&"function"==typeof t.body.appendChild&&t.body.appendChild(e),this.inputEl=e}return"function"==typeof this.inputEl.click&&(this.inputEl.click(),!0)}activate(){this.openPicker()}__defaultHint(){const t=[];return this.accept&&t.push(this.accept),this.maxSize<Number.MAX_SAFE_INTEGER&&t.push(`不超过 ${Math.round(this.maxSize/1024)} KB`),t.join(" · ")}__rejectReason(t){if(this.disabled)return"已禁用";if(!this.__accepts(t))return"文件类型不支持:"+t.name;if(Number(t.size)>this.maxSize)return"文件大小超出限制:"+t.name;if(this.files.length>=this.maxCount)return`超过最大数量限制(${this.maxCount})`;if(this.beforeUpload){const e=this.beforeUpload(t);if(!1===e)return"文件被拒绝:"+t.name;if("string"==typeof e)return e}return null}__accepts(t){if(!this.accept)return!0;const e=t.name.toLowerCase(),i=String(t.type||"").toLowerCase();return this.accept.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean).some(t=>t.startsWith(".")?e.endsWith(t):t.endsWith("/*")?i.startsWith(t.slice(0,-1)):i===t)}__emit(){this.onChangeCallback&&this.onChangeCallback(this.getFileList())}__render(){const t=h.getTheme(),e=Number(this.state.width)||320;this.removeChildren([...this.childNodes]),this.fileNodes=new Map,this.setState({height:96+this.files.length*this.rowHeight});const i=new r({left:3,top:3,width:Math.max(0,e-6),height:90,radius:t.radius.md,fill:!0,stroke:!0,lineDash:[6,4],style:{fillStyle:this.disabled?t.colors.disabled:t.colors.background,strokeStyle:this.disabled?t.colors.borderSecondary:t.colors.border}}),s=Math.max(0,e-6),o=s/2-12;i.addChild(new H({interactive:!1,left:o,top:14,width:24,height:24,align:"center",verticalAlign:"middle",text:"+",style:{fontSize:20,fillStyle:this.disabled?t.colors.textDisabled:t.colors.textSecondary}}),!1),i.addChild(new H({interactive:!1,left:12,top:42,width:Math.max(0,s-24),height:18,align:"center",verticalAlign:"middle",text:this.text,style:{fontSize:13,fillStyle:this.disabled?t.colors.textDisabled:t.colors.text}}),!1),this.hint&&i.addChild(new H({interactive:!1,left:12,top:62,width:Math.max(0,s-24),height:16,align:"center",verticalAlign:"middle",text:this.hint,style:{fontSize:11,fillStyle:t.colors.textTertiary}}),!1),this.disabled||i.on("click",()=>this.openPicker()),this.addChild(i,!1),this.dropZone=i,this.files.forEach((i,s)=>{const o=96+s*this.rowHeight,n=new r({left:0,top:o,width:e,height:this.rowHeight,fill:!0,stroke:!1,style:{fillStyle:s%2==0?t.colors.surface:t.colors.background}});n.addChild(new H({interactive:!1,left:8,top:0,width:Math.max(0,e-60),height:this.rowHeight,verticalAlign:"middle",text:`${i.name}${i.size?`(${Math.max(1,Math.round(i.size/1024))} KB)`:""}`,style:{fontSize:12,fillStyle:t.colors.text}}),!1);const h=new r({left:e-32,top:Math.round((this.rowHeight-20)/2),width:20,height:20,radius:t.radius.sm,fill:!1,stroke:!1});h.addChild(new H({interactive:!1,left:0,top:0,width:20,height:20,align:"center",verticalAlign:"middle",text:"✕",style:{fontSize:12,fillStyle:t.colors.textTertiary}}),!1),h.on("click",()=>this.removeFile(i.uid)),n.addChild(h,!1),this.addChild(n,!1),this.fileNodes.set(i.uid,n)}),this.ice&&void 0!==this.ice.dirty&&(this.ice.dirty=!0)}},t.ICEVirtualList=class extends r{items=[];nodes=new Map;scrollTop=0;constructor(t){super({fill:!1,stroke:!1,width:t.width||320,height:t.height||300,...t}),this.itemHeight=Math.max(1,Math.floor(Number(t.itemHeight)||1)),this.buffer=Math.max(0,Math.floor(Number(void 0===t.buffer?2:t.buffer)||0)),this.renderItem="function"==typeof t.renderItem?t.renderItem:()=>{},this.content=new r({left:0,top:0,width:this.__width(),height:0,fill:!1,stroke:!1,interactive:!1}),this.pane=new _t({left:0,top:0,width:this.__width(),height:this.__height(),scrollbar:!1!==t.scrollbar}),this.pane.setContent(this.content),this.pane.on("scroll",t=>{const e=t&&t.param&&Number(t.param.y)||0;this.scrollTop=e,this.__syncWindow()}),this.addChild(this.pane,!1),this.setItems(t.items||[])}getItemCount(){return this.items.length}getItemHeight(){return this.itemHeight}getBuffer(){return this.buffer}getItems(){return this.items.slice()}getContentHeight(){return this.items.length*this.itemHeight}getScrollTop(){return this.__syncWindow(),this.scrollTop}getRange(){return this.__syncWindow(),{start:this.__range().start,end:this.__range().end,count:this.__range().count}}getRenderedNodes(){return this.__syncWindow(),Array.from(this.nodes.keys()).sort((t,e)=>t-e).map(t=>({index:t,node:this.nodes.get(t)}))}getRenderedCount(){return this.__syncWindow(),this.nodes.size}getScrollPane(){return this.pane}setItems(t){this.items=Array.isArray(t)?t.slice():[];const e=this.getContentHeight();this.content.setState({width:this.__width(),height:e}),this.pane.setState({width:this.__width(),height:this.__height()}),this.pane.setContentSize(this.__width(),e);const i=Math.max(0,e-this.__height());return this.scrollTop=Math.min(this.scrollTop,i),this.pane.setScroll(0,this.scrollTop),this.__syncWindow(),this}setScrollTop(t){const e=Math.max(0,this.getContentHeight()-this.__height()),i=Math.min(Math.max(Number(t)||0,0),e);return this.scrollTop=i,this.pane.setScroll(0,i),this.__syncWindow(),this}scrollToIndex(t){if(!this.items.length)return this;const e=Math.min(Math.max(Math.floor(Number(t)||0),0),this.items.length-1);return this.setScrollTop(e*this.itemHeight)}__width(){return Number(this.state.width)||0}__height(){return Number(this.state.height)||0}__range(){return Ut({scrollTop:this.scrollTop,viewportHeight:this.__height(),itemHeight:this.itemHeight,itemCount:this.items.length,buffer:this.buffer})}__syncWindow(){this.pane.state.width===this.__width()&&this.pane.state.height===this.__height()||this.pane.setState({width:this.__width(),height:this.__height()});const t=this.__range();Array.from(this.nodes.keys()).forEach(e=>{if(e>=t.start&&e<t.end)return;const i=this.nodes.get(e);this.nodes.delete(e),i&&"function"==typeof this.content.removeChild&&this.content.removeChild(i)});for(let e=t.start;e<t.end;e+=1){if(this.nodes.has(e))continue;const t=new r({left:0,top:e*this.itemHeight,width:this.__width(),height:this.itemHeight,fill:!1,stroke:!1,interactive:!1});this.content.addChild(t,!1),this.nodes.set(e,t),this.renderItem(e,this.items[e],t)}}},t.ICEWatermark=class extends r{tiles=[];constructor(t){h.getTheme();const e=t.fontSize??14,i=String(t.text??"");super({id:t.id,fill:!1,stroke:!1,interactive:!1,draggable:!1,clipChildren:!0,left:t.left,top:t.top,width:t.width??400,height:t.height??200}),this.text=i,this.fontSize=e,this.color=t.color??"rgba(0,0,0,0.08)",this.rotate=t.rotate??-22,this.gapX=Number(t.gapX)||Math.round(F(i,e)+60),this.gapY=Number(t.gapY)||72,this.opacity=t.opacity??1,this.__render()}getText(){return this.text}getTileCount(){return this.tiles.length}getTileNodes(){return this.tiles.slice()}setText(t){return this.text=String(t??""),this.tiles.forEach(t=>t.setText(this.text)),this.revalidate(),this}setSize(t,e){return this.setState({width:Math.max(0,Number(t)||0),height:Math.max(0,Number(e)||0)}),this.__render(),this}__render(){const t=h.getTheme();this.removeChildren([...this.childNodes]),this.tiles=[];const e=Number(this.state.width)||0,i=Number(this.state.height)||0,s=Math.max(20,this.gapX),o=Math.max(20,this.gapY),n=Math.ceil(e/s)+1,r=Math.ceil(i/o)+1,l=F(this.text,this.fontSize),a=this.fontSize+6;for(let e=0;e<r;e+=1)for(let i=0;i<n;i+=1){const n=new H({interactive:!1,left:i*s-Math.round(s/2),top:e*o-Math.round(o/2),width:l,height:a,text:this.text,verticalAlign:"middle",opacity:this.opacity,transform:{rotate:this.rotate},style:{fontSize:this.fontSize,fontFamily:t.font.family,fillStyle:this.color}});this.addChild(n,!1),this.tiles.push(n)}this.revalidate(),this.ice&&(this.ice.dirty=!0)}},t.ICEWidget=r,t.ICEWindow=class extends r{titleBands=[];maximized=!1;restoreBox=null;content=null;dragOffset=null;resizing=!1;resizeStart=null;bound=!1;constructor(t={}){const e=t.titleBarHeight??28;super({id:t.id,fill:!1,stroke:!1,interactive:!0,left:t.left,top:t.top,width:t.width??420,height:t.height??320}),this.options=t,this.appearance={...ae,...t.appearance||{}},this.titleBarHeight=e,this.active=!1!==t.active,this.bounds=t.bounds||null,this.minWidth=t.minWidth??220,this.minHeight=t.minHeight??140,this.movable=!1!==t.movable,this.resizable=!1!==t.resizable;const i=new r({left:0,top:0,width:Number(this.state.width),height:Number(this.state.height),radius:7,fill:!0,stroke:!0,style:{fillStyle:this.appearance.body,strokeStyle:this.appearance.border,lineWidth:1}});this.addChild(i,!1),this.titleBar=new r({left:3,top:3,width:Number(this.state.width)-6,height:e,radius:5,fill:!1,stroke:!1});for(let t=0;t<10;t+=1){const i=new r({left:0,top:t*e/10,width:Number(this.state.width)-6,height:e/10+1,fill:!0,stroke:!1,style:{fillStyle:"#0058ee"}});this.titleBar.addChild(i,!1),this.titleBands.push(i)}if(t.iconNode){const i=t.iconNode,s=Number(i.state&&i.state.height)||16;i.setState({left:6,top:Math.round((e-s)/2)}),this.iconNode=i}else this.iconNode=new H({interactive:!1,left:6,top:0,width:18,height:e,text:t.icon??"",align:"center",verticalAlign:"middle",style:{fontSize:13,fillStyle:"#ffffff"}});this.titleLabel=new H({interactive:!1,left:26,top:0,width:Number(this.state.width)-120,height:e,text:t.title??"",verticalAlign:"middle",style:{fontSize:12,fontWeight:"700",fillStyle:this.appearance.titleText}}),this.titleBar.addChild(this.iconNode,!1),this.titleBar.addChild(this.titleLabel,!1);const s=Math.round((e-16)/2),o=Number(this.state.width)-6-4;this.closeButton=new le({left:o-20,top:s,size:20,text:"✕",onClick:()=>{!1!==this.options.closable&&(this.trigger("close",null,{}),this.options.onClose&&this.options.onClose())}}),this.maximizeButton=new le({left:o-40-2,top:s,size:20,text:"□",onClick:()=>{!1!==this.options.maximizable&&(this.maximized?this.restore():this.maximize())}}),this.minimizeButton=new le({left:o-60-4,top:s,size:20,text:"─",onClick:()=>{!1!==this.options.minimizable&&(this.trigger("minimize",null,{}),this.options.onMinimize&&this.options.onMinimize())}}),this.titleBar.addChild(this.closeButton,!1),this.titleBar.addChild(this.maximizeButton,!1),this.titleBar.addChild(this.minimizeButton,!1),this.addChild(this.titleBar,!1),this.client=new r({left:3,top:3+e,width:Number(this.state.width)-6,height:Number(this.state.height)-e-6,fill:!0,stroke:!1,clipChildren:!0,style:{fillStyle:"#ffffff"}}),this.addChild(this.client,!1),this.resizeHandle=new r({left:Number(this.state.width)-14,top:Number(this.state.height)-14,width:12,height:12,fill:!1,stroke:!1}),this.addChild(this.resizeHandle,!1),t.content&&this.setContent(t.content),this.__syncTitleBands(),this.on("mousedown",()=>this.activate())}getTitle(){return this.titleLabel.getText()}setTitle(t){return this.titleLabel.setText(t??""),this}getTitleBar(){return this.titleBar}getTitleBarHeight(){return this.titleBarHeight}getClientBox(){return{left:Number(this.client.state.left),top:Number(this.client.state.top),width:Number(this.client.state.width),height:Number(this.client.state.height)}}getClientNode(){return this.client}getCloseButton(){return this.closeButton}getMinimizeButton(){return this.minimizeButton}getMaximizeButton(){return this.maximizeButton}getResizeHandle(){return this.resizeHandle}getTitleBarColor(){const t=Math.floor(this.titleBands.length/2),e=this.titleBands[t];return e?String(e.state.style.fillStyle):""}isActive(){return this.active}setActive(t){const e=!!t;return e===this.active||(this.active=e,this.__syncTitleBands()),this}activate(){const t=this.active;return this.active=!0,t||this.__syncTitleBands(),this.trigger("activate",null,{}),this.options.onActivate&&this.options.onActivate(),this}isMaximized(){return this.maximized}maximize(){if(this.maximized)return this;this.restoreBox={left:Number(this.state.left)||0,top:Number(this.state.top)||0,width:Number(this.state.width)||0,height:Number(this.state.height)||0};const t=this.__bounds();return this.maximized=!0,this.setState({left:t.left,top:t.top,width:t.width,height:t.height}),this.__layout(),this.trigger("maximize",null,{maximized:!0}),this.options.onMaximize&&this.options.onMaximize(!0),this}restore(){if(!this.maximized)return this;this.maximized=!1;const t=this.restoreBox;return this.restoreBox=null,t&&this.setState(t),this.__layout(),this.trigger("maximize",null,{maximized:!1}),this.options.onMaximize&&this.options.onMaximize(!1),this}setContent(t){if(this.content&&this.content.parentNode===this.client&&this.client.removeChild(this.content),this.content=t||null,this.content){this.client.addChild(this.content,!1);const t=this.getClientBox();this.content.setState({left:0,top:0,width:t.width,height:t.height}),"function"==typeof this.content.revalidate&&this.content.revalidate()}return this}getContent(){return this.content}isDragging(){return!!this.dragOffset}isResizing(){return this.resizing}setBounds(t){return this.bounds=t,this}setSize(t,e){return this.setState({width:Math.max(this.minWidth,Math.round(t)||this.minWidth),height:Math.max(this.minHeight,Math.round(e)||this.minHeight)}),this.__layout(),this}afterAddHandler(){super.afterAddHandler(),!this.bound&&this.ice&&this.ice.evtBus&&(this.bound=!0,this.ice.evtBus.on("mousedown",this.__onGlobalMouseDown,this),this.ice.evtBus.on("mousemove",this.__onGlobalMouseMove,this),this.ice.evtBus.on("mouseup",this.__onGlobalMouseUp,this))}revalidate(){return super.revalidate(),this.__layout(),this}__afterStateMerge(t){super.__afterStateMerge(t),t&&this.__layout()}__bounds(){if(this.bounds)return this.bounds;const t=this.parentNode;return{left:0,top:0,width:Number(t&&t.state&&t.state.width)||Number(this.state.width)||0,height:Number(t&&t.state&&t.state.height)||Number(this.state.height)||0}}__syncTitleBands(){const[t,e]=this.active?this.appearance.titleActive:this.appearance.titleInactive;this.titleBands.forEach((i,s)=>{i.setState({style:{fillStyle:de(t,e,s/(this.titleBands.length-1))}})}),this.titleLabel.setState({style:{...this.titleLabel.state.style,fillStyle:this.active?this.appearance.titleText:this.appearance.titleTextInactive}})}__layout(){const t=Number(this.state.width)||0,e=Number(this.state.height)||0,i=this.childNodes[0];i&&i.setState({width:t,height:e});const s=Math.max(0,t-6);this.titleBar.setState({width:s}),this.titleBands.forEach((t,e)=>{t.setState({top:e*this.titleBarHeight/10,width:s,height:this.titleBarHeight/10+1})}),this.titleLabel.setState({width:Math.max(0,s-120)});const o=t-6-4;this.closeButton.setState({left:o-20,top:Math.round((this.titleBarHeight-16)/2)}),this.maximizeButton.setState({left:o-40-2}),this.minimizeButton.setState({left:o-60-4});const n=Math.max(0,t-6),h=Math.max(0,e-this.titleBarHeight-6);this.client.setState({width:n,height:h}),this.content&&(this.content.setState({left:0,top:0,width:n,height:h}),"function"==typeof this.content.revalidate&&this.content.revalidate()),this.resizeHandle.setState({left:t-14,top:e-14}),this.ice&&(this.ice.dirty=!0)}__nodeBoxWorld(t){const e=E(this);let i=0,s=0,o=t;for(;o&&o!==this;)i+=Number(o.state&&o.state.left)||0,s+=Number(o.state&&o.state.top)||0,o=o.parentNode;return{left:e.left+i,top:e.top+s,width:Number(t.state.width)||0,height:Number(t.state.height)||0}}__pointIn(t,e){if(!e||"number"!=typeof e.offsetX||"number"!=typeof e.offsetY)return!1;if(!this.ice||"function"!=typeof this.ice.screenToWorld)return!1;const[i,s]=this.ice.screenToWorld(e.offsetX,e.offsetY),o=this.__nodeBoxWorld(t);return i>=o.left&&i<=o.left+o.width&&s>=o.top&&s<=o.top+o.height}__hitOwnButton(t){return[this.closeButton,this.maximizeButton,this.minimizeButton].some(e=>this.__pointIn(e,t))}__parentOrigin(){const t=E(this);return{left:t.left-(Number(this.state.left)||0),top:t.top-(Number(this.state.top)||0)}}__onGlobalMouseDown(t){if(!this.__pointIn(this,t))return;if(this.activate(),this.maximized)return;if(this.resizable&&this.__pointIn(this.resizeHandle,t)){this.resizing=!0;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY);return void(this.resizeStart={x:e,y:i,width:Number(this.state.width)||0,height:Number(this.state.height)||0})}if(!this.movable||this.__hitOwnButton(t))return;if(!(this.__pointIn(this.titleBar,t)||this.__pointIn(this.iconNode,t)||this.__pointIn(this.titleLabel,t)))return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=this.__parentOrigin();this.dragOffset={x:e-(s.left+(Number(this.state.left)||0)),y:i-(s.top+(Number(this.state.top)||0))}}__onGlobalMouseMove(t){if(!this.ice||!t||"number"!=typeof t.offsetX)return;if(this.resizing&&this.resizeStart){const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=Math.max(this.minWidth,this.resizeStart.width+(e-this.resizeStart.x)),o=Math.max(this.minHeight,this.resizeStart.height+(i-this.resizeStart.y));return this.setState({width:Math.round(s),height:Math.round(o)}),this.__layout(),this.trigger("resize",null,{width:this.state.width,height:this.state.height}),void(this.options.onResize&&this.options.onResize(Number(this.state.width),Number(this.state.height)))}if(!this.dragOffset)return;const[e,i]=this.ice.screenToWorld(t.offsetX,t.offsetY),s=this.__bounds(),o=this.__parentOrigin(),n=Math.max(s.left,s.left+s.width-(Number(this.state.width)||0)),h=Math.max(s.top,s.top+s.height-(Number(this.state.height)||0)),r=Math.min(n,Math.max(s.left,e-this.dragOffset.x-o.left)),l=Math.min(h,Math.max(s.top,i-this.dragOffset.y-o.top));this.setState({left:Math.round(r),top:Math.round(l)}),this.trigger("move",null,{left:this.state.left,top:this.state.top}),this.options.onMove&&this.options.onMove(Number(this.state.left),Number(this.state.top))}__onGlobalMouseUp(){this.dragOffset=null,this.resizing=!1,this.resizeStart=null}},t.ICE_2048_DIRECTIONS=_e,t.ICE_ARCADE_PALETTE={empty:{fillStyle:"#161d27",strokeStyle:"#232c3a",lineWidth:1},I:{fillStyle:"#0dcaf0",strokeStyle:"#097e96"},O:{fillStyle:"#ffc107",strokeStyle:"#a67c00"},T:{fillStyle:"#a370f7",strokeStyle:"#6a43a6"},S:{fillStyle:"#198754",strokeStyle:"#0f5634"},Z:{fillStyle:"#dc3545",strokeStyle:"#8f222d"},J:{fillStyle:"#0d6efd",strokeStyle:"#0847a4"},L:{fillStyle:"#fd7e14",strokeStyle:"#a4510d"},snakeHead:{fillStyle:"#20c997",strokeStyle:"#158363"},snakeBody:{fillStyle:"#198754",strokeStyle:"#0f5634"},snakeBodyAlt:{fillStyle:"#157347",strokeStyle:"#0d4a2e"},food:{fillStyle:"#dc3545",strokeStyle:"#8f222d",radius:9},2:{fillStyle:"#eee4da",strokeStyle:"#d8cdc4",radius:6,fontSize:34,fontWeight:"700",textColor:"#776e65"},4:{fillStyle:"#ede0c8",strokeStyle:"#d8c9ad",radius:6,fontSize:34,fontWeight:"700",textColor:"#776e65"},8:{fillStyle:"#f2b179",strokeStyle:"#d69a63",radius:6,fontSize:34,fontWeight:"700",textColor:"#f9f6f2"},16:{fillStyle:"#f59563",strokeStyle:"#d67f4f",radius:6,fontSize:32,fontWeight:"700",textColor:"#f9f6f2"},32:{fillStyle:"#f67c5f",strokeStyle:"#d5674c",radius:6,fontSize:32,fontWeight:"700",textColor:"#f9f6f2"},64:{fillStyle:"#f65e3b",strokeStyle:"#d64c2d",radius:6,fontSize:32,fontWeight:"700",textColor:"#f9f6f2"},128:{fillStyle:"#edcf72",strokeStyle:"#cfb35c",radius:6,fontSize:28,fontWeight:"700",textColor:"#f9f6f2"},256:{fillStyle:"#edcc61",strokeStyle:"#cfb04f",radius:6,fontSize:28,fontWeight:"700",textColor:"#f9f6f2"},512:{fillStyle:"#edc850",strokeStyle:"#cfad3f",radius:6,fontSize:28,fontWeight:"700",textColor:"#f9f6f2"},1024:{fillStyle:"#edc53f",strokeStyle:"#cfaa31",radius:6,fontSize:24,fontWeight:"700",textColor:"#f9f6f2"},2048:{fillStyle:"#edc22e",strokeStyle:"#cfa71f",radius:6,fontSize:24,fontWeight:"700",textColor:"#f9f6f2"},4096:{fillStyle:"#3c3a32",strokeStyle:"#2b2923",radius:6,fontSize:22,fontWeight:"700",textColor:"#f9f6f2"},8192:{fillStyle:"#2f2d26",strokeStyle:"#211f1a",radius:6,fontSize:22,fontWeight:"700",textColor:"#f9f6f2"}},t.ICE_ARCADE_THEME=o,t.ICE_DARK_THEME=s,t.ICE_DEFAULT_LOCALE="zh-CN",t.ICE_LIGHT_THEME=i,t.ICE_LOCALE_EN_US=nt,t.ICE_LOCALE_ZH_CN=ot,t.ICE_MINESWEEPER_DIFFICULTIES=[{key:"beginner",label:"初级",rows:9,cols:9,mines:10},{key:"intermediate",label:"中级",rows:16,cols:16,mines:40},{key:"expert",label:"高级",rows:16,cols:30,mines:99}],t.ICE_SNAKE_DIRECTIONS=["up","right","down","left"],t.ICE_TETRIS_LINE_SCORES=me,t.ICE_TETROMINOES=ge,t.ICE_TOOLTIP_FONT_SIZE=12,t.ICE_TOOLTIP_PADDING_X=8,t.ICE_XP_THEME={colors:{primary:"#316ac5",primaryHover:"#4a86e8",primaryActive:"#24529a",primaryBg:"#d6e5fb",primaryBorder:"#7f9db9",primaryText:"#ffffff",background:"#ece9d8",surface:"#ffffff",elevated:"#ffffff",border:"#7f9db9",borderSecondary:"#d4d0c8",text:"#000000",textSecondary:"#4a4a4a",textTertiary:"#6d6d6d",textDisabled:"#9a9a9a",muted:"#6d6d6d",disabled:"#d4d0c8",disabledText:"#9a9a9a",success:"#1c7c31",successBg:"#dff0d8",successBorder:"#a6c99a",warning:"#b8860b",warningBg:"#fdf3d8",warningBorder:"#e0c37a",error:"#c1272d",errorBg:"#f8d7da",errorBorder:"#d9a0a3",info:"#0a5cd8",infoBg:"#d6e5fb",infoBorder:"#9db4d0",primaryTextEmphasis:"#1b3f75",successTextEmphasis:"#0f4a1e",warningTextEmphasis:"#6b4e05",errorTextEmphasis:"#7a191d",infoTextEmphasis:"#0a3b8c",focusRing:"#316ac5"},spacing:{xxs:4,xs:6,sm:10,md:14,lg:20,xl:28,xxl:40},radius:{xs:2,sm:2,md:3,lg:4,xl:6,pill:999},font:{family:'Tahoma, "Microsoft YaHei", "Segoe UI", Verdana, sans-serif',size:12,sizeSmall:11,sizeLarge:13,weightNormal:"normal",weightMedium:"500",weightSemibold:"600",weightBold:"bold"},control:{heightSmall:20,height:24,heightLarge:28,paddingXXS:3,paddingXS:6,paddingSmall:8,padding:12,paddingLarge:18,lineWidth:1,lineWidthFocused:2,switchWidth:40,switchHeight:20,switchHandle:16,checkboxSize:14,radioSize:14,progressHeight:14,sliderTrackHeight:4,sliderHandle:12},shadows:{sm:{shadowColor:"rgba(0, 0, 0, 0.10)",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}}},t.attachDropdown=function(t,e,i){return new pt(t,e,i).start()},t.attachPopconfirm=function(t,e,i={}){return new ft(t,e,i).start()},t.attachPopover=function(t,e,i={}){return new ut(t,e,i).start()},t.attachTooltip=function(t,e,i={}){return new ct(t,e,i).start()},t.buildMonthGrid=oe,t.centerTextNode=L,t.computeDropTarget=Z,t.computeTreeDropTarget=J,t.computeVirtualRange=Ut,t.createTextNode=V,t.easeInOutCubic=p,t.easeInQuad=g,t.easeOutCubic=m,t.estimateTextWidth=F,t.fadeIn=v,t.fadeOut=x,t.fadeTo=b,t.formatCalendarDate=se,t.formatCountdown=Jt,t.formatStatisticValue=Qt,t.getICEFocusManager=B,t.getICELocale=function(){return rt},t.getICELocaleMessages=function(t=rt){return{...ht[t]||{}}},t.getICELocaleNames=function(){return Object.keys(ht)},t.getICEMessageManager=q,t.getICEOverlayManager=z,t.getICEWorldBox=E,t.getStatusColors=D,t.iceUIManager=h,t.isPointInsideICEBox=function(t,e,i){return e>=t.left&&e<=t.left+t.width&&i>=t.top&&i<=t.top+t.height},t.mountICEAccessibilityMirror=function(t,e={}){const i=void 0===e.doc?globalThis.document:e.doc;let s=null,o=[],n=!1;const h=()=>{o.forEach(t=>{s&&"function"==typeof s.removeChild&&s.removeChild(t)}),o=[]},r=()=>{const n=s||(e.container&&"function"==typeof e.container.appendChild?(s=e.container,s):i&&i.body&&"function"==typeof i.createElement?(s=i.createElement("div"),s.id=e.id||"ice-a11y-mirror",s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.width=(Number(t&&t.canvasWidth)||0)+"px",s.style.height=(Number(t&&t.canvasHeight)||0)+"px",s.style.overflow="hidden",s.style.pointerEvents="none",s.style.zIndex="1","function"==typeof s.setAttribute&&s.setAttribute("role","application"),i.body.appendChild(s),s):null);if(!n||!t||"function"!=typeof t.getAccessibilityTree)return;h();const r=t.getAccessibilityTree({includeHidden:!0===e.includeHidden})||[],l=(()=>{const e=new Map,i=t=>{(t||[]).forEach(t=>{if(!t||!t.state)return;const s=t.state.id||t.props&&t.props.id;s&&e.set(String(s),t),i(t.childNodes)})};return i(t&&t.childNodes),e})();r.forEach(s=>{const h=l.get(String(s.id))||null,r=i.createElement("div"),a=s.box||{x:0,y:0,width:0,height:0};r.style.position="absolute",r.style.left=Math.round(a.x)+"px",r.style.top=Math.round(a.y)+"px",r.style.width=Math.max(1,Math.round(a.width))+"px",r.style.height=Math.max(1,Math.round(a.height))+"px",r.style.opacity="0",r.style.color="transparent",r.style.background="transparent",r.style.border="none",r.style.padding="0",r.style.margin="0",r.style.pointerEvents=s.interactive?"auto":"none","function"==typeof r.setAttribute&&(r.setAttribute("role",function(t,e,i){if(i.roleMap){const s=i.roleMap(t,e);if(s)return s}return t.interactive||t.focusable?"button":"text"===t.role?"text":"image"===t.role?"img":"link"===t.role?"link":"container"===t.role?"group":"img"}(s,h,e)),r.setAttribute("aria-label",s.label||s.id),r.setAttribute("data-ice-id",s.id),s.focusable&&r.setAttribute("tabindex",String(Math.max(0,s.tabIndex||0))),s.selected&&r.setAttribute("aria-selected","true"));const d=()=>{h&&("function"==typeof t.setFocusedComponent&&t.setFocusedComponent(h),"function"==typeof h.activate?h.activate():"function"==typeof h.trigger&&h.trigger("click"))};"function"==typeof r.addEventListener&&(r.addEventListener("click",d),r.addEventListener("focus",()=>{h&&"function"==typeof t.setFocusedComponent&&t.setFocusedComponent(h)})),n.appendChild(r),o.push(r)})},l={isMounted:()=>n,getContainer:()=>s,getElements:()=>o.slice(),refresh:()=>{n&&r()},unmount:()=>{n&&(h(),s&&s.parentNode&&"function"==typeof s.parentNode.removeChild&&s.parentNode.removeChild(s),e.container||(s=null),n=!1)}};return i&&i.body&&"function"==typeof i.createElement&&(n=!0,r()),l},t.moveItem=Q,t.moveKanbanCard=st,t.moveTreeNode=et,t.openDrawer=function(t,e={}){return new yt(t,e).open()},t.openImagePreview=function(t,e){const i=new ie(t,e);return i.open(),i},t.openModal=function(t,e={}){return new gt(t,e).open()},t.readHovered=R,t.registerICELocale=function(t,e){t&&(ht[t]={...ht[t]||{},...e||{}})},t.resolveColumnWidths=jt,t.resolveICEEasing=y,t.resolveICEOverlayPosition=u,t.scaleIn=C,t.setICELocale=function(t){t&&ht[t]&&(rt=t)},t.slideIn=S,t.t=lt,t.tooltipPanelWidth=dt,t.truncateTextLines=xt,t.tween=_,Object.defineProperty(t,"__esModule",{value:!0})}));