text: var je=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertySymbols;var Lt=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable;var tt=(a,e,t)=>e in a?je(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,U=(a,e)=>{for(var t in e||(e={}))Lt.call(e,t)&&tt(a,t,e[t]);if(et)for(var t of et(e))Mt.call(e,t)&&tt(a,t,e[t]);return a};var l=(a,e)=>je(a,"name",{value:e,configurable:!0});var v=(a,e,t,i)=>{for(var r=i>1?void 0:i?Et(e,t):e,n=a.length-1,s;n>=0;n--)(s=a[n])&&(r=(i?s(e,t,r):s(r))||r);return i&&r&&je(e,t,r),r};var it=(a,e,t)=>new Promise((i,r)=>{var n=h=>{try{o(t.next(h))}catch(d){r(d)}},s=h=>{try{o(t.throw(h))}catch(d){r(d)}},o=h=>h.done?i(h.value):Promise.resolve(h.value).then(n,s);o((t=t.apply(a,e)).next())});var Q;(function(n){n.SpaceBetween="between",n.SpaceAround="around",n[n.Start=0]="Start",n[n.Center=.5]="Center",n[n.End=1]="End"})(Q||(Q={}));var x;(function(r){r.Stretch="stretch",r[r.Start=0]="Start",r[r.Center=.5]="Center",r[r.End=1]="End"})(x||(x={}));var j=class{constructor(e,t,i){this.target=e,this.focusType=t,this.needsFocus=i}};l(j,"Event");var ue=class extends j{constructor(e,t,i,r,n,s){super(r,n,s);this.shift=e,this.ctrl=t,this.alt=i}};l(ue,"ModifierEvent");var k=class extends ue{constructor(e,t,i,r,n,s=null,o=null){super(i,r,n,s,o,!1);this.x=e,this.y=t}};l(k,"PointerEvent");var De=null;function Ee(a,e){if(De===null&&(De=document.createElement("canvas").getContext("2d"),De===null))throw new Error("Failed to get canvas context");return De.font=e,De.measureText(a)}l(Ee,"measureTextDims");function Le(a){return function(e,t){let i=new WeakMap;Object.defineProperty(e,t,{set:function(r){let n=i.get(this);r!==n&&(i.set(this,r),a.call(this,n))},get:function(){return i.get(this)},enumerable:!0,configurable:!0})}}l(Le,"watchField");function rt(a){return Le(function(){this[a]=!0})}l(rt,"flagField");var nt=rt("_dirty"),O=rt("_layoutDirty");function H(a){return Le(function(){for(let e of a)this[e]=!0})}l(H,"multiFlagField");var oi=H(["_dirty","_layoutDirty"]);function st(a,e=!1){return function(t,i){let r=new WeakMap;Object.defineProperty(t,i,{set:function(n){if(Array.isArray(n)){let s=r.get(this);if(Array.isArray(s)){if(n.length!==s.length){s.length=n.length;for(let o=0;o<n.length;o++)s[o]=n[o];a.call(this)}else for(let o=0;o<n.length;o++)if(s[o]!==n[o]){for(let h=0;h<n.length;h++)s[h]=n[h];a.call(this);return}}else r.set(this,[...n]),a.call(this)}else if(e)r.set(this,n),a.call(this);else throw new Error("Value must be an array")},get:function(){let n=r.get(this);return Array.isArray(n)?[...n]:n},enumerable:!0,configurable:!0})}}l(st,"watchArrayField");function ot(a,e=!1){return st(function(){this[a]=!0},e)}l(ot,"flagArrayField");function Me(a=!1){return ot("_dirty",a)}l(Me,"paintArrayField");function lt(a=!1){return ot("_layoutDirty",a)}l(lt,"layoutArrayField");function Ht(a,e=!1){return st(function(){for(let t of a)this[t]=!0},e)}l(Ht,"multiFlagArrayField");function at(a=!1){return Ht(["_dirty","_layoutDirty"],a)}l(at,"paintLayoutArrayField");var Vt=new Set([`
  `,"	"]),ce;(function(t){t[t.Normal=0]="Normal",t[t.Shrink=1]="Shrink"})(ce||(ce={}));var me;(function(i){i[i.Start=0]="Start",i[i.Center=.5]="Center",i[i.End=1]="End"})(me||(me={}));var C=class{constructor(){this.text="";this.font="";this.maxWidth=1/0;this.lineHeight=null;this.lineSpacing=null;this.tabWidth=4;this.wrapMode=0;this.alignMode=0;this._width=0;this._height=0;this._lineHeight=0;this._lineSpacing=0;this._tabWidth=0;this.measureDirty=!0;this.lineHeightSpacingDirty=!0;this.tabWidthDirty=!0;this._dirty=!1;this._lineRanges=[]}get dirty(){let e=this._dirty;return this._dirty=!1,e}measureTextSlice(e,t,i){let r=Ee(this.text.slice(t,i),this.font);return e===0?r.width+Math.max(0,r.actualBoundingBoxLeft):e+r.width}getLineRangeWidthUntil(e,t){if(t<=e[0][0])return 0;let i=0;for(;i<e.length;i++){let s=e[i],o=s[1];if(t==o)return s[2];if(t>=s[0]&&t<o)break}if(i===e.length)return e[i-1][2];let r=0;i>0&&(r=e[i-1][2]);let n=e[i];return n[3]?r+n[2]*(t-n[0])/(n[1]-n[0]):this.measureTextSlice(r,n[0],t)}measureText(e,t,i,r){var c,p;let n=0;for(;n<r.length;n++){let m=r[n];if(e>=m[0]&&e<m[1]){e=m[0];break}}if(n>0){let m=r[n-1];m[1]!==e&&(e=m[1],--n>0?m=r[n]:m=null),m!==null&&!m[3]&&!Vt.has(this.text[e])&&(e=m[0],n--)}let s=0;n>0&&(s=r[n-1][2]);let o=e,h=[];for(;o<t;)if(this.text[o]==="	"){let m=this.actualTabWidth;s=(Math.floor(s/m)+1)*m,h.push([o,++o,s,!0])}else if(this.text[o]===`
  `){h.push([o,++o,s,!0]),o<t&&console.warn("measureText called with text range where newline was at the middle of the range instead of at the end. Some text was ignored");break}else{let m=this.text.indexOf(`
  `,o+1);m===-1&&(m=1/0);let g=this.text.indexOf("	",o+1);g===-1&&(g=1/0);let b=Math.min(m,g,t);s=this.measureTextSlice(s,o,b),h.push([o,b,s,!1]),o=b}let d=n+h.length,u=(p=(c=h[h.length-1])!=null?c:r[n-1])!=null?p:null;return u===null?(r.length=0,r.push([e,e,0,!1]),!0):d===1&&u[1]-u[0]<=1||u[2]<=i?(r.length=n,r.push(...h),!0):!1}updateTextDims(){if(this.lineHeightSpacingDirty){this.lineHeightSpacingDirty=!1;let t=this._lineHeight,i=this._lineSpacing;if(this.lineHeight===null||this.lineSpacing===null){let r=Ee("~!@#$%^&*()_+`1234567890-=qwertyuiop[]\\QWERTYUIOP{}|asdfghjkl;'ASDFGHJKL:\"zxcvbnm,./ZXCVBNM<>?",this.font);this.lineHeight===null?this._lineHeight=r.actualBoundingBoxAscent:this._lineHeight=this.lineHeight,this.lineSpacing===null?this._lineSpacing=r.actualBoundingBoxDescent:this._lineSpacing=this.lineSpacing}else this._lineHeight=this.lineHeight,this._lineSpacing=this.lineSpacing;(t!==this._lineHeight||i!==this._lineSpacing)&&(this.measureDirty=!0)}if(this.tabWidthDirty&&(this.tabWidthDirty=!1,this._tabWidth=Ee(" ",this.font).width*this.tabWidth),!this.measureDirty)return;this.measureDirty=!1;let e=this._lineHeight+this._lineSpacing;if(this.text.length===0)this._height=e,this._width=this.maxWidth===1/0?0:this.maxWidth,this._lineRanges.length=1,this._lineRanges[0]=[[0,0,0,!1]];else if(this.maxWidth===1/0){this._lineRanges.length=0;let t=0;this._height=0,this._width=0;let i=this.text;for(;;){let r=this.text.indexOf(`
  `,t),n=r===-1,s=n?i.length:r+1,o=[];this.measureText(t,s,1/0,o),this._lineRanges.push(o),this._height+=e;let h=o[o.length-1][2];if(h>this._width&&(this._width=h),n)break;t=s}}else{this._lineRanges.length=0;let t=[],i=this.text,r=/\s/,n=-1;for(let s=0;s<=i.length;){let o=r.test(i[s]),h=s===i.length;if(o||h){if(n>=0&&!this.measureText(n,s,this.maxWidth,t)){let d=[];if(this.measureText(n,s,this.maxWidth,d)){if(t.length===0)throw new Error("Unexpected line range without any render groups");this._lineRanges.push(t),t=d}else{let u=n;for(;u<s-1&&this.measureText(u,u+1,this.maxWidth,t);u++);this._lineRanges.push(t),t=d,s=u,n=u;continue}}if(n=-1,h){if(t.length===0){let d=this._lineRanges[this._lineRanges.length-1];if(d===void 0)t.push([0,0,0,!1]);else{let u=d[d.length-1];u===void 0?t.push([0,0,0,!1]):t.push([u[1],u[1],0,!1])}}this._lineRanges.push(t);break}if(i[s]===`
  `)this.measureText(s,s+1,1/0,t),this._lineRanges.push(t),t=[];else if(!this.measureText(s,s+1,this.maxWidth,t))if(this.wrapMode===1){let d=s;do s++;while(i[s]!==`
  `&&r.test(i[s]));let u=t[t.length-1];t.push([d,s,u!==void 0?u[2]:0,!0]),this._lineRanges.push(t),t=[];continue}else this._lineRanges.push(t),t=[],this.measureText(s,s+1,1/0,t)}else n===-1&&(n=s);s++}this._width=this.maxWidth,this._height=e*this._lineRanges.length}}paintGroup(e,t,i,r,n){!t[3]&&t[2]>i&&e.fillText(this.text.slice(t[0],t[1]),r,n)}paint(e,t,i,r){e.save(),e.beginPath(),e.rect(i,r,this.width,this.height),e.clip(),e.font=this.font,e.fillStyle=t,e.textBaseline="alphabetic",this.updateTextDims();let n=this.fullLineHeight,s=r+this._lineHeight;for(let o=0;o<this._lineRanges.length;o++){let h=0,d=this.getLineShift(o);for(let u of this._lineRanges[o])this.paintGroup(e,u,h,i+h+d,s),h=u[2];s+=n}e.restore()}findOffsetFromIndex(e){if(this.updateTextDims(),e<=0||this._lineRanges.length===0)return[this.getLineShift(0),0];let t=0;for(let i of this._lineRanges){if(e<i[i.length-1][1])break;t++}return t>=this._lineRanges.length&&(t=this._lineRanges.length-1,e=this.text.length),[this.getLineRangeWidthUntil(this._lineRanges[t],e)+this.getLineShift(t),t*this.fullLineHeight]}findIndexOffsetFromOffset(e){let t=this.fullLineHeight,i=this.getLineShift(0);if(this.text===""||e[0]<=i&&e[1]<t||e[1]<0)return[0,[i,0]];let r=Math.floor(e[1]/t);if(this.updateTextDims(),r>=this._lineRanges.length){let p=this.text.length;return[p,this.findOffsetFromIndex(p)]}let n=r*t,s=this._lineRanges[r],o=this.getLineShift(r);if(s.length===1&&s[0][0]===s[0][1])return[s[0][0],[s[0][2]+o,n]];let h=0,d=s[0][0],u=s[s.length-1][1];this.text[u-1]===`
  `&&u--;let c=e[0]-o;for(let p=d;p<u;p++){let m=this.getLineRangeWidthUntil(s,p+1),g=(m+h)/2;if(c<g)return[p,[h+o,n]];h=m}return[u,[h+o,n]]}getLine(e){if(e<=0)return 0;this.updateTextDims();for(let t=0;t<this._lineRanges.length;t++){let i=this._lineRanges[t],r=i[i.length-1];if(e<r[1])return t}return this._lineRanges.length-1}getLineStart(e){if(e<=0)return 0;if(this.updateTextDims(),e>=this._lineRanges.length){let t=this._lineRanges[this._lineRanges.length-1];return t[t.length-1][1]}return this._lineRanges[e][0][0]}getLineEnd(e,t=!0){if(e<0)return 0;if(this.updateTextDims(),e>=this._lineRanges.length){let s=this._lineRanges[this._lineRanges.length-1];return s[s.length-1][1]}let i=this._lineRanges[e],r=i[i.length-1],n=r[1];return!t&&n>0&&this.text[n-1]===`
  `&&r[0]!==r[1]?n-1:n}getLineShift(e){let t=this.alignMode;if(t===0)return 0;if(this.updateTextDims(),e<0)e=0;else if(e>=this._lineRanges.length)return this.width*t;let i=this._lineRanges[e];return(this.width-i[i.length-1][2])*t}get width(){return this.updateTextDims(),this._width}get height(){return this.updateTextDims(),this._height}get lineRanges(){return this.updateTextDims(),[...this._lineRanges]}get actualLineHeight(){return this.updateTextDims(),this._lineHeight}get actualLineSpacing(){return this.updateTextDims(),this._lineSpacing}get actualTabWidth(){return this.updateTextDims(),this._tabWidth}get fullLineHeight(){return this.updateTextDims(),this._lineHeight+this._lineSpacing}};l(C,"TextHelper"),v([H(["_dirty","measureDirty"])],C.prototype,"text",2),v([H(["_dirty","measureDirty","lineHeightSpacingDirty","tabWidthDirty"])],C.prototype,"font",2),v([H(["_dirty","measureDirty"])],C.prototype,"maxWidth",2),v([H(["_dirty","measureDirty","lineHeightSpacingDirty"])],C.prototype,"lineHeight",2),v([H(["_dirty","measureDirty","lineHeightSpacingDirty"])],C.prototype,"lineSpacing",2),v([H(["_dirty","measureDirty","tabWidthDirty"])],C.prototype,"tabWidth",2),v([H(["_dirty","measureDirty"])],C.prototype,"wrapMode",2),v([H(["_dirty"])],C.prototype,"alignMode",2);var D=class{constructor(e,t){this.listener=null;this._fallbackTheme=t,typeof e!="undefined"&&(this._canvasFill=e.canvasFill,this._containerPadding=e.containerPadding,this._containerAlignment=e.containerAlignment,this._multiContainerSpacing=e.multiContainerSpacing,this._multiContainerAlignment=e.multiContainerAlignment,this._primaryFill=e.primaryFill,this._accentFill=e.accentFill,this._backgroundFill=e.backgroundFill,this._backgroundGlowFill=e.backgroundGlowFill,this._sliderMinLength=e.sliderMinLength,this._sliderThickness=e.sliderThickness,this._bodyTextFont=e.bodyTextFont,this._bodyTextFill=e.bodyTextFill,this._bodyTextHeight=e.bodyTextHeight,this._bodyTextSpacing=e.bodyTextSpacing,this._bodyTextAlign=e.bodyTextAlign,this._checkboxLength=e.checkboxLength,this._checkboxInnerPadding=e.checkboxInnerPadding,this._inputBackgroundFill=e.inputBackgroundFill,this._inputSelectBackgroundFill=e.inputSelectBackgroundFill,this._inputTextFont=e.inputTextFont,this._inputTextFill=e.inputTextFill,this._inputTextFillDisabled=e.inputTextFillDisabled,this._inputTextFillInvalid=e.inputTextFillInvalid,this._inputTextHeight=e.inputTextHeight,this._inputTextSpacing=e.inputTextSpacing,this._inputTextInnerPadding=e.inputTextInnerPadding,this._inputTextMinWidth=e.inputTextMinWidth,this._inputTextAlign=e.inputTextAlign,this._blinkRate=e.blinkRate,this._cursorThickness=e.cursorThickness,this._scrollBarThickness=e.scrollBarThickness,this._scrollBarMinPercent=e.scrollBarMinPercent,this._scrollBarMinPixels=e.scrollBarMinPixels)}get fallbackTheme(){return this._fallbackTheme}set fallbackTheme(e){if(this._fallbackTheme===e)return;let t=this._fallbackTheme;typeof t!="undefined"&&this.listener!==null&&t.unsubscribe(this.listener),typeof e!="undefined"&&(this.listener=i=>this.onThemeUpdated(i),e.subscribe(this.listener)),this._fallbackTheme=e,this.onThemeUpdated()}onThemeUpdated(e=null){}get canvasFill(){var e,t,i;return(i=(t=this._canvasFill)!=null?t:(e=this._fallbackTheme)==null?void 0:e.canvasFill)!=null?i:"rgba(0,0,0,0.5)"}set canvasFill(e){this._canvasFill!==e&&(this._canvasFill=e,this.onThemeUpdated("canvasFill"))}get containerPadding(){var e,t,i;return(i=(t=this._containerPadding)!=null?t:(e=this._fallbackTheme)==null?void 0:e.containerPadding)!=null?i:{left:4,right:4,top:4,bottom:4}}set containerPadding(e){this._containerPadding!==e&&(this._containerPadding=e,this.onThemeUpdated("containerPadding"))}get containerAlignment(){var e,t,i;return(i=(t=this._containerAlignment)!=null?t:(e=this._fallbackTheme)==null?void 0:e.containerAlignment)!=null?i:{horizontal:x.Start,vertical:x.Start}}set containerAlignment(e){this._containerAlignment!==e&&(this._containerAlignment=e,this.onThemeUpdated("containerAlignment"))}get multiContainerSpacing(){var e,t,i;return(i=(t=this._multiContainerSpacing)!=null?t:(e=this._fallbackTheme)==null?void 0:e.multiContainerSpacing)!=null?i:4}set multiContainerSpacing(e){this._multiContainerSpacing!==e&&(this._multiContainerSpacing=e,this.onThemeUpdated("multiContainerSpacing"))}get multiContainerAlignment(){var e,t,i;return(i=(t=this._multiContainerAlignment)!=null?t:(e=this._fallbackTheme)==null?void 0:e.multiContainerAlignment)!=null?i:{main:Q.SpaceBetween,cross:x.Stretch}}set multiContainerAlignment(e){this._multiContainerAlignment!==e&&(this._multiContainerAlignment=e,this.onThemeUpdated("multiContainerAlignment"))}get primaryFill(){var e,t,i;return(i=(t=this._primaryFill)!=null?t:(e=this._fallbackTheme)==null?void 0:e.primaryFill)!=null?i:"rgb(0,127,255)"}set primaryFill(e){this._primaryFill!==e&&(this._primaryFill=e,this.onThemeUpdated("primaryFill"))}get accentFill(){var e,t,i;return(i=(t=this._accentFill)!=null?t:(e=this._fallbackTheme)==null?void 0:e.accentFill)!=null?i:"rgb(0,195,255)"}set accentFill(e){this._accentFill!==e&&(this._accentFill=e,this.onThemeUpdated("accentFill"))}get backgroundFill(){var e,t,i;return(i=(t=this._backgroundFill)!=null?t:(e=this._fallbackTheme)==null?void 0:e.backgroundFill)!=null?i:"rgb(32,32,32)"}set backgroundFill(e){this._backgroundFill!==e&&(this._backgroundFill=e,this.onThemeUpdated("backgroundFill"))}get backgroundGlowFill(){var e,t,i;return(i=(t=this._backgroundGlowFill)!=null?t:(e=this._fallbackTheme)==null?void 0:e.backgroundGlowFill)!=null?i:"rgb(48,48,48)"}set backgroundGlowFill(e){this._backgroundGlowFill!==e&&(this._backgroundGlowFill=e,this.onThemeUpdated("backgroundGlowFill"))}get sliderMinLength(){var e,t,i;return(i=(t=this._sliderMinLength)!=null?t:(e=this._fallbackTheme)==null?void 0:e.sliderMinLength)!=null?i:100}set sliderMinLength(e){this._sliderMinLength!==e&&(this._sliderMinLength=e,this.onThemeUpdated("sliderMinLength"))}get sliderThickness(){var e,t,i;return(i=(t=this._sliderThickness)!=null?t:(e=this._fallbackTheme)==null?void 0:e.sliderThickness)!=null?i:10}set sliderThickness(e){this._sliderThickness!==e&&(this._sliderThickness=e,this.onThemeUpdated("sliderThickness"))}get bodyTextFont(){var e,t,i;return(i=(t=this._bodyTextFont)!=null?t:(e=this._fallbackTheme)==null?void 0:e.bodyTextFont)!=null?i:"1rem sans-serif"}set bodyTextFont(e){this._bodyTextFont!==e&&(this._bodyTextFont=e,this.onThemeUpdated("bodyTextFont"))}get bodyTextFill(){var e,t,i;return(i=(t=this._bodyTextFill)!=null?t:(e=this._fallbackTheme)==null?void 0:e.bodyTextFill)!=null?i:"white"}set bodyTextFill(e){this._bodyTextFill!==e&&(this._bodyTextFill=e,this.onThemeUpdated("bodyTextFill"))}get bodyTextHeight(){var e,t,i;return(i=(t=this._bodyTextHeight)!=null?t:(e=this._fallbackTheme)==null?void 0:e.bodyTextHeight)!=null?i:null}set bodyTextHeight(e){this._bodyTextHeight!==e&&(this._bodyTextHeight=e,this.onThemeUpdated("bodyTextHeight"))}get bodyTextSpacing(){var e,t,i;return(i=(t=this._bodyTextSpacing)!=null?t:(e=this._fallbackTheme)==null?void 0:e.bodyTextSpacing)!=null?i:null}set bodyTextSpacing(e){this._bodyTextSpacing!==e&&(this._bodyTextSpacing=e,this.onThemeUpdated("bodyTextSpacing"))}get bodyTextAlign(){var e,t,i;return(i=(t=this._bodyTextAlign)!=null?t:(e=this._fallbackTheme)==null?void 0:e.bodyTextAlign)!=null?i:me.Start}set bodyTextAlign(e){this._bodyTextAlign!==e&&(this._bodyTextAlign=e,this.onThemeUpdated("bodyTextAlign"))}get checkboxLength(){var e,t,i;return(i=(t=this._checkboxLength)!=null?t:(e=this._fallbackTheme)==null?void 0:e.checkboxLength)!=null?i:12}set checkboxLength(e){this._checkboxLength!==e&&(this._checkboxLength=e,this.onThemeUpdated("checkboxLength"))}get checkboxInnerPadding(){var e,t,i;return(i=(t=this._checkboxInnerPadding)!=null?t:(e=this._fallbackTheme)==null?void 0:e.checkboxInnerPadding)!=null?i:2}set checkboxInnerPadding(e){this._checkboxInnerPadding!==e&&(this._checkboxInnerPadding=e,this.onThemeUpdated("checkboxInnerPadding"))}get inputBackgroundFill(){var e,t,i;return(i=(t=this._inputBackgroundFill)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputBackgroundFill)!=null?i:"white"}set inputBackgroundFill(e){this._inputBackgroundFill!==e&&(this._inputBackgroundFill=e,this.onThemeUpdated("inputBackgroundFill"))}get inputSelectBackgroundFill(){var e,t,i;return(i=(t=this._inputSelectBackgroundFill)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputSelectBackgroundFill)!=null?i:"rgb(0,195,255)"}set inputSelectBackgroundFill(e){this._inputSelectBackgroundFill!==e&&(this._inputSelectBackgroundFill=e,this.onThemeUpdated("inputSelectBackgroundFill"))}get inputTextFont(){var e,t,i;return(i=(t=this._inputTextFont)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputTextFont)!=null?i:"1rem monospace"}set inputTextFont(e){this._inputTextFont!==e&&(this._inputTextFont=e,this.onThemeUpdated("inputTextFont"))}get inputTextFill(){var e,t,i;return(i=(t=this._inputTextFill)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputTextFill)!=null?i:"black"}set inputTextFill(e){this._inputTextFill!==e&&(this._inputTextFill=e,this.onThemeUpdated("inputTextFill"))}get inputTextFillDisabled(){var e,t,i;return(i=(t=this._inputTextFillDisabled)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputTextFillDisabled)!=null?i:"grey"}set inputTextFillDisabled(e){this._inputTextFillDisabled!==e&&(this._inputTextFillDisabled=e,this.onThemeUpdated("inputTextFillDisabled"))}get inputTextFillInvalid(){var e,t,i;return(i=(t=this._inputTextFillInvalid)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputTextFillInvalid)!=null?i:"red"}set inputTextFillInvalid(e){this._inputTextFillInvalid!==e&&(this._inputTextFillInvalid=e,this.onThemeUpdated("inputTextFillInvalid"))}get inputTextHeight(){var e,t,i;return(i=(t=this._inputTextHeight)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputTextHeight)!=null?i:null}set inputTextHeight(e){this._inputTextHeight!==e&&(this._inputTextHeight=e,this.onThemeUpdated("inputTextHeight"))}get inputTextSpacing(){var e,t,i;return(i=(t=this._inputTextSpacing)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputTextSpacing)!=null?i:null}set inputTextSpacing(e){this._inputTextSpacing!==e&&(this._inputTextSpacing=e,this.onThemeUpdated("inputTextSpacing"))}get inputTextInnerPadding(){var e,t,i;return(i=(t=this._inputTextInnerPadding)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputTextInnerPadding)!=null?i:2}set inputTextInnerPadding(e){this._inputTextInnerPadding!==e&&(this._inputTextInnerPadding=e,this.onThemeUpdated("inputTextInnerPadding"))}get inputTextMinWidth(){var e,t,i;return(i=(t=this._inputTextMinWidth)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputTextMinWidth)!=null?i:100}set inputTextMinWidth(e){this._inputTextMinWidth!==e&&(this._inputTextMinWidth=e,this.onThemeUpdated("inputTextMinWidth"))}get inputTextAlign(){var e,t,i;return(i=(t=this._inputTextAlign)!=null?t:(e=this._fallbackTheme)==null?void 0:e.inputTextAlign)!=null?i:me.Start}set inputTextAlign(e){this._inputTextAlign!==e&&(this._inputTextAlign=e,this.onThemeUpdated("inputTextAlign"))}get blinkRate(){var e,t,i;return(i=(t=this._blinkRate)!=null?t:(e=this._fallbackTheme)==null?void 0:e.blinkRate)!=null?i:.8}set blinkRate(e){this._blinkRate!==e&&(this._blinkRate=e,this.onThemeUpdated("blinkRate"))}get cursorThickness(){var e,t,i;return(i=(t=this._cursorThickness)!=null?t:(e=this._fallbackTheme)==null?void 0:e.cursorThickness)!=null?i:1}set cursorThickness(e){this._cursorThickness!==e&&(this._cursorThickness=e,this.onThemeUpdated("cursorThickness"))}get scrollBarThickness(){var e,t,i;return(i=(t=this._scrollBarThickness)!=null?t:(e=this._fallbackTheme)==null?void 0:e.scrollBarThickness)!=null?i:8}set scrollBarThickness(e){this._scrollBarThickness!==e&&(this._scrollBarThickness=e,this.onThemeUpdated("scrollBarThickness"))}get scrollBarMinPercent(){var e,t,i;return(i=(t=this._scrollBarMinPercent)!=null?t:(e=this._fallbackTheme)==null?void 0:e.scrollBarMinPercent)!=null?i:.1}set scrollBarMinPercent(e){this._scrollBarMinPercent!==e&&(this._scrollBarMinPercent=e,this.onThemeUpdated("scrollBarMinPercent"))}get scrollBarMinPixels(){var e,t,i;return(i=(t=this._scrollBarMinPixels)!=null?t:(e=this._fallbackTheme)==null?void 0:e.scrollBarMinPixels)!=null?i:20}set scrollBarMinPixels(e){this._scrollBarMinPixels!==e&&(this._scrollBarMinPixels=e,this.onThemeUpdated("scrollBarMinPixels"))}};l(D,"BaseTheme");var At=/[%a-zA-Z]+/,ht=/[0-9]+(\.[0-9]+)?(%|cap|ch|ex|vmin|vmax|Q|r?em|r?lh|i[cn]|[cm]m|p[xct]|v[hwib])/,w=class extends D{constructor(e,t,i){super(i);this._enabled=!0;this._dirty=!0;this._layoutDirty=!0;this.width=0;this.height=0;this.x=0;this.y=0;this._flex=0;this.root=null;this._cachedFont_bodyTextFont="";this._cachedLastFont_bodyTextFont="";this._cachedFont_inputTextFont="";this._cachedLastFont_inputTextFont="";this.needsClear=e,this.propagatesEvents=t}get flex(){return this._flex}set flex(e){e!==this._flex&&(this._flex=e,this._layoutDirty=!0)}set enabled(e){e!==this._enabled&&(this._enabled=e,this.forceDirty())}get enabled(){return this._enabled}set inheritedTheme(e){this.fallbackTheme=e}get inheritedTheme(){return this.fallbackTheme}onThemeUpdated(e=null){super.onThemeUpdated(e),this.needsClear&&(e===null||e==="canvasFill")&&(this._dirty=!0)}get dimensions(){return[this.width,this.height]}get position(){return[this.x,this.y]}get dirty(){return this._dirty&&!this.dimensionless}get layoutDirty(){return this._layoutDirty}get dimensionless(){return this.width==0||this.height==0}onFocusDropped(e,t){}handleEvent(e,t){return e.target===this?this:null}dispatchEvent(e,t){if(!this._enabled)return null;if(e.target===null){if(e instanceof k&&(e.x<this.x||e.y<this.y||e.x>=this.x+this.width||e.y>=this.y+this.height))return null}else if(e.target!==this&&!this.propagatesEvents)return null;return this.handleEvent(e,t)}handlePreLayoutUpdate(e){}preLayoutUpdate(e){this.root=e,this._enabled&&this.handlePreLayoutUpdate(e)}resolveDimensions(e,t,i,r){if(!this._enabled){this.width=0,this.height=0,this._layoutDirty=!1;return}if(e==1/0)throw new Error("minWidth must not be infinite");if(e>t&&(console.warn(`minWidth (${e}) must not be greater than maxWidth (${t}). Set minWidth to maxWidth. This may be caused by floating pointer precision errors`),e=t),e<0&&(console.warn(`minWidth (${e}) must not be lesser than 0. Set minWidth to 0. This may be caused by floating pointer precision errors`),e=0),i==1/0)throw new Error("minHeight must not be infinite");i>r&&(console.warn(`minHeight (${i}) must not be greater than maxHeight (${r}). Set minHeight to maxHeight. This may be caused by floating pointer precision errors`),i=r),i<0&&(console.warn(`minHeight (${i}) must not be lesser than 0. Set minHeight to 0. This may be caused by floating pointer precision errors`),i=0);let n=this.width,s=this.height;if(this.handleResolveDimensions(e,t,i,r),this.width<e?(this.width=e,console.error("Horizontal underflow in widget")):this.width>t&&(this.width=t,console.error("Horizontal overflow in widget")),this.width<0||!isFinite(this.width)||isNaN(this.width))throw new Error(`Disallowed width (${this.width}) in widget`);if(this.height<i?(this.height=i,console.error("Vertical underflow in widget")):this.height>r&&(this.height=r,console.error("Vertical overflow in widget")),this.height<0||!isFinite(this.height)||isNaN(this.height))throw new Error(`Disallowed height (${this.height}) in widget`);this._layoutDirty=!1,(n!==this.width||s!==this.height)&&(this._dirty=!0)}resolveDimensionsAsTop(e,t,i,r){this.resolveDimensions(e,t,i,r),(t===1/0||r===1/0)&&this.resolveDimensions(e,t===1/0?this.width:t,i,r===1/0?this.height:r)}afterPositionResolved(){}resolvePosition(e,t){(e!==this.x||t!==this.y)&&(this._dirty=!0),this.x=e,this.y=t,this.afterPositionResolved()}handlePostLayoutUpdate(e){}postLayoutUpdate(e){this._enabled&&this.handlePostLayoutUpdate(e)}clear(e,t,i,r,n,s=null){n.save(),n.globalCompositeOperation="copy",n.fillStyle=s!=null?s:this.canvasFill,n.beginPath(),n.rect(...this.roundRect(e,t,i,r,!0)),n.clip(),n.fill(),n.restore()}clearStart(e,t=null){e.save(),e.globalCompositeOperation="copy",e.fillStyle=t!=null?t:this.canvasFill,e.beginPath()}clearEnd(e,t="nonzero"){e.clip(t),e.fill(),e.restore()}roundRect(e,t,i,r,n=!1){let s=n?Math.ceil:Math.floor,o=n?Math.floor:Math.ceil;return e=s(e),t=s(t),[e,t,o(e+i)-e,o(t+r)-t]}handlePainting(e,t){}paint(e,t=!1){if(this.dimensionless)return this.dryPaint();!this._dirty&&!t||(this._enabled&&(this.needsClear&&this.clear(this.x,this.y,this.width,this.height,e),e.save(),this.handlePainting(e,t),e.restore()),this._dirty=!1)}dryPaint(){this._dirty=!1}forceThemeUpdate(){this.onThemeUpdated()}forceDirty(){this._dirty=!0,this._layoutDirty=!0}scaleFont(e,t){let i=e.search(ht),r,n,s=0;if(i==-1)(i=e.search("xx-small"))!==-1?(n=.5625*t,s=8):(i=e.search("x-small"))!==-1?(n=.625*t,s=7):(i=e.search("small"))!==-1?(n=.8333*t,s=5):(i=e.search("medium"))!==-1?(n=t,s=6):(i=e.search("large"))!==-1?(n=1.125*t,s=5):(i=e.search("x-large"))!==-1?(n=1.5*t,s=7):(i=e.search("xx-large"))!==-1?(n=2*t,s=8):(i=e.search("smaller"))!==-1?(n=.8333*t,s=7):(i=e.search("larger"))!==-1?(n=1.125*t,s=6):n=t,r="rem";else{let o=e.match(ht);if(o===null)throw new Error("Unexpected null font-size match");let h=o[0];s=h.length;let d=h.match(At);if(d===null)throw new Error("Unexpected null font-size suffix match");r=d[0],n=parseFloat(h)*t}return e.substring(0,i)+n.toString()+r+e.substring(i+s,e.length)}get containerPadding(){var i,r;let e=super.containerPadding,t=(r=(i=this.root)==null?void 0:i.resolution)!=null?r:1;return{left:e.left*t,right:e.right*t,top:e.top*t,bottom:e.bottom*t}}set containerPadding(e){super.containerPadding=e}get multiContainerSpacing(){var e,t;return super.multiContainerSpacing*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}set multiContainerSpacing(e){super.multiContainerSpacing=e}get sliderMinLength(){var e,t;return super.sliderMinLength*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}set sliderMinLength(e){super.sliderMinLength=e}get sliderThickness(){var e,t;return super.sliderThickness*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}set sliderThickness(e){super.sliderThickness=e}get bodyTextFont(){var t,i;let e=super.bodyTextFont;return e!==this._cachedLastFont_bodyTextFont&&(this._cachedLastFont_bodyTextFont=e,this._cachedFont_bodyTextFont=this.scaleFont(e,(i=(t=this.root)==null?void 0:t.resolution)!=null?i:1)),this._cachedFont_bodyTextFont}set bodyTextFont(e){super.bodyTextFont=e}get bodyTextHeight(){var t,i;let e=super.bodyTextHeight;return e===null?e:e*((i=(t=this.root)==null?void 0:t.resolution)!=null?i:1)}set bodyTextHeight(e){super.bodyTextHeight=e}get bodyTextSpacing(){var t,i;let e=super.bodyTextSpacing;return e===null?e:e*((i=(t=this.root)==null?void 0:t.resolution)!=null?i:1)}set bodyTextSpacing(e){super.bodyTextSpacing=e}get checkboxLength(){var e,t;return super.checkboxLength*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}set checkboxLength(e){super.checkboxLength=e}get checkboxInnerPadding(){var e,t;return super.checkboxInnerPadding*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}set checkboxInnerPadding(e){super.checkboxInnerPadding=e}get inputTextFont(){var t,i;let e=super.inputTextFont;return e!==this._cachedLastFont_inputTextFont&&(this._cachedLastFont_inputTextFont=e,this._cachedFont_inputTextFont=this.scaleFont(e,(i=(t=this.root)==null?void 0:t.resolution)!=null?i:1)),this._cachedFont_inputTextFont}set inputTextFont(e){super.inputTextFont=e}get inputTextHeight(){var t,i;let e=super.inputTextHeight;return e===null?e:e*((i=(t=this.root)==null?void 0:t.resolution)!=null?i:1)}set inputTextHeight(e){super.inputTextHeight=e}get inputTextSpacing(){var t,i;let e=super.inputTextSpacing;return e===null?e:e*((i=(t=this.root)==null?void 0:t.resolution)!=null?i:1)}set inputTextSpacing(e){super.inputTextSpacing=e}get inputTextInnerPadding(){var e,t;return super.inputTextInnerPadding*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}set inputTextInnerPadding(e){super.inputTextInnerPadding=e}get inputTextMinWidth(){var e,t;return super.inputTextMinWidth*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}set inputTextMinWidth(e){super.inputTextMinWidth=e}get cursorThickness(){var e,t;return super.cursorThickness*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}set cursorThickness(e){super.cursorThickness=e}get scrollBarThickness(){var e,t;return super.scrollBarThickness*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}set scrollBarThickness(e){super.scrollBarThickness=e}get scrollBarMinPixels(){var e,t;return super.scrollBarMinPixels*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}set scrollBarMinPixels(e){super.scrollBarMinPixels=e}};l(w,"Widget");var pe=class extends w{constructor(e,t,i,r){super(t,i,r);this._children=[...e],this.forceDirty()}set inheritedTheme(e){super.inheritedTheme=e;for(let t of this.children)t.inheritedTheme=e}get inheritedTheme(){return super.inheritedTheme}dryPaint(){super.dryPaint();for(let e of this.children)e.dryPaint()}forceDirty(){super.forceDirty();for(let e of this.children)e.forceDirty()}get childCount(){return this._children.length}get children(){return this._children.values()}};l(pe,"Parent");var He=class extends pe{add(e){if(Array.isArray(e))for(let t of e)this._children.push(t),t.inheritedTheme=this.inheritedTheme;else this._children.push(e),e.inheritedTheme=this.inheritedTheme;return this.forceDirty(),this}remove(e){if(Array.isArray(e))for(let t of e){let i=this._children.indexOf(t);i!==-1&&this._children.splice(i,1)}else{let t=this._children.indexOf(e);t!==-1&&this._children.splice(t,1)}return this.forceDirty(),this}clearChildren(){return this._children.length=0,this.forceDirty(),this}};l(He,"MultiParent");var q=class extends He{constructor(e,t){super([],!1,!0,t);this.backgroundDirty=!0;this.unusedSpace=0;this.enabledChildCount=0;this.vertical=e}onThemeUpdated(e=null){super.onThemeUpdated(e),e===null?(this._layoutDirty=!0,this.backgroundDirty=!0):e==="canvasFill"?this.backgroundDirty=!0:e==="multiContainerAlignment"?this._layoutDirty=!0:e==="multiContainerSpacing"&&(this._layoutDirty=!0)}handleEvent(e,t){for(let i of this.children){if(!i.enabled)continue;let r=i.dispatchEvent(e,t);if(r!==null)return r}return null}handlePreLayoutUpdate(e){for(let t of this.children)t.preLayoutUpdate(e),t.layoutDirty&&(this._layoutDirty=!0)}handlePostLayoutUpdate(e){for(let t of this.children)t.postLayoutUpdate(e),t.dirty&&(this._dirty=!0)}handleResolveDimensions(e,t,i,r){let n=0,s=0,o=0,h=this.vertical?r:t;this.multiContainerAlignment.cross===x.Stretch&&(o=this.vertical?t:r,o==1/0&&(o=this.vertical?e:i)),this.enabledChildCount=0;for(let y of this.children){if(!y.enabled){y.resolveDimensions(0,0,0,0);continue}this.enabledChildCount++;let[E,L]=y.dimensions;this.vertical?y.resolveDimensions(o,t,0,1/0):y.resolveDimensions(0,1/0,o,r);let[K,X]=y.dimensions;n+=y.flex,s=Math.max(this.vertical?K:X,s),(K!==E||X!==L)&&(this.backgroundDirty=!0)}let u=this.vertical?e:i;s<u&&(s=u);let c=this.multiContainerSpacing,p=Math.max(this.enabledChildCount-1,0)*c;for(let y of this.children)!y.enabled||(p+=this.vertical?y.dimensions[1]:y.dimensions[0]);let m=h-p;if(m==1/0||m<=0){let y=this.width,E=this.height;this.vertical?(this.width=s,this.height=Math.min(p,r)):(this.width=Math.min(p,t),this.height=s),(this.width!==y||this.height!==E)&&(this.backgroundDirty=!0),this.unusedSpace=0;let L=h;for(let K of this.children){if(!K.enabled)continue;let[X,de]=K.dimensions;if(this.vertical){let Se=Math.min(L,de);K.resolveDimensions(o,t,Se,Se)}else{let Se=Math.min(L,X);K.resolveDimensions(Se,Se,o,r)}let[se,Wt]=K.dimensions;(se!==X||Wt!==de)&&(this.backgroundDirty=!0);let Rt=this.vertical?de:X;L=Math.max(0,L-Rt-c)}return}let g=0,b=0;n>0&&(b=m/n);for(let y of this.children){if(!y.enabled)continue;g!==0&&(g+=c);let E=b*y.flex,[L,K]=y.dimensions;if(this.vertical){let se=E+K;y.resolveDimensions(o,t,se,se)}else{let se=E+L;y.resolveDimensions(se,se,o,r)}let[X,de]=y.dimensions;g+=this.vertical?de:X,(X!==L||de!==K)&&(this.backgroundDirty=!0)}let P=this.width,F=this.height,_;this.vertical?(_=r,this.width=s,this.height=_):(_=t,this.width=_,this.height=s),(this.width!==P||this.height!==F)&&(this.backgroundDirty=!0),this.unusedSpace=Math.max(_-g,0)}afterPositionResolved(){let e=this.multiContainerAlignment,t=e.main===Q.SpaceAround,i=e.main===Q.SpaceBetween||t,r=i?0:e.main,n=e.cross===x.Stretch?0:e.cross,s=this.enabledChildCount-1+(t?2:0),o;s<=0?o=0:o=this.unusedSpace/s;let h=this.multiContainerSpacing;i&&(h+=o);let d=(this.vertical?this.y:this.x)+r*this.unusedSpace;t&&(d+=o);for(let u of this.children){if(!u.enabled)continue;let[c,p]=u.position,[m,g]=u.dimensions;this.vertical?(u.resolvePosition(this.x+n*(this.width-m),d),d+=g+h):(u.resolvePosition(d,this.y+n*(this.height-g)),d+=m+h);let[b,P]=u.position;(b!==c||P!==p)&&(this.backgroundDirty=!0)}}handlePainting(e,t){let i=[];for(let r of this.children)r.paint(e,t),r.enabled&&(this.backgroundDirty||t)&&i.push(this.roundRect(...r.position,...r.dimensions,!0));if(this.backgroundDirty||t){this.clearStart(e),e.rect(...this.roundRect(this.x,this.y,this.width,this.height,!0));for(let r of i)e.rect(...r);this.clearEnd(e,"evenodd")}this.backgroundDirty=!1}dryPaint(){this.backgroundDirty=!1,super.dryPaint()}forceDirty(){super.forceDirty(),this.backgroundDirty=!0}};l(q,"MultiContainer");var Z=class extends pe{constructor(e,t,i,r){super([e],t,i,r)}get child(){return this._children[0]}};l(Z,"SingleParent");var J=class extends Z{constructor(e,t,i){super(e,!1,t,i);this.backgroundDirty=!0}onThemeUpdated(e=null){super.onThemeUpdated(e),e===null?(this._layoutDirty=!0,this.backgroundDirty=!0):e==="canvasFill"?this.backgroundDirty=!0:e==="containerPadding"?this._layoutDirty=!0:e==="containerAlignment"&&(this._layoutDirty=!0)}handleEvent(e,t){return this.child.dispatchEvent(e,t)}handlePreLayoutUpdate(e){let t=this.child;t.preLayoutUpdate(e),t.layoutDirty&&(this._layoutDirty=!0)}handlePostLayoutUpdate(e){let t=this.child;t.postLayoutUpdate(e),t.dirty&&(this._dirty=!0),this.backgroundDirty&&(this._dirty=!0)}handleResolveDimensions(e,t,i,r){let n=this.containerPadding,s=n.left+n.right,o=n.top+n.bottom,h=t-s,d=r-o;h<0&&(h=0),d<0&&(d=0);let u=this.containerAlignment,c=0;u.horizontal===x.Stretch&&(h!==1/0?c=h:c=Math.max(e-s,0));let p=0;u.vertical===x.Stretch&&(d!==1/0?p=d:p=Math.max(i-o,0));let[m,g]=this.child.dimensions;this.child.resolveDimensions(c,h,p,d);let[b,P]=this.child.dimensions,[F,_]=[this.width,this.height];this.width=Math.max(e,b+s),this.height=Math.max(i,P+o),(this.width!==F||this.height!==_||b!==m||P!==g)&&(this.backgroundDirty=!0)}afterPositionResolved(){let e=this.containerPadding,t=this.containerAlignment,[i,r]=this.child.dimensions,n=i+e.left+e.right,s=r+e.top+e.bottom,o=this.x+e.left;if(t.horizontal!==x.Stretch){let c=this.width-n;c>0&&(o+=c*t.horizontal)}let h=this.y+e.top;if(t.vertical!==x.Stretch){let c=this.height-s;c>0&&(h+=c*t.vertical)}let[d,u]=this.child.position;this.child.resolvePosition(o,h),(d!==o||u!==h)&&(this.backgroundDirty=!0)}handleBaseContainerPainting(e,t,i=null){(this.backgroundDirty||t)&&(this.clearStart(e,i),e.rect(...this.roundRect(this.x,this.y,this.width,this.height,!0)),e.rect(...this.roundRect(...this.child.position,...this.child.dimensions,!0)),this.clearEnd(e,"evenodd"),this.backgroundDirty=!1),this.child.paint(e,t)}handlePainting(e,t){this.handleBaseContainerPainting(e,t)}dryPaint(){this.backgroundDirty=!1,super.dryPaint()}forceDirty(){super.forceDirty(),this.backgroundDirty=!0}};l(J,"BaseContainer");var V=new Map;function fe(a){let e=V.get(a);return e===void 0?(console.warn(`Unknown debug feature "${a}"; defaulting to not enabled`),!1):e[0]}l(fe,"isDebugFeatureEnabled");function Kt(a,e){let t=V.get(a);if(t===void 0){console.warn(`Unknown debug feature "${a}"; ignored`);return}let[i,r]=t;e===void 0&&(e=!i),i!==e&&(t[0]=e,console.info(`[canvas-ui] ${e?"En":"Dis"}abled "${a}" debug feature`))}l(Kt,"toggleDebugFeature");function It(){for(let[a,e]of V)console.info(`[canvas-ui] "${a}" (${e[0]?"en":"dis"}abled): ${e[1]}`)}l(It,"listDebugFeatures");function Ve(a,e){let t=`${a.name}.${e}`,i=`watchflag.${t}`;if(V.has(i)){console.warn(`[canvas-ui] Already injected debug feature with name ${i}; ignored`);return}let r=`watchflag.${t}.strace`;if(V.has(r)){console.warn(`[canvas-ui] Already injected debug feature with name ${r}; ignored`);return}let n=new WeakMap;Object.defineProperty(a.prototype,e,{get(){return n.get(this)},set(s){if(fe(i)&&!n.get(this)&&s){let h=`[canvas-ui ${i}] ${this.constructor.name}.${e} set to true`;fe(r)?(console.groupCollapsed(h),console.trace(),console.groupEnd()):console.debug(h)}n.set(this,s)}}),V.set(i,[!1,`Show when ${t} is set to true`]),V.set(r,[!1,`Print stack trace when ${i} shows that a flag has been set`])}l(Ve,"injectWatchflagFeature");function Ae(a,e,t=null){let i=`${a.name}.${e}`,r=`trace.${i}`;if(V.has(r)){console.warn(`[canvas-ui] Already injected debug feature with name ${r}; ignored`);return}let n=[],s=new Map,o=a.prototype[e],h=0;function d(){h===0&&(fe(r)&&console.debug(`[canvas-ui ${r}] Trace:
  ${n.join(`
  `)}`),h=0,n.length=0,s.clear())}l(d,"logMsgStack"),a.prototype[e]=function(...u){h++;let c=s.get(this);if(c===void 0){c=n.length,s.set(this,c);let m;h>1?m="  ".repeat(h-2)+"> ":m="",n.push(`${m}${this.constructor.name}`)}else n[c]+=", recall";t!==null&&(n[c]+=t.apply(this,u));let p=new Date().getTime();try{let m=o.apply(this,u);return n[c]+=` <${new Date().getTime()-p} ms>`,m}catch(m){throw n[c]+=" <exception thrown>",m}finally{h--,d()}},V.set(r,[!1,`Trace ${i} method calls`])}l(Ae,"injectTraceFeature");function I(a,e){let t=`${a.name}.${e}`,i=`randomfill.${t}`;if(V.has(i)){console.warn(`[canvas-ui] Already injected debug feature with name ${i}; ignored`);return}let r=Object.getOwnPropertyDescriptor(a.prototype,e);Object.defineProperty(a.prototype,e,{get(){if(fe(i))return"#"+Math.floor(Math.random()*16777215).toString(16);if((r==null?void 0:r.get)!==void 0)return r.get.apply(this)},set(n){(r==null?void 0:r.set)!==void 0&&r.set.apply(this,[n])}}),V.set(i,[!1,`Show when ${t} is set to true`])}l(I,"injectRandomFillFeature");var dt=!1;function Vi(){if(dt){console.warn("[canvas-ui] Already injected debug code; ignored");return}dt=!0,Ae(w,"paint",(i,r)=>r?" (forced)":""),Ae(w,"resolveDimensions",(i,r,n,s)=>` (${i}, ${r}, ${n}, ${s})`),Ae(w,"resolvePosition",(i,r)=>` (${i}, ${r})`),Ae(w,"dispatchEvent",(i,r)=>` (${i.constructor.name})`),Ve(w,"_dirty"),Ve(w,"_layoutDirty"),Ve(J,"backgroundDirty"),Ve(q,"backgroundDirty"),I(D,"canvasFill"),I(D,"primaryFill"),I(D,"accentFill"),I(D,"backgroundFill"),I(D,"backgroundGlowFill"),I(D,"bodyTextFill"),I(D,"inputBackgroundFill"),I(D,"inputSelectBackgroundFill"),I(D,"inputTextFill"),I(D,"inputTextFillDisabled"),I(D,"inputTextFillInvalid"),V.set("textrendergroups",[!1,"Draw text render groups in a TextHelper with alternating background colours (green and red). Width overriding groups have a blue background and zero-width groups have a black background. Throws an exception on negative width groups"]);let a=new Map,e=C.prototype.paint;C.prototype.paint=function(i,r,n,s){a.set(this,!1),e.apply(this,[i,r,n,s])};let t=C.prototype.paintGroup;C.prototype.paintGroup=function(i,r,n,s,o){if(fe("textrendergroups")){let h=i.fillStyle,d=this.actualLineHeight,u=this.fullLineHeight;if(!r[3]&&r[2]>n){let c=a.get(this);i.fillStyle=c?"rgba(255, 0, 0, 0.5)":"rgba(0, 255, 0, 0.5)",i.fillRect(s,o-d,r[2]-n,u),a.set(this,!c),i.fillStyle=h}else{let c=r[2]-n;if(i.fillStyle=c>0?"rgba(0, 0, 255, 0.5)":"rgba(0, 0, 0, 0.5)",c==0)c=4;else if(c<0)throw new Error("Unexpected group with negative width");i.fillRect(s,o-d,c,u)}}t.apply(this,[i,r,n,s,o])},window.canvasDebug={enabled:fe,toggle:Kt,list:It},console.info("[canvas-ui] Injected debug code; the library will be slower"),console.info("[canvas-ui] Check if a debug feature is enabled in the console with canvasDebug.enabled(debugFeature: string)"),console.info("[canvas-ui] Enable a debug feature in the console with canvasDebug.toggle(debugFeature: string, enabled?: boolean)"),console.info("[canvas-ui] List debug features in the console with canvasDebug.list()")}l(Vi,"injectDebugCode");function Ki(a){return new Promise((e,t)=>{function i(){document.body.removeChild(h),document.body.removeChild(o)}l(i,"closePopup");function r(){i(),e(a)}l(r,"cancelHandler");function n(){i(),e(u.value)}l(n,"okHandler");function s(g){g.key=="Enter"&&(g.preventDefault(),n())}l(s,"enterChecker");let o=document.createElement("div");o.id="textInputHandlerOverlay";let h=document.createElement("div");h.id="textInputHandler";let d=document.createElement("p");d.textContent="Change text:";let u=document.createElement("input");u.addEventListener("keyup",s),u.value=a;let c=document.createElement("div"),p=document.createElement("button");p.addEventListener("click",r),p.textContent="Cancel";let m=document.createElement("button");m.addEventListener("click",n),m.textContent="OK",c.appendChild(p),c.appendChild(m),h.appendChild(d),h.appendChild(u),h.appendChild(c),document.body.appendChild(o),document.body.appendChild(h),u.focus({preventScroll:!1})})}l(Ki,"DefaultTextInputHandler");var f;(function(t){t[t.Pointer=0]="Pointer",t[t.Keyboard=1]="Keyboard"})(f||(f={}));var ee=class extends j{constructor(e,t=null){super(t,f.Keyboard,!1);this.text=e}cloneWithTarget(e){return new ee(this.text,e)}};l(ee,"TextPasteEvent");var R=class extends D{constructor(e,t){super(e,t);this.subscribers=new Set}get fallbackTheme(){return super.fallbackTheme}set fallbackTheme(e){super.fallbackTheme=e}onThemeUpdated(e=null){for(let t of this.subscribers)t(e)}subscribe(e){this.subscribers.add(e)}unsubscribe(e){this.subscribers.delete(e)}};l(R,"Theme");var W=class extends j{constructor(e=null){super(e,f.Pointer,!0)}cloneWithTarget(e){return new W(e)}};l(W,"Leave");function qe(a,e=!0){return Math.pow(2,(e?Math.ceil:Math.floor)(Math.log2(a)))}l(qe,"roundToPower2");var oe=class{constructor(e=64,t=64){this.constraints=[0,1/0,0,1/0];this._dirty=!0;this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t;let i=this.canvas.getContext("2d",{alpha:!0});if(i===null)throw new Error("Failed to get canvas context");this.context=i}get canvasDimensions(){return[this.canvas.width,this.canvas.height]}resolveChildsLayout(e){if(!e.layoutDirty&&!this._dirty)return!1;this._dirty=!1;let[t,i]=e.dimensions,[r,n,s,o]=this.constraints;e.resolveDimensionsAsTop(r,n,s,o),e.resolvePosition(0,0);let[h,d]=e.dimensions;if(h!==t||d!==i){let u=Math.max(qe(h),this.canvas.width),c=Math.max(qe(d),this.canvas.height);if(u!==this.canvas.width||c!==this.canvas.height){let p=null;if(t!==0&&i!==0){p=document.createElement("canvas"),p.width=t,p.height=i;let m=p.getContext("2d");if(m===null)throw new Error("Failed to get context of temporary canvas for resizing original canvas");m.globalCompositeOperation="copy",m.drawImage(this.canvas,0,0,h,d,0,0,h,d)}this.canvas.width=u,this.canvas.height=c,p!==null&&(this.context.globalCompositeOperation="copy",this.context.drawImage(p,0,0,p.width,p.height,0,0,p.width,p.height),this.context.globalCompositeOperation="source-over")}return!0}else return!1}paintToCanvas(e,t){let i=e.dirty;return e.paint(this.context,t),i}};l(oe,"Viewport"),v([Me()],oe.prototype,"constraints",2);var ge=class{constructor(e,t=null,i=new R){this.drivers=new Set;this._enabled=!0;this.pointerStyle="default";this._currentPointerStyle="default";this._foci=new Map([[f.Keyboard,null],[f.Pointer,null]]);this._fociCapturers=new Map([[f.Keyboard,null],[f.Pointer,null]]);this.textInputHandler=null;this._mobileTextInUse=!1;this._resolution=1;this.viewport=new oe,this.child=e,this.pointerStyleHandler=t,this.child.inheritedTheme=i}get constraints(){return this.viewport.constraints}set constraints(e){this.viewport.constraints=e}get canvasDimensions(){return this.viewport.canvasDimensions}get dimensions(){return this.child.dimensions}get enabled(){return this._enabled}set enabled(e){if(this._enabled!==e)if(this._enabled=e,e)for(let i of this.drivers)i.onEnable(this);else{for(let i of this.drivers)i.onDisable(this);this.updatePointerStyle("default");for(let i of this._foci.keys())this.clearFocus(i)}}get canvas(){return this.viewport.canvas}resolveLayout(){return this.enabled?this.viewport.resolveChildsLayout(this.child):!1}paint(){return this.enabled?this.viewport.paintToCanvas(this.child,!1):!1}dispatchEvent(e){var r;if(!this.enabled)return!1;if(e.focusType!==null&&e.target===null){let n=this._foci.get(e.focusType);if(typeof n=="undefined"&&(n=null),e.needsFocus&&n===null)return!1;e=e.cloneWithTarget(n)}this.pointerStyle="default";let t=this.child.dispatchEvent(e,this);if(t===null&&e.focusType!==null&&this.clearFocus(e.focusType),e.focusType===null)return t!==null;let i=(r=this._fociCapturers.get(e.focusType))!=null?r:null;if(i===t)return t!==null;e.focusType===f.Pointer&&i!==null&&this.child.dispatchEvent(new W(i),this),this._fociCapturers.set(e.focusType,t);for(let n of this.drivers)n.onFocusCapturerChanged(this,e.focusType,i,t);return t!==null}preLayoutUpdate(){if(!!this.enabled){for(let e of this.drivers)e.update(this);this.child.preLayoutUpdate(this)}}postLayoutUpdate(){!this.enabled||(this.child.postLayoutUpdate(this),this.updatePointerStyle())}updatePointerStyle(e=null){e!==null&&(this.pointerStyle=e),this.pointerStyle!==this._currentPointerStyle&&(this._currentPointerStyle=this.pointerStyle,this.pointerStyleHandler!==null&&this.pointerStyleHandler(this._currentPointerStyle))}requestFocus(e,t){if(t!==null){let i=this._foci.get(e);if(t!==i){this.clearFocus(e),this._foci.set(e,t);for(let r of this.drivers)r.onFocusChanged(this,e,t)}}}dropFocus(e,t){let i=this._foci.get(e);t===i&&this.clearFocus(e)}clearFocus(e){let t=this._foci.get(e);if(t!==null&&typeof t!="undefined"){t.onFocusDropped(e,this),this._foci.set(e,null);for(let i of this.drivers)i.onFocusChanged(this,e,null)}}getFocus(e){var t;return(t=this._foci.get(e))!=null?t:null}getFocusCapturer(e){var t;return(t=this._fociCapturers.get(e))!=null?t:null}registerDriver(e){this.drivers.has(e)||(this.drivers.add(e),this._enabled&&e.onEnable&&e.onEnable(this))}unregisterDriver(e){!this.drivers.delete(e)||this._enabled&&e.onDisable&&e.onDisable(this)}clearDrivers(){for(let e of this.drivers)this.unregisterDriver(e)}get hasMobileTextInput(){return this.textInputHandler!==null&&!this._mobileTextInUse}get usingMobileTextInput(){return this._mobileTextInUse}getTextInput(e=""){return it(this,null,function*(){if(this.textInputHandler!==null&&!this._mobileTextInUse){this._mobileTextInUse=!0;let t=yield this.textInputHandler(e);return this._mobileTextInUse=!1,t}return null})}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.child.forceThemeUpdate())}};l(ge,"Root");var Ke=class extends ge{constructor(e,t=new R){super(e,null,t);this.domElem=document.createElement("canvas"),this.domElem.tabIndex=1,[this.domElem.width,this.domElem.height]=this.dimensions;let i=this.domElem.getContext("2d",{alpha:!0});if(i===null)throw new Error("Failed to get DOM canvas context");this.domCanvasContext=i,this.pointerStyleHandler=r=>{this.domElem.style.cursor=r},this.domElem.addEventListener("paste",r=>{r.preventDefault(),r.clipboardData!==null&&this.dispatchEvent(new ee(r.clipboardData.getData("text")))}),this.domElem.contentEditable="true",this.domElem.style.outline="0px solid transparent",this.domElem.style.cursor="default"}update(){if(this.enabled)this.domElem.style.removeProperty("display");else{this.domElem.style.display="none";return}this.preLayoutUpdate(),this.resolveLayout()&&([this.domElem.width,this.domElem.height]=this.dimensions,this.autoScale()),this.postLayoutUpdate(),this.paint()&&(this.domCanvasContext.globalCompositeOperation="copy",this.domCanvasContext.drawImage(this.canvas,0,0))}get resolution(){return super.resolution}set resolution(e){super.resolution=e,this.autoScale()}autoScale(){this.domElem.style.width=(this.domElem.width/this.resolution).toString()+"px",this.domElem.style.height=(this.domElem.height/this.resolution).toString()+"px"}};l(Ke,"DOMRoot");var be=class extends Z{constructor(e,t){super(e,!1,!0,t)}handleEvent(e,t){return this.child.dispatchEvent(e,t)}handlePreLayoutUpdate(e){let t=this.child;t.preLayoutUpdate(e),t.layoutDirty&&(this._layoutDirty=!0)}handlePostLayoutUpdate(e){let t=this.child;t.postLayoutUpdate(e),t.dirty&&(this._dirty=!0)}handleResolveDimensions(e,t,i,r){let n=this.child;n.resolveDimensions(e,t,i,r),[this.width,this.height]=n.dimensions}afterPositionResolved(){this.child.resolvePosition(this.x,this.y)}handlePainting(e,t){this.child.paint(e,t)}};l(be,"PassthroughWidget");var le=class extends be{constructor(e,t=[0,1/0,0,1/0],i){super(e,i);this._constraints=[0,1/0,0,1/0];this.constraints=[0,1/0,0,1/0];this._constraints=[...t]}handleResolveDimensions(e,t,i,r){var u,c;let n=(c=(u=this.root)==null?void 0:u.resolution)!=null?c:1,s=Math.min(Math.max(this._constraints[0]*n,e),t),o=Math.min(Math.max(this._constraints[2]*n,i),r),h=Math.min(Math.max(this._constraints[1]*n,e),t),d=Math.min(Math.max(this._constraints[3]*n,i),r);s>h&&(s=h),o>d&&(o=d),super.handleResolveDimensions(s,h,o,d)}};l(le,"ArtificialConstraint"),v([lt()],le.prototype,"constraints",2);var ye=class extends k{constructor(e,t,i,r,n,s,o=null,h=null){super(e,t,r,n,s,o,h);this.button=i}get isLeft(){return this.button===0}get isPrimary(){return this.isLeft}get isRight(){return this.button===1}get isSecondary(){return this.isRight}get isMiddle(){return this.button===2}get isTertiary(){return this.isMiddle}};l(ye,"PointerButtonEvent");var A=class extends ye{constructor(e,t,i,r,n,s,o=null){super(e,t,i,r,n,s,o,f.Pointer)}correctOffset(e,t){return new A(this.x-e,this.y-t,this.button,this.shift,this.ctrl,this.alt,this.target)}cloneWithTarget(e){return new A(this.x,this.y,this.button,this.shift,this.ctrl,this.alt,e)}};l(A,"PointerRelease");var M=class extends ye{constructor(e,t,i,r,n,s,o=null){super(e,t,i,r,n,s,o)}correctOffset(e,t){return new M(this.x-e,this.y-t,this.button,this.shift,this.ctrl,this.alt,this.target)}cloneWithTarget(e){return new M(this.x,this.y,this.button,this.shift,this.ctrl,this.alt,e)}};l(M,"PointerPress");var T;(function(i){i[i.Released=0]="Released",i[i.Hover=1]="Hover",i[i.Hold=2]="Hold"})(T||(T={}));var B=class{constructor(e){this.lastClickState=0;this.clickState=0;this.clickStateChanged=!1;this.wasClick=!1;this.pointerPos=null;this.startingPointerPos=null;this.pointerButton=0;this.widget=e}getNormalInRect(e,t,i,r,n,s){return[(e-i)/(r-i),(t-n)/(s-n)]}isPointInRect(e,t,i,r,n,s){return e>=i&&e<r&&t>=n&&t<s}isNormalInRect(e,t){return e>=0&&e<1&&t>=0&&t<1}setClickState(e,t){this.clickState!==e?(this.lastClickState=this.clickState,this.clickState=e,this.wasClick=t&&this.lastClickState===2,this.clickStateChanged=!0):this.clickStateChanged=!1}handleClickEvent(e,t,i){if(e instanceof W)return t.dropFocus(f.Pointer,this.widget),this.pointerPos=null,this.setClickState(0,!1);if(e instanceof k){this.pointerPos=this.getNormalInRect(e.x,e.y,...i);let r=this.isNormalInRect(...this.pointerPos);if(r)t.pointerStyle="pointer";else if(e.target===null)return t.dropFocus(f.Pointer,this.widget),this.setClickState(0,!1);return e instanceof M&&e.button===this.pointerButton?(this.startingPointerPos=this.pointerPos,t.requestFocus(f.Pointer,this.widget),this.setClickState(2,r)):e instanceof A&&e.button===this.pointerButton?(t.dropFocus(f.Pointer,this.widget),r?this.setClickState(1,r):this.setClickState(0,r)):e.target===null?this.setClickState(1,r):this.setClickState(2,r)}else this.clickStateChanged=!1}};l(B,"ClickHelper");var S=class extends k{constructor(e,t,i,r,n,s,o,h,d=null){super(e,t,s,o,h,d,f.Pointer);this.deltaX=i,this.deltaY=r,this.fromDrag=n}correctOffset(e,t){return new S(this.x-e,this.y-t,this.deltaX,this.deltaY,this.fromDrag,this.shift,this.ctrl,this.alt,this.target)}cloneWithTarget(e){return new S(this.x,this.y,this.deltaX,this.deltaY,this.fromDrag,this.shift,this.ctrl,this.alt,e)}};l(S,"PointerWheel");var ve=class extends J{constructor(e,t=null,i){super(e,!1,i);this.clickHelper=new B(this),this.callback=t}handleEvent(e,t){if(e instanceof S)return null;if(this.callback===null)return this.clickHelper.clickStateChanged=!1,this;if(this.clickHelper.handleClickEvent(e,t,[this.x,this.x+this.width,this.y,this.y+this.height]),this.clickHelper.clickStateChanged&&this.clickHelper.wasClick)try{this.callback()}catch(i){console.error("Exception in Icon callback",i)}return this}};l(ve,"Button");var Ze=class extends ve{constructor(e,t=null,i){super(e,t,i);this.backgroundProperty="backgroundFill";this.forced=!1;this.childTheme=new R({canvasFill:this.getBackgroundFill()}),this.child.inheritedTheme=this.childTheme}updateBackground(){let e=this.backgroundProperty;if(this.forced)this.backgroundProperty="primaryFill";else switch(this.clickHelper.clickState){case T.Hold:this.backgroundProperty="accentFill";break;case T.Hover:this.backgroundProperty="backgroundGlowFill";break;default:this.backgroundProperty="backgroundFill";break}e!==this.backgroundProperty&&(this.backgroundDirty=!0,this.childTheme.canvasFill=this.getBackgroundFill())}getBackgroundFill(){switch(this.backgroundProperty){case"primaryFill":return this.primaryFill;case"accentFill":return this.accentFill;case"backgroundGlowFill":return this.backgroundGlowFill;case"backgroundFill":return this.backgroundFill;default:throw new Error(`Unknown theme property: ${this.backgroundProperty}`)}}set inheritedTheme(e){e!==this.fallbackTheme&&(this.fallbackTheme=e,this.childTheme.fallbackTheme=e)}get inheritedTheme(){return this.fallbackTheme}onThemeUpdated(e=null){e===null?(this._layoutDirty=!0,this.backgroundDirty=!0,this.childTheme.canvasFill=this.getBackgroundFill()):e===this.backgroundFill?(this.backgroundDirty=!0,this.childTheme.canvasFill=this.getBackgroundFill()):e==="containerPadding"?this._layoutDirty=!0:e==="containerAlignment"&&(this._layoutDirty=!0)}handleEvent(e,t){let i=super.handleEvent(e,t);return this.clickHelper.clickStateChanged&&this.updateBackground(),i}handlePainting(e,t){this.handleBaseContainerPainting(e,t,this.getBackgroundFill())}},We=Ze;l(We,"FilledButton"),v([Le(Ze.prototype.updateBackground)],We.prototype,"forced",2);var ae=class extends w{constructor(e,t){super(!0,!1,t);this.textGetter=null;this.wrapText=!0;this.textHelper=new C,this.textHelper.wrapMode=ce.Shrink,this.source=e}set source(e){e instanceof Function?this.textGetter=e:(this.textGetter=null,this.textHelper.text=e)}get source(){return this.textGetter!==null?this.textGetter:this.textHelper.text}get text(){return this.textHelper.text}onThemeUpdated(e=null){super.onThemeUpdated(e),e===null?(this._layoutDirty=!0,this._dirty=!0):e==="bodyTextFont"||e==="labelMinWidth"||e==="labelMinAscent"||e==="labelMinDescent"?(this._layoutDirty=!0,this._dirty=!0):e==="bodyTextFill"&&(this._dirty=!0)}handlePreLayoutUpdate(e){this.textGetter!==null&&(this.textHelper.text=this.textGetter()),this.textHelper.font=this.bodyTextFont,this.textHelper.lineHeight=this.bodyTextHeight,this.textHelper.lineSpacing=this.bodyTextSpacing,this.textHelper.alignMode=this.bodyTextAlign,this.textHelper.dirty&&(this._dirty=!0,this._layoutDirty=!0)}handleResolveDimensions(e,t,i,r){this.textHelper.maxWidth=this.wrapText?t:1/0,this.textHelper.dirty&&(this._dirty=!0),this.width=Math.max(Math.min(this.textHelper.width,t),e),this.height=Math.max(Math.min(this.textHelper.height,r),i)}handlePainting(e,t){this.wrapText||(e.save(),e.beginPath(),e.rect(this.x,this.y,this.width,this.height),e.clip()),this.textHelper.paint(e,this.bodyTextFill,this.x,this.y),this.wrapText||e.restore()}};l(ae,"Label"),v([O],ae.prototype,"wrapText",2);var xe=class extends We{constructor(e,t=null,i){let r=U({},i);r.containerAlignment={horizontal:x.Center,vertical:x.Stretch};let n=new ae(e,i);n.wrapText=!1;super(n,t,r)}};l(xe,"TextButton");var Ie=class extends le{constructor(e,t=null,i,r=0,n=24,s=24,o){t===null&&(t=e);function h(){return i.shift?t===null?e:t:e}l(h,"getGlyph");super(new xe(h,()=>i.callback(h()),o),[n,1/0,s,1/0],o);this.flex=r}};l(Ie,"GlyphVirtualKey");var Te=class extends q{constructor(e){super(!1,e)}};l(Te,"Row");var Be=class extends Te{constructor(e,t,i=0,r=24,n=24,s){super(s);for(let o of e)if(typeof o=="function"){let h=o;this.add(h(t,s))}else if(typeof o[0]=="string"&&typeof o[1]=="string"){let h=o[0],d=o[1];for(let u=0;u<h.length;u++){let c=null;u<d.length&&(c=d[u]),this.add(new Ie(h[u],c,t,i,r,n,s))}}else throw new Error(`Unknown virtual key row template format for entry: ${o}`)}};l(Be,"VirtualKeyRow");var G=class extends le{constructor(e,t,i=0,r=24,n=24,s){super(new xe(e,t,s),[r,1/0,n,1/0],s);this.flex=i}};l(G,"VirtualKey");var $=class extends G{constructor(e,t,i,r=0,n=24,s=24,o){super(e,()=>i.callback(t),r,n,s,o)}};l($,"BasicVirtualKey");var Ue=class extends ${constructor(e,t=0,i=60,r=24,n){super("Backspace","Backspace",e,t,i,r,n)}};l(Ue,"BackspaceKey");var Oe=class extends ${constructor(e,t=0,i=24,r=24,n){super("Esc","Escape",e,t,i,r,n)}};l(Oe,"EscapeKey");var Ge=class extends ${constructor(e,t=0,i=72,r=24,n){super("Enter","Enter",e,t,i,r,n)}};l(Ge,"EnterKey");var $e=class extends G{constructor(e,t=0,i=84,r=24,n){super("Shift",()=>{e.shift=!e.shift,this.child.forced=e.shift,e.callback("Shift")},t,i,r,n);this.child.forced=e.shift}};l($e,"ShiftKey");var Ne=class extends ${constructor(e,t=1,i=84,r=24,n){super("Space"," ",e,t,i,r,n)}};l(Ne,"SpaceKey");var Ye=class extends q{constructor(e){super(!0,e)}};l(Ye,"Column");function Bt(a,e){return new Ge(a,void 0,void 0,void 0,e)}l(Bt,"EnterKeyTemplate");function Ut(a,e){return new $e(a,void 0,void 0,void 0,e)}l(Ut,"ShiftKeyTemplate");function Ot(a,e){return new Ue(a,void 0,void 0,void 0,e)}l(Ot,"BackspaceKeyTemplate");function Gt(a,e){return new Ne(a,void 0,void 0,void 0,e)}l(Gt,"SpaceKeyTemplate");function $t(a,e){return new Oe(a,void 0,void 0,void 0,e)}l($t,"EscapeKeyTemplate");var Re=[[["`1234567890-=","~!@#$%^&*()_+"]],[["qwertyuiop[]\\","QWERTYUIOP{}|"]],[["asdfghjkl;'",'ASDFGHJKL:"'],Bt],[Ut,["zxcvbnm,./","ZXCVBNM<>?"]],[Ot,Gt,$t]],Pe=class extends Ye{constructor(e,t=Re,i=0,r=24,n=24,s){let o=U({},s);o.multiContainerAlignment={main:Q.SpaceBetween,cross:x.Stretch};super(o);let h={callback:d=>{e.keyPress(d,h.shift,h.ctrl,h.alt)},shift:!1,ctrl:!1,alt:!1};for(let d of t)this.add(new Be(d,h,i,r,n,o))}};l(Pe,"VirtualKeyboard");var te=class extends J{constructor(e,t){super(e,!0,t)}};l(te,"Container");var _e=class extends te{constructor(e,t){let i=U({},t);i.containerAlignment={horizontal:x.Center,vertical:x.Center};super(e,i)}};l(_e,"Margin");var ut=class extends Ke{constructor(e,t=Re,i=new R){super(new _e(new Pe(e,t)),i);this.keyboardDriver=e}update(){this.enabled=this.keyboardDriver.getFocusedRoot()!==null,super.update()}};l(ut,"DOMVirtualKeyboardRoot");var ct=class extends ge{constructor(e,t=Re,i=null,r=new R){super(new _e(new Pe(e,t)),i,r);this.keyboardDriver=e}updateVisibility(){this.enabled=this.keyboardDriver.getFocusedRoot()!==null}};l(ct,"VirtualKeyboardRoot");var we=class extends ue{constructor(e,t,i,r,n){super(t,i,r,n,f.Keyboard,!0);this.key=e}};l(we,"KeyEvent");var ke=class extends we{cloneWithTarget(e){return new ke(this.key,this.shift,this.ctrl,this.alt,e)}};l(ke,"KeyRelease");var ie=class extends we{cloneWithTarget(e){return new ie(this.key,this.shift,this.ctrl,this.alt,e)}};l(ie,"KeyPress");var Xe=class{constructor(){this.eventQueues=new Map;this.keysDown=new Set;this.focus=null}getEventQueue(e){if(e===null)return null;let t=this.eventQueues.get(e);return typeof t=="undefined"?null:t}changeFocusedRoot(e){this.focus!==null&&this.focus.clearFocus(f.Keyboard),this.focus=e,this.keysDown.clear()}getFocusedRoot(){return this.focus}clearFocus(){this.changeFocusedRoot(null)}keyDown(e,t,i,r){this.keysDown.add(e);let n=this.getEventQueue(this.focus);n!==null&&n.push(new ie(e,t,i,r,null))}keyUp(e,t,i,r){if(this.keysDown.delete(e)){let n=this.getEventQueue(this.focus);n!==null&&n.push(new ke(e,t,i,r,null))}}keyPress(e,t,i,r){let n=this.isKeyDown(e);this.keyDown(e,t,i,r),n||this.keyUp(e,t,i,r)}isKeyDown(e){return this.keysDown.has(e)}onEnable(e){this.eventQueues.has(e)||this.eventQueues.set(e,[])}onDisable(e){this.eventQueues.has(e)&&(this.eventQueues.delete(e),e===this.focus&&this.clearFocus())}update(e){let t=this.getEventQueue(e);if(t!==null){for(let i of t)e.dispatchEvent(i);t.length=0}}onFocusChanged(e,t,i){t===f.Keyboard&&(e==this.focus?i===null&&this.clearFocus():i!==null&&this.changeFocusedRoot(e))}onFocusCapturerChanged(e,t,i,r){}};l(Xe,"KeyboardDriver");var Nt=new Set(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","End","Home","PageDown","PageUp","Tab"," "]),Yt=new Set(["a","A"]);function mt(a){return[a.key,a.shiftKey,a.ctrlKey,a.altKey]}l(mt,"unpackKeyboardEvent");var pt=class extends Xe{constructor(){super(...arguments);this.domElems=new Set}bindDOMElem(e,t=!0){this.domElems.has(e)||(this.domElems.add(e),t&&(e.addEventListener("keydown",i=>{var r,n;(Nt.has(i.key)||Yt.has(i.key)&&i.ctrlKey)&&((n=(r=this.getFocusedRoot())==null?void 0:r.getFocus(f.Keyboard))!=null?n:null)!==null&&i.preventDefault(),this.keyDown(...mt(i))}),e.addEventListener("keyup",i=>{this.keyUp(...mt(i))})),e.addEventListener("blur",i=>{this.shouldClearFocus(i.relatedTarget)&&this.clearFocus()}))}shouldClearFocus(e){return e===null||!this.domElems.has(e)}};l(pt,"DOMKeyboardDriver");function Je(a,e){let t=e.getBoundingClientRect();return[(a.clientX-t.left)/t.width,(a.clientY-t.top)/t.height]}l(Je,"getPointerEventNormPos");var z=class extends k{constructor(e,t,i,r,n,s=null){super(e,t,i,r,n,s,f.Pointer)}correctOffset(e,t){return new z(this.x-e,this.y-t,this.shift,this.ctrl,this.alt,this.target)}cloneWithTarget(e){return new z(this.x,this.y,this.shift,this.ctrl,this.alt,e)}};l(z,"PointerMove");var N;(function(i){i[i.None=0]="None",i[i.Hovering=1]="Hovering",i[i.Pressing=2]="Pressing"})(N||(N={}));var Fe=class{constructor(){this.states=new Map;this.nextPointerID=0;this.hints=new Map;this.dragToScroll=new Map}unassignPointer(e,t){t.pointer!==null&&this.setPointerHint(t.pointer,N.None),t.pointer=null,t.hovering&&t.eventQueue.push(new W(e.getFocusCapturer(f.Pointer))),t.hovering=!1,t.pressing=0,t.dragLast=null}registerPointer(e=!1){let t=this.nextPointerID++;return this.setPointerHint(t,N.None),this.dragToScroll.set(t,e),t}unregisterPointer(e){for(let[t,i]of this.states)i.pointer===e&&this.unassignPointer(t,i);this.hints.delete(e),this.dragToScroll.delete(e)}canQueueEvent(e,t,i,r){let n=i.pointer===null;n&&(i.pointer=t);let s=i.pointer===t;if(!s||n)for(let[o,h]of this.states)o!==e&&h.pointer===t&&this.unassignPointer(o,h);return!s&&(!r||i.pressing>0)?!1:(r&&i.pointer!==t&&(this.unassignPointer(e,i),i.pointer=t),!0)}denormaliseCoords(e,t,i){let[r,n]=e.dimensions;return[t*r,i*n]}movePointer(e,t,i,r,n,s,o,h){let d=this.states.get(e);if(typeof d=="undefined"||(n===null&&(n=d.pressing),!this.canQueueEvent(e,t,d,n>0)))return;d.hovering=!0;let[u,c]=this.denormaliseCoords(e,i,r);if(n!==d.pressing){let p=Math.floor(Math.log2(Math.max(n,d.pressing)));for(let m=0;m<=p;m++){let g=(d.pressing>>m&1)==1,b=(n>>m&1)==1;g!==b&&(b?d.eventQueue.push(new M(u,c,m,s,o,h)):d.eventQueue.push(new A(u,c,m,s,o,h)))}d.pressing=n}else d.eventQueue.push(new z(u,c,s,o,h));d.pressing>0?this.setPointerHint(t,N.Pressing):this.setPointerHint(t,N.Hovering)}leavePointer(e,t){let i=this.states.get(e);typeof i!="undefined"&&i.hovering&&i.pointer==t&&(i.hovering=!1,i.pressing=0,i.dragLast=null,i.eventQueue.push(new W(e.getFocusCapturer(f.Pointer))),this.setPointerHint(t,N.None))}leaveAnyPointer(e){for(let t of this.states.keys())this.leavePointer(t,e)}wheelPointer(e,t,i,r,n,s,o,h,d){let u=this.states.get(e);if(typeof u=="undefined"||!this.canQueueEvent(e,t,u,!0))return;u.hovering=!0;let[c,p]=this.denormaliseCoords(e,i,r);u.eventQueue.push(new S(c,p,n,s,!1,o,h,d))}setPointerHint(e,t){return this.hints.get(e)!==t?(this.hints.set(e,t),!0):!1}getPointerHint(e){var t;return(t=this.hints.get(e))!=null?t:N.None}onEnable(e){this.states.set(e,{eventQueue:[],pointer:null,pressing:0,hovering:!1,dragLast:null,dragOrigin:[0,0]})}onDisable(e){e.dispatchEvent(new W);let t=this.states.get(e);typeof t!="undefined"&&t.pointer!==null&&(this.setPointerHint(t.pointer,N.None),t.dragLast=null),this.states.delete(e)}update(e){let t=this.states.get(e);if(typeof t=="undefined")return;let i=t.pointer===null?!1:this.dragToScroll.get(t.pointer);for(let r of t.eventQueue){if(r instanceof k&&t.dragLast!==null){let[n,s]=t.dragLast;e.dispatchEvent(new S(...t.dragOrigin,n-r.x,s-r.y,!1,!1,!1,!0)),r instanceof A?t.dragLast=null:(t.dragLast[0]=r.x,t.dragLast[1]=r.y);continue}e.dispatchEvent(r)?t.dragLast=null:i&&r instanceof M&&(t.dragLast=[r.x,r.y],t.dragOrigin[0]=r.x,t.dragOrigin[1]=r.y)}t.eventQueue.length=0}onFocusChanged(e,t,i){}onFocusCapturerChanged(e,t,i,r){}};l(Fe,"PointerDriver");function ft(a){return[a.shiftKey,a.ctrlKey,a.altKey]}l(ft,"unpackModifiers");var gt=class extends Fe{constructor(){super();this.domElems=new WeakMap;this.pointers=new Map;this.mousePointerID=this.registerPointer(!1)}bindDOMElem(e,t){let i=this.domElems.get(e);typeof i!="undefined"?this.removeListeners(i):(i={domElem:t,pointerListen:null,pointerleaveListen:null,wheelListen:null,contextMenuListen:null},this.domElems.set(e,i),t.style.touchAction="none"),e.enabled&&this.addListeners(e,i)}getPointerID(e){let t=this.pointers.get(e.pointerId);return typeof t=="undefined"&&(e.pointerType==="mouse"?t=this.mousePointerID:t=this.registerPointer(!0),this.pointers.set(e.pointerId,t)),t}addListeners(e,t){let i=t.domElem;t.pointerListen=r=>{this.movePointer(e,this.getPointerID(r),...Je(r,i),r.buttons,...ft(r))},t.pointerleaveListen=r=>{this.leavePointer(e,this.getPointerID(r))},t.wheelListen=r=>{this.wheelPointer(e,this.mousePointerID,...Je(r,i),r.deltaX,r.deltaY,...ft(r))},t.contextMenuListen=r=>{r.preventDefault()},i.addEventListener("pointermove",t.pointerListen),i.addEventListener("pointerdown",t.pointerListen),i.addEventListener("pointerup",t.pointerListen),i.addEventListener("pointerleave",t.pointerleaveListen),i.addEventListener("wheel",t.wheelListen),i.addEventListener("contextmenu",t.contextMenuListen)}removeListeners(e){e.pointerListen!==null&&(e.domElem.removeEventListener("pointermove",e.pointerListen),e.domElem.removeEventListener("pointerdown",e.pointerListen),e.domElem.removeEventListener("pointerup",e.pointerListen),e.pointerListen=null),e.pointerleaveListen!==null&&(e.domElem.removeEventListener("pointerleave",e.pointerleaveListen),e.pointerleaveListen=null),e.wheelListen!==null&&(e.domElem.removeEventListener("wheel",e.wheelListen),e.wheelListen=null),e.contextMenuListen!==null&&(e.domElem.removeEventListener("contextmenu",e.contextMenuListen),e.contextMenuListen=null)}onEnable(e){super.onEnable(e);let t=this.domElems.get(e);typeof t!="undefined"&&this.addListeners(e,t)}onDisable(e){super.onDisable(e);let t=this.domElems.get(e);typeof t!="undefined"&&this.removeListeners(t)}};l(gt,"DOMPointerDriver");var bt=class extends Fe{constructor(){super(...arguments);this.sources=new Set}handlePointerRay(e,t,i,r,n,s,o){let[h,d,u]=this.castRay(i,r);h===null?this.leaveAnyPointer(e):this.movePointer(h,e,d,u,t,n,s,o)}addSource(e){this.sources.has(e)||(e.setRayPointerDriver(this),this.sources.add(e))}setPointerHint(e,t){let i=super.setPointerHint(e,t);for(let r of this.sources)r.onPointerHintChanged(e,t);return i}};l(bt,"RayPointerDriver");var re=class{constructor(e,t=null){this._dirty=!1;this._value=e,this.callback=t}get value(){return this._value}set value(e){this.setValue(e)}get dirty(){let e=this._dirty;return this._dirty=!1,e}setValue(e,t=!0){if(this._value!==e&&(this._value=e,this._dirty=!0,t&&this.callback!==null))try{this.callback(e)}catch(i){console.error("Exception in Variable callback",i)}}};l(re,"Variable");var yt=class extends R{constructor(e=new R){super(void 0,e)}get canvasFill(){return"#"+Math.floor(Math.random()*16777215).toString(16)}set canvasFill(e){super.canvasFill=e}};l(yt,"DebugTheme");function Hs(a,e,t=null){return i=>{let r=!0,n=i;for(let s of a)if([r,n]=s(n),!r)return[!1,e];if(t!==null)try{t(n)}catch(s){console.warn("Exception in CompositeValidator callback:",s)}return[!0,n]}}l(Hs,"MakeCompositeValidator");function Xt(a){return[!0,a]}l(Xt,"DefaultTextValidator");function vt(a=null){return a===null?Xt:e=>(a(e),[!0,e])}l(vt,"MakeDefaultTextValidatorWithCallback");var Qt=/^-?(\.\d+|\d+(\.(\d+)?)?)(e\d+)?$/;function Ks(a){return Qt.test(a)?[!0,parseFloat(a)]:[!1,NaN]}l(Ks,"FloatValidator");var zt=/^-?\d+$/;function Bs(a){return zt.test(a)?[!0,parseInt(a)]:[!1,NaN]}l(Bs,"IntValidator");function Os(a,e){return t=>t<a?[!1,t]:t>e?[!1,t]:[!0,t]}l(Os,"MakeRangeValidator");var xt=class extends G{constructor(e,t=0,i=42,r=24,n){super("Alt",()=>{e.alt=!e.alt,this.child.forced=e.alt,e.callback("Alt")},t,i,r,n);this.child.forced=e.alt}};l(xt,"AltKey");var Tt=class extends G{constructor(e,t=0,i=42,r=24,n){super("Ctrl",()=>{e.ctrl=!e.ctrl,this.child.forced=e.ctrl,e.callback("Control")},t,i,r,n);this.child.forced=e.ctrl}};l(Tt,"ControlKey");var he=class extends w{constructor(e,t=null,i="",r){super(!1,!1,r);this.blinkStart=0;this.blinkWasOn=null;this.cursorPos=0;this.cursorOffset=[0,0];this.selectPos=0;this.selectOffset=[0,0];this.cursorOffsetDirty=!1;this._editingEnabled=!0;this.hideText=!1;this.offset=[0,0];this.wrapText=!0;this.inputFilter=null;this.dragging=!1;this.lastClick=0;this.dragStart=-1;this.successiveClickCount=0;this.textHelper=new C,this.variable=new re(i,n=>{let[s,o]=e(n);s&&(this._validValue=o),s!==this._valid&&(this._valid=s,this._dirty=!0)}),[this._valid,this._validValue]=e(i),this.inputFilter=t}onThemeUpdated(e=null){super.onThemeUpdated(e),e===null?(this._layoutDirty=!0,this._dirty=!0,this.cursorOffsetDirty=!0):e==="inputTextInnerPadding"||e==="inputTextFont"||e==="inputTextMinAscent"||e==="inputTextMinDescent"?(this._layoutDirty=!0,this._dirty=!0):e==="inputBackgroundFill"||e==="inputTextFill"||e==="inputTextFillInvalid"||e==="inputTextFillDisabled"||e==="cursorThickness"?this._dirty=!0:e==="inputTextAlign"&&(this.cursorOffsetDirty=!0)}get blinkOn(){if(this.blinkStart===0)return null;let e=this.blinkRate;return Math.trunc((Date.now()-this.blinkStart)/(500*e)%2)===0}get editingEnabled(){return this._editingEnabled}set editingEnabled(e){this._editingEnabled!==e&&(this._editingEnabled=e,e||(this.blinkStart=0,this.moveCursorTo(0,!1)),this._dirty=!0)}set text(e){this.variable.value=e}get text(){return this.variable.value}get displayedText(){return this.hideText?"\u25CF".repeat(this.variable.value.length):this.variable.value}get valid(){return this._valid}get validValue(){return this._validValue}get line(){return this.textHelper.getLine(this.cursorPos)}moveCursorTo(e,t){this.cursorPos=Math.min(Math.max(e,0),this.text.length),t||(this.selectPos=this.cursorPos),this.cursorOffsetDirty=!0,this._dirty=!0}moveCursor(e,t){this.moveCursorTo(this.cursorPos+e,t)}moveCursorFromOffset(e,t,i){[this.cursorPos,this.cursorOffset]=this.textHelper.findIndexOffsetFromOffset([e,t]),i||(this.selectPos=this.cursorPos,this.selectOffset=this.cursorOffset),this.blinkStart=Date.now(),this._dirty=!0}moveCursorLine(e,t){this.moveCursorFromOffset(this.cursorOffset[0],this.cursorOffset[1]+(.5+e)*this.textHelper.fullLineHeight,t)}moveCursorStart(e){this.moveCursorTo(this.textHelper.getLineStart(this.line),e)}moveCursorEnd(e){this.moveCursorTo(this.textHelper.getLineEnd(this.line,!1),e)}moveCursorWord(e,t){if(e==0)return;let i=/\w/,r=this.text,n=this.cursorPos;if(e>0)for(;e>0;){let s=!1;for(;n<=r.length;n++)if(n<r.length&&i.test(r[n]))s=!0;else if(s)break;e--}else for(;e<0;){n--;let s=!1;for(;n>=0;n--)if(n>=0&&i.test(r[n]))s=!0;else if(s)break;n++,e++}this.moveCursorTo(n,t)}deleteRange(e,t){e!==t&&(this.text=this.text.substring(0,e)+this.text.substring(t),this.cursorPos=this.selectPos=e,this.cursorOffsetDirty=!0)}deleteWord(e){if(e===0)return;if(this.cursorPos!==this.selectPos){this.deleteRange(Math.min(this.cursorPos,this.selectPos),Math.max(this.cursorPos,this.selectPos));return}let t=this.cursorPos;this.moveCursorWord(e,!1),t!==this.cursorPos&&this.deleteRange(Math.min(t,this.cursorPos),Math.max(t,this.cursorPos))}insertText(e){if(!(this.inputFilter!==null&&!this.inputFilter(e)))if(this.selectPos===this.cursorPos)this.text=this.text.substring(0,this.cursorPos)+e+this.text.substring(this.cursorPos),this.moveCursor(e.length,!1);else{let t=Math.min(this.cursorPos,this.selectPos),i=Math.max(this.cursorPos,this.selectPos);this.text=this.text.substring(0,t)+e+this.text.substring(i),this.moveCursorTo(t+e.length,!1)}}deleteText(e){e!==0&&(this.cursorPos!==this.selectPos?this.deleteRange(Math.min(this.cursorPos,this.selectPos),Math.max(this.cursorPos,this.selectPos)):e>0?this.text=this.text.substring(0,this.cursorPos)+this.text.substring(this.cursorPos+e):(this.text=this.text.substring(0,this.cursorPos+e)+this.text.substring(this.cursorPos),this.moveCursor(e,!1)))}selectRangeAt(e){let t=this.text,i=/\w/,r=i.test(t[e]),n=e;for(;e>=0&&i.test(t[e])===r;e--);let s=e+1;for(e=n;e<t.length&&i.test(t[e])===r;e++);return[s,e]}onFocusDropped(e,t){e===f.Keyboard&&(this.blinkStart=0)}handleEvent(e,t){if(!this._editingEnabled)return this;if(e instanceof W)return this.dragging=!1,this.lastClick=0,this;if(e instanceof S)return null;if(e instanceof k){if(t.pointerStyle="text",e instanceof M||e instanceof z){let i=e instanceof M&&e.isPrimary;if(i){this.dragging=!0;let n=new Date().getTime();n-this.lastClick<500?(this.successiveClickCount++,this.successiveClickCount>2&&(this.successiveClickCount=0)):this.successiveClickCount=0,this.lastClick=n}else if(!this.dragging)return this;let r=this.inputTextInnerPadding;if(this.moveCursorFromOffset(e.x-this.x-r+this.offset[0],e.y-this.y-r+this.offset[1],!i&&this.dragging),i&&(this.cursorPos!==this.dragStart&&(this.successiveClickCount=0),this.dragStart=this.cursorPos),this.successiveClickCount>0){let n,s;if(this.successiveClickCount===1){let[o,h]=this.selectRangeAt(this.dragStart),[d,u]=this.selectRangeAt(this.cursorPos);n=Math.min(o,d),s=Math.max(h,u)}else{let o=Math.min(this.cursorPos,this.dragStart),h=this.textHelper.getLine(o);n=this.textHelper.getLineStart(h);let d=Math.max(this.cursorPos,this.dragStart),u=this.textHelper.getLine(d);s=this.textHelper.getLineEnd(u)}this.cursorPos>=this.dragStart?(this.selectPos=n,this.cursorPos=s):(this.selectPos=s,this.cursorPos=n),this.cursorOffsetDirty=!0}t.requestFocus(f.Keyboard,this)}else e instanceof A&&e.isPrimary&&(this.dragging=!1,t.hasMobileTextInput&&t.getTextInput(this.text).then(i=>{i!==null&&this.text!==i&&(this.text=i,this.moveCursorTo(i.length,!1))}));return this}else if(e instanceof ie){if(this.dragging=!1,this.lastClick=0,e.alt)return this;if(e.ctrl){if(e.key==="Backspace")this.deleteWord(-1);else if(e.key==="Delete")this.deleteWord(1);else if(e.key==="ArrowLeft")this.moveCursorWord(-1,e.shift);else if(e.key==="ArrowRight")this.moveCursorWord(1,e.shift);else if(e.key==="c"||e.key==="C"){if(this.cursorPos===this.selectPos)return this;let i=this.text.slice(Math.min(this.cursorPos,this.selectPos),Math.max(this.cursorPos,this.selectPos));if(navigator.clipboard)navigator.clipboard.writeText(i);else return this}else if(e.key==="a"||e.key==="A")this.cursorPos=this.text.length,this.selectPos=0,this.cursorOffsetDirty=!0,this._dirty=!0;else return this;return this.blinkStart=Date.now(),this}if(e.key.length===1)this.insertText(e.key);else if(e.key==="Backspace")this.deleteText(-1);else if(e.key==="Delete")this.deleteText(1);else if(e.key==="ArrowLeft")this.moveCursor(-1,e.shift);else if(e.key==="ArrowRight")this.moveCursor(1,e.shift);else if(e.key==="ArrowUp")this.moveCursorLine(-1,e.shift);else if(e.key==="ArrowDown")this.moveCursorLine(1,e.shift);else if(e.key==="PageUp")this.moveCursorLine(-5,e.shift);else if(e.key==="PageDown")this.moveCursorLine(5,e.shift);else if(e.key==="Home")this.moveCursorStart(e.shift);else if(e.key==="End")this.moveCursorEnd(e.shift);else{if(e.key==="Escape")return t.dropFocus(f.Keyboard,this),this;if(e.key==="Enter")this.insertText(`
  `);else if(e.key==="Tab")this.insertText("	");else return this}this.blinkStart=Date.now()}else e instanceof ee&&e.target===this&&(this.insertText(e.text),this.blinkStart=Date.now());return this}handlePreLayoutUpdate(e){this.editingEnabled||e.dropFocus(f.Keyboard,this),this.blinkOn!==this.blinkWasOn&&(this._dirty=!0),this.textHelper.text=this.displayedText,this.textHelper.font=this.inputTextFont,this.textHelper.lineHeight=this.inputTextHeight,this.textHelper.lineSpacing=this.inputTextSpacing,this.textHelper.alignMode=this.inputTextAlign,this.textHelper.dirty&&(this._dirty=!0,this._layoutDirty=!0)}handleResolveDimensions(e,t,i,r){let n=2*this.inputTextInnerPadding;this.textHelper.maxWidth=this.wrapText?Math.max(t-n,0):1/0,this.textHelper.dirty&&(this._dirty=!0);let s=Math.min(Math.max(this.inputTextMinWidth,e),t);this.width=Math.min(Math.max(s,this.textHelper.width+n),t),this.height=Math.min(Math.max(i,this.textHelper.height+n),r)}handlePostLayoutUpdate(e){this.cursorOffsetDirty&&(this.cursorOffset=this.textHelper.findOffsetFromIndex(this.cursorPos),this.selectPos===this.cursorPos?(this.selectOffset[0]=this.cursorOffset[0],this.selectOffset[1]=this.cursorOffset[1]):this.selectOffset=this.textHelper.findOffsetFromIndex(this.selectPos),this.cursorOffsetDirty=!1);let t=this.inputTextInnerPadding,i=this.textHelper.width,r=this.textHelper.height,n=this.width-t*2,s=this.height-t*2,o=this.offset,[h,d]=this.cursorOffset;if(i>n){let u=Math.min(20,n/2),c=o[0]+u,p=o[0]+n-u;h>p&&(o[0]+=h-p),h<c&&(o[0]-=c-h),o[0]+n>i&&(o[0]=i-n),o[0]<0&&(o[0]=0)}else o[0]=0;if(r>s){let u=this.textHelper.fullLineHeight,c=s<2*u?0:u/2,p=o[1]+c,m=o[1]+s-c-u;d>m&&(o[1]+=d-m),d<p&&(o[1]-=p-d),o[1]+s>r&&(o[1]=r-s),o[1]<0&&(o[1]=0)}else o[1]=0;this.offset=o}handlePainting(e,t){e.fillStyle=this.inputBackgroundFill,e.fillRect(this.x,this.y,this.width,this.height),e.save(),e.beginPath(),e.rect(this.x,this.y,this.width,this.height),e.clip();let i=this.inputTextInnerPadding;if(this.cursorPos!==this.selectPos)if(e.fillStyle=this.inputSelectBackgroundFill,this.cursorOffset[1]===this.selectOffset[1]){let s=Math.min(this.cursorOffset[0],this.selectOffset[0]),o=Math.max(this.cursorOffset[0],this.selectOffset[0]);e.fillRect(this.x+i+s-this.offset[0],this.y+i+this.cursorOffset[1]-this.offset[1],o-s,this.textHelper.fullLineHeight)}else{let s,o;this.cursorOffset[1]<this.selectOffset[1]?(s=this.cursorOffset,o=this.selectOffset):(o=this.cursorOffset,s=this.selectOffset);let h=this.textHelper.fullLineHeight,d=this.width+this.offset[0]-s[0]-i;d>0&&e.fillRect(this.x+i+s[0]-this.offset[0],this.y+i+s[1]-this.offset[1],d,h);let u=o[0]+i-this.offset[0];u>0&&e.fillRect(this.x,this.y+i+o[1]-this.offset[1],u,h);let c=s[1]+h,p=o[1]-c;p>0&&e.fillRect(this.x,this.y+i+c-this.offset[1],this.width,p)}let r;this._editingEnabled?this._valid?r=this.inputTextFill:r=this.inputTextFillInvalid:r=this.inputTextFillDisabled,this.textHelper.paint(e,r,this.x+i-this.offset[0],this.y+i-this.offset[1]);let n=this.blinkOn;this.blinkWasOn=n,n&&(e.fillStyle=r,e.fillRect(this.x+i+this.cursorOffset[0]-this.offset[0],this.y+i+this.cursorOffset[1]-this.offset[1],this.cursorThickness,this.textHelper.fullLineHeight)),e.restore()}};l(he,"TextInput"),v([H(["cursorOffsetDirty","_dirty"])],he.prototype,"hideText",2),v([Me()],he.prototype,"offset",2),v([O],he.prototype,"wrapText",2);var Pt=class extends he{constructor(e=null,t="",i){let r=vt(e);super(r,null,t,i)}};l(Pt,"BasicTextInput");var _t=class extends te{constructor(e,t){let i=U({},t);i.containerAlignment={horizontal:x.Center,vertical:x.Center},i.containerPadding={left:0,right:0,top:0,bottom:0};super(e,i)}};l(_t,"Center");var Qe=class extends w{constructor(e=null,t=!1,i){super(!0,!1,i);this.offsetX=0;this.offsetY=0;this.actualLength=0;this.variable=new re(t,e),this.clickHelper=new B(this)}onThemeUpdated(e=null){super.onThemeUpdated(e),e===null?(this._layoutDirty=!0,this._dirty=!0):e==="checkboxLength"?(this._layoutDirty=!0,this._dirty=!0):(e==="backgroundGlowFill"||e==="backgroundFill"||e==="accentFill"||e==="primaryFill"||e==="checkboxInnerPadding")&&(this._dirty=!0)}set checked(e){this.variable.value=e}get checked(){return this.variable.value}handleEvent(e,t){if(e instanceof S)return null;let i=this.x+this.offsetX,r=this.y+this.offsetY;return this.clickHelper.handleClickEvent(e,t,[i,i+this.actualLength,r,r+this.actualLength]),this.clickHelper.clickStateChanged&&(this._dirty=!0,this.clickHelper.wasClick&&(this.checked=!this.checked)),this}handlePostLayoutUpdate(e){this.variable.dirty&&(this._dirty=!0)}handleResolveDimensions(e,t,i,r){let n=this.checkboxLength;this.actualLength=Math.min(n,t,r),this.width=this.actualLength,this.height=this.actualLength,this.width<e&&(this.width=e),this.height<i&&(this.height=i),this.offsetX=(this.width-this.actualLength)/2,this.offsetY=(this.height-this.actualLength)/2}handlePainting(e,t){let i=this.clickHelper.clickState===T.Hover||this.clickHelper.clickState===T.Hold;i?e.fillStyle=this.backgroundGlowFill:e.fillStyle=this.backgroundFill;let r=this.offsetX+this.x,n=this.offsetY+this.y;if(e.fillRect(r,n,this.actualLength,this.actualLength),this.checked){i?e.fillStyle=this.accentFill:e.fillStyle=this.primaryFill;let s=this.checkboxInnerPadding,o=this.actualLength-s*2;o<=0?e.fillRect(r,n,this.actualLength,this.actualLength):e.fillRect(r+s,n+s,o,o)}}};l(Qe,"Checkbox");var jt=/^.*\.(webm|og[gv]|m(p4|4v|ov)|avi|qt)$/i,ne=class extends w{constructor(e,t=null,i=null,r=null,n){super(!0,!1,n);this.lastSrc=null;this.rotation=0;this.imageWidth=null;this.imageHeight=null;this.offsetX=0;this.offsetY=0;this.actualWidth=0;this.actualHeight=0;this.loadedmetadataListener=null;this.canplayListener=null;this.frameCallback=null;if(typeof e=="string")if(jt.test(e)){let s=document.createElement("video");s.src=e,s.preload="auto",e=s}else{let s=document.createElement("img");s.src=e,e=s}this._image=e,this.imageWidth=t,this.imageHeight=i,this.viewBox=r,this.setupVideoEvents()}setupVideoEvents(){if(this.image instanceof HTMLVideoElement)if(this.loadedmetadataListener=e=>this._layoutDirty=!0,this.image.addEventListener("loadedmetadata",this.loadedmetadataListener),this.canplayListener=e=>this._dirty=!0,this.image.addEventListener("canplay",this.canplayListener),"requestVideoFrameCallback"in this.image){console.warn("requestVideoFrameCallback available; if video playback is choppy or broken, please report it on Github");let e=this.image;this.frameCallback=(t,i)=>{this._dirty=!0,console.log("set dirty"),this.image===e&&this.frameCallback!==null&&this.image.requestVideoFrameCallback(this.frameCallback)},this.image.requestVideoFrameCallback(this.frameCallback)}else console.warn("requestVideoFrameCallback not available; video will be played back on every frame when not paused")}set image(e){e!==this._image&&(this._image instanceof HTMLVideoElement&&(this.loadedmetadataListener!==null&&this._image.removeEventListener("loadedmetadata",this.loadedmetadataListener),this.canplayListener!==null&&this._image.removeEventListener("canplay",this.canplayListener)),this._image=e,this.lastSrc=null,this.loadedmetadataListener=null,this.canplayListener=null,this.frameCallback=null,this.setupVideoEvents())}get image(){return this._image}handlePreLayoutUpdate(e){var t,i;this._image instanceof HTMLVideoElement?!this._image.paused&&this.frameCallback===null&&(this._dirty=!0):((t=this._image)==null?void 0:t.src)!==this.lastSrc&&((i=this._image)==null?void 0:i.complete)&&(this._layoutDirty=!0,this._dirty=!0)}handleResolveDimensions(e,t,i,r){let n=this.imageWidth;n===null&&(this.viewBox===null?this._image instanceof HTMLVideoElement?n=this._image.videoWidth:n=this._image.naturalWidth:n=this.viewBox[2]),this.width=Math.max(Math.min(n,t),e);let s=this.imageHeight;s===null&&(this.viewBox===null?this._image instanceof HTMLVideoElement?s=this._image.videoHeight:s=this._image.naturalHeight:s=this.viewBox[3]),this.height=Math.max(Math.min(s,r),i);let o=this.width/n,h=this.height/s,d=Math.min(o,h);this.actualWidth=n*d,this.actualHeight=s*d,this.offsetX=(this.width-this.actualWidth)/2,this.offsetY=(this.height-this.actualHeight)/2}handlePainting(e,t){var s;if(this._image instanceof HTMLImageElement&&!((s=this._image)==null?void 0:s.complete)){this.lastSrc=null;return}this.lastSrc=this._image.src;let i=this.x+this.offsetX,r=this.y+this.offsetY,n=this.rotation!==0;n&&(e.save(),e.beginPath(),e.rect(this.x,this.y,this.width,this.height),e.clip(),e.translate(this.x+this.offsetX+this.actualWidth/2,this.y+this.offsetY+this.actualHeight/2),i=-this.actualWidth/2,r=-this.actualHeight/2,e.rotate(this.rotation)),this.viewBox===null?e.drawImage(this._image,i,r,this.actualWidth,this.actualHeight):e.drawImage(this._image,...this.viewBox,i,r,this.actualWidth,this.actualHeight),n&&e.restore()}dryPaint(){var e;this._image instanceof HTMLImageElement&&((e=this._image)==null?void 0:e.complete)?this.lastSrc=this._image.src:this.lastSrc=null,super.dryPaint()}};l(ne,"Icon"),v([nt],ne.prototype,"rotation",2),v([at(!0)],ne.prototype,"viewBox",2),v([O],ne.prototype,"imageWidth",2),v([O],ne.prototype,"imageHeight",2);var wt=class extends ve{constructor(e,t=null,i=null,r=null,n=null,s){super(new ne(e,t,i,r,s),n,s)}};l(wt,"IconButton");var ze=class extends w{constructor(e=1,t=0,i=0,r){super(!0,!1,r);this.flex=e,this.minWidth=t,this.minHeight=i}handleResolveDimensions(e,t,i,r){t!==1/0?this.width=t:this.width=Math.max(e,this.minWidth),r!==1/0?this.height=r:this.height=Math.max(i,this.minHeight)}};l(ze,"Spacing");var kt=class extends Te{constructor(e,t=null,i=!1,r){super(r);this.add([new ae(e,r),new ze(1,0,0,r),new Qe(t,i,r)])}};l(kt,"LabelledCheckbox");var Ce=class extends Z{constructor(e,t=0,i=0,r=!1,n=!1,s=!1,o){super(e,!1,!0,o);this._offset=[0,0];this._constraints=[0,1/0,0,1/0];this.forceReLayout=!0;this.forceRePaint=!0;this.viewport=s?new oe:null,this.minWidth=t,this.minHeight=i,this._widthTied=r,this._heightTied=n,this._constraints=[0,1/0,0,1/0]}get offset(){return[...this._offset]}set offset(e){(this._offset[0]!==e[0]||this._offset[1]!==e[1])&&(this._offset[0]=e[0],this._offset[1]=e[1],this._dirty=!0,this.correctChildPosition())}set constraints(e){(e[0]!==this._constraints[0]||e[1]!==this._constraints[1]||e[2]!==this._constraints[2]||e[3]!==this._constraints[3])&&(this._constraints[0]=e[0],this._constraints[1]=e[1],this._constraints[2]=e[2],this._constraints[3]=e[3],this.viewport!==null?this.viewport.constraints=e:this.forceReLayout=!0)}get constraints(){return[...this._constraints]}get widthTied(){return this._widthTied}set widthTied(e){this._widthTied!==e&&(this._widthTied=e,this._layoutDirty=!0,this.forceReLayout=!0)}get heightTied(){return this._heightTied}set heightTied(e){this._heightTied!==e&&(this._heightTied=e,this._layoutDirty=!0,this.forceReLayout=!0)}get scaledMinWidth(){var e,t;return this.minWidth*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}get scaledMinHeight(){var e,t;return this.minHeight*((t=(e=this.root)==null?void 0:e.resolution)!=null?t:1)}get scaledConstraints(){var t,i;let e=(i=(t=this.root)==null?void 0:t.resolution)!=null?i:1;return[this._constraints[0]*e,this._constraints[1]*e,this._constraints[2]*e,this._constraints[3]*e]}onThemeUpdated(e=null){super.onThemeUpdated(e),e===null?(this._layoutDirty=!0,this._dirty=!0):e==="canvasFill"&&(this._dirty=!0)}handleEvent(e,t){if(e.target===null&&!(e instanceof k))return null;let[i,r]=this.child.dimensions,n=this.x+this.offset[0],s=n+i,o=this.y+this.offset[1],h=o+r;if(e instanceof k){if(e.target===null&&(e.x<n||e.x>=s||e.y<o||e.y>=h))return null;this.viewport!==null&&(e=e.correctOffset(n,o))}return this.child.dispatchEvent(e,t)}handlePreLayoutUpdate(e){let t=this.child;t.preLayoutUpdate(e),this._widthTied||this._heightTied?t.layoutDirty&&(this._layoutDirty=!0):this.viewport!==null?(this.viewport.constraints=this.scaledConstraints,this.viewport.resolveChildsLayout(t)):(t.layoutDirty||this.forceReLayout)&&(t.resolveDimensionsAsTop(...this.scaledConstraints),this.correctChildPosition())}handlePostLayoutUpdate(e){let t=this.child;this.forceReLayout=!1,t.postLayoutUpdate(e),t.dirty&&(this._dirty=!0)}handleResolveDimensions(e,t,i,r){let n=!0,s=!0,o=Math.min(Math.max(e,this.scaledMinWidth),t),h=Math.min(Math.max(i,this.scaledMinHeight),r);if(this._widthTied||this._heightTied){let d=this.scaledConstraints;this._widthTied&&(d[0]=o,d[1]=t),this._heightTied&&(d[2]=h,d[3]=r);let u=this.child;this.viewport===null?(u.resolveDimensionsAsTop(...d),this.correctChildPosition()):(this.viewport.constraints=d,this.viewport.resolveChildsLayout(u)),this._widthTied&&(this.width=u.dimensions[0],n=!1),this._heightTied&&(this.height=u.dimensions[1],s=!1)}n&&(this.width=Math.min(o,t)),s&&(this.height=Math.min(h,r)),this.width===0&&this.minWidth===0&&!this._widthTied&&console.warn("ViewportWidget has no minimum width and width isn't tied, therefore, it may be dimensionless. Set a minimum width and/or tie the width"),this.height===0&&this.minHeight===0&&!this._heightTied&&console.warn("ViewportWidget has no minimum height and height isn't tied, therefore, it may be dimensionless. Set a minimum height and/or tie the height")}afterPositionResolved(){this.correctChildPosition(),this.viewport===null&&(this.forceRePaint=!0)}correctChildPosition(){if(this.viewport!==null)return;let[e,t]=this.offset;this.child.resolvePosition(this.x+e,this.y+t)}handlePainting(e,t){this.viewport!==null&&this.viewport.paintToCanvas(this.child,t);let[i,r,n,s]=this.roundRect(this.x,this.y,this.width,this.height,!0),[o,h]=this.child.dimensions,[d,u]=this.offset,c=i+n,p=r+s,m=this.x+d,g=this.y+u,b=Math.min(Math.max(m,i),c),P=Math.min(Math.max(g,r),p),F=Math.min(Math.max(m+o,i),c)-b,_=Math.min(Math.max(g+h,r),p)-P;if([b,P,F,_]=this.roundRect(b,P,F,_,!0),F===0||_===0){this.viewport===null&&this.child.dryPaint(),this.forceRePaint=!1;return}let y=b-m,E=P-g;this.clearStart(e),e.rect(i,r,n,s),e.clip(),this.viewport!==null&&e.drawImage(this.viewport.canvas,y,E,F,_,b,P,F,_),e.rect(b,P,F,_),this.clearEnd(e,"evenodd"),this.viewport===null&&(e.save(),e.beginPath(),e.rect(b,P,F,_),e.clip(),this.child.paint(e,t||this.forceRePaint),e.restore()),this.forceRePaint=!1}};l(Ce,"ViewportWidget"),v([O],Ce.prototype,"minWidth",2),v([O],Ce.prototype,"minHeight",2);var Y;(function(t){t[t.Overlay=0]="Overlay",t[t.Layout=1]="Layout"})(Y||(Y={}));var Ft=class extends Ce{constructor(e,t=0,i=0,r=!1,n=!1,s=0,o=!1,h){super(e,t,i,r,n,o,h);this.effectiveWidth=0;this.effectiveHeight=0;this.verticalDragged=null;this.startingScroll=0;this.startingOffset=0;this.lastScroll=0;this.horizWasPainted=!1;this.vertWasPainted=!1;this._scrollbarMode=s,this.horizontalClickHelper=new B(this),this.verticalClickHelper=new B(this)}get scrollbarMode(){return this._scrollbarMode}set scrollbarMode(e){if(this._scrollbarMode!==e){let t=this.scroll;this._scrollbarMode=e,this.scroll=t,this._layoutDirty=!0,this._dirty=!0}}get offset(){return super.offset}set offset(e){let[t,i]=this.child.dimensions;super.offset=[-Math.max(Math.min(-e[0],t-this.effectiveWidth),0),-Math.max(Math.min(-e[1],i-this.effectiveHeight),0)]}get widthTied(){return super.widthTied}set widthTied(e){let t=this.scroll;super.widthTied=e,this.scroll=t}get heightTied(){return super.heightTied}set heightTied(e){let t=this.scroll;super.heightTied=e,this.scroll=t}get scroll(){let[e,t]=this.offset,[i,r]=this.child.dimensions,n=i-this.effectiveWidth,s=r-this.effectiveHeight;return[n===0?0:Math.min(Math.max(-e/n,0),1),s===0?0:Math.min(Math.max(-t/s,0),1)]}set scroll(e){let[t,i]=this.child.dimensions;this.offset=[-e[0]*(t-this.effectiveWidth),-e[1]*(i-this.effectiveHeight)]}getClickHelper(e){return e?this.verticalClickHelper:this.horizontalClickHelper}handleEventScrollbar(e,t,i,r){if(this.verticalDragged!==null&&this.verticalDragged!==e)return!1;let[n,s]=this.getScrollbarRects(e,t),o=this._scrollbarMode===0,h=o?n:s,d=[h[0],h[0]+h[2],h[1],h[1]+h[3]],u=this.getClickHelper(e);u.handleClickEvent(i,r,d);let c=u.clickState,p=u.clickStateChanged;if(p&&(this._dirty=!0),c===T.Hold){if(u.pointerPos===null||!(i instanceof k))return!0;let m=e?1:0,g=this.scroll,b=o;b||(b=u.isPointInRect(i.x,i.y,n[0],n[0]+n[2],n[1],n[1]+n[3]));let P;if(o?P=u.getNormalInRect(i.x,i.y,s[0],s[0]+s[2],s[1],s[1]+s[3])[m]:P=u.pointerPos[m],p){if(!b){let F=e?this.effectiveHeight:this.effectiveWidth,_=this.child.dimensions[m],y=F/_;g[m]=(P-y/2)/(1-y),this.scroll=g}this.startingOffset=P,this.startingScroll=g[m],this.verticalDragged=e}else{let F=e?this.effectiveHeight:this.effectiveWidth,_=this.child.dimensions[m],y=F/_,E=P-this.startingOffset;g[m]=this.startingScroll+E/(1-y),this.scroll=g}return!0}else{if(c===T.Hover)return!0;if(p)return this.verticalDragged=null,!0}return!1}clampOffset(e){let[t,i]=this.child.dimensions,r=-(t-this.effectiveWidth);r>=0?e[0]=0:e[0]<r&&(e[0]=r);let n=-(i-this.effectiveHeight);n>=0?e[1]=0:e[1]<n&&(e[1]=n)}handleWheelEvent(e){let t=this.offset,[i,r]=t;t[0]-=e.shift?e.deltaY:e.deltaX,t[1]-=e.shift?e.deltaX:e.deltaY,this.clampOffset(t),this.offset=t;let[n,s]=this.offset,o=n!==i||s!==r,h=this.lastScroll,d=new Date().getTime();return this.lastScroll=d,o?!0:e.fromDrag?!1:d-h<200}onThemeUpdated(e=null){super.onThemeUpdated(e),e==="scrollBarThickness"?(this._layoutDirty=!0,this._dirty=!0):(e==="backgroundFill"||e==="scrollBarMinPercent"||e==="scrollBarMinPixels"||e==="primaryFill"||e==="accentFill"||e==="backgroundGlowFill")&&(this._dirty=!0)}handleEvent(e,t){if((e instanceof W||e instanceof k)&&(e.target===null||e.target===this)){let[r,n]=this.child.dimensions,s=this._scrollbarMode===0,o=!s&&!this.widthTied&&!this.heightTied,h=r>this.width,d=n>this.height,u=!1;if(!this.widthTied&&(h||!s)&&this.handleEventScrollbar(!1,d||o,e,t)&&(u=!0),!this.heightTied&&(d||!s)&&this.handleEventScrollbar(!0,h||o,e,t)&&(u=!0),u)return e instanceof S&&this.handleWheelEvent(e),this}let i=super.handleEvent(e,t);return i===null&&e instanceof S&&this.handleWheelEvent(e)?this:i}handleResolveDimensions(e,t,i,r){let n=this.scrollBarThickness,s=this._scrollbarMode===1,o=s&&!this.heightTied,h=s&&!this.widthTied,d,u,c,p;o?(u=Math.max(t-n,0),d=Math.min(e,u)):(u=t,d=e),h?(p=Math.max(r-n,0),c=Math.min(i,p)):(p=r,c=i),super.handleResolveDimensions(d,u,c,p),this.effectiveWidth=this.width,this.effectiveHeight=this.height,o&&(this.width=Math.min(Math.max(this.width+n,e),t)),h&&(this.height=Math.min(Math.max(this.height+n,i),r))}handlePostLayoutUpdate(e){super.handlePostLayoutUpdate(e);let t=this.offset;this.clampOffset(t),this.offset=t}handlePainting(e,t){let[i,r]=this.child.dimensions,n=i>this.width,s=r>this.height,o=this.scrollbarNeedsPaint(!1,n),h=this.scrollbarNeedsPaint(!0,s);(this.horizWasPainted!==o||this.vertWasPainted!==h)&&(this.horizWasPainted=o,this.vertWasPainted=h,this.forceRePaint=!0),super.handlePainting(e,t);let d=this._scrollbarMode===1&&!this.widthTied&&!this.heightTied;if(o&&this.paintScrollbar(!1,n,s||d,e),h&&this.paintScrollbar(!0,s,n||d,e),d){let u=this.scrollBarThickness;e.fillStyle=this.backgroundFill,e.fillRect(this.x+this.width-u,this.y+this.height-u,u,u)}}getScrollbarRects(e,t){let i=this._scrollbarMode===0,r=e?1:0,n=this.scroll[r],s=this.child.dimensions[r],o=e?this.effectiveHeight:this.effectiveWidth,h=this.scrollBarThickness,d=this.scrollBarMinPercent,u=this.scrollBarMinPixels,c=o;i&&(c-=t?h:0);let p=Math.min(Math.max(u,Math.max(o/s,d)*c),c),m=(c-p)*n,g,b,P,F;e?(g=this.x+this.width-h,b=this.y+m,P=h,F=p):(g=this.x+m,b=this.y+this.height-h,P=p,F=h);let _,y,E,L;return e?(_=g,y=this.y,E=h,L=c):(_=this.x,y=b,E=c,L=h),[[g,b,P,F],[_,y,E,L]]}scrollbarNeedsPaint(e,t){return!t&&this._scrollbarMode===0?!1:!(e?this.heightTied:this.widthTied)}paintScrollbar(e,t,i,r){let[n,s]=this.getScrollbarRects(e,i);if(this._scrollbarMode!==0&&(r.fillStyle=this.backgroundFill,r.fillRect(...s)),t)switch(this.getClickHelper(e).clickState){case T.Released:r.fillStyle=this.primaryFill;break;case T.Hover:case T.Hold:r.fillStyle=this.accentFill;break}else r.fillStyle=this.backgroundGlowFill;r.fillRect(...n)}};l(Ft,"ScrollableViewportWidget");var Ct=class extends w{constructor(e=null,t=0,i=1,r=0,n=0,s=!1,o){super(!0,!1,o);this.offsetX=0;this.offsetY=0;this.actualWidth=0;this.actualHeight=0;if(i<t)throw new Error("Slider max value can't be smaller than minimum value");this.clickHelper=new B(this),this.variable=new re(Math.max(n,t),e),this.minValue=t,this.maxValue=i,this.snapIncrement=r,this.vertical=s}set value(e){this.setValue(e)}get value(){return this.variable.value}setValue(e,t=!0){this.snapIncrement>0&&(e=Math.round(e/this.snapIncrement)*this.snapIncrement),e<this.minValue?e=this.minValue:e>this.maxValue&&(e=this.maxValue),this.variable.setValue(e,t)}onThemeUpdated(e=null){super.onThemeUpdated(e),e===null?(this._layoutDirty=!0,this._dirty=!0):e==="sliderThickness"||e==="sliderMinLength"?(this._layoutDirty=!0,this._dirty=!0):(e==="accentFill"||e==="primaryFill"||e==="backgroundFill")&&(this._dirty=!0)}handleEvent(e,t){if(e instanceof S)return null;let i=this.x+this.offsetX,r=this.y+this.offsetY;if(this.clickHelper.handleClickEvent(e,t,[i,i+this.actualWidth,r,r+this.actualHeight]),(this.clickHelper.clickStateChanged&&this.clickHelper.wasClick||this.clickHelper.clickState==T.Hold)&&this.clickHelper.pointerPos!==null){let n=this.clickHelper.pointerPos[0];this.value=this.minValue+n*(this.maxValue-this.minValue)}return this.clickHelper.clickStateChanged&&(this._dirty=!0),this}handlePostLayoutUpdate(e){this.variable.dirty&&(this._dirty=!0)}handleResolveDimensions(e,t,i,r){let n=this.sliderThickness,s=this.sliderMinLength;this.vertical?(r!=1/0?this.height=r:this.height=Math.max(s,i),this.actualHeight=this.height,this.offsetY=0,this.width=Math.min(Math.max(n,e),t),this.actualWidth=Math.min(this.width,n),this.offsetX=(this.width-this.actualWidth)/2):(t!=1/0?this.width=t:this.width=Math.max(s,e),this.actualWidth=this.width,this.offsetX=0,this.height=Math.min(Math.max(n,i),r),this.actualHeight=Math.min(this.height,n),this.offsetY=(this.height-this.actualHeight)/2)}handlePainting(e,t){let i=this.x+this.offsetX,r=this.y+this.offsetY;this.clickHelper.clickState===T.Hover||this.clickHelper.clickState===T.Hold?e.fillStyle=this.accentFill:e.fillStyle=this.primaryFill;let n=this.actualWidth*(this.value-this.minValue)/(this.maxValue-this.minValue);e.fillRect(i,r,n,this.actualHeight),e.fillStyle=this.backgroundFill;let s=this.actualWidth-n;e.fillRect(i+n,r,s,this.actualHeight)}};l(Ct,"Slider");var St=class extends te{constructor(e,t){let i=U({},t);i.containerAlignment={horizontal:x.Center,vertical:x.Stretch};super(e,i)}};l(St,"TextMargin");var Dt=class extends be{constructor(e,t){super(e);this.scopeTheme=t}set inheritedTheme(e){super.inheritedTheme=this.scopeTheme}get inheritedTheme(){return this.scopeTheme}};l(Dt,"ThemeScope");export{x as Alignment,xt as AltKey,le as ArtificialConstraint,Ue as BackspaceKey,J as BaseContainer,D as BaseTheme,Pt as BasicTextInput,$ as BasicVirtualKey,ve as Button,_t as Center,Qe as Checkbox,B as ClickHelper,T as ClickState,Ye as Column,te as Container,Tt as ControlKey,pt as DOMKeyboardDriver,gt as DOMPointerDriver,Ke as DOMRoot,ut as DOMVirtualKeyboardRoot,yt as DebugTheme,Ki as DefaultTextInputHandler,Xt as DefaultTextValidator,Ge as EnterKey,Oe as EscapeKey,j as Event,We as FilledButton,Q as FlexAlignment,Ks as FloatValidator,f as FocusType,Ie as GlyphVirtualKey,ne as Icon,wt as IconButton,Bs as IntValidator,we as KeyEvent,ie as KeyPress,ke as KeyRelease,Xe as KeyboardDriver,ae as Label,kt as LabelledCheckbox,W as Leave,Hs as MakeCompositeValidator,vt as MakeDefaultTextValidatorWithCallback,Os as MakeRangeValidator,_e as Margin,ue as ModifierEvent,q as MultiContainer,He as MultiParent,pe as Parent,be as PassthroughWidget,ye as PointerButtonEvent,Fe as PointerDriver,k as PointerEvent,N as PointerHint,z as PointerMove,M as PointerPress,A as PointerRelease,S as PointerWheel,bt as RayPointerDriver,ge as Root,Te as Row,Ft as ScrollableViewportWidget,Y as ScrollbarMode,$e as ShiftKey,Z as SingleParent,Ct as Slider,Ne as SpaceKey,ze as Spacing,me as TextAlignMode,xe as TextButton,C as TextHelper,he as TextInput,St as TextMargin,ee as TextPasteEvent,R as Theme,Dt as ThemeScope,re as Variable,oe as Viewport,Ce as ViewportWidget,G as VirtualKey,Be as VirtualKeyRow,Pe as VirtualKeyboard,ct as VirtualKeyboardRoot,w as Widget,ce as WrapMode,Re as defaultVirtualKeyboardTemplate,ot as flagArrayField,rt as flagField,Je as getPointerEventNormPos,Vi as injectDebugCode,I as injectRandomFillFeature,Ae as injectTraceFeature,Ve as injectWatchflagFeature,fe as isDebugFeatureEnabled,lt as layoutArrayField,O as layoutField,It as listDebugFeatures,Ee as measureTextDims,Ht as multiFlagArrayField,H as multiFlagField,Me as paintArrayField,nt as paintField,at as paintLayoutArrayField,oi as paintLayoutField,qe as roundToPower2,Kt as toggleDebugFeature,st as watchArrayField,Le as watchField};
  //# sourceMappingURL=index.esm.js.map
  