UNPKG

@scidian/osui

Version:

Lightweight JavaScript UI library.

9 lines 192 kB
/** * @description Osui * @about Lightweight JavaScript UI library. * @author Stephens Nunnally <@stevinz> * @license MIT - Copyright (c) 2021 Stephens Nunnally * @source https://github.com/scidian/osui * @version v0.1.19 */ const e="data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8' standalone='no'%3f%3e%3c!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg width='100%25' height='100%25' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' xml:space='preserve' xmlns:serif='http://www.serif.com/' style='fill-rule:evenodd%3bclip-rule:evenodd%3bstroke-linejoin:round%3bstroke-miterlimit:2%3b'%3e%3cpath d='M373.189%2c648.684c-0%2c-0 -237.09%2c-138.996 -258.087%2c-117.999c-20.997%2c20.997 212.331%2c288.419 212.331%2c288.419c1.975%2c3.009 4.284%2c5.857 6.926%2c8.499c10.698%2c10.698 24.796%2c15.945 38.83%2c15.71c14.035%2c0.235 28.132%2c-5.012 38.831%2c-15.71c2.641%2c-2.642 4.95%2c-5.49 6.926%2c-8.499c-0%2c-0 423.255%2c-489.7 496.91%2c-611.246c9.004%2c-14.859 -15.991%2c-40.415 -34.446%2c-27.458c-108.024%2c75.837 -508.221%2c468.284 -508.221%2c468.284Z' style='fill:%23ebebeb%3b'/%3e%3c/svg%3e",t="data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8' standalone='no'%3f%3e%3c!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg width='100%25' height='100%25' viewBox='0 0 512 512' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' xml:space='preserve' xmlns:serif='http://www.serif.com/' style='fill-rule:evenodd%3bclip-rule:evenodd%3bstroke-linejoin:round%3bstroke-miterlimit:2%3b'%3e%3cpath d='M386.576%2c386.574c-12.567%2c12.568 -33.514%2c12.568 -46.08%2c0.002l-84.496%2c-84.498l-84.497%2c84.498c-12.566%2c12.566 -33.512%2c12.566 -46.079%2c-0c-12.566%2c-12.568 -12.566%2c-33.513 0%2c-46.079l84.497%2c-84.496l-84.497%2c-84.498c-12.566%2c-12.566 -12.566%2c-33.511 0%2c-46.079c12.567%2c-12.565 33.513%2c-12.565 46.079%2c-0l84.496%2c84.498l84.497%2c-84.498c12.566%2c-12.565 33.512%2c-12.565 46.079%2c-0c12.566%2c12.568 12.566%2c33.513 0%2c46.079l-84.497%2c84.496l84.498%2c84.498c12.565%2c12.566 12.565%2c33.51 0%2c46.077Z' style='fill:white%3b'/%3e%3c/svg%3e",n="data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8' standalone='no'%3f%3e%3c!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg width='100%25' height='100%25' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' xml:space='preserve' xmlns:serif='http://www.serif.com/' style='fill-rule:evenodd%3bclip-rule:evenodd%3bstroke-linejoin:round%3bstroke-miterlimit:2%3b'%3e%3c/svg%3e",i="data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8' standalone='no'%3f%3e%3c!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg width='100%25' height='100%25' viewBox='0 0 512 512' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' xml:space='preserve' xmlns:serif='http://www.serif.com/' style='fill-rule:evenodd%3bclip-rule:evenodd%3bstroke-linejoin:round%3bstroke-miterlimit:2%3b'%3e%3cpath d='M202.677%2c396c-6.857%2c0 -13.038%2c-4.13 -15.662%2c-10.465c-2.624%2c-6.335 -1.174%2c-13.626 3.674%2c-18.474c44.911%2c-44.911 130.904%2c-130.904 176.025%2c-176.025c4.906%2c-4.906 12.285%2c-6.374 18.696%2c-3.719c6.41%2c2.656 10.59%2c8.911 10.59%2c15.85c0%2c45.295 0%2c117.022 0%2c159.048c0%2c18.659 -15.126%2c33.785 -33.785%2c33.785l-159.538%2c0Z' style='fill:white%3b'/%3e%3cpath d='M303.059%2c116c6.881%2c-0 13.084%2c4.145 15.717%2c10.502c2.634%2c6.357 1.178%2c13.674 -3.687%2c18.54c-43.748%2c43.748 -126.088%2c126.087 -169.914%2c169.913c-4.888%2c4.888 -12.239%2c6.35 -18.625%2c3.705c-6.386%2c-2.645 -10.55%2c-8.877 -10.55%2c-15.789c-0%2c-43.783 -0%2c-112.154 -0%2c-152.928c-0%2c-18.746 15.197%2c-33.943 33.943%2c-33.943l153.116%2c-0Z' style='fill:white%3b'/%3e%3c/svg%3e",s=25,o="0.3em",r={DARK:0,MID:1,LIGHT:2,FADED:3},a={SHADOW:"shadow",DARKNESS:"darkness",BACKGROUND_DARK:"background-dark",BACKGROUND_LIGHT:"background-light",BUTTON_DARK:"button-dark",BUTTON_LIGHT:"button-light",BLACKLIGHT:"blacklight",DARKLIGHT:"darklight",MIDLIGHT:"midlight",HIGHLIGHT:"highlight",TEXT_DARK:"text-dark",TEXT:"text",TEXT_LIGHT:"text-light",ICON_DARK:"icon-dark",ICON:"icon",ICON_LIGHT:"icon-light",COMPLEMENT:"complement",TRIADIC1:"triadic1",TRIADIC2:"triadic2",TRIADIC3:"triadic3",TRIADIC4:"triadic4"},l={TOP:"top",BOTTOM:"bottom",LEFT:"left",RIGHT:"right",TOP_LEFT:"top-left",TOP_RIGHT:"top-right",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right"},d={STRAIGHT:"straight",CURVE:"curve",ZIGZAG:"zigzag"},h={LINES:"lines",DOTS:"dots"},c={INPUT:"input",OUTPUT:"output"};class u{static getVariable(e,t){return(e=String(e)).startsWith("--")||(e="--"+e),t&&t.isElement&&(t=t.dom),t&&t instanceof HTMLElement||(t=document.querySelector(":root")),getComputedStyle(t).getPropertyValue(e)}static setVariable(e,t,n){(e=String(e)).startsWith("--")||(e="--"+e),n&&n.isElement&&(n=n.dom),n&&n instanceof HTMLElement||(n=document.querySelector(":root")),n.style.setProperty(e,t)}static baseSize(){return parseFloat(getComputedStyle(document.querySelector(":root")).fontSize)}static fontSize(e=document.body){return parseFloat(getComputedStyle(e).fontSize)}static guiScale(e=document.body){return u.fontSize(e)/u.baseSize()}static getTextWidth(e,t){const n=document.createElement("canvas").getContext("2d");return n.font=t,n.measureText(e).width}static getFontCssFromElement(e=document.body){return`${getComputedStyle(e).fontWeight||"normal"} ${getComputedStyle(e).fontSize||"16px"} ${getComputedStyle(e).fontFamily||"Arial"}`}static parentElementWithCSS(e,t,n){const i=Array.isArray(n)?n:[n];t=t.replace(/([A-Z])/g,"-$1").toLowerCase(),e.isElement&&e.dom&&(e=e.dom);let s=e.parentElement;for(;s;){const e=(s.ownerDocument||document).defaultView.getComputedStyle(s,null).getPropertyValue(t);if(e)for(let t=0;t<i.length;t++){if(e==i[t])return s}s=s.parentElement}}static parseSize(e){return"string"==typeof e&&(e.includes("%")||e.includes("px")||e.includes("em")||e.includes("rem")||e.includes("ch")||e.includes("ex")||e.includes("cap")||e.includes("vw")||e.includes("vh")||e.includes("vmin")||e.includes("vmax"))?e:parseInt(e)+"px"}static toEm(e,t=document.body){const n=u.parseSize(e);return n.includes("px")?parseFloat(n)/10/u.guiScale(t)+"em":n.includes("em")?n:(console.warn(`Css.toEm: Could not convert to em, unit passed in: ${e}`),size)}static toPx(e,t=document.body,n="w"){const i=u.parseSize(e);if(i.includes("%")){if(t){const i=u.parentElementWithCSS(t,"position",["relative","absolute"]);if(i)return"w"===n?.01*parseFloat(e)*i.offsetWidth+"px":.01*parseFloat(e)*i.offsetHeight+"px"}}else{if(i.includes("px"))return i;if(i.includes("rem"))return parseInt(10*parseFloat(e))+"px";if(i.includes("em"))return parseInt(10*parseFloat(e)*u.guiScale(t))+"px"}return console.warn(`Css.toPx: Could not convert to pixels, unit passed in: ${e}`),parseInt(i)+"px"}}const g={LEFT:"left",CENTER:"center",MIDDLE:"center",RIGHT:"right"},m={LEFT:"left",RIGHT:"right"},p={OVER:"over",UNDER:"under"};class b{static getLeft(e){return e.getBoundingClientRect().left}static getTop(e){return e.getBoundingClientRect().top}static getWidth(e){return e.offsetWidth}static getHeight(e){return e.offsetHeight}static popOver(e,t,n=g.LEFT,i=0,s=0,o=m.RIGHT){return b.popOverUnder(e,t,p.OVER,n,i,s,o)}static popUnder(e,t,n=g.LEFT,i=0,s=0,o=m.RIGHT){return b.popOverUnder(e,t,p.UNDER,n,i,s,o)}static popOverUnder(e,t,n=p.UNDER,i=g.LEFT,s=0,o=0,r=m.RIGHT){let a=window.innerWidth-4,l=window.innerHeight-4;s=s?parseInt(u.toPx(s),10):0,o=o?parseInt(u.toPx(o),10):0;let d=b.getLeft(t)+s;if(i===g.CENTER){d=b.getLeft(t)+(b.getWidth(t)-b.getWidth(e))/2+s}else if(i===g.RIGHT){d=b.getLeft(t)+(b.getWidth(t)-b.getWidth(e))+s}r===m.LEFT&&(a=b.getLeft(t)+b.getWidth(t));let h=d+b.getWidth(e);h>a&&(d-=h-a),d<4&&(d=4);let c=b.getTop(t)+b.getHeight(t)+o,v=b.getTop(t)-b.getHeight(e)-o,f=c+b.getHeight(e);f>l&&(n=p.OVER),v<4&&(n=p.UNDER);let w=n===p.UNDER?c:v;return n===p.UNDER&&(f=w+b.getHeight(e),f>l&&(w=l-b.getHeight(e),w<4&&(w=4))),e.style.left=u.toPx(d),e.style.top=u.toPx(w),n}}class v{static get NAMES(){return _}constructor(e=16777215,t,n,i=""){this.isColor=!0,this.isIris=!0,this.type="Color",this.r=1,this.g=1,this.b=1,this.set(e,t,n,i)}copy(e){return this.set(e)}clone(){return new this.constructor(this.r,this.g,this.b)}set(e=0,t,n,i=""){if(0===arguments.length)return this.set(0);if(null==e||Number.isNaN(e))(t||n)&&console.warn(`Iris: Passed some valid arguments, however 'r' was ${e}`);else if(void 0===t&&void 0===n){let n=e;if("number"==typeof n||0===n)return this.setHex(n);if(n&&(void 0!==(s=n).r&&void 0!==s.g&&void 0!==s.b))return this.setRGBF(n.r,n.g,n.b);if(n&&f(n))return this.setHSL(360*n.h,n.s,n.l);if(n&&w(n))return this.setRYB(255*n.r,255*n.y,255*n.b);if(Array.isArray(n)&&n.length>2){const e=null!=t&&!Number.isNaN(t)&&t>0?t:0;return this.setRGBF(n[e],n[e+1],n[e+2])}if("string"==typeof n)return this.setStyle(n)}else switch(i){case"rgb":return this.setRGB(e,t,n);case"hsl":return this.setHSL(e,t,n);case"ryb":return this.setRYB(e,t,n);default:return this.setRGBF(e,t,n)}var s;return this}setColorName(e){const t=_[e.toLowerCase()];return t?this.setHex(t):(console.warn(`Iris: Unknown color ${e}`),this)}setHex(e){((e=Math.floor(e))>16777215||e<0)&&(console.warn(`Iris: Given decimal outside of range, value was ${e}`),e=x(e,0,16777215));const t=(16711680&e)>>16,n=(65280&e)>>8,i=255&e;return this.setRGB(t,n,i)}setHSL(e,t,n){e=z(e,0,360),t=x(t,0,1),n=x(n,0,1);let i=(1-Math.abs(2*n-1))*t,s=i*(1-Math.abs(e/60%2-1)),o=n-i/2,r=0,a=0,l=0;return e<60?(r=i,a=s,l=0):60<=e&&e<120?(r=s,a=i,l=0):120<=e&&e<180?(r=0,a=i,l=s):180<=e&&e<240?(r=0,a=s,l=i):240<=e&&e<300?(r=s,a=0,l=i):300<=e&&(r=i,a=0,l=s),this.setRGBF(r+o,a+o,l+o),this}setRandom(){return this.setRGBF(Math.random(),Math.random(),Math.random())}setRGB(e,t,n){return this.setRGBF(e/255,t/255,n/255)}setRGBF(e,t,n){return this.r=x(e,0,1),this.g=x(t,0,1),this.b=x(n,0,1),this}setRYB(e,t,n){const i=G(x(e,0,255),x(t,0,255),x(n,0,255),255,W.RYB_TO_RGB);return this.setHex(i)}setScalar(e){return this.setRGB(e,e,e)}setScalarF(e){return this.setRGBF(e,e,e)}setStyle(e){let t;if(t=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const n=t[1],i=t[2];switch(n){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const t=Math.min(255,parseInt(e[1],10)),n=Math.min(255,parseInt(e[2],10)),i=Math.min(255,parseInt(e[3],10));return this.setRGB(t,n,i)}if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const t=Math.min(100,parseInt(e[1],10))/100,n=Math.min(100,parseInt(e[2],10))/100,i=Math.min(100,parseInt(e[3],10))/100;return this.setRGBF(t,n,i)}break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const t=parseFloat(e[1]),n=parseInt(e[2],10)/100,i=parseInt(e[3],10)/100;return this.setHSL(t,n,i)}}}else if(t=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=t[1],n=e.length;if(3===n){const t=parseInt(e.charAt(0)+e.charAt(0),16),n=parseInt(e.charAt(1)+e.charAt(1),16),i=parseInt(e.charAt(2)+e.charAt(2),16);return this.setRGB(t,n,i)}if(6===n){const t=parseInt(e.charAt(0)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(3),16),i=parseInt(e.charAt(4)+e.charAt(5),16);return this.setRGB(t,n,i)}}return e&&e.length>0?this.setColorName(e):this}cssString(e){return"rgb("+this.rgbString(e)+")"}hex(){return(this.red()<<16)+(this.green()<<8)+this.blue()}hexString(e){return e&&this.set(e),v.hexString(this.hex())}static hexString(e=0){return O.set(e),"#"+("000000"+(O.hex()>>>0).toString(16)).slice(-6)}static randomHex(){return F.setRandom().hex()}rgbString(e){const t=this.red()+", "+this.green()+", "+this.blue();return null!=e?String(t+", "+e):t}toJSON(){return this.hex()}getHSL(e){if(!e||!f(e))return{h:E(this.hex()),s:T(this.hex()),l:L(this.hex())};e.h=E(this.hex()),e.s=T(this.hex()),e.l=L(this.hex())}getRGB(e){if(!e||!f(e))return{r:this.r,g:this.g,b:this.b};e.r=this.r,e.g=this.g,e.b=this.b}getRYB(e){let t=G(this.r,this.g,this.b,1,W.RGB_TO_RYB);return e&&w(e)?(e.r=y(t),e.y=k(t),e.b=C(t),e):{r:y(t),y:k(t),b:C(t)}}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}red(){return x(Math.floor(255*this.r),0,255)}green(){return x(Math.floor(255*this.g),0,255)}blue(){return x(Math.floor(255*this.b),0,255)}redF(){return this.r}greenF(){return this.g}blueF(){return this.b}hue(){return S(this.hex())}saturation(){return T(this.hex())}lightness(){return L(this.hex())}hueF(){return E(this.hex())}hueRYB(){for(let e=1;e<U.length;e++)if(U[e]>this.hue())return e-2}add(e){return e.isColor||console.warn("Iris: add() was not called with a 'Color' object"),this.setRGBF(this.r+e.r,this.g+e.g,this.b+e.b)}addScalar(e){return this.setRGB(this.red()+e,this.green()+e,this.blue()+e)}addScalarF(e){return this.setRGBF(this.r+e,this.g+e,this.b+e)}brighten(e=.5){let t=S(this.hex()),n=T(this.hex()),i=L(this.hex());return i+=(1-i)*e,this.setHSL(t,n,i),this}darken(e=.5){let t=S(this.hex()),n=T(this.hex()),i=L(this.hex())*e;return this.setHSL(t,n,i)}greyscale(e=1,t="luminosity"){return this.grayscale(e,t)}grayscale(e=1,t="luminosity"){let n=0;"luminosity"===t&&(n=.21*this.r+.72*this.g+.07*this.b),n=(this.r+this.g+this.b)/3,e=x(e,0,1);const i=this.r*(1-e)+e*n,s=this.g*(1-e)+e*n,o=this.b*(1-e)+e*n;return this.setRGBF(i,s,o)}hslOffset(e,t,n){return this.setHSL(this.hue()+e,this.saturation()+t,this.lightness()+n)}mix(e,t=.5){e.isColor||console.warn("Iris: mix() was not called with a 'Color' object"),t=x(t,0,1);const n=this.r*(1-t)+t*e.r,i=this.g*(1-t)+t*e.g,s=this.b*(1-t)+t*e.b;return this.setRGBF(n,i,s)}multiply(e){return e.isColor||console.warn("Iris: multiply() was not called with a 'Color' object"),this.setRGBF(this.r*e.r,this.g*e.g,this.b*e.b)}multiplyScalar(e){return this.setRGBF(this.r*e,this.g*e,this.b*e)}rgbComplementary(){return this.rgbRotateHue(180)}rgbRotateHue(e=90){const t=z(this.hue()+e);return this.setHSL(t,this.saturation(),this.lightness())}rybAdjust(){return this.setHSL(S(V(this.hue(),$.RYB)),this.saturation(),this.lightness())}rybComplementary(){return this.rybRotateHue(180)}rybRotateHue(e=90){const t=z(this.hueRYB()+e);return this.setHSL(S(V(t,$.RYB)),this.saturation(),this.lightness())}subtract(e){return e.isColor||console.warn("Iris: subtract() was not called with a 'Color' object"),this.setRGBF(this.r-e.r,this.g-e.g,this.b-e.b)}equals(e){return e.isColor||console.warn("Iris: equals() was not called with a 'Color' object"),I(this.r,e.r)&&I(this.g,e.g)&&I(this.b,e.b)}isEqual(e){return this.equals(e)}isDark(){const e=this.hue(),t=this.lightness();return t<.6&&(e>=210||e<=27)||t<=.32}isLight(){return!this.isDark()}}function f(e){return void 0!==e.h&&void 0!==e.s&&void 0!==e.l}function w(e){return void 0!==e.r&&void 0!==e.y&&void 0!==e.b}function x(e,t,n){return Math.max(t,Math.min(n,e))}function y(e){return function(e){return x((16711680&e)>>16,0,255)}(e)/255}function k(e){return function(e){return x((65280&e)>>8,0,255)}(e)/255}function C(e){return function(e){return x(255&e,0,255)}(e)/255}function S(e){return N(e,"h")}function E(e){return S(e)/360}function T(e){return N(e,"s")}function L(e){return N(e,"l")}function I(e,t,n=.0015){return e<t+n&&e>t-n}function z(e,t=0,n=360){for(;e>=n;)e-=n-t;for(;e<t;)e+=n-t;return e}let R,D,M,A;function N(e,t="h"){if(e!==R){if(null==e)return 0;const t=y(e),n=k(e),i=C(e),s=Math.max(t,n,i),o=Math.min(t,n,i),r=s-o;if(A=(s+o)/2,0===r)D=M=0;else{switch(M=A<=.5?r/(s+o):r/(2-s-o),s){case t:D=(n-i)/r+(n<i?6:0);break;case n:D=(i-t)/r+2;break;case i:D=(t-n)/r+4}D=Math.round(60*D),D<0&&(D+=360)}R=e}switch(t){case"h":return D;case"s":return M;case"l":return A;default:console.warn(`Iris: Unknown channel (${t}) requested in hsl()`)}return 0}const H=new v,P=new v,B=new v,F=new v,O=new v;function V(e,t=$.RYB){let n=360/t.length,i=n,s=0;for(let o=0;o<t.length;o++){if(e<i){let o=(i-e)/n;return P.set(t[s+1]),P.mix(B.set(t[s]),o).hex()}i+=n,s+=1}}function G(e,t,n,i=255,s=W.RYB_TO_RGB){e=x(e/i,0,1),t=x(t/i,0,1),n=x(n/i,0,1);const o=s[0],r=s[1],a=s[2],l=s[3],d=s[4],h=s[5],c=s[6],u=s[7],g=1-e,m=1-t,p=1-n,b=g*m*p,v=g*m*n,f=g*t*p,w=e*m*p,y=g*t*n,k=e*m*n,C=e*t*p,S=e*t*n,E=b*o[0]+v*r[0]+f*a[0]+w*l[0]+y*d[0]+k*h[0]+C*c[0]+S*u[0],T=b*o[1]+v*r[1]+f*a[1]+w*l[1]+y*d[1]+k*h[1]+C*c[1]+S*u[1],L=b*o[2]+v*r[2]+f*a[2]+w*l[2]+y*d[2]+k*h[2]+C*c[2]+S*u[2];return H.set(E,T,L,"gl").hex()}const W={RYB_TO_RGB:[[1,1,1],[.163,.373,.6],[1,1,0],[1,0,0],[0,.66,.2],[.5,0,.5],[1,.5,0],[0,0,0]],RGB_TO_RYB:[[1,1,1],[0,0,1],[0,1,.483],[1,0,0],[0,.053,.21],[.309,0,.469],[0,1,0],[0,0,0]]},$={RYB:[16711680,16730368,16741376,16749056,16755200,16760576,16765696,16771072,16776960,13432320,10481152,6808320,52224,44900,39321,745892,1196203,1776563,3740847,5443501,7408042,10879142,13434996,14942277,16711680]},U=[0,1,2,3,5,6,7,8,9,10,11,13,14,15,16,17,18,19,19,20,21,21,22,23,23,24,25,25,26,27,27,28,28,29,29,30,30,31,31,32,32,32,33,33,34,34,35,35,35,36,36,37,37,37,38,38,38,39,39,40,40,40,41,41,41,42,42,42,43,43,43,44,44,44,45,45,45,46,46,46,47,47,47,47,48,48,48,49,49,49,50,50,50,51,51,51,52,52,52,53,53,53,54,54,54,55,55,55,56,56,56,57,57,57,58,58,59,59,59,60,60,61,61,62,63,63,64,65,65,66,67,68,68,69,70,70,71,72,72,73,73,74,75,75,76,77,77,78,79,79,80,81,82,82,83,84,85,86,87,88,88,89,90,91,92,93,95,96,98,100,102,104,105,107,109,111,113,115,116,118,120,122,125,127,129,131,134,136,138,141,143,145,147,150,152,154,156,158,159,161,163,165,166,168,170,171,173,175,177,178,180,182,184,185,187,189,191,192,194,196,198,199,201,203,205,206,207,208,209,210,212,213,214,215,216,217,218,219,220,221,222,223,224,226,227,228,229,230,232,233,234,235,236,238,239,240,241,242,243,244,245,246,247,248,249,250,251,251,252,253,254,255,256,257,257,258,259,260,260,261,262,263,264,264,265,266,267,268,268,269,270,271,272,273,274,274,275,276,277,278,279,280,282,283,284,286,287,289,290,292,293,294,296,297,299,300,302,303,305,307,309,310,312,314,316,317,319,321,323,324,326,327,328,329,330,331,332,333,334,336,337,338,339,340,341,342,343,344,345,347,348,349,350,352,353,354,355,356,358,359,999],_={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,transparent:0,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},K=new v,Y=new v,X=new v,j=new v,q=new v,Z=new v,J=new v,Q=new v,ee=new v;let te=r.DARK,ne=46255,ie=0,se=0;class oe{static changeBackground(e){null!=e&&(te=e,oe.updateCSS())}static changeColor(e,t,n){null!=e&&(ne=K.set(e).hex(),ie=void 0!==t?t:ie,se=void 0!==n?n:se,Y.set(e),X.copy(Y).brighten(),j.copy(Y).darken(),q.copy(Y).rybRotateHue(180).brighten(.2),Z.copy(Y).rybRotateHue(120).brighten(.2),J.copy(q).rybRotateHue(120).brighten(.2),Q.copy(Y).rybRotateHue(90).brighten(.2),ee.copy(q).rybRotateHue(90).brighten(.2),oe.updateCSS())}static updateCSS(){u.setVariable("--shadow",K.set(oe.color(a.SHADOW)).rgbString()),u.setVariable("--darkness",K.set(oe.color(a.DARKNESS)).rgbString()),u.setVariable("--background-dark",K.set(oe.color(a.BACKGROUND_DARK)).rgbString()),u.setVariable("--background-light",K.set(oe.color(a.BACKGROUND_LIGHT)).rgbString()),u.setVariable("--button-dark",K.set(oe.color(a.BUTTON_DARK)).rgbString()),u.setVariable("--button-light",K.set(oe.color(a.BUTTON_LIGHT)).rgbString()),u.setVariable("--text-dark",K.set(oe.color(a.TEXT_DARK)).rgbString()),u.setVariable("--text",K.set(oe.color(a.TEXT)).rgbString()),u.setVariable("--text-light",K.set(oe.color(a.TEXT_LIGHT)).rgbString()),u.setVariable("--blacklight",K.set(oe.color(a.BLACKLIGHT)).rgbString()),u.setVariable("--darklight",K.set(oe.color(a.DARKLIGHT)).rgbString()),u.setVariable("--midlight",K.set(oe.color(a.MIDLIGHT)).rgbString()),u.setVariable("--highlight",K.set(oe.color(a.HIGHLIGHT)).rgbString()),u.setVariable("--icon-dark",K.set(oe.color(a.ICON_DARK)).rgbString()),u.setVariable("--icon",K.set(oe.color(a.ICON)).rgbString()),u.setVariable("--icon-light",K.set(oe.color(a.ICON_LIGHT)).rgbString()),u.setVariable("--complement",K.set(oe.color(a.COMPLEMENT)).rgbString()),u.setVariable("--triadic1",K.set(oe.color(a.TRIADIC1)).rgbString()),u.setVariable("--triadic2",K.set(oe.color(a.TRIADIC2)).rgbString()),u.setVariable("--triadic3",K.set(oe.color(a.TRIADIC3)).rgbString()),u.setVariable("--triadic4",K.set(oe.color(a.TRIADIC4)).rgbString()),u.setVariable("--bright",te==r.LIGHT?"0":"1");const e=K.set(46255).hue(),t=K.set(oe.color(a.ICON,!0)).hue()-e+"deg";u.setVariable("--rotate-hue",t)}static color(e,t=!1){K.set(0);let n=ie,i=se,s=0;switch(te){case r.DARK:break;case r.MID:n*=.2,s=.2;break;case r.LIGHT:break;case r.FADED:n*=.1,s=.4}if(te==r.LIGHT)switch(e){case a.SHADOW:K.set(140,140,140,"rgb");break;case a.BACKGROUND_DARK:K.set(180,180,180,"rgb");break;case a.BACKGROUND_LIGHT:K.set(190,190,190,"rgb");break;case a.BUTTON_DARK:K.set(200,200,200,"rgb");break;case a.BUTTON_LIGHT:K.set(210,210,210,"rgb");break;case a.TEXT_DARK:K.set(80,80,80,"rgb");break;case a.TEXT:K.set(50,50,50,"rgb");break;case a.TEXT_LIGHT:K.set(25,25,25,"rgb");break;case a.BLACKLIGHT:K.set(255,255,255,"rgb");break;case a.DARKLIGHT:K.set(200,200,200,"rgb");break;case a.MIDLIGHT:K.set(220,220,220,"rgb");break;case a.HIGHLIGHT:K.set(0,0,0,"rgb")}else{switch(e){case a.SHADOW:K.set(0,0,0,"rgb"),n=0;break;case a.BACKGROUND_DARK:K.set(24,24,24,"rgb");break;case a.BACKGROUND_LIGHT:K.set(32,32,32,"rgb");break;case a.BUTTON_DARK:K.set(40,40,40,"rgb");break;case a.BUTTON_LIGHT:K.set(60,60,60,"rgb");break;case a.TEXT_DARK:K.set(100,100,100,"rgb");break;case a.TEXT:K.set(190,190,190,"rgb");break;case a.TEXT_LIGHT:K.set(225,225,225,"rgb");break;case a.BLACKLIGHT:K.set(0,0,0,"rgb"),s=0;break;case a.DARKLIGHT:K.set(8,8,8,"rgb"),s=0;break;case a.MIDLIGHT:K.set(85,85,85,"rgb");break;case a.HIGHLIGHT:K.set(255,255,255,"rgb")}te==r.MID&&e==a.DARKLIGHT&&K.set(64,64,64,"rgb")}if(e===a.DARKNESS)switch(te){case r.DARK:K.set(0,0,0,"rgb");break;case r.MID:K.set(64,64,64,"rgb");break;case r.LIGHT:K.set(128,128,128,"rgb");break;case r.FADED:K.set(0,0,0,"rgb")}switch(e){case a.ICON_DARK:K.copy(j);break;case a.ICON:K.copy(Y);break;case a.ICON_LIGHT:K.copy(X);break;case a.COMPLEMENT:K.copy(q);break;case a.TRIADIC1:K.copy(Z);break;case a.TRIADIC2:K.copy(J);break;case a.TRIADIC3:K.copy(Q);break;case a.TRIADIC4:K.copy(ee)}switch(e){case a.COMPLEMENT:case a.TRIADIC1:case a.TRIADIC2:case a.TRIADIC3:case a.TRIADIC4:i=0;case a.ICON_DARK:case a.ICON:case a.ICON_LIGHT:n=0,s=0}return 0!==n&&K.mix(Y,n),0!==s&&K.brighten(s),0===i||t||K.hslOffset(0,i,0),K.hex()}}class re{constructor(e){const t=this;this.isElement=!0,this.dom=e,this.name=void 0,this.contents=function(){return t},this.children=[],this.parent=void 0}destroy(){return de(this,!0),this}add(){for(let e=0;e<arguments.length;e++){const t=arguments[e];ae(this.contents(),t)}return this}addToSelf(){for(let e=0;e<arguments.length;e++){ae(this,arguments[e])}return this}clearContents(){return de(this.contents(),!1),this}remove(){for(let e=0;e<arguments.length;e++){const t=arguments[e];let n=he(this.contents(),t);n||(n=he(this,t))}return this}setClass(e){return this.dom.className=e,this}addClass(){for(let e=0;e<arguments.length;e++){const t=arguments[e];this.dom.classList.add(t)}return this}hasClass(e){return this.dom.classList.contains(e)}hasClassWithString(e){e=String(e).toLowerCase();const t=[...this.dom.classList];for(let n=0;n<t.length;n++){if(t[n].toLowerCase().includes(e))return!0}return!1}removeClass(){for(let e=0;e<arguments.length;e++){const t=arguments[e];this.dom.classList.remove(t)}return this}setId(e){return this.dom.id=e,void 0===this.name&&(this.name=e),this}getId(){return this.dom.id}setName(e){return this.name=e,this}getName(){return void 0===this.name?"No name":this.name}setAttribute(e,t){this.dom.setAttribute(e,t)}setDisabled(e=!0){return e?this.addClass("osui-disabled"):this.removeClass("osui-disabled"),this.dom.disabled=e,this}selectable(e){return e?this.removeClass("osui-unselectable"):this.addClass("osui-unselectable"),this}hide(e=!0){this.setStyle("display","none"),e&&this.dom.dispatchEvent(new Event("hidden"))}display(e=!0){this.setStyle("display",""),e&&this.dom.dispatchEvent(new Event("displayed"))}isDisplayed(){return"none"!=getComputedStyle(this.dom).display}isHidden(){return"none"==getComputedStyle(this.dom).display}allowFocus(){this.dom.tabIndex=0}focus(){this.dom.focus()}blur(){this.dom.blur()}setTextContent(e){return null!=e&&(this.contents().dom.textContent=e),this}getTextContent(){return this.contents().dom.textContent}setInnerHtml(e){return null==e&&(e=""),"function"==typeof this.contents().dom.setHTML?this.contents().dom.setHTML(e):this.contents().dom.innerHTML=e,this}getInnerHtml(){return this.contents().dom.innerHTML}setStyle(){for(let e=0,t=arguments.length;e<t;e+=2){const t=arguments[e],n=arguments[e+1];this.dom.style[t]=n}return this}setContentsStyle(){for(let e=0,t=arguments.length;e<t;e+=2){const t=arguments[e],n=arguments[e+1];this.contents().dom.style[t]=n}return this}getLeft(){return this.dom.getBoundingClientRect().left}getTop(){return this.dom.getBoundingClientRect().top}getWidth(){return this.dom.getBoundingClientRect().width}getHeight(){return this.dom.getBoundingClientRect().height}traverse(e,t=!0){if(t&&e(this),this.children)for(let t=0;t<this.children.length;t++)this.children[t].traverse(e,!0)}}function ae(e,t){if(t)if(t.isElement){e.dom.appendChild(t.dom);let n=!1;for(let i=0;i<e.children.length;i++){if(e.children[i].dom.isSameNode(t.dom)){n=!0;break}}n||e.children.push(t),t.parent=e}else try{e.dom.appendChild(t)}catch(e){}}function le(e){if(e.children)for(let t=e.children.length-1;t>=0;t--){const n=e.children[t];de(n,!0);try{e.removeChild(n)}catch(e){}}}function de(e,t=!0){e&&(e.isElement?(!function(e){for(let t=0;t<e.children.length;t++)de(e.children[t],!0);e.children.length=0}(e),le(e.dom),t&&e.dom&&e.dom.dispatchEvent&&e.dom.dispatchEvent(new Event("destroy"))):(le(e),t&&e&&e.dispatchEvent&&e.dispatchEvent(new Event("destroy"))))}function he(e,t){if(e&&t){if(t.isElement&&e.isElement)for(let n=0;n<e.children.length;n++){e.children[n].dom.isSameNode(t.dom)&&(e.children.splice(n,1),t.parent=void 0)}de(t);try{return e.isElement?e.dom.removeChild(t.isElement?t.dom:t):e.removeChild(t.isElement?t.dom:t),!0}catch(e){return!1}}}["display","color","left","top","right","bottom","width","height"].forEach((function(e){const t="set"+e.substring(0,1).toUpperCase()+e.substring(1,e.length);re.prototype[t]=function(t){return this.setStyle(e,t),this}})),Object.defineProperties(re.prototype,{id:{get:function(){return this.getId()},set:function(e){this.setId(e)}}});["Focus","Blur","Change","Input","Wheel","KeyUp","KeyDown","Click","DblClick","ContextMenu","PointerDown","PointerMove","PointerUp","PointerEnter","PointerLeave","PointerOut","PointerOver","PointerCancel"].forEach((function(e){const t="on"+e;re.prototype[t]=function(n){const i=e.toLowerCase();if("function"!=typeof n)return console.warn(`${t} in ${this.name}: No callback function provided!`),this;const s=n.bind(this),o=this.dom;return o.addEventListener(i,s),o.addEventListener("destroy",(()=>o.removeEventListener(i,s)),{once:!0}),this}}));class ce extends re{constructor(e){super(document.createElement("button"));const t=this;function n(e){const n=new Event("hidetooltip",{bubbles:!0});t.dom.dispatchEvent(n)}this.setClass("osui-button"),this.dom.textContent=e??" ",this.attachedMenu=void 0,this.menuOffsetX=0,this.menuOffsetY=0,this.alignMenu=g.LEFT,this.overflowMenu=m.RIGHT,Object.defineProperty(this,"disabled",{get:function(){return!this.dom||this.dom.disabled},set:function(e){this.dom&&(this.dom.disabled=e)}}),this.dom.addEventListener("pointerdown",n),this.dom.addEventListener("destroy",(function(){t.dom.removeEventListener("pointerdown",n),t.attachedMenu&&t.detachMenu()}),{once:!0})}attachMenu(e,t=!1){const n=this;function i(t){t.stopPropagation(),t.preventDefault(),!1===n.hasClass("osui-selected")&&(n.addClass("osui-selected"),s(),setTimeout((()=>{n.dom&&e.showMenu(n.dom,!0)}),0)),document.dispatchEvent(new Event("closemenu"))}function s(){const t=b.popUnder(e.dom,n.dom,n.alignMenu,n.menuOffsetX,n.menuOffsetY,n.overflowMenu);e.removeClass("osui-slide-up"),e.removeClass("osui-slide-down"),e.addClass(t===p.UNDER?"osui-slide-down":"osui-slide-up")}if(t&&e.addClass("osui-popup-menu"),!1===e.hasClass("osui-menu"))return this;this.addClass("osui-menu-button"),this.attachedMenu=e,document.body.appendChild(e.dom),this.dom.addEventListener("pointerdown",i);new MutationObserver(((e,t)=>{document.contains(this.dom)&&(s(),t.disconnect())})).observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0}),window.addEventListener("resize",s),this.detachMenu=function(){!1!==n.hasClass("osui-menu-button")&&(n.removeClass("osui-menu-button"),window.removeEventListener("resize",s),n.dom.removeEventListener("pointerdown",i),n.attachedMenu.destroy(),document.body.removeChild(n.attachedMenu.dom),n.attachedMenu=void 0)}}}class ue extends re{constructor(e){super(document.createElement("div")),this.setInnerHtml(e)}}class ge extends re{constructor(e,t=null,n=null,i=!1){const s=document.createElement("img");s.onerror=()=>s.style.visibility="hidden",i||(s.ondragstart=()=>!1),null!=t&&(s.style.width=u.parseSize(t)),null!=n&&(s.style.height=u.parseSize(n)),super(s),this.setClass("osui-image"),this.setImage(e)}setImage(e){if("string"==typeof e&&e.toLowerCase().includes("<svg")){const t=new Blob([e],{type:"image/svg+xml"}),n=URL.createObjectURL(t);this.dom.src=n,this.dom.addEventListener("load",(()=>URL.revokeObjectURL(n)),{once:!0})}else this.dom.src=e;return this}}class me extends ue{constructor(){if(super(),this.setClass("osui-vector-box"),this.img=void 0,0===arguments.length)return this.addImage(n);const e=Array.isArray(arguments[0])?arguments[0]:[...arguments];for(const t of e)this.addImage(t)}firstImage(){for(const e of this.contents().children)if(e&&e.isElement&&e.hasClass("osui-image"))return e}addImage(e=n){const t=new ge(e,"100%","100%",!1);return this.img||(this.img=t),this.add(t),this}enableDragging(){this.dom&&(this.dom.draggable=!0);for(const e of this.contents().children)e.isElement&&e.dom&&(e.dom.ondragstart=()=>{});return this}setImage(e){return this.img.setImage(e)}}class pe extends ue{constructor(){if(super(),this.setClass("osui-shadow-box"),this.addClass("osui-drop-shadow"),0===arguments.length)return;const e=Array.isArray(arguments[0])?arguments[0]:[...arguments];for(const t of e)this.add(t&&t.isElement?t:new me(t))}firstImage(){for(const e of this.contents().children)if(e&&e.isElement&&(e.hasClass("osui-image")||e.hasClass("osui-vector-box")))return e}fullSize(){return this.addClass("osui-full-size"),this}dropShadow(){return this.addClass("osui-drop-shadow"),this.removeClass("osui-even-shadow"),this}evenShadow(){return this.removeClass("osui-drop-shadow"),this.addClass("osui-even-shadow"),this}noShadow(){return this.removeClass("osui-drop-shadow"),this.removeClass("osui-even-shadow"),this}}const be={LEFT:"left",RIGHT:"right",BOTH:"both",NONE:"none"},ve="close",fe="max";class we{static addCloseButton(e,t=be.BOTH,n=0,i=1.3){we.addCornerButton(ve,e,t,n,i)}static addMaxButton(e,t=be.BOTH,n=0,i=1.3){we.addCornerButton(fe,e,t,n,i)}static addCornerButton(e=ve,n,s,o=0,r=1.3){if(!n||!n.isElement)return void console.warn("Interaction.addCornerButton: Missing element argument");const a=new ce;let l,d,h;switch(a.setClass("osui-corner-button"),a.addClass("osui-panel-button"),e){case ve:a.setStyle("background-color","#e24c4b"),l=t,d="Close Panel",h=0;break;case fe:a.setStyle("background-color","#2bc840"),l=i,d="Toggle Panel",h=1.2}const c=new pe(l).evenShadow().fullSize().addClass("osui-corner-image");a.add(c),a.dom.setAttribute("tooltip",d),a.setStyle("min-height",`${r}em`,"min-width",`${r}em`);const u=`${.8-(r+.28571)/2+o+h*r}em`;if(a.setStyle("top",.8-(r+.28571)/2+"em"),a.setStyle(s===be.LEFT?"left":"right",u),s===be.BOTH){let e=be.RIGHT;n.dom.addEventListener("pointermove",(function(t){const i=n.dom.getBoundingClientRect(),s=i.left+i.width/2,o=t.pageX;let r=be.NONE;o>s&&e!==be.RIGHT?r=be.RIGHT:o<s&&e!==be.LEFT&&(r=be.LEFT),r!==be.NONE&&(a.addClass("osui-item-hidden"),setTimeout((()=>{a.dom.style.removeProperty("left"),a.dom.style.removeProperty("right"),a.setStyle(r,u),a.removeClass("osui-item-hidden")}),100),e=r)}))}switch(e){case ve:a.dom.addEventListener("click",(()=>{n.hide()}));break;case fe:a.dom.addEventListener("click",(()=>{"function"==typeof n.toggleMinMax&&n.toggleMinMax()}))}n.dom.addEventListener("pointerenter",(()=>a.addClass("osui-item-shown"))),n.dom.addEventListener("pointerleave",(()=>a.removeClass("osui-item-shown"))),n.addToSelf(a)}static makeDraggable(e,t=e,n=!1,i=(()=>{}),s=(()=>{}),o=(()=>{})){const r=e&&e.isElement?e.dom:e,a=t&&t.isElement?t.dom:t;let l,d,h,c,g={},m=getComputedStyle(a),p=0;function b(t,n=25){return e.snapToGrid?Math.round(t/n)*n:t}function v(e){e.stopPropagation(),e.preventDefault(),r.releasePointerCapture(e.pointerId),r.ownerDocument.removeEventListener("pointermove",f),r.ownerDocument.removeEventListener("pointerup",v),r.style.cursor="inherit",o()}function f(t){if(t.stopPropagation(),t.preventDefault(),t.isTrusted&&(h=t.pageX,c=t.pageY),p=Math.max(p,Math.abs(l-h)),p=Math.max(p,Math.abs(d-c)),p<2)return;r.style.cursor="move";const i=e&&e.getScale?e.getScale():1,o=1/i*(h-l),m=1/i*(c-d);let v=b(g.left+o),f=b(g.top+m);if(n){const e=parseInt(u.toPx("4em"));v=Math.min(window.innerWidth-g.width/2,v),f=Math.min(window.innerHeight-e,f),v=Math.max(-g.width/2,v),f=Math.max(0,f)}a.style.left=`${v}px`,a.style.top=`${f}px`,s(o,m)}r.addEventListener("pointerdown",(function(e){0===e.button&&(e.stopPropagation(),e.preventDefault(),r.focus(),r.setPointerCapture(e.pointerId),p=0,l=e.pageX,d=e.pageY,h=e.pageX,c=e.pageY,m=getComputedStyle(a),g.left=parseFloat(m.left),g.top=parseFloat(m.top),g.width=parseFloat(m.width),g.height=parseFloat(m.height),r.ownerDocument.addEventListener("pointermove",f),r.ownerDocument.addEventListener("pointerup",v),document.dispatchEvent(new Event("closemenu")),i())}))}static makeResizeable(e,t=e,n=[],i=(()=>{}),s=(()=>{}),o=(()=>{})){if(!e||!e.isElement)return console.warning("Resizeable.enable: ResizeElement not defined");if(!t||!t.isElement)return console.warning("Resizeable.enable: AddToElement not defined");e.addClass("osui-resizeable");const r={};for(let d in l){const h=l[d],c=`osui-resizer-${h}`,u=new ue;let g,m,p,b;function v(t){0===t.button&&(t.stopPropagation(),t.preventDefault(),u.dom.setPointerCapture(t.pointerId),g=t.pageX,m=t.pageY,p=t.pageX,b=t.pageY,e.dom.ownerDocument.addEventListener("pointermove",w),e.dom.ownerDocument.addEventListener("pointerup",f),document.dispatchEvent(new Event("closemenu")),i())}function f(t){t.stopPropagation(),t.preventDefault(),u.dom.releasePointerCapture(t.pointerId),e.dom.ownerDocument.removeEventListener("pointermove",w),e.dom.ownerDocument.removeEventListener("pointerup",f),o()}function w(e){e.stopPropagation(),e.preventDefault(),e.isTrusted&&(p=e.pageX,b=e.pageY);s(u,p-g,b-m)}u.addClass("osui-resizer"),u.addClass(c),u.dom.addEventListener("pointerdown",v),r[h]=u,t.addToSelf(u)}const a={};e.toggleResize=function(t,n=!0){if(t)return a[t]=n,i(r[t],n),i(r[l.TOP_LEFT],a[l.TOP]&&a[l.LEFT]),i(r[l.TOP_RIGHT],a[l.TOP]&&a[l.RIGHT]),i(r[l.BOTTOM_LEFT],a[l.BOTTOM]&&a[l.LEFT]),i(r[l.BOTTOM_RIGHT],a[l.BOTTOM]&&a[l.RIGHT]),e;function i(e,t){e&&e.setStyle("display",t?"":"none")}};for(let x in l){const y=l[x];e.toggleResize(y,n.includes(y))}}}class xe{active=!0;params=null;onceOnly=!1;constructor(e,t,n,i=0){this.listener=t,this.onceOnly=n,this.signal=e,this.priority=i}execute(e){let t,n;return this.active&&this.listener&&(n=this.params?this.params.concat(e):e,t=this.listener.apply(null,n),this.onceOnly&&this.detach()),t}detach(){return this.isBound()?this.signal.remove(this.listener):null}isBound(){return!!this.signal&&!!this.listener}isOnce(){return this.onceOnly}getListener(){return this.listener}getSignal(){return this.signal}destroy(){delete this.signal,delete this.listener}toString(){return"[SignalBinding onceOnly:"+this.onceOnly+", isBound:"+this.isBound()+", active:"+this.active+"]"}}class ye{VERSION="1.0.1";active=!0;memorize=!1;shouldPropagate=!0;constructor(){this._bindings=[],this._prevParams=null}#e(e,t,n){let i,s=this.#t(e);if(-1!==s){if(i=this._bindings[s],i.isOnce()!==t)throw new Error("You cannot add"+(t?"":"Once")+"() then add"+(t?"Once":"")+"() the same listener without removing the relationship first")}else{i=new xe(this,e,t,n);let s=this._bindings.length;do{--s}while(this._bindings[s]&&i.priority<=this._bindings[s].priority);this._bindings.splice(s+1,0,i)}return this.memorize&&this._prevParams&&i.execute(this._prevParams),i}#t(e){let t,n=this._bindings.length;for(;n--;)if(t=this._bindings[n],t.listener===e)return n;return-1}has(e){return-1!==this.#t(e)}add(e,t){return ke(e,"add"),this.#e(e,!1,t)}addOnce(e,t){return ke(e,"addOnce"),this.#e(e,!0,t)}remove(e){ke(e,"remove");const t=this.#t(e);return-1!==t&&(this._bindings[t].destroy(),this._bindings.splice(t,1)),e}removeAll(){let e=this._bindings.length;for(;e--;)this._bindings[e].destroy();this._bindings.length=0}getNumListeners(){return this._bindings.length}halt(){this.shouldPropagate=!1}dispatch(){if(!this.active)return;let e=[...arguments],t=this._bindings.length;if(this.memorize&&(this._prevParams=e),!t)return;const n=[...this._bindings];this.shouldPropagate=!0;do{t--}while(n[t]&&this.shouldPropagate&&!1!==n[t].execute(e))}forget(){this._prevParams=null}dispose(){this.removeAll(),delete this._bindings,delete this._prevParams}toString(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}}function ke(e,t){if("function"!=typeof e)throw new Error(`'listener' is a required param of ${t}() and should be a Function!`)}class Ce{static isChildOf(e,t){e.isElement&&e.dom&&(e=e.dom);let n=e.parentElement;for(;n;){if(n.isSameNode(t))return!0;n=n.parentElement}return!1}static isChildOfElementWithClass(e,t){e.isElement&&e.dom&&(e=e.dom);let n=e.parentElement;for(;n;){if(n.classList.contains(t))return!0;n=n.parentElement}return!1}static parentElementWithClass(e,t){e.isElement&&e.dom&&(e=e.dom);let n=e.parentElement;for(;n;){if(n.classList.contains(t))return n;n=n.parentElement}}static traverse(e,t=(()=>{}),n=!0){e.isElement&&e.dom&&(e=e.dom),n&&t(e);for(let n=0;n<e.children.length;n++)Ce.traverse(e.children[n],t,!0)}static parentScroller(e){return e?(e.isElement&&e.dom&&(e=e.dom),e.scrollHeight>e.clientHeight?e:Ce.parentScroller(e.parentElement)):null}static scrollIntoView(e){const t=Ce.parentScroller(e);if(t){const n=parseInt(u.toPx("0.2em"));e.offsetTop-t.offsetTop-n<t.scrollTop?t.scrollTop=e.offsetTop-t.offsetTop-n:e.offsetTop>t.scrollTop+t.clientHeight+n-t.offsetTop&&(t.scrollTop=e.offsetTop-t.clientHeight+e.offsetHeight+n-t.offsetTop)}}}const Se=1,Ee=2;let Te;const Le=new class{constructor(){const e=(new ue).setClass("osui-tooltip");e.setInnerHtml(""),document.body.appendChild(e.dom);let t=Se;function n(t){if(t){const e=t.target;if(!(e&&e instanceof HTMLElement))return;if(!e.getAttribute("tooltip"))return}clearTimeout(Te),e.removeClass("osui-updated")}document.addEventListener("touchstart",(()=>t=Ee),{capture:!0,passive:!0}),document.addEventListener("mousemove",(()=>t=Se),{capture:!0,passive:!0}),document.addEventListener("mouseenter",(function(n){const i=n.target;if(!(i&&i instanceof HTMLElement))return;if(!i.getAttribute("tooltip"))return;if(n instanceof FocusEvent&&t!==Se)return;if("TouchEvent"in window&&n instanceof TouchEvent)return;let s=i.getAttribute("tooltip");if(!s.length)return;clearTimeout(Te),e.removeClass("osui-updated"),Te=setTimeout((()=>{e.setInnerHtml(s),b.popUnder(e.dom,i,g.CENTER,null,o),e.addClass("osui-updated")}),parseInt(u.getVariable("--tooltip-delay")))}),{capture:!0,passive:!0}),document.addEventListener("mouseleave",n,{capture:!0,passive:!0}),document.addEventListener("dragleave",n,{capture:!0,passive:!0}),document.addEventListener("blur",n,{capture:!0,passive:!0}),document.addEventListener("hidetooltip",(()=>{n()}),{capture:!0,passive:!0})}};class Ie extends re{constructor(e){super(document.createElement("span")),this.setInnerHtml(e)}}class ze extends Ie{constructor(){super(),this.setStyle("flex","1 1 auto"),this.setStyle("minHeight","0.01em")}}const Re={NONE:"none",SIMPLE:"simple",FANCY:"fancy"};class De extends ue{constructor({style:e=Re.NONE}={}){if(super(),this.setClass("osui-panel"),this.contents=function(){return this},e===Re.SIMPLE)this.addClass("osui-panel-simple");else if(e===Re.FANCY){this.addClass("osui-panel-fancy");const e=(new De).setClass("osui-panel-fancy-outer"),t=(new De).setClass("osui-panel-fancy-border"),n=(new De).setClass("osui-panel-fancy-inside");t.add(n),e.add(t),this.add(e),this.contents=function(){return n}}this.onContextMenu((function(e){e.preventDefault()}))}}class Me extends ue{constructor(){super(),this.addClass("osui-row")}}class Ae extends Ie{constructor(e){super(e),this.setClass("osui-text"),this.setStyle("cursor","default")}}const Ne={TABS:"tabs",NORMAL:"normal"};class He extends ue{constructor(e="50%",t=Ne.TABS){super(),this.addClass("osui-property-list"),this.setStyle("display","block"),this.leftPropertyWidth=e,this.leftPropertySpacing=t}setLeftPropertyWidth(e="50%"){return this.leftPropertyWidth=e,this}#n(){let e=this.leftPropertyWidth??"50%";return"string"==typeof this.leftPropertyWidth?e=parseInt(this.leftPropertyWidth):"number"==typeof this.leftPropertyWidth&&(e=100*parseFloat(this.leftPropertyWidth)),!Number.isNaN(e)&&Number.isFinite(e)||(e=50),e=Math.max(e,0),e=Math.min(e,100),e}#i(){return`${this.#n()}%`}#s(){return 100-this.#n()+"%"}addHeader(e="",t){const n=this.createHeader(e,t);return this.add(n),n}addRow(e="",...t){const n=this.createRow(e,...t);return this.add(n),n}addRowWithoutTitle(...e){const t=this.createRowWithoutTitle(...e);return this.add(t),t}createHeader(e="",t){const n=(new ue).setClass("osui-property-header-title"),i=new me(t),s=(new Ie).setClass("osui-property-header-icon").add(i),o=(new Ie).setClass("osui-property-header-text").setTextContent(e);return n.add(s,o),n}createRow(e="",...t){const n=this.createControls(...t),i=new Ae(e).selectable(!1).addClass("osui-property-left");this.leftPropertySpacing===Ne.TABS&&i.addClass("osui-left-tab-spacing"),u.setVariable("--left-property-width",this.#i(),i),u.setVariable("--right-property-width",this.#s(),n);const s=(new Me).addClass("osui-property-row").add(i,n);return s.leftWidget=i,s.rightWidget=n,s}createRowWithoutTitle(...e){const t=this.createControls(...e);t.removeClass("osui-property-right").addClass("osui-property-full");const n=(new Me).addClass("osui-property-row").add(t);return n.leftWidget=t,n.rightWidget=t,n}createControls(){const e=(new Me).setStyle("margin","0","padding","0").addClass("osui-property-right");let t=arguments;1===arguments.length&&Array.isArray(arguments[0])&&(t=arguments[0]);for(let n=0;n<t.length;n++){const i=t[n];i instanceof re&&i.isElement?(e.add(i),n<t.length-1&&e.add((new Ie).addClass("osui-property-space"))):console.error("PropertyList.createControls():",i,"is not an instance of Osui Element.")}return e}disableInputs(e=!0){const t=["osui-button","osui-checkbox","osui-checkbox-input","osui-number","osui-slider","osui-tick-marks","osui-text-area","osui-text-box"];for(let n=0;n<t.length;n++){const i=this.dom.getElementsByClassName(t[n]);for(let t=0;t<i.length;t++)e?(i[t].classList.add("osui-disabled"),i[t].disabled=!0):(i[t].classList.remove("osui-disabled"),i[t].disabled=!1)}}}class Pe extends De{constructor({text:e="",icon:t="",arrow:n="left",border:i=!0}={}){super();const s=this;this.addClass("osui-shrinkable"),i||this.addClass("osui-borderless"),this.titleDiv=void 0,this.bodyDiv=void 0;const o=(new ue).setClass("osui-shrink-title"),r=(new Ie).setClass("osui-shrink-arrow"),a=(new ue).addClass("osui-shrink-arrow-clicker");r.add(a);const l=(new Ie).setClass("osui-shrink-text").setInnerHtml(e),d=(new Ie).setClass("osui-shrink-icon");t&&d.addClass("osui-has-icon");const h=new me(t);d.add(h),"right"===n?o.add(d,l,r):o.add(r,d,l);const c=(new ue).setClass("osui-shrink-body");this.add(o),this.add(c),this.titleDiv=o,this.bodyDiv=c,this.contents=function(){return s.bodyDiv},this.setExpanded(!0,!1),a.onClick((function(){s.toggle()}))}setExpanded(e=!0,t=!0){e=Boolean(e),this.isExpanded=e,e?this.addClass("osui-expanded"):this.removeClass("osui-expanded"),t&&this.dom.dispatchEvent(new Event("expand"))}sort(){const e=this.contents().children;e.sort(((e,t)=>e.name<t.name?-1:e.name>t.name?1:0));for(let t=0;t<e.length;t++)e[t].setStyle("order",t)}toggle(){this.setExpanded(!this.isExpanded)}}const Be={LEFT:"left",RIGHT:"right"};class Fe extends De{#o=null;#r=null;#a=0;#l=1/0;#d=0;#h=1/0;constructor({tabSide:e=Be.RIGHT,style:t=Re.FANCY,resizers:n=[],startWidth:i=null,startHeight:s=null,minWidth:o=0,maxWidth:r=1/0,minHeight:a=0,maxHeight:l=1/0}={}){super({style:t});const d=this;this.addClass("osui-tabbed"),this.setName("osui-tabbed"),this.#o=i,this.#a=o,this.#l=r,this.#r=s,this.#d=a,this.#h=l,this.tabs=[],this.panels=[],this.selectedId="",this.selectedCount=0;const h={};we.makeResizeable(this,this,n,(function(){h.width=d.getWidth(),h.height=d.getHeight(),d.dom.dispatchEvent(new Event("clicked",{bubbles:!0,cancelable:!0}))}),(function(e,t,n){e.hasClassWithString("left")&&d.changeWidth(h.width-t),e.hasClassWithString("right")&&d.changeWidth(h.width+t),e.hasClassWithString("top")&&d.changeHeight(h.height-n),e.hasClassWithString("bottom")&&d.changeHeight(h.height+n)})),this.tabsDiv=(new ue).setClass("osui-tabs").setDisplay("none"),this.panelsDiv=(new ue).setClass("osui-tab-panels"),this.add(this.tabsDiv),this.add(this.panelsDiv),this.setTabSide(e)}changeWidth(e){if("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)||(e=this.#o),null==e)return this.dom.style.removeProperty("width"),null;const t=this.#a*u.guiScale(this.dom),n=this.#l*u.guiScale(this.dom);return e=Math.min(n,Math.max(t,parseFloat(e))).toFixed(1),this.setStyle("width",u.toEm(e,this.dom)),this.dom.dispatchEvent(new Event("resized")),e}changeHeight(e){if("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)||(e=this.#r),null==e)return this.dom.style.removeProperty("height"),null;const t=this.#d*u.guiScale(this.dom),n=this.#h*u.guiScale(this.dom);return e=Math.min(n,Math.max(t,parseFloat(e))).toFixed(1),this.setStyle("height",u.toEm(e,this.dom)),this.dom.dispatchEvent(new Event("resized")),e}addTab(e,t,i={}){"object"!=typeof i&&(i={}),"color"in i&&null!=i.color||(i.color=oe.color(a.ICON)),"alpha"in i||(i.alpha=1),"icon"in i||(i.icon=n),"shadow"in i||(i.shadow=0),"shrink"in i||(i.shrink=1),!0===i.shrink&&(i.shrink=.7),"string"==typeof i.shrink&&(i.shrink=parseFloat(i.shrink)/(i.shrink.includes("%")?100:1));let s=0;for(let t=0;t<this.tabs.length;t++){this.tabs[t].dom.id===e&&s++}const o=function(e){const t=String(e).split(" ");for(let e=0;e<t.length;e++)t[e]=t[e][0].toUpperCase()+t[e].substring(1);return t.join(" ")}(e),r=new Ve(this,o,i);r.setId(e),r.count=s,this.tabs.push(r),this.tabsDiv.add(r);this.tabs.length>0&&this.tabsDiv.setDisplay("");const l=(new De).setId(e);return l.addClass("osui-tab-panel","osui-hidden"),l.add(t),l.count=s,this.panels.push(l),this.panelsDiv.add(l),this.setContentsSt