text: /**
   * @license
   * Copyright 2010-2021 Uil.js Authors
   * SPDX-License-Identifier: MIT
   */
  !function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports):"function"==typeof define&&define.amd?define(["exports"],s):s((t="undefined"!=typeof globalThis?globalThis:t||self).UIL={})}(this,(function(t){"use strict";const s={frag:document.createDocumentFragment(),colorRing:null,joystick_0:null,joystick_1:null,circular:null,knob:null,svgns:"http://www.w3.org/2000/svg",links:"http://www.w3.org/1999/xlink",htmls:"http://www.w3.org/1999/xhtml",DOM_SIZE:["height","width","top","left","bottom","right","margin-left","margin-right","margin-top","margin-bottom"],SVG_TYPE_D:["pattern","defs","transform","stop","animate","radialGradient","linearGradient","animateMotion","use","filter","feColorMatrix"],SVG_TYPE_G:["svg","rect","circle","path","polygon","text","g","line","foreignObject"],PI:Math.PI,TwoPI:2*Math.PI,pi90:.5*Math.PI,pi60:Math.PI/3,torad:Math.PI/180,todeg:180/Math.PI,clamp:function(t,s,i){return t=(t=t<s?s:t)>i?i:t},size:{w:240,h:20,p:30,s:8},colors:{text:"#dcdcdc",textOver:"#FFFFFF",txtselectbg:"none",content:"none",background:"rgba(50,50,50,0.5)",backgroundOver:"rgba(50,50,50,0.5)",inputBorder:"#454545",inputHolder:"#808080",inputBorderSelect:"#005AAA",inputBg:"rgba(0,0,0,0.1)",inputOver:"rgba(0,0,0,0.2)",border:"#454545",borderOver:"#5050AA",borderSelect:"#308AFF",button:"#3c3c3c",boolbg:"#181818",boolon:"#C0C0C0",select:"#308AFF",moving:"#03afff",down:"#024699",over:"#024699",over2:"#1c1c1c",action:"#FF3300",stroke:"rgba(11,11,11,0.5)",scroll:"#333333",scrollback:"rgba(0,0,0,0.2)",scrollbackover:"rgba(0,0,0,0.3)",hide:"rgba(0,0,0,0)",groupBorder:"#3e3e3e",buttonBorder:"#4a4a4a",fontFamily:"Consolas,monaco,monospace",fontWeight:"normal",fontShadow:"none",fontSize:12,itemBg:"rgba(0,0,0,0.2)",radius:4},css:{basic:"position:absolute; pointer-events:none; box-sizing:border-box; margin:0; padding:0; overflow:hidden; -o-user-select:none; -ms-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -moz-user-select:none;",button:"display:flex; justify-content:center; align-items:center; text-align:center;"},svgs:{group:"M 7 7 L 7 8 8 8 8 7 7 7 M 5 7 L 5 8 6 8 6 7 5 7 M 3 7 L 3 8 4 8 4 7 3 7 M 7 5 L 7 6 8 6 8 5 7 5 M 6 6 L 6 5 5 5 5 6 6 6 M 7 3 L 7 4 8 4 8 3 7 3 M 6 4 L 6 3 5 3 5 4 6 4 M 3 5 L 3 6 4 6 4 5 3 5 M 3 3 L 3 4 4 4 4 3 3 3 Z",arrow:"M 3 8 L 8 5 3 2 3 8 Z",arrowDown:"M 5 8 L 8 3 2 3 5 8 Z",arrowUp:"M 5 2 L 2 7 8 7 5 2 Z",solid:"M 13 10 L 13 1 4 1 1 4 1 13 10 13 13 10 M 11 3 L 11 9 9 11 3 11 3 5 5 3 11 3 Z",body:"M 13 10 L 13 1 4 1 1 4 1 13 10 13 13 10 M 11 3 L 11 9 9 11 3 11 3 5 5 3 11 3 M 5 4 L 4 5 4 10 9 10 10 9 10 4 5 4 Z",vehicle:"M 13 6 L 11 1 3 1 1 6 1 13 3 13 3 11 11 11 11 13 13 13 13 6 M 2.4 6 L 4 2 10 2 11.6 6 2.4 6 M 12 8 L 12 10 10 10 10 8 12 8 M 4 8 L 4 10 2 10 2 8 4 8 Z",articulation:"M 13 9 L 12 9 9 2 9 1 5 1 5 2 2 9 1 9 1 13 5 13 5 9 4 9 6 5 8 5 10 9 9 9 9 13 13 13 13 9 Z",character:"M 13 4 L 12 3 9 4 5 4 2 3 1 4 5 6 5 8 4 13 6 13 7 9 8 13 10 13 9 8 9 6 13 4 M 6 1 L 6 3 8 3 8 1 6 1 Z",terrain:"M 13 8 L 12 7 Q 9.06 -3.67 5.95 4.85 4.04 3.27 2 7 L 1 8 7 13 13 8 M 3 8 Q 3.78 5.420 5.4 6.6 5.20 7.25 5 8 L 7 8 Q 8.39 -0.16 11 8 L 7 11 3 8 Z",joint:"M 7.7 7.7 Q 8 7.45 8 7 8 6.6 7.7 6.3 7.45 6 7 6 6.6 6 6.3 6.3 6 6.6 6 7 6 7.45 6.3 7.7 6.6 8 7 8 7.45 8 7.7 7.7 M 3.35 8.65 L 1 11 3 13 5.35 10.65 Q 6.1 11 7 11 8.28 11 9.25 10.25 L 7.8 8.8 Q 7.45 9 7 9 6.15 9 5.55 8.4 5 7.85 5 7 5 6.54 5.15 6.15 L 3.7 4.7 Q 3 5.712 3 7 3 7.9 3.35 8.65 M 10.25 9.25 Q 11 8.28 11 7 11 6.1 10.65 5.35 L 13 3 11 1 8.65 3.35 Q 7.9 3 7 3 5.7 3 4.7 3.7 L 6.15 5.15 Q 6.54 5 7 5 7.85 5 8.4 5.55 9 6.15 9 7 9 7.45 8.8 7.8 L 10.25 9.25 Z",ray:"M 9 11 L 5 11 5 12 9 12 9 11 M 12 5 L 11 5 11 9 12 9 12 5 M 11.5 10 Q 10.9 10 10.45 10.45 10 10.9 10 11.5 10 12.2 10.45 12.55 10.9 13 11.5 13 12.2 13 12.55 12.55 13 12.2 13 11.5 13 10.9 12.55 10.45 12.2 10 11.5 10 M 9 10 L 10 9 2 1 1 2 9 10 Z",collision:"M 11 12 L 13 10 10 7 13 4 11 2 7.5 5.5 9 7 7.5 8.5 11 12 M 3 2 L 1 4 4 7 1 10 3 12 8 7 3 2 Z",map:"M 13 1 L 1 1 1 13 13 13 13 1 M 12 2 L 12 7 7 7 7 12 2 12 2 7 7 7 7 2 12 2 Z",material:"M 13 1 L 1 1 1 13 13 13 13 1 M 12 2 L 12 7 7 7 7 12 2 12 2 7 7 7 7 2 12 2 Z",texture:"M 13 4 L 13 1 1 1 1 4 5 4 5 13 9 13 9 4 13 4 Z",object:"M 10 1 L 7 4 4 1 1 1 1 13 4 13 4 5 7 8 10 5 10 13 13 13 13 1 10 1 Z",none:"M 9 5 L 5 5 5 9 9 9 9 5 Z",cursor:"M 4 7 L 1 10 1 12 2 13 4 13 7 10 9 14 14 0 0 5 4 7 Z"},setStyle:function(t){for(var i in t)s.colors[i]&&(s.colors[i]=t[i]);s.setText()},setText:function(t,i,e,h){let o=s.colors;void 0!==e&&(o.fontFamily=e),void 0!==i&&(o.text=i),void 0!==t&&(o.fontSize=t),s.css.txt=s.css.basic+"font-family:"+o.fontFamily+"; font-weight:"+o.fontWeight+"; font-size:"+o.fontSize+"px; color:"+o.text+"; padding:2px 10px; left:0; top:2px; height:16px; width:100px; overflow:hidden; white-space: nowrap;",void 0!==h&&(s.css.txt+=" text-shadow:"+h+"; "),"none"!==o.fontShadow&&(s.css.txt+=" text-shadow: 1px 1px 1px "+o.fontShadow+";"),s.css.txtselect=s.css.txt+"display:flex; justify-content:left; align-items:center; text-align:left;padding:2px 5px; border:1px dashed "+o.border+"; background:"+o.txtselectbg+";",s.css.item=s.css.txt+"position:relative; margin-bottom:1px;"},cloneColor:function(){return Object.assign({},s.colors)},cloneCss:function(){return Object.assign({},s.css)},clone:function(t){return t.cloneNode(!0)},setSvg:function(t,s,i,e,h){-1===e?t.setAttributeNS(null,s,i):void 0!==h?t.childNodes[e||0].childNodes[h||0].setAttributeNS(null,s,i):t.childNodes[e||0].setAttributeNS(null,s,i)},setCss:function(t,i){for(let e in i)-1!==s.DOM_SIZE.indexOf(e)?t.style[e]=i[e]+"px":t.style[e]=i[e]},set:function(t,i){for(let e in i)"txt"===e&&(t.textContent=i[e]),"link"===e?t.setAttributeNS(s.links,"xlink:href",i[e]):t.setAttributeNS(null,e,i[e])},get:function(t,s){if(void 0===s)return t;if(!isNaN(s))return t.childNodes[s];if(s instanceof Array){if(2===s.length)return t.childNodes[s[0]].childNodes[s[1]];if(3===s.length)return t.childNodes[s[0]].childNodes[s[1]].childNodes[s[2]]}},dom:function(t,i,e,h,o){return t=t||"div",-1!==s.SVG_TYPE_D.indexOf(t)||-1!==s.SVG_TYPE_G.indexOf(t)?"svg"===t?(h=document.createElementNS(s.svgns,"svg"),s.set(h,e)):(void 0===h&&(h=document.createElementNS(s.svgns,"svg")),s.addAttributes(h,t,e,o)):h=void 0===h?document.createElementNS(s.htmls,t):h.appendChild(document.createElementNS(s.htmls,t)),i&&(h.style.cssText=i),void 0===o?h:h.childNodes[o||0]},addAttributes:function(t,i,e,h){let o=document.createElementNS(s.svgns,i);return s.set(o,e),s.get(t,h).appendChild(o),-1!==s.SVG_TYPE_G.indexOf(i)&&(o.style.pointerEvents="none"),o},clear:function(t){for(s.purge(t);t.firstChild;)t.firstChild.firstChild&&s.clear(t.firstChild),t.removeChild(t.firstChild)},purge:function(t){let i,e,h=t.attributes;if(h)for(i=h.length;i--;)e=h[i].name,"function"==typeof t[e]&&(t[e]=null);if(h=t.childNodes,h)for(i=h.length;i--;)s.purge(t.childNodes[i])},addSVGGlowEffect:function(){if(null!==document.getElementById("UILGlow"))return;let t=s.initUILEffects(),i=s.addAttributes(t,"filter",{id:"UILGlow",x:"-20%",y:"-20%",width:"140%",height:"140%"});s.addAttributes(i,"feGaussianBlur",{in:"SourceGraphic",stdDeviation:"3",result:"uilBlur"});let e=s.addAttributes(i,"feMerge",{});for(let t=0;t<=3;t++)s.addAttributes(e,"feMergeNode",{in:"uilBlur"});s.addAttributes(e,"feMergeNode",{in:"SourceGraphic"})},initUILEffects:function(){let t=document.getElementById("UILSVGEffects");return null===t&&(t=s.dom("svg",void 0,{id:"UILSVGEffects",width:"0",height:"0"}),document.body.appendChild(t)),t},ColorLuma:function(t,s){"n"===t&&(t="#000"),(t=String(t).replace(/[^0-9a-f]/gi,"")).length<6&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),s=s||0;let i,e,h="#";for(e=0;e<3;e++)i=parseInt(t.substr(2*e,2),16),i=Math.round(Math.min(Math.max(0,i+i*s),255)).toString(16),h+=("00"+i).substr(i.length);return h},findDeepInver:function(t){return.3*t[0]+.59*t[1]+.11*t[2]<=.6},lerpColor:function(t,s,i){let e={};for(let h=0;h<3;h++)e[h]=t[h]+(s[h]-t[h])*i;return e},hexToHtml:function(t){return"#"+("000000"+(t=void 0===t?0:t).toString(16)).substr(-6)},htmlToHex:function(t){return t.toUpperCase().replace("#","0x")},u255:function(t,s){return parseInt(t.substring(s,s+2),16)/255},u16:function(t,s){return parseInt(t.substring(s,s+1),16)/15},unpack:function(t){return 7==t.length?[s.u255(t,1),s.u255(t,3),s.u255(t,5)]:4==t.length?[s.u16(t,1),s.u16(t,2),s.u16(t,3)]:void 0},p255:function(t){let s=Math.round(255*t).toString(16);return s.length<2&&(s="0"+s),s},pack:function(t){return"#"+s.p255(t[0])+s.p255(t[1])+s.p255(t[2])},htmlRgb:function(t){return"rgb("+Math.round(255*t[0])+","+Math.round(255*t[1])+","+Math.round(255*t[2])+")"},pad:function(t){return 1==t.length&&(t="0"+t),t},rgbToHex:function(t){let i=Math.round(255*t[0]).toString(16),e=Math.round(255*t[1]).toString(16),h=Math.round(255*t[2]).toString(16);return"#"+s.pad(i)+s.pad(e)+s.pad(h)},hueToRgb:function(t,s,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(s-t)*i:i<.5?s:i<2/3?t+6*(s-t)*(2/3-i):t},rgbToHsl:function(t){let s=t[0],i=t[1],e=t[2],h=Math.min(s,i,e),o=Math.max(s,i,e),n=o-h,r=0,l=0,a=(h+o)/2;return a>0&&a<1&&(l=n/(a<.5?2*a:2-2*a)),n>0&&(o==s&&o!=i&&(r+=(i-e)/n),o==i&&o!=e&&(r+=2+(e-s)/n),o==e&&o!=s&&(r+=4+(s-i)/n),r/=6),[r,l,a]},hslToRgb:function(t){let i,e,h=t[0],o=t[1],n=t[2];return 0===o?[n,n,n]:(e=n<=.5?n*(o+1):n+o-n*o,i=2*n-e,[s.hueToRgb(i,e,h+.33333),s.hueToRgb(i,e,h),s.hueToRgb(i,e,h-.33333)])},makeGradiant:function(t,i,e,h){s.dom(t,null,i,e,0);let o,n=e.childNodes[0].childNodes.length-1;for(let t=0;t<h.length;t++)o=h[t],s.dom("stop",null,{offset:o[0]+"%","stop-color":o[1],"stop-opacity":o[2]},e,[0,n])},makeKnob:function(t){let i=128,e=s.dom("svg",s.css.basic,{viewBox:"0 0 128 "+i,width:i,height:i,preserveAspectRatio:"none"});s.dom("circle","",{cx:64,cy:64,r:34,fill:s.colors.button,stroke:"rgba(0,0,0,0.3)","stroke-width":8},e),s.dom("path","",{d:"",stroke:s.colors.text,"stroke-width":4,fill:"none","stroke-linecap":"round"},e),s.dom("circle","",{cx:64,cy:64,r:41,stroke:"rgba(0,0,0,0.1)","stroke-width":7,fill:"none"},e),s.dom("path","",{d:"",stroke:"rgba(255,255,255,0.3)","stroke-width":2,fill:"none","stroke-linecap":"round","stroke-opacity":.5},e),s.knob=e},makeCircular:function(t){let i=128,e=s.dom("svg",s.css.basic,{viewBox:"0 0 128 "+i,width:i,height:i,preserveAspectRatio:"none"});s.dom("circle","",{cx:64,cy:64,r:40,stroke:"rgba(0,0,0,0.1)","stroke-width":10,fill:"none"},e),s.dom("path","",{d:"",stroke:s.colors.text,"stroke-width":7,fill:"none","stroke-linecap":"butt"},e),s.circular=e},makeJoystick:function(t){let i,e=128,h=Math.floor(49),o=Math.floor(.6*h),n=s.dom("svg",s.css.basic,{viewBox:"0 0 128 "+e,width:e,height:e,preserveAspectRatio:"none"});if(s.dom("defs",null,{},n),s.dom("g",null,{},n),0===t){i=[[40,"rgb(0,0,0)",.3],[80,"rgb(0,0,0)",0],[90,"rgb(50,50,50)",.4],[100,"rgb(50,50,50)",0]],s.makeGradiant("radialGradient",{id:"grad",cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%"},n,i),i=[[60,"rgb(0,0,0)",.5],[100,"rgb(0,0,0)",0]],s.makeGradiant("radialGradient",{id:"gradS",cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%"},n,i);let t=["rgb(40,40,40)","rgb(48,48,48)","rgb(30,30,30)"],e=["rgb(1,90,197)","rgb(3,95,207)","rgb(0,65,167)"];i=[[30,t[0],1],[60,t[1],1],[80,t[1],1],[100,t[2],1]],s.makeGradiant("radialGradient",{id:"gradIn",cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%"},n,i),i=[[30,e[0],1],[60,e[1],1],[80,e[1],1],[100,e[2],1]],s.makeGradiant("radialGradient",{id:"gradIn2",cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%"},n,i),s.dom("circle","",{cx:64,cy:64,r:h,fill:"url(#grad)"},n),s.dom("circle","",{cx:69,cy:74,r:o+10,fill:"url(#gradS)"},n),s.dom("circle","",{cx:64,cy:64,r:o,fill:"url(#gradIn)"},n),s.joystick_0=n}else i=[[69,"rgb(0,0,0)",0],[70,"rgb(0,0,0)",.3],[100,"rgb(0,0,0)",0]],s.makeGradiant("radialGradient",{id:"gradX",cx:"50%",cy:"50%",r:"50%",fx:"50%",fy:"50%"},n,i),s.dom("circle","",{cx:64,cy:64,r:h,fill:"none",stroke:"rgba(100,100,100,0.25)","stroke-width":"4"},n),s.dom("circle","",{cx:64,cy:64,r:o+14,fill:"url(#gradX)"},n),s.dom("circle","",{cx:64,cy:64,r:o,fill:"none",stroke:"rgb(100,100,100)","stroke-width":"4"},n),s.joystick_1=n},makeColorRing:function(){let t=256,i=s.dom("svg",s.css.basic,{viewBox:"0 0 256 "+t,width:t,height:t,preserveAspectRatio:"none"});s.dom("defs",null,{},i),s.dom("g",null,{},i);let e,h,o,n,r,l,a,c,u,d=128,p=8/113/24*Math.PI,m=0,g=[];for(l=0;l<=24;++l){if(o=l/24,n=o*s.TwoPI,e=.5*(m+n),h=1/Math.cos(.5*(n-m)),r=[Math.sin(m),-Math.cos(m),Math.sin(e)*h,-Math.cos(e)*h,Math.sin(n),-Math.cos(n)],g[1]=s.rgbToHex(s.hslToRgb([o,1,.5])),l>0){for(a=6;a--;)r[a]=(113*r[a]+d).toFixed(2);c=" M"+r[0]+" "+r[1]+" Q"+r[2]+" "+r[3]+" "+r[4]+" "+r[5],u=[[0,g[0],1],[100,g[1],1]],s.makeGradiant("linearGradient",{id:"G"+l,x1:r[0],y1:r[1],x2:r[4],y2:r[5],gradientUnits:"userSpaceOnUse"},i,u),s.dom("path","",{d:c,"stroke-width":30,stroke:"url(#G"+l+")","stroke-linecap":"butt"},i,1)}m=n-p,g[0]=g[1]}u=[[0,"#FFFFFF",1],[50,"#FFFFFF",0],[50,"#000000",0],[100,"#000000",1]],s.makeGradiant("linearGradient",{id:"GL0",x1:0,y1:d-84.9,x2:0,y2:212.9,gradientUnits:"userSpaceOnUse"},i,u),u=[[0,"#7f7f7f",1],[50,"#7f7f7f",.5],[100,"#7f7f7f",0]],s.makeGradiant("linearGradient",{id:"GL1",x1:78.95,y1:0,x2:226,y2:0,gradientUnits:"userSpaceOnUse"},i,u),s.dom("g",null,{"transform-origin":"128px 128px",transform:"rotate(0)"},i),s.dom("polygon","",{points:"78.95 43.1 78.95 212.85 226 128",fill:"red"},i,2),s.dom("polygon","",{points:"78.95 43.1 78.95 212.85 226 128",fill:"url(#GL1)","stroke-width":1,stroke:"url(#GL1)"},i,2),s.dom("polygon","",{points:"78.95 43.1 78.95 212.85 226 128",fill:"url(#GL0)","stroke-width":1,stroke:"url(#GL0)"},i,2),s.dom("path","",{d:"M 255.75 136.5 Q 256 132.3 256 128 256 123.7 255.75 119.5 L 241 128 255.75 136.5 Z",fill:"none","stroke-width":2,stroke:"#000"},i,2),s.dom("circle","",{cx:128,cy:128,r:6,"stroke-width":2,stroke:"#000",fill:"none"},i),s.colorRing=i},icon:function(t,i,e){e=e||40,i=i||"#DEDEDE";let h=["<svg xmlns='"+s.svgns+"' version='1.1' xmlns:xlink='"+s.htmls+"' style='pointer-events:none;' preserveAspectRatio='xMinYMax meet' x='0px' y='0px' width='"+e+"px' height='"+e+"px' viewBox='0 0 256 256'><g>"];switch(t){case"logo":h[1]="<path id='logoin' fill='"+i+"' stroke='none' d='"+s.logoFill_d+"'/>";break;case"save":h[1]="<path stroke='"+i+"' stroke-width='4' stroke-linejoin='round' stroke-linecap='round' fill='none' d='M 26.125 17 L 20 22.95 14.05 17 M 20 9.95 L 20 22.95'/><path stroke='"+i,h[1]+="' stroke-width='2.5' stroke-linejoin='round' stroke-linecap='round' fill='none' d='M 32.6 23 L 32.6 25.5 Q 32.6 28.5 29.6 28.5 L 10.6 28.5 Q 7.6 28.5 7.6 25.5 L 7.6 23'/>"}return h[2]="</g></svg>",h.join("\n")},logoFill_d:["M 171 150.75 L 171 33.25 155.5 33.25 155.5 150.75 Q 155.5 162.2 147.45 170.2 139.45 178.25 128 178.25 116.6 178.25 108.55 170.2 100.5 162.2 100.5 150.75 ","L 100.5 33.25 85 33.25 85 150.75 Q 85 168.65 97.55 181.15 110.15 193.75 128 193.75 145.9 193.75 158.4 181.15 171 168.65 171 150.75 ","M 200 33.25 L 184 33.25 184 150.8 Q 184 174.1 167.6 190.4 151.3 206.8 128 206.8 104.75 206.8 88.3 190.4 72 174.1 72 150.8 L 72 33.25 56 33.25 56 150.75 ","Q 56 180.55 77.05 201.6 98.2 222.75 128 222.75 157.8 222.75 178.9 201.6 200 180.55 200 150.75 L 200 33.25 Z"].join("\n")};s.setText();const i=s,e={ui:[],dom:null,ID:null,lock:!1,wlock:!1,current:-1,needReZone:!0,isEventsInit:!1,downTime:0,prevTime:0,prevDefault:["contextmenu","wheel"],pointerEvent:["pointerdown","pointermove","pointerup"],eventOut:["pointercancel","pointerout","pointerleave"],xmlserializer:new XMLSerializer,tmpTime:null,tmpImage:null,oldCursor:"auto",input:null,parent:null,firstImput:!0,hiddenImput:null,hiddenSizer:null,hasFocus:!1,startInput:!1,inputRange:[0,0],cursorId:0,str:"",pos:0,startX:-1,moveX:-1,debugInput:!1,isLoop:!1,listens:[],e:{type:null,clientX:0,clientY:0,keyCode:NaN,key:null,delta:0},isMobile:!1,now:null,getTime:function(){return self.performance&&self.performance.now?self.performance.now.bind(performance):Date.now},add:function(t){e.ui.push(t),e.getZone(t),e.isEventsInit||e.initEvents()},testMobile:function(){let t=navigator.userAgent;return!!(t.match(/Android/i)||t.match(/webOS/i)||t.match(/iPhone/i)||t.match(/iPad/i)||t.match(/iPod/i)||t.match(/BlackBerry/i)||t.match(/Windows Phone/i))},remove:function(t){let s=e.ui.indexOf(t);-1!==s&&(e.removeListen(t),e.ui.splice(s,1)),0===e.ui.length&&e.removeEvents()},initEvents:function(){if(e.isEventsInit)return;let t=document.body;e.isMobile=e.testMobile(),e.now=e.getTime(),e.isMobile?t.style.touchAction="none":t.addEventListener("wheel",e,{passive:!1}),t.addEventListener("pointercancel",e),t.addEventListener("pointerleave",e),t.addEventListener("pointerout",e),t.addEventListener("pointerdown",e),t.addEventListener("pointermove",e),t.addEventListener("pointerup",e),t.addEventListener("keydown",e,!1),t.addEventListener("keyup",e,!1),window.addEventListener("resize",e.resize,!1),e.isEventsInit=!0,e.dom=t},removeEvents:function(){if(!e.isEventsInit)return;let t=document.body;e.isMobile||t.removeEventListener("wheel",e),t.removeEventListener("pointercancel",e),t.removeEventListener("pointermove",e),t.removeEventListener("pointerleave",e),t.removeEventListener("pointerdown",e),t.removeEventListener("pointerup",e),t.removeEventListener("pointerout",e),t.removeEventListener("keydown",e),t.removeEventListener("keyup",e),window.removeEventListener("resize",e.resize),e.isEventsInit=!1},resize:function(){e.needReZone=!0;let t,s=e.ui.length;for(;s--;)t=e.ui[s],t.isGui&&!t.isCanvasOnly&&t.autoResize&&t.setHeight()},out:function(){console.log("im am out"),e.clearOldID()},in:function(){console.log("im am in")},fakeUp:function(){this.handleEvent({type:"pointerup"})},handleEvent:function(t){-1!==e.prevDefault.indexOf(t.type)&&t.preventDefault(),e.findZone();let s=e.e,i=!1;"keydown"===t.type&&e.keydown(t),"keyup"===t.type&&e.keyup(t),"wheel"===t.type?s.delta=t.deltaY>0?1:-1:s.delta=0;let h=t.pointerType;if(s.clientX=("touch"===h?t.pageX:t.clientX)||0,s.clientY=("touch"===h?t.pageY:t.clientY)||0,s.type=t.type,-1!==e.eventOut.indexOf(t.type)&&(i=!0,s.type="mouseup"),"pointerdown"===t.type&&(s.type="mousedown"),"pointerup"===t.type&&(s.type="mouseup"),"pointermove"===t.type&&(s.type="mousemove"),"mousedown"===s.type){if(e.downTime=e.now(),e.downTime-e.prevTime<200)return e.selectAll(),!1;e.prevTime=e.downTime}"mousedown"===s.type&&e.clearInput(),"mousedown"===s.type&&(e.lock=!0),"mouseup"===s.type&&(e.lock=!1),e.isMobile&&"mousedown"===s.type&&e.findID(s),"mousemove"!==s.type||e.lock||e.findID(s),null!==e.ID&&(e.ID.isCanvasOnly&&(s.clientX=e.ID.mouse.x,s.clientY=e.ID.mouse.y),e.ID.handleEvent(s)),e.isMobile&&"mouseup"===s.type&&e.clearOldID(),i&&e.clearOldID()},findID:function(t){let s,i,h,o=e.ui.length,n=-1;for(;o--;)if(s=e.ui[o],s.isCanvasOnly?(i=s.mouse.x,h=s.mouse.y):(i=t.clientX,h=t.clientY),e.onZone(s,i,h)){n=o,n!==e.current&&(e.clearOldID(),e.current=n,e.ID=s);break}-1===n&&e.clearOldID()},clearOldID:function(){e.ID&&(e.current=-1,e.ID.reset(),e.ID=null,e.cursor())},calcUis:function(t,s,i){let e,h,o=t.length,n=0,r=0;for(h=0;h<o;h++)e=t[h],e.zone.w=e.w,e.zone.h=e.h,e.autoWidth?(e.zone.x=s.x,e.zone.y=i,i+=e.h+1):(0===n&&(i+=e.h+1),e.zone.x=s.x+n,e.zone.y=0===n?i-e.h:r,r=e.zone.y,n+=e.w,n+e.w>s.w&&(n=0)),e.isGroup&&e.calcUis()},findTarget:function(t,s){let i=t.length;for(;i--;)if(e.onZone(t[i],s.clientX,s.clientY))return i;return-1},findZone:function(t){if(e.needReZone||t){for(var s,i=e.ui.length;i--;)s=e.ui[i],e.getZone(s),s.isGui&&s.calcUis();e.needReZone=!1}},onZone:function(t,s,i){if(void 0===s||void 0===i)return!1;let e=t.zone,h=s-e.x,o=i-e.y,n=h>=0&&o>=0&&h<=e.w&&o<=e.h;return n?t.local.set(h,o):t.local.neg(),n},getZone:function(t){if(t.isCanvasOnly)return;let s=t.getDom().getBoundingClientRect();t.zone={x:s.left,y:s.top,w:s.width,h:s.height}},cursor:function(t){(t=t||"auto")!==e.oldCursor&&(document.body.style.cursor=t,e.oldCursor=t)},toCanvas:function(t,s,i,h){if(h&&null!==e.tmpTime&&(clearTimeout(e.tmpTime),e.tmpTime=null),null!==e.tmpTime)return;e.lock&&(e.tmpTime=setTimeout((function(){e.tmpTime=null}),10));let o=!1;s===t.canvas.width&&i===t.canvas.height||(o=!0),null===e.tmpImage&&(e.tmpImage=new Image);let n=e.tmpImage,r=e.xmlserializer.serializeToString(t.content),l='<svg xmlns="http://www.w3.org/2000/svg" width="'+s+'" height="'+i+'"><foreignObject style="pointer-events: none; left:0;" width="100%" height="100%">'+r+"</foreignObject></svg>";n.onload=function(){let e=t.canvas.getContext("2d");o?(t.canvas.width=s,t.canvas.height=i):e.clearRect(0,0,s,i),e.drawImage(this,0,0),t.onDraw()},n.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(l),n.crossOrigin=""},setHidden:function(){if(null===e.hiddenImput){let t=e.debugInput?"":"opacity:0; zIndex:0;",s=e.parent.css.txt+"padding:0; width:auto; height:auto; text-shadow:none;";s+="left:10px; top:auto; border:none; color:#FFF; background:#000;"+t,e.hiddenImput=document.createElement("input"),e.hiddenImput.type="text",e.hiddenImput.style.cssText=s+"bottom:30px;"+(e.debugInput?"":"transform:scale(0);"),e.hiddenSizer=document.createElement("div"),e.hiddenSizer.style.cssText=s+"bottom:60px;",document.body.appendChild(e.hiddenImput),document.body.appendChild(e.hiddenSizer)}e.hiddenImput.style.width=e.input.clientWidth+"px",e.hiddenImput.value=e.str,e.hiddenSizer.innerHTML=e.str,e.hasFocus=!0},clearHidden:function(t){null!==e.hiddenImput&&(e.hasFocus=!1)},clickPos:function(t){let s=e.str.length,i=0,h=0;for(;s--&&(i+=e.textWidth(e.str[h]),!(i>=t));)h++;return h},upInput:function(t,s){if(null===e.parent)return!1;let i=!1;if(s){let s=e.clickPos(t);if(e.moveX=s,-1===e.startX)e.startX=s,e.cursorId=s,e.inputRange=[e.startX,e.startX];else{e.moveX!==e.startX&&(e.startX>e.moveX?e.inputRange=[e.moveX,e.startX]:e.inputRange=[e.startX,e.moveX])}i=!0}else-1!==e.startX&&(e.hasFocus=!0,e.hiddenImput.focus(),e.hiddenImput.selectionStart=e.inputRange[0],e.hiddenImput.selectionEnd=e.inputRange[1],e.startX=-1,i=!0);return i&&e.selectParent(),i},selectAll:function(){e.parent&&(e.str=e.input.textContent,e.inputRange=[0,e.str.length],e.hasFocus=!0,e.hiddenImput.focus(),e.hiddenImput.selectionStart=e.inputRange[0],e.hiddenImput.selectionEnd=e.inputRange[1],e.cursorId=e.inputRange[1],e.selectParent())},selectParent:function(){var t=e.textWidth(e.str.substring(0,e.cursorId)),s=e.textWidth(e.str.substring(0,e.inputRange[0])),i=e.textWidth(e.str.substring(e.inputRange[0],e.inputRange[1]));e.parent.select(t,s,i)},textWidth:function(t){return null===e.hiddenSizer?0:(t=t.replace(/ /g,"&nbsp;"),e.hiddenSizer.innerHTML=t,e.hiddenSizer.clientWidth)},clearInput:function(){null!==e.parent&&(e.firstImput||e.parent.validate(!0),e.clearHidden(),e.parent.unselect(),e.input.style.background=e.parent.colors.inputBg,e.input.style.borderColor=e.parent.colors.inputBorder,e.parent.isEdit=!1,e.input=null,e.parent=null,e.str="",e.firstImput=!0)},setInput:function(t,s){e.clearInput(),e.input=t,e.parent=s,e.input.style.background=e.parent.colors.inputOver,e.input.style.borderColor=e.parent.colors.inputBorderSelect,e.str=e.input.textContent,e.setHidden()},keydown:function(t){if(null===e.parent)return;let s=t.which;t.shiftKey,e.firstImput=!1,e.hasFocus&&(window.focus(),e.hiddenImput.focus()),e.parent.isEdit=!0,13===s?e.clearInput():e.input.isNum?t.keyCode>47&&t.keyCode<58||t.keyCode>95&&t.keyCode<106||190===t.keyCode||110===t.keyCode||8===t.keyCode||109===t.keyCode?e.hiddenImput.readOnly=!1:e.hiddenImput.readOnly=!0:e.hiddenImput.readOnly=!1},keyup:function(t){null!==e.parent&&(e.str=e.hiddenImput.value,e.parent.allEqual?e.parent.sameStr(e.str):e.input.textContent=e.str,e.cursorId=e.hiddenImput.selectionStart,e.inputRange=[e.hiddenImput.selectionStart,e.hiddenImput.selectionEnd],e.selectParent(),e.parent.validate())},loop:function(){e.isLoop&&requestAnimationFrame(e.loop),e.update()},update:function(){let t=e.listens.length;for(;t--;)e.listens[t].listening()},removeListen:function(t){let s=e.listens.indexOf(t);-1!==s&&e.listens.splice(s,1),0===e.listens.length&&(e.isLoop=!1)},addListen:function(t){return-1===e.listens.indexOf(t)&&(e.listens.push(t),e.isLoop||(e.isLoop=!0,e.loop()),!0)}},h=e;class o{constructor(t=0,s=0){this.x=t,this.y=s}set(t,s){return this.x=t,this.y=s,this}divide(t){return this.x/=t.x,this.y/=t.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divideScalar(t){return this.multiplyScalar(1/t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}angle(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t}addScalar(t){return this.x+=t,this.y+=t,this}negate(){return this.x*=-1,this.y*=-1,this}neg(){return this.x=-1,this.y=-1,this}isZero(){return 0===this.x&&0===this.y}copy(t){return this.x=t.x,this.y=t.y,this}equals(t){return t.x===this.x&&t.y===this.y}nearEquals(t,s){return t.x.toFixed(s)===this.x.toFixed(s)&&t.y.toFixed(s)===this.y.toFixed(s)}lerp(t,s){return null===t?(this.x-=this.x*s,this.y-=this.y*s):(this.x+=(t.x-this.x)*s,this.y+=(t.y-this.y)*s),this}}class n{constructor(t={}){if(this.lock=t.lock||!1,this.main=t.main||null,this.isUI=t.isUI||!1,this.group=null,this.isListen=!1,this.ontop=!!t.ontop&&t.ontop,this.css=this.main?this.main.css:i.css,this.colors=this.main?this.main.colors:i.colors,this.defaultBorderColor=this.colors.border,this.svgs=i.svgs,this.isSpace=t.isSpace||!1,this.zone={x:0,y:0,w:0,h:0},this.local=(new o).neg(),this.isCanvasOnly=!1,this.isSelect=!1,this.p=void 0!==t.p?t.p:i.size.p,this.w=this.isUI?this.main.size.w:i.size.w,void 0!==t.w&&(this.w=t.w),this.h=this.isUI?this.main.size.h:i.size.h,void 0!==t.h&&(this.h=t.h),this.isSpace||(this.h=this.h<11?11:this.h),this.autoWidth=t.auto||!0,this.isOpen=!1,this.radius=t.radius||this.colors.radius,this.isNumber=!1,this.noNeg=t.noNeg||!1,this.allEqual=t.allEqual||!1,this.mono=!1,this.isEdit=!1,this.simple=t.simple||!1,this.simple&&(this.sa=0),this.setSize(this.w),void 0!==t.sa&&(this.sa=t.sa),void 0!==t.sb&&(this.sb=t.sb),this.simple&&(this.sb=this.w-this.sa),this.sc=void 0===t.sc?47:t.sc,this.objectLink=null,this.isSend=!1,this.val=null,this.bg=this.colors.background,this.bgOver=this.colors.backgroundOver,void 0!==t.bg&&(this.bg=t.bg,this.bgOver=t.bg),void 0!==t.bgOver&&(this.bgOver=t.bgOver),this.titleColor=t.titleColor||this.colors.text,this.fontColor=t.fontColor||this.colors.text,this.fontSelect=t.fontSelect||this.colors.textOver,void 0!==t.color&&(this.fontColor=t.color),this.colorPlus=i.ColorLuma(this.fontColor,.3),this.txt=t.name||"",this.name=t.rename||this.txt,this.target=t.target||null,this.callback=void 0===t.callback?null:t.callback,this.endCallback=null,null===this.callback&&this.isUI&&null!==this.main.callback&&(this.callback=this.main.callback),this.c=[],this.s=[],this.c[0]=i.dom("div",this.css.basic+"position:relative; height:20px; float:left; overflow:hidden;"),this.s[0]=this.c[0].style,this.isUI&&(this.s[0].marginBottom="1px"),this.simple||(this.c[1]=i.dom("div",this.css.txt),this.s[1]=this.c[1].style,this.c[1].textContent=this.name,this.s[1].color=this.titleColor),t.pos){this.s[0].position="absolute";for(let s in t.pos)this.s[0][s]=t.pos[s];this.mono=!0}t.css&&(this.s[0].cssText=t.css)}init(){this.zone.h=this.h;let t=this.s,s=this.c;t[0].height=this.h+"px",this.isUI&&(t[0].background=this.bg),void 0!==s[1]&&this.autoWidth&&(t[1]=s[1].style,t[1].height=this.h-4+"px",t[1].lineHeight=this.h-8+"px");let e=i.frag;for(let i=1,h=s.length;i!==h;i++)void 0!==s[i]&&(e.appendChild(s[i]),t[i]=s[i].style);let o=null!==this.target?this.target:this.isUI?this.main.inner:document.body;this.ontop?o.insertAdjacentElement("afterbegin",s[0]):o.appendChild(s[0]),s[0].appendChild(e),this.rSize(),this.isUI||(this.c[0].style.pointerEvents="auto",h.add(this))}dom(t,s,e,h,o){return i.dom(t,s,e,h,o)}setSvg(t,s,e,h,o){i.setSvg(t,s,e,h,o)}setCss(t,s){i.setCss(t,s)}clamp(t,s,e){return i.clamp(t,s,e)}getColorRing(){return i.colorRing||i.makeColorRing(),i.clone(i.colorRing)}getJoystick(t){return i["joystick_"+t]||i.makeJoystick(t),i.clone(i["joystick_"+t])}getCircular(t){return i.circular||i.makeCircular(t),i.clone(i.circular)}getKnob(t){return i.knob||i.makeKnob(t),i.clone(i.knob)}cursor(t){h.cursor(t)}update(){}reset(){}getDom(){return this.c[0]}uiout(){this.isSpace||this.s&&(this.s[0].background=this.bg)}uiover(){this.isSpace||this.s&&(this.s[0].background=this.bgOver)}rename(t){void 0!==this.c[1]&&(this.c[1].textContent=t)}listen(){return this.isListen=h.addListen(this),this}listening(){null!==this.objectLink&&(this.isSend||this.isEdit||this.setValue(this.objectLink[this.val]))}setValue(t){this.isNumber?this.value=this.numValue(t):this.value=t,this.update()}onChange(t){if(!this.isSpace)return this.callback=t||null,this}onFinishChange(t){if(!this.isSpace)return this.callback=null,this.endCallback=t,this}send(t){(t=t||this.value)instanceof Array&&1===t.length&&(t=t[0]),this.isSend=!0,null!==this.objectLink&&(this.objectLink[this.val]=t),this.callback&&this.callback(t,this.val),this.isSend=!1}sendEnd(t){(t=t||this.value)instanceof Array&&1===t.length&&(t=t[0]),this.endCallback&&this.endCallback(t),null!==this.objectLink&&(this.objectLink[this.val]=t)}clear(t){this.isListen&&h.removeListen(this),i.clear(this.c[0]),t||(null!==this.target?null!==this.group?this.group.clearOne(this):this.target.removeChild(this.c[0]):this.isUI?this.main.clearOne(this):document.body.removeChild(this.c[0]),this.isUI||h.remove(this)),this.c=null,this.s=null,this.callback=null,this.target=null,this.isListen=!1}setSize(t){if(this.autoWidth)if(this.w=t,this.simple)this.sb=this.w-this.sa;else{let t=this.w*(this.p/100);this.sa=Math.floor(t+10),this.sb=Math.floor(this.w-t-20)}}rSize(){this.autoWidth&&(this.s[0].width=this.w+"px",this.simple||(this.s[1].width=this.sa+"px"))}setTypeNumber(t){let s;switch(this.isNumber=!0,this.value=0,void 0!==t.value&&("string"==typeof t.value?this.value=1*t.value:this.value=t.value),this.min=void 0===t.min?-1/0:t.min,this.max=void 0===t.max?1/0:t.max,this.precision=void 0===t.precision?2:t.precision,this.precision){case 0:s=1;break;case 1:s=.1;break;case 2:s=.01;break;case 3:s=.001;break;case 4:s=1e-4;break;case 5:s=1e-5}this.step=void 0===t.step?s:t.step,this.range=this.max-this.min,this.value=this.numValue(this.value)}numValue(t){return this.noNeg&&(t=Math.abs(t)),1*Math.min(this.max,Math.max(this.min,t)).toFixed(this.precision)}handleEvent(t){return this[t.type]?this.lock||this.isSpace?void 0:this[t.type](t):console.error(t.type,"this type of event no existe !")}wheel(t){return!1}mousedown(t){return!1}mousemove(t){return!1}mouseup(t){return!1}keydown(t){return!1}keyup(t){return!1}setReferency(t,s){this.objectLink=t,this.val=s}display(t){t=t||!1,this.s[0].display=t?"block":"none"}open(){this.isOpen||(this.isOpen=!0)}close(){this.isOpen&&(this.isOpen=!1)}needZone(){h.needReZone=!0}rezone(){h.needReZone=!0}select(){}unselect(){}setInput(t){h.setInput(t,this)}upInput(t,s){return h.upInput(t,s)}selected(t){this.isSelect=t||!1}}class r extends n{constructor(t={}){if(super(t),this.value=t.value||!1,this.model=void 0!==t.mode?t.mode:0,this.onName=t.rename||this.txt,t.onName&&(t.onname=t.onName),t.onname&&(this.onName=t.onname),this.buttonColor=t.bColor||this.colors.button,this.inh=t.inh||Math.floor(.8*this.h),this.inw=t.inw||36,0===this.model){let t=Math.floor(.5*this.h)-.5*(this.inh-2);this.c[2]=this.dom("div",this.css.basic+"background:"+this.colors.boolbg+"; height:"+(this.inh-2)+"px; width:"+this.inw+"px; top:"+t+"px; border-radius:10px; border:2px solid "+this.boolbg),this.c[3]=this.dom("div",this.css.basic+"height:"+(this.inh-6)+"px; width:16px; top:"+(t+2)+"px; border-radius:10px; background:"+this.buttonColor+";")}else this.p=0,this.c[1].textContent="",this.c[2]=this.dom("div",this.css.txt+this.css.button+"top:1px; background:"+this.colors.button+"; height:"+(this.h-2)+"px; border:"+this.colors.buttonBorder+"; border-radius:"+this.radius+"px;");this.stat=-1,this.mode(this.value?2:1),this.init(),this.update()}mousedown(t){return this.value=!this.value,this.update(!0),this.mousemove(t)}mousemove(t){return this.cursor("pointer"),this.mode(this.value?4:3)}reset(){return this.cursor(),this.mode(this.value?2:1)}mode(t){let s=!1;if(this.stat!==t){if(0!==this.model){let s=this.c[2].style;switch(t){case 1:this.stat=1,s.color=this.fontColor,s.background=this.colors.button;break;case 2:this.stat=2,s.color=this.fontSelect,s.background=this.colors.select;break;case 3:this.stat=3,s.color=this.fontSelect,s.background=this.colors.over2;break;case 4:this.stat=4,s.color=this.fontSelect,s.background=this.colors.over}this.c[2].innerHTML=this.value?this.onName:this.name}else this.c[2].style.background=this.value?this.colors.boolon:this.colors.boolbg,this.c[2].style.borderColor=this.value?this.colors.boolon:this.colors.boolbg,this.c[3].style.marginLeft=this.value?"17px":"2px",this.c[1].textContent=this.value?this.onName:this.name;s=!0}return s}update(t){this.mode(this.value?4:3),t&&this.send()}rSize(){super.rSize();let t=this.s,s=this.w-10-this.inw;0===this.model?(t[2].left=s+"px",t[3].left=s+"px"):(t[2].left=this.sa+"px",t[2].width=this.w-20+"px")}}class l extends n{constructor(t={}){super(t),this.value=!1,this.values=t.value||this.txt,this.onName=t.onName||"",this.on=!1,this.customSize=t.forceWidth||-1,"string"==typeof this.values&&(this.values=[this.values]),this.isDown=!1,this.isLink=t.link||!1,this.cc=[this.colors.button,this.colors.over,this.colors.select],void 0!==t.cBg&&(this.cc[0]=t.cBg),void 0!==t.bColor&&(this.cc[0]=t.bColor),void 0!==t.cSelect&&(this.cc[1]=t.cSelect),void 0!==t.cDown&&(this.cc[2]=t.cDown),this.isLoadButton=t.loader||!1,this.isDragButton=t.drag||!1,this.isDragButton&&(this.isLoadButton=!0),this.lng=this.values.length,this.tmp=[],this.stat=[];for(let t=0;t<this.lng;t++)this.c[t+2]=this.dom("div",this.css.txt+this.css.button+"top:1px; background:"+this.cc[0]+"; height:"+(this.h-2)+"px; border:"+this.colors.buttonBorder+"; border-radius:"+this.radius+"px;"),this.c[t+2].style.color=this.fontColor,this.c[t+2].innerHTML=this.values[t],this.stat[t]=1;void 0!==this.c[1]&&(this.c[1].textContent=""),this.isLoadButton&&this.initLoader(),this.isDragButton&&(this.lng++,this.initDrager()),""!==this.onName&&(this.values[0]=this.on),this.init()}onOff(){this.on=!this.on,this.c[2].innerHTML=this.on?this.onName:this.txt}testZone(t){let s=this.local;if(-1===s.x&&-1===s.y)return"";let i=this.lng,e=this.tmp;for(;i--;)if(s.x>e[i][0]&&s.x<e[i][2])return i+2;return""}mouseup(t){return!!this.isDown&&(this.isDown=!1,this.mousemove(t))}mousedown(t){return this.isDown=!0,this.value=this.values[name-2],this.isLoadButton||this.send(),this.mousemove(t)}mousemove(t){let s=!1,i=this.testZone(t);return""!==i?(this.cursor("pointer"),s=this.modes(this.isDown?3:2,i)):s=this.reset(),s}modes(t,s){let i,e=!1;for(let h=0;h<this.lng;h++)i=h===s-2?this.mode(t,h+2):this.mode(1,h+2),i&&(e=!0);return e}mode(t,s){let i=!1,e=s-2;if(this.stat[e]!==t){switch(t){case 1:this.stat[e]=1,this.s[e+2].color=this.fontColor,this.s[e+2].background=this.cc[0];break;case 2:this.stat[e]=2,this.s[e+2].color=this.fontSelect,this.s[e+2].background=this.cc[1];break;case 3:this.stat[e]=3,this.s[e+2].color=this.fontSelect,this.s[e+2].background=this.cc[2]}i=!0}return i}reset(){return this.value=!1,this.cursor(),this.modes(1,2)}dragover(t){t.preventDefault(),this.s[4].borderColor=this.colors.select,this.s[4].color=this.colors.select}dragend(t){t.preventDefault(),this.s[4].borderColor=this.fontColor,this.s[4].color=this.fontColor}drop(t){t.preventDefault(),this.dragend(t),this.fileSelect(t.dataTransfer.files[0])}initDrager(){this.c[4]=this.dom("div",this.css.txt+" text-align:center; line-height:"+(this.h-8)+"px; border:1px dashed "+this.fontColor+"; top:2px;\theight:"+(this.h-4)+"px; border-radius:"+this.radius+"px; pointer-events:auto;"),this.c[4].textContent="DRAG",this.c[4].addEventListener("dragover",function(t){this.dragover(t)}.bind(this),!1),this.c[4].addEventListener("dragend",function(t){this.dragend(t)}.bind(this),!1),this.c[4].addEventListener("dragleave",function(t){this.dragend(t)}.bind(this),!1),this.c[4].addEventListener("drop",function(t){this.drop(t)}.bind(this),!1)}initLoader(){this.c[3]=this.dom("input",this.css.basic+"top:0px; opacity:0; height:"+this.h+"px; pointer-events:auto; cursor:pointer;"),this.c[3].name="loader",this.c[3].type="file",this.c[3].addEventListener("change",function(t){this.fileSelect(t.target.files[0])}.bind(this),!1)}fileSelect(t){if(void 0===t)return;let s=new FileReader,i=t.name,e=i.substring(i.lastIndexOf(".")+1,i.length);-1!==["png","jpg","mp4","webm","ogg"].indexOf(e)?s.readAsDataURL(t):-1!==["sea","z","hex","bvh","BVH","glb"].indexOf(e)?s.readAsArrayBuffer(t):s.readAsText(t),s.onload=function(t){this.callback&&this.callback(t.target.result,i,e)}.bind(this)}label(t,s){s=s||2,this.c[s].textContent=t}icon(t,s,i){i=i||2,this.s[i].padding=(s||0)+"px 0px",this.c[i].innerHTML=t}rSize(){super.rSize();let t=this.s,s=this.sb,i=this.sa,e=this.lng,h=Math.floor((s-3*(e-1))/e);for(-1!==this.customSize&&(h=this.customSize);e--;)this.tmp[e]=[Math.floor(i+h*e+3*e),h],this.tmp[e][2]=this.tmp[e][0]+this.tmp[e][1],t[e+2].left=this.tmp[e][0]+"px",t[e+2].width=this.tmp[e][1]+"px";this.isDragButton&&(t[4].left=i+h+3+"px",t[4].width=h+"px"),this.isLoadButton&&(t[3].left=i+"px",t[3].width=h+"px")}}class a extends n{constructor(t={}){super(t),this.isCyclic=t.cyclic||!1,this.model=t.stype||0,void 0!==t.mode&&(this.model=t.mode),this.autoWidth=!1,this.buttonColor=this.colors.button,this.setTypeNumber(t),this.radius=.5*this.w,this.twoPi=2*Math.PI,this.pi90=.5*Math.PI,this.offset=new o,this.h=t.h||this.w+10,this.top=0,this.c[0].style.width=this.w+"px",void 0!==this.c[1]&&(this.c[1].style.width=this.w+"px",this.c[1].style.textAlign="center",this.top=10,this.h+=10),this.percent=0,this.cmode=0,this.c[2]=this.dom("div",this.css.txt+"text-align:center; top:"+(this.h-20)+"px; width:"+this.w+"px; color:"+this.fontColor),this.c[3]=this.getCircular(),this.setSvg(this.c[3],"d",this.makePath(),1),this.setSvg(this.c[3],"stroke",this.fontColor,1),this.setSvg(this.c[3],"viewBox","0 0 "+this.w+" "+this.w),this.setCss(this.c[3],{width:this.w,height:this.w,left:0,top:this.top}),this.init(),this.update()}mode(t){if(this.cmode===t)return!1;switch(t){case 0:if(this.s[2].color=this.fontColor,this.setSvg(this.c[3],"stroke","rgba(0,0,0,0.1)",0),this.model>0){let t=i.pack(i.lerpColor(i.unpack(i.ColorLuma(this.fontColor,-.75)),i.unpack(this.fontColor),this.percent));this.setSvg(this.c[3],"stroke",t,1)}else this.setSvg(this.c[3],"stroke",this.fontColor,1);break;case 1:if(this.s[2].color=this.colorPlus,this.setSvg(this.c[3],"stroke","rgba(0,0,0,0.3)",0),this.model>0){let t=i.pack(i.lerpColor(i.unpack(i.ColorLuma(this.fontColor,-.75)),i.unpack(this.fontColor),this.percent));this.setSvg(this.c[3],"stroke",t,1)}else this.setSvg(this.c[3],"stroke",this.colorPlus,1)}return this.cmode=t,!0}reset(){this.isDown=!1}testZone(t){let s=this.local;return-1===s.x&&-1===s.y?"":s.y<=this.c[1].offsetHeight?"title":s.y>this.h-this.c[2].offsetHeight?"text":"circular"}mouseup(t){return this.isDown=!1,this.sendEnd(),this.mode(0)}mousedown(t){return this.isDown=!0,this.old=this.value,this.oldr=null,this.mousemove(t),this.mode(1)}mousemove(t){if(this.isDown){var s=this.offset;if(s.x=this.radius-(t.clientX-this.zone.x),s.y=this.radius-(t.clientY-this.zone.y-this.top),this.r=s.angle()-this.pi90,this.r=(this.r%this.twoPi+this.twoPi)%this.twoPi,null!==this.oldr){var i=this.r-this.oldr;this.r=Math.abs(i)>Math.PI?this.oldr:this.r,i>6&&(this.r=0),i<-6&&(this.r=this.twoPi)}var e=1/this.twoPi,h=this.r*e,o=this.range*h+this.min-this.old;(o>=this.step||o<=this.step)&&(o=~~(o/this.step),this.value=this.numValue(this.old+o*this.step),this.update(!0),this.old=this.value,this.oldr=this.r)}}wheel(t){if("circular"===this.testZone(t)){let s=this.value-this.step*t.delta;return s>this.max?s=this.isCyclic?this.min:this.max:s<this.min&&(s=this.isCyclic?this.max:this.min),this.setValue(s),this.old=s,this.update(!0),!0}return!1}makePath(){var t=40,s=this.percent*this.twoPi-.001,i=t+t*Math.sin(s)+24,e=t-t*Math.cos(s)+24;return"M 64,24 A 40,40 0 "+(s>Math.PI?1:0)+" 1 "+i+","+e}update(t){if(this.c[2].textContent=this.value,this.percent=(this.value-this.min)/this.range,this.setSvg(this.c[3],"d",this.makePath(),1),this.model>0){let t=i.pack(i.lerpColor(i.unpack(i.ColorLuma(this.fontColor,-.75)),i.unpack(this.fontColor),this.percent));this.setSvg(this.c[3],"stroke",t,1)}t&&this.send()}}class c extends n{constructor(t={}){super(t),this.ctype=t.ctype||"hex",this.wfixe=256,this.cw=this.sb>256?256:this.sb,null!=t.cw&&(this.cw=t.cw),this.side=t.side||"down",this.up="down"===this.side?0:1,this.baseH=this.h,this.offset=new o,this.decal=new o,this.pp=new o,this.c[2]=this.dom("div",this.css.txt+"height:"+(this.h-4)+"px;border-radius:"+this.radius+"px; line-height:"+(this.h-8)+"px;"),this.s[2]=this.c[2].style,this.s[2].textShadow="none",this.up&&(this.s[2].top="auto",this.s[2].bottom="2px"),this.c[3]=this.getColorRing(),this.c[3].style.visibility="hidden",this.hsl=null,this.value="#ffffff",void 0!==t.value&&(t.value instanceof Array?this.value=i.rgbToHex(t.value):isNaN(t.value)?this.value=t.value:this.value=i.hexToHtml(t.value)),this.bcolor=null,this.isDown=!1,this.fistDown=!1,this.tr=98,this.tsl=Math.sqrt(3)*this.tr,this.hue=0,this.d=256,this.setColor(this.value),this.init(),void 0!==t.open&&this.open()}testZone(t,s){let i=this.local;return-1===i.x&&-1===i.y?"":this.up&&this.isOpen?i.y>this.wfixe?"title":"color":i.y<this.baseH+2?"title":this.isOpen?"color":void 0}mouseup(t){this.isDown=!1,this.d=256}mousedown(t){let s=this.testZone(t.clientX,t.clientY);if("title"===s)return this.isOpen?this.close():this.open(),!0;"color"===s&&(this.isDown=!0,this.fistDown=!0,this.mousemove(t))}mousemove(t){let s,e,h,o,n,r,l,a,c,u=this.testZone(t.clientX,t.clientY),d=i;if("title"===u&&this.cursor("pointer"),"color"===u&&(s=this.offset,s.x=t.clientX-(this.zone.x+this.decal.x+this.mid),s.y=t.clientY-(this.zone.y+this.decal.y+this.mid),e=s.length()*this.ratio,c=s.angle(),c<0&&(c+=2*d.PI),e<128?this.cursor("crosshair"):this.isDown||this.cursor(),this.isDown&&(this.fistDown&&(this.d=e,this.fistDown=!1),this.d<128)))if(this.d>this.tr)h=(c+d.pi90)/d.TwoPI,this.hue=(h+1)%1,this.setHSL([(h+1)%1,this.hsl[1],this.hsl[2]]);else{l=s.x*this.ratio,a=s.y*this.ratio;let t=this.hue*d.TwoPI+d.PI;t<0&&(t+=2*d.PI),r=Math.atan2(-a,l),r<0&&(r+=2*d.PI);let i=(r+d.pi90+d.TwoPI+t)%d.TwoPI,e=i%(2/3*d.PI)-d.pi60,h=.5*this.tr,c=Math.tan(e)*h,u=Math.sqrt(l*l+a*a),p=Math.sqrt(h*h+c*c);if(u>p){let s=Math.tan(e)*u,o=Math.atan(s/p);o>d.pi60?o=d.pi60:o<-d.pi60&&(o=-d.pi60),r+=o-e,i=(r+d.pi90+d.TwoPI+t)%d.TwoPI,e=i%(2/3*d.PI)-d.pi60,c=Math.tan(e)*h,u=p=Math.sqrt(h*h+c*c)}n=Math.sin(i)*u/this.tsl+.5;let m=1-2*Math.abs(n-.5);o=(Math.cos(i)*u+this.tr/2)/(1.5*this.tr)/m,o=d.clamp(o,0,1),this.setHSL([this.hsl[0],o,n])}}setHeight(){this.h=this.isOpen?this.wfixe+this.baseH+5:this.baseH,this.s[0].height=this.h+"px",this.zone.h=this.h}parentHeight(t){null!==this.group?this.group.calc(t):this.isUI&&this.main.calc(t)}open(){super.open(),this.setHeight(),this.up&&(this.zone.y-=this.wfixe+5);let t=this.h-this.baseH;this.s[3].visibility="visible",this.parentHeight(t)}close(){super.close(),this.up&&(this.zone.y+=this.wfixe+5);let t=this.h-this.baseH;this.setHeight(),this.s[3].visibility="hidden",this.parentHeight(-t)}update(t){let s=i.rgbToHex(i.hslToRgb([this.hsl[0],1,.5]));this.moveMarkers(),this.value=this.bcolor,this.setSvg(this.c[3],"fill",s,2,0),this.s[2].background=this.bcolor,this.c[2].textContent=i.htmlToHex(this.bcolor),this.invert=i.findDeepInver(this.rgb),this.s[2].color=this.invert?"#fff":"#000",t&&("array"===this.ctype&&this.send(this.rgb),"rgb"===this.ctype&&this.send(i.htmlRgb(this.rgb)),"hex"===this.ctype&&this.send(i.htmlToHex(this.value)),"html"===this.ctype&&this.send())}setColor(t){let s=i.unpack(t);return this.bcolor!=t&&s&&(this.bcolor=t,this.rgb=s,this.hsl=i.rgbToHsl(this.rgb),this.hue=this.hsl[0],this.update()),this}setHSL(t){return this.hsl=t,this.rgb=i.hslToRgb(t),this.bcolor=i.rgbToHex(this.rgb),this.update(!0),this}moveMarkers(){let t=this.pp,s=i;this.invert;let e=this.hsl[0]*s.TwoPI,h=2/3*s.PI,o=this.tr,n=this.hsl[0],r=this.hsl[1],l=this.hsl[2],a=(e-s.pi90)*s.todeg;n=-e+s.pi90;let c=Math.cos(n)*o,u=-Math.sin(n)*o,d=Math.cos(n-h)*o,p=-Math.sin(n-h)*o,m=Math.cos(n+h)*o,g=-Math.sin(n+h)*o,v=(d+m)/2,x=(p+g)/2;e=(1-2*Math.abs(l-.5))*r;let f=d+(m-d)*l+(c-v)*e,b=p+(g-p)*l+(u-x)*e;t.set(f,b).addScalar(128),this.setSvg(this.c[3],"transform","rotate("+a+" )",2),this.setSvg(this.c[3],"cx",t.x,3),this.setSvg(this.c[3],"cy",t.y,3),this.setSvg(this.c[3],"stroke",this.invert?"#fff":"#000",2,3),this.setSvg(this.c[3],"stroke",this.invert?"#fff":"#000",3),this.setSvg(this.c[3],"fill",this.bcolor,3)}rSize(){super.rSize();let t=this.s;t[2].width=this.sb+"px",t[2].left=this.sa+"px",this.rSizeColor(this.cw),this.decal.x=Math.floor(.5*(this.w-this.wfixe)),t[3].left=this.decal.x+"px"}rSizeColor(t){if(t===this.wfixe)return;this.wfixe=t;let s=this.s;this.decal.y="up"===this.side?2:this.baseH+2,this.mid=Math.floor(.5*this.wfixe),this.setSvg(this.c[3],"viewBox","0 0 "+this.wfixe+" "+this.wfixe),s[3].width=this.wfixe+"px",s[3].height=this.wfixe+"px",s[3].top=this.decal.y+"px",this.ratio=256/this.wfixe,this.square=1/(this.wfixe/256*60),this.setHeight()}}class u extends n{constructor(t={}){super(t),this.round=Math.round,this.baseH=this.h,this.hplus=t.hplus||50,this.res=t.res||40,this.l=1,this.precision=t.precision||0,this.custom=t.custom||!1,this.names=t.names||["FPS","MS"];let s=t.cc||["220,220,220","255,255,0"];this.adding=t.adding||!1,this.range=t.range||[165,100,100],this.alpha=t.alpha||.25,this.values=[],this.points=[],this.textDisplay=[],this.custom||(this.now=h.getTime(),this.startTime=0,this.prevTime=0,this.frames=0,this.ms=0,this.fps=0,this.mem=0,this.mm=0,this.isMem=!(!self.performance||!self.performance.memory),this.isMem&&(this.names.push("MEM"),s.push("0,255,255")),this.txt=t.name||"Fps");let i=Math.floor(.5*this.h)-6;this.c[1].textContent=this.txt,this.c[0].style.cursor="pointer",this.c[0].style.pointerEvents="auto";let e="display:none; left:10px; top:"+this.h+"px; height:"+(this.hplus-8)+"px; box-sizing:border-box; background: rgba(0, 0, 0, 0.2); border:"+("none"!==this.colors.groupBorder?this.colors.groupBorder+";":"1px solid rgba(255, 255, 255, 0.2);");0!==this.radius&&(e+="border-radius:"+this.radius+"px;"),this.c[2]=this.dom("path",this.css.basic+e,{}),this.c[2].setAttribute("viewBox","0 0 "+this.res+" 50"),this.c[2].setAttribute("height","100%"),this.c[2].setAttribute("width","100%"),this.c[2].setAttribute("preserveAspectRatio","none"),this.c[3]=this.dom("path",this.css.basic+"position:absolute; width:10px; height:10px; left:4px; top:"+i+"px;",{d:this.svgs.arrow,fill:this.fontColor,stroke:"none"}),this.c[4]=this.dom("div",this.css.txt+"position:absolute; left:10px; top:"+(this.h+2)+"px; display:none; width:100%; text-align:center;"),t.bottomLine&&(this.c[4]=this.dom("div",this.css.basic+"width:100%; bottom:0px; height:1px; background: rgba(255, 255, 255, 0.2);")),this.isShow=!1;let o=this.s;o[1].marginLeft="10px",o[1].lineHeight=this.h-4,o[1].color=this.fontColor,o[1].fontWeight="bold",0!==this.radius&&(o[0].borderRadius=this.radius+"px"),o[0].border=this.colors.groupBorder;let n=0;for(n=0;n<this.names.length;n++){let t=[],i=this.res+1;for(;i--;)t.push(50);this.range[n]=1/this.range[n]*49,this.points.push(t),this.values.push(0),this.textDisplay.push("<span style='color:rgb("+s[n]+")'> "+this.names[n]+" ")}for(n=this.names.length;n--;)this.dom("path",null,{fill:"rgba("+s[n]+","+this.alpha+")","stroke-width":1,stroke:"rgba("+s[n]+",1)","vector-effect":"non-scaling-stroke"},this.c[2]);this.init()}mousedown(t){this.isShow?this.close():this.open()}tick(t){this.values=t,this.isShow&&(this.drawGraph(),this.upText())}makePath(t){let s="";s+="M -1 50";for(let i=0;i<this.res+1;i++)s+=" L "+i+" "+t[i];return s+=" L "+(this.res+1)+" 50",s}upText(t){let s=t||this.values,i="";for(let t=0,e=this.names.length;t<e;t++)i+=this.textDisplay[t]+s[t].toFixed(this.precision)+"</span>";this.c[4].innerHTML=i}drawGraph(){let t,s=this.c[2],i=this.names.length,e=0,h=0;for(;i--;)t=this.adding?(this.values[h]+e)*this.range[h]:this.values[h]*this.range[h],this.points[h].shift(),this.points[h].push(50-t),this.setSvg(s,"d",this.makePath(this.points[h]),i+1),e+=this.values[h],h++}open(){super.open(),this.h=this.hplus+this.baseH,this.setSvg(this.c[3],"d",this.svgs.arrowDown),null!==this.group?this.group.calc(this.hplus):this.isUI&&this.main.calc(this.hplus),this.s[0].height=this.h+"px",this.s[2].display="block",this.s[4].display="block",this.isShow=!0,this.custom||h.addListen(this)}close(){super.close(),this.h=this.baseH,this.setSvg(this.c[3],"d",this.svgs.arrow),null!==this.group?this.group.calc(-this.hplus):this.isUI&&this.main.calc(-this.hplus),this.s[0].height=this.h+"px",this.s[2].display="none",this.s[4].display="none",this.isShow=!1,this.custom||h.removeListen(this),this.c[4].innerHTML=""}begin(){this.startTime=this.now()}end(){let t=this.now();if(this.ms=t-this.startTime,this.frames++,t>this.prevTime+1e3&&(this.fps=this.round(1e3*this.frames/(t-this.prevTime)),this.prevTime=t,this.frames=0,this.isMem)){let t=performance.memory.usedJSHeapSize,s=performance.memory.jsHeapSizeLimit;this.mem=this.round(954e-9*t),this.mm=t/s}return this.values=[this.fps,this.ms,this.mm],this.drawGraph(),this.upText([this.fps,this.ms,this.mem]),t}listening(){this.custom||(this.startTime=this.end())}rSize(){let t=this.s,s=this.w;t[0].width=s+"px",t[1].width=s+"px",t[2].left="10px",t[2].width=s-20+"px",t[4].width=s-20+"px"}}class d extends n{constructor(t={}){super(t),this.value=void 0!==t.value?t.value:[0,0,0],this.lng=this.value.length,this.precision=void 0!==t.precision?t.precision:2,this.multiplicator=t.multiplicator||1,this.neg=t.neg||!1,this.line=void 0===t.line||t.line,this.autoWidth=void 0===t.autoWidth||t.autoWidth,this.isNumber=!1,this.isDown=!1,this.h=t.h||138,this.rh=this.h-10,this.top=0,this.c[0].style.width=this.w+"px",void 0!==this.c[1]&&(this.c[1].style.width=this.w+"px",this.top=10,this.h+=10),this.gh=this.rh-28,this.gw=this.w-28,this.c[2]=this.dom("div",this.css.txt+"text-align:center; top:"+(this.h-20)+"px; width:"+this.w+"px; color:"+this.fontColor),this.c[2].textContent=this.value;let s=this.dom("svg",this.css.basic,{viewBox:"0 0 "+this.w+" "+this.rh,width:this.w,height:this.rh,preserveAspectRatio:"none"});this.setCss(s,{width:this.w,height:this.rh,left:0,top:this.top}),this.dom("path","",{d:"",stroke:this.colors.text,"stroke-width":2,fill:"none","stroke-linecap":"butt"},s),this.dom("rect","",{x:10,y:10,width:this.gw+8,height:this.gh+8,stroke:"rgba(0,0,0,0.3)","stroke-width":1,fill:"none"},s),this.iw=(this.gw-4*(this.lng-1))/this.lng;let i=[];this.cMode=[],this.v=[];for(let t=0;t<this.lng;t++)i[t]=[14+t*this.iw+4*t,this.iw],i[t][2]=i[t][0]+i[t][1],this.cMode[t]=0,this.neg?this.v[t]=.5*(1+this.value[t]/this.multiplicator):this.v[t]=this.value[t]/this.multiplicator,this.dom("rect","",{x:i[t][0],y:14,width:i[t][1],height:1,fill:this.fontColor,"fill-opacity":.3},s);this.tmp=i,this.c[3]=s,this.init(),void 0!==this.c[1]&&(this.c[1].style.top="0px",this.c[1].style.height="20px",this.s[1].lineHeight="15px"),this.update(!1)}setValue(t){this.value=t,this.lng=this.value.length;for(var s=0;s<this.lng;s++)this.neg?this.v[s]=.5*(1+t[s]/this.multiplicator):this.v[s]=t[s]/this.multiplicator;this.update()}updateSVG(){this.line&&this.setSvg(this.c[3],"d",this.makePath(),0);for(let t=0;t<this.lng;t++)this.setSvg(this.c[3],"height",this.v[t]*this.gh,t+2),this.setSvg(this.c[3],"y",this.gh-this.v[t]*this.gh+14,t+2),this.neg?this.value[t]=1*((2*this.v[t]-1)*this.multiplicator).toFixed(this.precision):this.value[t]=1*(this.v[t]*this.multiplicator).toFixed(this.precision);this.c[2].textContent=this.value}testZone(t){let s=this.local;if(-1===s.x&&-1===s.y)return"";let i=this.lng,e=this.tmp;if(s.y>this.top&&s.y<this.h-20)for(;i--;)if(s.x>e[i][0]&&s.x<e[i][2])return i;return""}mode(t,s){if(t===this.cMode[s])return!1;let i;switch(t){case 0:i=.3;break;case 1:i=.6;break;case 2:i=1}return this.reset(),this.setSvg(this.c[3],"fill-opacity",i,s+2),this.cMode[s]=t,!0}reset(){let t=!1,s=this.lng;for(;s--;)0!==this.cMode[s]&&(this.cMode[s]=0,this.setSvg(this.c[3],"fill-opacity",.3,s+2),t=!0);return t}mouseup(t){if(this.isDown=!1,-1!==this.current)return this.reset()}mousedown(t){return this.isDown=!0,this.mousemove(t)}mousemove(t){let s=!1,i=this.testZone(t);return""===i?s=this.reset():(s=this.mode(this.isDown?2:1,i),this.isDown&&(this.v[i]=this.clamp(1-(t.clientY-this.zone.y-this.top-10)/this.gh,0,1),this.update(!0))),s}update(t){this.updateSVG(),t&&this.send()}makePath(){let t,s,i,e,h,o,n="";for(let r=0;r<this.lng;r++)t=this.gh-this.v[r]*this.gh+14,s=14+r*this.iw+4*r,e=s+.5*this.iw,i=s+this.iw,n+=0===r?"M "+s+" "+t+" T "+e+" "+t:" C "+h+" "+o+","+s+" "+t+","+e+" "+t,r===this.lng-1&&(n+=" T "+i+" "+t),h=i,o=t;return n}rSize(){super.rSize();let t=this.s;void 0!==this.c[1]&&(t[1].width=this.w+"px"),t[2].width=this.w+"px",t[3].width=this.w+"px";let s=(this.w-28-4*(this.lng-1))/this.lng,i=[];for(let t=0;t<this.lng;t++)i[t]=[14+t*s+4*t,s],i[t][2]=i[t][0]+i[t][1];this.tmp=i}}class p extends n{constructor(t={}){super(t),this.ADD=t.add,this.uis=[],this.isEmpty=!0,this.autoHeight=!0,this.current=-1,this.target=null,this.decal=0,this.baseH=this.h;let s=Math.floor(.5*this.h)-6;this.isLine=void 0!==t.line&&t.line,this.c[2]=this.dom("div",this.css.basic+"width:100%; left:0; height:auto; overflow:hidden; top:"+this.h+"px"),this.c[3]=this.dom("path",this.css.basic+"position:absolute; width:10px; height:10px; left:0; top:"+s+"px;",{d:this.svgs.group,fill:this.fontColor,stroke:"none"}),this.c[4]=this.dom("path",this.css.basic+"position:absolute; width:10px; height:10px; left:4px; top:"+s+"px;",{d:this.svgs.arrow,fill:this.fontColor,stroke:"none"}),this.isLine&&(this.c[5]=this.dom("div",this.css.basic+"background:rgba(255, 255, 255, 0.2); width:100%; left:0; height:1px; bottom:0px"));let i=this.s;i[0].height=this.h+"px",i[1].height=this.h+"px",this.c[1].name="group",i[1].marginLeft="10px",i[1].lineHeight=this.h-4,i[1].color=this.fontColor,i[1].fontWeight="bold",0!==this.radius&&(i[0].borderRadius=this.radius+"px"),i[0].border=this.colors.groupBorder,this.init(),this.setBG(this.bg),void 0!==t.open&&this.open()}testZone(t){let s=this.local;if(-1===s.x&&-1===s.y)return"";let i="";return s.y<this.baseH?i="title":this.isOpen&&(i="content"),i}clearTarget(){return-1!==this.current&&(this.target.uiout(),this.target.reset(),this.current=-1,this.target=null,this.cursor(),!0)}reset(){this.clearTarget()}handleEvent(t){let s=t.type,i=!1,e=!1,o=this.testZone(t);if(o){switch(o){case"content":this.cursor(),h.isMobile&&"mousedown"===s&&this.getNext(t,i),this.target&&(e=this.target.handleEvent(t)),h.lock||this.getNext(t,i);break;case"title":this.cursor("pointer"),"mousedown"===s&&(this.isOpen?this.close():this.open())}return this.isDown&&(i=!0),e&&(i=!0),i}}getNext(t,s){let i=h.findTarget(this.uis,t);i!==this.current&&(this.clearTarget(),this.current=i),-1!==i&&(this.target=this.uis[this.current],this.target.uiover())}calcH(){let t,s,i=this.uis.length,e=0,h=0,o=0;for(t=0;t<i;t++)s=this.uis[t],s.autoWidth?e+=s.h+1:(0===h?e+=s.h+1:o<s.h&&(e+=s.h-o),o=s.h,h+=s.w,h+s.w>this.w&&(h=0));return e}calcUis(){this.isOpen&&h.calcUis(this.uis,this.zone,this.zone.y+this.baseH)}setBG(t){this.s[0].background=t;let s=this.uis.length;for(;s--;)this.uis[s].setBG(t)}add(){let t=arguments;"object"==typeof t[1]?(t[1].isUI=this.isUI,t[1].target=this.c[2],t[1].main=this.main):"string"==typeof arguments[1]&&(void 0===t[2]?[].push.call(t,{isUI:!0,target:this.c[2],main:this.main}):(t[2].isUI=!0,t[2].target=this.c[2],t[2].main=this.main));let s=this.ADD.apply(this,t);return this.uis.push(s),s.group=this,this.isEmpty=!1,s}remove(t){t.clear&&t.clear()}empty(){this.close();let t,s=this.uis.length;for(;s--;)t=this.uis.pop(),this.c[2].removeChild(t.c[0]),t.clear(!0);this.isEmpty=!0,this.h=this.baseH}clearOne(t){let s=this.uis.indexOf(t);-1!==s&&(this.calc(-(this.uis[s].h+1)),this.c[2].removeChild(this.uis[s].c[0]),this.uis.splice(s,1),0===this.uis.length&&(this.isEmpty=!0,this.close()))}parentHeight(t){null!==this.group?this.group.calc(t):this.isUI&&this.main.calc(t)}open(){super.open(),this.setSvg(this.c[4],"d",this.svgs.arrowDown),this.rSizeContent();let t=this.h-this.baseH;this.parentHeight(t)}close(){super.close();let t=this.h-this.baseH;this.setSvg(this.c[4],"d",this.svgs.arrow),this.h=this.baseH,this.s[0].height=this.h+"px",this.parentHeight(-t)}clear(){this.empty(),this.isUI&&this.main.calc(-(this.h+1)),n.prototype.clear.call(this)}clearGroup(){this.empty()}calc(t){this.isOpen&&(void 0!==t?(this.h+=t,this.isUI&&this.main.calc(t)):this.h=this.calcH()+this.baseH,this.s[0].height=this.h+"px")}rSizeContent(){let t=this.uis.length;for(;t--;)this.uis[t].setSize(this.w),this.uis[t].rSize();this.calc()}rSize(){super.rSize();let t=this.s;t[3].left=this.sa+this.sb-17+"px",t[1].width=this.w+"px",t[2].width=this.w+"px",this.isOpen&&this.rSizeContent()}}p.prototype.isGroup=!0;class m extends n{constructor(t={}){super(t),this.autoWidth=!1,this.value=[0,0],this.joyType="analogique",this.model=void 0!==t.mode?t.mode:0,this.precision=t.precision||2,this.multiplicator=t.multiplicator||1,this.pos=new o,this.tmp=new o,this.interval=null,this.radius=.5*this.w,this.distance=.25*this.radius,this.h=t.h||this.w+10,this.top=0,this.c[0].style.width=this.w+"px",void 0!==this.c[1]&&(this.c[1].style.width=this.w+"px",this.c[1].style.textAlign="center",this.top=10,this.h+=10),this.c[2]=this.dom("div",this.css.txt+"text-align:center; top:"+(this.h-20)+"px; width:"+this.w+"px; color:"+this.fontColor),this.c[2].textContent=this.value,this.c[3]=this.getJoystick(this.model),this.setSvg(this.c[3],"viewBox","0 0 "+this.w+" "+this.w),this.setCss(this.c[3],{width:this.w,height:this.w,left:0,top:this.top}),this.ratio=128/this.w,this.init(),this.update(!1)}mode(t){switch(t){case 0:0===this.model?(this.setSvg(this.c[3],"fill","url(#gradIn)",4),this.setSvg(this.c[3],"stroke","#000",4)):(this.setSvg(this.c[3],"stroke","rgba(100,100,100,0.25)",2),this.setSvg(this.c[3],"stroke","#666",4),this.setSvg(this.c[3],"fill","none",4));break;case 1:0===this.model?(this.setSvg(this.c[3],"fill","url(#gradIn2)",4),this.setSvg(this.c[3],"stroke","rgba(0,0,0,0)",4)):(this.setSvg(this.c[3],"stroke","rgba(48,138,255,0.25)",2),this.setSvg(this.c[3],"stroke",this.colors.select,4),this.setSvg(this.c[3],"fill","rgba(48,138,255,0.25)",4))}}addInterval(){null!==this.interval&&this.stopInterval(),this.pos.isZero()||(this.interval=setInterval(function(){this.update()}.bind(this),10))}stopInterval(){null!==this.interval&&(clearInterval(this.interval),this.interval=null)}reset(){this.addInterval(),this.mode(0)}mouseup(t){this.addInterval(),this.isDown=!1}mousedown(t){this.isDown=!0,this.mousemove(t),this.mode(2)}mousemove(t){if(this.mode(1),!this.isDown)return;if(this.tmp.x=this.radius-(t.clientX-this.zone.x),this.tmp.y=this.radius-(t.clientY-this.zone.y-this.top),this.tmp.length()>this.distance){let t=Math.atan2(this.tmp.x,this.tmp.y);this.tmp.x=Math.sin(t)*this.distance,this.tmp.y=Math.cos(t)*this.distance}this.pos.copy(this.tmp).divideScalar(this.distance).negate(),this.update()}setValue(t){void 0===t&&(t=[0,0]),this.pos.set(t[0]||0,t[1]||0),this.updateSVG()}update(t){void 0===t&&(t=!0),null!==this.interval&&(this.isDown||(this.pos.lerp(null,.3),this.pos.x=Math.abs(this.pos.x)<.01?0:this.pos.x,this.pos.y=Math.abs(this.pos.y)<.01?0:this.pos.y,this.isUI&&this.main.isCanvas&&this.main.draw())),this.updateSVG(),t&&this.send(),this.pos.isZero()&&this.stopInterval()}updateSVG(){let t=this.radius- -this.pos.x*this.distance,s=this.radius- -this.pos.y*this.distance;if(0===this.model){let i=t+5*this.pos.x+5,e=s+5*this.pos.y+10;this.setSvg(this.c[3],"cx",i*this.ratio,3),this.setSvg(this.c[3],"cy",e*this.ratio,3)}else this.setSvg(this.c[3],"cx",t*this.ratio,3),this.setSvg(this.c[3],"cy",s*this.ratio,3);this.setSvg(this.c[3],"cx",t*this.ratio,4),this.setSvg(this.c[3],"cy",s*this.ratio,4),this.value[0]=1*(this.pos.x*this.multiplicator).toFixed(this.precision),this.value[1]=1*(this.pos.y*this.multiplicator).toFixed(this.precision),this.c[2].textContent=this.value}clear(){this.stopInterval(),super.clear()}}class g extends n{constructor(t={}){super(t),this.isCyclic=t.cyclic||!1,this.model=t.stype||0,void 0!==t.mode&&(this.model=t.mode),this.autoWidth=!1,this.buttonColor=this.colors.button,this.setTypeNumber(t),this.mPI=.8*Math.PI,this.toDeg=180/Math.PI,this.cirRange=2*this.mPI,this.offset=new o,this.radius=.5*this.w,this.h=t.h||this.w+10,this.top=0,this.c[0].style.width=this.w+"px",void 0!==this.c[1]&&(this.c[1].style.width=this.w+"px",this.c[1].style.textAlign="center",this.top=10,this.h+=10),this.percent=0,this.cmode=0,this.c[2]=this.dom("div",this.css.txt+"text-align:center; top:"+(this.h-20)+"px; width:"+this.w+"px; color:"+this.fontColor),this.c[3]=this.getKnob(),this.setSvg(this.c[3],"stroke",this.fontColor,1),this.setSvg(this.c[3],"stroke",this.fontColor,3),this.setSvg(this.c[3],"d",this.makeGrad(),3),this.setSvg(this.c[3],"viewBox","0 0 "+this.ww+" "+this.ww),this.setCss(this.c[3],{width:this.w,height:this.w,left:0,top:this.top}),this.model>0&&(i.dom("path","",{d:"",stroke:this.fontColor,"stroke-width":2,fill:"none","stroke-linecap":"round"},this.c[3]),2==this.model&&(i.addSVGGlowEffect(),this.setSvg(this.c[3],"style",'filter: url("#UILGlow");',4))),this.r=0,this.init(),this.update()}mode(t){if(this.cmode===t)return!1;switch(t){case 0:this.s[2].color=this.fontColor,this.setSvg(this.c[3],"fill",this.colors.button,0),this.setSvg(this.c[3],"stroke",this.fontColor,1);break;case 1:this.s[2].color=this.colorPlus,this.setSvg(this.c[3],"fill",this.colors.select,0),this.setSvg(this.c[3],"stroke",this.colorPlus,1)}return this.cmode=t,!0}testZone(t){let s=this.local;return-1===s.x&&-1===s.y?"":s.y<=this.c[1].offsetHeight?"title":s.y>this.h-this.c[2].offsetHeight?"text":"knob"}mouseup(t){return this.isDown=!1,this.sendEnd(),this.mode(0)}mousedown(t){return this.isDown=!0,this.old=this.value,this.oldr=null,this.mousemove(t),this.mode(1)}mousemove(t){if(!this.isDown)return;let s=this.offset;s.x=this.radius-(t.clientX-this.zone.x),s.y=this.radius-(t.clientY-this.zone.y-this.top),this.r=-Math.atan2(s.x,s.y),null!==this.oldr&&(this.r=Math.abs(this.r-this.oldr)>Math.PI?this.oldr:this.r),this.r=this.r>this.mPI?this.mPI:this.r,this.r=this.r<-this.mPI?-this.mPI:this.r;let i=1/this.cirRange,e=(this.r+this.mPI)*i,h=this.range*e+this.min-this.old;(h>=this.step||h<=this.step)&&(h=Math.floor(h/this.step),this.value=this.numValue(this.old+h*this.step),this.update(!0),this.old=this.value,this.oldr=this.r)}wheel(t){if("knob"===this.testZone(t)){let s=this.value-this.step*t.delta;return s>this.max?s=this.isCyclic?this.min:this.max:s<this.min&&(s=this.isCyclic?this.max:this.min),this.setValue(s),this.old=s,this.update(!0),!0}return!1}makeGrad(){let t,s,i,e,h,o,n,r="",l=64,a=Math.PI+this.mPI,c=Math.PI-this.mPI;this.step>5?(s=this.range/this.step,t=(a-c)/s):(t=(a-c)/l*2,s=32);for(let c=0;c<=s;++c)i=a-t*c,e=l+44*Math.sin(i),h=l+44*Math.cos(i),o=l+40*Math.sin(i),n=l+40*Math.cos(i),r+="M"+e+" "+h+" L"+o+" "+n+" ";return r}update(t){this.c[2].textContent=this.value,this.percent=(this.value-this.min)/this.range;let s=Math.PI+this.mPI,e=this.percent*this.cirRange-this.mPI,h=Math.sin(e),o=Math.cos(e),n=25*h+64,r=-25*o+64,l=20*h+64,a=-20*o+64;if(this.setSvg(this.c[3],"d","M "+n+" "+r+" L "+l+" "+a,1),this.model>0){let t=36*Math.sin(s)+64,n=36*Math.cos(s)+64,r=36*h+64,l=-36*o+64,a=e<=Math.PI-this.mPI?0:1;this.setSvg(this.c[3],"d","M "+t+","+n+" A 36,36 1 "+a+" 1 "+r+","+l,4);let c=i.pack(i.lerpColor(i.unpack(i.ColorLuma(this.fontColor,-.75)),i.unpack(this.fontColor),this.percent));this.setSvg(this.c[3],"stroke",c,4)}t&&this.send()}}class v extends n{constructor(t={}){super(t),this.path=t.path||"",this.format=t.format||"",this.imageSize=t.imageSize||[20,20],this.isWithImage=""!==this.path,this.preLoadComplete=!1,this.tmpImage={},this.tmpUrl=[];let s=t.align||"center";this.sMode=0,this.tMode=0,this.listOnly=t.listOnly||!1,""===this.txt&&(this.p=0),this.buttonColor=t.bColor||this.colors.button,this.itemBg=t.itemBg||this.colors.itemBg;let i=Math.floor(.5*this.h)-5;if(this.c[2]=this.dom("div",this.css.basic+"top:0; display:none;"),this.c[3]=this.dom("div",this.css.txt+"text-align:"+s+"; line-height:"+(this.h-4)+"px; top:1px; background:"+this.buttonColor+"; height:"+(this.h-2)+"px; border-radius:"+this.radius+"px;"),this.c[4]=this.dom("path",this.css.basic+"position:absolute; width:10px; height:10px; top:"+i+"px;",{d:this.svgs.arrow,fill:this.fontColor,stroke:"none"}),this.scroller=this.dom("div",this.css.basic+"right:5px; width:10px; background:#666; display:none;"),this.c[3].style.color=this.fontColor,this.list=[],this.refObject=null,t.list)if(t.list instanceof Array)this.list=t.list;else{this.refObject=t.list;for(let t in this.refObject)this.list.push(t)}this.items=[],this.prevName="",this.baseH=this.h,this.itemHeight=t.itemHeight||this.h-3,this.full=t.full||!1,this.py=0,this.ww=this.sb,this.scroll=!1,this.isDown=!1,this.current=null,this.side=t.side||"down",this.up="down"===this.side?0:1,this.up?(this.c[2].style.top="auto",this.c[3].style.top="auto",this.c[4].style.top="auto",this.c[2].style.bottom=this.h-2+"px",this.c[3].style.bottom="1px",this.c[4].style.bottom=i+"px"):this.c[2].style.top=this.baseH+"px",this.listIn=this.dom("div",this.css.basic+"left:0; top:0; width:100%; background:rgba(0,0,0,0.2);"),this.listIn.name="list",this.topList=0,this.c[2].appendChild(this.listIn),this.c[2].appendChild(this.scroller),void 0!==t.value?isNaN(t.value)?this.value=t.value:this.value=this.list[t.value]:this.value=this.list[0],this.isOpenOnStart=t.open||!1,this.listOnly&&(this.baseH=5,this.c[3].style.display="none",this.c[4].style.display="none",this.c[2].style.top=this.baseH+"px",this.isOpenOnStart=!0),this.miniCanvas=t.miniCanvas||!1,this.canvasBg=t.canvasBg||"rgba(0,0,0,0)",this.drag=t.drag||!1,this.dragout=t.dragout||!1,this.dragstart=t.dragstart||null,this.dragend=t.dragend||null,this.isWithImage&&this.preloadImage(),this.setList(this.list),this.init(),this.isOpenOnStart&&this.open(!0)}preloadImage(){this.preLoadComplete=!1,this.tmpImage={};for(let t=0;t<this.list.length;t++)this.tmpUrl.push(this.list[t]);this.loadOne()}nextImg(){this.tmpUrl.shift(),0===this.tmpUrl.length?(this.preLoadComplete=!0,this.addImages()):this.loadOne()}loadOne(){let t=this,s=this.tmpUrl[0],i=document.createElement("img");i.style.cssText="position:absolute; width:"+t.imageSize[0]+"px; height:"+t.imageSize[1]+"px",i.setAttribute("src",this.path+s+this.format),i.addEventListener("load",(function(){t.imageSize[2]=i.width,t.imageSize[3]=i.height,t.tmpImage[s]=i,t.nextImg()}))}testZone(t){let s=this.local;if(-1===s.x&&-1===s.y)return"";if(this.up&&this.isOpen){if(s.y>this.h-this.baseH)return"title";if(this.scroll&&s.x>this.sa+this.sb-20)return"scroll";if(s.x>this.sa)return this.testItems(s.y-this.baseH)}else{if(s.y<this.baseH+2)return"title";if(this.isOpen){if(this.scroll&&s.x>this.sa+this.sb-20)return"scroll";if(s.x>this.sa)return this.testItems(s.y-this.baseH)}}return""}testItems(t){let s,i,e,h="",o=this.items.length;for(;o--;)if(s=this.items[o],i=s.posy+this.topList,e=s.posy+this.itemHeight+1+this.topList,t>=i&&t<=e)return h="item"+o,this.unSelected(),this.current=s,this.selected(),h;return h}unSelected(){this.current&&(this.current.style.background="rgba(0,0,0,0.2)",this.current.style.color=this.fontColor,this.current=null)}selected(){this.current.style.background=this.colors.select,this.current.style.color="#FFF"}mouseup(t){this.isDown=!1}mousedown(t){let s=this.testZone(t);return!!s&&("scroll"===s?(this.isDown=!0,this.mousemove(t)):"title"===s?(this.modeTitle(2),this.listOnly||(this.isOpen?this.close():this.open())):this.current&&(this.value=this.list[this.current.id],this.send(null!==this.refObject?this.refObject[this.list[this.current.id]]:this.value),this.listOnly||(this.close(),this.setTopItem())),!0)}mousemove(t){let s=!1,i=this.testZone(t);if(!i)return s;if("title"===i)this.unSelected(),this.modeTitle(1),this.cursor("pointer");else if("scroll"===i){if(this.cursor("s-resize"),this.modeScroll(1),this.isDown){this.modeScroll(2);let s=this.zone.y+this.baseH-2;this.update(t.clientY-s-.5*this.sh)}}else this.modeTitle(0),this.modeScroll(0),this.cursor("pointer");return i!==this.prevName&&(s=!0),this.prevName=i,s}wheel(t){return"title"!==this.testZone(t)&&(this.py+=10*t.delta,this.update(this.py),!0)}reset(){this.prevName="",this.unSelected(),this.modeTitle(0),this.modeScroll(0)}modeScroll(t){if(t!==this.sMode){switch(t){case 0:this.scroller.style.background=this.buttonColor;break;case 1:this.scroller.style.background=this.colors.select;break;case 2:this.scroller.style.background=this.colors.down}this.sMode=t}}modeTitle(t){if(t===this.tMode)return;let s=this.s;switch(t){case 0:s[3].color=this.fontColor,s[3].background=this.buttonColor;break;case 1:s[3].color="#FFF",s[3].background=this.colors.select;break;case 2:s[3].color=this.fontColor,s[3].background=this.colors.down}this.tMode=t}clearList(){for(;this.listIn.children.length;)this.listIn.removeChild(this.listIn.lastChild);this.items=[]}setList(t){let s,i;this.clearList(),this.list=t,this.length=this.list.length,this.maxItem=this.full?this.length:5,this.maxItem=this.length<this.maxItem?this.length:this.maxItem,this.maxHeight=this.maxItem*(this.itemHeight+1)+2,this.max=this.length*(this.itemHeight+1)+2,this.ratio=this.maxHeight/this.max,this.sh=this.maxHeight*this.ratio,this.range=this.maxHeight-this.sh,this.c[2].style.height=this.maxHeight+"px",this.scroller.style.height=this.sh+"px",this.max>this.maxHeight&&(this.ww=this.sb-20,this.scroll=!0);for(let t=0;t<this.length;t++){if(i=this.list[t],s=this.dom("div",this.css.item+"width:"+this.ww+"px; height:"+this.itemHeight+"px; line-height:"+(this.itemHeight-5)+"px; color:"+this.fontColor+"; background:"+this.itemBg+";"),s.name="item"+t,s.id=t,s.posy=(this.itemHeight+1)*t,this.listIn.appendChild(s),this.items.push(s),this.isWithImage||(s.textContent=i),this.miniCanvas){let t=document.createElement("canvas");t.width=this.imageSize[0],t.height=this.imageSize[1];let e=t.getContext("2d");e.fillStyle=this.canvasBg,e.fillRect(0,0,this.imageSize[0],this.imageSize[1]),t.style.cssText="pointer-events:none; display:inline-block; float: left; margin-left:-5px;margin-right:5px; ",s.appendChild(t),this.tmpImage[i]=t}this.dragout&&(s.img=this.tmpImage[i],s.style.pointerEvents="auto",s.draggable="true",s.addEventListener("dragstart",this.dragstart||function(){}),s.addEventListener("drag",this.drag||function(){}),s.addEventListener("dragleave",(function(){h.fakeUp()})),s.addEventListener("dragend",this.dragend||function(){}.bind(this)))}this.setTopItem()}drawImage(t,s,i,e,h,o){this.tmpImage[t].getContext("2d").drawImage(s,i,e,h,o,0,0,this.imageSize[0],this.imageSize[1])}addImages(){let t=this.list.length;for(let s=0;s<t;s++)this.items[s].appendChild(this.tmpImage[this.list[s]]);this.setTopItem()}setValue(t){isNaN(t)?this.value=t:this.value=this.list[t],this.setTopItem()}setTopItem(){if(this.isWithImage){if(!this.preLoadComplete)return;this.c[3].children.length||(this.canvas=document.createElement("canvas"),this.canvas.width=this.imageSize[0],this.canvas.height=this.imageSize[1],this.canvas.style.cssText="position:absolute; top:0px; left:0px;",this.ctx=this.canvas.getContext("2d"),this.c[3].appendChild(this.canvas)),this.tmpImage[this.value],this.ctx.drawImage(this.tmpImage[this.value],0,0,this.imageSize[2],this.imageSize[3],0,0,this.imageSize[0],this.imageSize[1])}else this.c[3].textContent=this.value;if(this.miniCanvas){if(!this.c[3].children.length){this.canvas=document.createElement("canvas"),this.canvas.width=this.imageSize[0],this.canvas.height=this.imageSize[1];let t=.5*(this.h-this.imageSize[1]);this.canvas.style.cssText="position:absolute; top:"+t+"px; left:5px;",this.ctx=this.canvas.getContext("2d"),this.c[3].appendChild(this.canvas)}this.ctx.drawImage(this.tmpImage[this.value],0,0)}}update(t){this.scroll&&(t=(t=t<0?0:t)>this.range?this.range:t,this.topList=-Math.floor(t/this.ratio),this.listIn.style.top=this.topList+"px",this.scroller.style.top=Math.floor(t)+"px",this.py=t)}parentHeight(t){null!==this.group?this.group.calc(t):this.isUI&&this.main.calc(t)}open(t){super.open(),this.update(0),this.h=this.maxHeight+this.baseH+5,this.scroll?this.scroller.style.display="block":(this.topList=0,this.h=this.baseH+5+this.max,this.scroller.style.display="none"),this.s[0].height=this.h+"px",this.s[2].display="block",this.up?(this.zone.y-=this.h-(this.baseH-10),this.setSvg(this.c[4],"d",this.svgs.arrowUp)):this.setSvg(this.c[4],"d",this.svgs.arrowDown),this.rSizeContent();let s=this.h-this.baseH;this.zone.h=this.h,t||this.parentHeight(s)}close(){super.close(),this.up&&(this.zone.y+=this.h-(this.baseH-10));let t=this.h-this.baseH;this.h=this.baseH,this.s[0].height=this.h+"px",this.s[2].display="none",this.setSvg(this.c[4],"d",this.svgs.arrow),this.zone.h=this.h,this.parentHeight(-t)}text(t){this.c[3].textContent=t}rSizeContent(){let t=this.length;for(;t--;)this.listIn.children[t].style.width=this.ww+"px"}rSize(){super.rSize();let t=this.s,s=this.sb,i=this.sa;void 0!==t[2]&&(t[2].width=s+"px",t[2].left=i+"px",t[3].width=s+"px",t[3].left=i+"px",t[4].left=i+s-17+"px",this.ww=s,this.max>this.maxHeight&&(this.ww=s-20),this.isOpen&&this.rSizeContent())}}class x extends n{constructor(t={}){super(t),this.setTypeNumber(t),this.allway=t.allway||!1,this.isDown=!1,this.value=[0],this.multy=1,this.invmulty=1,this.isSingle=!0,this.isAngle=!1,this.isVector=!1,t.isAngle&&(this.isAngle=!0,this.multy=i.torad,this.invmulty=i.todeg),this.isDrag=t.drag||!1,void 0!==t.value&&(isNaN(t.value)?t.value instanceof Array?(this.value=t.value,this.isSingle=!1):t.value instanceof Object&&(this.value=[],void 0!==t.value.x&&(this.value[0]=t.value.x),void 0!==t.value.y&&(this.value[1]=t.value.y),void 0!==t.value.z&&(this.value[2]=t.value.z),void 0!==t.value.w&&(this.value[3]=t.value.w),this.isVector=!0,this.isSingle=!1):this.value=[t.value]),this.lng=this.value.length,this.tmp=[],this.current=-1,this.prev={x:0,y:0,d:0,v:0},this.c[2]=this.dom("div",this.css.basic+" background:"+this.colors.select+"; top:4px; width:0px; height:"+(this.h-8)+"px;"),this.cMode=[];let s=this.lng;for(;s--;)this.isAngle&&(this.value[s]=(180*this.value[s]/Math.PI).toFixed(this.precision)),this.c[3+s]=this.dom("div",this.css.txtselect+" height:"+(this.h-4)+"px; background:"+this.colors.inputBg+"; borderColor:"+this.colors.inputBorder+"; border-radius:"+this.radius+"px;"),t.center&&(this.c[2+s].style.textAlign="center"),this.c[3+s].textContent=this.value[s],this.c[3+s].style.color=this.fontColor,this.c[3+s].isNum=!0,this.cMode[s]=0;this.cursorId=3+this.lng,this.c[this.cursorId]=this.dom("div",this.css.basic+"top:4px; height:"+(this.h-8)+"px; width:0px; background:"+this.fontColor+";"),this.init()}testZone(t){let s=this.local;if(-1===s.x&&-1===s.y)return"";let i=this.lng,e=this.tmp;for(;i--;)if(s.x>e[i][0]&&s.x<e[i][2])return i;return""}mousedown(t){let s=this.testZone(t);return!this.isDown&&(this.isDown=!0,""!==s&&(this.current=s,this.prev={x:t.clientX,y:t.clientY,d:0,v:this.isSingle?parseFloat(this.value):parseFloat(this.value[this.current])},this.setInput(this.c[3+this.current])),this.mousemove(t))}mouseup(t){return!!this.isDown&&(this.isDown=!1,this.prev={x:0,y:0,d:0,v:0},this.mousemove(t))}mousemove(t){let s=!1,i=0;if(""===this.testZone(t)?this.cursor():this.isDrag?this.cursor(-1!==this.current?"move":"pointer"):this.cursor("text"),!this.isDrag)return this.isDown&&(i=t.clientX-this.zone.x-3),-1!==this.current&&(i-=this.tmp[this.current][0]),this.upInput(i,this.isDown);if(-1!==this.current){this.prev.d+=t.clientX-this.prev.x-(t.clientY-this.prev.y);let i=this.prev.v+this.prev.d*this.step;this.value[this.current]=this.numValue(i),this.c[3+this.current].textContent=this.value[this.current],this.validate(),this.prev.x=t.clientX,this.prev.y=t.clientY,s=!0}return s}reset(){return!1}setValue(t){this.isVector?(void 0!==t.x&&(this.value[0]=t.x),void 0!==t.y&&(this.value[1]=t.y),void 0!==t.z&&(this.value[2]=t.z),void 0!==t.w&&(this.value[3]=t.w)):this.isSingle?this.value=[t]:this.value=t,this.update()}sameStr(t){let s=this.value.length;for(;s--;)this.c[3+s].textContent=t}update(t){let s=this.value.length;for(;s--;)this.value[s]=this.numValue(this.value[s]*this.invmulty),this.c[3+s].textContent=this.value[s];t&&this.send()}send(t){t=t||this.value,this.isSend=!0,null!==this.objectLink&&(this.isVector?this.objectLink[this.val].fromArray(t):this.objectLink[this.val]=t),this.callback&&this.callback(t,this.val),this.isSend=!1}select(t,s,i){let e=this.s,h=-1!==this.current?this.tmp[this.current][0]+5:0;e[this.cursorId].width="1px",e[this.cursorId].left=h+t+"px",e[2].left=h+s+"px",e[2].width=i+"px"}unselect(){let t=this.s;t&&(t[2].width="0px",t[this.cursorId].width="0px")}validate(t){let s=[],i=this.lng;for(this.allway&&(t=!0);i--;){if(isNaN(this.c[3+i].textContent))this.c[3+i].textContent=this.value[i];else{let t=this.numValue(this.c[3+i].textContent);this.c[3+i].textContent=t,this.value[i]=t}s[i]=this.value[i]*this.multy}t&&(this.isSingle?this.send(s[0]):this.send(s))}rSize(){super.rSize();let t=Math.floor((this.sb+5)/this.lng)-5,s=this.s,i=this.lng;for(;i--;)this.tmp[i]=[Math.floor(this.sa+t*i+5*i),t],this.tmp[i][2]=this.tmp[i][0]+this.tmp[i][1],s[3+i].left=this.tmp[i][0]+"px",s[3+i].width=this.tmp[i][1]+"px"}}class f extends n{constructor(t={}){if(super(t),this.setTypeNumber(t),this.model=t.stype||0,void 0!==t.mode&&(this.model=t.mode),this.buttonColor=t.bColor||this.colors.button,this.defaultBorderColor=this.colors.hide,this.isDown=!1,this.isOver=!1,this.allway=t.allway||!1,this.isDeg=t.isDeg||!1,this.isCyclic=t.cyclic||!1,this.firstImput=!1,this.c[2]=this.dom("div",this.css.txtselect+"border:none; width:47px; color:"+this.fontColor),this.c[3]=this.dom("div",this.css.basic+" top:0; height:"+this.h+"px;"),this.c[4]=this.dom("div",this.css.basic+"background:"+this.colors.scrollback+"; top:2px; height:"+(this.h-4)+"px;"),this.c[5]=this.dom("div",this.css.basic+"left:4px; top:5px; height:"+(this.h-10)+"px; background:"+this.fontColor+";"),this.c[2].isNum=!0,this.c[2].style.height=this.h-2+"px",this.c[2].style.lineHeight=this.h-10+"px",0!==this.model){let t=4,s=8,i=this.h-4,e=20;2===this.model&&(t=4,s=8,e=2,i=.5*(this.h-4)),3===this.model&&(this.c[5].style.visible="none"),this.c[4].style.borderRadius=t+"px",this.c[4].style.height=s+"px",this.c[4].style.top=.5*this.h-t+"px",this.c[5].style.borderRadius=.5*t+"px",this.c[5].style.height=t+"px",this.c[5].style.top=.5*this.h-.5*t+"px",this.c[6]=this.dom("div",this.css.basic+"border-radius:"+e+"px; margin-left:"+.5*-i+"px; border:1px solid "+this.colors.border+"; background:"+this.buttonColor+"; left:4px; top:2px; height:"+(this.h-4)+"px; width:"+i+"px;")}this.init()}testZone(t){let s=this.local;return-1===s.x&&-1===s.y?"":s.x>=this.txl?"text":s.x>=this.sa?"scroll":""}mouseup(t){this.isDown&&(this.isDown=!1)}mousedown(t){let s=this.testZone(t);return!!s&&("scroll"===s&&(this.isDown=!0,this.old=this.value,this.mousemove(t)),!0)}mousemove(t){let s=!1;if("scroll"===this.testZone(t)?(this.mode(1),this.cursor("w-resize")):this.cursor(),this.isDown){let i=(t.clientX-(this.zone.x+this.sa)-3)/this.ww*this.range+this.min-this.old;(i>=this.step||i<=this.step)&&(i=Math.floor(i/this.step),this.value=this.numValue(this.old+i*this.step),this.update(!0),this.old=this.value),s=!0}return s}wheel(t){if("scroll"===this.testZone(t)){let s=this.value-this.step*t.delta;return s>this.max?s=this.isCyclic?this.min:this.max:s<this.min&&(s=this.isCyclic?this.max:this.min),this.setValue(s),this.old=s,this.update(!0),!0}return!1}validate(){let t=this.c[2].textContent;isNaN(t)?this.c[2].textContent=this.value+(this.isDeg?"°":""):(this.value=this.numValue(t),this.update(!0))}reset(){this.isDown=!1,this.mode(0)}mode(t){let s=this.s;switch(t){case 0:s[2].color=this.fontColor,s[4].background=this.colors.scrollback,s[5].background=this.fontColor;break;case 1:s[2].color=this.colorPlus,s[4].background=this.colors.scrollbackover,s[5].background=this.colorPlus}}update(t){let s=Math.floor(this.ww*((this.value-this.min)/this.range));3!==this.model&&(this.s[5].width=s+"px"),this.s[6]&&(this.s[6].left=this.sa+s+3+"px"),this.c[2].textContent=this.value+(this.isDeg?"°":""),t&&this.send()}rSize(){super.rSize();let t=this.sb-this.sc;this.ww=t-6;let s=this.sc;!this.isUI&&this.simple||(s=this.sc+10),this.txl=this.w-s+2;let i=this.s;i[2].width=this.sc-6+"px",i[2].left=this.txl+4+"px",i[3].left=this.sa+"px",i[3].width=t+"px",i[4].left=this.sa+"px",i[4].width=t+"px",i[5].left=this.sa+3+"px",this.update()}}class b extends n{constructor(t={}){super(t),this.cmode=0,this.value=t.value||"",this.placeHolder=t.placeHolder||"",this.allway=t.allway||!1,this.editable=void 0===t.edit||t.edit,this.isDown=!1,this.c[2]=this.dom("div",this.css.basic+" background:"+this.colors.select+"; top:4px; width:0px; height:"+(this.h-8)+"px;"),this.c[3]=this.dom("div",this.css.txtselect+"height:"+(this.h-4)+"px; background:"+this.colors.inputBg+"; borderColor:"+this.colors.inputBorder+"; border-radius:"+this.radius+"px;"),this.c[3].textContent=this.value,this.c[4]=this.dom("div",this.css.basic+"top:4px; height:"+(this.h-8)+"px; width:0px; background:"+this.fontColor+";"),this.c[5]=this.dom("div",this.css.txtselect+"height:"+(this.h-4)+"px; justify-content: center; font-style: italic; color:"+this.colors.inputHolder+";"),""===this.value&&(this.c[5].textContent=this.placeHolder),this.init()}testZone(t){let s=this.local;return-1===s.x&&-1===s.y?"":s.x>=this.sa?"text":""}mouseup(t){if(this.editable)return!!this.isDown&&(this.isDown=!1,this.mousemove(t))}mousedown(t){if(!this.editable)return;let s=this.testZone(t);return!this.isDown&&(this.isDown=!0,"text"===s&&this.setInput(this.c[3]),this.mousemove(t))}mousemove(t){if(!this.editable)return;let s=0;return"text"===this.testZone(t)?this.cursor("text"):this.cursor(),this.isDown&&(s=t.clientX-this.zone.x),this.upInput(s-this.sa-3,this.isDown)}update(){this.c[3].textContent=this.value}render(t,s,i){this.s[4].width="1px",this.s[4].left=this.sa+t+5+"px",this.s[2].left=this.sa+s+5+"px",this.s[2].width=i+"px"}reset(){this.cursor()}select(t,s,i){let e=this.s,h=this.sa+5;e[4].width="1px",e[4].left=h+t+"px",e[2].left=h+s+"px",e[2].width=i+"px"}unselect(){let t=this.s;t&&(t[2].width="0px",t[4].width="0px")}validate(t){this.allway&&(t=!0),this.value=this.c[3].textContent,""!==this.value?this.c[5].textContent="":this.c[5].textContent=this.placeHolder,t&&this.send()}rSize(){super.rSize();let t=this.s;t[3].left=this.sa+"px",t[3].width=this.sb+"px",t[5].left=this.sa+"px",t[5].width=this.sb+"px"}}class w extends n{constructor(t={}){super(t);let s=t.prefix||"";this.c[2]=this.dom("div",this.css.txt+"text-align:right; width:60px; line-height:"+(this.h-8)+"px; color:"+this.fontColor),31===this.h&&(this.s[0].height=this.h+"px",this.s[1].top="8px",this.c[2].style.top="8px");let i=this.s;i[1].textAlign=t.align||"left",i[1].fontWeight=t.fontWeight||"bold",this.c[1].textContent=this.txt.substring(0,1).toUpperCase()+this.txt.substring(1).replace("-"," "),this.c[2].textContent=s,this.init()}text(t){this.c[1].textContent=t}text2(t){this.c[2].textContent=t}rSize(){super.rSize(),this.s[1].width=this.w+"px",this.s[2].left=this.w+"px"}}class y extends n{constructor(t={}){super(t),this.value=t.value||"",this.isDown=!1,this.onActif=t.onActif||function(){},this.buttonColor=t.bColor||this.colors.button,this.buttonOver=t.bOver||this.colors.over,this.buttonDown=t.bDown||this.colors.select,this.buttonAction=t.bAction||this.colors.action,t.prefix,this.c[2]=this.dom("div",this.css.txt+this.css.button+" top:1px; background:"+this.buttonColor+"; height:"+(this.h-2)+"px; border:"+this.colors.buttonBorder+"; border-radius:15px; width:30px; left:10px;"),this.c[2].style.color=this.fontColor,this.c[3]=this.dom("div",this.css.txtselect+"height:"+(this.h-4)+"px; background:"+this.colors.inputBg+"; borderColor:"+this.colors.inputBorder+"; border-radius:"+this.radius+"px;"),this.c[3].textContent=this.value;let s=Math.floor(.5*this.h)-7;this.c[4]=this.dom("path",this.css.basic+"position:absolute; width:14px; height:14px; left:5px; top:"+s+"px;",{d:this.svgs.cursor,fill:this.fontColor,stroke:"none"}),this.stat=1,this.isActif=!1,this.init()}testZone(t){let s=this.local;return-1===s.x&&-1===s.y?"":s.x>this.sa&&s.x<this.sa+30?"over":"0"}mouseup(t){return!!this.isDown&&(this.isDown=!1,this.mousemove(t))}mousedown(t){return!!this.testZone(t)&&(this.isDown=!0,this.mousemove(t))}mousemove(t){let s=!1;return"over"===this.testZone(t)?(this.cursor("pointer"),s=this.mode(this.isDown?3:2)):s=this.reset(),s}apply(t){(t=t||"")!==this.value&&(this.value=t,this.c[3].textContent=this.value,this.send()),this.mode(1)}update(){this.mode(3)}mode(t){let s=!1;if(this.stat!==t){switch(1===t&&(this.isActif=!1),3===t&&(this.isActif?this.isActif=!1:(this.isActif=!0,t=4,this.onActif(this))),2===t&&this.isActif&&(t=4),t){case 1:this.stat=1,this.s[2].color=this.fontColor,this.s[2].background=this.buttonColor;break;case 2:this.stat=2,this.s[2].color=this.fontSelect,this.s[2].background=this.buttonOver;break;case 3:this.stat=3,this.s[2].color=this.fontSelect,this.s[2].background=this.buttonDown;break;case 4:this.stat=4,this.s[2].color=this.fontSelect,this.s[2].background=this.buttonAction}s=!0}return s}reset(){return this.cursor(),this.mode(this.isActif?4:1)}text(t){this.c[3].textContent=t}rSize(){super.rSize();let t=this.s;t[2].left=this.sa+"px",t[3].left=this.sa+40+"px",t[3].width=this.sb-40+"px",t[4].left=this.sa+8+"px"}}class k extends n{constructor(t={}){let s;super(t),this.values=t.values,"string"==typeof this.values&&(this.values=[this.values]),this.value=t.value||null,this.isSelectable=!0,void 0!==t.selectable&&(this.isSelectable=t.selectable),this.isDown=!1,this.buttonColor=t.bColor||this.colors.button,this.buttonOver=t.bOver||this.colors.over,this.buttonDown=t.bDown||this.colors.select,this.lng=this.values.length,this.tmp=[],this.stat=[];for(let t=0;t<this.lng;t++)s=!1,this.values[t]===this.value&&this.isSelectable&&(s=!0),this.c[t+2]=this.dom("div",this.css.txt+this.css.button+" top:1px; height:"+(this.h-2)+"px; border:"+this.colors.buttonBorder+"; border-radius:"+this.radius+"px;"),this.c[t+2].style.background=s?this.buttonDown:this.buttonColor,this.c[t+2].style.color=s?this.fontSelect:this.fontColor,this.c[t+2].innerHTML=this.values[t],this.stat[t]=s?3:1;this.init()}testZone(t){let s=this.local;if(-1===s.x&&-1===s.y)return"";let i=this.lng,e=this.tmp;for(;i--;)if(s.x>e[i][0]&&s.x<e[i][2])return i;return-1}mouseup(t){return!!this.isDown&&(this.isDown=!1,this.mousemove(t))}mousedown(t){let s=this.testZone(t);return!(s<0)&&(this.isDown=!0,this.value=this.values[s],this.send(),this.mousemove(t))}mousemove(t){let s=!1,i=this.testZone(t);return-1!==i?(this.cursor("pointer"),s=this.modes(this.isDown?3:2,i)):s=this.reset(),s}modes(t,s){let i,e=!1,h=this.lng;for(;h--;)i=h===s?this.mode(t,h):this.isSelectable&&this.values[h]===this.value?this.mode(3,h):this.mode(1,h),i&&(e=!0);return e}mode(t,s){let i=!1,e=s+2;if(this.stat[s]!==t){switch(t){case 1:this.stat[s]=1,this.s[e].color=this.fontColor,this.s[e].background=this.buttonColor;break;case 2:this.stat[s]=2,this.s[e].color=this.fontSelect,this.s[e].background=this.buttonOver;break;case 3:this.stat[s]=3,this.s[e].color=this.fontSelect,this.s[e].background=this.buttonDown}i=!0}return i}reset(){return this.cursor(),this.modes(1,-1)}label(t,s){s=s||2,this.c[s].textContent=t}icon(t,s,i){i=i||2,this.s[i].padding=(s||0)+"px 0px",this.c[i].innerHTML=t}rSize(){super.rSize();let t=this.s,s=this.sb,i=this.sa,e=this.lng,h=Math.floor((s-3*(e-1))/e);for(;e--;)this.tmp[e]=[Math.floor(i+h*e+3*e),h],this.tmp[e][2]=this.tmp[e][0]+this.tmp[e][1],t[e+2].left=this.tmp[e][0]+"px",t[e+2].width=this.tmp[e][1]+"px"}}class C extends n{constructor(t={}){t.simple=!0,t.isSpace=!0,super(t),this.init()}}class S extends n{constructor(t={}){super(t),this.p=100,this.value=this.txt,this.status=1,this.itype=t.itype||"none",this.val=this.itype,this.graph=this.svgs[this.itype];let s=Math.floor(.5*this.h)-7;this.c[2]=this.dom("path",this.css.basic+"position:absolute; width:14px; height:14px; left:5px; top:"+s+"px;",{d:this.graph,fill:this.fontColor,stroke:"none"}),this.s[1].marginLeft="20px",this.init()}mousemove(t){this.cursor("pointer")}mousedown(t){return this.isUI&&this.main.resetItem(),this.selected(!0),this.send(),!0}uiout(){this.isSelect?this.mode(3):this.mode(1)}uiover(){this.isSelect?this.mode(4):this.mode(2)}update(){}mode(t){let s=!1;if(this.status!==t){switch(this.status=t,t){case 1:this.status=1,this.s[1].color=this.fontColor,this.s[0].background="none";break;case 2:this.status=2,this.s[1].color=this.fontColor,this.s[0].background=this.bgOver;break;case 3:this.status=3,this.s[1].color="#FFF",this.s[0].background=this.colors.select;break;case 4:this.status=4,this.s[1].color="#FFF",this.s[0].background=this.colors.down}s=!0}return s}reset(){this.cursor()}selected(t){this.isSelect&&this.mode(1),this.isSelect=t||!1,this.isSelect&&this.mode(3)}}class I extends n{constructor(t={}){super(t),this.values=t.values||[],"string"==typeof this.values&&(this.values=[this.values]),this.value=t.value||null,this.isSelectable=t.selectable||!1,this.isDown=!1,this.buttonColor=t.bColor||this.colors.button,this.buttonOver=t.bOver||this.colors.over,this.buttonDown=t.bDown||this.colors.select,this.spaces=t.spaces||[5,3],this.bsize=t.bsize||[90,20],t.h&&(this.bsize[1]=t.h),this.bsizeMax=this.bsize[0],this.lng=this.values.length,this.tmp=[],this.stat=[],this.grid=[2,Math.round(.5*this.lng)],this.h=this.grid[1]*(this.bsize[1]+this.spaces[1])+this.spaces[1],this.c[1].textContent="",this.c[2]=this.dom("table",this.css.basic+"width:100%; top:"+(this.spaces[1]-2)+"px; height:auto; border-collapse:separate; border:none; border-spacing: "+(this.spaces[0]-2)+"px "+(this.spaces[1]-2)+"px;");let s,i,e,h,o=0;this.buttons=[],this.stat=[],this.tmpX=[],this.tmpY=[];for(let t=0;t<this.grid[1];t++){e=this.c[2].insertRow(),e.style.cssText="pointer-events:none;";for(let t=0;t<this.grid[0];t++)i=e.insertCell(),i.style.cssText="pointer-events:none;",this.values[o]?(h=!1,this.values[o]===this.value&&this.isSelectable&&(h=!0),s=document.createElement("div"),s.style.cssText=this.css.txt+this.css.button+"position:static; width:"+this.bsize[0]+"px; height:"+this.bsize[1]+"px; border:"+this.colors.buttonBorder+"; left:auto; right:auto; border-radius:"+this.radius+"px;",s.style.background=h?this.buttonDown:this.buttonColor,s.style.color=h?this.fontSelect:this.fontColor,s.innerHTML=this.values[o],i.appendChild(s),this.buttons.push(s),this.stat.push(1)):(s=document.createElement("div"),s.style.cssText=this.css.txt+"position:static; width:"+this.bsize[0]+"px; height:"+this.bsize[1]+"px; text-align:center;\tleft:auto; right:auto; background:none;",i.appendChild(s)),s.style.cssText+=0===t?"float:right;":"float:left;",o++}this.init()}testZone(t){let s=this.local;if(-1===s.x&&-1===s.y)return-1;let i=this.tmpX,e=this.tmpY,h=-1,o=-1,n=-1,r=this.grid[0];for(;r--;)s.x>i[r][0]&&s.x<i[r][1]&&(o=r);for(r=this.grid[1];r--;)s.y>e[r][0]&&s.y<e[r][1]&&(n=r);return-1!==o&&-1!==n&&(h=o+2*n,h>this.lng-1&&(h=-1)),h}mouseup(t){return!!this.isDown&&(this.isDown=!1,this.mousemove(t))}mousedown(t){let s=this.testZone(t);return!(s<0)&&(this.isDown=!0,this.value=this.values[s],this.send(),this.mousemove(t))}mousemove(t){let s=!1,i=this.testZone(t);return-1!==i?(this.cursor("pointer"),s=this.modes(this.isDown?3:2,i)):s=this.reset(),s}modes(t,s){let i,e=!1,h=this.lng;for(;h--;)i=h===s?this.mode(t,h):this.isSelectable&&this.values[h]===this.value?this.mode(3,h):this.mode(1,h),i&&(e=!0);return e}mode(t,s){let i=!1;if(this.stat[s]!==t){switch(t){case 1:this.stat[s]=1,this.buttons[s].style.color=this.fontColor,this.buttons[s].style.background=this.buttonColor;break;case 2:this.stat[s]=2,this.buttons[s].style.color=this.fontSelect,this.buttons[s].style.background=this.buttonOver;break;case 3:this.stat[s]=3,this.buttons[s].style.color=this.fontSelect,this.buttons[s].style.background=this.buttonDown}i=!0}return i}reset(){return this.cursor(),this.modes(1,-1)}label(t,s){this.buttons[s].textContent=t}icon(t,s,i){this.buttons[i].style.padding=(s||0)+"px 0px",this.buttons[i].innerHTML=t}testW(){let t=!1;if(3*this.spaces[0]+2*this.bsizeMax>this.w?(this.bsize[0]=.5*(this.w-3*this.spaces[0]),t=!0):this.bsize[0]!==this.bsizeMax&&(this.bsize[0]=this.bsizeMax,t=!0),!t)return;let s=this.buttons.length;for(;s--;)this.buttons[s].style.width=this.bsize[0]+"px"}rSize(){let t;super.rSize(),this.testW(),this.tmpX=[],this.tmpY=[];for(let s=0;s<this.grid[0];s++)0===s?(t=.5*this.w-.5*this.spaces[0],this.tmpX.push([t-this.bsize[0],t])):(t=.5*this.w+.5*this.spaces[0],this.tmpX.push([t,t+this.bsize[0]]));t=this.spaces[1];for(let s=0;s<this.grid[1];s++)this.tmpY.push([t,t+this.bsize[1]]),t+=this.bsize[1]+this.spaces[1]}}class M extends n{constructor(t={}){super(t),this.autoWidth=!1,this.margin=15,this.pos=new o,this.model=t.stype||0,void 0!==t.mode&&(this.model=t.mode),this.precision=void 0===t.precision?2:t.precision,this.bounds={},this.bounds.x1=t.x1||-1,this.bounds.x2=t.x2||1,this.bounds.y1=t.y1||-1,this.bounds.y2=t.y2||1,this.lerpX=this.lerp(this.margin,this.w-this.margin,this.bounds.x1,this.bounds.x2),this.lerpY=this.lerp(this.margin,this.w-this.margin,this.bounds.y1,this.bounds.y2),this.alerpX=this.lerp(this.bounds.x1,this.bounds.x2,this.margin,this.w-this.margin),this.alerpY=this.lerp(this.bounds.y1,this.bounds.y2,this.margin,this.w-this.margin),this.value=[];let s=Array.isArray(t.value)&&2==t.value.length?t.value:[0,0];this.setValue(s),this.h=t.h||this.w+10,this.top=0,this.c[0].style.width=this.w+"px",void 0!==this.c[1]&&(this.c[1].style.width=this.w+"px",this.c[1].style.textAlign="center",this.top=10,this.h+=10),this.c[2]=this.dom("div",this.css.txt+"text-align:center; top:"+(this.h-20)+"px; width:"+this.w+"px; color:"+this.fontColor),this.c[2].textContent=this.value;let e=i.dom("svg",i.css.basic,{viewBox:"0 0 "+this.w+" "+this.w,width:this.w,height:this.w,preserveAspectRatio:"none"});i.dom("rect","",{x:this.margin-5,y:this.margin-5,width:this.w-2*(this.margin-5),height:this.w-2*(this.margin-5),rx:5,ty:5,stroke:"rgba(0,0,0,0.25)","stroke-width":0,fill:"rgba(0,0,0,0.1)"},e),i.dom("rect","",{x:this.margin,y:this.margin,width:this.w-2*this.margin,height:this.w-2*this.margin,stroke:"rgba(0,0,0,0.25)","stroke-width":0,fill:"rgba(0,0,0,0.1)"},e),this.c[3]=e,this.setSvg(this.c[3],"viewBox","0 0 "+this.w+" "+this.w),this.setCss(this.c[3],{left:0,top:this.top}),i.dom("line","",{x1:this.margin,y1:this.w/2,x2:this.w-this.margin,y2:this.w/2,stroke:"#1C1C1C","stroke-width":1},this.c[3]),i.dom("line","",{x1:this.w/2,y1:this.margin,x2:this.w/2,y2:this.w-this.margin,stroke:"#1C1C1C","stroke-width":1},this.c[3]),i.dom("circle","",{cx:this.w/2,cy:this.w/2,r:5,stroke:"rgba(0,0,0,0.25)","stroke-width":0,fill:this.fontColor},this.c[3]),this.init(),this.update(!1)}testZone(t){let s=this.local;return-1===s.x&&-1===s.y?"":s.x>=this.margin&&s.x<=this.w-this.margin&&s.y>=this.top+this.margin&&s.y<=this.top+this.w-this.margin?"pad":""}mouseup(t){this.isDown=!1}mousedown(t){"pad"===this.testZone(t)&&(this.isDown=!0,this.mousemove(t))}mousemove(t){if(!this.isDown)return;let s=t.clientX-this.zone.x,i=t.clientY-this.zone.y-this.top;s<this.margin&&(s=this.margin),s>this.w-this.margin&&(s=this.w-this.margin),i<this.margin&&(i=this.margin),i>this.w-this.margin&&(i=this.w-this.margin),this.setPos([s,i]),this.update()}update(t){void 0===t&&(t=!0),this.c[2].textContent=this.value,this.updateSVG(),t&&this.send()}updateSVG(){1==this.model&&(this.setSvg(this.c[3],"y1",this.pos.y,2),this.setSvg(this.c[3],"y2",this.pos.y,2),this.setSvg(this.c[3],"x1",this.pos.x,3),this.setSvg(this.c[3],"x2",this.pos.x,3)),this.setSvg(this.c[3],"cx",this.pos.x,4),this.setSvg(this.c[3],"cy",this.pos.y,4)}setPos(t){void 0===t&&(t=[this.w/2,this.w/2]),this.pos.set(t[0],t[1]),this.value[0]=this.lerpX(t[0]).toFixed(this.precision),this.value[1]=this.lerpY(t[1]).toFixed(this.precision)}setValue(t,s=!1){void 0===t&&(t=[0,0]),t[0]<this.bounds.x1&&(t[0]=this.bounds.x1),t[0]>this.bounds.x2&&(t[0]=this.bounds.x2),t[1]<this.bounds.y1&&(t[1]=this.bounds.y1),t[1]>this.bounds.y2&&(t[1]=this.bounds.y2),this.value[0]=t[0],this.value[1]=t[1],this.pos.set(this.alerpX(t[0]),this.alerpY(t[1])),s&&this.update()}lerp(t,s,i,e,h=!0){let o=(e-i)/(s-t);return h?e=>((e<t?t:e>s?s:e)-t)*o+i:s=>(s-t)*o+i}}const z=function(){let t,s,i=arguments,e=!1,h=null;"string"==typeof i[0]?(t=i[0],s=i[1]||{}):"object"==typeof i[0]&&(e=!0,void 0===i[2]&&[].push.call(i,{}),t=i[2].type?i[2].type:"slide",s=i[2],s.name=i[1],s.value=i[0][i[1]]);let o=t.toLowerCase();switch("group"===o&&(s.add=z),o){case"bool":h=new r(s);break;case"button":h=new l(s);break;case"circular":h=new a(s);break;case"color":h=new c(s);break;case"fps":h=new u(s);break;case"graph":h=new d(s);break;case"group":h=new p(s);break;case"joystick":h=new m(s);break;case"knob":h=new g(s);break;case"list":h=new v(s);break;case"numeric":case"number":h=new x(s);break;case"slide":h=new f(s);break;case"textInput":case"string":h=new b(s);break;case"title":h=new w(s);break;case"select":h=new y(s);break;case"selector":h=new k(s);break;case"empty":case"space":h=new C(s);break;case"item":h=new S(s);break;case"grid":h=new I(s);break;case"pad2d":h=new M(s)}if(null!==h)return e&&h.setReferency(i[0],i[1]),h};class L{constructor(t={}){this.canvas=null,this.screen=null,this.plane=t.plane||null,this.isEmpty=!0,this.colors=i.cloneColor(),this.css=i.cloneCss(),t.config&&this.setConfig(t.config),this.bg=t.bg||this.colors.background,void 0!==t.transparent&&(this.colors.background="none",this.colors.backgroundOver="none"),this.isReset=!0,this.tmpAdd=null,this.tmpH=0,this.isCanvas=t.isCanvas||!1,this.isCanvasOnly=!1,this.cssGui=void 0!==t.css?t.css:"",this.callback=void 0===t.callback?null:t.callback,this.forceHeight=t.maxHeight||0,this.lockHeight=t.lockHeight||!1,this.isItemMode=void 0!==t.itemMode&&t.itemMode,this.cn="",this.size=i.size,void 0!==t.p&&(this.size.p=t.p),void 0!==t.w&&(this.size.w=t.w),void 0!==t.h&&(this.size.h=t.h),void 0!==t.s&&(this.size.s=t.s),this.size.h=this.size.h<11?11:this.size.h,this.local=(new o).neg(),this.zone={x:0,y:0,w:this.size.w,h:0},this.mouse=(new o).neg(),this.h=0,this.prevY=-1,this.sw=0,this.isWithClose=void 0===t.close||t.close,this.bh=this.isWithClose?this.size.h:0,this.autoResize=void 0===t.autoResize||t.autoResize,this.isCenter=t.center||!1,this.isOpen=void 0===t.open||t.open,this.isDown=!1,this.isScroll=!1,this.uis=[],this.current=-1,this.target=null,this.decal=0,this.ratio=1,this.oy=0,this.isNewTarget=!1,this.content=i.dom("div",this.css.basic+" width:0px; height:auto; top:0px; background:"+this.colors.content+"; "+this.cssGui),this.innerContent=i.dom("div",this.css.basic+"width:100%; top:0; left:0; height:auto; overflow:hidden;"),this.content.appendChild(this.innerContent),this.inner=i.dom("div",this.css.basic+"width:100%; left:0; "),this.innerContent.appendChild(this.inner),this.scrollBG=i.dom("div",this.css.basic+"right:0; top:0; width:"+(this.size.s-1)+"px; height:10px; display:none; background:"+this.bg+";"),this.content.appendChild(this.scrollBG),this.scroll=i.dom("div",this.css.basic+"background:"+this.colors.scroll+"; right:2px; top:0; width:"+(this.size.s-4)+"px; height:10px;"),this.scrollBG.appendChild(this.scroll),this.bottomText=t.bottomText||["open","close"];let s=t.radius||this.colors.radius;this.bottom=i.dom("div",this.css.txt+"width:100%; top:auto; bottom:0; left:0; border-bottom-right-radius:"+s+"px;\tborder-bottom-left-radius:"+s+"px; text-align:center; height:"+this.bh+"px; line-height:"+(this.bh-5)+"px;"),this.content.appendChild(this.bottom),this.bottom.textContent=this.isOpen?this.bottomText[1]:this.bottomText[0],this.bottom.style.background=this.bg,this.parent=void 0!==t.parent?t.parent:null,this.parent=void 0!==t.target?t.target:this.parent,null!==this.parent||this.isCanvas||(this.parent=document.body,this.isCenter||(this.content.style.right="10px")),null!==this.parent&&this.parent.appendChild(this.content),this.isCanvas&&null===this.parent&&(this.isCanvasOnly=!0),this.isCanvasOnly||(this.content.style.pointerEvents="auto"),this.setWidth(),this.isCanvas&&this.makeCanvas(),h.add(this)}setTop(t,s){this.content.style.top=t+"px",void 0!==s&&(this.forceHeight=s),this.setHeight(),h.needReZone=!0}dispose(){this.clear(),null!==this.parent&&this.parent.removeChild(this.content),h.remove(this)}onDraw(){}makeCanvas(){this.canvas=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),this.canvas.width=this.zone.w,this.canvas.height=this.forceHeight?this.forceHeight:this.zone.h}draw(t){if(null===this.canvas)return;let s=this.zone.w,i=this.forceHeight?this.forceHeight:this.zone.h;h.toCanvas(this,s,i,t)}getDom(){return this.content}setUvMouse(t){this.mouse.set(Math.round(t.x*this.canvas.width),this.canvas.height-Math.round(t.y*this.canvas.height))}noMouse(){this.mouse.neg()}setMouse(t){this.mouse.set(t.x,t.y)}setConfig(t){this.setColors(t),this.setText(t.fontSize,t.text,t.font,t.shadow)}setColors(t){for(let s in t)this.colors[s]&&(this.colors[s]=t[s])}setText(t,s,e,h){i.setText(t,s,e,h,this.colors,this.css)}hide(t){this.content.style.display=t?"none":"block"}onChange(t){return this.callback=t||null,this}mode(t){let s=!1;if(t!==this.cn){switch(this.cn=t,t){case"def":this.scroll.style.background=this.colors.scroll,this.bottom.style.background=this.colors.background,this.bottom.style.color=this.colors.text;break;case"scrollOver":this.scroll.style.background=this.colors.select;break;case"scrollDown":this.scroll.style.background=this.colors.down;break;case"bottomOver":this.bottom.style.background=this.colors.backgroundOver,this.bottom.style.color="#FFF"}s=!0}return s}clearTarget(){return-1!==this.current&&(this.target.uiout(),this.target.reset(),this.target=null,this.current=-1,h.cursor(),!0)}testZone(t){let s=this.local;if(-1===s.x&&-1===s.y)return"";this.isReset=!1;let i="",e=this.isScroll?this.zone.w-this.size.s:this.zone.w;return i=s.y>this.zone.h-this.bh&&s.y<this.zone.h?"bottom":s.x>e?"scroll":"content",i}handleEvent(t){let s=t.type,i=!1,e=!1,o=this.testZone(t);if("mouseup"===s&&this.isDown&&(this.isDown=!1),"mousedown"!==s||this.isDown||(this.isDown=!0),this.isDown&&this.isNewTarget&&(h.clearInput(),this.isNewTarget=!1),o){switch(o){case"content":t.clientY=this.isScroll?t.clientY+this.decal:t.clientY,h.isMobile&&"mousedown"===s&&this.getNext(t,i),this.target&&(e=this.target.handleEvent(t)),"mousemove"===s&&(i=this.mode("def")),"wheel"===s&&!e&&this.isScroll&&(i=this.onWheel(t)),h.lock||this.getNext(t,i);break;case"bottom":this.clearTarget(),"mousemove"===s&&(i=this.mode("bottomOver")),"mousedown"===s&&(this.isOpen=!this.isOpen,this.bottom.textContent=this.isOpen?this.bottomText[1]:this.bottomText[0],this.setHeight(),this.mode("def"),i=!0);break;case"scroll":this.clearTarget(),"mousemove"===s&&(i=this.mode("scrollOver")),"mousedown"===s&&(i=this.mode("scrollDown")),"wheel"===s&&(i=this.onWheel(t)),this.isDown&&this.update(t.clientY-this.zone.y-.5*this.sh)}this.isDown&&(i=!0),e&&(i=!0),"keyup"===s&&(i=!0),"keydown"===s&&(i=!0),i&&this.draw()}}getNext(t,s){let i=h.findTarget(this.uis,t);i!==this.current&&(this.clearTarget(),this.current=i,this.isNewTarget=!0),-1!==i&&(this.target=this.uis[this.current],this.target.uiover())}onWheel(t){return this.oy+=20*t.delta,this.update(this.oy),!0}reset(t){if(this.isReset)return;this.mouse.neg(),this.isDown=!1;let s=this.mode("def"),i=this.clearTarget();(s||i)&&this.draw(!0),this.isReset=!0}add(){let t=arguments,s=!1;"object"==typeof t[1]?(t[1].isUI=!0,t[1].main=this,s=!!t[1].ontop&&t[1].ontop):"string"==typeof t[1]&&(void 0===t[2]?[].push.call(t,{isUI:!0,main:this}):(t[2].isUI=!0,t[2].main=this,s=!!t[1].ontop&&t[1].ontop));let i=z.apply(this,t);if(null!==i){if(s?this.uis.unshift(i):this.uis.push(i),i.autoWidth)this.prevY=0,this.calc(i.h+1);else{let t=i.c[0].getBoundingClientRect().top;this.prevY!==t&&(this.calc(i.h+1),this.prevY=t)}return this.isEmpty=!1,i}}applyCalc(){this.calc(this.tmpH),this.tmpAdd=null}calcUis(){h.calcUis(this.uis,this.zone,this.zone.y)}remove(t){t.clear&&t.clear()}clearOne(t){let s=this.uis.indexOf(t);-1!==s&&(this.calc(-(this.uis[s].h+1)),this.inner.removeChild(this.uis[s].c[0]),this.uis.splice(s,1))}empty(){let t,s=this.uis.length;for(;s--;)t=this.uis.pop(),this.inner.removeChild(t.c[0]),t.clear(!0);this.isEmpty=!0,this.calc(-this.h)}clear(){this.empty()}resetItem(){if(!this.isItemMode)return;let t=this.uis.length;for(;t--;)this.uis[t].selected()}setItem(t){if(!this.isItemMode)return;if(t=t||"",this.resetItem(),!t)return void this.update(0);let s=this.uis.length;for(;s--;)this.uis[s].value===t&&(this.uis[s].selected(!0),this.isScroll&&this.update(s*(this.uis[s].h+1)*this.ratio))}upScroll(t){this.sw=t?this.size.s:0,this.oy=t?this.oy:0,this.scrollBG.style.display=t?"block":"none",t&&(this.total=this.h,this.maxView=this.maxHeight,this.ratio=this.maxView/this.total,this.sh=this.maxView*this.ratio,this.range=this.maxView-this.sh,this.oy=i.clamp(this.oy,0,this.range),this.scrollBG.style.height=this.maxView+"px",this.scroll.style.height=this.sh+"px"),this.setItemWidth(this.zone.w-this.sw),this.update(this.oy)}update(t){t=i.clamp(t,0,this.range),this.decal=Math.floor(t/this.ratio),this.inner.style.top=-this.decal+"px",this.scroll.style.top=Math.floor(t)+"px",this.oy=t}calc(t){this.h+=t,clearTimeout(this.tmp),this.tmp=setTimeout(this.setHeight.bind(this),10)}setHeight(){if(this.tmp&&clearTimeout(this.tmp),this.zone.h=this.bh,this.isScroll=!1,this.isOpen){let t=this.forceHeight?this.forceHeight+this.zone.y:window.innerHeight;this.maxHeight=t-this.zone.y-this.bh,this.h-this.maxHeight>1?(this.isScroll=!0,this.zone.h=this.maxHeight+this.bh):this.zone.h=this.h+this.bh}this.upScroll(this.isScroll),this.innerContent.style.height=this.zone.h-this.bh+"px",this.content.style.height=this.zone.h+"px",this.bottom.style.top=this.zone.h-this.bh+"px",this.forceHeight&&this.lockHeight&&(this.content.style.height=this.forceHeight+"px"),this.isOpen&&this.calcUis(),this.isCanvas&&this.draw(!0)}rezone(){h.needReZone=!0}setWidth(t){t&&(this.zone.w=t),this.content.style.width=this.zone.w+"px",this.isCenter&&(this.content.style.marginLeft=-Math.floor(.5*this.zone.w)+"px"),this.setItemWidth(this.zone.w-this.sw),this.setHeight(),this.isCanvasOnly||(h.needReZone=!0)}setItemWidth(t){let s=this.uis.length;for(;s--;)this.uis[s].setSize(t),this.uis[s].rSize()}}L.prototype.isGui=!0;t.Bool=r,t.Button=l,t.Circular=a,t.Color=c,t.Fps=u,t.Group=p,t.Gui=L,t.Joystick=m,t.Knob=g,t.List=v,t.Numeric=x,t.Proto=n,t.REVISION="3.2",t.Slide=f,t.TextInput=b,t.Title=w,t.Tools=i,t.add=z,Object.defineProperty(t,"__esModule",{value:!0})}));
  