lexgui 8.1.0 → 8.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/AlertDialog.d.ts +7 -7
- package/build/components/Counter.d.ts +9 -9
- package/build/components/Dialog.d.ts +20 -20
- package/build/components/Footer.d.ts +14 -14
- package/build/components/Menubar.d.ts +59 -59
- package/build/core/Area.d.ts +143 -143
- package/build/core/Namespace.js +1 -1
- package/build/core/Namespace.js.map +1 -1
- package/build/core/Panel.d.ts +538 -538
- package/build/extensions/AssetView.d.ts +1 -1
- package/build/extensions/AssetView.js +2 -2
- package/build/extensions/AssetView.js.map +1 -1
- package/build/extensions/Audio.js +163 -163
- package/build/extensions/CodeEditor.js +5022 -5022
- package/build/extensions/DocMaker.d.ts +27 -27
- package/build/extensions/DocMaker.js +327 -327
- package/build/extensions/GraphEditor.js +2760 -2760
- package/build/extensions/ImUi.js +227 -227
- package/build/extensions/Timeline.d.ts +670 -670
- package/build/extensions/Timeline.js +3955 -3955
- package/build/extensions/VideoEditor.js +898 -898
- package/build/extensions/index.d.ts +8 -8
- package/build/extensions/index.js +10 -10
- package/build/index.all.d.ts +2 -2
- package/build/index.css.d.ts +4 -4
- package/build/index.d.ts +56 -56
- package/build/lexgui.all.js +4 -4
- package/build/lexgui.all.js.map +1 -1
- package/build/lexgui.all.min.js +1 -1
- package/build/lexgui.all.module.js +4 -4
- package/build/lexgui.all.module.js.map +1 -1
- package/build/lexgui.all.module.min.js +1 -1
- package/build/lexgui.css +2 -2
- package/build/lexgui.js +2 -2
- package/build/lexgui.js.map +1 -1
- package/build/lexgui.min.css +2 -2
- package/build/lexgui.min.js +1 -1
- package/build/lexgui.module.js +2 -2
- package/build/lexgui.module.js.map +1 -1
- package/build/lexgui.module.min.js +1 -1
- package/changelog.md +6 -1
- package/examples/asset-view.html +48 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=globalThis;let t=e.LX;t||(t={version:"8.1.0",ready:!1,extensions:[],extraCommandbarEntries:[],signals:{},activeDraggable:null,spacingMode:"default",layoutMode:"app",MOUSE_LEFT_CLICK:0,MOUSE_MIDDLE_CLICK:1,MOUSE_RIGHT_CLICK:2,MOUSE_DOUBLE_CLICK:2,MOUSE_TRIPLE_CLICK:3,CURVE_MOVEOUT_CLAMP:0,CURVE_MOVEOUT_DELETE:1,DRAGGABLE_Z_INDEX:101},e.LX=t);const s={Abc:[24,24,[],"regular","M17 15q-.425 0-.712-.288T16 14v-4q0-.425.288-.712T17 9h3q.425 0 .713.288T21 10v1h-1.5v-.5h-2v3h2V13H21v1q0 .425-.288.713T20 15zm-7.5 0V9h4q.425 0 .713.288T14.5 10v1q0 .425-.288.713T13.5 12q.425 0 .713.288T14.5 13v1q0 .425-.288.713T13.5 15zm1.5-3.75h2v-.75h-2zm0 2.25h2v-.75h-2zM3 15v-5q0-.425.288-.712T4 9h3q.425 0 .713.288T8 10v5H6.5v-1.5h-2V15zm1.5-3h2v-1.5h-2z"],Android:[128,128,[],"solid","M21.005 43.003c-4.053-.002-7.338 3.291-7.339 7.341l.005 30.736a7.34 7.34 0 0 0 7.342 7.343a7.33 7.33 0 0 0 7.338-7.342V50.34a7.345 7.345 0 0 0-7.346-7.337m59.193-27.602l5.123-9.355a1.023 1.023 0 0 0-.401-1.388a1.02 1.02 0 0 0-1.382.407l-5.175 9.453c-4.354-1.938-9.227-3.024-14.383-3.019c-5.142-.005-10.013 1.078-14.349 3.005L44.45 5.075a1.01 1.01 0 0 0-1.378-.406a1.007 1.007 0 0 0-.404 1.38l5.125 9.349c-10.07 5.193-16.874 15.083-16.868 26.438l66.118-.008c.002-11.351-6.79-21.221-16.845-26.427M48.942 29.858a2.772 2.772 0 0 1 .003-5.545a2.78 2.78 0 0 1 2.775 2.774a2.776 2.776 0 0 1-2.778 2.771m30.106-.005a2.77 2.77 0 0 1-2.772-2.771a2.793 2.793 0 0 1 2.773-2.778a2.79 2.79 0 0 1 2.767 2.779a2.767 2.767 0 0 1-2.768 2.77M31.195 44.39l.011 47.635a7.82 7.82 0 0 0 7.832 7.831l5.333.002l.006 16.264c-.001 4.05 3.291 7.342 7.335 7.342c4.056 0 7.342-3.295 7.343-7.347l-.004-16.26l9.909-.003l.004 16.263c0 4.047 3.293 7.346 7.338 7.338c4.056.003 7.344-3.292 7.343-7.344l-.005-16.259l5.352-.004a7.835 7.835 0 0 0 7.836-7.834l-.009-47.635zm83.134 5.943a7.34 7.34 0 0 0-7.341-7.339c-4.053-.004-7.337 3.287-7.337 7.342l.006 30.738a7.334 7.334 0 0 0 7.339 7.339a7.337 7.337 0 0 0 7.338-7.343z"],Clone:[512,512,[],"regular","M64 464l224 0c8.8 0 16-7.2 16-16l0-64 48 0 0 64c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 224c0-35.3 28.7-64 64-64l64 0 0 48-64 0c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16zM224 304l224 0c8.8 0 16-7.2 16-16l0-224c0-8.8-7.2-16-16-16L224 48c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16zm-64-16l0-224c0-35.3 28.7-64 64-64L448 0c35.3 0 64 28.7 64 64l0 224c0 35.3-28.7 64-64 64l-224 0c-35.3 0-64-28.7-64-64z"],IdBadge:[384,512,[],"regular","M256 48l0 16c0 17.7-14.3 32-32 32l-64 0c-17.7 0-32-14.3-32-32l0-16L64 48c-8.8 0-16 7.2-16 16l0 384c0 8.8 7.2 16 16 16l256 0c8.8 0 16-7.2 16-16l0-384c0-8.8-7.2-16-16-16l-64 0zM0 64C0 28.7 28.7 0 64 0L320 0c35.3 0 64 28.7 64 64l0 384c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 64zM160 320l64 0c44.2 0 80 35.8 80 80c0 8.8-7.2 16-16 16L96 416c-8.8 0-16-7.2-16-16c0-44.2 35.8-80 80-80zm-32-96a64 64 0 1 1 128 0 64 64 0 1 1 -128 0z"],Paste:[512,512,[],"regular","M104.6 48L64 48C28.7 48 0 76.7 0 112L0 384c0 35.3 28.7 64 64 64l96 0 0-48-96 0c-8.8 0-16-7.2-16-16l0-272c0-8.8 7.2-16 16-16l16 0c0 17.7 14.3 32 32 32l72.4 0C202 108.4 227.6 96 256 96l62 0c-7.1-27.6-32.2-48-62-48l-40.6 0C211.6 20.9 188.2 0 160 0s-51.6 20.9-55.4 48zM144 56a16 16 0 1 1 32 0 16 16 0 1 1 -32 0zM448 464l-192 0c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l140.1 0L464 243.9 464 448c0 8.8-7.2 16-16 16zM256 512l192 0c35.3 0 64-28.7 64-64l0-204.1c0-12.7-5.1-24.9-14.1-33.9l-67.9-67.9c-9-9-21.2-14.1-33.9-14.1L256 128c-35.3 0-64 28.7-64 64l0 256c0 35.3 28.7 64 64 64z"],Trash3:[448,512,[],"regular","M170.5 51.6L151.5 80l145 0-19-28.4c-1.5-2.2-4-3.6-6.7-3.6l-93.7 0c-2.7 0-5.2 1.3-6.7 3.6zm147-26.6L354.2 80 368 80l48 0 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-8 0 0 304c0 44.2-35.8 80-80 80l-224 0c-44.2 0-80-35.8-80-80l0-304-8 0c-13.3 0-24-10.7-24-24S10.7 80 24 80l8 0 48 0 13.8 0 36.7-55.1C140.9 9.4 158.4 0 177.1 0l93.7 0c18.7 0 36.2 9.4 46.6 24.9zM80 128l0 304c0 17.7 14.3 32 32 32l224 0c17.7 0 32-14.3 32-32l0-304L80 128zm80 64l0 208c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-208c0-8.8 7.2-16 16-16s16 7.2 16 16zm80 0l0 208c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-208c0-8.8 7.2-16 16-16s16 7.2 16 16zm80 0l0 208c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-208c0-8.8 7.2-16 16-16s16 7.2 16 16z"],FilePdf:[512,512,[],"regular","M64 464l48 0 0 48-48 0c-35.3 0-64-28.7-64-64L0 64C0 28.7 28.7 0 64 0L229.5 0c17 0 33.3 6.7 45.3 18.7l90.5 90.5c12 12 18.7 28.3 18.7 45.3L384 304l-48 0 0-144-80 0c-17.7 0-32-14.3-32-32l0-80L64 48c-8.8 0-16 7.2-16 16l0 384c0 8.8 7.2 16 16 16zM176 352l32 0c30.9 0 56 25.1 56 56s-25.1 56-56 56l-16 0 0 32c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-48 0-80c0-8.8 7.2-16 16-16zm32 80c13.3 0 24-10.7 24-24s-10.7-24-24-24l-16 0 0 48 16 0zm96-80l32 0c26.5 0 48 21.5 48 48l0 64c0 26.5-21.5 48-48 48l-32 0c-8.8 0-16-7.2-16-16l0-128c0-8.8 7.2-16 16-16zm32 128c8.8 0 16-7.2 16-16l0-64c0-8.8-7.2-16-16-16l-16 0 0 96 16 0zm80-112c0-8.8 7.2-16 16-16l48 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-32 0 0 32 32 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-32 0 0 48c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-64 0-64z"],FileWord:[384,512,[],"regular","M48 448L48 64c0-8.8 7.2-16 16-16l160 0 0 80c0 17.7 14.3 32 32 32l80 0 0 288c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16zM64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-293.5c0-17-6.7-33.3-18.7-45.3L274.7 18.7C262.7 6.7 246.5 0 229.5 0L64 0zm55 241.1c-3.8-12.7-17.2-19.9-29.9-16.1s-19.9 17.2-16.1 29.9l48 160c3 10.2 12.4 17.1 23 17.1s19.9-7 23-17.1l25-83.4 25 83.4c3 10.2 12.4 17.1 23 17.1s19.9-7 23-17.1l48-160c3.8-12.7-3.4-26.1-16.1-29.9s-26.1 3.4-29.9 16.1l-25 83.4-25-83.4c-3-10.2-12.4-17.1-23-17.1s-19.9 7-23 17.1l-25 83.4-25-83.4z"],FilePowerpoint:[384,512,[],"regular","M64 464c-8.8 0-16-7.2-16-16L48 64c0-8.8 7.2-16 16-16l160 0 0 80c0 17.7 14.3 32 32 32l80 0 0 288c0 8.8-7.2 16-16 16L64 464zM64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-293.5c0-17-6.7-33.3-18.7-45.3L274.7 18.7C262.7 6.7 246.5 0 229.5 0L64 0zm72 208c-13.3 0-24 10.7-24 24l0 104 0 56c0 13.3 10.7 24 24 24s24-10.7 24-24l0-32 44 0c42 0 76-34 76-76s-34-76-76-76l-68 0zm68 104l-44 0 0-56 44 0c15.5 0 28 12.5 28 28s-12.5 28-28 28z"],FileExcel:[384,512,[],"regular","M48 448L48 64c0-8.8 7.2-16 16-16l160 0 0 80c0 17.7 14.3 32 32 32l80 0 0 288c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16zM64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-293.5c0-17-6.7-33.3-18.7-45.3L274.7 18.7C262.7 6.7 246.5 0 229.5 0L64 0zm90.9 233.3c-8.1-10.5-23.2-12.3-33.7-4.2s-12.3 23.2-4.2 33.7L161.6 320l-44.5 57.3c-8.1 10.5-6.3 25.5 4.2 33.7s25.5 6.3 33.7-4.2L192 359.1l37.1 47.6c8.1 10.5 23.2 12.3 33.7 4.2s12.3-23.2 4.2-33.7L222.4 320l44.5-57.3c8.1-10.5 6.3-25.5-4.2-33.7s-25.5-6.3-33.7 4.2L192 280.9l-37.1-47.6z"],Settings3:[640,512,[],"solid","M308.5 135.3c7.1-6.3 9.9-16.2 6.2-25c-2.3-5.3-4.8-10.5-7.6-15.5L304 89.4c-3-5-6.3-9.9-9.8-14.6c-5.7-7.6-15.7-10.1-24.7-7.1l-28.2 9.3c-10.7-8.8-23-16-36.2-20.9L199 27.1c-1.9-9.3-9.1-16.7-18.5-17.8C173.9 8.4 167.2 8 160.4 8l-.7 0c-6.8 0-13.5 .4-20.1 1.2c-9.4 1.1-16.6 8.6-18.5 17.8L115 56.1c-13.3 5-25.5 12.1-36.2 20.9L50.5 67.8c-9-3-19-.5-24.7 7.1c-3.5 4.7-6.8 9.6-9.9 14.6l-3 5.3c-2.8 5-5.3 10.2-7.6 15.6c-3.7 8.7-.9 18.6 6.2 25l22.2 19.8C32.6 161.9 32 168.9 32 176s.6 14.1 1.7 20.9L11.5 216.7c-7.1 6.3-9.9 16.2-6.2 25c2.3 5.3 4.8 10.5 7.6 15.6l3 5.2c3 5.1 6.3 9.9 9.9 14.6c5.7 7.6 15.7 10.1 24.7 7.1l28.2-9.3c10.7 8.8 23 16 36.2 20.9l6.1 29.1c1.9 9.3 9.1 16.7 18.5 17.8c6.7 .8 13.5 1.2 20.4 1.2s13.7-.4 20.4-1.2c9.4-1.1 16.6-8.6 18.5-17.8l6.1-29.1c13.3-5 25.5-12.1 36.2-20.9l28.2 9.3c9 3 19 .5 24.7-7.1c3.5-4.7 6.8-9.5 9.8-14.6l3.1-5.4c2.8-5 5.3-10.2 7.6-15.5c3.7-8.7 .9-18.6-6.2-25l-22.2-19.8c1.1-6.8 1.7-13.8 1.7-20.9s-.6-14.1-1.7-20.9l22.2-19.8zM112 176a48 48 0 1 1 96 0 48 48 0 1 1 -96 0zM504.7 500.5c6.3 7.1 16.2 9.9 25 6.2c5.3-2.3 10.5-4.8 15.5-7.6l5.4-3.1c5-3 9.9-6.3 14.6-9.8c7.6-5.7 10.1-15.7 7.1-24.7l-9.3-28.2c8.8-10.7 16-23 20.9-36.2l29.1-6.1c9.3-1.9 16.7-9.1 17.8-18.5c.8-6.7 1.2-13.5 1.2-20.4s-.4-13.7-1.2-20.4c-1.1-9.4-8.6-16.6-17.8-18.5L583.9 307c-5-13.3-12.1-25.5-20.9-36.2l9.3-28.2c3-9 .5-19-7.1-24.7c-4.7-3.5-9.6-6.8-14.6-9.9l-5.3-3c-5-2.8-10.2-5.3-15.6-7.6c-8.7-3.7-18.6-.9-25 6.2l-19.8 22.2c-6.8-1.1-13.8-1.7-20.9-1.7s-14.1 .6-20.9 1.7l-19.8-22.2c-6.3-7.1-16.2-9.9-25-6.2c-5.3 2.3-10.5 4.8-15.6 7.6l-5.2 3c-5.1 3-9.9 6.3-14.6 9.9c-7.6 5.7-10.1 15.7-7.1 24.7l9.3 28.2c-8.8 10.7-16 23-20.9 36.2L315.1 313c-9.3 1.9-16.7 9.1-17.8 18.5c-.8 6.7-1.2 13.5-1.2 20.4s.4 13.7 1.2 20.4c1.1 9.4 8.6 16.6 17.8 18.5l29.1 6.1c5 13.3 12.1 25.5 20.9 36.2l-9.3 28.2c-3 9-.5 19 7.1 24.7c4.7 3.5 9.5 6.8 14.6 9.8l5.4 3.1c5 2.8 10.2 5.3 15.5 7.6c8.7 3.7 18.6 .9 25-6.2l19.8-22.2c6.8 1.1 13.8 1.7 20.9 1.7s14.1-.6 20.9-1.7l19.8 22.2zM464 304a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"],MessagesCircle:[640,512,[],"regular","M88.2 309.1c9.8-18.3 6.8-40.8-7.5-55.8C59.4 230.9 48 204 48 176c0-63.5 63.8-128 160-128s160 64.5 160 128s-63.8 128-160 128c-13.1 0-25.8-1.3-37.8-3.6c-10.4-2-21.2-.6-30.7 4.2c-4.1 2.1-8.3 4.1-12.6 6c-16 7.2-32.9 13.5-49.9 18c2.8-4.6 5.4-9.1 7.9-13.6c1.1-1.9 2.2-3.9 3.2-5.9zM208 352c114.9 0 208-78.8 208-176S322.9 0 208 0S0 78.8 0 176c0 41.8 17.2 80.1 45.9 110.3c-.9 1.7-1.9 3.5-2.8 5.1c-10.3 18.4-22.3 36.5-36.6 52.1c-6.6 7-8.3 17.2-4.6 25.9C5.8 378.3 14.4 384 24 384c43 0 86.5-13.3 122.7-29.7c4.8-2.2 9.6-4.5 14.2-6.8c15.1 3 30.9 4.5 47.1 4.5zM432 480c16.2 0 31.9-1.6 47.1-4.5c4.6 2.3 9.4 4.6 14.2 6.8C529.5 498.7 573 512 616 512c9.6 0 18.2-5.7 22-14.5c3.8-8.8 2-19-4.6-25.9c-14.2-15.6-26.2-33.7-36.6-52.1c-.9-1.7-1.9-3.4-2.8-5.1C622.8 384.1 640 345.8 640 304c0-94.4-87.9-171.5-198.2-175.8c4.1 15.2 6.2 31.2 6.2 47.8l0 .6c87.2 6.7 144 67.5 144 127.4c0 28-11.4 54.9-32.7 77.2c-14.3 15-17.3 37.6-7.5 55.8c1.1 2 2.2 4 3.2 5.9c2.5 4.5 5.2 9 7.9 13.6c-17-4.5-33.9-10.7-49.9-18c-4.3-1.9-8.5-3.9-12.6-6c-9.5-4.8-20.3-6.2-30.7-4.2c-12.1 2.4-24.8 3.6-37.8 3.6c-61.7 0-110-26.5-136.8-62.3c-16 5.4-32.8 9.4-50 11.8C279 439.8 350 480 432 480z"],LinkOff:[640,512,["ChainBroken","ChainOff","Unlink"],"solid","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM406.6 416.4L220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3zm-290-228.5L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9z"],StreetView:[512,512,[],"solid","M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64l0 48c0 17.7 14.3 32 32 32l1.8 0 11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5l38.7 0c16.3 0 30-12.3 31.8-28.5L318.2 304l1.8 0c17.7 0 32-14.3 32-32l0-48c0-35.3-28.7-64-64-64l-64 0zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"],ClosedCaptioning:[576,512,["CC"],"regular","M512 80c8.8 0 16 7.2 16 16l0 320c0 8.8-7.2 16-16 16L64 432c-8.8 0-16-7.2-16-16L48 96c0-8.8 7.2-16 16-16l448 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l448 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zM200 208c14.2 0 27 6.1 35.8 16c8.8 9.9 24 10.7 33.9 1.9s10.7-24 1.9-33.9c-17.5-19.6-43.1-32-71.5-32c-53 0-96 43-96 96s43 96 96 96c28.4 0 54-12.4 71.5-32c8.8-9.9 8-25-1.9-33.9s-25-8-33.9 1.9c-8.8 9.9-21.6 16-35.8 16c-26.5 0-48-21.5-48-48s21.5-48 48-48zm144 48c0-26.5 21.5-48 48-48c14.2 0 27 6.1 35.8 16c8.8 9.9 24 10.7 33.9 1.9s10.7-24 1.9-33.9c-17.5-19.6-43.1-32-71.5-32c-53 0-96 43-96 96s43 96 96 96c28.4 0 54-12.4 71.5-32c8.8-9.9 8-25-1.9-33.9s-25-8-33.9 1.9c-8.8 9.9-21.6 16-35.8 16c-26.5 0-48-21.5-48-48z"],ChildReaching:[384,512,[],"solid","M256 64A64 64 0 1 0 128 64a64 64 0 1 0 128 0zM152.9 169.3c-23.7-8.4-44.5-24.3-58.8-45.8L74.6 94.2C64.8 79.5 45 75.6 30.2 85.4s-18.7 29.7-8.9 44.4L40.9 159c18.1 27.1 42.8 48.4 71.1 62.4L112 480c0 17.7 14.3 32 32 32s32-14.3 32-32l0-96 32 0 0 96c0 17.7 14.3 32 32 32s32-14.3 32-32l0-258.4c29.1-14.2 54.4-36.2 72.7-64.2l18.2-27.9c9.6-14.8 5.4-34.6-9.4-44.3s-34.6-5.5-44.3 9.4L291 122.4c-21.8 33.4-58.9 53.6-98.8 53.6c-12.6 0-24.9-2-36.6-5.8c-.9-.3-1.8-.7-2.7-.9z"],HourglassHalf:[384,512,[],"regular","M0 24C0 10.7 10.7 0 24 0L360 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-8 0 0 19c0 40.3-16 79-44.5 107.5L225.9 256l81.5 81.5C336 366 352 404.7 352 445l0 19 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24L24 512c-13.3 0-24-10.7-24-24s10.7-24 24-24l8 0 0-19c0-40.3 16-79 44.5-107.5L158.1 256 76.5 174.5C48 146 32 107.3 32 67l0-19-8 0C10.7 48 0 37.3 0 24zM110.5 371.5c-3.9 3.9-7.5 8.1-10.7 12.5l184.4 0c-3.2-4.4-6.8-8.6-10.7-12.5L192 289.9l-81.5 81.5zM284.2 128C297 110.4 304 89 304 67l0-19L80 48l0 19c0 22.1 7 43.4 19.8 61l184.4 0z"],PaperPlane:[512,512,[],"regular","M16.1 260.2c-22.6 12.9-20.5 47.3 3.6 57.3L160 376l0 103.3c0 18.1 14.6 32.7 32.7 32.7c9.7 0 18.9-4.3 25.1-11.8l62-74.3 123.9 51.6c18.9 7.9 40.8-4.5 43.9-24.7l64-416c1.9-12.1-3.4-24.3-13.5-31.2s-23.3-7.5-34-1.4l-448 256zm52.1 25.5L409.7 90.6 190.1 336l1.2 1L68.2 285.7zM403.3 425.4L236.7 355.9 450.8 116.6 403.3 425.4z"],Axis3DArrows:[24,24,[],"solid","m12 2l4 4h-3v7.85l6.53 3.76L21 15.03l1.5 5.47l-5.5 1.46l1.53-2.61L12 15.58l-6.53 3.77L7 21.96L1.5 20.5L3 15.03l1.47 2.58L11 13.85V6H8z"],PersonWalkingDashedLineArrowRight:[640,512,[],"solid","M208 96a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM123.7 200.5c1-.4 1.9-.8 2.9-1.2l-16.9 63.5c-5.6 21.1-.1 43.6 14.7 59.7l70.7 77.1 22 88.1c4.3 17.1 21.7 27.6 38.8 23.3s27.6-21.7 23.3-38.8l-23-92.1c-1.9-7.8-5.8-14.9-11.2-20.8l-49.5-54 19.3-65.5 9.6 23c4.4 10.6 12.5 19.3 22.8 24.5l26.7 13.3c15.8 7.9 35 1.5 42.9-14.3s1.5-35-14.3-42.9L281 232.7l-15.3-36.8C248.5 154.8 208.3 128 163.7 128c-22.8 0-45.3 4.8-66.1 14l-8 3.5c-32.9 14.6-58.1 42.4-69.4 76.5l-2.6 7.8c-5.6 16.8 3.5 34.9 20.2 40.5s34.9-3.5 40.5-20.2l2.6-7.8c5.7-17.1 18.3-30.9 34.7-38.2l8-3.5zm-30 135.1L68.7 398 9.4 457.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L116.3 441c4.6-4.6 8.2-10.1 10.6-16.1l14.5-36.2-40.7-44.4c-2.5-2.7-4.8-5.6-7-8.6zM550.6 153.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L530.7 224 384 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l146.7 0-25.4 25.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l80-80c12.5-12.5 12.5-32.8 0-45.3l-80-80zM392 0c-13.3 0-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24s24-10.7 24-24l0-48c0-13.3-10.7-24-24-24zm24 152c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 16c0 13.3 10.7 24 24 24s24-10.7 24-24l0-16zM392 320c-13.3 0-24 10.7-24 24l0 16c0 13.3 10.7 24 24 24s24-10.7 24-24l0-16c0-13.3-10.7-24-24-24zm24 120c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24s24-10.7 24-24l0-48z"],PersonWalkingArrowLoopLeft:[640,512,[],"solid","M208 96a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM123.7 200.5c1-.4 1.9-.8 2.9-1.2l-16.9 63.5c-5.6 21.1-.1 43.6 14.7 59.7l70.7 77.1 22 88.1c4.3 17.1 21.7 27.6 38.8 23.3s27.6-21.7 23.3-38.8l-23-92.1c-1.9-7.8-5.8-14.9-11.2-20.8l-49.5-54 19.3-65.5 9.6 23c4.4 10.6 12.5 19.3 22.8 24.5l26.7 13.3c15.8 7.9 35 1.5 42.9-14.3s1.5-35-14.3-42.9L281 232.7l-15.3-36.8C248.5 154.8 208.3 128 163.7 128c-22.8 0-45.3 4.8-66.1 14l-8 3.5c-32.9 14.6-58.1 42.4-69.4 76.5l-2.6 7.8c-5.6 16.8 3.5 34.9 20.2 40.5s34.9-3.5 40.5-20.2l2.6-7.8c5.7-17.1 18.3-30.9 34.7-38.2l8-3.5zm-30 135.1L68.7 398 9.4 457.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L116.3 441c4.6-4.6 8.2-10.1 10.6-16.1l14.5-36.2-40.7-44.4c-2.5-2.7-4.8-5.6-7-8.6zm347.7 119c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L461.3 384l18.7 0c88.4 0 160-71.6 160-160s-71.6-160-160-160L352 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l128 0c53 0 96 43 96 96s-43 96-96 96l-18.7 0 25.4-25.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-80 80c-12.5 12.5-12.5 32.8 0 45.3l80 80z"],PersonWalkingArrowRight:[640,512,[],"solid","M208 96a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM123.7 200.5c1-.4 1.9-.8 2.9-1.2l-16.9 63.5c-5.6 21.1-.1 43.6 14.7 59.7l70.7 77.1 22 88.1c4.3 17.1 21.7 27.6 38.8 23.3s27.6-21.7 23.3-38.8l-23-92.1c-1.9-7.8-5.8-14.9-11.2-20.8l-49.5-54 19.3-65.5 9.6 23c4.4 10.6 12.5 19.3 22.8 24.5l26.7 13.3c15.8 7.9 35 1.5 42.9-14.3s1.5-35-14.3-42.9L281 232.7l-15.3-36.8C248.5 154.8 208.3 128 163.7 128c-22.8 0-45.3 4.8-66.1 14l-8 3.5c-32.9 14.6-58.1 42.4-69.4 76.5l-2.6 7.8c-5.6 16.8 3.5 34.9 20.2 40.5s34.9-3.5 40.5-20.2l2.6-7.8c5.7-17.1 18.3-30.9 34.7-38.2l8-3.5zm-30 135.1L68.7 398 9.4 457.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L116.3 441c4.6-4.6 8.2-10.1 10.6-16.1l14.5-36.2-40.7-44.4c-2.5-2.7-4.8-5.6-7-8.6zM550.6 153.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L530.7 224 384 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l146.7 0-25.4 25.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l80-80c12.5-12.5 12.5-32.8 0-45.3l-80-80z"],ClapperboardClosed:[512,512,[],"solid","M448 32l-86.1 0-1 1-127 127 92.1 0 1-1L453.8 32.3c-1.9-.2-3.8-.3-5.8-.3zm64 128l0-64c0-15.1-5.3-29.1-14-40l-104 104L512 160zM294.1 32l-92.1 0-1 1L73.9 160l92.1 0 1-1 127-127zM64 32C28.7 32 0 60.7 0 96l0 64 6.1 0 1-1 127-127L64 32zM512 192L0 192 0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-224z"],UserOff:[640,512,[],"solid","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L381.9 274c48.5-23.2 82.1-72.7 82.1-130C464 64.5 399.5 0 320 0C250.4 0 192.4 49.3 178.9 114.9L38.8 5.1zM545.5 512L528 512 284.3 320l-59 0C136.2 320 64 392.2 64 481.3c0 17 13.8 30.7 30.7 30.7l450.6 0 .3 0z"],PhotoFilm:[640,512,["Media"],"solid","M256 0L576 0c35.3 0 64 28.7 64 64l0 224c0 35.3-28.7 64-64 64l-320 0c-35.3 0-64-28.7-64-64l0-224c0-35.3 28.7-64 64-64zM476 106.7C471.5 100 464 96 456 96s-15.5 4-20 10.7l-56 84L362.7 169c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l80 0 48 0 144 0c8.9 0 17-4.9 21.2-12.7s3.7-17.3-1.2-24.6l-96-144zM336 96a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM64 128l96 0 0 256 0 32c0 17.7 14.3 32 32 32l128 0c17.7 0 32-14.3 32-32l0-32 160 0 0 64c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 192c0-35.3 28.7-64 64-64zm8 64c-8.8 0-16 7.2-16 16l0 16c0 8.8 7.2 16 16 16l16 0c8.8 0 16-7.2 16-16l0-16c0-8.8-7.2-16-16-16l-16 0zm0 104c-8.8 0-16 7.2-16 16l0 16c0 8.8 7.2 16 16 16l16 0c8.8 0 16-7.2 16-16l0-16c0-8.8-7.2-16-16-16l-16 0zm0 104c-8.8 0-16 7.2-16 16l0 16c0 8.8 7.2 16 16 16l16 0c8.8 0 16-7.2 16-16l0-16c0-8.8-7.2-16-16-16l-16 0zm336 16l0 16c0 8.8 7.2 16 16 16l16 0c8.8 0 16-7.2 16-16l0-16c0-8.8-7.2-16-16-16l-16 0c-8.8 0-16 7.2-16 16z"],Chart:[448,512,[],"solid","M160 80c0-26.5 21.5-48 48-48l32 0c26.5 0 48 21.5 48 48l0 352c0 26.5-21.5 48-48 48l-32 0c-26.5 0-48-21.5-48-48l0-352zM0 272c0-26.5 21.5-48 48-48l32 0c26.5 0 48 21.5 48 48l0 160c0 26.5-21.5 48-48 48l-32 0c-26.5 0-48-21.5-48-48L0 272zM368 96l32 0c26.5 0 48 21.5 48 48l0 288c0 26.5-21.5 48-48 48l-32 0c-26.5 0-48-21.5-48-48l0-288c0-26.5 21.5-48 48-48z"],HandsAslInterpreting:[640,512,["ASL"],"solid","M156.6 46.3c7.9-15.8 1.5-35-14.3-42.9s-35-1.5-42.9 14.3L13.5 189.4C4.6 207.2 0 226.8 0 246.7L0 256c0 70.7 57.3 128 128 128l72 0 8 0 0-.3c35.2-2.7 65.4-22.8 82.1-51.7c8.8-15.3 3.6-34.9-11.7-43.7s-34.9-3.6-43.7 11.7c-7 12-19.9 20-34.7 20c-22.1 0-40-17.9-40-40s17.9-40 40-40c14.8 0 27.7 8 34.7 20c8.8 15.3 28.4 20.5 43.7 11.7s20.5-28.4 11.7-43.7c-12.8-22.1-33.6-39.1-58.4-47.1l80.8-22c17-4.6 27.1-22.2 22.5-39.3s-22.2-27.1-39.3-22.5L194.9 124.6l81.6-68c13.6-11.3 15.4-31.5 4.1-45.1S249.1-3.9 235.5 7.4L133.6 92.3l23-46zM483.4 465.7c-7.9 15.8-1.5 35 14.3 42.9s35 1.5 42.9-14.3l85.9-171.7c8.9-17.8 13.5-37.4 13.5-57.2l0-9.3c0-70.7-57.3-128-128-128l-72 0-8 0 0 .3c-35.2 2.7-65.4 22.8-82.1 51.7c-8.9 15.3-3.6 34.9 11.7 43.7s34.9 3.6 43.7-11.7c7-12 19.9-20 34.7-20c22.1 0 40 17.9 40 40s-17.9 40-40 40c-14.8 0-27.7-8-34.7-20c-8.9-15.3-28.4-20.5-43.7-11.7s-20.5 28.4-11.7 43.7c12.8 22.1 33.6 39.1 58.4 47.1l-80.8 22c-17.1 4.7-27.1 22.2-22.5 39.3s22.2 27.1 39.3 22.5l100.7-27.5-81.6 68c-13.6 11.3-15.4 31.5-4.1 45.1s31.5 15.4 45.1 4.1l101.9-84.9-23 46z"],HandPointRight:[512,512,[],"regular","M448 128l-177.6 0c1 5.2 1.6 10.5 1.6 16l0 16 32 0 144 0c8.8 0 16-7.2 16-16s-7.2-16-16-16zM224 144c0-17.7-14.3-32-32-32c0 0 0 0 0 0l-24 0c-66.3 0-120 53.7-120 120l0 48c0 52.5 33.7 97.1 80.7 113.4c-.5-3.1-.7-6.2-.7-9.4c0-20 9.2-37.9 23.6-49.7c-4.9-9-7.6-19.4-7.6-30.3c0-15.1 5.3-29 14-40c-8.8-11-14-24.9-14-40l0-40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 40c0 8.8 7.2 16 16 16s16-7.2 16-16l0-40 0-40zM192 64s0 0 0 0c18 0 34.6 6 48 16l208 0c35.3 0 64 28.7 64 64s-28.7 64-64 64l-82 0c1.3 5.1 2 10.5 2 16c0 25.3-14.7 47.2-36 57.6c2.6 7 4 14.5 4 22.4c0 20-9.2 37.9-23.6 49.7c4.9 9 7.6 19.4 7.6 30.3c0 35.3-28.7 64-64 64l-64 0-24 0C75.2 448 0 372.8 0 280l0-48C0 139.2 75.2 64 168 64l24 0zm64 336c8.8 0 16-7.2 16-16s-7.2-16-16-16l-48 0-16 0c-8.8 0-16 7.2-16 16s7.2 16 16 16l64 0zm16-176c0 5.5-.7 10.9-2 16l2 0 32 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-32 0 0 16zm-24 64l-40 0c-8.8 0-16 7.2-16 16s7.2 16 16 16l48 0 16 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-24 0z"],HandPointUp:[384,512,[],"regular","M64 64l0 177.6c5.2-1 10.5-1.6 16-1.6l16 0 0-32L96 64c0-8.8-7.2-16-16-16s-16 7.2-16 16zM80 288c-17.7 0-32 14.3-32 32c0 0 0 0 0 0l0 24c0 66.3 53.7 120 120 120l48 0c52.5 0 97.1-33.7 113.4-80.7c-3.1 .5-6.2 .7-9.4 .7c-20 0-37.9-9.2-49.7-23.6c-9 4.9-19.4 7.6-30.3 7.6c-15.1 0-29-5.3-40-14c-11 8.8-24.9 14-40 14l-40 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l40 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-40 0-40 0zM0 320s0 0 0 0c0-18 6-34.6 16-48L16 64C16 28.7 44.7 0 80 0s64 28.7 64 64l0 82c5.1-1.3 10.5-2 16-2c25.3 0 47.2 14.7 57.6 36c7-2.6 14.5-4 22.4-4c20 0 37.9 9.2 49.7 23.6c9-4.9 19.4-7.6 30.3-7.6c35.3 0 64 28.7 64 64l0 64 0 24c0 92.8-75.2 168-168 168l-48 0C75.2 512 0 436.8 0 344l0-24zm336-64c0-8.8-7.2-16-16-16s-16 7.2-16 16l0 48 0 16c0 8.8 7.2 16 16 16s16-7.2 16-16l0-64zM160 240c5.5 0 10.9 .7 16 2l0-2 0-32c0-8.8-7.2-16-16-16s-16 7.2-16 16l0 32 16 0zm64 24l0 40c0 8.8 7.2 16 16 16s16-7.2 16-16l0-48 0-16c0-8.8-7.2-16-16-16s-16 7.2-16 16l0 24z"],HandPointDown:[384,512,[],"regular","M64 448l0-177.6c5.2 1 10.5 1.6 16 1.6l16 0 0 32 0 144c0 8.8-7.2 16-16 16s-16-7.2-16-16zM80 224c-17.7 0-32-14.3-32-32c0 0 0 0 0 0l0-24c0-66.3 53.7-120 120-120l48 0c52.5 0 97.1 33.7 113.4 80.7c-3.1-.5-6.2-.7-9.4-.7c-20 0-37.9 9.2-49.7 23.6c-9-4.9-19.4-7.6-30.3-7.6c-15.1 0-29 5.3-40 14c-11-8.8-24.9-14-40-14l-40 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l40 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-40 0-40 0zM0 192s0 0 0 0c0 18 6 34.6 16 48l0 208c0 35.3 28.7 64 64 64s64-28.7 64-64l0-82c5.1 1.3 10.5 2 16 2c25.3 0 47.2-14.7 57.6-36c7 2.6 14.5 4 22.4 4c20 0 37.9-9.2 49.7-23.6c9 4.9 19.4 7.6 30.3 7.6c35.3 0 64-28.7 64-64l0-64 0-24C384 75.2 308.8 0 216 0L168 0C75.2 0 0 75.2 0 168l0 24zm336 64c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-48 0-16c0-8.8 7.2-16 16-16s16 7.2 16 16l0 64zM160 272c5.5 0 10.9-.7 16-2l0 2 0 32c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-32 16 0zm64-24l0-40c0-8.8 7.2-16 16-16s16 7.2 16 16l0 48 0 16c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-24z"],HandPointLeft:[512,512,[],"regular","M64 128l177.6 0c-1 5.2-1.6 10.5-1.6 16l0 16-32 0L64 160c-8.8 0-16-7.2-16-16s7.2-16 16-16zm224 16c0-17.7 14.3-32 32-32c0 0 0 0 0 0l24 0c66.3 0 120 53.7 120 120l0 48c0 52.5-33.7 97.1-80.7 113.4c.5-3.1 .7-6.2 .7-9.4c0-20-9.2-37.9-23.6-49.7c4.9-9 7.6-19.4 7.6-30.3c0-15.1-5.3-29-14-40c8.8-11 14-24.9 14-40l0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-40 0-40zm32-80s0 0 0 0c-18 0-34.6 6-48 16L64 80C28.7 80 0 108.7 0 144s28.7 64 64 64l82 0c-1.3 5.1-2 10.5-2 16c0 25.3 14.7 47.2 36 57.6c-2.6 7-4 14.5-4 22.4c0 20 9.2 37.9 23.6 49.7c-4.9 9-7.6 19.4-7.6 30.3c0 35.3 28.7 64 64 64l64 0 24 0c92.8 0 168-75.2 168-168l0-48c0-92.8-75.2-168-168-168l-24 0zM256 400c-8.8 0-16-7.2-16-16s7.2-16 16-16l48 0 16 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-64 0zM240 224c0 5.5 .7 10.9 2 16l-2 0-32 0c-8.8 0-16-7.2-16-16s7.2-16 16-16l32 0 0 16zm24 64l40 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-48 0-16 0c-8.8 0-16-7.2-16-16s7.2-16 16-16l24 0z"],HandScissors:[512,512,[],"regular","M.2 276.3c-1.2-35.3 26.4-65 61.7-66.2l3.3-.1L57 208.1C22.5 200.5 .7 166.3 8.3 131.8S50.2 75.5 84.7 83.2l173 38.3c2.3-2.9 4.7-5.7 7.1-8.5l18.4-20.3C299.9 74.5 323.5 64 348.3 64l10.2 0c54.1 0 104.1 28.7 131.3 75.4l1.5 2.6c13.6 23.2 20.7 49.7 20.7 76.6L512 344c0 66.3-53.7 120-120 120l-8 0-96 0c-35.3 0-64-28.7-64-64c0-2.8 .2-5.6 .5-8.3c-19.4-11-32.5-31.8-32.5-55.7c0-.8 0-1.6 0-2.4L66.4 338c-35.3 1.2-65-26.4-66.2-61.7zm63.4-18.2c-8.8 .3-15.7 7.7-15.4 16.5s7.7 15.7 16.5 15.4l161.5-5.6c9.8-.3 18.7 5.3 22.7 14.2s2.2 19.3-4.5 26.4c-2.8 2.9-4.4 6.7-4.4 11c0 8.8 7.2 16 16 16c9.1 0 17.4 5.1 21.5 13.3s3.2 17.9-2.3 25.1c-2 2.7-3.2 6-3.2 9.6c0 8.8 7.2 16 16 16l96 0 8 0c39.8 0 72-32.2 72-72l0-125.4c0-18.4-4.9-36.5-14.2-52.4l-1.5-2.6c-18.6-32-52.8-51.6-89.8-51.6l-10.2 0c-11.3 0-22 4.8-29.6 13.1l-17.5-15.9 17.5 15.9-18.4 20.3c-.6 .6-1.1 1.3-1.7 1.9l57 13.2c8.6 2 14 10.6 12 19.2s-10.6 14-19.2 12l-85.6-19.7L74.3 130c-8.6-1.9-17.2 3.5-19.1 12.2s3.5 17.2 12.2 19.1l187.5 41.6c10.2 2.3 17.8 10.9 18.7 21.4l.1 1c.6 6.6-1.5 13.1-5.8 18.1s-10.6 7.9-17.2 8.2L63.6 258.1z"],HandSpock:[576,512,[],"regular","M170.2 80.8C161 47 180.8 12 214.6 2.4c34-9.6 69.4 10.2 79 44.2l30.3 107.1L337.1 84c6.6-34.7 40.1-57.5 74.8-50.9c31.4 6 53 33.9 52 64.9c10-2.6 20.8-2.8 31.5-.1c34.3 8.6 55.1 43.3 46.6 77.6L486.7 397.2C469.8 464.7 409.2 512 339.6 512l-33.7 0c-56.9 0-112.2-19-157.2-53.9l-92-71.6c-27.9-21.7-32.9-61.9-11.2-89.8s61.9-32.9 89.8-11.2l17 13.2L100.5 167.5c-13-32.9 3.2-70.1 36-83c11.1-4.4 22.7-5.4 33.7-3.7zm77.1-21.2c-2.4-8.5-11.2-13.4-19.7-11s-13.4 11.2-11 19.7l54.8 182.4c3.5 12.3-3.3 25.2-15.4 29.3s-25.3-2-30-13.9L174.9 138.1c-3.2-8.2-12.5-12.3-20.8-9s-12.3 12.5-9 20.8l73.3 185.6c12 30.3-23.7 57-49.4 37l-63.1-49.1c-7-5.4-17-4.2-22.5 2.8s-4.2 17 2.8 22.5l92 71.6c36.5 28.4 81.4 43.8 127.7 43.8l33.7 0c47.5 0 89-32.4 100.5-78.5l55.4-221.6c2.1-8.6-3.1-17.3-11.6-19.4s-17.3 3.1-19.4 11.6l-26 104C435.6 271.8 425 280 413 280c-16.5 0-28.9-15-25.8-31.2L415.7 99c1.7-8.7-4-17.1-12.7-18.7s-17.1 4-18.7 12.7L352.5 260c-2.2 11.6-12.4 20-24.2 20c-11 0-20.7-7.3-23.7-17.9L247.4 59.6z"],HandBackFist:[448,512,["HandRock"],"regular","M144 64c0-8.8 7.2-16 16-16s16 7.2 16 16c0 9.1 5.1 17.4 13.3 21.5s17.9 3.2 25.1-2.3c2.7-2 6-3.2 9.6-3.2c8.8 0 16 7.2 16 16c0 9.1 5.1 17.4 13.3 21.5s17.9 3.2 25.1-2.3c2.7-2 6-3.2 9.6-3.2c8.8 0 16 7.2 16 16c0 9.1 5.1 17.4 13.3 21.5s17.9 3.2 25.1-2.3c2.7-2 6-3.2 9.6-3.2c8.8 0 16 7.2 16 16l0 104c0 31.3-20 58-48 67.9c-9.6 3.4-16 12.5-16 22.6L304 488c0 13.3 10.7 24 24 24s24-10.7 24-24l0-117.8c38-20.1 64-60.1 64-106.2l0-104c0-35.3-28.7-64-64-64c-2.8 0-5.6 .2-8.3 .5C332.8 77.1 311.9 64 288 64c-2.8 0-5.6 .2-8.3 .5C268.8 45.1 247.9 32 224 32c-2.8 0-5.6 .2-8.3 .5C204.8 13.1 183.9 0 160 0C124.7 0 96 28.7 96 64l0 64.3c-11.7 7.4-22.5 16.4-32 26.9l17.8 16.1L64 155.2l-9.4 10.5C40 181.8 32 202.8 32 224.6l0 12.8c0 49.6 24.2 96.1 64.8 124.5l13.8-19.7L96.8 361.9l8.9 6.2c6.9 4.8 14.4 8.6 22.3 11.3L128 488c0 13.3 10.7 24 24 24s24-10.7 24-24l0-128.1c0-12.6-9.8-23.1-22.4-23.9c-7.3-.5-14.3-2.9-20.3-7.1l-13.1 18.7 13.1-18.7-8.9-6.2C96.6 303.1 80 271.3 80 237.4l0-12.8c0-9.9 3.7-19.4 10.3-26.8l9.4-10.5c3.8-4.2 7.9-8.1 12.3-11.6l0 32.3c0 8.8 7.2 16 16 16s16-7.2 16-16l0-65.7 0-14.3 0-64z"],HandLizard:[512,512,[],"regular","M72 112c-13.3 0-24 10.7-24 24s10.7 24 24 24l168 0c35.3 0 64 28.7 64 64s-28.7 64-64 64l-104 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l152 0c4.5 0 8.9 1.3 12.7 3.6l64 40c7 4.4 11.3 12.1 11.3 20.4l0 24c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-10.7L281.1 384 136 384c-39.8 0-72-32.2-72-72s32.2-72 72-72l104 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L72 208c-39.8 0-72-32.2-72-72S32.2 64 72 64l209.6 0c46.7 0 90.9 21.5 119.7 58.3l78.4 100.1c20.9 26.7 32.3 59.7 32.3 93.7L512 424c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-107.9c0-23.2-7.8-45.8-22.1-64.1L363.5 151.9c-19.7-25.2-49.9-39.9-81.9-39.9L72 112z"],HandPeace:[512,512,[],"regular","M250.8 1.4c-35.2-3.7-66.6 21.8-70.3 57L174 119 156.7 69.6C145 36.3 108.4 18.8 75.1 30.5S24.2 78.8 35.9 112.1L88.7 262.2C73.5 276.7 64 297.3 64 320c0 0 0 0 0 0l0 24c0 92.8 75.2 168 168 168l48 0c92.8 0 168-75.2 168-168l0-72 0-16 0-32c0-35.3-28.7-64-64-64c-7.9 0-15.4 1.4-22.4 4c-10.4-21.3-32.3-36-57.6-36c-.7 0-1.5 0-2.2 0l5.9-56.3c3.7-35.2-21.8-66.6-57-70.3zm-.2 155.4C243.9 166.9 240 179 240 192l0 48c0 .7 0 1.4 0 2c-5.1-1.3-10.5-2-16-2l-7.4 0-5.4-15.3 17-161.3c.9-8.8 8.8-15.2 17.6-14.2s15.2 8.8 14.2 17.6l-9.5 90.1zM111.4 85.6L165.7 240 144 240c-4 0-8 .3-11.9 .9L81.2 96.2c-2.9-8.3 1.5-17.5 9.8-20.4s17.5 1.5 20.4 9.8zM288 192c0-8.8 7.2-16 16-16s16 7.2 16 16l0 32 0 16c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-48zm38.4 108c10.4 21.3 32.3 36 57.6 36c5.5 0 10.9-.7 16-2l0 10c0 66.3-53.7 120-120 120l-48 0c-66.3 0-120-53.7-120-120l0-24s0 0 0 0c0-17.7 14.3-32 32-32l80 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-40 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l40 0c35.3 0 64-28.7 64-64c0-.7 0-1.4 0-2c5.1 1.3 10.5 2 16 2c7.9 0 15.4-1.4 22.4-4zM400 272c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-32 0-16c0-8.8 7.2-16 16-16s16 7.2 16 16l0 32 0 16z"],Html:[24,24,[],"solid","m3 2l1.578 17.824L12 22l7.467-2.175L21 2zm14.049 6.048H9.075l.172 2.016h7.697l-.626 6.565l-4.246 1.381l-4.281-1.455l-.288-2.932h2.024l.16 1.411l2.4.815l2.346-.763l.297-3.005H7.416l-.562-6.05h10.412z"],CircleNodes:[512,512,[],"solid","M418.4 157.9c35.3-8.3 61.6-40 61.6-77.9c0-44.2-35.8-80-80-80c-43.4 0-78.7 34.5-80 77.5L136.2 151.1C121.7 136.8 101.9 128 80 128c-44.2 0-80 35.8-80 80s35.8 80 80 80c12.2 0 23.8-2.7 34.1-7.6L259.7 407.8c-2.4 7.6-3.7 15.8-3.7 24.2c0 44.2 35.8 80 80 80s80-35.8 80-80c0-27.7-14-52.1-35.4-66.4l37.8-207.7zM156.3 232.2c2.2-6.9 3.5-14.2 3.7-21.7l183.8-73.5c3.6 3.5 7.4 6.7 11.6 9.5L317.6 354.1c-5.5 1.3-10.8 3.1-15.8 5.5L156.3 232.2z"],CircleRight:[512,512,[],"regular","M464 256A208 208 0 1 1 48 256a208 208 0 1 1 416 0zM0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zM294.6 151.2c-4.2-4.6-10.1-7.2-16.4-7.2C266 144 256 154 256 166.3l0 41.7-96 0c-17.7 0-32 14.3-32 32l0 32c0 17.7 14.3 32 32 32l96 0 0 41.7c0 12.3 10 22.3 22.3 22.3c6.2 0 12.1-2.6 16.4-7.2l84-91c3.5-3.8 5.4-8.7 5.4-13.9s-1.9-10.1-5.4-13.9l-84-91z"],CircleUp:[512,512,[],"regular","M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM151.2 217.4c-4.6 4.2-7.2 10.1-7.2 16.4c0 12.3 10 22.3 22.3 22.3l41.7 0 0 96c0 17.7 14.3 32 32 32l32 0c17.7 0 32-14.3 32-32l0-96 41.7 0c12.3 0 22.3-10 22.3-22.3c0-6.2-2.6-12.1-7.2-16.4l-91-84c-3.8-3.5-8.7-5.4-13.9-5.4s-10.1 1.9-13.9 5.4l-91 84z"],CircleLeft:[512,512,[],"regular","M48 256a208 208 0 1 1 416 0A208 208 0 1 1 48 256zm464 0A256 256 0 1 0 0 256a256 256 0 1 0 512 0zM217.4 376.9c4.2 4.5 10.1 7.1 16.3 7.1c12.3 0 22.3-10 22.3-22.3l0-57.7 96 0c17.7 0 32-14.3 32-32l0-32c0-17.7-14.3-32-32-32l-96 0 0-57.7c0-12.3-10-22.3-22.3-22.3c-6.2 0-12.1 2.6-16.3 7.1L117.5 242.2c-3.5 3.8-5.5 8.7-5.5 13.8s2 10.1 5.5 13.8l99.9 107.1z"],CircleDown:[512,512,[],"regular","M256 464a208 208 0 1 1 0-416 208 208 0 1 1 0 416zM256 0a256 256 0 1 0 0 512A256 256 0 1 0 256 0zM376.9 294.6c4.5-4.2 7.1-10.1 7.1-16.3c0-12.3-10-22.3-22.3-22.3L304 256l0-96c0-17.7-14.3-32-32-32l-32 0c-17.7 0-32 14.3-32 32l0 96-57.7 0C138 256 128 266 128 278.3c0 6.2 2.6 12.1 7.1 16.3l107.1 99.9c3.8 3.5 8.7 5.5 13.8 5.5s10.1-2 13.8-5.5l107.1-99.9z"],WindowRestore:[512,512,[],"solid","M432 48L208 48c-17.7 0-32 14.3-32 32l0 16-48 0 0-16c0-44.2 35.8-80 80-80L432 0c44.2 0 80 35.8 80 80l0 224c0 44.2-35.8 80-80 80l-16 0 0-48 16 0c17.7 0 32-14.3 32-32l0-224c0-17.7-14.3-32-32-32zM48 448c0 8.8 7.2 16 16 16l256 0c8.8 0 16-7.2 16-16l0-192L48 256l0 192zM64 128l256 0c35.3 0 64 28.7 64 64l0 256c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 192c0-35.3 28.7-64 64-64z"],WindowMaximize:[512,512,[],"solid","M.3 89.5C.1 91.6 0 93.8 0 96L0 224 0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-192 0-128c0-35.3-28.7-64-64-64L64 32c-2.2 0-4.4 .1-6.5 .3c-9.2 .9-17.8 3.8-25.5 8.2C21.8 46.5 13.4 55.1 7.7 65.5c-3.9 7.3-6.5 15.4-7.4 24zM48 224l416 0 0 192c0 8.8-7.2 16-16 16L64 432c-8.8 0-16-7.2-16-16l0-192z"],WindowMinimize:[512,512,[],"solid","M24 432c-13.3 0-24 10.7-24 24s10.7 24 24 24l464 0c13.3 0 24-10.7 24-24s-10.7-24-24-24L24 432z"],VrCardboard:[640,512,["VR"],"solid","M576 64L64 64C28.7 64 0 92.7 0 128L0 384c0 35.3 28.7 64 64 64l120.4 0c24.2 0 46.4-13.7 57.2-35.4l32-64c8.8-17.5 26.7-28.6 46.3-28.6s37.5 11.1 46.3 28.6l32 64c10.8 21.7 33 35.4 57.2 35.4L576 448c35.3 0 64-28.7 64-64l0-256c0-35.3-28.7-64-64-64zM96 240a64 64 0 1 1 128 0A64 64 0 1 1 96 240zm384-64a64 64 0 1 1 0 128 64 64 0 1 1 0-128z"],C:[32,32,[],"solid","M29.86 8c-.224-.385-.532-.724-.871-.921L17.234.292c-.677-.391-1.787-.391-2.464 0L3.015 7.079C2.338 7.47 1.78 8.432 1.78 9.214v13.573c0 .391.14.828.364 1.213.219.385.532.724.871.917l11.749 6.791c.683.391 1.787.391 2.464 0l11.755-6.791c.339-.193.647-.532.871-.917s.359-.823.359-1.213V9.214c.005-.391-.135-.828-.353-1.213zM16 25.479c-5.229 0-9.479-4.249-9.479-9.479S10.77 6.521 16 6.521a9.51 9.51 0 0 1 8.208 4.733l-4.104 2.376A4.76 4.76 0 0 0 16 11.259c-2.615 0-4.74 2.125-4.74 4.74s2.125 4.74 4.74 4.74a4.76 4.76 0 0 0 4.104-2.371l4.104 2.376A9.51 9.51 0 0 1 16 25.479z",{svgClass:"stroke-none"}],CPlusPlus:[32,32,[],"solid","M29.86 8c-.224-.385-.532-.724-.871-.921L17.234.292c-.677-.391-1.787-.391-2.464 0L3.015 7.079C2.338 7.47 1.78 8.432 1.78 9.214v13.573c0 .391.14.828.364 1.213c.219.385.532.724.871.917l11.749 6.791c.683.391 1.787.391 2.464 0l11.755-6.791c.339-.193.647-.532.871-.917s.359-.823.359-1.213V9.214c.005-.391-.135-.828-.353-1.213zM16 25.479c-5.229 0-9.479-4.249-9.479-9.479S10.77 6.521 16 6.521a9.51 9.51 0 0 1 8.208 4.733l-4.104 2.376A4.76 4.76 0 0 0 16 11.259c-2.615 0-4.74 2.125-4.74 4.74s2.125 4.74 4.74 4.74a4.76 4.76 0 0 0 4.104-2.371l4.104 2.376A9.51 9.51 0 0 1 16 25.477zm9.479-8.952h-1.052v1.052H23.37v-1.052h-1.052v-1.053h1.052v-1.052h1.057v1.052h1.052zm3.948 0h-1.052v1.052h-1.052v-1.052h-1.052v-1.053h1.052v-1.052h1.052v1.052h1.052z",{svgClass:"stroke-none"}],Css:[24,24,[],"solid","M0 0v20.16A3.84 3.84 0 0 0 3.84 24h16.32A3.84 3.84 0 0 0 24 20.16V3.84A3.84 3.84 0 0 0 20.16 0Zm14.256 13.08c1.56 0 2.28 1.08 2.304 2.64h-1.608c.024-.288-.048-.6-.144-.84c-.096-.192-.288-.264-.552-.264c-.456 0-.696.264-.696.84c-.024.576.288.888.768 1.08c.72.288 1.608.744 1.92 1.296q.432.648.432 1.656c0 1.608-.912 2.592-2.496 2.592c-1.656 0-2.4-1.032-2.424-2.688h1.68c0 .792.264 1.176.792 1.176c.264 0 .456-.072.552-.24c.192-.312.24-1.176-.048-1.512c-.312-.408-.912-.6-1.32-.816q-.828-.396-1.224-.936c-.24-.36-.36-.888-.36-1.536c0-1.44.936-2.472 2.424-2.448m5.4 0c1.584 0 2.304 1.08 2.328 2.64h-1.608c0-.288-.048-.6-.168-.84c-.096-.192-.264-.264-.528-.264c-.48 0-.72.264-.72.84s.288.888.792 1.08c.696.288 1.608.744 1.92 1.296c.264.432.408.984.408 1.656c.024 1.608-.888 2.592-2.472 2.592c-1.68 0-2.424-1.056-2.448-2.688h1.68c0 .744.264 1.176.792 1.176c.264 0 .456-.072.552-.24c.216-.312.264-1.176-.048-1.512c-.288-.408-.888-.6-1.32-.816c-.552-.264-.96-.576-1.2-.936s-.36-.888-.36-1.536c-.024-1.44.912-2.472 2.4-2.448m-11.031.018c.711-.006 1.419.198 1.839.63c.432.432.672 1.128.648 1.992H9.336c.024-.456-.096-.792-.432-.96c-.312-.144-.768-.048-.888.24c-.12.264-.192.576-.168.864v3.504c0 .744.264 1.128.768 1.128a.65.65 0 0 0 .552-.264c.168-.24.192-.552.168-.84h1.776c.096 1.632-.984 2.712-2.568 2.688c-1.536 0-2.496-.864-2.472-2.472v-4.032c0-.816.24-1.44.696-1.848c.432-.408 1.146-.624 1.857-.63"],Discord:[640,512,[],"solid","M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"],Godot:[32,32,[],"solid","M12.745.917c-1.458.328-2.906.781-4.266 1.464a32 32 0 0 0 .266 3.505c-.526.339-1.078.63-1.568 1.026c-.5.38-1.01.75-1.464 1.198a28 28 0 0 0-2.849-1.651C1.801 7.6.812 8.834-.001 10.214c.609.99 1.25 1.911 1.938 2.792h.016v8.474a.2.2 0 0 1 .047.005l5.198.5a.554.554 0 0 1 .5.521l.161 2.292l4.531.323l.313-2.115a.56.56 0 0 1 .552-.479h5.484a.56.56 0 0 1 .552.479l.313 2.115l4.531-.323l.161-2.292a.554.554 0 0 1 .505-.521l5.193-.5c.016 0 .031-.005.047-.005v-8.474h.021a30 30 0 0 0 1.932-2.792c-.807-1.38-1.802-2.615-2.865-3.755A29 29 0 0 0 26.28 8.11c-.453-.448-.958-.818-1.458-1.198c-.495-.396-1.047-.688-1.573-1.026c.156-1.161.234-2.307.266-3.505c-1.354-.682-2.802-1.135-4.266-1.464A31 31 0 0 0 17.671 4a11 11 0 0 0-1.661-.13h-.026c-.552.005-1.109.042-1.661.13A30 30 0 0 0 12.74.917zm-4.11 12.406a3.134 3.134 0 0 1 3.13 3.135a3.13 3.13 0 1 1-6.26 0a3.134 3.134 0 0 1 3.13-3.135m14.73 0a3.134 3.134 0 0 1 3.13 3.135a3.13 3.13 0 1 1-6.26 0a3.134 3.134 0 0 1 3.13-3.135M8.932 14.568a2.076 2.076 0 1 0 0 4.151a2.077 2.077 0 0 0 2.083-2.073a2.08 2.08 0 0 0-2.083-2.078m14.131 0a2.076 2.076 0 1 0 0 4.151a2.073 2.073 0 0 0 2.078-2.073a2.074 2.074 0 0 0-2.078-2.078M16 15.172c.557 0 1.01.406 1.01.911v2.885c0 .505-.453.917-1.01.917s-1.01-.411-1.01-.917v-2.885c0-.505.453-.911 1.01-.911M1.948 22.599c0 .505.005 1.052.005 1.161c0 4.938 6.26 7.307 14.036 7.333h.021c7.776-.026 14.031-2.396 14.031-7.333l.01-1.161l-4.672.453l-.161 2.307a.556.556 0 0 1-.516.516l-5.578.396a.56.56 0 0 1-.552-.474l-.318-2.156h-4.516l-.318 2.156a.557.557 0 0 1-.594.474l-5.531-.396a.565.565 0 0 1-.521-.516l-.156-2.307l-4.672-.448z"],Google:[488,512,[],"solid","M488 261.8C488 403.3 391.1 504 248 504 110.8 504 0 393.2 0 256S110.8 8 248 8c66.8 0 123 24.5 166.3 64.9l-67.5 64.9C258.5 52.6 94.3 116.6 94.3 256c0 86.5 69.1 156.6 153.7 156.6 98.2 0 135-70.4 140.8-106.9H248v-85.3h236.1c2.3 12.7 3.9 24.9 3.9 41.4z"],Go:[24,24,[],"solid","M1.811 10.231c-.047 0-.058-.023-.035-.059l.246-.315c.023-.035.081-.058.128-.058h4.172c.046 0 .058.035.035.07l-.199.303c-.023.036-.082.07-.117.07zM.047 11.306c-.047 0-.059-.023-.035-.058l.245-.316c.023-.035.082-.058.129-.058h5.328c.047 0 .07.035.058.07l-.093.28c-.012.047-.058.07-.105.07zm2.828 1.075c-.047 0-.059-.035-.035-.07l.163-.292c.023-.035.07-.07.117-.07h2.337c.047 0 .07.035.07.082l-.023.28c0 .047-.047.082-.082.082zm12.129-2.36c-.736.187-1.239.327-1.963.514c-.176.046-.187.058-.34-.117c-.174-.199-.303-.327-.548-.444c-.737-.362-1.45-.257-2.115.175c-.795.514-1.204 1.274-1.192 2.22c.011.935.654 1.706 1.577 1.835c.795.105 1.46-.175 1.987-.77c.105-.13.198-.27.315-.434H10.47c-.245 0-.304-.152-.222-.35c.152-.362.432-.97.596-1.274a.32.32 0 0 1 .292-.187h4.253c-.023.316-.023.631-.07.947a5 5 0 0 1-.958 2.29c-.841 1.11-1.94 1.8-3.33 1.986c-1.145.152-2.209-.07-3.143-.77c-.865-.655-1.356-1.52-1.484-2.595c-.152-1.274.222-2.419.993-3.424c.83-1.086 1.928-1.776 3.272-2.02c1.098-.2 2.15-.07 3.096.571c.62.41 1.063.97 1.356 1.648c.07.105.023.164-.117.2m3.868 6.461c-1.064-.024-2.034-.328-2.852-1.029a3.67 3.67 0 0 1-1.262-2.255c-.21-1.32.152-2.489.947-3.529c.853-1.122 1.881-1.706 3.272-1.95c1.192-.21 2.314-.095 3.33.595c.923.63 1.496 1.484 1.648 2.605c.198 1.578-.257 2.863-1.344 3.962c-.771.783-1.718 1.273-2.805 1.495c-.315.06-.63.07-.934.106m2.78-4.72c-.011-.153-.011-.27-.034-.387c-.21-1.157-1.274-1.81-2.384-1.554c-1.087.245-1.788.935-2.045 2.033c-.21.912.234 1.835 1.075 2.21c.643.28 1.285.244 1.905-.07c.923-.48 1.425-1.228 1.484-2.233z"],Git:[32,32,[],"solid","M13.172 2.828L11.78 4.22l1.91 1.91l2 2A2.986 2.986 0 0 1 20 10.81a3.25 3.25 0 0 1-.31 1.31l2.06 2a2.68 2.68 0 0 1 3.37.57a2.86 2.86 0 0 1 .88 2.117a3.02 3.02 0 0 1-.856 2.109A2.9 2.9 0 0 1 23 19.81a2.93 2.93 0 0 1-2.13-.87a2.694 2.694 0 0 1-.56-3.38l-2-2.06a3 3 0 0 1-.31.12V20a3 3 0 0 1 1.44 1.09a2.92 2.92 0 0 1 .56 1.72a2.88 2.88 0 0 1-.878 2.128a2.98 2.98 0 0 1-2.048.871a2.981 2.981 0 0 1-2.514-4.719A3 3 0 0 1 16 20v-6.38a2.96 2.96 0 0 1-1.44-1.09a2.9 2.9 0 0 1-.56-1.72a2.9 2.9 0 0 1 .31-1.31l-3.9-3.9l-7.579 7.572a4 4 0 0 0-.001 5.658l10.342 10.342a4 4 0 0 0 5.656 0l10.344-10.344a4 4 0 0 0 0-5.656L18.828 2.828a4 4 0 0 0-5.656 0"],Json:[32,32,[],"solid","M4.014 14.976a2.5 2.5 0 0 0 1.567-.518a2.38 2.38 0 0 0 .805-1.358a15.3 15.3 0 0 0 .214-2.944q.012-2.085.075-2.747a5.2 5.2 0 0 1 .418-1.686a3 3 0 0 1 .755-1.018A3.05 3.05 0 0 1 9 4.125A6.8 6.8 0 0 1 10.544 4h.7v1.96h-.387a2.34 2.34 0 0 0-1.723.468a3.4 3.4 0 0 0-.425 2.092a36 36 0 0 1-.137 4.133a4.7 4.7 0 0 1-.768 2.06A4.6 4.6 0 0 1 6.1 16a3.8 3.8 0 0 1 1.992 1.754a8.9 8.9 0 0 1 .618 3.865q0 2.435.05 2.9a1.76 1.76 0 0 0 .504 1.181a2.64 2.64 0 0 0 1.592.337h.387V28h-.7a5.7 5.7 0 0 1-1.773-.2a2.97 2.97 0 0 1-1.324-.93a3.35 3.35 0 0 1-.681-1.63a24 24 0 0 1-.165-3.234a16.5 16.5 0 0 0-.214-3.106a2.4 2.4 0 0 0-.805-1.361a2.5 2.5 0 0 0-1.567-.524Zm23.972 2.035a2.5 2.5 0 0 0-1.567.524a2.4 2.4 0 0 0-.805 1.361a16.5 16.5 0 0 0-.212 3.109a24 24 0 0 1-.169 3.234a3.35 3.35 0 0 1-.681 1.63a2.97 2.97 0 0 1-1.324.93a5.7 5.7 0 0 1-1.773.2h-.7V26.04h.387a2.64 2.64 0 0 0 1.592-.337a1.76 1.76 0 0 0 .506-1.186q.05-.462.05-2.9a8.9 8.9 0 0 1 .618-3.865A3.8 3.8 0 0 1 25.9 16a4.6 4.6 0 0 1-1.7-1.286a4.7 4.7 0 0 1-.768-2.06a36 36 0 0 1-.137-4.133a3.4 3.4 0 0 0-.425-2.092a2.34 2.34 0 0 0-1.723-.468h-.387V4h.7a6.8 6.8 0 0 1 1.54.125a3.05 3.05 0 0 1 1.149.581a3 3 0 0 1 .755 1.018a5.2 5.2 0 0 1 .418 1.686q.062.662.075 2.747a15.3 15.3 0 0 0 .212 2.947a2.38 2.38 0 0 0 .805 1.355a2.5 2.5 0 0 0 1.567.518Z"],Js:[32,32,[],"solid","M18.774 19.7a3.73 3.73 0 0 0 3.376 2.078c1.418 0 2.324-.709 2.324-1.688c0-1.173-.931-1.589-2.491-2.272l-.856-.367c-2.469-1.052-4.11-2.37-4.11-5.156c0-2.567 1.956-4.52 5.012-4.52A5.06 5.06 0 0 1 26.9 10.52l-2.665 1.711a2.33 2.33 0 0 0-2.2-1.467a1.49 1.49 0 0 0-1.638 1.467c0 1.027.636 1.442 2.1 2.078l.856.366c2.908 1.247 4.549 2.518 4.549 5.376c0 3.081-2.42 4.769-5.671 4.769a6.58 6.58 0 0 1-6.236-3.5ZM6.686 20c.538.954 1.027 1.76 2.2 1.76c1.124 0 1.834-.44 1.834-2.15V7.975h3.422v11.683c0 3.543-2.078 5.156-5.11 5.156A5.31 5.31 0 0 1 3.9 21.688Z"],Ts:[32,32,[],"solid","M23.827 8.243a4.4 4.4 0 0 1 2.223 1.281a6 6 0 0 1 .852 1.143c.011.045-1.534 1.083-2.471 1.662c-.034.023-.169-.124-.322-.35a2.01 2.01 0 0 0-1.67-1c-1.077-.074-1.771.49-1.766 1.433a1.3 1.3 0 0 0 .153.666c.237.49.677.784 2.059 1.383c2.544 1.095 3.636 1.817 4.31 2.843a5.16 5.16 0 0 1 .416 4.333a4.76 4.76 0 0 1-3.932 2.815a11 11 0 0 1-2.708-.028a6.53 6.53 0 0 1-3.616-1.884a6.3 6.3 0 0 1-.926-1.371a3 3 0 0 1 .327-.208c.158-.09.756-.434 1.32-.761l1.024-.6l.214.312a4.8 4.8 0 0 0 1.35 1.292a3.3 3.3 0 0 0 3.458-.175a1.545 1.545 0 0 0 .2-1.974c-.276-.395-.84-.727-2.443-1.422a8.8 8.8 0 0 1-3.349-2.055a4.7 4.7 0 0 1-.976-1.777a7.1 7.1 0 0 1-.062-2.268a4.33 4.33 0 0 1 3.644-3.374a9 9 0 0 1 2.691.084m-8.343 1.483l.011 1.454h-4.63v13.148H7.6V11.183H2.97V9.755a14 14 0 0 1 .04-1.466c.017-.023 2.832-.034 6.245-.028l6.211.017Z"],Linux:[448,512,[],"regular","M220.8 123.3c1 .5 1.8 1.7 3 1.7 1.1 0 2.8-.4 2.9-1.5.2-1.4-1.9-2.3-3.2-2.9-1.7-.7-3.9-1-5.5-.1-.4.2-.8.7-.6 1.1.3 1.3 2.3 1.1 3.4 1.7zm-21.9 1.7c1.2 0 2-1.2 3-1.7 1.1-.6 3.1-.4 3.5-1.6.2-.4-.2-.9-.6-1.1-1.6-.9-3.8-.6-5.5.1-1.3.6-3.4 1.5-3.2 2.9.1 1 1.8 1.5 2.8 1.4zM420 403.8c-3.6-4-5.3-11.6-7.2-19.7-1.8-8.1-3.9-16.8-10.5-22.4-1.3-1.1-2.6-2.1-4-2.9-1.3-.8-2.7-1.5-4.1-2 9.2-27.3 5.6-54.5-3.7-79.1-11.4-30.1-31.3-56.4-46.5-74.4-17.1-21.5-33.7-41.9-33.4-72C311.1 85.4 315.7.1 234.8 0 132.4-.2 158 103.4 156.9 135.2c-1.7 23.4-6.4 41.8-22.5 64.7-18.9 22.5-45.5 58.8-58.1 96.7-6 17.9-8.8 36.1-6.2 53.3-6.5 5.8-11.4 14.7-16.6 20.2-4.2 4.3-10.3 5.9-17 8.3s-14 6-18.5 14.5c-2.1 3.9-2.8 8.1-2.8 12.4 0 3.9.6 7.9 1.2 11.8 1.2 8.1 2.5 15.7.8 20.8-5.2 14.4-5.9 24.4-2.2 31.7 3.8 7.3 11.4 10.5 20.1 12.3 17.3 3.6 40.8 2.7 59.3 12.5 19.8 10.4 39.9 14.1 55.9 10.4 11.6-2.6 21.1-9.6 25.9-20.2 12.5-.1 26.3-5.4 48.3-6.6 14.9-1.2 33.6 5.3 55.1 4.1.6 2.3 1.4 4.6 2.5 6.7v.1c8.3 16.7 23.8 24.3 40.3 23 16.6-1.3 34.1-11 48.3-27.9 13.6-16.4 36-23.2 50.9-32.2 7.4-4.5 13.4-10.1 13.9-18.3.4-8.2-4.4-17.3-15.5-29.7zM223.7 87.3c9.8-22.2 34.2-21.8 44-.4 6.5 14.2 3.6 30.9-4.3 40.4-1.6-.8-5.9-2.6-12.6-4.9 1.1-1.2 3.1-2.7 3.9-4.6 4.8-11.8-.2-27-9.1-27.3-7.3-.5-13.9 10.8-11.8 23-4.1-2-9.4-3.5-13-4.4-1-6.9-.3-14.6 2.9-21.8zM183 75.8c10.1 0 20.8 14.2 19.1 33.5-3.5 1-7.1 2.5-10.2 4.6 1.2-8.9-3.3-20.1-9.6-19.6-8.4.7-9.8 21.2-1.8 28.1 1 .8 1.9-.2-5.9 5.5-15.6-14.6-10.5-52.1 8.4-52.1zm-13.6 60.7c6.2-4.6 13.6-10 14.1-10.5 4.7-4.4 13.5-14.2 27.9-14.2 7.1 0 15.6 2.3 25.9 8.9 6.3 4.1 11.3 4.4 22.6 9.3 8.4 3.5 13.7 9.7 10.5 18.2-2.6 7.1-11 14.4-22.7 18.1-11.1 3.6-19.8 16-38.2 14.9-3.9-.2-7-1-9.6-2.1-8-3.5-12.2-10.4-20-15-8.6-4.8-13.2-10.4-14.7-15.3-1.4-4.9 0-9 4.2-12.3zm3.3 334c-2.7 35.1-43.9 34.4-75.3 18-29.9-15.8-68.6-6.5-76.5-21.9-2.4-4.7-2.4-12.7 2.6-26.4v-.2c2.4-7.6.6-16-.6-23.9-1.2-7.8-1.8-15 .9-20 3.5-6.7 8.5-9.1 14.8-11.3 10.3-3.7 11.8-3.4 19.6-9.9 5.5-5.7 9.5-12.9 14.3-18 5.1-5.5 10-8.1 17.7-6.9 8.1 1.2 15.1 6.8 21.9 16l19.6 35.6c9.5 19.9 43.1 48.4 41 68.9zm-1.4-25.9c-4.1-6.6-9.6-13.6-14.4-19.6 7.1 0 14.2-2.2 16.7-8.9 2.3-6.2 0-14.9-7.4-24.9-13.5-18.2-38.3-32.5-38.3-32.5-13.5-8.4-21.1-18.7-24.6-29.9s-3-23.3-.3-35.2c5.2-22.9 18.6-45.2 27.2-59.2 2.3-1.7.8 3.2-8.7 20.8-8.5 16.1-24.4 53.3-2.6 82.4.6-20.7 5.5-41.8 13.8-61.5 12-27.4 37.3-74.9 39.3-112.7 1.1.8 4.6 3.2 6.2 4.1 4.6 2.7 8.1 6.7 12.6 10.3 12.4 10 28.5 9.2 42.4 1.2 6.2-3.5 11.2-7.5 15.9-9 9.9-3.1 17.8-8.6 22.3-15 7.7 30.4 25.7 74.3 37.2 95.7 6.1 11.4 18.3 35.5 23.6 64.6 3.3-.1 7 .4 10.9 1.4 13.8-35.7-11.7-74.2-23.3-84.9-4.7-4.6-4.9-6.6-2.6-6.5 12.6 11.2 29.2 33.7 35.2 59 2.8 11.6 3.3 23.7.4 35.7 16.4 6.8 35.9 17.9 30.7 34.8-2.2-.1-3.2 0-4.2 0 3.2-10.1-3.9-17.6-22.8-26.1-19.6-8.6-36-8.6-38.3 12.5-12.1 4.2-18.3 14.7-21.4 27.3-2.8 11.2-3.6 24.7-4.4 39.9-.5 7.7-3.6 18-6.8 29-32.1 22.9-76.7 32.9-114.3 7.2zm257.4-11.5c-.9 16.8-41.2 19.9-63.2 46.5-13.2 15.7-29.4 24.4-43.6 25.5s-26.5-4.8-33.7-19.3c-4.7-11.1-2.4-23.1 1.1-36.3 3.7-14.2 9.2-28.8 9.9-40.6.8-15.2 1.7-28.5 4.2-38.7 2.6-10.3 6.6-17.2 13.7-21.1.3-.2.7-.3 1-.5.8 13.2 7.3 26.6 18.8 29.5 12.6 3.3 30.7-7.5 38.4-16.3 9-.3 15.7-.9 22.6 5.1 9.9 8.5 7.1 30.3 17.1 41.6 10.6 11.6 14 19.5 13.7 24.6zM173.3 148.7c2 1.9 4.7 4.5 8 7.1 6.6 5.2 15.8 10.6 27.3 10.6 11.6 0 22.5-5.9 31.8-10.8 4.9-2.6 10.9-7 14.8-10.4s5.9-6.3 3.1-6.6-2.6 2.6-6 5.1c-4.4 3.2-9.7 7.4-13.9 9.8-7.4 4.2-19.5 10.2-29.9 10.2s-18.7-4.8-24.9-9.7c-3.1-2.5-5.7-5-7.7-6.9-1.5-1.4-1.9-4.6-4.3-4.9-1.4-.1-1.8 3.7 1.7 6.5z"],SquareJs:[448,512,[],"solid","M448 96c0-35.3-28.7-64-64-64H64C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96zM180.9 444.9c-33.7 0-53.2-17.4-63.2-38.5L152 385.7c6.6 11.7 12.6 21.6 27.1 21.6c13.8 0 22.6-5.4 22.6-26.5V237.7h42.1V381.4c0 43.6-25.6 63.5-62.9 63.5zm85.8-43L301 382.1c9 14.7 20.8 25.6 41.5 25.6c17.4 0 28.6-8.7 28.6-20.8c0-14.4-11.4-19.5-30.7-28l-10.5-4.5c-30.4-12.9-50.5-29.2-50.5-63.5c0-31.6 24.1-55.6 61.6-55.6c26.8 0 46 9.3 59.8 33.7L368 290c-7.2-12.9-15-18-27.1-18c-12.3 0-20.1 7.8-20.1 18c0 12.6 7.8 17.7 25.9 25.6l10.5 4.5c35.8 15.3 55.9 31 55.9 66.2c0 37.8-29.8 58.6-69.7 58.6c-39.1 0-64.4-18.6-76.7-43z"],Safari:[512,512,[],"solid","M274.69,274.69l-37.38-37.38L166,346ZM256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8ZM411.85,182.79l14.78-6.13A8,8,0,0,1,437.08,181h0a8,8,0,0,1-4.33,10.46L418,197.57a8,8,0,0,1-10.45-4.33h0A8,8,0,0,1,411.85,182.79ZM314.43,94l6.12-14.78A8,8,0,0,1,331,74.92h0a8,8,0,0,1,4.33,10.45l-6.13,14.78a8,8,0,0,1-10.45,4.33h0A8,8,0,0,1,314.43,94ZM256,60h0a8,8,0,0,1,8,8V84a8,8,0,0,1-8,8h0a8,8,0,0,1-8-8V68A8,8,0,0,1,256,60ZM181,74.92a8,8,0,0,1,10.46,4.33L197.57,94a8,8,0,1,1-14.78,6.12l-6.13-14.78A8,8,0,0,1,181,74.92Zm-63.58,42.49h0a8,8,0,0,1,11.31,0L140,128.72A8,8,0,0,1,140,140h0a8,8,0,0,1-11.31,0l-11.31-11.31A8,8,0,0,1,117.41,117.41ZM60,256h0a8,8,0,0,1,8-8H84a8,8,0,0,1,8,8h0a8,8,0,0,1-8,8H68A8,8,0,0,1,60,256Zm40.15,73.21-14.78,6.13A8,8,0,0,1,74.92,331h0a8,8,0,0,1,4.33-10.46L94,314.43a8,8,0,0,1,10.45,4.33h0A8,8,0,0,1,100.15,329.21Zm4.33-136h0A8,8,0,0,1,94,197.57l-14.78-6.12A8,8,0,0,1,74.92,181h0a8,8,0,0,1,10.45-4.33l14.78,6.13A8,8,0,0,1,104.48,193.24ZM197.57,418l-6.12,14.78a8,8,0,0,1-14.79-6.12l6.13-14.78A8,8,0,1,1,197.57,418ZM264,444a8,8,0,0,1-8,8h0a8,8,0,0,1-8-8V428a8,8,0,0,1,8-8h0a8,8,0,0,1,8,8Zm67-6.92h0a8,8,0,0,1-10.46-4.33L314.43,418a8,8,0,0,1,4.33-10.45h0a8,8,0,0,1,10.45,4.33l6.13,14.78A8,8,0,0,1,331,437.08Zm63.58-42.49h0a8,8,0,0,1-11.31,0L372,383.28A8,8,0,0,1,372,372h0a8,8,0,0,1,11.31,0l11.31,11.31A8,8,0,0,1,394.59,394.59ZM286.25,286.25,110.34,401.66,225.75,225.75,401.66,110.34ZM437.08,331h0a8,8,0,0,1-10.45,4.33l-14.78-6.13a8,8,0,0,1-4.33-10.45h0A8,8,0,0,1,418,314.43l14.78,6.12A8,8,0,0,1,437.08,331ZM444,264H428a8,8,0,0,1-8-8h0a8,8,0,0,1,8-8h16a8,8,0,0,1,8,8h0A8,8,0,0,1,444,264Z"],Php:[512,512,[],"solid","M170.322 349.808c-2.4-15.66-9-28.38-25.02-34.531c-6.27-2.4-11.7-6.78-17.88-9.54c-7.02-3.15-14.16-6.15-21.57-8.1c-5.61-1.5-10.83 1.02-14.16 5.94c-3.15 4.62-.87 8.97 1.77 12.84c2.97 4.35 6.27 8.49 9.6 12.57c5.52 6.78 11.37 13.29 16.74 20.161c5.13 6.57 9.51 13.86 8.76 22.56c-1.65 19.08-10.29 34.891-24.21 47.76c-1.53 1.38-4.23 2.37-6.21 2.19c-8.88-.96-16.95-4.32-23.46-10.53c-7.47-7.11-6.33-15.48 2.61-20.67c2.13-1.23 4.35-2.37 6.3-3.87c5.46-4.11 7.29-11.13 4.32-17.22c-1.41-2.94-3-6.12-5.34-8.25c-11.43-10.41-22.651-21.151-34.891-30.63C18.01 307.447 2.771 276.968.43 240.067c-2.64-40.981 6.87-79.231 28.5-114.242c8.19-13.29 17.73-25.951 32.37-32.52c9.96-4.47 20.88-6.99 31.531-9.78c29.311-7.71 58.89-13.5 89.401-8.34c26.28 4.41 45.511 17.94 54.331 43.77c5.79 16.89 7.17 34.35 5.37 52.231c-3.54 35.131-29.49 66.541-63.331 75.841c-14.67 4.02-22.68 1.77-31.5-10.44c-6.33-8.79-11.58-18.36-17.25-27.631c-.84-1.38-1.44-2.97-2.16-4.44c-.69-1.47-1.44-2.88-2.16-4.35c2.13 15.24 5.67 29.911 13.98 42.99c4.5 7.11 10.5 12.36 19.29 13.14c32.34 2.91 59.641-7.71 79.021-33.721c21.69-29.101 26.461-62.581 20.19-97.831c-1.23-6.96-3.3-13.77-4.77-20.7c-.99-4.47.78-7.77 5.19-9.33c2.04-.69 4.14-1.26 6.18-1.68c26.461-5.7 53.221-7.59 80.191-4.86c30.601 3.06 59.551 11.46 85.441 28.471c40.531 26.67 65.641 64.621 79.291 110.522c1.98 6.66 2.28 13.95 2.46 20.971c.12 4.68-2.88 5.91-6.45 2.97c-3.93-3.21-7.53-6.87-10.92-10.65c-3.15-3.57-5.67-7.65-8.73-11.4c-2.37-2.94-4.44-2.49-5.58 1.17c-.72 2.22-1.35 4.41-1.98 6.63c-7.08 25.26-18.24 48.3-36.33 67.711c-2.52 2.73-4.77 6.78-5.07 10.38c-.78 9.96-1.35 20.13-.39 30.06c1.98 21.331 5.07 42.57 7.47 63.871c1.35 12.03-2.52 19.11-13.83 23.281c-7.95 2.91-16.47 5.04-24.87 5.64c-13.38.93-26.88.27-40.32.27c-.36-15 .93-29.731-13.17-37.771c2.73-11.13 5.88-21.69 7.77-32.49c1.56-8.97.24-17.79-6.06-25.14c-5.91-6.93-13.32-8.82-20.101-4.86c-20.43 11.91-41.671 11.97-63.301 4.17c-9.93-3.6-16.86-1.56-22.351 7.5c-5.91 9.75-8.4 20.7-7.74 31.771c.84 13.95 3.27 27.75 5.13 41.64c1.02 7.77.15 9.78-7.56 11.76c-17.13 4.35-34.56 4.83-52.081 3.42c-.93-.09-1.86-.48-2.46-.63c-.87-14.55.66-29.671-16.68-37.411c7.68-16.29 6.63-33.18 3.99-50.07l-.06-.15zm-103.561-57.09c2.55-2.4 4.59-6.15 5.31-9.6c1.8-8.64-4.68-20.22-12.18-23.43c-3.99-1.74-7.47-1.11-10.29 2.07c-6.87 7.77-13.65 15.63-20.401 23.521c-1.14 1.35-2.16 2.94-2.97 4.53c-2.7 5.19-1.11 8.97 4.65 10.38c3.48.87 7.08 1.05 10.65 1.56c9.3-.9 18.3-2.46 25.23-9zm.78-86.371c-.03-6.18-5.19-11.34-11.28-11.37c-6.27-.03-11.67 5.58-11.46 11.76c.27 6.21 5.43 11.19 11.61 11.07c6.24-.09 11.22-5.19 11.16-11.43z"],Python:[448,512,[],"solid","M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"],Markdown:[32,32,[],"solid","m14 10l-4 3.5L6 10H4v12h4v-6l2 2l2-2v6h4V10zm12 6v-6h-4v6h-4l6 8l6-8z"],Microsoft:[448,512,[],"solid","M0 32h214.6v214.6H0V32zm233.4 0H448v214.6H233.4V32zM0 265.4h214.6V480H0V265.4zm233.4 0H448V480H233.4V265.4z"],Npm:[576,512,[],"solid","M288 288h-32v-64h32v64zm288-128v192H288v32H160v-32H0V160h576zm-416 32H32v128h64v-96h32v96h32V192zm160 0H192v160h64v-32h64V192zm224 0H352v128h64v-96h32v96h32v-96h32v96h32V192z"],Reddit:[512,512,[],"solid","M0 256C0 114.6 114.6 0 256 0S512 114.6 512 256s-114.6 256-256 256L37.1 512c-13.7 0-20.5-16.5-10.9-26.2L75 437C28.7 390.7 0 326.7 0 256zM349.6 153.6c23.6 0 42.7-19.1 42.7-42.7s-19.1-42.7-42.7-42.7c-20.6 0-37.8 14.6-41.8 34c-34.5 3.7-61.4 33-61.4 68.4l0 .2c-37.5 1.6-71.8 12.3-99 29.1c-10.1-7.8-22.8-12.5-36.5-12.5c-33 0-59.8 26.8-59.8 59.8c0 24 14.1 44.6 34.4 54.1c2 69.4 77.6 125.2 170.6 125.2s168.7-55.9 170.6-125.3c20.2-9.6 34.1-30.2 34.1-54c0-33-26.8-59.8-59.8-59.8c-13.7 0-26.3 4.6-36.4 12.4c-27.4-17-62.1-27.7-100-29.1l0-.2c0-25.4 18.9-46.5 43.4-49.9l0 0c4.4 18.8 21.3 32.8 41.5 32.8zM177.1 246.9c16.7 0 29.5 17.6 28.5 39.3s-13.5 29.6-30.3 29.6s-31.4-8.8-30.4-30.5s15.4-38.3 32.1-38.3zm190.1 38.3c1 21.7-13.7 30.5-30.4 30.5s-29.3-7.9-30.3-29.6c-1-21.7 11.8-39.3 28.5-39.3s31.2 16.6 32.1 38.3zm-48.1 56.7c-10.3 24.6-34.6 41.9-63 41.9s-52.7-17.3-63-41.9c-1.2-2.9 .8-6.2 3.9-6.5c18.4-1.9 38.3-2.9 59.1-2.9s40.7 1 59.1 2.9c3.1 .3 5.1 3.6 3.9 6.5z"],Rust:[512,512,[],"solid","M508.52,249.75,486.7,236.24c-.17-2-.34-3.93-.55-5.88l18.72-17.5a7.35,7.35,0,0,0-2.44-12.25l-24-9c-.54-1.88-1.08-3.78-1.67-5.64l15-20.83a7.35,7.35,0,0,0-4.79-11.54l-25.42-4.15c-.9-1.73-1.79-3.45-2.73-5.15l10.68-23.42a7.35,7.35,0,0,0-6.95-10.39l-25.82.91q-1.79-2.22-3.61-4.4L439,81.84A7.36,7.36,0,0,0,430.16,73L405,78.93q-2.17-1.83-4.4-3.61l.91-25.82a7.35,7.35,0,0,0-10.39-7L367.7,53.23c-1.7-.94-3.43-1.84-5.15-2.73L358.4,25.08a7.35,7.35,0,0,0-11.54-4.79L326,35.26c-1.86-.59-3.75-1.13-5.64-1.67l-9-24a7.35,7.35,0,0,0-12.25-2.44l-17.5,18.72c-1.95-.21-3.91-.38-5.88-.55L262.25,3.48a7.35,7.35,0,0,0-12.5,0L236.24,25.3c-2,.17-3.93.34-5.88.55L212.86,7.13a7.35,7.35,0,0,0-12.25,2.44l-9,24c-1.89.55-3.79,1.08-5.66,1.68l-20.82-15a7.35,7.35,0,0,0-11.54,4.79l-4.15,25.41c-1.73.9-3.45,1.79-5.16,2.73L120.88,42.55a7.35,7.35,0,0,0-10.39,7l.92,25.81c-1.49,1.19-3,2.39-4.42,3.61L81.84,73A7.36,7.36,0,0,0,73,81.84L78.93,107c-1.23,1.45-2.43,2.93-3.62,4.41l-25.81-.91a7.42,7.42,0,0,0-6.37,3.26,7.35,7.35,0,0,0-.57,7.13l10.66,23.41c-.94,1.7-1.83,3.43-2.73,5.16L25.08,153.6a7.35,7.35,0,0,0-4.79,11.54l15,20.82c-.59,1.87-1.13,3.77-1.68,5.66l-24,9a7.35,7.35,0,0,0-2.44,12.25l18.72,17.5c-.21,1.95-.38,3.91-.55,5.88L3.48,249.75a7.35,7.35,0,0,0,0,12.5L25.3,275.76c.17,2,.34,3.92.55,5.87L7.13,299.13a7.35,7.35,0,0,0,2.44,12.25l24,9c.55,1.89,1.08,3.78,1.68,5.65l-15,20.83a7.35,7.35,0,0,0,4.79,11.54l25.42,4.15c.9,1.72,1.79,3.45,2.73,5.14L42.56,391.12a7.35,7.35,0,0,0,.57,7.13,7.13,7.13,0,0,0,6.37,3.26l25.83-.91q1.77,2.22,3.6,4.4L73,430.16A7.36,7.36,0,0,0,81.84,439L107,433.07q2.18,1.83,4.41,3.61l-.92,25.82a7.35,7.35,0,0,0,10.39,6.95l23.43-10.68c1.69.94,3.42,1.83,5.14,2.73l4.15,25.42a7.34,7.34,0,0,0,11.54,4.78l20.83-15c1.86.6,3.76,1.13,5.65,1.68l9,24a7.36,7.36,0,0,0,12.25,2.44l17.5-18.72c1.95.21,3.92.38,5.88.55l13.51,21.82a7.35,7.35,0,0,0,12.5,0l13.51-21.82c2-.17,3.93-.34,5.88-.56l17.5,18.73a7.36,7.36,0,0,0,12.25-2.44l9-24c1.89-.55,3.78-1.08,5.65-1.68l20.82,15a7.34,7.34,0,0,0,11.54-4.78l4.15-25.42c1.72-.9,3.45-1.79,5.15-2.73l23.42,10.68a7.35,7.35,0,0,0,10.39-6.95l-.91-25.82q2.22-1.79,4.4-3.61L430.16,439a7.36,7.36,0,0,0,8.84-8.84L433.07,405q1.83-2.17,3.61-4.4l25.82.91a7.23,7.23,0,0,0,6.37-3.26,7.35,7.35,0,0,0,.58-7.13L458.77,367.7c.94-1.7,1.83-3.43,2.73-5.15l25.42-4.15a7.35,7.35,0,0,0,4.79-11.54l-15-20.83c.59-1.87,1.13-3.76,1.67-5.65l24-9a7.35,7.35,0,0,0,2.44-12.25l-18.72-17.5c.21-1.95.38-3.91.55-5.87l21.82-13.51a7.35,7.35,0,0,0,0-12.5Zm-151,129.08A13.91,13.91,0,0,0,341,389.51l-7.64,35.67A187.51,187.51,0,0,1,177,424.44l-7.64-35.66a13.87,13.87,0,0,0-16.46-10.68l-31.51,6.76a187.38,187.38,0,0,1-16.26-19.21H258.3c1.72,0,2.89-.29,2.89-1.91V309.55c0-1.57-1.17-1.91-2.89-1.91H213.47l.05-34.35H262c4.41,0,23.66,1.28,29.79,25.87,1.91,7.55,6.17,32.14,9.06,40,2.89,8.82,14.6,26.46,27.1,26.46H407a187.3,187.3,0,0,1-17.34,20.09Zm25.77,34.49A15.24,15.24,0,1,1,368,398.08h.44A15.23,15.23,0,0,1,383.24,413.32Zm-225.62-.68a15.24,15.24,0,1,1-15.25-15.25h.45A15.25,15.25,0,0,1,157.62,412.64ZM69.57,234.15l32.83-14.6a13.88,13.88,0,0,0,7.06-18.33L102.69,186h26.56V305.73H75.65A187.65,187.65,0,0,1,69.57,234.15ZM58.31,198.09a15.24,15.24,0,0,1,15.23-15.25H74a15.24,15.24,0,1,1-15.67,15.24Zm155.16,24.49.05-35.32h63.26c3.28,0,23.07,3.77,23.07,18.62,0,12.29-15.19,16.7-27.68,16.7ZM399,306.71c-9.8,1.13-20.63-4.12-22-10.09-5.78-32.49-15.39-39.4-30.57-51.4,18.86-11.95,38.46-29.64,38.46-53.26,0-25.52-17.49-41.59-29.4-49.48-16.76-11-35.28-13.23-40.27-13.23H116.32A187.49,187.49,0,0,1,221.21,70.06l23.47,24.6a13.82,13.82,0,0,0,19.6.44l26.26-25a187.51,187.51,0,0,1,128.37,91.43l-18,40.57A14,14,0,0,0,408,220.43l34.59,15.33a187.12,187.12,0,0,1,.4,32.54H423.71c-1.91,0-2.69,1.27-2.69,3.13v8.82C421,301,409.31,305.58,399,306.71ZM240,60.21A15.24,15.24,0,0,1,255.21,45h.45A15.24,15.24,0,1,1,240,60.21ZM436.84,214a15.24,15.24,0,1,1,0-30.48h.44a15.24,15.24,0,0,1-.44,30.48Z"],Unity:[16,16,[],"solid","M8 6.5L5 5l2-1V2L2 5v5l2-1V6.5L7 8v4.5L4 11l-2 1l6 3l6-3l-2-1l-3 1.5V8l3-1.5V9l2 1V5L9 2v2l2 1Z"],UnrealEngine:[24,24,[],"regular","M12 0a12 12 0 1 0 12 12A12 12 0 0 0 12 0m0 23.52A11.52 11.52 0 1 1 23.52 12A11.52 11.52 0 0 1 12 23.52m7.13-9.791c-.206.997-1.126 3.557-4.06 4.942l-1.179-1.325l-1.988 2a7.34 7.34 0 0 1-5.804-2.978a3 3 0 0 0 .65.123c.326.006.678-.114.678-.66v-5.394a.89.89 0 0 0-1.116-.89c-.92.212-1.656 2.509-1.656 2.509a7.3 7.3 0 0 1 2.528-5.597a7.4 7.4 0 0 1 3.73-1.721c-1.006.573-1.57 1.507-1.57 2.29c0 1.262.76 1.109.984.923v7.28a1.2 1.2 0 0 0 .148.256a1.08 1.08 0 0 0 .88.445c.76 0 1.747-.868 1.747-.868V9.172c0-.6-.452-1.324-.905-1.572c0 0 .838-.149 1.484.346a6 6 0 0 1 .387-.425c1.508-1.48 2.929-1.902 4.112-2.112c0 0-2.151 1.69-2.151 3.96c0 1.687.043 5.801.043 5.801c.799.771 1.986-.342 3.059-1.441Z"],"UnrealEngine@solid":[24,24,[],"solid","M12 23c6.075 0 11-4.925 11-11S18.075 1 12 1S1 5.925 1 12s4.925 11 11 11m-8.442-9.416c.718-2.333 2.53-6.86 7.27-8.584v10.23c.179.18.645.54 1.076.54c.67 0 1.615-.54 1.615-.54V8.77c.555-1.16 3.123-3.232 4.847-3.232c-1.044 1.204-1.532 1.91-2.154 3.231v6.462c.718.18 2.154 0 3.23-1.077c-.87 1.98-3.23 4.308-4.307 4.308l-1.616-1.077L11.904 19c-1.615 0-4.308-1.077-5.385-2.692h1.616v-6.17c-1.96-.268-2.857.973-4.577 3.446"],Ubuntu:[576,512,[],"solid","M469.2 75A75.6 75.6 0 1 0 317.9 75a75.6 75.6 0 1 0 151.2 0zM154.2 240.7A75.6 75.6 0 1 0 3 240.7a75.6 75.6 0 1 0 151.2 0zM57 346C75.6 392.9 108 433 150 461.1s91.5 42.6 142 41.7c-14.7-18.6-22.9-41.5-23.2-65.2c-6.8-.9-13.3-2.1-19.5-3.4c-26.8-5.7-51.9-17.3-73.6-34s-39.3-38.1-51.7-62.5c-20.9 9.9-44.5 12.8-67.1 8.2zm395.1 89.8a75.6 75.6 0 1 0 -151.2 0 75.6 75.6 0 1 0 151.2 0zM444 351.6c18.5 14.8 31.6 35.2 37.2 58.2c33.3-41.3 52.6-92.2 54.8-145.2s-12.5-105.4-42.2-149.4c-8.6 21.5-24 39.6-43.8 51.6c15.4 28.6 22.9 60.8 21.9 93.2s-10.7 64-28 91.6zM101.1 135.4c12.4 2.7 24.3 7.5 35.1 14.3c16.6-24.2 38.9-44.1 64.8-58S255.8 70.4 285.2 70c.2-5.9 .9-11.9 2-17.7c3.6-16.7 11.1-32.3 21.8-45.5c-47.7-3.8-95.4 6-137.6 28.5S94.3 91.7 70.8 133.4c2.7-.2 5.3-.3 8-.3c7.5 0 15 .8 22.4 2.3z"],VsCode:[16,16,[],"solid","M11.5 11.19V4.8L7.3 7.99M1.17 6.07a.6.6 0 0 1-.01-.81L2 4.48c.14-.13.48-.18.73 0l2.39 1.83l5.55-5.09c.22-.22.61-.32 1.05-.08l2.8 1.34c.25.15.49.38.49.81v9.49c0 .28-.2.58-.42.7l-3.08 1.48c-.22.09-.64 0-.79-.14L5.11 9.69l-2.38 1.83c-.27.18-.6.13-.74 0l-.84-.77c-.22-.23-.2-.61.04-.84l2.1-1.9"],Windows:[448,512,[],"solid","M0 93.7l183.6-25.3v177.4H0V93.7zm0 324.6l183.6 25.3V268.4H0v149.9zm203.8 28L448 480V268.4H203.8v177.9zm0-380.6v180.1H448V32L203.8 65.7z"],Whatsapp:[448,512,[],"regular","M380.9 97.1C339 55.1 283.2 32 223.9 32c-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480l117.7-30.9c32.4 17.7 68.9 27 106.1 27h.1c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3L72 359.2l-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1 34.8 34.9 56.2 81.2 56.1 130.5 0 101.8-84.9 184.6-186.6 184.6zm101.2-138.2c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8-3.7 5.6-14.3 18-17.6 21.8-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7.9-6.9-.5-9.7-1.4-2.8-12.5-30.1-17.1-41.2-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2-3.7 0-9.7 1.4-14.8 6.9-5.1 5.6-19.4 19-19.4 46.3 0 27.3 19.9 53.7 22.6 57.4 2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4 4.6-13 4.6-24.1 3.2-26.4-1.3-2.5-5-3.9-10.5-6.6z"],"X-Twitter":[512,512,[],"regular","M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"],Keyboard:[576,512,[],"regular","M64 112c-8.8 0-16 7.2-16 16l0 256c0 8.8 7.2 16 16 16l448 0c8.8 0 16-7.2 16-16l0-256c0-8.8-7.2-16-16-16L64 112zM0 128C0 92.7 28.7 64 64 64l448 0c35.3 0 64 28.7 64 64l0 256c0 35.3-28.7 64-64 64L64 448c-35.3 0-64-28.7-64-64L0 128zM176 320l224 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-224 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16zm-72-72c0-8.8 7.2-16 16-16l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16zm16-96l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16zm64 96c0-8.8 7.2-16 16-16l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16zm16-96l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16zm64 96c0-8.8 7.2-16 16-16l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16zm16-96l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16zm64 96c0-8.8 7.2-16 16-16l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16zm16-96l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16zm64 96c0-8.8 7.2-16 16-16l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16zm16-96l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16z"],IdCard:[576,512,[],"regular","M528 160l0 256c0 8.8-7.2 16-16 16l-192 0c0-44.2-35.8-80-80-80l-64 0c-44.2 0-80 35.8-80 80l-32 0c-8.8 0-16-7.2-16-16l0-256 480 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l448 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zM272 256a64 64 0 1 0 -128 0 64 64 0 1 0 128 0zm104-48c-13.3 0-24 10.7-24 24s10.7 24 24 24l80 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-80 0zm0 96c-13.3 0-24 10.7-24 24s10.7 24 24 24l80 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-80 0z"],BookUser:[576,512,[],"regular","M512 80c8.8 0 16 7.2 16 16l0 320c0 8.8-7.2 16-16 16L64 432c-8.8 0-16-7.2-16-16L48 96c0-8.8 7.2-16 16-16l448 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l448 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zM208 256a64 64 0 1 0 0-128 64 64 0 1 0 0 128zm-32 32c-44.2 0-80 35.8-80 80c0 8.8 7.2 16 16 16l192 0c8.8 0 16-7.2 16-16c0-44.2-35.8-80-80-80l-64 0zM376 144c-13.3 0-24 10.7-24 24s10.7 24 24 24l80 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-80 0zm0 96c-13.3 0-24 10.7-24 24s10.7 24 24 24l80 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-80 0z"],Copy:[448,512,[],"regular","M384 336l-192 0c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l140.1 0L400 115.9 400 320c0 8.8-7.2 16-16 16zM192 384l192 0c35.3 0 64-28.7 64-64l0-204.1c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1L192 0c-35.3 0-64 28.7-64 64l0 256c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l192 0c35.3 0 64-28.7 64-64l0-32-48 0 0 32c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l32 0 0-48-32 0z"],Eye:[576,512,[],"regular","M288 80c-65.2 0-118.8 29.6-159.9 67.7C89.6 183.5 63 226 49.4 256c13.6 30 40.2 72.5 78.6 108.3C169.2 402.4 222.8 432 288 432s118.8-29.6 159.9-67.7C486.4 328.5 513 286 526.6 256c-13.6-30-40.2-72.5-78.6-108.3C406.8 109.6 353.2 80 288 80zM95.4 112.6C142.5 68.8 207.2 32 288 32s145.5 36.8 192.6 80.6c46.8 43.5 78.1 95.4 93 131.1c3.3 7.9 3.3 16.7 0 24.6c-14.9 35.7-46.2 87.7-93 131.1C433.5 443.2 368.8 480 288 480s-145.5-36.8-192.6-80.6C48.6 356 17.3 304 2.5 268.3c-3.3-7.9-3.3-16.7 0-24.6C17.3 208 48.6 156 95.4 112.6zM288 336c44.2 0 80-35.8 80-80s-35.8-80-80-80c-.7 0-1.3 0-2 0c1.3 5.1 2 10.5 2 16c0 35.3-28.7 64-64 64c-5.5 0-10.9-.7-16-2c0 .7 0 1.3 0 2c0 44.2 35.8 80 80 80zm0-208a128 128 0 1 1 0 256 128 128 0 1 1 0-256z"],EyeOff:[640,512,[],"regular","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zm151 118.3C226 97.7 269.5 80 320 80c65.2 0 118.8 29.6 159.9 67.7C518.4 183.5 545 226 558.6 256c-12.6 28-36.6 66.8-70.9 100.9l-53.8-42.2c9.1-17.6 14.2-37.5 14.2-58.7c0-70.7-57.3-128-128-128c-32.2 0-61.7 11.9-84.2 31.5l-46.1-36.1zM394.9 284.2l-81.5-63.9c4.2-8.5 6.6-18.2 6.6-28.3c0-5.5-.7-10.9-2-16c.7 0 1.3 0 2 0c44.2 0 80 35.8 80 80c0 9.9-1.8 19.4-5.1 28.2zm9.4 130.3C378.8 425.4 350.7 432 320 432c-65.2 0-118.8-29.6-159.9-67.7C121.6 328.5 95 286 81.4 256c8.3-18.4 21.5-41.5 39.4-64.8L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5l-41.9-33zM192 256c0 70.7 57.3 128 128 128c13.3 0 26.1-2 38.2-5.8L302 334c-23.5-5.4-43.1-21.2-53.7-42.3l-56.1-44.2c-.2 2.8-.3 5.6-.3 8.5z"],StickyNote:[448,512,[],"regular","M64 80c-8.8 0-16 7.2-16 16l0 320c0 8.8 7.2 16 16 16l224 0 0-80c0-17.7 14.3-32 32-32l80 0 0-224c0-8.8-7.2-16-16-16L64 80zM288 480L64 480c-35.3 0-64-28.7-64-64L0 96C0 60.7 28.7 32 64 32l320 0c35.3 0 64 28.7 64 64l0 224 0 5.5c0 17-6.7 33.3-18.7 45.3l-90.5 90.5c-12 12-28.3 18.7-45.3 18.7l-5.5 0z"],CreditCard:[576,512,[],"regular","M512 80c8.8 0 16 7.2 16 16l0 32L48 128l0-32c0-8.8 7.2-16 16-16l448 0zm16 144l0 192c0 8.8-7.2 16-16 16L64 432c-8.8 0-16-7.2-16-16l0-192 480 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l448 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm56 304c-13.3 0-24 10.7-24 24s10.7 24 24 24l48 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-48 0zm128 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l112 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-112 0z"],Hourglass:[384,512,[],"regular","M24 0C10.7 0 0 10.7 0 24S10.7 48 24 48l8 0 0 19c0 40.3 16 79 44.5 107.5L158.1 256 76.5 337.5C48 366 32 404.7 32 445l0 19-8 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l336 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-8 0 0-19c0-40.3-16-79-44.5-107.5L225.9 256l81.5-81.5C336 146 352 107.3 352 67l0-19 8 0c13.3 0 24-10.7 24-24s-10.7-24-24-24L24 0zM192 289.9l81.5 81.5C293 391 304 417.4 304 445l0 19L80 464l0-19c0-27.6 11-54 30.5-73.5L192 289.9zm0-67.9l-81.5-81.5C91 121 80 94.6 80 67l0-19 224 0 0 19c0 27.6-11 54-30.5 73.5L192 222.1z"],Bell:[448,512,[],"solid","M224 0c-17.7 0-32 14.3-32 32l0 19.2C119 66 64 130.6 64 208l0 18.8c0 47-17.3 92.4-48.5 127.6l-7.4 8.3c-8.4 9.4-10.4 22.9-5.3 34.4S19.4 416 32 416l384 0c12.6 0 24-7.4 29.2-18.9s3.1-25-5.3-34.4l-7.4-8.3C401.3 319.2 384 273.9 384 226.8l0-18.8c0-77.4-55-142-128-156.8L256 32c0-17.7-14.3-32-32-32zm45.3 493.3c12-12 18.7-28.3 18.7-45.3l-64 0-64 0c0 17 6.7 33.3 18.7 45.3s28.3 18.7 45.3 18.7s33.3-6.7 45.3-18.7z"],BellOff:[640,512,[],"solid","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7l-90.2-70.7c.2-.4 .4-.9 .6-1.3c5.2-11.5 3.1-25-5.3-34.4l-7.4-8.3C497.3 319.2 480 273.9 480 226.8l0-18.8c0-77.4-55-142-128-156.8L352 32c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 19.2c-42.6 8.6-79 34.2-102 69.3L38.8 5.1zM406.2 416L160 222.1l0 4.8c0 47-17.3 92.4-48.5 127.6l-7.4 8.3c-8.4 9.4-10.4 22.9-5.3 34.4S115.4 416 128 416l278.2 0zm-40.9 77.3c12-12 18.7-28.3 18.7-45.3l-64 0-64 0c0 17 6.7 33.3 18.7 45.3s28.3 18.7 45.3 18.7s33.3-6.7 45.3-18.7z"],Compass:[512,512,[],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm50.7-186.9L162.4 380.6c-19.4 7.5-38.5-11.6-31-31l55.5-144.3c3.3-8.5 9.9-15.1 18.4-18.4l144.3-55.5c19.4-7.5 38.5 11.6 31 31L325.1 306.7c-3.2 8.5-9.9 15.1-18.4 18.4zM288 256a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"],File:[384,512,[],"solid","M0 64C0 28.7 28.7 0 64 0L224 0l0 128c0 17.7 14.3 32 32 32l128 0 0 288c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 64zm384 64l-128 0L256 0 384 128z"],MessageCircle:[512,512,[],"solid","M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4c0 0 0 0 0 0s0 0 0 0s0 0 0 0c0 0 0 0 0 0l.3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"],Inbox:[512,512,[],"solid","M121 32C91.6 32 66 52 58.9 80.5L1.9 308.4C.6 313.5 0 318.7 0 323.9L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-92.1c0-5.2-.6-10.4-1.9-15.5l-57-227.9C446 52 420.4 32 391 32L121 32zm0 64l270 0 48 192-51.2 0c-12.1 0-23.2 6.8-28.6 17.7l-14.3 28.6c-5.4 10.8-16.5 17.7-28.6 17.7l-120.4 0c-12.1 0-23.2-6.8-28.6-17.7l-14.3-28.6c-5.4-10.8-16.5-17.7-28.6-17.7L73 288 121 96z"],Mail:[512,512,[],"solid","M48 64C21.5 64 0 85.5 0 112c0 15.1 7.1 29.3 19.2 38.4L236.8 313.6c11.4 8.5 27 8.5 38.4 0L492.8 150.4c12.1-9.1 19.2-23.3 19.2-38.4c0-26.5-21.5-48-48-48L48 64zM0 176L0 384c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-208L294.4 339.2c-22.8 17.1-54 17.1-76.8 0L0 176z"],MailOpen:[512,512,[],"solid","M64 208.1L256 65.9 448 208.1l0 47.4L289.5 373c-9.7 7.2-21.4 11-33.5 11s-23.8-3.9-33.5-11L64 255.5l0-47.4zM256 0c-12.1 0-23.8 3.9-33.5 11L25.9 156.7C9.6 168.8 0 187.8 0 208.1L0 448c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-239.9c0-20.3-9.6-39.4-25.9-51.4L289.5 11C279.8 3.9 268.1 0 256 0z"],Mic:[384,512,[],"solid","M192 0C139 0 96 43 96 96l0 160c0 53 43 96 96 96s96-43 96-96l0-160c0-53-43-96-96-96zM64 216c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 89.1 66.2 162.7 152 174.4l0 33.6-48 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l72 0 72 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-48 0 0-33.6c85.8-11.7 152-85.3 152-174.4l0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 70.7-57.3 128-128 128s-128-57.3-128-128l0-40z"],MicOff:[640,512,[],"solid","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L472.1 344.7c15.2-26 23.9-56.3 23.9-88.7l0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 21.2-5.1 41.1-14.2 58.7L416 300.8 416 96c0-53-43-96-96-96s-96 43-96 96l0 54.3L38.8 5.1zM344 430.4c20.4-2.8 39.7-9.1 57.3-18.2l-43.1-33.9C346.1 382 333.3 384 320 384c-70.7 0-128-57.3-128-128l0-8.7L144.7 210c-.5 1.9-.7 3.9-.7 6l0 40c0 89.1 66.2 162.7 152 174.4l0 33.6-48 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l72 0 72 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-48 0 0-33.6z"],Link:[640,512,["Chain"],"solid","M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"],House:[576,512,[],"solid","M575.8 255.5c0 18-15 32.1-32 32.1l-32 0 .7 160.2c0 2.7-.2 5.4-.5 8.1l0 16.2c0 22.1-17.9 40-40 40l-16 0c-1.1 0-2.2 0-3.3-.1c-1.4 .1-2.8 .1-4.2 .1L416 512l-24 0c-22.1 0-40-17.9-40-40l0-24 0-64c0-17.7-14.3-32-32-32l-64 0c-17.7 0-32 14.3-32 32l0 64 0 24c0 22.1-17.9 40-40 40l-24 0-31.9 0c-1.5 0-3-.1-4.5-.2c-1.2 .1-2.4 .2-3.6 .2l-16 0c-22.1 0-40-17.9-40-40l0-112c0-.9 0-1.9 .1-2.8l0-69.7-32 0c-18 0-32-14-32-32.1c0-9 3-17 10-24L266.4 8c7-7 15-8 22-8s15 2 21 7L564.8 231.5c8 7 12 15 11 24z"],Gamepad:[640,512,[],"solid","M192 64C86 64 0 150 0 256S86 448 192 448l256 0c106 0 192-86 192-192s-86-192-192-192L192 64zM496 168a40 40 0 1 1 0 80 40 40 0 1 1 0-80zM392 304a40 40 0 1 1 80 0 40 40 0 1 1 -80 0zM168 200c0-13.3 10.7-24 24-24s24 10.7 24 24l0 32 32 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-32 0 0 32c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-32-32 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l32 0 0-32z"],Camera:[512,512,[],"solid","M149.1 64.8L138.7 96 64 96C28.7 96 0 124.7 0 160L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-256c0-35.3-28.7-64-64-64l-74.7 0L362.9 64.8C356.4 45.2 338.1 32 317.4 32L194.6 32c-20.7 0-39 13.2-45.5 32.8zM256 192a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"],Printer:[512,512,[],"solid","M128 0C92.7 0 64 28.7 64 64l0 96 64 0 0-96 226.7 0L384 93.3l0 66.7 64 0 0-66.7c0-17-6.7-33.3-18.7-45.3L400 18.7C388 6.7 371.7 0 354.7 0L128 0zM384 352l0 32 0 64-256 0 0-64 0-16 0-16 256 0zm64 32l32 0c17.7 0 32-14.3 32-32l0-96c0-35.3-28.7-64-64-64L64 192c-35.3 0-64 28.7-64 64l0 96c0 17.7 14.3 32 32 32l32 0 0 64c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-64zM432 248a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"],Server:[512,512,[],"solid","M64 32C28.7 32 0 60.7 0 96l0 64c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-64c0-35.3-28.7-64-64-64L64 32zm280 72a24 24 0 1 1 0 48 24 24 0 1 1 0-48zm48 24a24 24 0 1 1 48 0 24 24 0 1 1 -48 0zM64 288c-35.3 0-64 28.7-64 64l0 64c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-64c0-35.3-28.7-64-64-64L64 288zm280 72a24 24 0 1 1 0 48 24 24 0 1 1 0-48zm56 24a24 24 0 1 1 48 0 24 24 0 1 1 -48 0z"],Calendar:[448,512,[],"solid","M96 32l0 32L48 64C21.5 64 0 85.5 0 112l0 48 448 0 0-48c0-26.5-21.5-48-48-48l-48 0 0-32c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 32L160 64l0-32c0-17.7-14.3-32-32-32S96 14.3 96 32zM448 192L0 192 0 464c0 26.5 21.5 48 48 48l352 0c26.5 0 48-21.5 48-48l0-272z"],Pipette:[512,512,[],"solid","M341.6 29.2L240.1 130.8l-9.4-9.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-9.4-9.4L482.8 170.4c39-39 39-102.2 0-141.1s-102.2-39-141.1 0zM55.4 323.3c-15 15-23.4 35.4-23.4 56.6l0 42.4L5.4 462.2c-8.5 12.7-6.8 29.6 4 40.4s27.7 12.5 40.4 4L89.7 480l42.4 0c21.2 0 41.6-8.4 56.6-23.4L309.4 335.9l-45.3-45.3L143.4 411.3c-3 3-7.1 4.7-11.3 4.7L96 416l0-36.1c0-4.2 1.7-8.3 4.7-11.3L221.4 247.9l-45.3-45.3L55.4 323.3z"],Scroll:[576,512,[],"solid","M0 80l0 48c0 17.7 14.3 32 32 32l16 0 48 0 0-80c0-26.5-21.5-48-48-48S0 53.5 0 80zM112 32c10 13.4 16 30 16 48l0 304c0 35.3 28.7 64 64 64s64-28.7 64-64l0-5.3c0-32.4 26.3-58.7 58.7-58.7L480 320l0-192c0-53-43-96-96-96L112 32zM464 480c61.9 0 112-50.1 112-112c0-8.8-7.2-16-16-16l-245.3 0c-14.7 0-26.7 11.9-26.7 26.7l0 5.3c0 53-43 96-96 96l176 0 96 0z"],Smartphone:[384,512,[],"solid","M16 64C16 28.7 44.7 0 80 0L304 0c35.3 0 64 28.7 64 64l0 384c0 35.3-28.7 64-64 64L80 512c-35.3 0-64-28.7-64-64L16 64zM144 448c0 8.8 7.2 16 16 16l64 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-64 0c-8.8 0-16 7.2-16 16zM304 64L80 64l0 320 224 0 0-320z"],Settings:[512,512,[],"solid","M495.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4L83.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4C64.6 273.1 64 264.6 64 256s.6-17.1 1.7-25.4L22.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z"],Map:[576,512,[],"solid","M384 476.1L192 421.2l0-385.3L384 90.8l0 385.3zm32-1.2l0-386.5L543.1 37.5c15.8-6.3 32.9 5.3 32.9 22.3l0 334.8c0 9.8-6 18.6-15.1 22.3L416 474.8zM15.1 95.1L160 37.2l0 386.5L32.9 474.5C17.1 480.8 0 469.2 0 452.2L0 117.4c0-9.8 6-18.6 15.1-22.3z"],Folder:[512,512,[],"solid","M64 480H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H288c-10.1 0-19.6-4.7-25.6-12.8L243.2 57.6C231.1 41.5 212.1 32 192 32H64C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64z"],FolderOpen:[576,512,[],"solid","M384 480l48 0c11.4 0 21.9-6 27.6-15.9l112-192c5.8-9.9 5.8-22.1 .1-32.1S555.5 224 544 224l-400 0c-11.4 0-21.9 6-27.6 15.9L48 357.1 48 96c0-8.8 7.2-16 16-16l117.5 0c4.2 0 8.3 1.7 11.3 4.7l26.5 26.5c21 21 49.5 32.8 79.2 32.8L416 144c8.8 0 16 7.2 16 16l0 32 48 0 0-32c0-35.3-28.7-64-64-64L298.5 96c-17 0-33.3-6.7-45.3-18.7L226.7 50.7c-12-12-28.3-18.7-45.3-18.7L64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l23.7 0L384 480z"],FolderClosed:[512,512,[],"solid","M448 480L64 480c-35.3 0-64-28.7-64-64L0 192l512 0 0 224c0 35.3-28.7 64-64 64zm64-320L0 160 0 96C0 60.7 28.7 32 64 32l128 0c20.1 0 39.1 9.5 51.2 25.6l19.2 25.6c6 8.1 15.5 12.8 25.6 12.8l160 0c35.3 0 64 28.7 64 64z"],Function:[384,512,[],"solid","M314.7 32c-38.8 0-73.7 23.3-88.6 59.1L170.7 224 64 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l80 0L98.9 396.3c-5 11.9-16.6 19.7-29.5 19.7L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l37.3 0c38.8 0 73.7-23.3 88.6-59.1L213.3 288 320 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-80 0 45.1-108.3c5-11.9 16.6-19.7 29.5-19.7L352 96c17.7 0 32-14.3 32-32s-14.3-32-32-32l-37.3 0z"],Stop:[384,512,[],"solid","M0 128C0 92.7 28.7 64 64 64H320c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V128z"],Image:[512,512,[],"solid","M448 80c8.8 0 16 7.2 16 16l0 319.8-5-6.5-136-176c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3L202 340.7l-30.5-42.7C167 291.7 159.8 288 152 288s-15 3.7-19.5 10.1l-80 112L48 416.3l0-.3L48 96c0-8.8 7.2-16 16-16l384 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm80 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"],Images:[576,512,[],"solid","M160 80l352 0c8.8 0 16 7.2 16 16l0 224c0 8.8-7.2 16-16 16l-21.2 0L388.1 178.9c-4.4-6.8-12-10.9-20.1-10.9s-15.7 4.1-20.1 10.9l-52.2 79.8-12.4-16.9c-4.5-6.2-11.7-9.8-19.4-9.8s-14.8 3.6-19.4 9.8L175.6 336 160 336c-8.8 0-16-7.2-16-16l0-224c0-8.8 7.2-16 16-16zM96 96l0 224c0 35.3 28.7 64 64 64l352 0c35.3 0 64-28.7 64-64l0-224c0-35.3-28.7-64-64-64L160 32c-35.3 0-64 28.7-64 64zM48 120c0-13.3-10.7-24-24-24S0 106.7 0 120L0 344c0 75.1 60.9 136 136 136l320 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-320 0c-48.6 0-88-39.4-88-88l0-224zm208 24a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"],Info:[512,512,[],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"],Bone:[576,512,[],"solid","M153.7 144.8c6.9 16.3 20.6 31.2 38.3 31.2l192 0c17.7 0 31.4-14.9 38.3-31.2C434.4 116.1 462.9 96 496 96c44.2 0 80 35.8 80 80c0 30.4-17 56.9-42 70.4c-3.6 1.9-6 5.5-6 9.6s2.4 7.7 6 9.6c25 13.5 42 40 42 70.4c0 44.2-35.8 80-80 80c-33.1 0-61.6-20.1-73.7-48.8C415.4 350.9 401.7 336 384 336l-192 0c-17.7 0-31.4 14.9-38.3 31.2C141.6 395.9 113.1 416 80 416c-44.2 0-80-35.8-80-80c0-30.4 17-56.9 42-70.4c3.6-1.9 6-5.5 6-9.6s-2.4-7.7-6-9.6C17 232.9 0 206.4 0 176c0-44.2 35.8-80 80-80c33.1 0 61.6 20.1 73.7 48.8z"],Puzzle:[512,512,[],"solid","M192 104.8c0-9.2-5.8-17.3-13.2-22.8C167.2 73.3 160 61.3 160 48c0-26.5 28.7-48 64-48s64 21.5 64 48c0 13.3-7.2 25.3-18.8 34c-7.4 5.5-13.2 13.6-13.2 22.8c0 12.8 10.4 23.2 23.2 23.2l56.8 0c26.5 0 48 21.5 48 48l0 56.8c0 12.8 10.4 23.2 23.2 23.2c9.2 0 17.3-5.8 22.8-13.2c8.7-11.6 20.7-18.8 34-18.8c26.5 0 48 28.7 48 64s-21.5 64-48 64c-13.3 0-25.3-7.2-34-18.8c-5.5-7.4-13.6-13.2-22.8-13.2c-12.8 0-23.2 10.4-23.2 23.2L384 464c0 26.5-21.5 48-48 48l-56.8 0c-12.8 0-23.2-10.4-23.2-23.2c0-9.2 5.8-17.3 13.2-22.8c11.6-8.7 18.8-20.7 18.8-34c0-26.5-28.7-48-64-48s-64 21.5-64 48c0 13.3 7.2 25.3 18.8 34c7.4 5.5 13.2 13.6 13.2 22.8c0 12.8-10.4 23.2-23.2 23.2L48 512c-26.5 0-48-21.5-48-48L0 343.2C0 330.4 10.4 320 23.2 320c9.2 0 17.3 5.8 22.8 13.2C54.7 344.8 66.7 352 80 352c26.5 0 48-28.7 48-64s-21.5-64-48-64c-13.3 0-25.3 7.2-34 18.8C40.5 250.2 32.4 256 23.2 256C10.4 256 0 245.6 0 232.8L0 176c0-26.5 21.5-48 48-48l120.8 0c12.8 0 23.2-10.4 23.2-23.2z"],Lock:[448,512,[],"solid","M144 144l0 48 160 0 0-48c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192l0-48C80 64.5 144.5 0 224 0s144 64.5 144 144l0 48 16 0c35.3 0 64 28.7 64 64l0 192c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 256c0-35.3 28.7-64 64-64l16 0z"],LockOpen:[576,512,[],"solid","M352 144c0-44.2 35.8-80 80-80s80 35.8 80 80l0 48c0 17.7 14.3 32 32 32s32-14.3 32-32l0-48C576 64.5 511.5 0 432 0S288 64.5 288 144l0 48L64 192c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l320 0c35.3 0 64-28.7 64-64l0-192c0-35.3-28.7-64-64-64l-32 0 0-48z"],Shuffle:[512,512,[],"solid","M403.8 34.4c12-5 25.7-2.2 34.9 6.9l64 64c6 6 9.4 14.1 9.4 22.6s-3.4 16.6-9.4 22.6l-64 64c-9.2 9.2-22.9 11.9-34.9 6.9s-19.8-16.6-19.8-29.6l0-32-32 0c-10.1 0-19.6 4.7-25.6 12.8L284 229.3 244 176l31.2-41.6C293.3 110.2 321.8 96 352 96l32 0 0-32c0-12.9 7.8-24.6 19.8-29.6zM164 282.7L204 336l-31.2 41.6C154.7 401.8 126.2 416 96 416l-64 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l64 0c10.1 0 19.6-4.7 25.6-12.8L164 282.7zm274.6 188c-9.2 9.2-22.9 11.9-34.9 6.9s-19.8-16.6-19.8-29.6l0-32-32 0c-30.2 0-58.7-14.2-76.8-38.4L121.6 172.8c-6-8.1-15.5-12.8-25.6-12.8l-64 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l64 0c30.2 0 58.7 14.2 76.8 38.4L326.4 339.2c6 8.1 15.5 12.8 25.6 12.8l32 0 0-32c0-12.9 7.8-24.6 19.8-29.6s25.7-2.2 34.9 6.9l64 64c6 6 9.4 14.1 9.4 22.6s-3.4 16.6-9.4 22.6l-64 64z"],Play:[384,512,[],"solid","M73 39c-14.8-9.1-33.4-9.4-48.5-.9S0 62.6 0 80L0 432c0 17.4 9.4 33.4 24.5 41.9s33.7 8.1 48.5-.9L361 297c14.3-8.7 23-24.2 23-41s-8.7-32.2-23-41L73 39z"],Pause:[320,512,[],"solid","M48 64C21.5 64 0 85.5 0 112L0 400c0 26.5 21.5 48 48 48l32 0c26.5 0 48-21.5 48-48l0-288c0-26.5-21.5-48-48-48L48 64zm192 0c-26.5 0-48 21.5-48 48l0 288c0 26.5 21.5 48 48 48l32 0c26.5 0 48-21.5 48-48l0-288c0-26.5-21.5-48-48-48l-32 0z"],LogIn:[512,512,[],"solid","M352 96l64 0c17.7 0 32 14.3 32 32l0 256c0 17.7-14.3 32-32 32l-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0c53 0 96-43 96-96l0-256c0-53-43-96-96-96l-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32zm-9.4 182.6c12.5-12.5 12.5-32.8 0-45.3l-128-128c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L242.7 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l210.7 0-73.4 73.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l128-128z"],LogOut:[512,512,[],"solid","M502.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-128-128c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L402.7 224 192 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l210.7 0-73.4 73.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l128-128zM160 96c17.7 0 32-14.3 32-32s-14.3-32-32-32L96 32C43 32 0 75 0 128L0 384c0 53 43 96 96 96l64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-64 0c-17.7 0-32-14.3-32-32l0-256c0-17.7 14.3-32 32-32l64 0z"],MousePointer:[320,512,[],"solid","M0 55.2L0 426c0 12.2 9.9 22 22 22c6.3 0 12.4-2.7 16.6-7.5L121.2 346l58.1 116.3c7.9 15.8 27.1 22.2 42.9 14.3s22.2-27.1 14.3-42.9L179.8 320l118.1 0c12.2 0 22.1-9.9 22.1-22.1c0-6.3-2.7-12.3-7.4-16.5L38.6 37.9C34.3 34.1 28.9 32 23.2 32C10.4 32 0 42.4 0 55.2z"],User:[512,512,[],"solid","M256 288A144 144 0 1 0 256 0a144 144 0 1 0 0 288zm-94.7 32C72.2 320 0 392.2 0 481.3c0 17 13.8 30.7 30.7 30.7l450.6 0c17 0 30.7-13.8 30.7-30.7C512 392.2 439.8 320 350.7 320l-189.4 0z"],HardDriveDownload:[512,512,[],"solid","M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 242.7-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7 288 32zM64 352c-35.3 0-64 28.7-64 64l0 32c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-32c0-35.3-28.7-64-64-64l-101.5 0-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352 64 352zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"],HardDriveUpload:[512,512,[],"solid","M288 109.3L288 352c0 17.7-14.3 32-32 32s-32-14.3-32-32l0-242.7-73.4 73.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l128-128c12.5-12.5 32.8-12.5 45.3 0l128 128c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L288 109.3zM64 352l128 0c0 35.3 28.7 64 64 64s64-28.7 64-64l128 0c35.3 0 64 28.7 64 64l0 32c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64l0-32c0-35.3 28.7-64 64-64zM432 456a24 24 0 1 0 0-48 24 24 0 1 0 0 48z"],CircleCheck:[512,512,["CheckCircle2"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"],CirclePlay:[512,512,[],"solid","M0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zM188.3 147.1c-7.6 4.2-12.3 12.3-12.3 20.9l0 176c0 8.7 4.7 16.7 12.3 20.9s16.8 4.1 24.3-.5l144-88c7.1-4.4 11.5-12.1 11.5-20.5s-4.4-16.1-11.5-20.5l-144-88c-7.4-4.5-16.7-4.7-24.3-.5z"],CirclePause:[512,512,[],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM224 192l0 128c0 17.7-14.3 32-32 32s-32-14.3-32-32l0-128c0-17.7 14.3-32 32-32s32 14.3 32 32zm128 0l0 128c0 17.7-14.3 32-32 32s-32-14.3-32-32l0-128c0-17.7 14.3-32 32-32s32 14.3 32 32z"],CirclePlus:[512,512,["PlusCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM232 344l0-64-64 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l64 0 0-64c0-13.3 10.7-24 24-24s24 10.7 24 24l0 64 64 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-64 0 0 64c0 13.3-10.7 24-24 24s-24-10.7-24-24z"],CircleMinus:[512,512,["MinusCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM184 232l144 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-144 0c-13.3 0-24-10.7-24-24s10.7-24 24-24z"],CircleStop:[512,512,[],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM192 160l128 0c17.7 0 32 14.3 32 32l0 128c0 17.7-14.3 32-32 32l-128 0c-17.7 0-32-14.3-32-32l0-128c0-17.7 14.3-32 32-32z"],CircleDot:[512,512,[],"solid","M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256-96a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"],CircleHelp:[512,512,["HelpCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM169.8 165.3c7.9-22.3 29.1-37.3 52.8-37.3l58.3 0c34.9 0 63.1 28.3 63.1 63.1c0 22.6-12.1 43.5-31.7 54.8L280 264.4c-.2 13-10.9 23.6-24 23.6c-13.3 0-24-10.7-24-24l0-13.5c0-8.6 4.6-16.5 12.1-20.8l44.3-25.4c4.7-2.7 7.6-7.7 7.6-13.1c0-8.4-6.8-15.1-15.1-15.1l-58.3 0c-3.4 0-6.4 2.1-7.5 5.3l-.4 1.2c-4.4 12.5-18.2 19-30.6 14.6s-19-18.2-14.6-30.6l.4-1.2zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"],CircleArrowUp:[512,512,["ArrowUpCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM385 215c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-71-71L280 392c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-214.1-71 71c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9L239 103c9.4-9.4 24.6-9.4 33.9 0L385 215z"],CircleArrowDown:[512,512,["ArrowDownCircle"],"solid","M256 0a256 256 0 1 0 0 512A256 256 0 1 0 256 0zM127 297c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l71 71L232 120c0-13.3 10.7-24 24-24s24 10.7 24 24l0 214.1 71-71c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L273 409c-9.4 9.4-24.6 9.4-33.9 0L127 297z"],CircleArrowLeft:[512,512,["ArrowLeftCircle"],"solid","M512 256A256 256 0 1 0 0 256a256 256 0 1 0 512 0zM215 127c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-71 71L392 232c13.3 0 24 10.7 24 24s-10.7 24-24 24l-214.1 0 71 71c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L103 273c-9.4-9.4-9.4-24.6 0-33.9L215 127z"],CircleArrowRight:[512,512,["ArrowRightCircle"],"solid","M0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zM297 385c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l71-71L120 280c-13.3 0-24-10.7-24-24s10.7-24 24-24l214.1 0-71-71c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0L409 239c9.4 9.4 9.4 24.6 0 33.9L297 385z"],CircleAlert:[512,512,["AlertCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"],CircleUser:[512,512,["UserCircle"],"solid","M399 384.2C376.9 345.8 335.4 320 288 320l-64 0c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"],CircleChevronRight:[512,512,["ChevronRightCircle"],"solid","M0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zM241 377c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l87-87-87-87c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0L345 239c9.4 9.4 9.4 24.6 0 33.9L241 377z"],CircleChevronDown:[512,512,["ChevronDownCircle"],"solid","M256 0a256 256 0 1 0 0 512A256 256 0 1 0 256 0zM135 241c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l87 87 87-87c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L273 345c-9.4 9.4-24.6 9.4-33.9 0L135 241z"],CircleChevronUp:[512,512,["ChevronUpCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM377 271c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-87-87-87 87c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9L239 167c9.4-9.4 24.6-9.4 33.9 0L377 271z"],CircleChevronLeft:[512,512,["ChevronLeftCircle"],"solid","M512 256A256 256 0 1 0 0 256a256 256 0 1 0 512 0zM271 135c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-87 87 87 87c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L167 273c-9.4-9.4-9.4-24.6 0-33.9L271 135z"],CircleX:[512,512,["XCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"],Apple:[384,512,[],"solid","M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"],Chrome:[512,512,[],"solid","M0 256C0 209.4 12.47 165.6 34.27 127.1L144.1 318.3C166 357.5 207.9 384 256 384C270.3 384 283.1 381.7 296.8 377.4L220.5 509.6C95.9 492.3 0 385.3 0 256zM365.1 321.6C377.4 302.4 384 279.1 384 256C384 217.8 367.2 183.5 340.7 160H493.4C505.4 189.6 512 222.1 512 256C512 397.4 397.4 511.1 256 512L365.1 321.6zM477.8 128H256C193.1 128 142.3 172.1 130.5 230.7L54.19 98.47C101 38.53 174 0 256 0C350.8 0 433.5 51.48 477.8 128V128zM168 256C168 207.4 207.4 168 256 168C304.6 168 344 207.4 344 256C344 304.6 304.6 344 256 344C207.4 344 168 304.6 168 256z"],Facebook:[512,512,[],"solid","M512 256C512 114.6 397.4 0 256 0S0 114.6 0 256C0 376 82.7 476.8 194.2 504.5V334.2H141.4V256h52.8V222.3c0-87.1 39.4-127.5 125-127.5c16.2 0 44.2 3.2 55.7 6.4V172c-6-.6-16.5-1-29.6-1c-42 0-58.2 15.9-58.2 57.2V256h83.6l-14.4 78.2H287V510.1C413.8 494.8 512 386.9 512 256h0z"],Github:[496,512,[],"solid","M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"],Youtube:[576,512,[],"solid","M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z"],"CircleRight@solid":[512,512,[],"solid","M0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zm395.3 11.3l-112 112c-4.6 4.6-11.5 5.9-17.4 3.5s-9.9-8.3-9.9-14.8l0-64-96 0c-17.7 0-32-14.3-32-32l0-32c0-17.7 14.3-32 32-32l96 0 0-64c0-6.5 3.9-12.3 9.9-14.8s12.9-1.1 17.4 3.5l112 112c6.2 6.2 6.2 16.4 0 22.6z"],"CircleUp@solid":[512,512,[],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm11.3-395.3l112 112c4.6 4.6 5.9 11.5 3.5 17.4s-8.3 9.9-14.8 9.9l-64 0 0 96c0 17.7-14.3 32-32 32l-32 0c-17.7 0-32-14.3-32-32l0-96-64 0c-6.5 0-12.3-3.9-14.8-9.9s-1.1-12.9 3.5-17.4l112-112c6.2-6.2 16.4-6.2 22.6 0z"],"CircleLeft@solid":[512,512,[],"solid","M512 256A256 256 0 1 0 0 256a256 256 0 1 0 512 0zM116.7 244.7l112-112c4.6-4.6 11.5-5.9 17.4-3.5s9.9 8.3 9.9 14.8l0 64 96 0c17.7 0 32 14.3 32 32l0 32c0 17.7-14.3 32-32 32l-96 0 0 64c0 6.5-3.9 12.3-9.9 14.8s-12.9 1.1-17.4-3.5l-112-112c-6.2-6.2-6.2-16.4 0-22.6z"],"CircleDown@solid":[512,512,[],"solid","M256 0a256 256 0 1 0 0 512A256 256 0 1 0 256 0zM244.7 395.3l-112-112c-4.6-4.6-5.9-11.5-3.5-17.4s8.3-9.9 14.8-9.9l64 0 0-96c0-17.7 14.3-32 32-32l32 0c17.7 0 32 14.3 32 32l0 96 64 0c6.5 0 12.3 3.9 14.8 9.9s1.1 12.9-3.5 17.4l-112 112c-6.2 6.2-16.4 6.2-22.6 0z"],"PaperPlane@solid":[512,512,[],"solid","M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480l0-83.6c0-4 1.5-7.8 4.2-10.8L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"]};t.LucideIconAlias={Stop:"Square",Refresh:"RefreshCw",Left:"ChevronLeft",Right:"ChevronRight",Up:"ChevronUp",Down:"ChevronDown",MenuArrows:"ChevronsUpDown",RotateForward:"RotateCw",RotateRight:"RotateCw",RotateBack:"RotateCcw",RotateLeft:"RotateCcw"},t.ICONS=(()=>{const e={};for(let t in s){s[t][2].forEach(s=>e[s]=t)}return{...s,...e}})();let i=class{name;value;domEvent;constructor(e,t,s){this.name=e,this.value=t,this.domEvent=s}};t.IEvent=i;class o{static NONE=0;static NODE_SELECTED=1;static NODE_DELETED=2;static NODE_DBLCLICKED=3;static NODE_CONTEXTMENU=4;static NODE_DRAGGED=5;static NODE_RENAMED=6;static NODE_VISIBILITY=7;static NODE_CARETCHANGED=8;type=o.NONE;node;value;event;multiple=!1;panel=null;constructor(e,t,s,i){this.type=e||o.NONE,this.node=t,this.value=s,this.event=i}string(){switch(this.type){case o.NONE:return"tree_event_none";case o.NODE_SELECTED:return"tree_event_selected";case o.NODE_DELETED:return"tree_event_deleted";case o.NODE_DBLCLICKED:return"tree_event_dblclick";case o.NODE_CONTEXTMENU:return"tree_event_contextmenu";case o.NODE_DRAGGED:return"tree_event_dragged";case o.NODE_RENAMED:return"tree_event_renamed";case o.NODE_VISIBILITY:return"tree_event_visibility";case o.NODE_CARETCHANGED:return"tree_event_caretchanged"}}}var n;t.TreeEvent=o,function(e){e[e.NONE=0]="NONE",e[e.TEXT=1]="TEXT",e[e.TEXTAREA=2]="TEXTAREA",e[e.BUTTON=3]="BUTTON",e[e.SELECT=4]="SELECT",e[e.CHECKBOX=5]="CHECKBOX",e[e.TOGGLE=6]="TOGGLE",e[e.RADIO=7]="RADIO",e[e.BUTTONS=8]="BUTTONS",e[e.COLOR=9]="COLOR",e[e.RANGE=10]="RANGE",e[e.NUMBER=11]="NUMBER",e[e.TITLE=12]="TITLE",e[e.VECTOR=13]="VECTOR",e[e.TREE=14]="TREE",e[e.PROGRESS=15]="PROGRESS",e[e.FILE=16]="FILE",e[e.LAYERS=17]="LAYERS",e[e.ARRAY=18]="ARRAY",e[e.LIST=19]="LIST",e[e.TAGS=20]="TAGS",e[e.CURVE=21]="CURVE",e[e.CARD=22]="CARD",e[e.IMAGE=23]="IMAGE",e[e.CONTENT=24]="CONTENT",e[e.CUSTOM=25]="CUSTOM",e[e.SEPARATOR=26]="SEPARATOR",e[e.KNOB=27]="KNOB",e[e.SIZE=28]="SIZE",e[e.OTP=29]="OTP",e[e.PAD=30]="PAD",e[e.FORM=31]="FORM",e[e.DIAL=32]="DIAL",e[e.COUNTER=33]="COUNTER",e[e.TABLE=34]="TABLE",e[e.TABS=35]="TABS",e[e.DATE=36]="DATE",e[e.MAP2D=37]="MAP2D",e[e.LABEL=39]="LABEL",e[e.BLANK=40]="BLANK",e[e.RATE=41]="RATE"}(n||(n={})),t.ComponentType=n;let a=class e{type;name;customName;options;root;customIdx=-1;disabled=!1;onSetValue;onGetValue;onAllowPaste;onResize;_initialValue;static NO_CONTEXT_TYPES=[n.BUTTON,n.LIST,n.FILE,n.PROGRESS];constructor(e,s,i,o={}){this.type=e,this.name=s,this.options=o,this._initialValue=i;const a=document.createElement("div");if(a.className="lexcomponent",this.onResize=()=>{},o.id&&(a.id=o.id),o.title&&(a.title=o.title),o.className&&(a.className+=" "+o.className),e!=n.TITLE&&(o.width&&(a.style.width=a.style.minWidth=o.width),o.maxWidth&&(a.style.maxWidth=o.maxWidth),o.minWidth&&(a.style.minWidth=o.minWidth),o.height&&(a.style.height=a.style.minHeight=o.height),t.componentResizeObserver.observe(a)),null!=s){if(!o.hideName){let e=document.createElement("div");e.className="lexcomponentname",o.justifyName&&e.classList.add("float-"+o.justifyName),e.innerHTML=s,e.title=o.title??e.innerHTML,e.style.width=o.nameWidth||t.DEFAULT_NAME_WIDTH,e.style.minWidth=e.style.width,a.appendChild(e),a.domName=e;const n=this;e.addEventListener("contextmenu",function(e){e.preventDefault(),n.oncontextmenu(e)}),o.skipReset||null==i||this._addResetProperty(e,function(e,t){n.set(n._initialValue,!1,t),e.style.display="none"})}}else o.hideName=!0;o.signal&&t.addSignal(o.signal,this),this.root=a,this.root.jsInstance=this,this.options=o}static _dispatchEvent(e,t,s,i,o){let n=new CustomEvent(t,{detail:s,bubbles:i,cancelable:o});e.dispatchEvent(n)}_addResetProperty(e,s){const i=t.makeIcon("Undo2",{iconClass:"ml-0 mr-1 px-1",title:"Reset"});return i.style.display="none",i.addEventListener("click",s.bind(i,i)),e.appendChild(i),i}_canPaste(){const e=navigator.clipboard;let t=this.type===n.CUSTOM?void 0!==e.customIdx&&this.customIdx==e.customIdx:e.type===this.type;return t=t&&!0!==this.disabled,this.onAllowPaste&&(t=this.onAllowPaste(t)),t}_trigger(e,t,s=this){t&&t.call(s,e.value,e.domEvent,e.name)}value(){if(this.onGetValue)return this.onGetValue();console.warn("Can't get value of "+this.typeName())}set(e,t,s){if(this.onSetValue){let i=this.root.querySelector(".lexcomponentname .lexicon");if(i){i.style.display=e!=this.value()?"block":"none";const t=e.constructor===Array?function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var s=0;s<e.length;++s)if(e[s]!==t[s])return!1;return!0}(e,this._initialValue):e==this._initialValue;i.style.display=t?"none":"block"}return this.onSetValue(e,t??!1,s)}console.warn(`Can't set value of ${this.typeName()}`)}oncontextmenu(s){e.NO_CONTEXT_TYPES.includes(this.type)||t.addContextMenu(this.typeName(),s,e=>{e.add("Copy",()=>{this.copy()}),e.add("Paste",{disabled:!this._canPaste(),callback:()=>{this.paste()}})})}copy(){const e=navigator.clipboard;e.type=this.type,e.customIdx=this.customIdx,e.data=this.value(),e.writeText(e.data)}paste(){if(!this._canPaste())return;const e=navigator.clipboard;this.set(e.data)}typeName(){switch(this.type){case n.TEXT:return"Text";case n.TEXTAREA:return"TextArea";case n.BUTTON:return"Button";case n.SELECT:return"Select";case n.CHECKBOX:return"Checkbox";case n.TOGGLE:return"Toggle";case n.RADIO:return"Radio";case n.COLOR:return"Color";case n.RANGE:return"Range";case n.NUMBER:return"Number";case n.VECTOR:return"Vector";case n.TREE:return"Tree";case n.PROGRESS:return"Progress";case n.FILE:return"File";case n.LAYERS:return"Layers";case n.ARRAY:return"Array";case n.LIST:return"List";case n.TAGS:return"Tags";case n.CURVE:return"Curve";case n.KNOB:return"Knob";case n.SIZE:return"Size";case n.PAD:return"Pad";case n.FORM:return"Form";case n.DIAL:return"Dial";case n.COUNTER:return"Counter";case n.TABLE:return"Table";case n.TABS:return"Tabs";case n.DATE:return"Date";case n.MAP2D:return"Map2D";case n.RATE:return"Rate";case n.LABEL:return"Label";case n.BLANK:return"Blank";case n.CUSTOM:return this.customName}console.error(`Unknown Component type: ${this.type}`)}refresh(e){}};t.BaseComponent=a;class l extends a{selectable=!1;callback;setState;swap;constructor(e,s,o,a={}){super(n.BUTTON,e,null,a),this.callback=o,this.selectable=a.selectable??this.selectable,this.onGetValue=()=>{const e=t.hasClass(l,"selected"),i=l.querySelector("input");return i?i.checked:this.selectable?e:s},this.onSetValue=(e,s,i)=>{if(a.swap)this.setState(e,s);else if(l.innerHTML="",a.icon){const e=t.makeIcon(a.icon);l.prepend(e)}else if(a.img){let e=document.createElement("img");e.src=a.img,l.prepend(e)}else l.innerHTML=`<span>${e??""}</span>`},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`},this.setState=function(t,n){const r=l.querySelector("input");r?r.checked=t:this.selectable&&(a.parent&&a.parent.querySelectorAll(".lexbutton.selected").forEach(e=>{e!=l&&e.classList.remove("selected")}),l.classList.toggle("selected",t)),n||this._trigger(new i(e,r?r.checked:this.selectable?t:s,null),o)};var l=document.createElement("button");if(l.title=a.tooltip?"":a.title??"",l.className="lexbutton px-3 "+(a.buttonClass??""),this.root.appendChild(l),a.selected&&l.classList.add("selected"),a.img){let e=document.createElement("img");e.src=a.img,l.prepend(e)}else if(a.icon){const e=t.makeIcon(a.icon,{iconClass:a.iconClass,svgClass:a.svgClass}),i=a.iconPosition??"cover";"cover"==i||void 0!==a.swap?l.prepend(e):(l.innerHTML=`<span>${s||""}</span>`,"start"==i?l.querySelector("span").prepend(e):l.querySelector("span").appendChild(e)),l.classList.add("justify-center")}else l.innerHTML=`<span>${s||""}</span>`;if(a.fileInput){const e=document.createElement("input");e.type="file",e.className="file-input",e.style.display="none",l.appendChild(e),e.addEventListener("change",function(e){if(!e.target)return;const t=e.target.files;if(!t.length)return;const s=new FileReader;"text"===a.fileInputType?s.readAsText(t[0]):"buffer"===a.fileInputType?s.readAsArrayBuffer(t[0]):"bin"===a.fileInputType?s.readAsBinaryString(t[0]):"url"===a.fileInputType&&s.readAsDataURL(t[0]),s.onload=e=>{o.call(this,e.target?.result,t[0])}})}a.disabled&&(this.disabled=!0,l.setAttribute("disabled",!0));let r=l;if(a.swap){l.classList.add("swap"),l.querySelector("a").classList.add("swap-off");const e=document.createElement("input");e.className="p-0 border-0",e.type="checkbox",l.prepend(e);const s=t.makeIcon(a.swap,{iconClass:"swap-on"});l.appendChild(s),this.swap=function(e){const t=l.querySelector("input");t.checked=!t.checked,e||r.click()}}r.addEventListener("click",n=>{let r;if(this.selectable&&(a.parent&&a.parent.querySelectorAll(".lexbutton.selected").forEach(e=>{e!=l&&e.classList.remove("selected")}),r=l.classList.toggle("selected")),a.fileInput)l.querySelector(".file-input").click();else if(a.mustConfirm){const r=l.querySelector("input");new t.PopConfirm(l,{onConfirm:()=>{a.swap&&(r.checked=!0),this._trigger(new i(e,s,n),o)},side:a.confirmSide,align:a.confirmAlign,confirmText:a.confirmText,cancelText:a.confirmCancelText,title:a.confirmTitle,content:a.confirmContent}),a.swap&&(r.checked=!1)}else{const t=l.querySelector("input");this._trigger(new i(e,t?.checked??(this.selectable?r:s),n),o)}}),a.tooltip&&t.asTooltip(l,a.title??e),t.doAsync(this.onResize.bind(this))}click(){this.root.querySelector("button").click()}setSwapIcon(e){const s=this.root.querySelector(".swap-on");if(!s)return;const i=t.makeIcon(e,{iconClass:"swap-on"});s.replaceWith(i)}}t.Button=l;class r{root;siblingArea;buttonContainer;items=[];buttons={};icons={};shorts={};focused=!1;_currentDropdown;constructor(e,t={}){this.root=document.createElement("div"),this.root.className="lexmenubar",t.float&&(this.root.style.justifyContent=t.float),this.items=e??[],this.createEntries()}_resetMenubar(e){this.root.querySelectorAll(".lexmenuentry").forEach(e=>{e.classList.remove("selected"),delete e.dataset.built}),this._currentDropdown&&(this._currentDropdown.destroy(),this._currentDropdown=null),this.focused=e??!1}createEntries(){for(let e of this.items){let s=e.name,i=t.getSupportedDOMName(s);if(this.root.querySelector("#"+i))continue;let o=document.createElement("div");o.className="lexmenuentry",o.id=i,o.innerHTML="<span>"+s+"</span>",o.tabIndex=1,this.root.appendChild(o);const n=()=>{this._resetMenubar(!0),o.classList.add("selected"),o.dataset.built="true",this._currentDropdown=t.addDropdownMenu(o,e.submenu??[],{side:"bottom",align:"start",onBlur:()=>{this._resetMenubar()}})};o.addEventListener("mousedown",e=>{e.preventDefault()}),o.addEventListener("mouseup",t=>{t.preventDefault();const i=e.callback;if(!i)return n(),this.focused=!0,!1;i.call(this,s,o,t)}),o.addEventListener("mouseover",e=>{this.focused&&!o.dataset.built&&n()})}}getButton(e){return this.buttons[e]}getSubitem(e,t){for(const s of e)if(s?.name==t[0]){if(1==t.length)return s;if(s.submenu)return t.shift(),this.getSubitem(s.submenu,t)}}getItem(e){const t=e.split("/");return this.getSubitem(this.items,t)}setButtonIcon(e,s,i,o={}){if(!e)throw"Set Button Name!";let n=this.buttons[e];n&&(delete this.buttons[e],t.deleteElement(n.root)),n=new l(e,void 0,i,{title:e,buttonClass:"lexmenubutton main bg-none",disabled:o.disabled,icon:s,svgClass:"xl",hideName:!0,swap:o.swap}),"right"==o.float&&(n.root.right=!0),this.root.lastChild&&this.root.lastChild.right?this.root.lastChild.before(n.root):"left"==o.float?this.root.prepend(n.root):this.root.appendChild(n.root),this.buttons[e]=n}setButtonImage(e,t,s,i={}){if(!e)throw"Set Button Name!";let o=this.buttons[e];if(o)return void(o.querySelector("img").src=t);o=document.createElement("div");const n=i.disabled??!1;o.className="lexmenubutton main"+(n?" disabled":""),o.title=e,o.innerHTML="<a><image src='"+t+"' class='lexicon' style='height:32px;'></a>","right"==i.float&&(o.right=!0),this.root.lastChild&&this.root.lastChild.right?this.root.lastChild.before(o):"left"==i.float?this.root.prepend(o):this.root.appendChild(o);const a=o.querySelector("a");a.addEventListener("mousedown",e=>{e.preventDefault()}),a.addEventListener("mouseup",e=>{s&&!n&&s.call(this,a,e)}),this.buttons[e]=o}addButtons(e,t={}){if(!e)throw"No buttons to add!";this.buttonContainer||(this.buttonContainer=document.createElement("div"),this.buttonContainer.className="lexmenubuttons",this.buttonContainer.classList.add(t.float??"center"),"right"==t.float&&(this.buttonContainer.right=!0),this.root.lastChild&&this.root.lastChild.right?this.root.lastChild.before(this.buttonContainer):this.root.appendChild(this.buttonContainer));for(const t of e){const e=t.title,s=new l(e,t.label,t.callback,{title:e,buttonClass:"bg-none",disabled:t.disabled,icon:t.icon,hideName:!0,swap:t.swap,iconPosition:"start"});this.buttonContainer.appendChild(s.root),e&&(this.buttons[e]=s)}}}class c{static TAB_ID=0;root;area;tabs={};tabDOMs={};thumb;selected=null;folding=!1;folded=!1;onclose;constructor(e,s={}){this.onclose=s.onclose;let i=document.createElement("div");i.className="lexareatabs "+(s.fit?"fit":"row");const o=s.folding??!1;o&&i.classList.add("folding");let n=this;i.addEventListener("dragenter",function(e){e.preventDefault(),this.classList.add("dockingtab")}),i.addEventListener("dragleave",function(e){e.preventDefault(),this.contains(e.relatedTarget)||this.classList.remove("dockingtab")}),i.addEventListener("drop",function(e){e.preventDefault();const t=e.dataTransfer.getData("source"),s=document.getElementById(t);if(!s)return;const i=s.parentElement,o=e.target,a=o.getBoundingClientRect();e.offsetX<.5*a.width?this.insertBefore(s,o):o.nextElementSibling?this.insertBefore(s,o.nextElementSibling):this.appendChild(s);{i.childNodes.forEach((e,t)=>e.childIndex=t-1);const t=/true/.test(e.dataTransfer.getData("fit"));let s=null;if(i.childElementCount==(t?2:1))s=i.lastChild;else{s=i.querySelector(".selected")??i.childNodes[t?1:0]}s._forceSelect=!0,s.click()}this.childNodes.forEach((e,t)=>e.childIndex=t-1);const l=document.getElementById(t+"_content");n.area.attach(l),this.classList.remove("dockingtab"),s.instance=n,s._forceSelect=!0,s.click(),n.tabs[s.dataset.name]=l}),e.root.classList.add("lexareatabscontainer");const[a,l]=e.split({type:"vertical",sizes:s.sizes??"auto",resize:!1,top:2});if(a.attach(i),s.parentClass&&i.parentElement&&(i.parentElement.className+=` ${s.parentClass}`),this.area=l,this.area.root.className+=" lexareatabscontent",s.contentClass&&(this.area.root.className+=` ${s.contentClass}`),this.selected=null,this.root=i,s.fit){let e=document.createElement("span");e.className="lexareatab thumb",this.thumb=e,this.root.appendChild(e);new ResizeObserver(e=>{const s=this.thumb.item;if(s){var i=this.thumb.style.transition;this.thumb.style.transition="none",this.thumb.style.transform="translate( "+s.childIndex*s.offsetWidth+"px )",this.thumb.style.width=s.offsetWidth+"px",t.flushCss(this.thumb),this.thumb.style.transition=i}}).observe(this.area.root)}if(o){this.folded=!0,this.folding=o,"up"==o&&t.insertChildAtIndex(e.root,e.sections[1].root,0);new ResizeObserver(t=>{for(const s of t){const t=s.contentRect,i=e.parentArea?.sections[0].root;i.style.height="calc(100% - "+(42+t.height)+"px )"}}).observe(this.area.root),this.area.root.classList.add("folded")}}add(e,s,i={}){let o=i.selected??!1;if(o){this.root.querySelectorAll("span").forEach(e=>e.classList.remove("selected"));(this.area.root.querySelector(":scope > .pseudoparent-tabs")??this.area.root).querySelectorAll(":scope > .lextabcontent").forEach(e=>e.style.display="none")}o=!Object.keys(this.tabs).length&&!this.folding||o;let n=s.root?s.root:s;if(n.originalDisplay=n.style.display,n.style.display=o?n.originalDisplay:"none",n.classList.add("lextabcontent"),i.icon)if(i.icon.includes(".")){const e="https://raw.githubusercontent.com/jxarco/lexgui.js/master/";i.icon="<img src='"+(e+i.icon)+"'>"}else{const e=i.icon.split(" ");i.icon=t.makeIcon(e[0],{svgClass:"sm "+e.slice(0).join(" ")}).innerHTML}let a=document.createElement("span");if(a.dataset.name=e,a.className="lexareatab flex flex-row gap-1"+(o?" selected":""),a.innerHTML=(i.icon??"")+e,a.id=e.replace(/\s/g,"")+c.TAB_ID++,a.title=i.title??"",a.selected=o??!1,a.fixed=i.fixed,a.instance=this,n.id=a.id+"_content",i.badge){const e={};(i.badge.asChild??!1)&&(e.parent=a),a.innerHTML+=t.badge(i.badge.content??"",i.badge.className,e)}a.selected&&(this.selected=e),a.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation();const t=a.instance;if(!a.fixed){const e=a.selected;a.parentElement.querySelectorAll("span").forEach(e=>e.selected=!1),a.selected=!e||!!a._forceSelect,a.parentElement.querySelectorAll("span").forEach(e=>e.classList.remove("selected")),a.classList.toggle("selected",a.selected);(t.area.root.querySelector(":scope > .pseudoparent-tabs")??t.area.root).querySelectorAll(":scope > .lextabcontent").forEach(e=>e.style.display="none"),n.style.display=n.originalDisplay,t.selected=a.dataset.name}t.folding&&(t.folded=a.selected,t.area.root.classList.toggle("folded",!t.folded)),i.onSelect&&i.onSelect(e,a.dataset.name),t.thumb&&(t.thumb.style.transform="translate( "+a.childIndex*a.offsetWidth+"px )",t.thumb.style.width=a.offsetWidth+"px",t.thumb.item=a),delete a._forceSelect}),a.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation(),i.onContextMenu&&i.onContextMenu(e,a.dataset.name)}),i.allowDelete&&(a.addEventListener("mousedown",e=>{e.button==t.MOUSE_MIDDLE_CLICK&&e.preventDefault()}),a.addEventListener("mouseup",e=>{e.preventDefault(),e.stopPropagation(),e.button==t.MOUSE_MIDDLE_CLICK&&this.delete(a.dataset.name)})),a.setAttribute("draggable",!0),a.addEventListener("dragstart",e=>{const t=!!this.thumb;a.parentElement.childNodes.length!=(t?2:1)?(e.dataTransfer.setData("source",e.target.id),e.dataTransfer.setData("fit",t)):e.preventDefault()});const l=i.indexOffset??-1;a.childIndex=this.root.childElementCount+l,t.insertChildAtIndex(this.root,a,a.childIndex+1),this.area.attach(n),this.tabDOMs[e]=a,this.tabs[e]=s,setTimeout(()=>{i.onCreate&&i.onCreate.call(this,this.area.root.getBoundingClientRect()),o&&this.thumb&&(this.thumb.classList.add("no-transition"),this.thumb.style.transform="translate( "+a.childIndex*a.offsetWidth+"px )",this.thumb.style.width=a.offsetWidth+"px",this.thumb.item=a,this.thumb.classList.remove("no-transition"))},10)}select(e){this.tabDOMs[e]&&this.tabDOMs[e].click()}delete(e){this.selected==e&&(this.selected=null);const t=this.tabDOMs[e];if(!t||t.fixed)return;this.onclose&&this.onclose(e),this.tabDOMs[e].remove(),delete this.tabDOMs[e],this.tabs[e].remove(),delete this.tabs[e];const s=this.root.lastChild;s&&!s.fixed&&this.root.lastChild.click()}}t.Tabs=c;class h extends a{setLimits;constructor(e,s,o,a={}){super(n.NUMBER,e,s,a),this.onGetValue=()=>s,this.onSetValue=(n,l,c)=>{if(isNaN(n))return;s=t.clamp(+n,+h.min,+h.max),h.value=s=t.round(s,a.precision);const d=r.querySelector(".lexinputslider");d&&(d.value=s),l||this._trigger(new i(e,s,c),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=a.inputWidth??`calc( 100% - ${t})`},this.setLimits=(e,t,s)=>{};var l=document.createElement("div");l.className="lexnumber",this.root.appendChild(l);let r=document.createElement("div");r.className="numberbox",l.appendChild(r);let c=t.makeContainer(["auto","100%"],"relative flex flex-row cursor-text","",r),h=document.createElement("input");h.id="number_"+t.guidGenerator(),h.className="vecinput",h.min=a.min??-1e24,h.max=a.max??1e24,h.step=a.step??"any",h.type="number",s.constructor==Number&&(s=t.clamp(s,+h.min,+h.max),s=t.round(s,a.precision)),h.value=h.iValue=s,c.appendChild(h);const d=t.makeIcon("MoveVertical",{iconClass:"drag-icon hidden-opacity",svgClass:"sm"});if(c.appendChild(d),a.units){let e=t.makeContainer(["auto","auto"],"px-2 bg-secondary content-center",a.units,c,{"word-break":"keep-all"});h.unitBox=e}if(a.disabled&&(this.disabled=h.disabled=!0),!a.skipSlider&&void 0!==a.min&&void 0!==a.max){let e=t.makeContainer(["100%","auto"],"z-1 input-box","",r),i=document.createElement("input");i.className="lexinputslider",i.min=a.min,i.max=a.max,i.step=a.step??1,i.type="range",i.value=s,i.disabled=this.disabled,i.addEventListener("input",e=>{this.set(i.valueAsNumber,!1,e)},!1),i.addEventListener("mousedown",function(e){a.onPress&&a.onPress.bind(i)(e,i)},!1),i.addEventListener("mouseup",function(e){a.onRelease&&a.onRelease.bind(i)(e,i)},!1),e.appendChild(i),this.setLimits=(e,t,o)=>{h.min=i.min=e??h.min,h.max=i.max=t??h.max,h.step=o??h.step,i.step=o??i.step,this.set(s,!0)}}h.addEventListener("input",function(e){s=+h.valueAsNumber,s=t.round(s,a.precision)},!1),h.addEventListener("wheel",e=>{if(e.preventDefault(),h!==document.activeElement)return;let t=a.step??1;e.shiftKey?t*=10:e.altKey&&(t*=.1),s=+h.valueAsNumber-t*(e.deltaY>0?1:-1),this.set(s,!1,e)},{passive:!1}),h.addEventListener("change",e=>{this.set(h.valueAsNumber,!1,e)},{passive:!1});var u=this;let p=e=>{let t=-e.movementY;if(0!=t){let i=a.step??1;e.shiftKey?i*=10:e.altKey&&(i*=.1),s=+h.valueAsNumber+i*t,this.set(s,!1,e)}e.stopPropagation(),e.preventDefault()},m=e=>{var t=u.root.ownerDocument;t.removeEventListener("mousemove",p),t.removeEventListener("mouseup",m),document.body.classList.remove("noevents"),d.classList.add("hidden-opacity"),document.pointerLockElement&&document.exitPointerLock(),a.onRelease&&a.onRelease.bind(h)(e,h)};c.addEventListener("mousedown",e=>{if(document.activeElement!=h&&e.button==t.MOUSE_LEFT_CLICK){var s=u.root.ownerDocument;s.addEventListener("mousemove",p),s.addEventListener("mouseup",m),document.body.classList.add("noevents"),d.classList.remove("hidden-opacity"),e.stopImmediatePropagation(),e.stopPropagation(),document.pointerLockElement||c.requestPointerLock(),a.onPress&&a.onPress.bind(h)(e,h)}}),t.doAsync(this.onResize.bind(this))}}t.NumberInput=h;class d extends a{valid;_triggerEvent;_lastValueTriggered;constructor(e,s,o,a={}){super(n.TEXT,e,String(s),a),this.onGetValue=()=>s,this.onSetValue=(t,n,l)=>{let c=this._lastValueTriggered==t;a.ignoreValidation||(c=c||!this.valid(t)),c||(this._lastValueTriggered=s=t,r.value=t,delete this._triggerEvent,n||this._trigger(new i(e,t,l),o))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=a.inputWidth??`calc( 100% - ${t})`},this.valid=(e,s)=>{if(e=e??this.value(),!a.pattern)return!0;return 0==t.validateValueAtPattern(e,a.pattern,s).length};let l=document.createElement("div");l.className=a.warning?" lexwarning":"",l.style.display="flex",l.style.position="relative",this.root.appendChild(l),this.disabled=(a.disabled||a.warning)??!!a.url;let r=null;if(this.disabled)a.url?(r=document.createElement("a"),r.href=a.url,r.target="_blank",r.innerHTML=s??"",r.style.textAlign=a.float??"",r.className="lextext ellipsis-overflow"):(r=document.createElement("input"),r.disabled=!0,r.value=s,r.style.textAlign=a.float??"",r.className="lextext ellipsis-overflow "+(a.inputClass??""));else{r=document.createElement("input"),r.className="lextext "+(a.inputClass??""),r.type=a.type||"",r.value=s||"",r.style.textAlign=a.float??"",r.setAttribute("placeholder",a.placeholder??""),a.required&&r.setAttribute("required",a.required),a.pattern&&r.setAttribute("pattern",t.buildTextPattern(a.pattern));const e=a.trigger??"default";if("default"==e?(r.addEventListener("keyup",e=>{"Enter"==e.key&&(this._triggerEvent=e,r.blur())}),r.addEventListener("focusout",e=>{this._triggerEvent=this._triggerEvent??e,this.set(e.target.value,!1,this._triggerEvent)})):"input"==e&&r.addEventListener("input",e=>{this.set(e.target.value,!1,e)}),r.addEventListener("mousedown",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),a.icon){r.style.paddingLeft="1.75rem";const e=t.makeIcon(a.icon,{iconClass:"absolute z-1 ml-2",svgClass:"sm"});l.appendChild(e)}}a.fit&&r.classList.add("size-content"),Object.assign(r.style,a.style??{}),l.appendChild(r),t.doAsync(this.onResize.bind(this))}}t.TextInput=d;class u extends a{_lastPlacement=[!1,!1];constructor(e,s,o,a,r={}){super(n.SELECT,e,o,r),this.onGetValue=()=>o,this.onSetValue=(n,l,c)=>{o=n;let h=null;if(C.childNodes.forEach(e=>{e.classList.remove("selected"),e.getAttribute("value")==n&&(h=e)}),console.assert(h,`Item ${n} does not exist in the Select.`),h.classList.add("selected"),p.refresh(o),f){f.root.querySelector("input").value="";const e=this._filterOptions(s,"");g.refresh(e)}const d=this.root.querySelector(".lexcustomcontainer"),u=r[`on_${o}`];if(d.toggleAttribute("hidden",!u),u){d.innerHTML="";const e=new t.Panel;e.queue(d),u.call(this,e),e.clearQueue()}this.root.dataset.opened=!!u,g.style.height="",l||this._trigger(new i(e,o,c),a)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=r.inputWidth??`calc( 100% - ${t})`};let c=document.createElement("div");c.className="lexselect",this.root.appendChild(c);let h=document.createElement("div");h.className="lexselect lexoption",h.name=e,h.iValue=o,void 0!==r.overflowContainer&&(r.overflowContainerX=r.overflowContainerY=r.overflowContainer);const u=(e,s)=>{const i=p.root,o=i.getBoundingClientRect(),n=e.parentElement.closest("dialog")??e.parentElement.closest(".lexcolorpicker");{const a=void 0!==r.overflowContainerY?r.overflowContainerY:t.getParentArea(e),l=e.offsetHeight;let c=o.y,h=window.innerHeight;if(a){const e=a.getBoundingClientRect();h=e.y+e.height}if(n){const e=n.getBoundingClientRect();c-=e.y,h-=e.y}e.style.top=c+i.offsetHeight+"px",g.style.height="";const d=s?this._lastPlacement[0]:c-l<0,u=s?this._lastPlacement[1]:c+l>h;u&&!d?(e.style.top=c-l+"px",e.classList.add("place-above")):u&&d&&(g.style.height=h-c-32+"px"),this._lastPlacement=[d,u]}{const s=void 0!==r.overflowContainerX?r.overflowContainerX:t.getParentArea(e),i=e.offsetWidth;let a=o.x;if(e.style.minWidth=o.width+"px",n){a-=n.getBoundingClientRect().x}e.style.left=a+"px";let l=window.innerWidth;if(s){const e=s.getBoundingClientRect();l=e.x+e.width}a+i>l&&(e.style.left=a-(i-o.width)+"px")}};let p=new l(null,o,(e,t)=>{if(g.unfocus_event)return void delete g.unfocus_event;m.classList.remove("place-above");m.hasAttribute("open")?m.close():(m.show(),u(m)),f&&f.root.querySelector("input").focus()},{buttonClass:"array",skipInlineCount:!0,disabled:r.disabled});p.root.style.width="100%",p.root.querySelector("span").appendChild(t.makeIcon("Down",{svgClass:"sm"})),c.appendChild(p.root),p.refresh=e=>{const t=p.root.querySelector("span");""==t.innerText?t.innerText=e:t.innerHTML=t.innerHTML.replaceAll(t.innerText,e)};const m=document.createElement("dialog");m.className="lexselectoptions";let g=document.createElement("ul");g.tabIndex=-1,g.className="lexoptions",m.appendChild(g),g.addEventListener("focusout",function(e){if(e.stopPropagation(),e.stopImmediatePropagation(),e.relatedTarget===p.root.querySelector("button"))g.unfocus_event=!0,setTimeout(()=>delete g.unfocus_event,200);else{if(e.relatedTarget&&m.contains(e.relatedTarget))return;if("lexinput-filter"==e.target.className)return}m.close()});let f=null;if(r.filter){const e=t.deepCopy(r);e.placeholder=e.placeholder??"Search...",e.skipComponent=e.skipComponent??!0,e.trigger="input",e.icon="Search",e.className="lexfilter",e.inputClass="outline",f=new d(null,r.filterValue??"",e=>{const t=this._filterOptions(s,e);g.refresh(t),u(m,!0)},e),f.root.querySelector(".lextext").style.border="1px solid transparent";f.root.querySelector("input").addEventListener("focusout",function(e){e.relatedTarget&&"UL"==e.relatedTarget.tagName&&e.relatedTarget.classList.contains("lexoptions")||m.close()}),g.appendChild(f.root)}const C=document.createElement("span");C.className="lexselectinnerlist",g.appendChild(C),g.refresh=e=>{if(C.innerHTML="",!e.length){let e=r.emptyMsg??"No options found.",s=document.createElement("div");s.className="option",s.innerHTML=t.makeIcon("Inbox",{svgClass:"mr-2"}).innerHTML+e;let i=document.createElement("li");return i.className="lexselectitem empty",i.appendChild(s),void C.appendChild(i)}for(let s=0;s<e.length;s++){let i=e[s],n=document.createElement("li"),a=document.createElement("div");a.className="option",n.appendChild(a);const l=e=>{this.set(e.currentTarget?.getAttribute("value"),!1,e),m.close()};if(n.addEventListener("click",l),i.constructor!=Object){const e="@"===i[0];e?(a.innerHTML="<span>"+i.substr(1)+"</span>",n.removeEventListener("click",l)):(a.innerHTML=`<span>${i}</span>`,a.appendChild(t.makeIcon("Check")),a.value=i,n.setAttribute("value",i),i==o&&(n.classList.add("selected"),h.innerHTML=i)),n.classList.add(e?"lexselectlabel":"lexselectitem")}else{let e=document.createElement("img");e.src=i.src,n.setAttribute("value",i.value),n.className="lexlistitem",a.innerText=i.value,a.className+=" media",a.prepend(e),a.setAttribute("value",i.value),a.setAttribute("data-index",s),a.setAttribute("data-src",i.src),a.setAttribute("title",i.value),o==i.value&&n.classList.add("selected")}C.appendChild(n)}},g.refresh(s),c.appendChild(m);let v=document.createElement("div");v.className="lexcustomcontainer w-full";const y=r[`on_${o}`];if(v.toggleAttribute("hidden",!y),y){v.innerHTML="";const e=new t.Panel;e.queue(v),y.call(this,e),e.clearQueue()}this.root.appendChild(v),this.root.dataset.opened=!!y,t.doAsync(this.onResize.bind(this))}_filterOptions(e,t){const s=!t.length;let i=[];for(let o=0;o<e.length;o++){let n=e[o];if(!s){let e="string"==typeof n?n:n.value;const s=t.toLowerCase();if(!e.toLowerCase().includes(s))continue}i.push(n)}return i}}t.Select=u;class p extends a{_updateItems;constructor(e,s=[],o,a={}){a.nameWidth="100%",super(n.ARRAY,e,null,a),this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{s=t,this._updateItems(),n||this._trigger(new i(e,s,a),o)};let r=document.createElement("div");r.className="lexarray",r.style.width="100%",this.root.appendChild(r),this.root.dataset.opened=!1;let c=`Array (size ${s.length})`;const p=new l(null,c,()=>{this.root.dataset.opened="true"!=this.root.dataset.opened,this.root.querySelector(".lexarrayitems").toggleAttribute("hidden")},{buttonClass:"array"});p.root.querySelector("span").appendChild(t.makeIcon("Down",{svgClass:"sm"})),r.appendChild(p.root);let m=document.createElement("div");m.className="lexarrayitems",m.toggleAttribute("hidden",!0),this.root.appendChild(m),this._updateItems=()=>{let n=this.root.querySelector(".lexbutton.array span");for(let e of n.childNodes)if(e.nodeType===Node.TEXT_NODE){e.textContent=`Array (size ${s.length})`;break}m.innerHTML="";for(let t=0;t<s.length;++t){const n=s[t];let r=a.innerValues?"select":n.constructor,c=null;switch(r){case String:c=new d(t+"",n,function(e){s[t]=e,o(s)},{nameWidth:"12px",className:"p-0",skipReset:!0});break;case Number:c=new h(t+"",n,function(e){s[t]=e,o(s)},{nameWidth:"12px",className:"p-0",skipReset:!0});break;case"select":c=new u(t+"",a.innerValues,n,function(e){s[t]=e,o(s)},{nameWidth:"12px",className:"p-0",skipReset:!0})}console.assert(c,`Value of type ${r} cannot be modified in ArrayInput`),m.appendChild(c.root);const p=new l(null,"",(t,a)=>{s.splice(s.indexOf(n),1),this._updateItems(),this._trigger(new i(e,s,a),o)},{title:"Remove item",icon:"Trash3"});c.root.appendChild(p.root)}const r=new l(null,t.makeIcon("Plus",{svgClass:"sm"}).innerHTML+"Add item",(t,n)=>{s.push(a.innerValues?a.innerValues[0]:""),this._updateItems(),this._trigger(new i(e,s,n),o)},{buttonClass:"array"});m.appendChild(r.root)},this._updateItems()}}t.ArrayInput=p;class m extends a{constructor(e,s={}){s.hideName=!0,super(n.CARD,e,null,s),this.root.classList.add("place-content-center");const o=t.makeContainer(["100%","auto"],"lexcard max-w-sm flex flex-col gap-4 bg-primary border rounded-xl py-6","",this.root);if(s.header){const e=void 0!==s.header.action;let i=t.makeContainer(["100%","auto"],`flex ${e?"flex-row gap-4":"flex-col gap-1"} px-6`,"",o);if(e){const e=new l(null,s.header.action.name,s.header.action.callback);i.appendChild(e.root);const o=t.makeContainer(["75%","auto"],"flex flex-col gap-1","");i.prepend(o),i=o}s.header.title&&t.makeElement("div","text-md leading-none font-semibold",s.header.title,i),s.header.description&&t.makeElement("div","text-sm fg-tertiary",s.header.description,i)}if(s.content){const e=t.makeContainer(["100%","auto"],"flex flex-col gap-2 px-6","",o),i=[].concat(s.content);for(let t of i)e.appendChild(t.root?t.root:t)}if(s.footer){const e=t.makeContainer(["100%","auto"],"flex flex-col gap-1 px-6","",o),i=[].concat(s.footer);for(let t of i)e.appendChild(t.root?t.root:t)}s.callback&&(o.classList.add("selectable"),o.style.cursor="pointer",o.addEventListener("click",t=>{this._trigger(new i(e,null,t),s.callback)}))}}t.Card=m;class g extends a{constructor(e,s,o,a={}){if(!e&&!a.label)throw"Set Component Name or at least a label!";super(n.CHECKBOX,e,s,a),this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{t!=s&&(r.checked=s=t,this.root.querySelector(".lexcheckboxsubmenu")?.toggleAttribute("hidden",!t),n||this._trigger(new i(e,t,a),o))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=a.inputWidth??`calc( 100% - ${t})`};var l=document.createElement("div");l.className="lexcheckboxcont",this.root.appendChild(l);let r=document.createElement("input");r.type="checkbox",r.className="lexcheckbox "+(a.className??"primary"),r.checked=s,r.disabled=a.disabled??!1,l.appendChild(r);let c=document.createElement("span");if(c.className="checkboxtext",c.innerHTML=a.label??"On",l.appendChild(c),r.addEventListener("change",e=>{this.set(r.checked,!1,e)}),a.suboptions){let e=document.createElement("div");e.className="lexcheckboxsubmenu",e.toggleAttribute("hidden",!r.checked);const s=new t.Panel;s.queue(e),a.suboptions.call(this,s),s.clearQueue(),this.root.appendChild(e)}t.doAsync(this.onResize.bind(this))}}t.Checkbox=g;class f{_rgb;_hex="#000000";_hsv;css;get rgb(){return this._rgb}set rgb(e){this._fromRGB(e)}get hex(){return this._hex}set hex(e){this._fromHex(e)}get hsv(){return this._hsv}set hsv(e){this._fromHSV(e)}constructor(e){this.set(e)}set(e){if("string"==typeof e&&e.startsWith("#"))this._fromHex(e);else if("r"in e&&"g"in e&&"b"in e)e.a=e.a??1,this._fromRGB(e);else{if(!("h"in e&&"s"in e&&"v"in e))throw"Bad color model!";e.a=e.a??1,this._fromHSV(e)}}setHSV(e){this._fromHSV(e)}setRGB(e){this._fromRGB(e)}setHex(e){this._fromHex(e)}_fromHex(e){this._fromRGB(t.hexToRgb(e))}_fromRGB(e){this._rgb=e,this._hsv=t.rgbToHsv(e),this._hex=t.rgbToHex(e),this.css=t.rgbToCss(this._rgb)}_fromHSV(e){this._hsv=e,this._rgb=t.hsvToRgb(e),this._hex=t.rgbToHex(this._rgb),this.css=t.rgbToCss(this._rgb)}}t.Color=f;class C{static currentPicker=!1;root;colorModel;useAlpha;callback;markerHalfSize;markerSize;currentColor;labelComponent;colorPickerBackground;intSatMarker;colorPickerTracker;alphaTracker;hueMarker;alphaMarker;onPopover;constructor(e,s={}){this.colorModel=s.colorModel??"Hex",this.useAlpha=s.useAlpha??!1,this.callback=s.onChange,this.callback||console.warn("Define a callback in _options.onChange_ to allow getting new Color values!"),this.root=document.createElement("div"),this.root.className="lexcolorpicker",this.markerHalfSize=8,this.markerSize=2*this.markerHalfSize,this.currentColor=new f(e);const i=new f({h:this.currentColor.hsv.h,s:1,v:1});this.colorPickerBackground=document.createElement("div"),this.colorPickerBackground.className="lexcolorpickerbg",this.colorPickerBackground.style.backgroundColor=`rgb(${i.css.r}, ${i.css.g}, ${i.css.b})`,this.root.appendChild(this.colorPickerBackground),this.intSatMarker=document.createElement("div"),this.intSatMarker.className="lexcolormarker",this.intSatMarker.style.backgroundColor=this.currentColor.hex,this.colorPickerBackground.appendChild(this.intSatMarker);let o=null,n=e=>{const s=e.movementX,i=e.movementY,n=e.x-o.x,a=e.y-o.y;0!=s&&(n>=0||s<0)&&(n<this.colorPickerBackground.offsetWidth||s>0)&&(this.intSatMarker.style.left=t.clamp(parseInt(this.intSatMarker.style.left)+s,-this.markerHalfSize,this.colorPickerBackground.offsetWidth-this.markerHalfSize)+"px"),0!=i&&(a>=0||i<0)&&(a<this.colorPickerBackground.offsetHeight||i>0)&&(this.intSatMarker.style.top=t.clamp(parseInt(this.intSatMarker.style.top)+i,-this.markerHalfSize,this.colorPickerBackground.offsetHeight-this.markerHalfSize)+"px"),this._positionToSv(parseInt(this.intSatMarker.style.left),parseInt(this.intSatMarker.style.top)),this._updateColorValue(),e.stopPropagation(),e.preventDefault()},a=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",n),t.removeEventListener("mouseup",a),document.body.classList.remove("noevents")};this.colorPickerBackground.addEventListener("mousedown",e=>{var t=this.root.ownerDocument;t.addEventListener("mousemove",n),t.addEventListener("mouseup",a),document.body.classList.add("noevents"),e.stopImmediatePropagation(),e.stopPropagation();const s=e.offsetX-this.markerHalfSize;this.intSatMarker.style.left=s+"px";const i=e.offsetY-this.markerHalfSize;this.intSatMarker.style.top=i+"px",this._positionToSv(s,i),this._updateColorValue(),o=this.colorPickerBackground.getBoundingClientRect()});const r=t.makeContainer(["100%","auto"],"flex flex-row gap-1 items-center","",this.root),c=window.EyeDropper;c&&r.appendChild(new l(null,"eyedrop",async()=>{const e=new c;try{const t=await e.open();this.fromHexColor(t.sRGBHex)}catch(e){}},{icon:"Pipette",buttonClass:"bg-none",title:"Sample Color"}).root);const h=t.makeContainer(["100%","100%"],"flex flex-col gap-2","",r);this.colorPickerTracker=document.createElement("div"),this.colorPickerTracker.className="lexhuetracker",h.appendChild(this.colorPickerTracker),this.hueMarker=document.createElement("div"),this.hueMarker.className="lexcolormarker",this.hueMarker.style.backgroundColor=`rgb(${i.css.r}, ${i.css.g}, ${i.css.b})`,this.colorPickerTracker.appendChild(this.hueMarker);const p=e=>{this.hueMarker.style.left=e+"px",this.currentColor.hsv.h=t.remapRange(e,0,this.colorPickerTracker.offsetWidth-this.markerSize,0,360);const s=new f({h:this.currentColor.hsv.h,s:1,v:1});this.hueMarker.style.backgroundColor=`rgb(${s.css.r}, ${s.css.g}, ${s.css.b})`,this.colorPickerBackground.style.backgroundColor=`rgb(${s.css.r}, ${s.css.g}, ${s.css.b})`,this._updateColorValue()};let m=null,g=e=>{const s=e.movementX,i=e.x-m.x;if(0!=s&&(i>=this.markerHalfSize||s<0)&&(i<this.colorPickerTracker.offsetWidth-this.markerHalfSize||s>0)){const e=t.clamp(parseInt(this.hueMarker.style.left)+s,0,this.colorPickerTracker.offsetWidth-this.markerSize);p(e)}e.stopPropagation(),e.preventDefault()},C=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",g),t.removeEventListener("mouseup",C),document.body.classList.remove("noevents")};if(this.colorPickerTracker.addEventListener("mousedown",e=>{const s=this.root.ownerDocument;s.addEventListener("mousemove",g),s.addEventListener("mouseup",C),document.body.classList.add("noevents"),e.stopImmediatePropagation(),e.stopPropagation();const i=t.clamp(e.offsetX-this.markerHalfSize,0,this.colorPickerTracker.offsetWidth-this.markerSize);p(i),m=this.colorPickerTracker.getBoundingClientRect()}),this.useAlpha){this.alphaTracker=document.createElement("div"),this.alphaTracker.className="lexalphatracker",this.alphaTracker.style.color=`rgb(${this.currentColor.css.r}, ${this.currentColor.css.g}, ${this.currentColor.css.b})`,h.appendChild(this.alphaTracker),this.alphaMarker=document.createElement("div"),this.alphaMarker.className="lexcolormarker",this.alphaMarker.style.backgroundColor=`rgb(${this.currentColor.css.r}, ${this.currentColor.css.g}, ${this.currentColor.css.b},${this.currentColor.css.a})`,this.alphaTracker.appendChild(this.alphaMarker);const e=e=>{this.alphaMarker.style.left=e+"px",this.currentColor.hsv.a=t.remapRange(e,0,this.alphaTracker.offsetWidth-this.markerSize,0,1),this._updateColorValue(),this.alphaMarker.style.backgroundColor=`rgb(${this.currentColor.css.r}, ${this.currentColor.css.g}, ${this.currentColor.css.b},${this.currentColor.css.a})`};let s=null,i=i=>{const a=this.root.ownerDocument;a.addEventListener("mousemove",o),a.addEventListener("mouseup",n),document.body.classList.add("noevents"),i.stopImmediatePropagation(),i.stopPropagation();const l=t.clamp(i.offsetX-this.markerHalfSize,0,this.alphaTracker.offsetWidth-this.markerSize);e(l),s=this.alphaTracker.getBoundingClientRect()},o=i=>{const o=i.movementX,n=i.x-s.x;if(0!=o&&(n>=this.markerHalfSize||o<0)&&(n<this.alphaTracker.offsetWidth-this.markerHalfSize||o>0)){const s=t.clamp(parseInt(this.alphaMarker.style.left)+o,0,this.alphaTracker.offsetWidth-this.markerSize);e(s)}i.stopPropagation(),i.preventDefault()},n=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",o),t.removeEventListener("mouseup",n),document.body.classList.remove("noevents")};this.alphaTracker.addEventListener("mousedown",i)}const v=t.makeContainer(["100%","auto"],"flex flex-row gap-1","",this.root);v.appendChild(new u(null,["CSS","Hex","HSV","RGB"],this.colorModel,e=>{this.colorModel=e,this._updateColorValue(null,!0)}).root),this.labelComponent=new d(null,"",null,{inputClass:"bg-none",fit:!0,disabled:!0}),v.appendChild(this.labelComponent.root);{const e=new l(null,"copy",async()=>{navigator.clipboard.writeText(this.labelComponent.value()),e.root.querySelector("input[type='checkbox']").style.pointerEvents="none",t.doAsync(()=>{e.swap&&e.swap(!0),e.root.querySelector("input[type='checkbox']").style.pointerEvents="auto"},3e3)},{swap:"Check",icon:"Copy",buttonClass:"bg-none",className:"ml-auto",title:"Copy"});e.root.querySelector(".swap-on svg").classList.add("fg-success"),v.appendChild(e.root)}this._updateColorValue(e,!0),t.doAsync(this._placeMarkers.bind(this)),this.onPopover=this._placeMarkers.bind(this)}_placeMarkers(){this._svToPosition(this.currentColor.hsv.s,this.currentColor.hsv.v);const e=t.remapRange(this.currentColor.hsv.h,0,360,0,this.colorPickerTracker.offsetWidth-this.markerSize);if(this.hueMarker.style.left=e+"px",this.useAlpha){const e=t.remapRange(this.currentColor.hsv.a,0,1,0,this.alphaTracker.offsetWidth-this.markerSize);this.alphaMarker.style.left=e+"px"}}_svToPosition(e,s){this.intSatMarker.style.left=`${t.remapRange(e,0,1,-this.markerHalfSize,this.colorPickerBackground.offsetWidth-this.markerHalfSize)}px`,this.intSatMarker.style.top=`${t.remapRange(1-s,0,1,-this.markerHalfSize,this.colorPickerBackground.offsetHeight-this.markerHalfSize)}px`}_positionToSv(e,s){this.currentColor.hsv.s=t.remapRange(e,-this.markerHalfSize,this.colorPickerBackground.offsetWidth-this.markerHalfSize,0,1),this.currentColor.hsv.v=1-t.remapRange(s,-this.markerHalfSize,this.colorPickerBackground.offsetHeight-this.markerHalfSize,0,1)}_updateColorValue(e,t=!1){this.currentColor.set(e??this.currentColor.hsv),this.callback&&!t&&this.callback(this.currentColor),this.intSatMarker.style.backgroundColor=this.currentColor.hex,this.useAlpha&&(this.alphaTracker.style.color=`rgb(${this.currentColor.css.r}, ${this.currentColor.css.g}, ${this.currentColor.css.b})`);const s=(e,t=2)=>e.toFixed(t).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,"$1");if("CSS"==this.colorModel){const{r:e,g:t,b:i,a:o}=this.currentColor.css;this.labelComponent.set(`rgb${this.useAlpha?"a":""}(${e},${t},${i}${this.useAlpha?","+s(o):""})`)}else if("Hex"==this.colorModel)this.labelComponent.set((this.useAlpha?this.currentColor.hex:this.currentColor.hex.substr(0,7)).toUpperCase());else if("HSV"==this.colorModel){const{h:e,s:t,v:i,a:o}=this.currentColor.hsv,n=[Math.floor(e)+"º",Math.floor(100*t)+"%",Math.floor(100*i)+"%"];this.useAlpha&&n.push(s(o)),this.labelComponent.set(n.join(" "))}else{const{r:e,g:t,b:i,a:o}=this.currentColor.rgb,n=[s(e),s(t),s(i)];this.useAlpha&&n.push(s(o)),this.labelComponent.set(n.join(" "))}}fromHexColor(e){this.currentColor.setHex(e);const{h:s,s:i,v:o}=this.currentColor.hsv;this._svToPosition(i,o);const n=new f({h:s,s:1,v:1});this.hueMarker.style.backgroundColor=this.colorPickerBackground.style.backgroundColor=`rgb(${n.css.r}, ${n.css.g}, ${n.css.b})`,this.hueMarker.style.left=t.remapRange(s,0,360,-this.markerHalfSize,this.colorPickerTracker.offsetWidth-this.markerHalfSize)+"px",this._updateColorValue(e)}}t.ColorPicker=C;class v{static activeElement=null;root;side="bottom";align="center";sideOffset=0;alignOffset=0;avoidCollisions=!0;reference;_windowPadding=4;_trigger;_parent;_onClick;constructor(e,s,i={}){if(v.activeElement)return void v.activeElement.destroy();this._trigger=e,e&&(e.classList.add("triggered"),e.active=this),this.side=i.side??this.side,this.align=i.align??this.align,this.sideOffset=i.sideOffset??this.sideOffset,this.alignOffset=i.alignOffset??this.alignOffset,this.avoidCollisions=i.avoidCollisions??!0,this.reference=i.reference,this.root=document.createElement("div"),this.root.dataset.side=this.side,this.root.tabIndex="1",this.root.className="lexpopover";const o=(e??this.reference).closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=t.root,this._parent.appendChild(this.root),this.root.addEventListener("keydown",e=>{"Escape"==e.key&&(e.preventDefault(),e.stopPropagation(),this.destroy())}),s&&(s=[].concat(s)).forEach(e=>{const t=e.root??e;this.root.appendChild(t),e.onPopover&&e.onPopover()}),v.activeElement=this,t.doAsync(()=>{this._adjustPosition(),this._trigger&&(this.root.focus(),this._onClick=e=>{e.target&&(this.root.contains(e.target)||e.target==this._trigger)||this.destroy()},document.body.addEventListener("mousedown",this._onClick,!0),document.body.addEventListener("focusin",this._onClick,!0))},10)}destroy(){this._trigger&&(this._trigger.classList.remove("triggered"),delete this._trigger.active,document.body.removeEventListener("mousedown",this._onClick,!0),document.body.removeEventListener("focusin",this._onClick,!0)),this.root.remove(),v.activeElement=null}_adjustPosition(){const e=[0,0];{const t=this.reference??this._trigger;console.assert(t,"Popover needs a trigger or reference element!");const s=t.getBoundingClientRect();let i=!0;switch(this.side){case"left":e[0]+=s.x-this.root.offsetWidth-this.sideOffset,i=!1;break;case"right":e[0]+=s.x+s.width+this.sideOffset,i=!1;break;case"top":e[1]+=s.y-this.root.offsetHeight-this.sideOffset,i=!0;break;case"bottom":e[1]+=s.y+s.height+this.sideOffset,i=!0}switch(this.align){case"start":i?e[0]+=s.x:e[1]+=s.y;break;case"center":i?e[0]+=s.x+.5*s.width-.5*this.root.offsetWidth:e[1]+=s.y+.5*s.height-.5*this.root.offsetHeight;break;case"end":i?e[0]+=s.x-this.root.offsetWidth+s.width:e[1]+=s.y-this.root.offsetHeight+s.height}i?e[0]+=this.alignOffset:e[1]+=this.alignOffset}if(this.avoidCollisions&&(e[0]=t.clamp(e[0],0,window.innerWidth-this.root.offsetWidth-this._windowPadding),e[1]=t.clamp(e[1],0,window.innerHeight-this.root.offsetHeight-this._windowPadding)),this._parent instanceof HTMLDialogElement){let t=this._parent.getBoundingClientRect();e[0]-=t.x,e[1]-=t.y}this.root.style.left=`${e[0]}px`,this.root.style.top=`${e[1]}px`}}t.Popover=v;t.PopConfirm=class{_popover=null;constructor(e,s={}){const i=s.confirmText??"Yes",o=s.cancelText??"No",n=s.title??"Confirm",a=s.content??"Are you sure you want to proceed?",l=s.onConfirm,r=s.onCancel,c=t.makeContainer(["auto","auto"],"tour-step-container");{const e=t.makeContainer(["100%","auto"],"flex flex-row","",c);t.makeContainer(["100%","auto"],"p-1 font-medium text-md",n,e)}t.makeContainer(["100%","auto"],"p-1 text-md",a,c,{maxWidth:"400px"});const h=t.makeContainer(["100%","auto"],"flex flex-row text-md","",c),d=t.makeContainer(["100%","auto"],"text-md","",h),u=new t.Panel;d.appendChild(u.root),u.sameLine(2,"justify-end"),u.addButton(null,o,()=>{r&&r(),this._popover?.destroy()},{xbuttonClass:"contrast"}),u.addButton(null,i,()=>{l&&l(),this._popover?.destroy()},{buttonClass:"accent"}),this._popover?.destroy(),this._popover=new t.Popover(null,[c],{reference:e,side:s.side??"top",align:s.align,sideOffset:s.sideOffset,alignOffset:s.alignOffset})}};class y extends a{picker;_skipTextUpdate=!1;_popover=void 0;constructor(e,s,o,a={}){s=s??"#000000";const l=a.useAlpha??(s.constructor===Object&&"a"in s||s.constructor===String&&[5,9].includes(s.length)),r=new f(s);s=l?r.hex:r.hex.substr(0,7),super(n.COLOR,e,s,a),this.onGetValue=()=>{const e=new f(s);return a.useRGB?e.rgb:s},this.onSetValue=(t,n,r)=>{const c=new f(t);if(u.style.color=s=c.hex.substr(0,7),l&&(p.style.color=s=c.hex),this._skipTextUpdate||m.set(s,!0,r),!n){let t=s;a.useRGB&&(t=c.rgb,l||delete t.a),this._trigger(new i(e,t,r),o)}},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${t})`};var c=document.createElement("span");c.className="lexcolor",this.root.appendChild(c),this.picker=new C(s,{colorModel:a.useRGB?"RGB":"Hex",useAlpha:l,onChange:e=>{this.set(e.hex)}});let h=t.makeContainer(["18px","18px"],"flex flex-row bg-contrast rounded overflow-hidden","",c);h.tabIndex="1",h.addEventListener("click",e=>{a.disabled||(this._popover=new v(h,[this.picker]))});let u=document.createElement("div");u.className="lexcolorsample",u.style.color=s,h.appendChild(u);let p=null;l?(p=document.createElement("div"),p.className="lexcolorsample",p.style.color=s,h.appendChild(p)):u.style.width="18px";const m=new d(null,s,e=>{this._skipTextUpdate=!0,this.set(e),delete this._skipTextUpdate,this.picker.fromHexColor(e)},{width:"calc( 100% - 24px )",disabled:a.disabled});m.root.style.marginLeft="6px",c.appendChild(m.root),t.doAsync(this.onResize.bind(this))}}t.Color=f,t.ColorPicker=C,t.ColorInput=y;class b extends a{constructor(e,s,o={}){const a=!o.noSelection;let l=a&&(o.toggle??!1),r=document.createElement("div");r.className="lexcombobuttons ",o.skipReset=!0,o.float&&(r.className+=o.float);let c=[],h=document.createElement("div");h.className="lexcombobuttonsbox ",r.appendChild(h);for(let e of s){if(!e.value)throw"Set 'value' for each button!";let s=document.createElement("button");if(s.className="lexbutton combo",s.title=e.icon?e.value:"",s.id=e.id??"",s.dataset.value=e.value,o.buttonClass&&s.classList.add(o.buttonClass),a&&(e.selected||o.selected?.includes(e.value))&&(s.classList.add("selected"),c=c.concat([e.value])),e.icon){const i=t.makeIcon(e.icon);s.appendChild(i)}else s.innerHTML=`<span>${e.value}</span>`;e.disabled&&s.setAttribute("disabled","true"),s.addEventListener("click",t=>{c=[],a&&(l?s.classList.toggle("selected"):(r.querySelectorAll("button").forEach(e=>e.classList.remove("selected")),s.classList.add("selected"))),r.querySelectorAll("button").forEach(e=>{e.classList.contains("selected")&&c.push(e.dataset.value)}),!l&&c.length>1?console.error("Enable _options.toggle_ to allow selecting multiple options in ComboButtons."):(c=c[0],this.set(e.value,!1,s.classList.contains("selected")))}),h.appendChild(s)}c.length>1?l||(o.toggle=!0,l=a,console.warn(`Multiple options selected in '${e}' ComboButtons. Enabling _toggle_ mode.`)):c=c[0],super(n.BUTTONS,e,null,o),this.onGetValue=()=>c,this.onSetValue=(t,o,n)=>{if(a&&null==n&&(r.querySelectorAll("button").forEach(e=>e.classList.remove("selected")),r.querySelectorAll("button").forEach(e=>{c&&c.indexOf(e.dataset.value)>-1&&e.classList.add("selected")})),!o&&t.constructor!=Array){const o=n,a=s.filter(e=>e.value==t)[0]?.callback;this._trigger(new i(e,l?[t,o]:t,null),a)}},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${t})`},this.root.appendChild(r),t.doAsync(this.onResize.bind(this))}}t.ComboButtons=b;class _ extends a{count;constructor(e,s,o,a={}){super(n.COUNTER,e,s,a),this.onGetValue=()=>this.count,this.onSetValue=(s,n,a)=>{this.count=t.clamp(s,r,c),u.value=this.count,n||this._trigger(new i(e,s,a),o)},this.count=s;const r=a.min??0,c=a.max??100,h=a.step??1,d=document.createElement("div");d.className="flex flex-row border bg-primary rounded-lg shadow",this.root.appendChild(d);const u=t.makeElement("input","lexcounter w-12 bg-primary px-2 fg-primary","",d);u.type="number",u.value=s,a.disabled&&u.setAttribute("disabled","true");const p=new l(null,"",(e,t)=>{let s=h??1;t.shiftKey&&(s*=10),this.set(this.count-s,!1,t)},{disabled:a.disabled,className:`p-0 ${a.disabled?"":"hover:bg-secondary"} border-left border-right`,buttonClass:"bg-none",icon:"Minus"});d.appendChild(p.root);const m=new l(null,"",(e,t)=>{let s=h??1;t.shiftKey&&(s*=10),this.set(this.count+s,!1,t)},{disabled:a.disabled,className:`p-0 ${a.disabled?"":"hover:bg-secondary"} rounded-r-lg`,buttonClass:"bg-none",icon:"Plus"});d.appendChild(m.root)}}t.Counter=_;class x{element;canvas;constructor(e,s={}){let i=document.createElement("div");i.className="curve "+(s.className?s.className:""),i.style.minHeight="50px",i.style.width=s.width||"100%",i.style.minWidth="50px",i.style.minHeight="20px",i.bgcolor=s.bgColor||t.getThemeColor("global-background"),i.pointscolor=s.pointsColor||t.getThemeColor("global-color-accent"),i.activepointscolor=s.activePointsColor||t.getThemeColor("global-color-accent-light"),i.linecolor=s.lineColor||"#555",i.value=e||[],i.xrange=s.xrange||[0,1],i.yrange=s.yrange||[0,1],i.defaulty=null!=s.defaulty?s.defaulty:0,i.no_overlap=s.noOverlap||!1,i.show_samples=s.showSamples||0,i.allow_add_values=s.allowAddValues??!0,i.draggable_x=s.draggableX??!0,i.draggable_y=s.draggableY??!0,i.smooth=(s.smooth&&"number"==typeof s.smooth?s.smooth:.3)||!1,i.move_out=s.moveOutAction??t.CURVE_MOVEOUT_DELETE,t.addSignal("@on_new_color_scheme",(e,o)=>{i.bgcolor=s.bgColor||t.getThemeColor("global-background"),i.pointscolor=s.pointsColor||t.getThemeColor("global-color-accent"),i.activepointscolor=s.activePointsColor||t.getThemeColor("global-color-accent-light"),this.redraw()}),this.element=i;let o=document.createElement("canvas");function n(e){return[o.width*(e[0]-i.xrange[0])/i.xrange[1],o.height*(e[1]-i.yrange[0])/i.yrange[1]]}function a(e){return[e[0]*i.xrange[1]/o.width+i.xrange[0],e[1]*i.yrange[1]/o.height+i.yrange[0]]}o.width=s.width||200,o.height=s.height||50,i.appendChild(o),this.canvas=o,i.addEventListener("mousedown",function(e){document.addEventListener("mousemove",c),document.addEventListener("mouseup",h);var s=o.getBoundingClientRect(),d=e.clientX-s.left,m=e.clientY-s.top;if(l=function(e,t){for(var s=1e5,o=-1,a=0;a<i.value.length;a++){var l=u([e,t],n(i.value[a]));l<s&&l<8&&(s=l,o=a)}return o}(d,o.height-m),e.button==t.MOUSE_LEFT_CLICK&&-1==l&&i.allow_add_values){var g=a([d,o.height-m]);i.value.push(g),p(),l=i.value.indexOf(g)}r=[d,m],i.redraw(),e.preventDefault(),e.stopPropagation()}),i.getValueAt=function(e){if(e<i.xrange[0]||e>i.xrange[1])return i.defaulty;let t=[i.xrange[0],i.defaulty],s=0;for(let o=0;o<i.value.length;o+=1){let n=i.value[o];if(e==n[0])return n[1];if(e<n[0])return s=(e-t[0])/(n[0]-t[0]),t[1]*(1-s)+n[1]*s;t=n}let o=[i.xrange[1],i.defaulty];return s=(e-t[0])/(o[0]-t[0]),t[1]*(1-s)+o[1]*s},i.resample=function(e){let t=[],s=(i.xrange[1]-i.xrange[0])/e;for(let e=i.xrange[0];e<=i.xrange[1];e+=s)t.push(i.getValueAt(e));return t},i.addValue=function(e){for(let t=0;t<i.value;t++){if(!(i.value[t][0]<e[0]))return i.value.splice(t,0,e),void this.redraw()}i.value.push(e),this.redraw()};let l=-1;i.redraw=function(e={}){e.value&&(i.value=e.value),e.xrange&&(i.xrange=e.xrange),e.yrange&&(i.yrange=e.yrange),e.smooth&&(i.smooth=e.smooth);var s=o.getContext("2d");if(!s)return;s.setTransform(1,0,0,1,0,0),s.translate(0,o.height),s.scale(1,-1),s.fillStyle=i.bgcolor,s.fillRect(0,0,o.width,o.height),s.strokeStyle=i.linecolor,s.beginPath();var a=n([i.xrange[0],i.defaulty]);s.moveTo(a[0],a[1]);let r=[a[0],a[1]];for(var c in i.value){a=n(i.value[c]),r.push(a[0]),r.push(a[1]),i.smooth||s.lineTo(a[0],a[1])}a=n([i.xrange[1],i.defaulty]),r.push(a[0]),r.push(a[1]),i.smooth?t.drawSpline(s,r,i.smooth):(s.lineTo(a[0],a[1]),s.stroke());for(var h=0;h<i.value.length;h+=1){a=n(i.value[h]);const e=h==l;s.fillStyle=e?i.activepointscolor:i.pointscolor,s.beginPath(),s.arc(a[0],a[1],e?4:3,0,2*Math.PI),s.fill()}if(i.show_samples){var d=i.resample(i.show_samples);s.fillStyle="#888";for(h=0;h<d.length;h+=1){a=n([h*((i.xrange[1]-i.xrange[0])/i.show_samples)+i.xrange[0],d[h]]),s.beginPath(),s.arc(a[0],a[1],2,0,2*Math.PI),s.fill()}}};var r=[0,0];function c(e){var s=o.getBoundingClientRect(),n=e.clientX-s.left,c=e.clientY-s.top;n<0?n=0:n>o.width&&(n=o.width),c<0?c=0:c>o.height&&(c=o.height);const m=[e.clientX-s.left,e.clientY-s.top];if(-1!=l&&u(m,[n,c])>.5*o.height){if(i.move_out==t.CURVE_MOVEOUT_DELETE)i.value.splice(l,1);else{const e=[m[0]-n,m[1]-c];let t=i.value[l];t[0]=0==e[0]?t[0]:e[0]<0?i.xrange[0]:i.xrange[1],t[1]=0==e[1]?t[1]:e[1]<0?i.yrange[1]:i.yrange[0]}h(e)}else{var g=a([-(i.draggable_x?r[0]-n:0),i.draggable_y?r[1]-c:0]);if(-1!=l){var f=i.xrange[0],C=i.xrange[1];i.no_overlap&&(l>0&&(f=i.value[l-1][0]),l<i.value.length-1&&(C=i.value[l+1][0]));var v=i.value[l];v[0]+=g[0],v[1]+=g[1],v[0]<f?v[0]=f:[0]>C&&(v[0]=C),v[1]<i.yrange[0]?v[1]=i.yrange[0]:v[1]>i.yrange[1]&&(v[1]=i.yrange[1])}p(),i.redraw(),r[0]=n,r[1]=c,d(e),e.preventDefault(),e.stopPropagation()}}function h(e){l=-1,i.redraw(),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",h),d(e),e.preventDefault(),e.stopPropagation()}function d(e){s.callback&&s.callback.call(i,i.value,e)}function u(e,t){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function p(){var e=null;-1!=l&&(e=i.value[l]),i.value.sort(function(e,t){return e[0]-t[0]}),e&&(l=i.value.indexOf(e))}return i.redraw(),this}redraw(e={}){this.element.redraw(e)}}class L extends a{curveInstance;constructor(e,s,o,a={}){let l=JSON.parse(JSON.stringify(s));super(n.CURVE,e,l,a),this.onGetValue=()=>JSON.parse(JSON.stringify(c.element.value)),this.onSetValue=(t,s,n)=>{c.element.value=JSON.parse(JSON.stringify(t)),c.redraw(),s||this._trigger(new i(e,c.element.value,n),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${t})`};var r=document.createElement("div");r.className="lexcurve",this.root.appendChild(r),a.callback=(t,s)=>{this._trigger(new i(e,t,s),o)},a.name=e;let c=new x(s,a);r.appendChild(c.element),this.curveInstance=c;new ResizeObserver(e=>{for(const t of e)c.canvas.width=t.contentRect.width,c.redraw()}).observe(r),t.doAsync(this.onResize.bind(this))}}t.CanvasCurve=x,t.Curve=L;class S{root;day=-1;month=-1;year=-1;monthName="";firstDay=-1;daysInMonth=-1;calendarDays=[];currentDate;range;untilToday;fromToday;skipPrevMonth;skipNextMonth;onChange;onPreviousMonth;onNextMonth;constructor(e,s={}){if(this.root=t.makeContainer(["256px","auto"],"p-1 text-md"),this.onChange=s.onChange,this.onPreviousMonth=s.onPreviousMonth,this.onNextMonth=s.onNextMonth,this.untilToday=s.untilToday,this.fromToday=s.fromToday,this.range=s.range,this.skipPrevMonth=s.skipPrevMonth,this.skipNextMonth=s.skipNextMonth,e)this.fromDateString(e);else{const e=new Date;this.month=e.getMonth()+1,this.year=e.getFullYear(),this.fromMonthYear(this.month,this.year)}}_getCurrentDate(){return{day:this.day,month:this.month,year:this.year,fullDate:this.getFullDate()}}_previousMonth(e){this.month=Math.max(1,this.month-1),1==this.month&&(this.month=12,this.year--),this.fromMonthYear(this.month,this.year),!e&&this.onPreviousMonth&&this.onPreviousMonth(this.currentDate)}_nextMonth(e){this.month=Math.min(this.month+1,13),13==this.month&&(this.month=1,this.year++),this.fromMonthYear(this.month,this.year),!e&&this.onNextMonth&&this.onNextMonth(this.currentDate)}refresh(){this.root.innerHTML="";{const e=t.makeContainer(["100%","auto"],"flex flex-row p-1","",this.root);if(!this.skipPrevMonth){const s=t.makeIcon("Left",{title:"Previous Month",iconClass:"border p-1 rounded hover:bg-secondary",svgClass:"sm"});e.appendChild(s),s.addEventListener("click",()=>{this._previousMonth()})}if(t.makeContainer(["100%","auto"],"text-center font-medium select-none",`${this.monthName} ${this.year}`,e),!this.skipNextMonth){const s=t.makeIcon("Right",{title:"Next Month",iconClass:"border p-1 rounded hover:bg-secondary",svgClass:"sm"});e.appendChild(s),s.addEventListener("click",()=>{this._nextMonth()})}}{const e=document.createElement("table");e.className="w-full",this.root.appendChild(e);{const t=document.createElement("thead");e.appendChild(t);const s=document.createElement("tr");for(const e of["Mo","Tu","We","Th","Fr","Sa","Su"]){const t=document.createElement("th");t.className="fg-tertiary text-sm font-normal select-none",t.innerHTML=`<span>${e}</span>`,s.appendChild(t)}t.appendChild(s)}{const s=document.createElement("tbody");e.appendChild(s);let i=this.range?t.dateFromDateString(this.range[0]):null,o=this.range?t.dateFromDateString(this.range[1]):null;for(let e=0;e<6;e++){const t=document.createElement("tr"),n=this.calendarDays.slice(7*e,7*e+7);for(const e of n){const s=document.createElement("th");s.className="leading-loose font-normal rounded select-none cursor-pointer";const n=new Date(`${this.month}/${e.day}/${this.year}`),a=new Date,l=!this.untilToday||n.getTime()<a.getTime(),r=!this.fromToday||(n.getFullYear()>a.getFullYear()||n.getFullYear()===a.getFullYear()&&n.getMonth()>a.getMonth()||n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()>=a.getDate()),c=e.currentMonth&&l&&r,h=this.currentDate&&e.day==this.currentDate.day&&this.month==this.currentDate.month&&this.year==this.currentDate.year&&e.currentMonth,d=c&&i&&e.day==i.getDate()&&this.month==i.getMonth()+1&&this.year==i.getFullYear(),u=c&&o&&e.day==o.getDate()&&this.month==o.getMonth()+1&&this.year==o.getFullYear();!this.range&&h||this.range&&(d||u)?s.className+=" bg-contrast fg-contrast":this.range&&c&&n>i&&n<o?s.className+=" bg-accent fg-contrast":s.className+=` ${c?"fg-primary":"fg-tertiary"} hover:bg-secondary`,s.innerHTML=`<span>${e.day}</span>`,t.appendChild(s),c?s.addEventListener("click",()=>{this.day=e.day,this.currentDate=this._getCurrentDate(),this.onChange&&this.onChange(this.currentDate)}):void 0!==this.range||e.currentMonth||s.addEventListener("click",()=>{e?.prevMonth?this._previousMonth():this._nextMonth()})}s.appendChild(t)}}}}fromDateString(e){const t=e.split("/");this.day=parseInt(t[0]),this.month=parseInt(t[1]),this.monthName=this.getMonthName(this.month-1),this.year=parseInt(t[2]),this.currentDate=this._getCurrentDate(),this.fromMonthYear(this.month,this.year)}fromMonthYear(e,t){e=Math.max(e-1,0),t=t??(new Date).getFullYear();const s=new Date(t,e,1).getDay(),i=0===s?6:s-1,o=new Date(t,e+1,0).getDate(),n=new Date(0===e?t-1:t,(0===e?11:e-1)+1,0).getDate(),a=[];for(let e=i-1;e>=0;e--)a.push({day:n-e,currentMonth:!1,prevMonth:!0});for(let e=1;e<=o;e++)a.push({day:e,currentMonth:!0});const l=42-a.length;for(let e=1;e<=l;e++)a.push({day:e,currentMonth:!1,nextMonth:!0});this.monthName=this.getMonthName(e),this.firstDay=i,this.daysInMonth=o,this.calendarDays=a,this.refresh()}getMonthName(e,t="en-US"){return new Intl.DateTimeFormat(t,{month:"long"}).format(new Date(2e3,e,1))}getFullDate(e,t,s){return`${e??this.monthName} ${t??this.day}${this._getOrdinalSuffix(t??this.day)}, ${s??this.year}`}setRange(e){console.assert(e.constructor===Array,"Date Range must be in Array format"),this.range=e,this.refresh()}setMonth(e){this.month=e,this.fromMonthYear(this.month,this.year)}_getOrdinalSuffix(e){if(e>3&&e<21)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}}t.Calendar=S;class k{root;fromCalendar;toCalendar;from;to;_selectingRange=!1;constructor(e,s={}){this.root=t.makeContainer(["auto","auto"],"flex flex-row"),console.assert(e&&e.constructor===Array,"Range cannot be empty and has to be an Array!");let i=null,o=!1;{const s=t.dateFromDateString(e[0]),n=t.dateFromDateString(e[1]);if(s>n){const t=e[0];e[0]=e[1],e[1]=t,o=!0}i=(o?n.getMonth():s.getMonth())+2}this.from=e[0],this.to=e[1];const n=e=>{const t=`${e.day}/${e.month}/${e.year}`;this._selectingRange?(this.to=t,this._selectingRange=!1):(this.from=this.to=t,this._selectingRange=!0);const i=[this.from,this.to];this.fromCalendar.setRange(i),this.toCalendar.setRange(i),s.onChange&&s.onChange(i)};this.fromCalendar=new S(this.from,{skipNextMonth:!0,onChange:n,onPreviousMonth:()=>{this.toCalendar._previousMonth()},range:e}),this.toCalendar=new S(this.to,{skipPrevMonth:!0,onChange:n,onNextMonth:()=>{this.fromCalendar._nextMonth()},range:e}),console.assert(i&&"New Month must be valid"),this.toCalendar.setMonth(i),this.root.appendChild(this.fromCalendar.root),this.root.appendChild(this.toCalendar.root)}getFullDate(){const e=t.dateFromDateString(this.from),s=this.fromCalendar.getMonthName(e.getMonth()),i=t.dateFromDateString(this.to),o=this.toCalendar.getMonthName(i.getMonth());return`${this.fromCalendar.getFullDate(s,e.getDate(),e.getFullYear())} to ${this.toCalendar.getFullDate(o,i.getDate(),i.getFullYear())}`}}t.CalendarRange=k;class E extends a{calendar;_popover=void 0;constructor(e,s,o,a={}){super(n.DATE,e,null,a);const r=s?.constructor===Array;if(!r&&a.today){const e=new Date;s=`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()}`}this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{r||this.calendar.fromDateString(t),s=t,h(this.calendar.getFullDate()),n||this._trigger(new i(e,t,a),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${t})`};const c=t.makeContainer(["auto","auto"],"lexdate flex flex-row");this.root.appendChild(c),this.calendar=r?new k(s,{onChange:e=>{this.set(e)},...a}):new S(s,{onChange:e=>{const t=`${e.day}/${e.month}/${e.year}`;this.set(t)},...a});const h=e=>{const s=!!e;c.innerHTML="";const i=(e=e??"Pick a date").split(" to "),o=r?i[0]:e,n=t.makeIcon("Calendar"),a=new l(null,o,()=>{this._popover=new v(a.root,[this.calendar])},{buttonClass:`flex flex-row px-3 ${s?"":"fg-tertiary"} justify-between`});if(a.root.querySelector("button").appendChild(n),a.root.style.width="100%",c.appendChild(a.root),r){const e=t.makeIcon("ArrowRight");t.makeContainer(["32px","auto"],"content-center",e.innerHTML,c);const o=i[1],n=t.makeIcon("Calendar"),a=new l(null,o,()=>{this._popover=new v(a.root,[this.calendar])},{buttonClass:`flex flex-row px-3 ${s?"":"fg-tertiary"} justify-between`});a.root.querySelector("button").appendChild(n),a.root.style.width="100%",c.appendChild(a.root)}};s?h(this.calendar.getFullDate()):h(),t.doAsync(this.onResize.bind(this))}}t.Calendar=S,t.CalendarRange=k,t.DatePicker=E;class T{element;canvas;constructor(e,s={}){let i=document.createElement("div");i.className="dial "+(s.className?s.className:""),i.style.width=i.style.height=s.size||"100%",i.style.minWidth=i.style.minHeight="50px",i.bgcolor=s.bgColor||t.getThemeColor("global-background"),i.pointscolor=s.pointsColor||t.getThemeColor("global-color-accent-light"),i.linecolor=s.lineColor||"#555",i.value=e||[],i.xrange=s.xrange||[0,1],i.yrange=s.yrange||[0,1],i.defaulty=null!=s.defaulty?s.defaulty:0,i.no_overlap=s.noOverlap||!1,i.show_samples=s.showSamples||0,i.allow_add_values=s.allowAddValues??!0,i.draggable_x=s.draggableX??!0,i.draggable_y=s.draggableY??!0,i.smooth=(s.smooth&&"number"==typeof s.smooth?s.smooth:.3)||!1,i.move_out=s.moveOutAction??t.CURVE_MOVEOUT_DELETE,t.addSignal("@on_new_color_scheme",(e,o)=>{i.bgcolor=s.bgColor||t.getThemeColor("global-background"),i.pointscolor=s.pointsColor||t.getThemeColor("global-color-accent-light"),this.redraw()}),this.element=i;let o=document.createElement("canvas");function n(e){return[o.width*(e[0]-i.xrange[0])/i.xrange[1],o.height*(e[1]-i.yrange[0])/i.yrange[1]]}function a(e){return[e[0]*i.xrange[1]/o.width+i.xrange[0],e[1]*i.yrange[1]/o.height+i.yrange[0]]}o.width=o.height=s.size||200,i.appendChild(o),this.canvas=o,i.addEventListener("mousedown",function(e){document.addEventListener("mousemove",c),document.addEventListener("mouseup",h);var s=o.getBoundingClientRect(),d=e.clientX-s.left,m=e.clientY-s.top;if(l=function(e,t){for(var s=1e5,o=-1,a=0;a<i.value.length;a++){var l=u([e,t],n(i.value[a]));l<s&&l<8&&(s=l,o=a)}return o}(d,o.height-m),e.button==t.MOUSE_LEFT_CLICK&&-1==l&&i.allow_add_values){var g=a([d,o.height-m]);i.value.push(g),p(),l=i.value.indexOf(g)}r=[d,m],i.redraw(),e.preventDefault(),e.stopPropagation()}),i.getValueAt=function(e){if(e<i.xrange[0]||e>i.xrange[1])return i.defaulty;for(var t=[i.xrange[0],i.defaulty],s=0,o=0;o<i.value.length;o+=1){var n=i.value[o];if(e==n[0])return n[1];if(e<n[0])return s=(e-t[0])/(n[0]-t[0]),t[1]*(1-s)+n[1]*s;t=n}return n=[i.xrange[1],i.defaulty],s=(e-t[0])/(n[0]-t[0]),t[1]*(1-s)+n[1]*s},i.resample=function(e){for(var t=[],s=(i.xrange[1]-i.xrange[0])/e,o=i.xrange[0];o<=i.xrange[1];o+=s)t.push(i.getValueAt(o));return t},i.addValue=function(e){for(var t=0;t<i.value;t++){if(!(i.value[t][0]<e[0]))return i.value.splice(t,0,e),void this.redraw()}i.value.push(e),this.redraw()};var l=-1;i.redraw=function(e={}){e.value&&(i.value=e.value),e.xrange&&(i.xrange=e.xrange),e.yrange&&(i.yrange=e.yrange),e.smooth&&(i.smooth=e.smooth);var t=o.getContext("2d");if(!t)return;t.setTransform(1,0,0,1,0,0),t.translate(0,o.height),t.scale(1,-1),t.fillStyle=i.bgcolor,t.fillRect(0,0,o.width,o.height),t.strokeStyle=i.linecolor,t.beginPath();var s=n([i.xrange[0],i.defaulty]);t.moveTo(s[0],s[1]);let a=[s[0],s[1]];for(var r in i.value){s=n(i.value[r]),a.push(s[0]),a.push(s[1])}s=n([i.xrange[1],i.defaulty]),a.push(s[0]),a.push(s[1]);s=n([0,0]),t.fillStyle="gray",t.beginPath(),t.arc(s[0],s[1],3,0,2*Math.PI),t.fill();for(var c=0;c<i.value.length;c+=1){s=n(i.value[c]);const e=c==l;t.fillStyle=e?"white":i.pointscolor,t.beginPath(),t.arc(s[0],s[1],e?4:3,0,2*Math.PI),t.fill()}if(i.show_samples){var h=i.resample(i.show_samples);t.fillStyle="#888";for(c=0;c<h.length;c+=1){s=n([c*((i.xrange[1]-i.xrange[0])/i.show_samples)+i.xrange[0],h[c]]),t.beginPath(),t.arc(s[0],s[1],2,0,2*Math.PI),t.fill()}}};var r=[0,0];function c(e){var s=o.getBoundingClientRect(),n=e.clientX-s.left,c=e.clientY-s.top;n<0?n=0:n>o.width&&(n=o.width),c<0?c=0:c>o.height&&(c=o.height);const m=[e.clientX-s.left,e.clientY-s.top];if(-1!=l&&u(m,[n,c])>.5*o.height){if(i.move_out==t.CURVE_MOVEOUT_DELETE)i.value.splice(l,1);else{const e=[m[0]-n,m[1]-c];let t=i.value[l];t[0]=0==e[0]?t[0]:e[0]<0?i.xrange[0]:i.xrange[1],t[1]=0==e[1]?t[1]:e[1]<0?i.yrange[1]:i.yrange[0]}h(e)}else{var g=a([-(i.draggable_x?r[0]-n:0),i.draggable_y?r[1]-c:0]);if(-1!=l){var f=i.xrange[0],C=i.xrange[1];i.no_overlap&&(l>0&&(f=i.value[l-1][0]),l<i.value.length-1&&(C=i.value[l+1][0]));var v=i.value[l];v[0]+=g[0],v[1]+=g[1],v[0]<f?v[0]=f:v[0]>C&&(v[0]=C),v[1]<i.yrange[0]?v[1]=i.yrange[0]:v[1]>i.yrange[1]&&(v[1]=i.yrange[1])}p(),i.redraw(),r[0]=n,r[1]=c,d(e),e.preventDefault(),e.stopPropagation()}}function h(e){l=-1,i.redraw(),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",h),d(e),e.preventDefault(),e.stopPropagation()}function d(e){s.callback&&s.callback.call(i,i.value,e)}function u(e,t){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function p(){var e=null;-1!=l&&(e=i.value[l]),i.value.sort(function(e,t){return e[0]-t[0]}),e&&(l=i.value.indexOf(e))}return i.redraw(),this}redraw(e={}){this.element.redraw(e)}}t.CanvasDial=T;class w extends a{dialInstance;constructor(e,s,o,a={}){let l=JSON.parse(JSON.stringify(s));super(n.DIAL,e,l,a),this.onGetValue=()=>JSON.parse(JSON.stringify(c.element.value)),this.onSetValue=(t,s,n)=>{c.element.value=JSON.parse(JSON.stringify(t)),c.redraw(),s||this._trigger(new i(e,c.element.value,n),o)},this.onResize=e=>{const s=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${s})`,t.flushCss(r),c.element.style.height=c.element.offsetWidth+"px",c.canvas.width=c.element.offsetWidth,r.style.width=c.element.offsetWidth+"px",c.canvas.height=c.canvas.width,c.redraw()};var r=document.createElement("div");r.className="lexcurve",this.root.appendChild(r),a.callback=(t,s)=>{this._trigger(new i(e,t,s),o)},a.name=e;let c=new T(s,a);r.appendChild(c.element),this.dialInstance=c,t.doAsync(this.onResize.bind(this))}}t.CanvasDial=T,t.Dial=w;class M extends a{constructor(e,s,i={}){super(n.FILE,e,null,i);let o=i.local??!0,a=i.type??"text",r=i.read??!0;this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${t})`};let c=document.createElement("input");if(c.className="lexfileinput",c.type="file",c.disabled=i.disabled??!1,this.root.appendChild(c),i.placeholder&&(c.placeholder=i.placeholder),c.addEventListener("change",function(e){const t=e.target.files;if(t.length)if(r){i.onBeforeRead&&i.onBeforeRead();const e=new FileReader;"text"===a?e.readAsText(t[0]):"buffer"===a?e.readAsArrayBuffer(t[0]):"bin"===a?e.readAsBinaryString(t[0]):"url"===a&&e.readAsDataURL(t[0]),e.onload=e=>{s.call(this,e.target?.result,t[0])}}else s(t[0])}),c.addEventListener("cancel",function(e){s(null)}),o){let e=null;const s=new l(null,"",()=>{e||(e=new t.Dialog("Load Settings",e=>{e.addSelect("Type",["text","buffer","bin","url"],a,e=>{a=e}),e.addButton(null,"Reload",()=>{c.dispatchEvent(new Event("change"))})},{onclose:t=>{t.remove(),e=null}}))},{skipInlineCount:!0,title:"Settings",disabled:i.disabled,icon:"Settings"});this.root.appendChild(s.root)}t.doAsync(this.onResize.bind(this))}}t.FileInput=M;class A extends a{constructor(e,s,i,o={}){if(s.constructor!=Object)return void console.error("Form data must be an Object");o.hideName=!0,super(n.FORM,e,null,o),this.onGetValue=()=>r.formData,this.onSetValue=(e,t,s)=>{r.formData=e;const i=r.querySelectorAll(".lexcomponent");for(let s=0;s<i.length;++s){if(i[s].jsInstance.type!=n.TEXT)continue;let o=i[s].querySelector(".lexcomponentname").innerText,l=i[s].querySelector(".lextext input");l.value=e[o]??"",a._dispatchEvent(l,"focusout",t)}};let r=document.createElement("div");r.className="lexformdata",r.style.width="100%",r.formData={},this.root.appendChild(r);for(let e in s){let i=s[e];if(i.constructor!=Object){const o=t.deepCopy(i);i={value:o},s[e]=i}if(i.width="100%",i.placeholder=i.placeholder??i.label??`Enter ${e}`,i.ignoreValidation=!0,!o.skipLabels){const t=new d(null,i.label??e,null,{disabled:!0,inputClass:"formlabel bg-none"});r.appendChild(t.root)}i.textComponent=new d(null,i.constructor==Object?i.value:i,(t,s)=>{r.formData[e]=t,i.submit&&s.constructor===KeyboardEvent&&h?.click()},i),r.appendChild(i.textComponent.root),r.formData[e]=i.constructor==Object?i.value:i}const c=t.makeContainer(["100%","auto"],"flex flex-row mt-2","",r);if(o.secondaryActionName||o.secondaryActionCallback){const e=new l(null,o.secondaryActionName??"Cancel",(e,t)=>{o.secondaryActionCallback&&o.secondaryActionCallback(r.formData,t)},{width:"100%",minWidth:"0",buttonClass:o.secondaryButtonClass??"primary"});c.appendChild(e.root)}const h=new l(null,o.primaryActionName??"Submit",(e,o)=>{const n=[];for(let e in s){let i=s[e];const o=i.pattern,a=o?.fieldMatchName?r.formData[o.fieldMatchName]:void 0;if(!i.textComponent.valid(void 0,a)){const s={entry:e,type:"input_not_valid",messages:[]};o&&(s.messages=t.validateValueAtPattern(r.formData[e],o,a)),n.push(s)}}i&&i(r.formData,n,o)},{width:"100%",minWidth:"0",buttonClass:o.primaryButtonClass??"contrast"});c.appendChild(h.root)}}t.Form=A;class N extends a{setLayers;constructor(e,s,o,a={}){super(n.LAYERS,e,s,a),this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{s=t,this.setLayers(s),n||this._trigger(new i(e,s,a),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};const l=document.createElement("div");l.className="lexlayers",this.root.appendChild(l);const r=a.maxBits??16;this.setLayers=e=>{l.innerHTML="";let t=e.toString(2),s=t.length;for(let e=0;e<r-s;++e)t="0"+t;for(let s=0;s<r;++s){let i=document.createElement("div");if(i.className="lexlayer",null!=e){const e=t[r-s-1];null!=e&&"1"==e&&i.classList.add("selected")}i.innerText=s+1,i.title="Bit "+s+", value "+(1<<s),l.appendChild(i),i.addEventListener("click",t=>{t.stopPropagation(),t.stopImmediatePropagation(),t.target.classList.toggle("selected");const i=e^1<<s;this.set(i,!1,t)})}},this.setLayers(s),t.doAsync(this.onResize.bind(this))}}t.Layers=N;class P extends a{_updateValues;constructor(e,s,o,a,l={}){super(n.LIST,e,o,l),this.onGetValue=()=>o,this.onSetValue=(t,n,l)=>{r.querySelectorAll(".lexlistitem").forEach(e=>e.classList.remove("selected"));let c=null;for(let e=0;e<s.length;++e){const i=s[e];if(i==t||i.constructor==Array&&i[0]==t){c=e;break}}c?(r.children[c].classList.toggle("selected"),o=t,n||this._trigger(new i(e,t,l),a)):console.error(`Cannot find item ${t} in List.`)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${t})`},this._updateValues=n=>{s=n,r.innerHTML="";for(let n=0;n<s.length;++n){let l=null,c=s[n];c.constructor===Array&&(l=c[1],c=c[0]);let h=document.createElement("div");h.className="lexlistitem"+(o==c?" selected":""),l&&h.appendChild(t.makeIcon(l)),h.innerHTML+=`<span>${c}</span>`,h.addEventListener("click",t=>{r.querySelectorAll(".lexlistitem").forEach(e=>e.classList.remove("selected")),h.classList.toggle("selected"),o=c,this._trigger(new i(e,c,t),a)}),r.appendChild(h)}};let r=document.createElement("div");r.className="lexlist",this.root.appendChild(r),this._updateValues(s),t.doAsync(this.onResize.bind(this))}}t.List=P;let O=class e{x;y;constructor(e,t){this.x=e??0,this.y=t??e??0}get xy(){return[this.x,this.y]}get yx(){return[this.y,this.x]}set(e,t){this.x=e,this.y=t}add(t,s=new e){return s.set(this.x+t.x,this.y+t.y),s}sub(t,s=new e){return s.set(this.x-t.x,this.y-t.y),s}mul(t,s=new e){return t.constructor==Number&&(t=new e(t)),s.set(this.x*t.x,this.y*t.y),s}div(t,s=new e){return t.constructor==Number&&(t=new e(t)),s.set(this.x/t.x,this.y/t.y),s}abs(t=new e){return t.set(Math.abs(this.x),Math.abs(this.y)),t}dot(e){return this.x*e.x+this.y*e.y}len2(){return this.dot(this)}len(){return Math.sqrt(this.len2())}nrm(t=new e){return t.set(this.x,this.y),t.mul(1/this.len(),t)}dst(e){return e.sub(this).len()}clp(s,i,o=new e){return o.set(t.clamp(this.x,s,i),t.clamp(this.y,s,i)),o}fromArray(e){this.x=e[0],this.y=e[1]}toArray(){return this.xy}};t.vec2=O;class I{static COLORS=[[255,0,0],[0,255,0],[0,0,255],[0,128,128],[128,0,128],[128,128,0],[255,128,0],[255,0,128],[0,128,255],[128,0,255]];static GRID_SIZE=64;canvas;imageCanvas=null;root;circular;showNames;size;points;callback;weights=[];weightsObj={};currentPosition=new O(0,0);circleCenter=[0,0];circleRadius=1;margin=8;dragging=!1;_valuesChanged=!0;_selectedPoint=null;_precomputedWeightsGridSize=0;_precomputedWeights=null;constructor(e,s,i={}){this.circular=i.circular??!1,this.showNames=i.showNames??!0,this.size=i.size??[200,200],this.points=e??[],this.callback=s,this._valuesChanged=!0,this._selectedPoint=null,this.root=t.makeContainer(["auto","auto"]),this.root.tabIndex="1",this.root.addEventListener("mousedown",function(e){var t=o.root.ownerDocument;return t.addEventListener("mouseup",a),t.addEventListener("mousemove",n),e.stopPropagation(),e.preventDefault(),o.dragging=!0,!0});const o=this;function n(e){if(!o.dragging)return;const s=o.margin,i=o.root.getBoundingClientRect();let n=new O;n.set(e.x-i.x-.5*o.size[0],e.y-i.y-.5*o.size[1]);var a=o.currentPosition;if(a.set(t.clamp(n.x/(.5*o.size[0]-s),-1,1),t.clamp(n.y/(.5*o.size[1]-s),-1,1)),o.circular){const e=new O(0,0);a.dst(e)>1&&(a=a.nrm())}return o.renderToCanvas(o.canvas.getContext("2d",{willReadFrequently:!0})),o.computeWeights(a),o.callback&&o.callback(o.weightsObj,o.weights,a),!0}function a(e){o.dragging=!1;var t=o.root.ownerDocument;t.removeEventListener("mouseup",a),t.removeEventListener("mousemove",n)}this.canvas=document.createElement("canvas"),this.canvas.width=this.size[0],this.canvas.height=this.size[1],this.root.appendChild(this.canvas);const l=this.canvas.getContext("2d",{willReadFrequently:!0});this.renderToCanvas(l)}computeWeights(e){if(!this.points.length)return;let t=this._precomputedWeights;t&&!this._valuesChanged||(t=this.precomputeWeights());let s=this.weights;s.length=this.points.length;for(var i=0;i<s.length;++i)s[i]=0;const o=I.GRID_SIZE;let n=0,a=new O;for(var l=0;l<o;++l)for(var r=0;r<o;++r){a.set(r/o*2-1,l/o*2-1);var c=2*r+l*o*2,h=t[c];e.dst(a)<t[c+1]+.001&&(s[h]+=1,n++)}for(i=0;i<s.length;++i)s[i]/=n,this.weightsObj[this.points[i].name]=s[i];return s}precomputeWeights(){this._valuesChanged=!1;const e=this.points.length,t=I.GRID_SIZE,s=2*t*t;let i=new O;this._precomputedWeights&&this._precomputedWeights.length==s||(this._precomputedWeights=new Float32Array(s));let o=this._precomputedWeights;this._precomputedWeightsGridSize=t;for(let s=0;s<t;++s)for(let n=0;n<t;++n){let a=-1,l=1e5;for(let o=0;o<e;++o){i.set(n/t*2-1,s/t*2-1);let e=new O;e.fromArray(this.points[o].pos);let r=i.dst(e);r>l||(a=o,l=r)}o[2*n+2*s*t]=a,o[2*n+2*s*t+1]=l}return o}precomputeWeightsToImage(e){if(!this.points.length)return null;const t=I.GRID_SIZE;var s=this._precomputedWeights;s&&!this._valuesChanged&&this._precomputedWeightsGridSize==t||(s=this.precomputeWeights());var i=this.imageCanvas;i||(i=this.imageCanvas=document.createElement("canvas")),i.width=i.height=t;var o=i.getContext("2d",{willReadFrequently:!0});if(!o)return;var n=this.weights;n.length=this.points.length;for(var a=0;a<n.length;++a)n[a]=0;let l=0,r=o.getImageData(0,0,t,t),c=new O;for(var h=0;h<t;++h)for(var d=0;d<t;++d){c.set(d/t*2-1,h/t*2-1);const i=4*d+h*t*4,o=2*d+h*t*2,a=s[o],p=I.COLORS[a%I.COLORS.length];var u=e.dst(c)<s[o+1]+.001;u&&(n[a]+=1,l++),r.data[i]=p[0]+(u?128:0),r.data[i+1]=p[1]+(u?128:0),r.data[i+2]=p[2]+(u?128:0),r.data[i+3]=255}for(let e=0;e<n.length;++e)n[e]/=l;return o.putImageData(r,0,0),i}addPoint(e,s=null){if(this.findPoint(e))return void console.warn("CanvasMap2D.addPoint: There is already a point with that name");s||(s=[this.currentPosition.x,this.currentPosition.y]),s[0]=t.clamp(s[0],-1,1),s[1]=t.clamp(s[1],-1,1);const i={name:e,pos:s};return this.points.push(i),this._valuesChanged=!0,i}removePoint(e){const t=this.points.findIndex(t=>t.name==e);t>-1&&(this.points.splice(t,1),this._valuesChanged=!0)}findPoint(e){return this.points.find(t=>t.name==e)}clear(){this.points.length=0,this._precomputedWeights=null,this._selectedPoint=null}renderToCanvas(e){if(!e)return;const s=this.margin,i=this.size[0],o=this.size[1];e.fillStyle="black",e.strokeStyle="#BBB",e.clearRect(0,0,i,o),this.circular?(this.circleCenter[0]=.5*i,this.circleCenter[1]=.5*o,this.circleRadius=.5*o-s,e.lineWidth=1,e.beginPath(),e.arc(this.circleCenter[0],this.circleCenter[1],this.circleRadius,0,2*Math.PI),e.fill(),e.stroke(),e.beginPath(),e.moveTo(this.circleCenter[0]+.5,this.circleCenter[1]-this.circleRadius),e.lineTo(this.circleCenter[0]+.5,this.circleCenter[1]+this.circleRadius),e.moveTo(this.circleCenter[0]-this.circleRadius,this.circleCenter[1]),e.lineTo(this.circleCenter[0]+this.circleRadius,this.circleCenter[1]),e.stroke()):(e.fillRect(s,s,i-2*s,o-2*s),e.strokeRect(s,s,i-2*s,o-2*s));var n=this.precomputeWeightsToImage(this.currentPosition);n&&(e.globalAlpha=.5,e.imageSmoothingEnabled=!1,this.circular?(e.save(),e.beginPath(),e.arc(this.circleCenter[0],this.circleCenter[1],this.circleRadius,0,2*Math.PI),e.clip(),e.drawImage(n,this.circleCenter[0]-this.circleRadius,this.circleCenter[1]-this.circleRadius,2*this.circleRadius,2*this.circleRadius),e.restore()):e.drawImage(n,s,s,i-2*s,o-2*s),e.imageSmoothingEnabled=!0,e.globalAlpha=1);for(let n=0;n<this.points.length;++n){const a=this.points[n];let l=.5*a.pos[0]+.5,r=.5*a.pos[1]+.5;l=l*(i-2*s)+s,r=r*(o-2*s)+s,l=t.clamp(l,s,i-s),r=t.clamp(r,s,o-s),e.fillStyle=a==this._selectedPoint?"#CDF":"#BCD",e.beginPath(),e.arc(l,r,3,0,2*Math.PI),e.fill(),this.showNames&&e.fillText(a.name,l+5,r+5)}e.fillStyle="white",e.beginPath();var a=.5*this.currentPosition.x+.5,l=.5*this.currentPosition.y+.5;a=a*(i-2*s)+s,l=l*(o-2*s)+s,a=t.clamp(a,s,i-s),l=t.clamp(l,s,o-s),e.arc(a,l,4,0,2*Math.PI),e.fill()}}t.CanvasMap2D=I;class R extends a{map2d;_popover=null;constructor(e,s,i,o={}){super(n.MAP2D,e,null,o),this.onGetValue=()=>this.map2d.weightsObj,this.onSetValue=(e,t,s)=>{},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=`calc( 100% - ${t})`};var a=document.createElement("div");a.className="lexmap2d",this.root.appendChild(a),this.map2d=new I(s,i,o);const r=t.makeIcon("SquareMousePointer"),c=new l(null,"Open Map",()=>{this._popover=new v(c.root,[this.map2d])},{buttonClass:"flex flex-row px-3 fg-secondary justify-between"});c.root.querySelector("button").appendChild(r),a.appendChild(c.root),t.doAsync(this.onResize.bind(this))}}t.Map2D=R;class D{domEl;data;onevent;options;selected=[];_forceClose=!1;constructor(e,t,s={}){if(this.domEl=e,this.data=t,this.onevent=s.onevent,this.options=s,t.constructor===Object)this._createItem(null,t);else for(let e of t)this._createItem(null,e)}_createItem(e,s,i=0,n){const a=this,r=this.domEl.querySelector(".lexnodetreefilter");if(s.children=s.children??[],r&&""!=r.value&&!s.id.includes(r.value)){for(var c=0;c<s.children.length;++c)this._createItem(s,s.children[c],i+1,n);return}const h=this.domEl.querySelector("ul");s.visible=s.visible??!0,s.parent=e;let d=s.children.length>0,u=this.selected.indexOf(s)>-1||s.selected;if(this.options.onlyFolders){let e=!1;s.children.forEach(t=>{e=e||"folder"==t.type}),d=!!e}let p=document.createElement("li");p.className="lextreeitem datalevel"+i+(d?" parent":"")+(u?" selected":""),p.id=t.getSupportedDOMName(s.id),p.tabIndex="0",p.treeData=s;let m=this.options.skipDefaultIcon??1?null:"Dot";if(d&&(m=s.closed?"Right":"Down"),m&&p.appendChild(t.makeIcon(m,{iconClass:"hierarchy",svgClass:"xs"})),m=s.icon,m)if(s.icon.includes(".")){const e="https://raw.githubusercontent.com/jxarco/lexgui.js/master/";p.innerHTML+="<img src='"+(e+s.icon)+"'>"}else{const e=s.icon.split(" "),i=t.makeIcon(e[0],{iconClass:"tree-item-icon mr-2",svgClass:"md"+(e.length>1?` ${e.slice(0).join(" ")}`:"")});p.appendChild(i)}p.innerHTML+=s.rename?"":s.id,p.setAttribute("draggable",!0),p.style.paddingLeft=3+15*(i+1)+"px",h.appendChild(p),p.addEventListener("click",e=>{if(f)return void(f=!1);e.shiftKey||(h.querySelectorAll("li").forEach(e=>{e.classList.remove("selected")}),this.selected.length=0);const t=this.selected.indexOf(s);if(t>-1?(p.classList.remove("selected"),this.selected.splice(t,1)):(p.classList.add("selected"),this.selected.push(s)),d&&s.id.length>1){if(s.closed=!1,a.onevent){const t=new o(o.NODE_CARETCHANGED,s,s.closed,e);a.onevent(t)}a.frefresh(s.id)}if(a.onevent){const t=new o(o.NODE_SELECTED,s,this.selected,e);t.multiple=e.shiftKey,a.onevent(t)}}),p.addEventListener("dblclick",function(e){if((a.options.rename??1)&&(s.rename=!0,a.refresh()),a.onevent){const t=new o(o.NODE_DBLCLICKED,s,null,e);a.onevent(t)}}),p.addEventListener("contextmenu",e=>{if(e.preventDefault(),!a.onevent)return;const i=new o(o.NODE_CONTEXTMENU,s,this.selected,e);i.multiple=this.selected.length>1,t.addContextMenu(i.multiple?"Selected Nodes":i.node.id,i.event,e=>{i.panel=e}),a.onevent(i),this.options.addDefault&&(i.panel.items&&i.panel.add(""),i.panel.add("Select Children",()=>{const e=t=>{if(!t.closed)for(let s of t.children??[]){if(!s)continue;this.domEl.querySelector("#"+s.id).classList.add("selected"),this.selected.push(s),e(s)}};this.domEl.querySelectorAll(".selected").forEach(e=>e.classList.remove("selected")),this.selected.length=0,e(s)}),i.panel.add("Delete",{callback:()=>{if(a.deleteNode(s)&&a.onevent){const e=new o(o.NODE_DELETED,s,[s],null);a.onevent(e)}this.refresh()}}))}),p.addEventListener("keydown",e=>{if(!s.rename)if(e.preventDefault(),"Delete"==e.key){const t=[];for(let e of this.selected)a.deleteNode(e)&&t.push(e);if(t.length&&a.onevent){const i=new o(o.NODE_DELETED,s,t,e);i.multiple=t.length>1,a.onevent(i)}this.selected.length=0,this.refresh()}else if("ArrowUp"==e.key||"ArrowDown"==e.key){var i=this.selected.length>1?"ArrowUp"==e.key?this.selected.shift():this.selected.pop():this.selected[0],n=this.domEl.querySelector("#"+t.getSupportedDOMName(i.id)),l="ArrowUp"==e.key?n.previousSibling:n.nextSibling;l&&l.click()}});const g=document.createElement("input");g.toggleAttribute("hidden",!s.rename),g.className="bg-none",g.value=s.id,p.appendChild(g),s.rename&&(p.classList.add("selected"),g.focus()),g.addEventListener("keyup",function(e){if("Enter"==e.key){if(this.value=this.value.replace(/\s/g,"_"),a.onevent){const t=new o(o.NODE_RENAMED,s,this.value,e);a.onevent(t)}s.id=t.getSupportedDOMName(this.value),delete s.rename,a.frefresh(s.id),h.querySelector("#"+s.id).classList.add("selected")}else"Escape"==e.key&&(delete s.rename,a.frefresh(s.id))}),g.addEventListener("blur",function(e){delete s.rename,a.refresh()}),(this.options.draggable??1)&&(e&&p.addEventListener("dragstart",e=>{window.__tree_node_dragged=s}),p.addEventListener("dragover",e=>{e.preventDefault()},!1),p.addEventListener("dragenter",e=>{e.target.classList.add("draggingover")}),p.addEventListener("dragend",e=>{e.target.classList.remove("draggingover")}),p.addEventListener("dragleave",e=>{e.target.classList.remove("draggingover")}),p.addEventListener("drop",e=>{e.preventDefault();let t=window.__tree_node_dragged;if(!t)return t=window.__av_item_dragged,void(t&&(t._nodeTarget=s));let i=s;if(t.id==i.id)return void console.warn("Cannot parent node to itself!");const n=function(e,t){var s=!1;for(var i of t.children){if(i.id==e.id)return!0;s=s||n(e,i)}return s};if(n(i,t))return void console.warn("Cannot parent node to a current child!");if(a.onevent){const s=new o(o.NODE_DRAGGED,t,i,e);a.onevent(s)}const l=t.parent.children.findIndex(e=>e.id==t.id),r=t.parent.children.splice(l,1);i.children.push(r[0]),a.refresh(),delete window.__tree_node_dragged}));let f=!1;d&&p.querySelector("a.hierarchy").addEventListener("click",function(e){if(f=!0,e.stopImmediatePropagation(),e.stopPropagation(),e.altKey){const e=function(t){for(var s of(t.closed=!t.closed,t.children))e(s)};e(s)}else s.closed=!s.closed;if(a.onevent){const t=new o(o.NODE_CARETCHANGED,s,s.closed,e);a.onevent(t)}a.frefresh(s.id)});const C=document.createElement("div");if(p.appendChild(C),s.actions)for(let e=0;e<s.actions.length;++e){const t=s.actions[e],i=new l(null,"",(e,i)=>{i.stopPropagation(),t.callback&&t.callback(s,e,i)},{icon:t.icon,swap:t.swap,title:t.name,hideName:!0,className:"p-0 m-0",buttonClass:"p-0 m-0 bg-none no-h"});i.root.style.minWidth="fit-content",i.root.style.margin="0",i.root.style.padding="0";const o=i.root.querySelector("button");o.style.minWidth="fit-content",o.style.margin="0",o.style.padding="0",C.appendChild(i.root)}if(!s.skipVisibility){const e=new l(null,"",(e,t)=>{if(t.stopPropagation(),s.visible=void 0!==s.visible&&!s.visible,a.onevent){const e=new o(o.NODE_VISIBILITY,s,s.visible,t);a.onevent(e)}},{icon:s.visible?"Eye":"EyeOff",swap:s.visible?"EyeOff":"Eye",title:"Toggle visible",className:"p-0 m-0",buttonClass:"bg-none"});C.appendChild(e.root)}const v=function(e,t){if(e.id==t)return!0;let s=!1;for(var i of e?.children??[])s=s||v(i,t);return s},y=v(s,n);if(!s.closed||y)for(c=0;c<s.children.length;++c){let e=s.children[c];this.options.onlyFolders&&"folder"!=e.type||this._createItem(s,e,i+1,n)}}refresh(e,t){if(this.data=e??this.data,this.domEl.querySelector("ul").innerHTML="",this.data.constructor===Object)this._createItem(null,this.data,0,t);else for(let e of this.data)this._createItem(null,e,0,t)}frefresh(e){this.refresh();var t=this.domEl.querySelector(`#${e}`);t&&t.focus()}select(e){const t=this.domEl.querySelector(".lexnodetreefilter");if(t&&(t.value=""),this.refresh(null,e),this.domEl.querySelectorAll(".selected").forEach(e=>e.classList.remove("selected")),!e)return void(this.selected.length=0);const s=this.domEl.querySelector("#"+e);console.assert(s,"NodeTree: Can't select node "+e),s.classList.add("selected"),this.selected=[s.treeData],s.focus()}deleteNode(e){const t=this.data.constructor===Array;if(e.parent){let t=e.parent.children;const s=t.indexOf(e);t.splice(s,1)}else{if(!t)return console.warn("NodeTree: Can't delete root node from object data!"),!1;{const t=this.data.indexOf(e);console.assert(t>-1,"NodeTree: Can't delete root node "+e.id+" from data array!"),this.data.splice(t,1)}}return!0}}t.NodeTree=D;class z extends a{innerTree;constructor(e,s,i={}){i.hideName=!0,super(n.TREE,e,null,i);let o=document.createElement("div");if(o.className="lextree",this.root.appendChild(o),e){let t=document.createElement("span");t.innerHTML=e,o.appendChild(t)}let a=document.createElement("div");if(a.className="lextreetools",e||(a.className+=" notitle"),i.icons)for(let e of i.icons){const s=t.makeIcon(e.icon,{title:e.name});s.addEventListener("click",e.callback),a.appendChild(s)}i.filter=i.filter??!0;let l=null;if(i.filter){l=document.createElement("input"),l.className="lexnodetreefilter",l.setAttribute("placeholder","Filter.."),l.style.width="100%",l.addEventListener("input",()=>{this.innerTree.refresh()});let e=t.makeIcon("Search");a.appendChild(l),a.appendChild(e)}(i.icons||i.filter)&&o.appendChild(a);let r=document.createElement("ul");r.addEventListener("contextmenu",function(e){e.preventDefault()}),o.appendChild(r),this.innerTree=new D(o,s,i)}}t.Tree=z;class B extends a{constructor(e,s,o,a={}){const l=a.pattern??"xxx-xxx",r=(l.match(/x/g)||[]).length;(s=String(s)).length||(s="x".repeat(r)),super(n.OTP,e,s,a),this.onGetValue=()=>+s,this.onSetValue=(t,n,a)=>{d(s=t),n||this._trigger(new i(e,+t,a),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${t})`},this.disabled=a.disabled??!1;const c=document.createElement("div");c.className="lexotp flex flex-row items-center",this.root.appendChild(c);const h=l.split("-"),d=e=>{c.innerHTML="";let s=0,i=0;for(let o=0;o<h.length;++o){const n=h[o];for(let o=0;o<n.length;++o){let a=e[s++];a="x"==a?"":a;const l=t.makeContainer(["36px","30px"],"lexotpslot border-top border-bottom border-left px-3 cursor-text select-none font-medium outline-none",a,c);l.tabIndex="1",this.disabled&&l.classList.add("disabled");const r=s;0==o?l.className+=" rounded-l":o==n.length-1&&(l.className+=" rounded-r border-right"),l.addEventListener("click",()=>{if(this.disabled)return;c.querySelectorAll(".lexotpslot").forEach(e=>e.classList.remove("active"));const e=c.querySelectorAll(".lexotpslot")[i];e.classList.add("active"),e.focus()}),l.addEventListener("blur",()=>{this.disabled||t.doAsync(()=>{c.contains(document.activeElement)||c.querySelectorAll(".lexotpslot").forEach(e=>e.classList.remove("active"))},10)}),l.addEventListener("keyup",t=>{if(!this.disabled)if(/[^0-9]+/g.test(t.key))if("ArrowLeft"==t.key||"ArrowRight"==t.key){const e="ArrowLeft"==t.key?-1:1,s=c.querySelectorAll(".lexotpslot")[i+e];s&&(c.querySelectorAll(".lexotpslot")[i].classList.remove("active"),s.classList.add("active"),s.focus(),i+=e)}else"Enter"!=t.key||e.includes("x")||this.set(e);else{const s=t.key;console.assert(!Number.isNaN(parseInt(s))),l.innerHTML=s,e=e.substring(0,r-1)+s+e.substring(r);const o=c.querySelectorAll(".lexotpslot")[i+1];o?(c.querySelectorAll(".lexotpslot")[i].classList.remove("active"),o.classList.add("active"),o.focus(),i++):this.set(e)}})}o<h.length-1&&t.makeContainer(["auto","auto"],"mx-2","-",c)}console.assert(s==e.length,"OTP Value/Pattern Mismatch!")};d(s)}}t.OTPInput=B;class H extends a{constructor(e,s,o,a={}){super(n.PAD,e,null,a),this.onGetValue=()=>c.value.xy,this.onSetValue=(t,s,n)=>{c.value.set(t[0],t[1]),h(c.value),s||this._trigger(new i(e,c.value.xy,n),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};var l=document.createElement("div");l.className="lexpad",this.root.appendChild(l);let r=document.createElement("div");r.id="lexpad-"+e,r.className="lexinnerpad",r.style.width=a.padSize??"96px",r.style.height=a.padSize??"96px",l.appendChild(r);let c=document.createElement("div");c.className="lexpadthumb",c.value=new O(s[0],s[1]),c.min=a.min??0,c.max=a.max??1,r.appendChild(c);let h=e=>{const[s,i]=[r.offsetWidth,r.offsetHeight],o=new O(t.remapRange(e.x,c.min,c.max,0,1),t.remapRange(e.y,c.min,c.max,0,1));c.style.transform=`translate(calc( ${s*o.x}px - 50% ), calc( ${i*o.y}px - 50%)`};r.addEventListener("mousedown",function(e){if(document.activeElement==c)return;var t=d.root.ownerDocument;t.addEventListener("mousemove",u),t.addEventListener("mouseup",p),document.body.classList.add("nocursor"),document.body.classList.add("noevents"),e.stopImmediatePropagation(),e.stopPropagation(),c.classList.add("active"),a.onPress&&a.onPress.bind(c)(e,c)});let d=this;function u(s){const n=r.getBoundingClientRect(),a=new O(s.x-n.x,s.y-n.y);a.clp(0,r.offsetWidth,a);const[l,h]=[r.offsetWidth,r.offsetHeight],u=a.div(new O(r.offsetWidth,r.offsetHeight));c.style.transform=`translate(calc( ${l*u.x}px - 50% ), calc( ${h*u.y}px - 50%)`,c.value=new O(t.remapRange(u.x,0,1,c.min,c.max),t.remapRange(u.y,0,1,c.min,c.max)),d._trigger(new i(e,c.value.xy,s),o),s.stopPropagation(),s.preventDefault()}function p(e){var t=d.root.ownerDocument;t.removeEventListener("mousemove",u),t.removeEventListener("mouseup",p),document.body.classList.remove("nocursor"),document.body.classList.remove("noevents"),c.classList.remove("active"),a.onRelease&&a.onRelease.bind(c)(e,c)}t.doAsync(()=>{this.onResize(),h(c.value)})}}t.Pad=H;class F extends a{constructor(e,s,o={}){super(n.PROGRESS,e,s,o),this.onGetValue=()=>l.value,this.onSetValue=(s,n,a)=>{s=t.clamp(s,l.min,l.max),this.root.querySelector("meter").value=s,r(),this.root.querySelector("span")&&(this.root.querySelector("span").innerText=s),n||this._trigger(new i(e,s,a),o.callback)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=`calc( 100% - ${t})`};const a=document.createElement("div");a.className="lexprogress",this.root.appendChild(a);let l=document.createElement("meter");l.id="lexprogressbar-"+e,l.className="lexprogressbar",l.step="any",l.min=o.min??0,l.max=o.max??1,l.low=o.low??l.low,l.high=o.high??l.high,l.optimum=o.optimum??l.optimum,l.value=s,a.appendChild(l);const r=()=>{let e=t.getThemeColor("global-selected");null!=l.low&&l.value<l.low?e=t.getThemeColor("global-color-error"):null!=l.high&&l.value<l.high&&(e=t.getThemeColor("global-color-warning")),l.style.background=`color-mix(in srgb, ${e} 20%, transparent)`};if(o.showValue){const t=document.getElementById("progressvalue-"+e);t&&t.remove();let i=document.createElement("span");i.id="progressvalue-"+e,i.style.padding="0px 5px",i.innerText=s,a.appendChild(i)}if(o.editable){l.classList.add("editable");let e=e=>{var o=this.root.ownerDocument;o.addEventListener("mousemove",s),o.addEventListener("mouseup",i),document.body.classList.add("noevents"),l.classList.add("grabbing"),e.stopImmediatePropagation(),e.stopPropagation();const n=l.getBoundingClientRect(),a=t.round(t.remapRange(e.offsetX,0,n.width,l.min,l.max));this.set(a,!1,e)},s=e=>{if(0!=e.movementX){const s=l.getBoundingClientRect(),i=t.round(t.remapRange(e.offsetX-s.x,0,s.width,l.min,l.max));this.set(i,!1,e)}e.stopPropagation(),e.preventDefault()},i=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",s),t.removeEventListener("mouseup",i),document.body.classList.remove("noevents"),l.classList.remove("grabbing")};l.addEventListener("mousedown",e)}r(),t.doAsync(this.onResize.bind(this))}}t.Progress=F;class $ extends a{constructor(e,t,s,o,a={}){super(n.RADIO,e,null,a);let l=null;this.onGetValue=()=>{const e=r.querySelectorAll("button");return l?[l,e[l]]:void 0},this.onSetValue=(e,t,n)=>{e=e[0]??e,console.assert(e.constructor==Number,"RadioGroup _value_ must be an Array index!");const a=r.querySelectorAll("button");a.forEach(e=>{e.checked=!1,e.classList.remove("checked")});const l=a[e];l.checked=!l.checked,l.classList.toggle("checked"),t||this._trigger(new i(null,[e,s[e]],n),o)};var r=document.createElement("div");r.className="lexradiogroup "+(a.className??""),this.root.appendChild(r);let c=document.createElement("span");c.innerHTML=t,r.appendChild(c);for(let e=0;e<s.length;++e){const t=document.createElement("div");t.className="lexradiogroupitem",r.appendChild(t);const i=document.createElement("button");i.className="flex p-0 rounded-lg cursor-pointer",i.disabled=a.disabled??!1,t.appendChild(i),i.addEventListener("click",t=>{this.set(e,!1,t)});const o=document.createElement("span");i.appendChild(o);const n=document.createElement("span");n.innerHTML=s[e],t.appendChild(n)}a.selected&&(console.assert(a.selected.constructor==Number,"RadioGroup _selected_ must be an Array index!"),l=a.selected,this.set(l,!0))}}t.RadioGroup=$;class V extends a{_maxSlider=null;_labelTooltip=null;setLimits;constructor(e,s,o,l={}){const r=t.deepCopy(s);super(n.RANGE,e,t.deepCopy(r),l);const c=s.constructor==Array&&2==s.length;c&&(s=r[0],l.fill=!1),this.onGetValue=()=>{let e=s;return c?e=[s,r[1]]:l.left&&(e=+d.max-s+ +d.min),e},this.onSetValue=(n,a,u)=>{let p="";const m=l.max-l.min;if(c&&this._maxSlider){d.value=s=t.clamp(+n[0],+d.min,+d.max),this._maxSlider.value=r[1]=t.clamp(+n[1],+d.min,+d.max);const e=s/m-.5,i=r[1]/m-.5,o=t.remapRange(s,l.min,l.max,0,1),a=t.remapRange(r[1],l.min,l.max,0,1);d.style.setProperty("--range-min-value",100*o+"%"),d.style.setProperty("--range-max-value",100*a+"%"),d.style.setProperty("--range-fix-min-offset",-e+"rem"),d.style.setProperty("--range-fix-max-offset",`${i}rem`),h.dataset.tooltipOffsetX=""+(h.offsetWidth*o+h.offsetWidth*(a-o)*.5-.5*h.offsetWidth),p=`${s} - ${r[1]}`}else{if(isNaN(n))return;d.value=s=t.clamp(+n,+d.min,+d.max);const e=.5*t.remapRange(s,l.min,l.max,0,1);h.dataset.tooltipOffsetX=""+(h.offsetWidth*e-.5*h.offsetWidth),p=`${s}`}if(h.dataset.tooltipContent=p,this._labelTooltip&&(this._labelTooltip.innerHTML=p),!a){let t=s;c?t=[s,r[1]]:l.left&&(t=+d.max-s+ +d.min),this._trigger(new i(e,t,u),o)}},this.onResize=e=>{const i=this.root.domName?.style.width??"0px";if(h.style.width=l.inputWidth??`calc( 100% - ${i})`,c){const e=l.max-l.min,i=s/e-.5,o=r[1]/e-.5;d.style.setProperty("--range-min-value",100*t.remapRange(s,l.min,l.max,0,1)+"%"),d.style.setProperty("--range-max-value",100*t.remapRange(r[1],l.min,l.max,0,1)+"%"),d.style.setProperty("--range-fix-min-offset",-i+"rem"),d.style.setProperty("--range-fix-max-offset",`${o}rem`)}};const h=document.createElement("div");h.className="lexrange relative",this.root.appendChild(h);let d=document.createElement("input");if(d.className="lexrangeslider "+(c?"pointer-events-none ":"")+(l.className??""),d.min=l.min??0,d.max=l.max??100,d.step=l.step??1,d.type="range",d.disabled=l.disabled??!1,s.constructor==Number&&(s=t.clamp(s,+d.min,+d.max)),l.left&&(s=+d.max-s+ +d.min,d.classList.add("left")),(l.fill??1)||d.classList.add("no-fill"),d.value=s,h.appendChild(d),d.addEventListener("input",e=>{this.set(c?[Math.min(e.target.valueAsNumber,r[1]),r[1]]:e.target.valueAsNumber,!1,e)},{passive:!1}),c||(d.addEventListener("mousedown",function(e){l.onPress&&l.onPress.bind(d)(e,d)},!1),d.addEventListener("mouseup",function(e){l.onRelease&&l.onRelease.bind(d)(e,d)},!1)),this.setLimits=(e,t,s)=>{d.min=e??d.min,d.max=t??d.max,d.step=s??d.step,a._dispatchEvent(d,"input",!0)},t.doAsync(()=>{this.onResize();let e=0;if(c){const i=t.remapRange(s,l.min,l.max,0,1),o=t.remapRange(r[1],l.min,l.max,0,1);e=h.offsetWidth*i+h.offsetWidth*(o-i)*.5-.5*h.offsetWidth}else{const i=.5*t.remapRange(s,l.min,l.max,0,1);e=h.offsetWidth*i-.5*h.offsetWidth}t.asTooltip(h,`${s}${c?`- ${r[1]}`:""}`,{offsetX:e,callback:e=>{this._labelTooltip=e}})}),r.constructor==Array){let e=document.createElement("input");e.className="lexrangeslider no-fill pointer-events-none overlap absolute top-0 left-0 "+(l.className??""),e.min=l.min??0,e.max=l.max??100,e.step=l.step??1,e.type="range",e.disabled=l.disabled??!1,this._maxSlider=e;let i=r[1];e.value=i=t.clamp(i,+e.min,+e.max),h.appendChild(e),e.addEventListener("input",e=>{r[1]=Math.max(s,+e.target.valueAsNumber),this.set([s,r[1]],!1,e)},{passive:!1})}}}t.RangeInput=V;class K extends a{constructor(e,s,o,a={}){const l=a.allowHalf??!1;l||(s=Math.floor(s)),super(n.RATE,e,s,a),this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{u(s=t),n||this._trigger(new i(e,t,a),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${t})`};const r=document.createElement("div");r.className="lexrate relative",this.root.appendChild(r);const c=t.makeContainer(["fit-content","auto"],"flex flex-row gap-1","",r),h=t.makeContainer(["fit-content","auto"],"absolute top-0 flex flex-row gap-1 pointer-events-none","",r),d=t.makeContainer(["fit-content","auto"],"absolute top-0 flex flex-row gap-1 pointer-events-none","",r);c.addEventListener("mousemove",e=>{const t=e.target,s=t.dataset.idx;if(void 0!==s){const i=t.getBoundingClientRect(),o=l&&e.offsetX<.5*i.width;u(s-(o?.5:0))}},!1),c.addEventListener("mouseleave",e=>{u(s)},!1);for(let e=0;e<5;++e){const s=t.makeIcon("Star",{svgClass:"lg fill-current fg-secondary"});s.dataset.idx=e+1,c.appendChild(s),s.addEventListener("click",e=>{const t=e.target,s=t.getBoundingClientRect(),i=l&&e.offsetX<.5*s.width;this.set(parseFloat(t.dataset.idx)-(i?.5:0))},!1);const i=t.makeIcon("Star",{svgClass:"lg fill-current fg-yellow-500"});h.appendChild(i);const o=t.makeIcon("StarHalf",{svgClass:"lg fill-current fg-yellow-500"});d.appendChild(o)}const u=e=>{for(let t=0;t<5;++t){const s=e>t+.5,i=h.childNodes[t],o=d.childNodes[t];if(s)i.style.opacity=1;else{i.style.opacity=0;const s=l&&e>t;o.style.opacity=s?1:0}}};u(s),t.doAsync(this.onResize.bind(this))}}t.Rate=K;class U extends a{constructor(e,s,i,o={}){super(n.SIZE,e,s,o),this.onGetValue=()=>{const e=[];for(let t=0;t<this.root.dimensions.length;++t)e.push(this.root.dimensions[t].value());return e},this.onSetValue=(e,t,s)=>{for(let s=0;s<this.root.dimensions.length;++s)this.root.dimensions[s].set(e[s],t)},this.root.aspectRatio=2==s.length?s[0]/s[1]:null,this.root.dimensions=[];for(let e=0;e<s.length;++e){const n=new t.Panel;if(this.root.dimensions[e]=n.addNumber(null,s[e],t=>{const s=this.value();if(this.root.locked){const i=0==e?1/this.root.aspectRatio:this.root.aspectRatio,o=(1+e)%2;s[o]=t*i,this.root.dimensions[o].set(s[o],!0)}i&&i(s)},{min:0,disabled:o.disabled,precision:o.precision,className:"flex-fill"}),this.root.appendChild(this.root.dimensions[e].root),e+1!=s.length){const e=t.makeIcon("X",{svgClass:"fg-accent font-bold"});this.root.appendChild(e)}}if(o.units){let e=document.createElement("span");e.className="select-none fg-tertiary font-medium",e.innerText=o.units,this.root.appendChild(e)}if(this.root.aspectRatio){const e=new l(null,"",e=>{if(this.root.locked=e,e){const e=this.value();this.root.aspectRatio=e[0]/e[1]}},{title:"Lock Aspect Ratio",icon:"LockOpen",swap:"Lock",buttonClass:"bg-none p-0"});this.root.appendChild(e.root)}}}t.SizeInput=U;class G{static ITEMS_PER_PAGE_VALUES=[8,12,24,48,96];root;pagesRoot;page=1;pages=1;_alwaysShowEdges=!0;_useEllipsis=!0;_maxButtons=3;_itemsPerPage=12;_itemsPerPageValues=G.ITEMS_PER_PAGE_VALUES;onChange=()=>{};onItemsPerPageChange=()=>{};constructor(e={}){if(this.pages=e.pages??1,this.page=t.clamp(e.page??1,1,this.pages),this._alwaysShowEdges=e.alwaysShowEdges??this._alwaysShowEdges,this._useEllipsis=e.useEllipsis??this._useEllipsis,this._maxButtons=e.maxButtons??this._maxButtons,this._itemsPerPage=e.itemsPerPage??this._itemsPerPage,-1===this._itemsPerPageValues.indexOf(this._itemsPerPage)&&(this._itemsPerPageValues.push(this._itemsPerPage),this._itemsPerPageValues=this._itemsPerPageValues.sort((e,t)=>e<t?-1:e>t?1:0)),"function"==typeof e.onChange&&(this.onChange=e.onChange),"function"==typeof e.onItemsPerPageChange&&(this.onItemsPerPageChange=e.onItemsPerPageChange),this.root=t.makeContainer(["auto","auto"],"flex flex-row gap-2 "+(e.className??"")),e.allowChangeItemsPerPage){const e=t.makeContainer(["auto","auto"],"flex flex-row items-center","",this.root),s=new u(null,G.ITEMS_PER_PAGE_VALUES,this._itemsPerPage,e=>{this._itemsPerPage=e,this.onItemsPerPageChange?.(this._itemsPerPage)},{overflowContainer:null});e.appendChild(s.root)}this.pagesRoot=t.makeContainer(["auto","auto"],"flex flex-row overflow-scroll","",this.root),this.refresh()}setPage(e){const s=t.clamp(e,1,this.pages);s!==this.page&&(this.page=s,this.refresh(),this._emitChange())}setPages(e){this.pages=Math.max(1,e),this.page>this.pages&&(this.page=this.pages),this.refresh()}next(){this.setPage(this.page+1)}prev(){this.setPage(this.page-1)}refresh(){this.pagesRoot.innerHTML="",this._makeButton(t.makeIcon("ChevronLeft").innerHTML,1===this.page,()=>this.prev(),"bg-none "+(1===this.page?"":"hover:bg-tertiary"));const e=t.makeContainer(["auto","auto"],"flex flex-row items-center","",this.pagesRoot),s=this._maxButtons+2;if(this.pages<=s)for(let t=1;t<=this.pages;t++)this._makePageButton(e,t);else{const i=this.page,o=this.pages,n=1,a=o,l=this._alwaysShowEdges?1:0,r=s-2,c=Math.floor(r/2);let h=Math.max(1+l,i-c),d=Math.min(o-l,i+c);h<=2&&(h=1+l,d=h+r-1),d>=o-1&&(d=o-l,h=d-r+1),this._alwaysShowEdges&&this._makePageButton(e,n),this._useEllipsis&&h>2&&t.makeElement("span","h-6 px-2 text-lg font-semibold whitespace-nowrap","...",e);for(let t=h;t<=d;t++)this._makePageButton(e,t);this._useEllipsis&&d<o-1&&t.makeElement("span","h-6 px-2 text-lg font-semibold whitespace-nowrap","...",e),this._alwaysShowEdges&&this._makePageButton(e,a)}this._makeButton(t.makeIcon("ChevronRight").innerHTML,this.page===this.pages,()=>this.next(),"bg-none "+(this.page===this.pages?"":"hover:bg-tertiary"))}_emitChange(){this.onChange?.(this.page),this.root.dispatchEvent(new CustomEvent("change",{detail:{page:this.page}}))}_makeButton(e,t,s,i,o){const n=new l(null,e,s,{disabled:t,buttonClass:i});return n.root.querySelector("button").style.paddingInline="0.5rem",(o=o??this.pagesRoot).appendChild(n.root),n.root}_makePageButton(e,t){const s=t===this.page?"bg-secondary border":"bg-none";return this._makeButton(String(t),!1,()=>this.setPage(t),s,e)}}t.Pagination=G;class W extends a{data;filter;customFilters;activeCustomFilters;rowOffsetCount=0;_currentFilter;_toggleColumns;_sortColumns;_resetCustomFiltersBtn=null;_hiddenColumns=[];_paginator;_showSelectedNumber;_centered;get centered(){return this._centered}set centered(e){this._setCentered(e)}_rowsPerPage=-1;get rowsPerPage(){return this._rowsPerPage}set rowsPerPage(e){this._setRowsPerPage(e)}constructor(e,s,i={}){if(!s)throw"Data is needed to create a table!";super(n.TABLE,e,null,i),this.onResize=e=>{const t=this.root.domName?.style.width??"0px";o.style.width=`calc( 100% - ${t})`};const o=document.createElement("div");o.className="lextable",this.root.appendChild(o),this._centered=i.centered??!1,!0===this._centered&&o.classList.add("centered"),this.data=s,this.filter=i.filter??!1,this.customFilters=i.customFilters,this.activeCustomFilters={},this._toggleColumns=i.toggleColumns??!1,this._sortColumns=i.sortColumns??!0,this._showSelectedNumber=i.showSelectedNumber??!0,this._currentFilter=i.filterValue,this._hiddenColumns=i.hiddenColumns??[],s.head=s.head??[],s.body=s.body??[],s.checkMap={},s.colVisibilityMap={},s.head.forEach((e,t)=>{const i=this._hiddenColumns.indexOf(e),o=!this._toggleColumns||-1===i;s.colVisibilityMap[t]=o}),i.pagination&&(this._rowsPerPage=i.rowsPerPage??12,this._paginator=new G({pages:this._getNumPages(),itemsPerPage:this._rowsPerPage,allowChangeItemsPerPage:i.allowChangeItemsPerPage??!0,onChange:this._onChangePage.bind(this),onItemsPerPageChange:e=>{this.rowsPerPage=e}}));const a=e=>{const t=e.match(/^(\d{1,2})[\/-](\d{1,2})[\/-](\d{2}|\d{4})$/);if(!t)return null;let s=Number(t[1]),i=Number(t[2])-1,o=Number(t[3]);o<100&&(o+=2e3);const n=new Date(o,i,s);return n.getFullYear()!==o||n.getMonth()!==i||n.getDate()!==s?null:n},r=(e,t,s,i)=>{const o=s[e],n=i[e],l=a(o),r=a(n);if(l&&r)return l.getTime()<r.getTime()?-t:l.getTime()>r.getTime()?t:0;const c=Number(o),h=Number(n);return isNaN(c)||isNaN(h)?o<n?-t:o>n?t:0:c<h?-t:c>h?t:0},c=(e,t)=>{s.body=s.body.sort(r.bind(this,e,t)),this.refresh()},h=this;if(this.filter||this.customFilters||this._toggleColumns){const e=t.makeContainer(["100%","auto"],"flex flex-row mb-2");if(this.filter){const s=t.deepCopy(i);s.placeholder=`Filter ${this.filter}...`,s.skipComponent=!0,s.trigger="input",s.inputClass="outline";let o=new d(null,this._currentFilter??"",e=>{this._currentFilter=e,this.refresh()},s);e.appendChild(o.root)}if(null!==this.customFilters){const s=t.makeIcon("CirclePlus",{svgClass:"sm"}),i='<div class="lexcontainer border-right self-center mx-1" style="width: 1px; height: 70%;"></div>';for(let o of this.customFilters)o.component=new l(null,s.innerHTML+o.name,e=>{const n=o.component.root.querySelector("span");if(o.options){const e=o.options.map((e,a)=>{const l={name:e,checked:!!this.activeCustomFilters[e],callback:(e,a,l)=>{a?this.activeCustomFilters[e]=o.name:delete this.activeCustomFilters[e];const r=Object.keys(this.activeCustomFilters).filter(e=>this.activeCustomFilters[e]==o.name),c=r.reduce((e,s)=>e+t.badge(s,"bg-tertiary fg-secondary text-sm border-0"),"");n.innerHTML=s.innerHTML+o.name+(r.length?i:"")+c,this.refresh()}};return l});t.addDropdownMenu(o.component.root,e,{side:"bottom",align:"start"})}else if("range"==o.type){console.assert(null!=o.min&&null!=o.max,"Range filter needs min and max values!");const e=t.makeContainer(["240px","auto"],"text-md"),a=new t.Panel;t.makeContainer(["100%","auto"],"px-3 p-2 pb-0 text-md font-medium",o.name,e),o.start=o.start??o.min,o.end=o.end??o.max,a.refresh=()=>{a.clear(),a.sameLine(2,"justify-center"),a.addNumber(null,o.start,e=>{o.start=e;const a=o.start!=o.min||o.end!=o.max;n.innerHTML=s.innerHTML+o.name+(a?i+t.badge(`${o.start} - ${o.end} ${o.units??""}`,"bg-tertiary fg-secondary text-sm border-0"):""),a&&this._resetCustomFiltersBtn?.root.classList.remove("hidden"),this.refresh()},{skipSlider:!0,min:o.min,max:o.max,step:o.step,units:o.units}),a.addNumber(null,o.end,e=>{o.end=e;const a=o.start!=o.min||o.end!=o.max;n.innerHTML=s.innerHTML+o.name+(a?i+t.badge(`${o.start} - ${o.end} ${o.units??""}`,"bg-tertiary fg-secondary text-sm border-0"):""),a&&this._resetCustomFiltersBtn?.root.classList.remove("hidden"),this.refresh()},{skipSlider:!0,min:o.min,max:o.max,step:o.step,units:o.units}),a.addButton(null,"Reset",()=>{o.start=o.min,o.end=o.max,n.innerHTML=s.innerHTML+o.name,a.refresh(),this.refresh()},{buttonClass:"contrast"})},a.refresh(),e.appendChild(a.root),new v(o.component.root,[e],{side:"bottom"})}else if("date"==o.type){const e=t.makeContainer(["auto","auto"],"text-md"),a=new t.Panel;t.makeContainer(["100%","auto"],"px-3 p-2 pb-0 text-md font-medium",o.name,e),a.refresh=()=>{if(a.clear(),!o.default){const e=new Date,t=`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()}`;o.default=[t,t]}const e=new k(o.value??o.default,{onChange:a=>{o.value=a,n.innerHTML=s.innerHTML+o.name+(i+t.badge(`${e.getFullDate()}`,"bg-tertiary fg-secondary text-sm border-0")),this._resetCustomFiltersBtn?.root.classList.remove("hidden"),this.refresh()}});a.attach(e)},a.refresh(),e.appendChild(a.root),new v(o.component.root,[e],{side:"bottom"})}},{buttonClass:"px-2 primary dashed"}),e.appendChild(o.component.root);this._resetCustomFiltersBtn=new l(null,"resetButton",()=>{this.activeCustomFilters={},this._resetCustomFiltersBtn?.root.classList.add("hidden");for(let e of this.customFilters??[])e.component.root.querySelector("span").innerHTML=s.innerHTML+e.name,"range"==e.type?(e.start=e.min,e.end=e.max):"date"==e.type&&delete e.value;this.refresh()},{title:"Reset filters",tooltip:!0,icon:"X"}),e.appendChild(this._resetCustomFiltersBtn?.root),this._resetCustomFiltersBtn?.root.classList.add("hidden")}if(this._toggleColumns){const i=t.makeIcon("Settings2"),o=new l("toggleColumnsBtn",i.innerHTML+"View",(e,i)=>{const o=s.head.map((e,t)=>{const i={name:e,icon:"Check",callback:()=>{s.colVisibilityMap[t]=!s.colVisibilityMap[t];u.querySelectorAll(`tr > *:nth-child(${t+this.rowOffsetCount+1})`).forEach(e=>{e.style.display="none"===e.style.display?"":"none"})}};return s.colVisibilityMap[t]||delete i.icon,i});t.addDropdownMenu(i.target,o,{side:"bottom",align:"end"})},{hideName:!0});e.appendChild(o.root),o.root.style.marginLeft="auto"}o.appendChild(e)}const u=document.createElement("table");t.addClass(u,i.tableClass),o.appendChild(u),this.refresh=()=>{this._currentFilter=this._currentFilter??"",u.innerHTML="",this.rowOffsetCount=0;{const e=document.createElement("thead");e.className="lextablehead",u.appendChild(e);const o=document.createElement("tr");if(i.sortable){const e=document.createElement("th");e.style.width="0px",o.appendChild(e),this.rowOffsetCount++}if(i.selectable){const e=document.createElement("th");e.style.width="0px";const i=document.createElement("input");i.type="checkbox",i.className="lexcheckbox accent",i.checked=s.checkMap[":root"]??!1,e.appendChild(i),i.addEventListener("change",function(){s.checkMap[":root"]=this.checked;const e=u.querySelector("tbody");for(const t of e.childNodes){const e=t.getAttribute("rowId");e&&(s.checkMap[e]=this.checked,t.querySelector("input[type='checkbox']").checked=this.checked)}const i=h.getSelectedRows();t.emitSignal("@rows_selected_changed",i.length)}),this.rowOffsetCount++,o.appendChild(e)}for(const e of s.head){const n=document.createElement("th");n.innerHTML=`<span>${e}</span>`,n.querySelector("span").appendChild(t.makeIcon("MenuArrows",{svgClass:"sm"}));const a=s.head.indexOf(e);this._centered?.indexOf&&(this._centered.indexOf(a)>-1||this._centered.indexOf(e)>-1)&&n.classList.add("centered");const l=[];if(i.columnActions)for(let e of i.columnActions)e.name?l.push({name:e.name,icon:e.icon,className:e.className,callback:()=>{const t=this.data.body.map(e=>[e[a]]);e.callback(t,u)&&this.refresh()}}):console.warn("Invalid column action (missing name):",e);this._sortColumns&&(l.length>0&&l.push(null),l.push({name:"Asc",icon:"ArrowUpZA",callback:c.bind(this,a,1)},{name:"Desc",icon:"ArrowDownZA",callback:c.bind(this,a,-1)})),this._toggleColumns&&(l.length>0&&l.push(null),l.push({name:"Hide",icon:"EyeOff",callback:()=>{s.colVisibilityMap[a]=!1;u.querySelectorAll(`tr > *:nth-child(${a+this.rowOffsetCount+1})`).forEach(e=>{e.style.display="none"===e.style.display?"":"none"})}})),n.addEventListener("click",e=>{0!==l.length&&t.addDropdownMenu(e.target,l,{side:"bottom",align:"start"})}),o.appendChild(n)}if(i.rowActions){const e=document.createElement("th");e.className="sm",o.appendChild(e)}e.appendChild(o)}{const e=document.createElement("tbody");e.className="lextablebody",u.appendChild(e);let o=null,n=!1,a=null;document.addEventListener("mouseup",e=>{if(null===o)return;document.removeEventListener("mousemove",l);const i=u.rows[o];if(i.dY=0,i.classList.remove("dragging"),Array.from(u.rows).forEach(e=>{e.style.transform="",e.style.transition="none"}),t.flushCss(i),a){const e=this._paginator?(this._paginator.page-1)*this.rowsPerPage:0,i=o-1+e,n=a[1]-1+e;t.emitSignal("@on_table_sort",{instance:this,fromIdx:i,targetIdx:n});const l=s.body[i];let r=0;if(i==n)return;if(i>n)for(let e=i;e>n;--e)s.body[e]=s.body[e-1];else{r=1;for(let e=i;e<n;++e)s.body[e]=s.body[e+1]}s.body[n]=l;const c=a[0].parentNode;t.insertChildAtIndex(c,a[0],n+r-e),a=null}o=null,t.doAsync(()=>{Array.from(u.rows).forEach(e=>{e.style.transition="transform 0.2s ease-in"})})});let l=e=>{if(!o)return;const t=u.rows[o];t.dY=t.dY??0,t.dY+=e.movementY,t.style.transform=`translateY(${t.dY}px)`};const r=[];for(let e=0;e<s.body.length;++e){const i=s.body[e];if(this.filter){const e=s.head.indexOf(this.filter);if(e>-1){if(!t.stripHTML(i[e]).toLowerCase().includes(this._currentFilter.toLowerCase()))continue}}if(Object.keys(this.activeCustomFilters).length){let e={};this._resetCustomFiltersBtn?.root.classList.remove("hidden");for(let o in this.activeCustomFilters){const n=this.activeCustomFilters[o];e[n]=e[n]??!1;const a=s.head.indexOf(n);if(a>-1){const s=i[a],l=t.stripTags(s)??s;e[n]=e[n]||l===o}}if(!Object.values(e).reduce((e,t)=>e&&t,!0))continue}if(this.customFilters){let e={};for(let o of this.customFilters){const n=o.name;if("range"==o.type){e[n]=e[n]??!1;const t=s.head.indexOf(n);if(t>-1){const s=parseFloat(i[t]),a=o.start??o.min,l=o.end??o.max;e[n]=e[n]||s>=a&&s<=l}}else if("date"==o.type){e[n]=e[n]??!1;const a=s.head.indexOf(n);if(a>-1){if(!o.value){e[n]=!0;continue}o.value=o.value??o.default;const s=i[a],l=t.dateFromDateString(s),r=t.dateFromDateString(o.value[0]),c=t.dateFromDateString(o.value[1]);e[n]=e[n]||l>=r&&l<=c}}}if(!Object.values(e).reduce((e,t)=>e&&t,!0))continue}r.push(i)}this._paginator&&this._paginator.setPages(this._getNumPages(r.length));const c=this._paginator?(this._paginator.page-1)*this.rowsPerPage:0,d=this._paginator?Math.min(c+this.rowsPerPage,r.length):r.length;for(let p=c;p<d;++p){const c=r[p],d=this.data.body.indexOf(c),m=document.createElement("tr"),g=this._makeRowId(c);if(m.setAttribute("rowId",g),i.sortable){const e=document.createElement("td");e.style.width="0px";const s=t.makeIcon("GripVertical");e.appendChild(s),s.draggable=!0,s.addEventListener("dragstart",e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),o=m.rowIndex,m.classList.add("dragging"),document.addEventListener("mousemove",l)},!1),m.addEventListener("mouseenter",function(e){if(e.preventDefault(),null!=o&&this.rowIndex!=o&&n!=this.rowIndex){n=this.rowIndex;const e=u.rows[o],s=""!=this.style.transform;this.rowIndex>o?(a=[e,s?this.rowIndex-1:this.rowIndex],this.style.transform=s?"":`translateY(-${this.offsetHeight}px)`):(a=[e,s?this.rowIndex+1:this.rowIndex],this.style.transform=s?"":`translateY(${this.offsetHeight}px)`),t.doAsync(()=>{n=!1})}}),m.appendChild(e)}if(i.selectable){const e=document.createElement("td"),i=document.createElement("input");i.type="checkbox",i.className="lexcheckbox accent",i.checked=s.checkMap[g],e.appendChild(i),i.addEventListener("change",function(){s.checkMap[g]=this.checked;const e=u.querySelector("thead input[type='checkbox']");if(console.assert(e,"Header checkbox not found!"),this.checked){Array.from(u.querySelectorAll("tbody input[type='checkbox']")).filter(e=>!e.checked).length||(e.checked=s.checkMap[":root"]=!0)}else e.checked=s.checkMap[":root"]=!1;const i=h.getSelectedRows();t.emitSignal("@rows_selected_changed",i.length)}),m.appendChild(e)}for(let e=0;e<c.length;++e){const t=c[e],i=document.createElement("td");i.innerHTML=`${t}`;const o=s.head[e];this._centered?.indexOf&&(this._centered.indexOf(e)>-1||this._centered.indexOf(o)>-1)&&i.classList.add("centered"),m.appendChild(i)}if(i.rowActions){const e=document.createElement("td");e.style.width="0px";const o=document.createElement("div");o.className="lextablebuttons",e.appendChild(o);for(const e of i.rowActions){let n=null;"delete"==e?(n=t.makeIcon("Trash3",{title:"Delete Row"}),n.addEventListener("click",()=>{s.body.splice(d,1),this.refresh()})):"menu"==e?(n=t.makeIcon("EllipsisVertical",{title:"Menu"}),n.addEventListener("click",function(e){if(!i.onMenuAction)return;const o=i.onMenuAction(d,s);console.assert(o.length,"Add items to the Menu Action Dropdown!"),t.addDropdownMenu(e.target,o,{side:"bottom",align:"end"})})):(console.assert(e.constructor==Object),n=t.makeIcon(e.icon,{title:e.title}),e.callback&&n.addEventListener("click",t=>{e.callback(d,c,u,t)&&this.refresh()})),console.assert(n),o.appendChild(n)}m.appendChild(e)}e.appendChild(m)}if(i.selectable){const e=this.getSelectedRows();t.emitSignal("@rows_selected_changed",e.length)}if(0==e.childNodes.length){const t=document.createElement("tr"),i=document.createElement("td");i.setAttribute("colspan",s.head.length+this.rowOffsetCount+1),i.className="empty-row",i.innerHTML="No results.",t.appendChild(i),e.appendChild(t)}}for(const e in s.colVisibilityMap){const t=parseInt(e);if(!s.colVisibilityMap[t]){u.querySelectorAll(`tr > *:nth-child(${t+this.rowOffsetCount+1})`).forEach(e=>{e.style.display="none"===e.style.display?"":"none"})}}};const p=this._showSelectedNumber&&i.selectable;if(p||this._paginator){const e=t.makeContainer(["100%","auto"],"flex flex-row px-3 my-1 align-center","",o);if(p){const s=t.makeContainer(["100%","auto"],"flex justify-start items-center fg-secondary","0 row(s) selected.",e);t.addSignal("@rows_selected_changed",(e,t)=>{this._showSelectedNumber&&(s.innerHTML=0===t?"":`${t??0} row(s) selected.`)})}if(this._paginator){t.makeContainer(["100%","auto"],"flex justify-end","",e).appendChild(this._paginator.root)}}this.refresh(),t.doAsync(this.onResize.bind(this))}getSelectedRows(){const e=[];for(const t of this.data.body){const s=this._makeRowId(t);!0===this.data.checkMap[s]&&e.push(t)}return e}_makeRowId(e){return t.getSupportedDOMName(e.join("-")).substr(0,32)}_onChangePage(e){this.refresh()}_getNumPages(e){return-1===this.rowsPerPage?1:(e=e??this.data.body?.length,Math.ceil((e??0)/this.rowsPerPage))}_setRowsPerPage(e){this._rowsPerPage=e,this.refresh()}_setCentered(e){if(e.constructor==Boolean){this.root.querySelector(".lextable").classList.toggle("centered",e)}else e=Array.isArray(e)?e:[e];this._centered=e,this.refresh()}}t.Table=W;class q extends a{tabs;tabDOMs;constructor(e,s,i={}){if(i.hideName=!0,super(n.TABS,e,null,i),s.constructor!=Array)throw"Param @tabs must be an Array!";if(!s.length)throw"Tab list cannot be empty!";const o=i.vertical??!0,a=!o&&(i.showNames??!1);this.tabDOMs={};let l=document.createElement("div");l.className="lextabscontainer",o||(l.className+=" horizontal");let r=document.createElement("div");r.className="tabs",l.appendChild(r),this.root.appendChild(l),s.findIndex(e=>!0===e.selected)<0&&(s[0].selected=!0);for(let e of s){console.assert(e.name);let s=document.createElement("div");s.className="lextab "+(e.selected?"selected":""),s.innerHTML=a?e.name:"",s.appendChild(t.makeIcon(e.icon??"Hash",{title:e.name,iconClass:e.iconClass,svgClass:e.svgClass})),this.tabDOMs[e.name]=s;let i=document.createElement("div");if(i.id=e.name.replace(/\s/g,""),i.className="components",i.toggleAttribute("hidden",!e.selected),l.appendChild(i),s.addEventListener("click",t=>{r.querySelectorAll(".lextab").forEach(e=>{e.classList.remove("selected")}),s.classList.add("selected"),l.querySelectorAll(".components").forEach(e=>{e.toggleAttribute("hidden",!0)});const o=l.querySelector("#"+i.id);o?.toggleAttribute("hidden"),e.onSelect&&e.onSelect(this,i)}),r.appendChild(s),e.onCreate){const s=new t.Panel;s.queue(i),e.onCreate.call(this,s,i),s.clearQueue()}}this.tabs=s}select(e){const t=this.tabDOMs[e];t&&t.click()}}t.TabSections=q;class Y extends a{generateTags;constructor(e,s,o,a={}){let l=s.replace(/\s/g,"").split(","),r=t.deepCopy(l);super(n.TAGS,e,r,a),this.options.skipDuplicates=a.skipDuplicates??!0,this.onGetValue=()=>t.deepCopy(s),this.onSetValue=(t,s,n)=>{l=[].concat(t),this.generateTags(l),s||this._trigger(new i(e,l,n),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${t})`};const c=document.createElement("div");c.className="lextags",this.root.appendChild(c),this.generateTags=e=>{c.innerHTML="";for(let s=0;s<e.length;++s){const i=e[s],o=document.createElement("span");o.className="lextag",o.innerHTML=i;const n=t.makeIcon("X",{svgClass:"sm"});o.appendChild(n),n.addEventListener("click",t=>{o.remove(),e.splice(e.indexOf(i),1),this.set(e,!1,t)}),c.appendChild(o)}let s=document.createElement("input");s.value="",s.placeholder="Add tag...",c.appendChild(s),s.onkeydown=t=>{if(" "==t.key||"Enter"==t.key){const i=s.value.replace(/\s/g,"");if(t.preventDefault(),!i.length||a.skipDuplicates&&e.indexOf(i)>-1)return;e.push(i),this.set(e,!1,t),c.querySelector("input")?.focus()}}},this.generateTags(l),t.doAsync(this.onResize.bind(this))}}t.Tags=Y;class X extends a{constructor(e,s,o,a={}){super(n.TEXTAREA,e,s,a),this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{r.value=s=t,n||this._trigger(new i(e,t,a),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=a.inputWidth??`calc( 100% - ${t})`};let l=document.createElement("div");l.className="lextextarea",l.style.display="flex",this.root.appendChild(l);let r=document.createElement("textarea");r.value=s??"",r.className=a.inputClass??"",r.style.textAlign=a.float??"",Object.assign(r.style,a.style??{}),a.fitHeight&&r.classList.add("size-content"),(a.resize??1)||r.classList.add("resize-none"),l.appendChild(r),a.disabled&&(this.disabled=!0,r.setAttribute("disabled","true")),a.placeholder&&r.setAttribute("placeholder",a.placeholder);const c=a.trigger??"default";if("default"==c?(r.addEventListener("keyup",function(e){"Enter"==e.key&&r.blur()}),r.addEventListener("focusout",e=>{this.set(e.target?.value,!1,e)})):"input"==c&&r.addEventListener("input",e=>{this.set(e.target?.value,!1,e)}),a.icon){const e=t.makeIcon(a.icon,{iconClass:"absolute z-1 ml-2",svgClass:"sm"});l.appendChild(e)}t.doAsync(()=>{l.style.height=a.height??"",this.onResize()},10)}}t.TextArea=X;class j extends a{constructor(e,s={}){if(console.assert(0!==e.length,"Can't create Title Component without text!"),super(n.TITLE,null,null,s),this.root.className=`lextitle ${this.root.className}`,s.icon){let e=t.makeIcon(s.icon,{iconClass:"mr-2"});e.querySelector("svg").style.color=s.iconColor||"",this.root.appendChild(e)}let i=document.createElement("span");if(i.innerText=e,this.root.appendChild(i),Object.assign(this.root.style,s.style??{}),null!=s.link){let t=document.createElement("a");t.innerText=e,t.href=s.link,t.target=s.target??"",t.className="lextitle link",Object.assign(t.style,s.style??{}),this.root.replaceWith(t)}}}t.Title=j;class Z extends a{constructor(e,s,o,a={}){if(!e&&!a.label)throw"Set Component Name or at least a label!";super(n.TOGGLE,e,s,a),this.onGetValue=()=>r.checked,this.onSetValue=(t,n,a)=>{t!=s&&(r.checked=s=t,this.root.querySelector(".lextogglesubmenu")?.toggleAttribute("hidden",!t),n||this._trigger(new i(e,t,a),o))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=a.inputWidth??`calc( 100% - ${t})`};var l=document.createElement("div");l.className="lextogglecont",this.root.appendChild(l);let r=document.createElement("input");r.type="checkbox",r.className="lextoggle "+(a.className??""),r.checked=s,r.iValue=s,r.disabled=a.disabled??!1,l.appendChild(r);let c=document.createElement("span");if(c.className="toggletext",c.innerHTML=a.label??"On",l.appendChild(c),r.addEventListener("change",e=>{this.set(r.checked,!1,e)}),a.suboptions){let e=document.createElement("div");e.className="lextogglesubmenu",e.toggleAttribute("hidden",!r.checked);const s=new t.Panel;s.queue(e),a.suboptions.call(this,s),s.clearQueue(),this.root.appendChild(e)}t.doAsync(this.onResize.bind(this))}}t.Toggle=Z;class J extends a{setLimits;constructor(e,s,o,r,c={}){e=t.clamp(e,2,4),o=o??new Array(e).fill(0),super(n.VECTOR,s,t.deepCopy(o),c),this.onGetValue=()=>{let e=this.root.querySelectorAll("input[type='number']"),t=[];for(var s of e)t.push(+s.value);return t},this.onSetValue=(e,n,a)=>{if(h.length==e.length){for(let s=0;s<h.length;++s){let i=e[s];i=t.clamp(i,+h[s].min,+h[s].max),i=t.round(i,c.precision)??0,h[s].value=o[s]=i}n||this._trigger(new i(s,o,a),r)}else console.error("Input length does not match vector length.")},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";d.style.width=`calc( 100% - ${t})`},this.setLimits=(e,t,s)=>{};const h=[];var d=document.createElement("div");d.className="lexvector",this.root.appendChild(d),this.disabled=c.disabled??!1;const u=this;for(let m=0;m<e;++m){let g=document.createElement("div");g.className="vecbox",g.innerHTML="<span class='"+t.Panel.VECTOR_COMPONENTS[m]+"'></span>";let f=document.createElement("input");f.className="vecinput v"+e,f.min=c.min??-1e24,f.max=c.max??1e24,f.step=c.step??"any",f.type="number",f.id="vec"+e+"_"+t.guidGenerator(),f.idx=m,h[m]=f,g.appendChild(f),o[m].constructor==Number&&(o[m]=t.clamp(o[m],+f.min,+f.max),o[m]=t.round(o[m],c.precision)),f.value=f.iValue=o[m];const C=t.makeIcon("MoveVertical",{iconClass:"drag-icon hidden-opacity",svgClass:"sm"});function v(e){if(document.activeElement!=f&&e.button==t.MOUSE_LEFT_CLICK){var s=u.root.ownerDocument;s.addEventListener("mousemove",y),s.addEventListener("mouseup",b),document.body.classList.add("noevents"),C.classList.remove("hidden-opacity"),e.stopImmediatePropagation(),e.stopPropagation(),document.pointerLockElement||g.requestPointerLock(),c.onPress&&c.onPress.bind(f)(e,f)}}function y(e){let s=-e.movementY;if(0!=s){let i=c.step??1;if(e.shiftKey?i=10:e.altKey&&(i=.1),p.locked)for(let e of h)e.value=t.round(+e.valueAsNumber+i*s,c.precision),a._dispatchEvent(e,"change");else f.value=t.round(+f.valueAsNumber+i*s,c.precision),a._dispatchEvent(f,"change")}e.stopPropagation(),e.preventDefault()}function b(e){var t=u.root.ownerDocument;t.removeEventListener("mousemove",y),t.removeEventListener("mouseup",b),document.body.classList.remove("noevents"),C.classList.add("hidden-opacity"),document.pointerLockElement&&document.exitPointerLock(),c.onRelease&&c.onRelease.bind(f)(e,f)}g.appendChild(C),this.disabled&&(f.disabled=!0),f.addEventListener("wheel",function(e){if(e.preventDefault(),f!==document.activeElement)return;let s=c.step??1;if(e.shiftKey?s=10:e.altKey&&(s=.1),p.locked)for(let i of h)i.value=t.round(+i.valueAsNumber-s*(e.deltaY>0?1:-1),c.precision),a._dispatchEvent(i,"change");else f.value=t.round(+f.valueAsNumber-s*(e.deltaY>0?1:-1),c.precision),a._dispatchEvent(f,"change")},{passive:!1}),f.addEventListener("change",e=>{if(isNaN(e.target.value))return;let s=t.clamp(e.target.value,+f.min,+f.max);if(s=t.round(s,c.precision),p.locked)for(let e of h)e.value=s,o[e.idx]=s;else f.value=s,o[e.target.idx]=s;this.set(o,!1,e)},!1),g.addEventListener("mousedown",v),d.appendChild(g)}void 0===c.min&&void 0===c.max||(this.setLimits=(e,t,s)=>{for(let i of h)i.min=e??i.min,i.max=t??i.max,i.step=s??i.step;this.set(o,!0)});const p=new l(null,"",e=>{p.locked=e},{title:"Lock",icon:"LockOpen",swap:"Lock",buttonClass:"no-h bg-none p-0"});d.appendChild(p.root),t.doAsync(this.onResize.bind(this))}}t.Vector=J;class Q{name;components;closed;root;content;grabber;panel;onclick;oncontextmenu;constructor(e,s={}){this.name=e;var i=document.createElement("div");i.className="lexbranch",s.id&&(i.id=s.id),s.className&&(i.className+=" "+s.className),i.style.margin="0 auto";var o=this;this.closed=s.closed??!1,this.root=i,this.components=[],this.panel=null;const n=document.createElement("div");if(n.className="lexbranchtitle",s.icon){const e=t.makeIcon(s.icon,{iconClass:"mr-2"});n.appendChild(e)}n.innerHTML+=e||"Branch";const a=t.makeIcon("Right",{iconClass:"switch-branch-button",svgClass:"sm"});n.appendChild(a),i.appendChild(n);var l=document.createElement("div");l.id=e.replace(/\s/g,""),l.className="lexbranchcontent",i.appendChild(l),this.content=l,this._addBranchSeparator(),this.closed&&(n.classList.add("closed"),i.classList.add("closed"),this.grabber.setAttribute("hidden",!0),t.doAsync(()=>{this.content.setAttribute("hidden",!0)},10)),this.onclick=function(){n.classList.toggle("closed"),n.parentElement.classList.toggle("closed"),o.content.toggleAttribute("hidden"),o.grabber.toggleAttribute("hidden"),t.emitSignal("@on_branch_closed",n.classList.contains("closed"))},this.oncontextmenu=function(e){e.preventDefault(),e.stopPropagation(),n.parentElement.classList.contains("dialog")||t.addContextMenu("Dock",e,t=>{e.preventDefault(),t.add("Floating",o._onMakeFloating.bind(o))},{icon:"WindowRestore"})},n.addEventListener("click",this.onclick),n.addEventListener("contextmenu",this.oncontextmenu)}_onMakeFloating(){const e=new t.Dialog(this.name,e=>{for(let t of this.components)e.root.appendChild(t.root)},{dockable:!0}),s=Array.from(this.root.parentElement.childNodes).indexOf(this.root);console.assert(s>=0,"Branch not found!"),e.branchData={name:this.name,components:this.components,closed:this.closed,panel:this.panel,childIndex:s},this.root.remove()}_addBranchSeparator(){const e=document.createElement("div");e.className="lexcomponentseparator",e.style.width="100%",e.style.background="none";const s=document.createElement("div");s.innerHTML="▾",e.appendChild(s),t.doAsync(()=>{s.style.marginLeft=parseFloat(t.DEFAULT_NAME_WIDTH)/100*this.content.offsetWidth+"px"},10);const i=document.createElement("div");i.style.width="1px",i.style.marginLeft="6px",i.style.marginTop="2px",i.style.height="0px",s.appendChild(i),s.addEventListener("mousedown",function(e){var t=o.root.ownerDocument;t.addEventListener("mouseup",a),t.addEventListener("mousemove",n),e.stopPropagation(),e.preventDefault();const s=o.root.offsetHeight-o.root.children[0].offsetHeight;i.style.height=s-3+"px",document.body.classList.add("nocursor")}),this.grabber=s;let o=this;function n(e){let i=e.movementX;if(0!=i){const e=parseFloat(s.style.marginLeft);s.style.marginLeft=t.clamp(e+i,32,o.content.offsetWidth-32)+"px"}}function a(e){o._updateComponents(),i.style.height="0px";var t=o.root.ownerDocument;t.removeEventListener("mouseup",a),t.removeEventListener("mousemove",n),document.body.classList.remove("nocursor")}this.content.appendChild(e)}_updateComponents(){var e=this.grabber.style.marginLeft;for(let s=0;s<this.components.length;s++){let i=this.components[s];const o=i.root;if(o.children.length<2)continue;let n=o.children[0],a=o.children[1];switch(n.style.width=e,n.style.minWidth=e,i.type){case t.BaseComponent.CUSTOM:case t.BaseComponent.ARRAY:continue}a.style.width="-moz-calc( 100% - "+e+" )",a.style.width="-webkit-calc( 100% - "+e+" )",a.style.width="calc( 100% - "+e+" )"}}}t.Branch=Q;let ee=class{root;branches;components;signals;queuedContainer;_branchOpen;_currentBranch;_queue;_inlineComponentsLeft;_inlineQueuedContainer;_inlineExtraClass;_inlineContainer;_inlineComponents;constructor(e={}){var t=document.createElement("div");t.className="lexpanel",e.id&&(t.id=e.id),e.className&&(t.className+=" "+e.className),t.style.width=e.width||"100%",t.style.height=e.height||"100%",Object.assign(t.style,e.style??{}),this.root=t,this.branches=[],this.signals=[],this.components={},this._branchOpen=!1,this._currentBranch=null,this._queue=[],this._inlineComponentsLeft=-1,this._inlineQueuedContainer=null,this._inlineExtraClass=null,this._inlineComponents=[]}get(e){return this.components[e]}getValue(e){let t=this.components[e];if(!t)throw"No component called "+e;return t.value()}setValue(e,t,s){let i=this.components[e];if(!i)throw"No component called "+e;return i.set(t,s)}attach(e){console.assert(e,"No content to attach!"),e.parent=this,this.root.appendChild(e.root?e.root:e)}clear(){this.branches=[],this._branchOpen=!1,this._currentBranch=null;for(let e in this.components)if(this.components[e].options&&this.components[e].options.signal){const s=this.components[e].options.signal;for(let i=0;i<t.signals[s].length;i++)t.signals[s][i]==this.components[e]&&(t.signals[s]=[...t.signals[s].slice(0,i),...t.signals[s].slice(i+1)])}if(this.signals)for(let e=0;e<this.signals.length;e++){let s=Object.values(this.signals[e])[0],i=s.options.signal;for(let e=0;e<t.signals[i].length;e++)t.signals[i][e]==s&&(t.signals[i]=[...t.signals[i].slice(0,e),...t.signals[i].slice(e+1)])}this.components={},this.root.innerHTML=""}sameLine(e,t){this._inlineQueuedContainer=this.queuedContainer,this._inlineComponentsLeft=e??1/0,this._inlineExtraClass=t??null}endLine(e){if(e=e??this._inlineExtraClass,-1!=this._inlineComponentsLeft){this._inlineComponentsLeft=-1,this._inlineContainer||(this._inlineContainer=document.createElement("div"),this._inlineContainer.className="lexinlinecomponents",e&&(this._inlineContainer.className+=` ${e}`));for(let e of this._inlineComponents){e.constructor==Array?this._inlineQueuedContainer?this._inlineContainer.appendChild(e[0]):e[1].appendChild(e[0]):this._inlineContainer.appendChild(e)}this._inlineQueuedContainer?this._inlineQueuedContainer.appendChild(this._inlineContainer):this._currentBranch?this._currentBranch.content.appendChild(this._inlineContainer):this.root.appendChild(this._inlineContainer),this._inlineComponents=[],this._inlineContainer=null,this._inlineExtraClass=null}else console.warn("No pending components to be inlined!")}branch(e,t={}){this._branchOpen&&this.merge();var s=new Q(e,t);return s.panel=this,this._branchOpen=!0,this._currentBranch=s,this.branches.push(s),this.root.appendChild(s.root),t.filter&&this._addFilter(t.filter,{callback:this._searchComponents.bind(this,s.name)}),s}merge(){this._branchOpen=!1,this._currentBranch=null}_pick(e,t){return void 0===e?t:e}_attachComponent(e,t={}){null!=e.name&&(this.components[e.name]=e),e.options.signal&&!e.name&&(this.signals||(this.signals=[]),this.signals.push({[e.options.signal]:e}));const s=s=>{t.container?t.container.appendChild(s):this.queuedContainer?this.queuedContainer.appendChild(s):this._currentBranch?(t.skipComponent||this._currentBranch.components.push(e),this._currentBranch.content.appendChild(s)):(s.className+=" nobranch w-full",this.root.appendChild(s))},i=e=>{this.queuedContainer?this._inlineComponents.push([e,this.queuedContainer]):this._inlineComponents.push(e)};return this._inlineComponentsLeft>0&&!t.skipInlineCount?(i(e.root),this._inlineComponentsLeft--,this._inlineComponentsLeft||this.endLine()):s(e.root),e}_addFilter(e,s={}){s.placeholder=e.constructor==String?e:"Filter properties..",s.skipComponent=s.skipComponent??!0,s.skipInlineCount=!0;const i=new d(null,void 0,null,s).root;i.className+=" lexfilter";let o=document.createElement("input");o.className="lexinput-filter",o.setAttribute("placeholder",s.placeholder),o.style.width="100%",o.value=s.filterValue||"";let n=t.makeIcon("Search");return i.appendChild(n),i.appendChild(o),o.addEventListener("input",e=>{s.callback&&s.callback(o.value,e)}),i}_searchComponents(e,t){for(let s of this.branches){if(s.name!==e)continue;for(let e of s.components)e.domEl.classList.contains("lexfilter")||e.domEl.remove();this.queue(s.content);const i=!t.length;for(let e of s.components){if(!i){if(!e.name)continue;if(!e.name.toLowerCase().includes(t))continue}this.queuedContainer.appendChild(e.domEl)}return void this.clearQueue()}}getBranch(e){return e?this.branches.find(t=>t.name==e):this._currentBranch}queue(e){!e&&this._currentBranch&&(e=this._currentBranch.root),this.queuedContainer&&this._queue.push(this.queuedContainer),this.queuedContainer=e}clearQueue(){this._queue&&this._queue.length?this.queuedContainer=this._queue.pop():delete this.queuedContainer}addSeparator(){var e=document.createElement("div");e.className="lexseparator";let t=new a(n.SEPARATOR);t.root=e,this._currentBranch?(this._currentBranch.content.appendChild(e),this._currentBranch.components.push(t)):this.root.appendChild(e)}addTitle(e,t={}){const s=new j(e,t);return this._attachComponent(s)}addText(e,t,s,i={}){const o=new d(e,t,s,i);return this._attachComponent(o)}addTextArea(e,t,s,i={}){const o=new X(e,t,s,i);return this._attachComponent(o)}addLabel(e,t={}){t.disabled=!0,t.inputClass=(t.inputClass??"")+" bg-none";const s=this.addText(null,e,null,t);return s.type=n.LABEL,s}addButton(e,t,s,i={}){const o=new l(e,t,s,i);return this._attachComponent(o)}addComboButtons(e,t,s={}){const i=new b(e,t,s);return this._attachComponent(i)}addCard(e,t={}){const s=new m(e,t);return this._attachComponent(s)}addForm(e,t,s,i={}){const o=new A(e,t,s,i);return this._attachComponent(o)}addContent(e,t,s={}){if(console.assert(t,"Empty content!"),t.constructor==String){const e=document.createElement("div");e.innerHTML=t,t=e.childElementCount>1?e:e.firstElementChild}s.hideName=!0;let i=new a(n.CONTENT,e,null,s);return i.root.appendChild(t),this._attachComponent(i)}async addImage(e,t,s={}){console.assert(0!==t.length,"Empty src/url for Image!");let i=document.createElement("div");i.className="leximage",i.style.width="100%";let o=document.createElement("img");o.src=t,Object.assign(o.style,s.style??{}),i.appendChild(o);let l=new a(n.IMAGE,e,null,s);return l.root.appendChild(i),o.decode(),this._attachComponent(l)}addSelect(e,t,s,i,o={}){const n=new u(e,t,s,i,o);return this._attachComponent(n)}addCurve(e,t,s,i={}){const o=new L(e,t,s,i);return this._attachComponent(o)}addDial(e,t,s,i={}){const o=new w(e,t,s,i);return this._attachComponent(o)}addLayers(e,t,s,i={}){const o=new N(e,t,s,i);return this._attachComponent(o)}addArray(e,t=[],s,i={}){const o=new p(e,t,s,i);return this._attachComponent(o)}addList(e,t,s,i,o={}){const n=new P(e,t,s,i,o);return this._attachComponent(n)}addTags(e,t,s,i={}){const o=new Y(e,t,s,i);return this._attachComponent(o)}addCheckbox(e,t,s,i={}){const o=new g(e,t,s,i);return this._attachComponent(o)}addToggle(e,t,s,i={}){const o=new Z(e,t,s,i);return this._attachComponent(o)}addRadioGroup(e,t,s,i,o={}){const n=new $(e,t,s,i,o);return this._attachComponent(n)}addColor(e,t,s,i={}){const o=new y(e,t,s,i);return this._attachComponent(o)}addRange(e,t,s,i={}){const o=new V(e,t,s,i);return this._attachComponent(o)}addNumber(e,t,s,i={}){const o=new h(e,t,s,i);return this._attachComponent(o)}static VECTOR_COMPONENTS={0:"x",1:"y",2:"z",3:"w"};_addVector(e,t,s,i,o={}){const n=new J(e,t,s,i,o);return this._attachComponent(n)}addVector2(e,t,s,i){return this._addVector(2,e,t,s,i)}addVector3(e,t,s,i){return this._addVector(3,e,t,s,i)}addVector4(e,t,s,i){return this._addVector(4,e,t,s,i)}addSize(e,t,s,i={}){const o=new U(e,t,s,i);return this._attachComponent(o)}addOTP(e,t,s,i={}){const o=new B(e,t,s,i);return this._attachComponent(o)}addPad(e,t,s,i={}){const o=new H(e,t,s,i);return this._attachComponent(o)}addProgress(e,t,s={}){const i=new F(e,t,s);return this._attachComponent(i)}addFile(e,t,s={}){const i=new M(e,t,s);return this._attachComponent(i)}addTree(e,t,s={}){const i=new z(e,t,s);return this._attachComponent(i)}addTabSections(e,t,s={}){const i=new q(e,t,s);return this._attachComponent(i)}addCounter(e,t,s,i={}){const o=new _(e,t,s,i);return this._attachComponent(o)}addTable(e,t,s={}){const i=new W(e,t,s);return this._attachComponent(i)}addDate(e,t,s,i={}){const o=new E(e,t,s,i);return this._attachComponent(o)}addMap2D(e,t,s,i={}){const o=new R(e,t,s,i);return this._attachComponent(o)}addRate(e,t,s,i={}){const o=new K(e,t,s,i);return this._attachComponent(o)}};t.Panel=ee;class te{area;options;buttons;constructor(e,t,s={}){this.area=e,this.options=s,this.buttons={},this._buildButtons(t,s)}_buildButtons(e,t={}){t.className="lexoverlaybuttons";let s=this.area.addPanel(t),i=null;const o=document.createElement("div");o.className="lexoverlaybuttonscontainer",o.appendChild(s.root),this.area.attach(o);const n=t.float;let a="";if(n){for(let e=0;e<n.length;e++){switch(n[e]){case"h":case"t":case"l":break;case"v":a+=" vertical";break;case"m":a+=" middle";break;case"b":a+=" bottom";break;case"c":a+=" center";break;case"r":a+=" right"}}o.className+=` ${a}`}const l=(e,t,o)=>{const n={width:"auto",selectable:e.selectable,selected:e.selected,icon:e.icon,img:e.img,className:e.class??"",title:e.name,overflowContainerX:s.root,swap:e.swap};t&&(i||(i=document.createElement("div"),i.className="lexoverlaygroup",s.queuedContainer=i),n.parent=i);let a=e.callback,l=null;l=e.options?s.addSelect(null,e.options,e.value??e.name,a,n):s.addButton(null,e.name,function(t,s){if(e.selectable)if(e.group){let t=e.selected;e.group.forEach(e=>e.selected=!1),e.selected=!t}else e.selected=!e.selected;a&&a(t,s,l.root)},n),this.buttons[e.name]=l,i&&o&&(s.root.appendChild(i),i=null,s.clearQueue())};!function(){s.clear();for(let t of e){if(null===t){const e=document.createElement("div");e.className="lexoverlayseparator"+a,s.root.appendChild(e);continue}if(t.constructor===Array)for(let e=0;e<t.length;++e){let s=t[e];s.group=t,l(s,!0,e==t.length-1)}else l(t)}if(n){var t=0;s.root.childNodes.forEach(e=>{t+=e.offsetHeight}),o.className.includes("middle")&&(o.style.top="-moz-calc( 50% - "+.5*t+"px )",o.style.top="-webkit-calc( 50% - "+.5*t+"px )",o.style.top="calc( 50% - "+.5*t+"px )")}}()}}t.AreaOverlayButtons=te;let se=class e{offset=0;root;size;resize=!1;sections=[];panels=[];minWidth=0;minHeight=0;maxWidth=1/0;maxHeight=1/0;layout;type;parentArea;splitBar;splitExtended;overlayButtons;onresize;_autoVerticalResizeObserver;_root;constructor(e={}){var s=document.createElement("div");s.className="lexarea",e.id&&(s.id=e.id),e.className&&(s.className+=" "+e.className);var i=e.width||"100%",o=e.height||"100%";this.setLimitBox(e.minWidth,e.minHeight,e.maxWidth,e.maxHeight),i.constructor==Number&&(i=`${i}px`),o.constructor==Number&&(o=`${o}px`),s.style.width=i,s.style.height=o,this.root=s,this.size=[this.root.offsetWidth,this.root.offsetHeight];let n=document.getElementById("lexroot");n&&!e.skipAppend&&n.appendChild(this.root),e.layout&&this.setLayout(e.layout);let a=e.overlay;if(a){this.root.classList.add("overlay-"+a),e.left?this.root.style.left=e.left:e.right?this.root.style.right=e.right:e.top?this.root.style.top=e.top:e.bottom&&(this.root.style.bottom=e.bottom);if((e.draggable??!0)&&t.makeDraggable(s,e),e.resizeable&&s.classList.add("resizeable"),e.resize){this.splitBar=document.createElement("div");let l="left"==a||"right"==a?"horizontal":"vertical";if(this.type=a,this.splitBar.className="lexsplitbar "+l,"right"==a)this.splitBar.style.width=t.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.left=-t.DEFAULT_SPLITBAR_SIZE/2+"px";else if("left"==a){let p=Math.min(document.body.clientWidth-t.DEFAULT_SPLITBAR_SIZE,this.root.clientWidth);this.splitBar.style.width=t.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.left=p+t.DEFAULT_SPLITBAR_SIZE/2+"px"}else if("top"==a){let m=Math.min(document.body.clientHeight-t.DEFAULT_SPLITBAR_SIZE,this.root.clientHeight);this.splitBar.style.height=t.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.top=m+t.DEFAULT_SPLITBAR_SIZE/2+"px"}else"bottom"==a&&(this.splitBar.style.height=t.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.top=-t.DEFAULT_SPLITBAR_SIZE/2+"px");this.splitBar.addEventListener("mousedown",h),this.root.appendChild(this.splitBar);const r=this;let c=[0,0];function h(e){const t=r.root.ownerDocument;t.addEventListener("mousemove",d),t.addEventListener("mouseup",u),c[0]=e.x,c[1]=e.y,e.stopPropagation(),e.preventDefault(),document.body.classList.add("nocursor"),r.splitBar.classList.add("nocursor")}function d(e){switch(r.type){case"right":var s=c[0]-e.x,i=r.root.offsetWidth+s;r.root.style.width=i+"px";break;case"left":s=c[0]-e.x,i=Math.min(document.body.clientWidth-t.DEFAULT_SPLITBAR_SIZE,r.root.offsetWidth-s);r.root.style.width=i+"px",r.splitBar.style.left=i+t.DEFAULT_SPLITBAR_SIZE/2+"px";break;case"top":s=c[1]-e.y,i=Math.min(document.body.clientHeight-t.DEFAULT_SPLITBAR_SIZE,r.root.offsetHeight-s);r.root.style.height=i+"px",r.splitBar.style.top=i+t.DEFAULT_SPLITBAR_SIZE/2+"px";break;case"bottom":s=c[1]-e.y,i=r.root.offsetHeight+s;r.root.style.height=i+"px"}c[0]=e.x,c[1]=e.y,e.stopPropagation(),e.preventDefault(),r.onresize&&r.onresize(r.root.getBoundingClientRect())}function u(e){const t=r.root.ownerDocument;t.removeEventListener("mousemove",d),t.removeEventListener("mouseup",u),document.body.classList.remove("nocursor"),r.splitBar.classList.remove("nocursor")}}}}attach(e){if(this.sections.length)return void this.sections[1].attach(e);if(!e)throw"no content to attach";e.parent=this;let t=e.root?e.root:e;this.root.appendChild(t)}setLayout(e){if(this.layout=t.deepCopy(e),!e.splits)return void console.warn("Area layout has no splits!");const s=(e,t)=>{if(t.className&&(e.root.className+=` ${t.className}`),!t.splits)return;const i=t.type??"horizontal",o=t.resize??!0,n=t.minimizable??!1,[a,l]=e.split({type:i,resize:o,minimizable:n,sizes:[t.splits[0].size,t.splits[1].size]});s(a,t.splits[0]),s(l,t.splits[1])};s(this,e)}split(s={}){this.sections.length&&(this.offset=this.root.childNodes[0].offsetHeight,this._root=this.sections[0].root,this.root=this.sections[1].root);const i=s.type??"horizontal",o=s.sizes||["50%","50%"],n="auto"===s.sizes||s.sizes&&"auto"==s.sizes[0]&&"auto"==s.sizes[1],a=this.root.getBoundingClientRect();if(!o[1]||"auto"!=o[0]&&"auto"==o[1]){let e=o[0],t=s.top?s.top:0;e.constructor==Number&&(e+=t,e=`${e}px`),o[1]="calc( 100% - "+e+" )"}let l=s.minimizable??!1,r=(s.resize??!0)||l,c=s.fixedSize??!r,h=0,d=[],u=[];if(this.offset=0,r&&(this.resize=r,this.splitBar=document.createElement("div"),this.splitBar.className="lexsplitbar "+i,"horizontal"==i?this.splitBar.style.width=t.DEFAULT_SPLITBAR_SIZE+"px":this.splitBar.style.height=t.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.addEventListener("mousedown",function(e){const t=g.root.ownerDocument;t.addEventListener("mousemove",f),t.addEventListener("mouseup",C),e.stopPropagation(),e.preventDefault()}),h=t.DEFAULT_SPLITBAR_SIZE/2),"horizontal"==i){if(this.root.style.display="flex",c)d[0]=`calc(${o[0]} - ${h}px)`,u[0]=`calc(${o[1]} - ${h}px)`;else{const e=a.width,s=t.parsePixelSize(o[0],e)/e*100,i=t.parsePixelSize(o[1],e)/e*100;d[0]=`calc(${s}% - ${h}px)`,u[0]=`calc(${i}% - ${h}px)`}d[1]="100%",u[1]="100%"}else{if(n)d[1]="auto",u[1]="auto";else if(c)d[1]="auto"==o[0]?"auto":`calc(${o[0]} - ${h}px)`,u[1]="auto"==o[1]?"auto":`calc(${o[1]} - ${h}px)`;else{const e=a.height,s=t.parsePixelSize(o[0],e)/e*100,i=t.parsePixelSize(o[1],e)/e*100;d[1]="auto"==o[0]?"auto":`calc(${s}% - ${h}px)`,u[1]="auto"==o[1]?"auto":`calc(${i}% - ${h}px)`}d[0]="100%",u[0]="100%"}let p=new e({width:d[0],height:d[1],skipAppend:!0,className:"split"+(s.menubar||s.sidebar?"":" origin")}),m=new e({width:u[0],height:u[1],skipAppend:!0,className:"split"});if(!(c||a.width&&a.height)){const e=new ResizeObserver(s=>{console.assert(1==s.length,"AreaResizeObserver: more than one entry");const a=s[0].contentRect;if(a.width&&a.height){if(this._update([a.width,a.height],!1),!n){if("horizontal"==i){const e=a.width,s=t.parsePixelSize(o[0],e)/e*100,i=t.parsePixelSize(o[1],e)/e*100;d[0]=`calc(${s}% - ${h}px)`,u[0]=`calc(${i}% - ${h}px)`}else{const e=a.height,s=t.parsePixelSize(o[0],e)/e*100,i=t.parsePixelSize(o[1],e)/e*100;d[1]="auto"==o[0]?"auto":`calc(${s}% - ${h}px)`,u[1]="auto"==o[1]?"auto":`calc(${i}% - ${h}px)`}p.root.style.width=d[0],p.root.style.height=d[1],m.root.style.width=u[0],m.root.style.height=u[1]}p._update(),m._update(),e.disconnect()}});t.doAsync(()=>{e.observe(this.root)},100)}if(n&&"vertical"==i&&(this._autoVerticalResizeObserver=new ResizeObserver(e=>{for(const s of e){const e=t.getComputedSize(s.target);m.root.style.height="calc(100% - "+e.height+"px )"}}),this._autoVerticalResizeObserver.observe(p.root)),r&&l&&(this.splitExtended=!1,m.root.addEventListener("animationend",e=>{const s=getComputedStyle(m.root).opacity;m.root.classList.remove(e.animationName+"-"+i),m.root.style.opacity=s,t.flushCss(m.root)}),this.splitBar.addEventListener("contextmenu",e=>{e.preventDefault(),t.addContextMenu(null,e,e=>{e.add("Extend",{disabled:this.splitExtended,callback:()=>{this.extend()}}),e.add("Reduce",{disabled:!this.splitExtended,callback:()=>{this.reduce()}})})})),p.parentArea=this,m.parentArea=this,this.root.appendChild(p.root),r&&this.root.appendChild(this.splitBar),this.root.appendChild(m.root),this.sections=[p,m],this.type=i,this._update(a.width||a.height?[a.width,a.height]:void 0),!r)return this.sections;const g=this;function f(e){const t=g.root.getBoundingClientRect();e.x<t.x||e.x>t.x+t.width||e.y<t.y||e.y>t.y+t.height||("horizontal"==g.type?g._moveSplit(-e.movementX):g._moveSplit(-e.movementY),e.stopPropagation(),e.preventDefault())}function C(e){const t=g.root.ownerDocument;t.removeEventListener("mousemove",f),t.removeEventListener("mouseup",C)}return this.sections}setLimitBox(e=0,t=0,s=1/0,i=1/0){this.minWidth=e,this.minHeight=t,this.maxWidth=s,this.maxHeight=i,0!=e&&(this.root.style.minWidth=`${e}px`),0!=t&&(this.root.style.minHeight=`${t}px`),s!=1/0&&(this.root.style.maxWidth=`${s}px`),i!=1/0&&(this.root.style.maxHeight=`${i}px`)}setSize(e){let[s,i]=e;null!=s&&s.constructor==Number&&(s=`${s}px`),null!=i&&i.constructor==Number&&(i=`${i}px`),s&&(this.root.style.width=s),i&&(this.root.style.height=i),this.onresize&&this.onresize(this.root.getBoundingClientRect()),t.doAsync(()=>{this.size=[this.root.clientWidth,this.root.clientHeight],this.propagateEvent("onresize")},150)}extend(){if(this.splitExtended)return;let[e,s]=this.sections;this.splitExtended=!0,e.root.classList.add(`maximize-${this.type}`),s.root.classList.add(`minimize-${this.type}`),s.root.classList.add(`fadeout-${this.type}`),s.root.classList.remove(`fadein-${this.type}`),"vertical"==this.type?(this.offset=s.root.offsetHeight,this._moveSplit(-1/0,!0)):(this.offset=s.root.offsetWidth-8,this._moveSplit(-1/0,!0,8)),t.doAsync(()=>{this.propagateEvent("onresize")},100)}reduce(){if(!this.splitExtended)return;this.splitExtended=!1;let[e,s]=this.sections;e.root.classList.add(`minimize-${this.type}`),s.root.classList.add(`maximize-${this.type}`),s.root.classList.add(`fadein-${this.type}`),s.root.classList.remove(`fadeout-${this.type}`),this._moveSplit(this.offset),t.doAsync(()=>{this.propagateEvent("onresize")},100)}hide(){this.root.classList.add("hidden")}show(){this.root.classList.remove("hidden")}toggle(e){this.root.classList.toggle("hidden",e)}propagateEvent(e){for(let t=0;t<this.sections.length;t++){const s=this.sections[t];s[e]&&s[e].call(this,s.root.getBoundingClientRect()),s.propagateEvent(e)}}addPanel(e){let t=new ee(e);return this.attach(t),this.panels.push(t),t}addMenubar(e,s={}){let i=new r(e,s);t.menubars.push(i);const[o,n]=this.split({type:"vertical",sizes:["48px",null],resize:!1,menubar:!0});return i.siblingArea=n,o.attach(i),o.isMenubar=!0,(s.sticky??1)&&(o.root.className+=" sticky top-0 z-1000"),s.parentClass&&(o.root.className+=` ${s.parentClass}`),i}addSidebar(e,s={}){let i=new t.Sidebar({callback:e,...s});e&&e(i),i.update(),t.sidebars.push(i);const o=s.side??"left";console.assert("left"==o||"right"==o,"Invalid sidebar side: "+o);const n="left"==o,a=s.width??"16rem",l=n?[a,null]:[null,a],[r,c]=this.split({type:"horizontal",sizes:l,resize:!1,sidebar:!0});i.siblingArea=n?c:r;let h=n?r:c;return h.attach(i),h.isSidebar=!0,s.parentClass&&(h.root.className+=` ${s.parentClass}`),i}addOverlayButtons(e,t={}){return this.sections.length?this.sections[1].addOverlayButtons(e,t):(console.assert(e.constructor==Array&&0!==e.length),this.root.style.position="relative",this.overlayButtons=new te(this,e,t),this.overlayButtons)}addTabs(e={}){const t=new c(this,e);return e.folding&&(this.parentArea?._disableSplitResize(),this.root.style.paddingTop="4px"),t}_moveSplit(e,s=!1,i=0){if(!this.type)throw"No split area";if(void 0===e)return;this._autoVerticalResizeObserver&&this._autoVerticalResizeObserver.disconnect();const o=this.sections[0];var n=o.root;n.classList.contains("origin")||(n=n.parentElement);const a=this.sections[1],l=a.root,r="- "+t.DEFAULT_SPLITBAR_SIZE+"px";let c=null;if(s||(c=n.style.transition,n.style.transition=l.style.transition="none"),"horizontal"==this.type){var h=Math.max(l.offsetWidth+e,parseInt(a.minWidth));i&&(h=i);const t=h/this.size[0]*100,s=Math.max(0,100-t);n.style.width=`-moz-calc(${s}% ${r})`,n.style.width=`-webkit-calc( ${s}% ${r})`,n.style.width=`calc( ${s}% ${r})`,l.style.width=`${t}%`,l.style.width=`${t}%`,l.style.width=`${t}%`,o.maxWidth!=1/0&&(l.style.minWidth=`calc( 100% - ${parseInt(o.maxWidth)}px )`)}else{const s=this.size[1];h=Math.max(l.offsetHeight+e+a.offset,parseInt(a.minHeight));h=Math.min(s-t.DEFAULT_SPLITBAR_SIZE,h),i&&(h=i);const c=h/s*100,d=Math.max(0,100-c);n.style.height=`-moz-calc(${d}% ${r})`,n.style.height=`-webkit-calc( ${d}% ${r})`,n.style.height=`calc( ${d}% ${r})`,l.style.height=`${c}%`,l.style.height=`${c}%`,l.style.height=`${c}%`,o.maxHeight!=1/0&&(l.style.minHeight=`calc( 100% - ${parseInt(o.maxHeight)}px )`)}s||(n.style.transition=l.style.transition=c),t.doAsync(()=>{this._update(),this.propagateEvent("onresize")},10)}_disableSplitResize(){this.resize=!1,this.splitBar.remove(),delete this.splitBar}_update(e,t=!0){if(e)this.size=e;else{const e=this.root.getBoundingClientRect();this.size=[e.width,e.height]}if(t)for(var s=0;s<this.sections.length;s++)this.sections[s]._update()}};function ie(e,s=!0){e="light"==e?"light":"dark",document.documentElement.setAttribute("data-theme",e),s&&localStorage.setItem("lxColorScheme",e),t.emitSignal("@on_new_color_scheme",e)}function oe(){return document.documentElement.getAttribute("data-theme")??"dark"}function ne(e){if(!/^#(?:[A-Fa-f0-9]{3,4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e))throw`Invalid Hex Color: ${e}`;3!==(e=e.replace(/^#/,"")).length&&4!==e.length||(e=e.split("").map(e=>e+e).join(""));const t=parseInt(e,16);return{r:(t>>(8===e.length?24:16)&255)/255,g:(t>>(8===e.length?16:8)&255)/255,b:(t>>(8===e.length?8:0)&255)/255,a:(8===e.length?255&t:4===e.length?parseInt(e.slice(-2),16):255)/255}}function ae(e){let{r:t,g:s,b:i,a:o}=e;o=o??1;const n=Math.max(t,s,i),a=n-Math.min(t,s,i);let l=0;0!==a&&(l=n===t?(s-i)/a%6:n===s?(i-t)/a+2:(t-s)/a+4,l*=60,l<0&&(l+=360));return{h:l,s:0===n?0:a/n,v:n,a:o}}t.Area=se,t.clamp=function(e,t,s){return Math.min(Math.max(e,t),s)},t.round=function(e,t){return 0==t?Math.floor(e):+e.toFixed(t??2).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,"$1")},t.remapRange=function(e,t,s,i,o){return(e-t)*(o-i)/(s-t)+i},"undefined"!=typeof performance?t.getTime=performance.now.bind(performance):"undefined"!=typeof Date&&Date.now?t.getTime=Date.now.bind(Date):t.getTime=function(){return(new Date).getTime()},t.doAsync=function(e,t){setTimeout(e,t??0)},t.flushCss=function(e){e.offsetHeight},t.deleteElement=function(e){e&&e.remove()},t.toCamelCase=function(e){return e.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(e,t)=>t.toUpperCase())},t.toTitleCase=function(e){return e.replace(/-/g," ").toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())},t.toKebabCase=function(e){return e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())},t.getSupportedDOMName=function(e){console.assert("string"==typeof e,"getSupportedDOMName: Text is not a string!");let t=e.trim();return t=t.replace(/@/g,"_at_").replace(/\+/g,"_plus_").replace(/\./g,"_dot_"),t=t.replace(/[^a-zA-Z0-9_-]/g,"_"),/^[0-9]/.test(t)&&(t="_"+t),t},t.has=function(e){return t.extensions.indexOf(e)>-1},t.getExtension=function(e){return e.includes(".")?e.split(".").pop():null},t.stripHTML=function(e){const t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||""},t.stripTags=function(e,t){t=(((t||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join("");const s=/<\/?([a-z0-9]*)\b[^>]*>?/gi,i=/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;let o=e;for(o="<"===o.substring(o.length-1)?o.substring(0,o.length-1):o;;){const e=o;if(o=e.replace(i,"").replace(s,function(e,s){return t.indexOf("<"+s.toLowerCase()+">")>-1?e:""}),e===o)return o}},t.parsePixelSize=function e(t,s){if(t.constructor===Number)return t;if(t.constructor===String){const i=parseFloat(t);if(t.endsWith("px"))return i;if(t.endsWith("%"))return i/100*s;if(t.endsWith("rem")||t.endsWith("em")){return i*16}if(t.endsWith("vw"))return i/100*window.innerWidth;if(t.endsWith("vh"))return i/100*window.innerHeight;if(t.startsWith("calc(")){const i=t.slice(5,-1).split(/([+\-])/);let o=0,n="+";for(let t of i)if(t=t.trim(),"+"===t||"-"===t)n=t;else{let i=e(t,s);o="+"===n?o+i:o-i}return o}}throw"Bad size format!"},t.deepCopy=function(e){return JSON.parse(JSON.stringify(e))},t.concatTypedArray=function(e,t){let s=new t(e.reduce((e,t)=>e+t.length,0)),i=0;for(let t=0;t<e.length;++t)s.set(e[t],i),i+=e[t].length;return s},t.setTheme=ie,t.getTheme=oe,t.switchTheme=function(){ie("dark"==oe()?"light":"dark")},t.setSystemTheme=function(){ie(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"),localStorage.removeItem("lxColorScheme"),t._mqlPrefersDarkScheme&&(t._mqlPrefersDarkScheme.removeEventListener("change",t._onChangeSystemTheme),t._mqlPrefersDarkScheme.addEventListener("change",t._onChangeSystemTheme))},t.setThemeColor=function(e,t){document.querySelector(":root").style.setProperty("--"+e,t)},t.getThemeColor=function(e){const t=document.querySelector(":root"),s=getComputedStyle(t),i=s.getPropertyValue("--"+e);if(i.includes("light-dark")){return"light"==s.getPropertyValue("color-scheme")?i.substring(i.indexOf("(")+1,i.indexOf(",")).replace(/\s/g,""):i.substring(i.indexOf(",")+1,i.indexOf(")")).replace(/\s/g,"")}return i},t.switchSpacing=function(){const e=document.documentElement.getAttribute("data-spacing")??"default";document.documentElement.setAttribute("data-spacing","default"==e?"compact":"default"),t.emitSignal("@on_new_spacing_layout",e)},t.getBase64Image=function(e){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");return s&&s.drawImage(e,0,0),t.toDataURL("image/png")},t.hexToRgb=ne,t.hexToHsv=function(e){return ae(ne(e))},t.rgbToHex=function(e,t=255){const s=[e.r,e.g,e.b];return null!=e.a&&s.push(e.a),"#"+s.map(e=>{const s=(e=Math.floor(e*t)).toString(16);return 1===s.length?"0"+s:s}).join("")},t.rgbToCss=function(e){return{r:Math.floor(255*e.r),g:Math.floor(255*e.g),b:Math.floor(255*e.b),a:e.a}},t.rgbToHsv=ae,t.hsvToRgb=function(e){const{h:t,s:s,v:i,a:o}=e,n=i*s,a=n*(1-Math.abs(t/60%2-1)),l=i-n;let r=0,c=0,h=0;return t<60?(r=n,c=a,h=0):t<120?(r=a,c=n,h=0):t<180?(r=0,c=n,h=a):t<240?(r=0,c=a,h=n):t<300?(r=a,c=0,h=n):(r=n,c=0,h=a),{r:r+l,g:c+l,b:h+l,a:o}},t.dateFromDateString=function(e){const t=e.split("/"),s=parseInt(t[0]),i=parseInt(t[1]),o=parseInt(t[2]);return new Date(`${i}/${s}/${o}`)},t.measureRealWidth=function(e,s=8){var i=document.createElement("span");i.className="lexinputmeasure",i.innerHTML=e,document.body.appendChild(i);var o=i.getBoundingClientRect();return t.deleteElement(i),o.width+s},t.guidGenerator=function(){var e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+"-"+e()+"-"+e()},t.escapeRegExp=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},t.wildcardToRegExp=function(e){const t=e.replace(/([.+^${}()|[\]\\])/g,"\\$1").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp("^"+t+"$","i")},t.buildTextPattern=function(e={}){let t=[];e.lowercase&&t.push("(?=.*[a-z])"),e.uppercase&&t.push("(?=.*[A-Z])"),e.digit&&t.push("(?=.*\\d)"),e.specialChar&&t.push("(?=.*[@#$%^&+=!])"),e.noSpaces&&t.push("(?!.*\\s)"),e.email&&t.push("(^[^s@]+@[^s@]+.[^s@]+$)");let s=e.minLength||0,i=e.maxLength||"",o=`^${t.join("")}.{${s},${i}}$`;return e.asRegExp?new RegExp(o):o},t.validateValueAtPattern=function(e,t={},...s){const i=[],o=t.minLength||0,n=t.maxLength;return e.length<o?i.push(`Must be at least ${o} characters long.`):void 0!==n&&e.length>n&&i.push(`Must be no more than ${n} characters long.`),t.lowercase&&!/[a-z]/.test(e)&&i.push("Must contain at least one lowercase letter (a-z)."),t.uppercase&&!/[A-Z]/.test(e)&&i.push("Must contain at least one uppercase letter (A-Z)."),t.digit&&!/\d/.test(e)&&i.push("Must contain at least one number (0-9)."),t.noSpaces&&/\s/.test(e)&&i.push("Must NOT contain any spaces."),t.specialChar&&!/[@#$%^&+=!]/.test(e)&&i.push("Must contain at least one special character (e.g., @, #, $, %, ^, &, +, =, !)."),t.email&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)&&i.push("Must have a valid email format."),t.fieldMatchName&&e!==s[0]&&i.push(`Must match ${t.fieldMatchName} field.`),i},t.makeDraggable=function(e,s={}){let i=0,o=0,n=null,a=s.targetClass,l=s.dragMargin??3,r=(s,n,a)=>{const r=e.parentElement?e.parentElement.getBoundingClientRect():{x:0,y:0,width:0,height:0},c="fixed"==e.style.position?new O(r.x,r.y):new O;a=a??s.clientX-i-r.x,n=n??s.clientY-o-r.y,e.style.left=t.clamp(a,l+c.x,c.x+r.width-e.offsetWidth-l)+"px",e.style.top=t.clamp(n,l+c.y,c.y+r.height-e.offsetHeight-l)+"px",e.style.translate="none"};s.autoAdjust&&r(null,parseInt(e.style.left),parseInt(e.style.top));let c=t.guidGenerator();e["draggable-id"]=c;let h=s.onMove?e=>{n&&s.onMove&&s.onMove(n)}:e=>{n&&r(e)},d=s.onDragStart;e.setAttribute("draggable","true"),e.addEventListener("mousedown",function(e){n=e.target.classList.contains(a)||!a?e.target:null}),e.addEventListener("dragstart",function(a){if(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation(),!n)return;var l=new Image;l.src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=",a.dataTransfer&&(a.dataTransfer.setDragImage(l,0,0),a.dataTransfer.effectAllowed="move");const r=a.target.getBoundingClientRect(),c=n.parentElement.getBoundingClientRect(),u="fixed"==n.style.position?new O(c.x,c.y):new O;i=a.clientX-r.x-u.x,o=a.clientY-r.y-u.y,document.addEventListener("mousemove",h),n.eventCatched=!0,(s.updateLayers??1)&&(t.activeDraggable&&(t.activeDraggable.style.zIndex=t.DRAGGABLE_Z_INDEX),t.activeDraggable=e,t.activeDraggable.style.zIndex=t.DRAGGABLE_Z_INDEX+1),d&&d(n,a)},!1),document.addEventListener("mouseup",e=>{n&&(n=null,document.removeEventListener("mousemove",h))})},t.makeCollapsible=function(e,s,i,o={}){e.classList.add("collapsible");const n=o.collapsed??!0,a=t.makeIcon("Right");a.classList.add("collapser"),n&&(a.dataset.collapsed=`${n}`),a.style.marginLeft="auto",a.style.marginRight="0.2rem",a.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),this.dataset.collapsed?(delete this.dataset.collapsed,s.style.display=o.display??"block"):(this.dataset.collapsed="true",s.style.display="none")}),e.appendChild(a),(i=i??e.parentElement).appendChild(s)},t.makeCodeSnippet=function(e,s,i={}){if(!t.has("CodeEditor"))return void console.error("Import the CodeEditor component to create snippets!");const o=document.createElement("div");o.className="lexcodesnippet "+(i.className??""),o.style.width=s?s[0]:"auto",o.style.height=s?s[1]:"auto";const n=new se({xskipAppend:!0});return new t.CodeEditor(n,{skipInfo:!0,disableEdition:!0,allowAddScripts:!1,name:i.tabName,callback:t=>{if(t.setText(e,i.language??"Plain Text"),i.linesAdded){const e=t.root.querySelector(".code");for(let t of i.linesAdded){const s=t;if(s.constructor==Number)e.childNodes[s-1].classList.add("added");else if(s.constructor==Array)for(let t=s[0]-1;t<=s[1]-1;t++)e.childNodes[t].classList.add("added")}}if(i.linesRemoved){const e=t.root.querySelector(".code");for(let t of i.linesRemoved){const s=t;if(s.constructor==Number)e.childNodes[s-1].classList.add("removed");else if(s.constructor==Array)for(let t=s[0]-1;t<=s[1]-1;t++)e.childNodes[t].classList.add("removed")}}if(i.windowMode){const e=document.createElement("div");e.className="lexwindowbuttons";const s=document.createElement("span");s.style.background="#ee4f50";const i=document.createElement("span");i.style.background="#f5b720";const o=document.createElement("span");o.style.background="#53ca29",e.appendChild(s),e.appendChild(i),e.appendChild(o);t.root.querySelector(".lexareatabs").prepend(e)}(i.lineNumbers??1)||t.root.classList.add("no-gutter")}}),o.appendChild(n.root),o},t.makeKbd=function(e,s=!0,i=""){const o={Ctrl:"⌃",Enter:"↩",Shift:"⇧",CapsLock:"⇪",Meta:"⌘",Option:"⌥",Alt:"⌥",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Space:"␣"},n=t.makeContainer(["auto","auto"],"flex flex-row ml-auto");for(const a of e)t.makeContainer(["auto","auto"],"self-center text-xs fg-secondary select-none "+i,s?o[a]??a:a,n);return n},t.makeBreadcrumb=function(e,s={}){const i=t.makeContainer(["auto","auto"],"flex flex-row gap-1"),o=s.separatorIcon??"ChevronRight",n=s.maxItems??4,a=e.length-n;if(a>0){const t={title:"...",ellipsis:e.splice(1,a+1).map(e=>e.title).join("/")};e.splice(1,0,t)}for(let s=0;s<e.length;++s){const n=e[s];if(console.assert(n.title,"Breadcrumb item must have a title!"),0!=s){const e=t.makeIcon(o,{svgClass:"sm fg-secondary separator"});i.appendChild(e)}const a=s==e.length-1,l=t.makeContainer(["auto","auto"],"p-1 flex flex-row gap-1 items-center "+(a?"":"fg-secondary"));i.appendChild(l);let r=t.makeElement("p","",n.title);if(n.icon&&l.appendChild(t.makeIcon(n.icon,{svgClass:"sm"})),void 0!==n.items){const e=t.makeContainer(["auto","auto"],""+(a?"":"fg-secondary"));t.listen(e,"click",e=>{t.addDropdownMenu(e.target,n.items,{side:"bottom",align:"start"})}),e.append(r),l.appendChild(e)}else if(void 0!==n.url){let e=t.makeElement("a","decoration-none fg-"+(a?"primary":"secondary"),"",l);e.href=n.url,e.appendChild(r)}else l.appendChild(r);n.ellipsis&&t.asTooltip(l,n.ellipsis,{side:"bottom",offset:4})}return i},t.makeIcon=function(e,s={}){let i=null;const o=t=>{s.svgClass&&s.svgClass.length&&s.svgClass.split(" ").forEach(e=>t.classList.add(e));const i=document.createElement("a");return i.title=s.title??"",i.className="lexicon "+(s.iconClass??""),i.appendChild(t),t.dataset.name=e,i};if(e.includes("@")){const t=e.split("@");e=t[0],s.variant=t[1]}let n=t.ICONS[e];const a=window.lucide,l=a[e]??a[t.LucideIconAlias[e]];if(n){n.constructor!=Array&&(n=t.ICONS[n]);const a=s.variant??"regular";n=("solid"==a?t.ICONS[`${e}@solid`]:n)??n;const r=n[3];if(a==r||!l||"regular"==r){if(i=document.createElementNS("http://www.w3.org/2000/svg","svg"),i.setAttribute("viewBox",`0 0 ${n[0]} ${n[1]}`),n[5]){const e=n[5].svgClass;e?.split(" ").forEach(e=>{i.classList.add(e)});const t=n[5].svgAttributes;t?.split(" ").forEach(e=>{const t=e.split("=");i.setAttribute(t[0],t[1])})}const e=document.createElement("path");if(e.setAttribute("fill","currentColor"),e.setAttribute("d",n[4]),i.appendChild(e),n[5]){const t=n[5].pathClass;t?.split(" ").forEach(t=>{e.classList.add(t)});const s=n[5].pathAttributes;s?.split(" ").forEach(t=>{const s=t.split("=");e.setAttribute(s[0],s[1])})}const t="\x3c!-- This icon might belong to a collection from Iconify - https://iconify.design/ - or !Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc. --\x3e";return i.innerHTML+=t,o(i)}}return console.assert(l,`No existing icon named _${e}_`),i=a.createElement(l,s),o(i)},t.registerIcon=function(e,s,i="none",o=[]){const n=(new DOMParser).parseFromString(s,"image/svg+xml").documentElement,a=n.querySelector("path"),l=n.getAttribute("viewBox").split(" "),r=a.getAttribute("d");let c=[],h=[];for(const e of n.attributes)switch(e.name){case"transform":case"fill":case"stroke-width":case"stroke-linecap":case"stroke-linejoin":c.push(`${e.name}=${e.value}`)}for(const e of a.attributes)switch(e.name){case"transform":case"fill":case"stroke-width":case"stroke-linecap":case"stroke-linejoin":h.push(`${e.name}=${e.value}`)}const d=[parseInt(l[2]),parseInt(l[3]),o,i,r,{svgAttributes:c.length?c.join(" "):null,pathAttributes:h.length?h.join(" "):null}];t.ICONS[e]&&console.warn(`${e} will be added/replaced in LX.ICONS`),t.ICONS[e]=d},t.registerCommandbarEntry=function(e,s){t.extraCommandbarEntries.push({name:e,callback:s})},t.message=function(e,s,i={}){if(!e)throw"No message to show";return i.modal=!0,new t.Dialog(s,t=>{t.addTextArea(null,e,null,{disabled:!0,fitHeight:!0})},i)},t.popup=function(e,s,i={}){if(!e)throw"No message to show";i.size=i.size??["max-content","auto"],i.class="lexpopup";const o=i.timeout||3e3,n=new t.Dialog(s,t=>{t.addTextArea(null,e,null,{disabled:!0,fitHeight:!0})},i);return setTimeout(()=>{n.close()},Math.max(o,150)),n},t.prompt=function e(s,i,o,n={}){n.modal=!0,n.className="prompt";let a="";const l=new t.Dialog(i,r=>{r.addTextArea(null,s,null,{disabled:!0,fitHeight:!0}),(n.input??1)&&r.addText(null,n.input||a,e=>a=e,{placeholder:"..."}),r.sameLine(2),r.addButton(null,"Cancel",()=>{n.on_cancel&&n.on_cancel(),l.close()}),r.addButton(null,n.accept||"Continue",()=>{n.required&&""===a?(s+=s.includes("You must fill the input text.")?"":"\nYou must fill the input text.",l.close(),e(s,i,o,n)):(o&&o.call(t,a),l.close())},{buttonClass:"primary"})},n);return(n.input??1)&&l.root.querySelector("input").focus(),l},t.toast=function(e,s,i={}){if(!e)throw"The toast needs at least a title!";const o=t.notifications;console.assert(o);const n=document.createElement("li");n.className="lextoast",o.prepend(n);const[a,l]=i.position?i.position.split("-"):["bottom","right"];switch(o.style.right="unset",o.style.left="unset",o.style.top="unset",o.style.bottom="unset",o.style.placeSelf="unset",a){case"top":n.style.translate="0 -30px",o.style.top="1rem",o.style.flexDirection="column";break;case"bottom":n.style.translate="0 calc(100% + 30px)",o.style.top="auto",o.style.bottom="1rem",o.style.flexDirection="column-reverse"}switch(l){case"left":o.style.left="1rem";break;case"center":o.style.placeSelf="center";break;case"right":o.style.right="1rem"}n.classList.add(a),n.classList.add(l),t.doAsync(()=>{o.offsetWidth>o.iWidth&&(o.iWidth=Math.min(o.offsetWidth,480),o.style.width=o.iWidth+"px"),n.dataset.open=!0},10);const r=document.createElement("div");r.className="lextoastcontent",n.appendChild(r);const c=document.createElement("div");if(c.className="title",c.innerHTML=e,r.appendChild(c),s){const e=document.createElement("div");e.className="desc",e.innerHTML=s,r.appendChild(e)}if(i.action){const e=new ee;e.addButton(null,i.action.name??"Accept",i.action.callback.bind(t,n),{width:"auto",maxWidth:"150px",className:"right",buttonClass:"border"}),n.appendChild(e.root.childNodes[0])}if(n.close=function(){this.dataset.open="false",t.doAsync(()=>{this.remove(),t.notifications.childElementCount||(t.notifications.style.width="unset",t.notifications.iWidth=0)},500)},i.closable??1){const e=t.makeIcon("X",{iconClass:"closer"});e.addEventListener("click",()=>{n.close()}),n.appendChild(e)}const h=i.timeout??3e3;-1!=h&&t.doAsync(()=>{n.close()},h)},t.badge=function(e,s,i={}){const o=document.createElement("div");if(o.innerHTML=e,o.className="lexbadge "+(s??""),i.chip&&o.classList.add("chip"),Object.assign(o.style,i.style??{}),i.callback){const e=t.makeIcon("ArrowUpRight",{svgClass:"xs fg-contrast"});e.querySelector("svg").style.marginLeft="-0.25rem",o.innerHTML+=e.innerHTML,o.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),i.callback()})}return i.parent&&(i.parent.classList.add("lexbadge-parent"),i.parent.appendChild(o)),i.asElement?o:o.outerHTML},t.makeElement=function(e,t,s,i,o={}){const n=document.createElement(e);return n.className=t??"",n.innerHTML=s??"",Object.assign(n.style,o),i&&(i.attach?i.attach(n):i.appendChild(n)),n},t.makeContainer=function(e,s,i,o,n={}){const a=t.makeElement("div","lexcontainer "+(s??""),i,o,n);return a.style.width=e&&e[0]?e[0]:"100%",a.style.height=e&&e[1]?e[1]:"100%",a},t.asTooltip=function(e,s,i={}){console.assert(e,"You need a trigger to generate a tooltip!"),e.dataset.disableTooltip=!(i.active??1);let o=null;const n=i.offset,a=i.offsetX??n??0,l=i.offsetY??n??6;e.addEventListener("mouseenter",function(n){if("true"==e.dataset.disableTooltip)return;o=document.createElement("div"),o.className="lextooltip",o.innerHTML=e.dataset.tooltipContent??s;const r=e.closest("dialog"),c=r??t.root;t.root.querySelectorAll(".lextooltip").forEach(e=>e.remove()),c.appendChild(o),t.doAsync(()=>{const s=[0,0],n=parseFloat(e.dataset.tooltipOffsetX??a),h=parseFloat(e.dataset.tooltipOffsetY??l),d=e.getBoundingClientRect();let u=!0;switch(i.side??"top"){case"left":s[0]+=d.x-o.offsetWidth-n,u=!1;break;case"right":s[0]+=d.x+d.width+n,u=!1;break;case"top":s[1]+=d.y-o.offsetHeight-h,u=!0;break;case"bottom":s[1]+=d.y+d.height+h,u=!0}if(u?s[0]+=d.x+.5*d.width-.5*o.offsetWidth+n:s[1]+=d.y+.5*d.height-.5*o.offsetHeight+h,s[0]=t.clamp(s[0],0,window.innerWidth-o.offsetWidth-4),s[1]=t.clamp(s[1],0,window.innerHeight-o.offsetHeight-4),r){let e=c.getBoundingClientRect();s[0]-=e.x,s[1]-=e.y}o.style.left=`${s[0]}px`,o.style.top=`${s[1]}px`,i.callback&&i.callback(o,e)})}),e.addEventListener("mouseleave",function(e){o&&o.remove()})},t.insertChildAtIndex=function(e,t,s=1/0){s>=e.children.length?e.appendChild(t):e.insertBefore(t,e.children[s])},t.getComputedSize=function(e){return{width:e.offsetWidth,height:e.offsetHeight}},t.listen=function(e,t,s,i){e[i=i??"_on"+t]=s,e.addEventListener(t,s)},t.ignore=function(e,t,s){const i=e[s=s??"_on"+t];e.removeEventListener(t,i)},t.getParentArea=function(e){let t=e.parentElement;for(;t;){if(t.classList.contains("lexarea"))return t;t=t.parentElement}},t.hasClass=function(e,t){return!!(t=[].concat(t)).filter(t=>e.classList.contains(t)).length},t.addClass=function(e,t){t&&e.classList.add(t)},t.removeClass=function(e,t){t&&e.classList.remove(t)},t.toggleClass=function(e,t,s){t&&e.classList.toggle(t,s)},t.lastChar=function(e){return e[e.length-1]},Object.assign(t,{request(e){var t=e.dataType||"text";"json"==t||"xml"==t?t="text":"binary"==t&&(t="arraybuffer",e.mimeType="application/octet-stream");var s=new XMLHttpRequest;s.open(e.data?"POST":"GET",e.url,!0),t&&(s.responseType=t),e.mimeType&&s.overrideMimeType(e.mimeType),e.nocache&&s.setRequestHeader("Cache-Control","no-cache"),s.onload=function(t){var s=this.response;if(200==this.status){if("json"==e.dataType)try{s=JSON.parse(s)}catch(i){if(!e.error)throw i;e.error(i)}else if("xml"==e.dataType)try{s=(new DOMParser).parseFromString(s,"text/xml")}catch(i){if(!e.error)throw i;e.error(i)}e.success&&e.success.call(this,s,this)}else{var i="Error "+this.status;e.error&&e.error(i)}},s.onerror=function(t){e.error&&e.error(t)};var i=new FormData;if(e.data)for(var o in e.data)i.append(o,e.data[o]);return s.send(i),s},requestText(e,t,s){return this.request({url:e,dataType:"text",success:t,error:s})},requestJSON(e,t,s){return this.request({url:e,dataType:"json",success:t,error:s})},requestBinary(e,t,s){return this.request({url:e,dataType:"binary",success:t,error:s})},requireScript(e,t,s,i,o){if(!e)throw"invalid URL";e.constructor===String&&(e=[e]);var n=e.length,a=[];for(var l in e){var r=document.createElement("script");r.num=l,r.type="text/javascript",r.src=e[l]+(o?"?version="+o:""),r.original_src=e[l],r.async=!1,r.onload=function(e){n--,a.push(this),n?i&&i(this.original_src,this.num):t&&t(a)},s&&(r.onerror=function(e){s(e,this.original_src,this.num)}),document.getElementsByTagName("head")[0].appendChild(r)}},loadScriptSync:e=>new Promise((t,s)=>{const i=document.createElement("script");i.src=e,i.async=!1,i.onload=()=>t(1),i.onerror=()=>s(new Error(`Failed to load ${e}`)),document.head.appendChild(i)}),downloadURL(e,s){const i=new FileReader,o=function(e){var t=document.createElement("a");t.href=e,t.download=s,document.body.appendChild(t),t.click(),document.body.removeChild(t)};e.includes("http")?t.request({url:e,dataType:"blob",success:e=>{i.readAsDataURL(e),i.onload=e=>{o(e.currentTarget.result)}}}):o(e)},downloadFile:function(e,t,s){if(t){s||(s=t.constructor===String?"text/plain":"application/octet-stream");var i=null;i=t.constructor!==File&&t.constructor!==Blob?new Blob([t],{type:s}):t;var o=URL.createObjectURL(i),n=document.createElement("a");n.setAttribute("href",o),n.setAttribute("download",e),n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(function(){URL.revokeObjectURL(o)},6e4)}else console.warn("No file provided to download")}}),t.formatBytes=function(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toFixed(2)+" "+["B","KB","MB","GB","TB"][t]},t.compareThreshold=function(e,t,s,i){return Math.abs(e-t)>=i||Math.abs(e-s)>=i},t.compareThresholdRange=function(e,t,s,i){return e>=s&&e<=i||t>=s&&t<=i||e<=s&&t>=i},t.getControlPoints=function(e,t,s,i,o,n,a){var l=Math.sqrt(Math.pow(s-e,2)+Math.pow(i-t,2)),r=a*l/(l+Math.sqrt(Math.pow(o-s,2)+Math.pow(n-i,2))),c=a-r;return[s+r*(e-o),i+r*(t-n),s-c*(e-o),i-c*(t-n)]},t.drawSpline=function(e,s,i){e.save();for(var o=[],n=s.length,a=0;a<n-4;a+=2)o=o.concat(t.getControlPoints(s[a],s[a+1],s[a+2],s[a+3],s[a+4],s[a+5],i));for(a=2;a<s.length-5;a+=2)e.beginPath(),e.moveTo(s[a],s[a+1]),e.bezierCurveTo(o[2*a-2],o[2*a-1],o[2*a],o[2*a+1],s[a+2],s[a+3]),e.stroke(),e.closePath();e.beginPath(),e.moveTo(s[0],s[1]),e.quadraticCurveTo(o[0],o[1],s[2],s[3]),e.stroke(),e.closePath(),e.beginPath(),e.moveTo(s[n-2],s[n-1]),e.quadraticCurveTo(o[2*n-10],o[2*n-9],s[n-4],s[n-3]),e.stroke(),e.closePath(),e.restore()};class le{root;constructor(e={}){const s=e.icon??"LoaderCircle",i=e.size??"md",o=`flex ${e.iconClass??""}`.trim(),n=`animate-spin ${i} ${e.svgClass??""}`.trim();this.root=t.makeIcon(s,{iconClass:o,svgClass:n})}html(){return this.root.innerHTML}destroy(){this.root.remove()}}t.Spinner=le;let re=class e{static _last_id=0;id;root;panel;title;size=[];branchData;close=()=>{};_oncreate;constructor(s,i,o={}){i||console.warn("Content is empty, add some components using 'callback' parameter!"),this._oncreate=i,this.id=t.guidGenerator();const n=o.size??[],a=o.position??[],l=o.draggable??!0,r=o.dockable??!1,c=o.modal??!1;let h=document.createElement("dialog");h.className="lexdialog "+(o.className??""),h.id=o.id??"dialog"+e._last_id++,h.dataset.modal=c,t.root.appendChild(h),t.doAsync(()=>{c?h.showModal():h.show()},10);let d=this;const u=document.createElement("div");if(s&&(u.className="lexdialogtitle",u.innerHTML=s,u.setAttribute("draggable","false"),h.appendChild(u)),o.closable??1){this.close=()=>{o.onBeforeClose&&o.onBeforeClose(this),o.onclose?o.onclose(this.root):(h.close(),t.doAsync(()=>{d.panel.clear(),h.remove()},150))};const e=t.makeIcon("X",{title:"Close",iconClass:"lexdialogcloser"});e.addEventListener("click",this.close);const i=t.makeIcon("Minus",{title:"Dock",iconClass:"ml-auto mr-2"});i.addEventListener("click",()=>{const e=this.branchData,t=e.panel,s=t.root.childElementCount,i=t.branch(e.name,{closed:e.closed});i.components=e.components;for(let e of i.components)i.content.appendChild(e.root);e.childIndex<s&&t.root.insertChildAtIndex(i.root,e.childIndex),this.close()}),s?(r&&u.appendChild(i),u.appendChild(e)):(e.classList.add("notitle"),h.appendChild(e))}const p=new t.Panel;p.root.classList.add("lexdialogcontent"),s||p.root.classList.add("notitle"),i&&i.call(this,p),h.appendChild(p.root),p.root.querySelectorAll(".lexbranch").forEach(e=>e.classList.add("dialog")),this.panel=p,this.root=h,this.title=u,l&&t.makeDraggable(h,Object.assign({targetClass:"lexdialogtitle"},o)),n.length&&"string"!=typeof n[0]&&(n[0]+="px"),n.length&&"string"!=typeof n[1]&&(n[1]+="px"),h.style.width=n[0]?n[0]:"25%",h.style.height=n[1]?n[1]:"auto",h.style.translate=o.position?"unset":"-50% -50%",o.size&&(this.size=n),h.style.left=a[0]??"50%",h.style.top=a[1]??"50%",p.root.style.height=s?"calc( 100% - "+(u.offsetHeight+30)+"px )":"calc(100%)"}destroy(){this.root.remove()}refresh(){this.panel.root.innerHTML="",this._oncreate.call(this,this.panel)}setPosition(e,t){this.root.style.left=`${e}px`,this.root.style.top=`${t}px`}setTitle(e){const t=this.root.querySelector(".lexdialogtitle");t&&(t.innerText=e)}};t.Dialog=re;class ce extends re{constructor(e,s,i,o={}){o.closable=!1,o.draggable=!1,o.modal=!0,super(void 0,n=>{n.root.classList.add("p-4","flex","flex-col","gap-2"),t.makeContainer(["100%","100%"],"text-xl font-medium",e,n),n.addTextArea(null,s,null,{disabled:!0,fitHeight:!0,inputClass:"bg-none fg-tertiary"}),n.sameLine(2,"justify-end"),n.addButton(null,o.cancelText??"Cancel",()=>this.destroy(),{buttonClass:"border bg-primary"}),n.addButton(null,o.continueText??"Continue",()=>{this.destroy(),i&&i()},{buttonClass:"contrast"})},o)}}t.AlertDialog=ce;class he{root;items;colors;_parent;constructor(e,s,i={}){if(document.body.querySelectorAll(".lexcontextmenu").forEach(e=>e.remove()),this.root=document.createElement("div"),this.root.className="lexcontextmenu",this.root.addEventListener("mouseleave",function(){this.remove()}),this.items=[],this.colors={},s){let e={};e[s]=[],e.className="cmtitle",e.icon=i.icon,this.items.push(e)}const o=e.target.closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=t.root,this._parent.appendChild(this.root);const n=[e.x-48,e.y-8];if(this._parent instanceof HTMLDialogElement){let e=this._parent.getBoundingClientRect();n[0]-=e.x,n[1]-=e.y}this.root.style.left=`${n[0]}px`,this.root.style.top=`${n[1]}px`}_adjustPosition(e,t,s=!1){let i=e.getBoundingClientRect(),o=parseInt(e.style.left),n=parseInt(e.style.top);if(s){let s=window.innerWidth-i.right;s<0&&(o=e.offsetLeft+(s-t)),s=window.innerHeight-(i.top+i.height),s<0&&(n=e.offsetTop+(s-t+20))}else{let s=i.width;i.left<0?o=t:window.innerWidth-i.right<0&&(o=window.innerWidth-s-t),i.top<0?n=t:i.top+i.height>window.innerHeight&&(e.style.marginTop="",n=window.innerHeight-i.height-t)}e.style.left=`${o}px`,e.style.top=`${n}px`}_createSubmenu(e,t,s,i){this.root.querySelectorAll(".lexcontextmenu").forEach(e=>e.remove());let o=document.createElement("div");o.className="lexcontextmenu",s.appendChild(o);for(let s=0;s<e[t].length;++s){const n=e[t][s],a=Object.keys(n)[0];this._createEntry(n,a,o,i)}const n=s.getBoundingClientRect();o.style.left=n.x+n.width+"px",o.style.marginTop="-31px",this._adjustPosition(o,6)}_createEntry(e,s,i,o){const n=e[s].length;let a=document.createElement("div");a.className="lexmenuboxentry"+(e.className?" "+e.className:""),a.id=e.id??"eId"+t.getSupportedDOMName(s),a.innerHTML="";const l=e.icon;l&&a.appendChild(t.makeIcon(l,{svgClass:"sm"}));const r=e.disabled;if(a.innerHTML+="<div class='lexentryname"+(r?" disabled":"")+"'>"+s+"</div>",i.appendChild(a),this.colors[s]&&(a.style.borderColor=this.colors[s]),""==s)return void(a.className+=" cmseparator");if(a.addEventListener("click",i=>{if(i.stopPropagation(),i.stopImmediatePropagation(),r)return;const l=e.callback;l&&(l.call(this,s,a),this.root.remove()),n&&"click"==t.OPEN_CONTEXTMENU_ENTRY&&this._createSubmenu(e,s,a,++o)}),!n)return;const c=t.makeIcon("Menu",{svgClass:"sm"});a.appendChild(c),"mouseover"==t.OPEN_CONTEXTMENU_ENTRY&&a.addEventListener("mouseover",t=>{"true"!=a.dataset.built&&(a.dataset.built="true",this._createSubmenu(e,s,a,++o),t.stopPropagation())}),a.addEventListener("mouseleave",()=>{o=-1,i.querySelectorAll(".lexcontextmenu").forEach(e=>e.remove())})}onCreate(){t.doAsync(()=>this._adjustPosition(this.root,6))}add(e,s={}){s.constructor==Function&&(s={callback:s});const i=(e+="").split("/"),o=i[i.length-1];this.colors[o]=s.color;let n=0;const a=(e,t)=>{if(null==e)return;let o=null;if(t.forEach(t=>{const s=Object.keys(t).find(t=>t==e);s&&(o=t[s])}),o)a(i[n++],o);else{let o={};o[e]=[];const l=i[n++];l||(o.id=s.id,o.icon=s.icon,o.callback=s.callback,o.disabled=s.disabled??!1),t.push(o),a(l,o[e])}};a(i[n++],this.items);const l=e=>{let t=Object.keys(e)[0],s=e[t];if(s.length){if(null==s.find(e=>Object.keys(e)[0]==t)){let s={};s[t]=[],s.className="cmtitle",e[t].unshift(s)}for(let s of e[t]){let e=Object.keys(s)[0];for(let t=0;t<s[e].length;++t)l(s)}}};for(let e of this.items)l(e);for(let e of this.items){let s=Object.keys(e)[0],i="eId"+t.getSupportedDOMName(s);const o="#"+(e.id??i);this.root.querySelector(o)||this._createEntry(e,s,this.root,-1)}}setColor(e,s){"#"!==s[0]&&(s=t.rgbToHex(s)),this.colors[e]=s}}t.ContextMenu=he,t.addContextMenu=function(e,t,s,i={}){const o=new he(t,e,i);return s&&s(o),o.onCreate(),o};class de{static currentMenu=null;root;side="bottom";align="center";sideOffset=0;alignOffset=0;avoidCollisions=!0;onBlur;event;inPlace=!1;_trigger;_items=[];_parent;_windowPadding=4;_onClick;_radioGroup;invalid=!1;constructor(e,s,i={}){if(console.assert(e,"DropdownMenu needs a DOM element as trigger!"),de.currentMenu||!s?.length)return de.currentMenu?.destroy(),void(this.invalid=!0);this._trigger=e,e.classList.add("triggered"),e.ddm=this,this._items=s,this.side=i.side??"bottom",this.align=i.align??"center",this.sideOffset=i.sideOffset??0,this.alignOffset=i.alignOffset??0,this.avoidCollisions=i.avoidCollisions??!0,this.onBlur=i.onBlur,this.event=i.event,this.root=document.createElement("div"),this.root.id="root",this.root.dataset.side=this.side,this.root.tabIndex="1",this.root.className="lexdropdownmenu";const o=e.closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=t.root,this._parent.appendChild(this.root),this._create(this._items),de.currentMenu=this,t.doAsync(()=>{this._adjustPosition(),this.root.focus(),this._onClick=e=>{(!e.target||null==e.target.closest(".lexdropdownmenu")&&e.target!=this._trigger)&&this.destroy(!0)},document.body.addEventListener("mousedown",this._onClick,!0),document.body.addEventListener("focusin",this._onClick,!0)},10)}destroy(e=!1){this._trigger.classList.remove("triggered"),delete this._trigger.ddm,document.body.removeEventListener("mousedown",this._onClick,!0),document.body.removeEventListener("focusin",this._onClick,!0),this._parent.querySelectorAll(".lexdropdownmenu").forEach(e=>{e.remove()}),de.currentMenu=null,e&&this.onBlur&&this.onBlur()}_create(e,s){if(s){const e=s.getBoundingClientRect();let i=document.createElement("div");i.tabIndex="1",i.className="lexdropdownmenu",i.dataset.id=s.dataset.id,i.dataset.side="right",this._parent.appendChild(i),i.currentParent=s,s=i,t.doAsync(()=>{const s=[e.x+e.width,e.y];if(this._parent instanceof HTMLDialogElement){let e=this._parent.getBoundingClientRect();s[0]-=e.x,s[1]-=e.y}this.avoidCollisions&&(s[0]=t.clamp(s[0],0,window.innerWidth-i.offsetWidth-this._windowPadding),s[1]=t.clamp(s[1],0,window.innerHeight-i.offsetHeight-this._windowPadding)),i.style.left=`${s[0]}px`,i.style.top=`${s[1]}px`},10)}else s=this.root;let i=e.filter(e=>null!=e?.icon||null!=e?.checked).length>0;for(let t of e)this._createItem(t,s,i)}_createItem(e,s,i){if(!e)return void this._addSeparator(s);const o=e.name??e,n=t.getSupportedDOMName(o);if(s.querySelector("#"+n))return;const a=document.createElement("div");if(a.className="lexdropdownmenuitem"+(e.name||e.options?"":" label")+(e.disabled?" disabled":"")+` ${e.className??""}`,a.dataset.id=n,a.innerHTML=`<span class="ellipsis-overflow">${o}</span>`,a.tabIndex="1",s.appendChild(a),e.constructor===String)return;if(e.submenu){const e=t.makeIcon("Right",{svgClass:"sm"});a.appendChild(e)}else if(e.kbd){e.kbd=[].concat(e.kbd);const s=t.makeKbd(e.kbd);a.appendChild(s),document.addEventListener("keydown",t=>{if(!this._trigger.ddm)return;t.preventDefault();let s=e.kbd.join("");s=1==s.length?s.toLowerCase():s,s==t.key&&a.click()})}const l=e.disabled??!1;if(void 0!==this._radioGroup){if(e.name===this._radioGroup.selected){const e=t.makeIcon("Circle",{svgClass:"xxs fill-current"});a.prepend(e)}a.setAttribute("data-radioname",this._radioGroup.name)}else if(e.icon){const s=e.icon.constructor===String?t.makeIcon(e.icon,{svgClass:l?"fg-tertiary":e.svgClass??e.className}):e.icon;a.prepend(s)}else null==e.checked&&i&&a.classList.add("pl-8");if(!l){if(null!=e.checked){const t=new g(n+"_entryChecked",e.checked,t=>{const s=e.callback;e.checked=t,s&&s.call(this,o,t,a)},{className:"accent"}),s=t.root.querySelector("input");s.classList.add("ml-auto"),a.appendChild(s),a.addEventListener("click",e=>{"checkbox"!=e.target.type&&(s.checked=!s.checked,t.set(s.checked))})}else a.addEventListener("click",t=>{const s=a.getAttribute("data-radioname");s&&(this._trigger[s]=o);const i=e.callback;i&&i.call(this,o,a,s),!e.options&&(e.closeOnClick??1)&&this.destroy(!0)});if(a.addEventListener("mouseover",t=>{let i=a.dataset.id;if(!i)return;let o=s;for(;o;)i+="/"+o.dataset.id,o=o.currentParent?.parentElement;if(this._parent.querySelectorAll(".lexdropdownmenu").forEach(e=>{i.includes(e.dataset.id)||(e.currentParent.built=!1,e.remove())}),e.submenu&&this.inPlace){if(a.built)return;a.built=!0,this._create(e.submenu,a)}t.stopPropagation()}),e.options){console.assert(this._trigger[e.name]&&"An item of the radio group must be selected!"),this._radioGroup={name:e.name,selected:this._trigger[e.name]};for(let t of e.options)this._createItem(t,s,i);delete this._radioGroup,this._addSeparator()}}}_adjustPosition(){const e=[0,0],s=this._trigger.getBoundingClientRect();if(this.event)e[0]=this.event.x,e[1]=this.event.y;else{let t=!0;switch(this.side){case"left":e[0]+=s.x-this.root.offsetWidth-this.sideOffset,t=!1;break;case"right":e[0]+=s.x+s.width+this.sideOffset,t=!1;break;case"top":e[1]+=s.y-this.root.offsetHeight-this.sideOffset,t=!0;break;case"bottom":e[1]+=s.y+s.height+this.sideOffset,t=!0}switch(this.align){case"start":t?e[0]+=s.x:e[1]+=s.y;break;case"center":t?e[0]+=s.x+.5*s.width-.5*this.root.offsetWidth:e[1]+=s.y+.5*s.height-.5*this.root.offsetHeight;break;case"end":t?e[0]+=s.x-this.root.offsetWidth+s.width:e[1]+=s.y-this.root.offsetHeight+s.height}t?e[0]+=this.alignOffset:e[1]+=this.alignOffset}if(this._parent instanceof HTMLDialogElement){let t=this._parent.getBoundingClientRect();e[0]-=t.x,e[1]-=t.y}this.avoidCollisions&&(e[0]=t.clamp(e[0],0,window.innerWidth-this.root.offsetWidth-this._windowPadding),e[1]=t.clamp(e[1],0,window.innerHeight-this.root.offsetHeight-this._windowPadding)),this.root.style.left=`${e[0]}px`,this.root.style.top=`${e[1]}px`,this.inPlace=!0}_addSeparator(e=null){const t=document.createElement("div");t.className="separator",e=e??this.root,e?.appendChild(t)}}function ue(e,t,s={}){const i=new de(e,t,s);return i.invalid?null:i}t.DropdownMenu=de,t.addDropdownMenu=ue;class pe{root;constructor(e={}){const s=document.createElement("footer");s.className=`lexfooter ${e.className??""}`;const i=document.createElement("div");if(i.style.minHeight="48px",i.className="w-full",s.appendChild(i),e.columns&&e.columns.constructor==Array){const t=document.createElement("div");t.className="columns",t.style.gridTemplateColumns="1fr ".repeat(e.columns.length),i.appendChild(t);for(let s of e.columns){const e=document.createElement("div");e.className="col",t.appendChild(e);const i=document.createElement("h2");if(i.innerHTML=s.title,e.appendChild(i),!s.items||!s.items.length)continue;const o=document.createElement("ul");e.appendChild(o);for(let e of s.items){const t=document.createElement("li");t.innerHTML=`<a class="" href="${e.link}">${e.title}</a>`,o.appendChild(t)}}}if(e.credits||e.socials){const s=document.createElement("div");if(s.className="credits-and-socials",i.appendChild(s),e.credits){const t=document.createElement("p");t.innerHTML=e.credits,s.appendChild(t)}if(e.socials){const i=document.createElement("div");i.className="socials flex flex-row gap-1 my-2 justify-end";for(let s of e.socials){const e=t.makeIcon(s.icon,{title:s.title,svgClass:"xl"});e.href=s.link,e.target="_blank",i.appendChild(e)}s.appendChild(i)}}(e.parent??document.body).appendChild(s),s.previousElementSibling&&(s.previousElementSibling.style.flexGrow="1"),this.root=s}}t.Footer=pe;let me=class e extends re{static TOP=0;static BOTTOM=1;dockPosition=e.TOP;minimized=!1;constructor(s,i,o={}){o.draggable=o.draggable??!1,o.closable=o.closable??!1;super(s,i,o);let n=this;t.addSignal("@on_branch_closed",this.panel,t=>{this.dockPosition==e.BOTTOM&&(this.root.style.top=`calc(100% - ${this.root.offsetHeight+3}px)`)}),this.root.classList.add("pocket"),this.root.style.translate="none",this.root.style.top="0",this.root.style.left="unset",o.position||(this.root.style.right="3px",this.root.style.top="3px"),this.panel.root.style.width="100%",this.panel.root.style.height="100%";const a=this.title;if(a.tabIndex=-1,a.addEventListener("click",t=>{a.eventCatched?a.eventCatched=!1:(this.size&&(this.minimized?this.root.style.height=this.size[1]:this.root.style.height="auto"),this.root.classList.toggle("minimized"),this.minimized=!this.minimized,this.dockPosition==e.BOTTOM&&(n.root.style.top=this.root.classList.contains("minimized")?`calc(100% - ${n.title.offsetHeight+6}px)`:`calc(100% - ${n.root.offsetHeight+3}px)`))}),!o.draggable){const t=o.float;if(t)for(let e=0;e<t.length;e++){switch(t[e]){case"b":this.root.style.top=`calc(100% - ${this.root.offsetHeight+3}px)`;break;case"l":this.root.style.right="unset",this.root.style.left=o.position?o.position[1]:"3px"}}this.root.classList.add("dockable"),a.addEventListener("keydown",function(t){t.ctrlKey&&(n.root.style.right="unset","ArrowLeft"==t.key?n.root.style.left="0px":"ArrowRight"==t.key?n.root.style.left=`calc(100% - ${n.root.offsetWidth+3}px)`:"ArrowUp"==t.key?(n.root.style.top="0px",n.dockPosition=e.TOP):"ArrowDown"==t.key&&(n.root.style.top=`calc(100% - ${n.root.offsetHeight+3}px)`,n.dockPosition=e.BOTTOM))})}}};t.PocketDialog=me;class ge{side="left";root;_onClick;constructor(e,s,i={}){this.side=i.side??this.side,this.root=document.createElement("div"),this.root.dataset.side=this.side,this.root.tabIndex="1",this.root.role="dialog",this.root.className="lexsheet fixed z-1000 bg-primary",document.body.appendChild(this.root),this.root.addEventListener("keydown",e=>{"Escape"==e.key&&(e.preventDefault(),e.stopPropagation(),this.destroy())}),s&&(s=[].concat(s)).forEach(e=>{const t=e.root??e;this.root.appendChild(t),e.onSheet&&e.onSheet()}),t.doAsync(()=>{switch(t.modal.toggle(!1),this.side){case"left":this.root.style.left="0",this.root.style.width=e,this.root.style.height="100%";break;case"right":this.root.style.right="0",this.root.style.width=e,this.root.style.height="100%";break;case"top":this.root.style.left="0",this.root.style.top="0",this.root.style.width="100%",this.root.style.height=e;break;case"bottom":this.root.style.left="0",this.root.style.bottom="0",this.root.style.width="100%",this.root.style.height=e}document.documentElement.setAttribute("data-scale",`sheet-${this.side}`),this.root.focus(),this._onClick=e=>{e.target&&this.root.contains(e.target)||this.destroy()},document.body.addEventListener("mousedown",this._onClick,!0),document.body.addEventListener("focusin",this._onClick,!0)},10)}destroy(){document.documentElement.setAttribute("data-scale",""),document.body.removeEventListener("mousedown",this._onClick,!0),document.body.removeEventListener("focusin",this._onClick,!0),this.root.remove(),t.modal.toggle(!0)}}t.Sheet=ge;class fe{root;callback;items=[];icons={};groups={};side;collapsable;collapsed;filterString;filter;header;content;footer;resizeObserver=void 0;siblingArea=void 0;currentGroup;collapseQueue;collapseContainer;_collapseWidth;_displaySelected=!0;get displaySelected(){return this._displaySelected}set displaySelected(e){this._displaySelected=e,e||this.root.querySelectorAll(".lexsidebarentry").forEach(e=>e.classList.remove("selected"))}constructor(e={}){const s=navigator&&/Android|iPhone/i.test(navigator.userAgent);if(this.root=document.createElement("div"),this.root.className="lexsidebar flex flex-col "+(e.className??""),this.callback=e.callback??null,this._displaySelected=e.displaySelected??!1,this.side=e.side??"left",this.collapsable=e.collapsable??!0,this._collapseWidth=e.collapseToIcons??1?"58px":"0px",this.collapsed=e.collapsed??s,this.filterString="",t.doAsync(()=>{if(this.root.parentElement.ogWidth=this.root.parentElement.style.width,this.root.parentElement.style.transition=this.collapsed?"":"width 0.25s ease-out",this.resizeObserver=new ResizeObserver(e=>{for(const t of e)this.siblingArea?.setSize(["calc(100% - "+t.contentRect.width+"px )",null])}),this.collapsed){if(this.root.classList.toggle("collapsed",this.collapsed),this.root.parentElement.style.width=this._collapseWidth,!this.resizeObserver)throw"Wait until ResizeObserver has been created!";this.resizeObserver.observe(this.root.parentElement),t.doAsync(()=>{this.resizeObserver?.unobserve(this.root.parentElement),this.root.querySelectorAll(".lexsidebarentrycontent").forEach(e=>e.dataset.disableTooltip=`${!this.collapsed}`)},10)}},10),!e.skipHeader&&(this.header=e.header??this._generateDefaultHeader(e),console.assert(this.header.constructor===HTMLDivElement,"Use an HTMLDivElement to build your custom header"),this.header.className="lexsidebarheader flex-auto",this.root.appendChild(this.header),this.collapsable)){const i=t.makeIcon("left"==this.side?"PanelLeft":"PanelRight",{title:"Toggle Sidebar",iconClass:"toggler"});if(this.header.appendChild(i),s){const s=new se({skipAppend:!0}),o=t.deepCopy(e);o.collapsed=!1,o.collapsable=!1,s.addSidebar(this.callback,o),i.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),new t.Sheet("256px",[s],{side:this.side})})}else i.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.toggleCollapsed()})}if(e.filter){const e=new d(null,"",(e,t)=>{this.filterString=e,this.update()},{inputClass:"outline",placeholder:"Search...",icon:"Search",className:"lexsidebarfilter"});this.filter=e.root,this.root.appendChild(this.filter)}this.content=document.createElement("div"),this.content.className="lexsidebarcontent flex-auto-fill",this.root.appendChild(this.content),e.skipFooter||(this.footer=e.footer??this._generateDefaultFooter(e),console.assert(this.footer.constructor===HTMLDivElement,"Use an HTMLDivElement to build your custom footer"),this.footer.className="lexsidebarfooter flex-auto",this.root.appendChild(this.footer))}_generateDefaultHeader(e={}){const s=document.createElement("div");s.addEventListener("click",t=>{this.collapsed?(t.preventDefault(),t.stopPropagation(),this.toggleCollapsed()):e.onHeaderPressed&&e.onHeaderPressed(t)});const i=document.createElement("span");if(i.className="lexavatar",s.appendChild(i),e.headerImage){const t=document.createElement("img");t.src=e.headerImage,i.appendChild(t)}else if(e.headerIcon){const s=t.makeIcon(e.headerIcon);i.appendChild(s)}{const t=document.createElement("div");t.className="infodefault",s.appendChild(t);const i=document.createElement("span");i.innerHTML=e.headerTitle??"",t.appendChild(i);const o=document.createElement("span");o.innerHTML=e.headerSubtitle??"",t.appendChild(o)}if(e.onHeaderPressed&&!this.collapsable){const e=t.makeIcon("MenuArrows");s.appendChild(e)}return s}_generateDefaultFooter(e={}){const s=document.createElement("div");s.addEventListener("click",t=>{e.onFooterPressed&&e.onFooterPressed(t,s)});const i=document.createElement("span");if(i.className="lexavatar",s.appendChild(i),e.footerImage){const t=document.createElement("img");t.src=e.footerImage,i.appendChild(t)}else if(e.footerIcon){const s=t.makeIcon(e.footerIcon);i.appendChild(s)}{const t=document.createElement("div");t.className="infodefault",s.appendChild(t);const i=document.createElement("span");i.innerHTML=e.footerTitle??"",t.appendChild(i);const o=document.createElement("span");o.innerHTML=e.footerSubtitle??"",t.appendChild(o)}if(e.onFooterPressed){const e=t.makeIcon("MenuArrows");s.appendChild(e)}return s}toggleCollapsed(e){if(this.collapsable){if(this.collapsed=e??!this.collapsed,this.collapsed?(this.root.classList.add("collapsing"),this.root.parentElement.style.width=this._collapseWidth):(this.root.classList.remove("collapsing"),this.root.classList.remove("collapsed"),this.root.parentElement.style.width=this.root.parentElement.ogWidth),!this.resizeObserver)throw"Wait until ResizeObserver has been created!";this.resizeObserver.observe(this.root.parentElement),t.doAsync(()=>{this.root.classList.toggle("collapsed",this.collapsed),this.resizeObserver?.unobserve(this.root.parentElement),this.root.querySelectorAll(".lexsidebarentrycontent").forEach(e=>e.dataset.disableTooltip=`${!this.collapsed}`)},250)}}separator(){this.currentGroup=null,this.add("")}group(e,t){this.currentGroup=e,this.groups[e]=t}add(e,t={}){t.constructor==Function&&(t={callback:t});const s=e.split("/"),i=s[s.length-1];this.icons[i]=t.icon;let o=0;const n=(e,i)=>{if(null==e)return;let a=null;if(i.forEach(t=>{const s=Object.keys(t).find(t=>t==e);s&&(a=t[s])}),a)n(s[o++],a);else{let a={};a[e]=[];const l=s[o++];l||(a.callback=t.callback,a.group=this.currentGroup,a.options=t),i.push(a),n(l,a[e])}};n(s[o++],this.items)}select(e){let s=t.getSupportedDOMName(e);const i=this.items.find(e=>e.name===s);i&&i.dom.click()}update(){this.content.innerHTML="";for(let e of this.items)delete e.dom;for(let e of this.items){const s=e.options??{};if(e.dom)continue;let i=e.name=Object.keys(e)[0];if(this.filterString.length&&!i.toLowerCase().includes(this.filterString.toLowerCase()))continue;let o=t.getSupportedDOMName(i),n=null,a=document.createElement("div");if(a.id=o,a.className="lexsidebarentry "+(s.className??""),this.displaySelected&&s.selected&&a.classList.add("selected"),e.group){const s=e.group.replace(/\s/g,"").replaceAll(".","");if(n=this.content.querySelector("#"+s),n){if(!n.classList.contains("lexsidebargroup"))throw"Bad id: "+e.group}else{n=document.createElement("div"),n.id=s,n.className="lexsidebargroup",this.content.appendChild(n);let i=document.createElement("div");i.className="lexsidebargrouptitle",n.appendChild(i);let o=document.createElement("div");if(o.innerHTML=e.group,i.appendChild(o),null!=this.groups[e.group]){const s=t.makeIcon(this.groups[e.group].icon,{svgClass:"sm"});i.appendChild(s),s.addEventListener("click",t=>{this.groups[e.group].callback&&this.groups[e.group].callback(e.group,t)})}}}if(""==o){let e=document.createElement("div");e.className="lexsidebarseparator",this.content.appendChild(e);continue}this.collapseContainer?(this.collapseContainer.appendChild(a),this.collapseQueue--,this.collapseQueue||delete this.collapseContainer):n?n.appendChild(a):this.content.appendChild(a);let l=document.createElement("div");if(l.className="lexsidebarentrycontent",a.appendChild(l),e.dom=a,"checkbox"==s.type){e.value=s.value??!1;const t=new ee;e.checkbox=t.addCheckbox(null,e.value,(t,o)=>{o.preventDefault(),o.stopPropagation();const n=s.callback;e.value=t,n&&n.call(this,i,t,o)},{className:"accent",label:i,signal:"@checkbox_"+i}),l.appendChild(t.root.childNodes[0])}else{if(s.icon){const e=t.makeIcon(s.icon,{iconClass:"lexsidebarentryicon"});l.appendChild(e),t.asTooltip(l,i,{side:"right",offset:16,active:!1})}if(t.makeElement("a","grid-column-start-2",i,l),s.swap){l.classList.add("swap","inline-grid"),l.querySelector("a")?.classList.add("swap-off");const e=document.createElement("input");e.className="p-0 border-0",e.type="checkbox",l.prepend(e);const i=t.makeIcon(s.swap,{iconClass:"lexsidebarentryicon swap-on"});l.appendChild(i)}s.content&&l.appendChild(s.content)}const r=null!=s.collapsable?s.collapsable:s.collapsable||e[i].length;if(a.addEventListener("click",t=>{if(t.target&&t.target.classList.contains("lexcheckbox"))return;let o;if(r)l.querySelector(".collapser")?.click();else if(e.checkbox)e.value=!e.value,e.checkbox.set(e.value,!0),o=e.value;else if(s.swap&&!(t.target instanceof HTMLInputElement)){const e=l.querySelector("input");e.checked=!e.checked,o=e.checked}const n=s.callback;n&&n.call(this,i,o??a,t),this.displaySelected&&!s.skipSelection&&(this.root.querySelectorAll(".lexsidebarentry").forEach(e=>e.classList.remove("selected")),a.classList.add("selected"))}),s.action){const e=t.makeIcon(s.action.icon??"Ellipsis",{title:s.action.name});l.appendChild(e),e.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation();const t=s.action.callback;t&&t.call(this,i,e)})}else if(r){const e=document.createElement("div");e.className="collapsablecontainer",Object.assign(e.style,{width:"100%",display:"none"}),t.makeCollapsible(l,e,n??this.content),this.collapseQueue=s.collapsable,this.collapseContainer=e}if(!e[i].length)continue;let c=document.createElement("div");c.className="lexsidebarsubentrycontainer",r?(this.collapseContainer.appendChild(c),delete this.collapseContainer):n?(c.classList.add("collapsablecontainer"),n.appendChild(c)):this.content.appendChild(c);for(let s=0;s<e[i].length;++s){const o=e[i][s],n=o.options??{},a=o.name=Object.keys(o)[0];if(this.filterString.length&&!a.toLowerCase().includes(this.filterString.toLowerCase()))continue;let l=document.createElement("div");if(l.innerHTML=`<span>${a}</span>`,n.action){const e=t.makeIcon(n.action.icon??"Ellipsis",{title:n.action.name});l.appendChild(e),e.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation();const t=n.action.callback;t&&t.call(this,a,e)})}if(l.className="lexsidebarentry",l.id=a,n.content){const e=t.makeElement("div");e.appendChild(n.content),l.appendChild(e)}c.appendChild(l),l.addEventListener("click",e=>{const t=n.callback;t&&t.call(this,a,l,e),this.displaySelected&&!n.skipSelection&&(this.root.querySelectorAll(".lexsidebarentry").forEach(e=>e.classList.remove("selected")),l.classList.add("selected"))})}}}}t.Sidebar=fe;class Ce{root;constructor(e){if(this.root=t.makeContainer(["auto","auto"],"flex flex-row lexskeleton"),e.constructor===String)this.root.innerHTML=e;else{e=[].concat(e);for(let t of e)this.root.appendChild(t)}}destroy(){this.root.dataset.closed=!0,t.doAsync(()=>{this.root.remove(),this.root=null},200)}}t.Skeleton=Ce;class ve{static ACTIVE_TOURS=[];steps;currentStep=0;useModal;offset;horizontalOffset;verticalOffset;radius;tourContainer;tourMask=void 0;_popover=null;constructor(e,s={}){this.steps=e||[],this.useModal=s.useModal??!0,this.offset=s.offset??8,this.horizontalOffset=s.horizontalOffset,this.verticalOffset=s.verticalOffset,this.radius=s.radius??12,this.tourContainer=document.querySelector(".tour-container"),this.tourContainer||(this.tourContainer=t.makeContainer(["100%","100%"],"tour-container"),this.tourContainer.style.display="none",document.body.appendChild(this.tourContainer),window.addEventListener("resize",()=>{for(const e of ve.ACTIVE_TOURS)e._showStep(0)}))}begin(){this.currentStep=0,this.tourContainer.style.display="block",ve.ACTIVE_TOURS.push(this),this._showStep(0)}stop(){this.useModal&&(this.tourMask?.remove(),this.tourMask=void 0),this._popover?.destroy();const e=ve.ACTIVE_TOURS.indexOf(this);-1!==e&&ve.ACTIVE_TOURS.splice(e,1),this.tourContainer.innerHTML="",this.tourContainer.style.display="none"}_showStep(e=1){this.currentStep+=e;const t=this.steps[this.currentStep];if(!t)return void this.stop();const s=this.steps[this.currentStep-1],i=this.steps[this.currentStep+1];this.useModal&&this._generateMask(t.reference),this._createHighlight(t,s,i)}_generateMask(e){this.tourContainer.innerHTML="",this.tourMask=t.makeContainer(["100%","100%"],"tour-mask"),this.tourContainer.appendChild(this.tourMask);const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.style.width="100%",s.style.height="100%",this.tourMask?.appendChild(s);const i=document.createElementNS("http://www.w3.org/2000/svg","clipPath");function o(e,t){const s=Math.ceil(e);return[s,t-(s-e)]}i.setAttribute("id","svgTourClipPath"),s.appendChild(i);const n=e.getBoundingClientRect(),[a,l]=o(n.x,n.width),[r,c]=o(n.y,n.height),h=this.verticalOffset??this.offset,d=this.horizontalOffset??this.offset;{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x","0"),e.setAttribute("y","0"),e.setAttribute("width",`${Math.max(0,a-d)}`),e.setAttribute("height",`${window.innerHeight}`),e.setAttribute("stroke","none"),i.appendChild(e)}{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x",""+(a-d)),e.setAttribute("y","0"),e.setAttribute("width",`${Math.max(0,l+2*d)}`),e.setAttribute("height",`${Math.max(0,r-h)}`),e.setAttribute("stroke","none"),i.appendChild(e)}{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x",""+(a-d)),e.setAttribute("y",`${r+c+h}`),e.setAttribute("width",`${Math.max(0,l+2*d)}`),e.setAttribute("height",`${Math.max(0,window.innerHeight-r-c-h)}`),e.setAttribute("stroke","none"),i.appendChild(e)}{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x",`${a+l+d}`),e.setAttribute("y","0"),e.setAttribute("width",`${Math.max(0,window.innerWidth-a-l)}`),e.setAttribute("height",`${Math.max(0,window.innerHeight)}`),e.setAttribute("stroke","none"),i.appendChild(e)}const u=t.makeContainer(["0","0"],"tour-ref-mask");u.style.left=a-d-1+"px",u.style.top=r-h-1+"px",u.style.width=`${l+2*d+2}px`,u.style.height=`${c+2*h+2}px`,this.tourContainer.appendChild(u);const p=document.createElementNS("http://www.w3.org/2000/svg","mask");p.setAttribute("id","svgTourReferenceMask"),s.appendChild(p);{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("width",`${l+2*d+2}`),e.setAttribute("height",`${c+2*h+2}`),e.setAttribute("stroke","none"),e.setAttribute("fill","white"),p.appendChild(e);const t=document.createElementNS("http://www.w3.org/2000/svg","rect");t.setAttribute("rx",`${this.radius}`),t.setAttribute("width",`${l+2*d+2}`),t.setAttribute("height",`${c+2*h+2}`),t.setAttribute("stroke","none"),t.setAttribute("fill","black"),p.appendChild(t)}}_createHighlight(e,s,i){const o=t.makeContainer(["auto","auto"],"tour-step-container");{const s=t.makeContainer(["100%","auto"],"flex flex-row","",o);t.makeContainer(["70%","auto"],"p-2 font-medium",e.title,s);const i=t.makeContainer(["30%","auto"],"flex flex-row p-2 justify-end","",s),n=t.makeIcon("X");i.appendChild(n),t.listen(n,"click",()=>{this.stop()})}t.makeContainer(["100%","auto"],"p-2 text-md",e.content,o,{maxWidth:"400px"});const n=t.makeContainer(["100%","auto"],"flex flex-row text-md","",o);{const e=t.makeContainer(["50%","auto"],"p-2 gap-1 self-center flex flex-row text-md","",n);for(let t=0;t<this.steps.length;t++){const s=document.createElement("span");s.className="tour-step-indicator",t===this.currentStep&&s.classList.add("active"),e.appendChild(s)}}const a=t.makeContainer(["50%","auto"],"text-md","",n),l=new ee;let r=1;s&&r++,r>1&&l.sameLine(2,"justify-end"),s&&l.addButton(null,"Previous",()=>{this._showStep(-1)},{buttonClass:"contrast"}),i?l.addButton(null,"Next",()=>{this._showStep(1)},{buttonClass:"accent"}):l.addButton(null,"Finish",()=>{this.stop()}),a.appendChild(l.root);const c=("left"===e.side||"right"===e.side?this.horizontalOffset:this.verticalOffset)??this.offset,h="start"===e.align||"end"===e.align?c:0;this._popover?.destroy(),this._popover=new v(null,[o],{reference:e.reference,side:e.side,align:e.align,sideOffset:c,alignOffset:"start"===e.align?-h:h})}}if(t.Tour=ve,t.init=async function(e={}){if(this.ready)return this.mainArea;await t.loadScriptSync("https://unpkg.com/lucide@latest"),console.log(`LexGUI v${this.version}`);var s=document.createElement("div");s.id="lexroot",s.className="lexcontainer",s.tabIndex=-1,e.rootClass&&(s.className+=` ${e.rootClass}`),this.modal=document.createElement("div"),this.modal.id="modal",this.modal.classList.add("hidden-opacity"),this.modal.toggle=function(e){this.classList.toggle("hidden-opacity",e)},this.root=s,this.container=document.body,e.container&&(this.container=e.container.constructor===String?document.getElementById(e.container):e.container),this.layoutMode=e.layoutMode??"app",document.documentElement.setAttribute("data-layout",this.layoutMode),this.layoutMode,this.spacingMode=e.spacingMode??"default",document.documentElement.setAttribute("data-spacing",this.spacingMode),this.container.appendChild(this.modal),e.skipRoot?this.root=document.body:this.container.appendChild(s);{const e=document.createElement("section");e.className="notifications",this.notifications=document.createElement("ol"),this.notifications.className="",this.notifications.iWidth=0,e.appendChild(this.notifications),document.body.appendChild(e),this.notifications.addEventListener("mouseenter",()=>{this.notifications.classList.add("list")}),this.notifications.addEventListener("mouseleave",()=>{this.notifications.classList.remove("list")})}s.addEventListener("dragover",function(e){e.preventDefault()},!1),document.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.DEFAULT_NAME_WIDTH="30%",this.DEFAULT_SPLITBAR_SIZE=4,this.OPEN_CONTEXTMENU_ENTRY="click",this.componentResizeObserver=new ResizeObserver(e=>{for(const t of e){const e=t.target?.jsInstance;e&&e.onResize&&e.onResize(t.contentRect)}}),this.ready=!0,this.menubars=[],this.sidebars=[],this.commandbar=this._createCommandbar(this.container),e.skipRoot||e.skipDefaultArea||(this.mainArea=new se({id:e.id??"mainarea"})),this._onChangeSystemTheme=function(e){localStorage.getItem("lxColorScheme")||t.setTheme(e.matches?"dark":"light",!1)},this._mqlPrefersDarkScheme=window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)"):null;const i=localStorage.getItem("lxColorScheme");return i?t.setTheme(i):this._mqlPrefersDarkScheme&&(e.autoTheme??1)&&(window.matchMedia("(prefers-color-scheme: light)").matches&&t.setTheme("light",!1),this._mqlPrefersDarkScheme.addEventListener("change",this._onChangeSystemTheme)),this.mainArea},t.setSpacingMode=function(e){this.spacingMode=e,document.documentElement.setAttribute("data-spacing",this.spacingMode)},t.setLayoutMode=function(e){this.layoutMode=e,document.documentElement.setAttribute("data-layout",this.layoutMode)},t.addSignal=function(e,s,i){s[e]=i,t.signals[e]||(t.signals[e]=[]),t.signals[e].indexOf(s)>-1||t.signals[e].push(s)},t.emitSignal=function(e,s,i={}){const o=t.signals[e];if(!o)return;const n=i.target;if(n)n[e]&&n[e].call(n,s);else for(let t of o)if(t instanceof a)t.set(s,i.skipCallback??!0);else if(t.constructor===Function){t(null,s)}else{const i=t[e];console.assert(i,`No callback registered with _${e}_ signal`),i.bind(t)(s)}},t._createCommandbar=function(e){let s=document.createElement("dialog");s.className="commandbar",s.tabIndex=-1,e.appendChild(s);let i=[],o=null;s.addEventListener("keydown",function(e){if(e.stopPropagation(),e.stopImmediatePropagation(),o=o??-1,"Escape"==e.key)s.close(),h(!0);else if("Enter"==e.key){const e=i[o];e&&(null!=e.item.checked&&(e.item.checked=!e.item.checked),s.close(),e.callback.call(window,e.item.name,e.item.checked))}else if("ArrowDown"==e.key&&o<i.length-1){o++,s.querySelectorAll(".hovered").forEach(e=>e.classList.remove("hovered"));const e=i[o];e.classList.add("hovered");let t=e.offsetHeight*(o+1)-r.offsetHeight;t>0&&r.scrollTo({top:t,behavior:"smooth"})}else if("ArrowUp"==e.key&&o>0){o--,s.querySelectorAll(".hovered").forEach(e=>e.classList.remove("hovered"));i[o].classList.add("hovered")}}),s.addEventListener("focusout",function(e){e.relatedTarget!=e.currentTarget&&(e.stopPropagation(),e.stopImmediatePropagation(),s.close(),h(!0))}),e.addEventListener("keydown",e=>{if(" "==e.key&&e.ctrlKey)e.stopImmediatePropagation(),e.stopPropagation(),t.setCommandbarState(!0);else for(let s of t.extensions){if(!t[s]||!t[s].prototype.onKeyPressed)continue;const i=t.CodeEditor.getInstances();for(let t of i)t.onKeyPressed(e)}});const n=t.makeContainer(["100%","auto"],"flex flex-row"),a=new d(null,"",e=>{s._addElements(e.toLowerCase())},{width:"100%",icon:"Search",trigger:"input",placeholder:"Search..."});n.appendChild(a.root);const l=new se({width:"100%",skipAppend:!0,className:"cb-tabs"});{const e=(e,t)=>{};l.addTabs({parentClass:"p-2"}).add("All",document.createElement("div"),{selected:!0,onSelect:e})}const r=document.createElement("div");r.className="searchitembox";let c=null;const h=e=>{r.innerHTML="",i.length=0,o=null,e&&a.set("",!0)},u=(e,n,a,l)=>{if(!e.length)return;c&&c.classList.remove("last");let d=document.createElement("div");if(d.className="searchitem last",void 0!==l?.checked){const s=l.checked?t.makeIcon("Check").innerHTML:"";d.innerHTML=s+(a+e)}else d.innerHTML=a+e;d.callback=n,d.item=l,d.addEventListener("click",s=>{null!=l.checked&&(l.checked=!l.checked),n.call(window,e,l.checked),t.setCommandbarState(!1),h(!0)}),d.addEventListener("mouseenter",function(e){s.querySelectorAll(".hovered").forEach(e=>e.classList.remove("hovered")),d.classList.add("hovered"),o=i.indexOf(d)}),d.addEventListener("mouseleave",function(e){d.classList.remove("hovered")}),i.push(d),r.appendChild(d),c=d},p=(e,s,i,o)=>{if(!e||e.constructor!=Object)return;let n=e.name;n.toLowerCase().includes(s)&&e.callback&&u(n,e.callback,i,e);const a=e.submenu??e[n];if(!a)return;i+=n+t.makeIcon("ChevronRight",{svgClass:"sm fg-secondary separator"}).innerHTML;for(let e of a)p(e,s,i)};return s._addElements=e=>{h();for(let s of t.menubars)for(let t of s.items)p(t,e,"");for(let s of t.sidebars)for(let t of s.items)p(t,e,"");for(let s of t.extraCommandbarEntries){const t=s.name;t.toLowerCase().includes(e)&&u(t,s.callback,"",{})}if(t.has("CodeEditor")){const s=t.CodeEditor.getInstances();if(!s.length||!s[0].area.root.offsetHeight)return;const i=t.CodeEditor.languages;for(let o of Object.keys(i)){const n="Language: "+o,a=s[0]._getFileIcon(null,i[o].ext).split(" ");let l=t.makeIcon(a[0],{svgClass:`${a.slice(0).join(" ")}`}).innerHTML;l+=n+" <span class='lang-ext'>("+i[o].ext+")</span>",n.toLowerCase().includes(e)&&u(l,()=>{for(let e of s)e._changeLanguage(o)},"",{})}}},s.appendChild(n),s.appendChild(l.root),s.appendChild(r),s},t.setCommandbarState=function(e,t=!0){const s=this.commandbar;e?(s.show(),s.querySelector("input").focus(),t&&s._addElements(void 0)):s.close()},t.REGISTER_COMPONENT=function(e,s={}){let o=t.guidGenerator();ee.prototype["add"+e]=function(l,r,c){const h=Array.from(arguments).slice(3);let d=new a(n.CUSTOM,l,null,s);this._attachComponent(d),d.customName=e,d.customIdx=o,d.onGetValue=()=>r,d.onSetValue=(e,t,s)=>{r=e,f(),u.querySelector(".lexcustomitems").toggleAttribute("hidden",!1),t||d._trigger(new i(l,r,s),c)},d.onResize=()=>{const e=d.root.domName?.style.width??"0px";p.style.width=`calc( 100% - ${e})`};const u=d.root;let p,m,g=s.default??{};const f=()=>{p&&p.remove(),m&&m.remove(),p=document.createElement("div"),p.className="lexcustomcontainer w-full",u.appendChild(p),u.dataset.opened=!1;const o=t.makeIcon(s.icon??"Box"),n=t.makeIcon("Menu");let a=e+(r?"":" [empty]"),C=this.addButton(null,a,(s,i)=>{r?(u.querySelector(".lexcustomitems").toggleAttribute("hidden"),u.dataset.opened=!u.querySelector(".lexcustomitems").hasAttribute("hidden")):t.addContextMenu(null,i,t=>{t.add("New "+e,()=>{r={},f(),u.querySelector(".lexcustomitems").toggleAttribute("hidden",!1),u.dataset.opened=!u.querySelector(".lexcustomitems").hasAttribute("hidden")})})},{buttonClass:"custom"});const v=C.root.querySelector("span");if(v.prepend(o),v.appendChild(n),p.appendChild(C.root),r&&n.addEventListener("click",e=>{e.stopImmediatePropagation(),e.stopPropagation(),t.addContextMenu(null,e,e=>{e.add("Clear",()=>{r=null,f()})})}),m=document.createElement("div"),m.className="lexcustomitems",m.toggleAttribute("hidden",!0),u.appendChild(m),r){this.queue(m);const e=(e,t,o)=>{const n=s[`_set_${e}`];n?n.call(r,t):r[e]=t,d._trigger(new i(l,r,o),c)};for(let t in g){let i=null;const o=s[`_get_${t}`];if(i=o?r[t]?o.call(r):o.call(g):r[t]??g[t],i)switch(i.constructor){case String:"#"===i[0]?this.addColor(t,i,e.bind(this,t)):this.addText(t,i,e.bind(this,t));break;case Number:this.addNumber(t,i,e.bind(this,t));break;case Boolean:this.addCheckbox(t,i,e.bind(this,t));break;case Array:i.length>4?this.addArray(t,i,e.bind(this,t)):this._addVector(i.length,t,i,e.bind(this,t));break;default:console.warn(`Unsupported property type: ${i.constructor.name}`)}}s.onCreate&&s.onCreate.call(this,this,...h),this.clearQueue()}};f()}},!t)throw"Missing LX namespace!";t.extensions.push("AssetView");const ye=t.Area;t.Panel,t.NodeTree,t.TreeEvent;class be{static LAYOUT_GRID=0;static LAYOUT_COMPACT=1;static LAYOUT_LIST=2;static CONTENT_SORT_ASC=0;static CONTENT_SORT_DESC=1;root;area=null;content;leftPanel=null;toolsPanel;contentPanel;previewPanel;tree=null;prevData=[];nextData=[];data=[];currentData=[];currentFolder=void 0;rootItem;path=[];rootPath="";selectedItem=void 0;allowedTypes;searchValue="";filter="None";gridScale=1;layout=be.LAYOUT_GRID;sortMode=be.CONTENT_SORT_ASC;skipBrowser=!1;skipPreview=!1;useNativeTitle=!1;onlyFolders=!0;allowMultipleSelection=!1;previewActions=[];contextMenu=[];onRefreshContent=null;itemContextMenuOptions=null;onItemDragged=null;_assetsPerPage=24;get assetsPerPage(){return this._assetsPerPage}set assetsPerPage(e){this._setAssetsPerPage(e)}_callbacks={};_lastSortBy="";_paginator;_scriptCodeDialog;_moveItemDialog;_movingItem;constructor(e={}){this.rootPath="https://raw.githubusercontent.com/jxarco/lexgui.js/master/",this.layout=e.layout??this.layout,this.sortMode=e.sortMode??this.sortMode,e.rootPath&&(e.rootPath.constructor!==String?console.warn(`Asset Root Path must be a String (now is a ${e.rootPath.constructor.name})`):this.rootPath=e.rootPath);let s=document.createElement("div");s.className="lexassetbrowser",this.root=s;let i=new ye({width:"100%",height:"100%"});s.appendChild(i.root);let o,n,a=i;if(this.skipBrowser=e.skipBrowser??this.skipBrowser,this.skipPreview=e.skipPreview??this.skipPreview,this.useNativeTitle=e.useNativeTitle??this.useNativeTitle,this.onlyFolders=e.onlyFolders??this.onlyFolders,this.allowMultipleSelection=e.allowMultipleSelection??this.allowMultipleSelection,this.previewActions=e.previewActions??[],this.itemContextMenuOptions=e.itemContextMenuOptions,this.onRefreshContent=e.onRefreshContent,this.onItemDragged=e.onItemDragged,this.gridScale=e.gridScale??this.gridScale,1!==this.gridScale){document.querySelector(":root").style.setProperty("--av-grid-scale",this.gridScale)}document.body.appendChild(this.root),this.skipBrowser||([o,n]=i.split({type:"horizontal",sizes:["15%","85%"]}),a=n,o.setLimitBox(210,0),n.setLimitBox(512,0)),this.skipPreview||([a,n]=a.split({type:"horizontal",sizes:["80%","20%"]})),this.allowedTypes={None:{},Image:{color:"yellow-500"},JSON:{color:"sky-200"},Video:{color:"indigo-400"},...e.allowedTypes??{}},this.path=["@"],this.rootItem={id:"/",children:this.data,type:"folder",metadata:{uid:t.guidGenerator()}},this.currentFolder=this.rootItem,this._processData(this.data),this.currentData=this.data,this.skipBrowser||this._createTreePanel(o),this._createContentPanel(a),this.skipPreview||(this.previewPanel=n.addPanel({className:"lexassetcontentpanel",style:{overflow:"scroll"}})),document.body.removeChild(this.root)}on(e,t){this._callbacks[e]=t}load(e){this.prevData.length=0,this.nextData.length=0,this.data=e,this.rootItem.children=this.data,this._processData(this.data),this.currentData=this.data,this.path=["@"],this.skipBrowser||this.tree.refresh({id:"/",children:this.data,type:"folder",metadata:{uid:t.guidGenerator()}}),this._refreshContent()}addItem(e,s,i=!0){const o=this.layout==be.LAYOUT_LIST,n=this.layout==be.LAYOUT_GRID,a=e.type.charAt(0).toUpperCase()+e.type.slice(1),l=t.getExtension(e.id),r="Folder"===a,c=this;let h=document.createElement("li");h.className="lexassetitem "+e.type.toLowerCase(),h.tabIndex=-1,t.insertChildAtIndex(this.content,h,s);const d=this.allowedTypes[a]?.color;d&&t.makeElement("span",`rounded-full w-2 h-2 z-100 flex absolute ml-2 mt-2 bg-${d}`,"",h);const u=e.metadata;if(u.uid||(u.uid=t.guidGenerator()),u.lastModified&&!u.lastModifiedDate&&(u.lastModifiedDate=this._lastModifiedToStringDate(u.lastModified)),this.useNativeTitle)h.title=a+": "+e.id;else{let i=document.createElement("span");i.className="lexitemdesc",i.id=`floatingTitle_${u.uid}`,i.innerHTML=`File: ${e.id}<br>Type: ${a}`,t.insertChildAtIndex(this.content,i,s?s+1:void 0),h.addEventListener("mousemove",e=>{if(!n)return;const t=e.target,s=h.closest("dialog"),o=h.getBoundingClientRect(),a=t.getBoundingClientRect();let l=o.x+e.offsetX,r=o.y+e.offsetY;if(s){const e=s.getBoundingClientRect();l-=e.x,r-=e.y}t.classList.contains("lexassettitle")&&(r+=a.y-o.y),i.style.left=l+"px",i.style.top=r-36+"px"})}if(this.allowMultipleSelection){let t=document.createElement("input");t.type="checkbox",t.className="lexcheckbox",t.checked=u.selected,t.addEventListener("change",t=>{u.selected=!u.selected;const s=c._callbacks.check;if(void 0!==s){s({type:"check",items:[e],userInitiated:!0})}t.stopPropagation(),t.stopImmediatePropagation()}),h.appendChild(t)}let p=document.createElement("span");if(p.className="lexassettitle",p.innerText=e.id,h.appendChild(p),!this.skipPreview){if("video"===e.type){const s=t.makeElement("video","absolute left-0 top-0 w-full border-none pointer-events-none","",h);s.setAttribute("disablePictureInPicture",!1),s.setAttribute("disableRemotePlayback",!1),s.setAttribute("loop",!0),s.setAttribute("async",!0),s.style.transition="opacity 0.2s ease-out",s.style.opacity=u.preview?"0":"1",s.src=e.src,s.volume=u.volume??.4}let s=null;const i=u.preview??e.src;if(i&&((()=>{const e=t.getExtension(i.split("?")[0].split("#")[0]);return!!e&&["png","jpg","jpeg","gif","bmp","avif"].includes(e.toLowerCase())})()||i.startsWith("data:image/"))||r||!n){const e=`${this.rootPath}images/file.png`,t=`${this.rootPath}images/folder.png`;s=document.createElement("img");let o=u.unknownExtension?e:r?t:i;s.src=n||r?o:e,s.setAttribute("draggable","false"),s.className="pointer-events-none",h.appendChild(s)}else{s=document.createElement("svg"),s.className="asset-file-preview",h.appendChild(s);let t=document.createElement("text");t.innerText=l&&l!=e.id?`${l.toUpperCase()}`:e.type.toUpperCase(),s.appendChild(t);var m=2.5/t.innerText.length;if(m<1){var g=64*m;t.style.fontSize=g+"px",s.style.paddingTop=`calc(50% - ${.5*t.offsetHeight+10}px)`}}}let f=a;o&&(u.bytesize&&(f+=` | ${t.formatBytes(u.bytesize)}`),u.lastModifiedDate&&(f+=` | ${u.lastModifiedDate}`)),t.makeContainer(["auto","auto"],"lexassetinfo",f,h),h.addEventListener("click",function(s){s.stopImmediatePropagation(),s.stopPropagation();const i=s.detail==t.MOUSE_DOUBLE_CLICK;if(i){if(r)return void c._enterFolder(e)}else s.shiftKey||c.content.querySelectorAll(".lexassetitem").forEach(e=>e.classList.remove("selected")),this.classList.add("selected"),c.selectedItem=e,c.skipPreview||c._previewAsset(e);const o=c._callbacks.select,n=c._callbacks.dblClick;if(i&&void 0!==n){n({type:"dbl_click",items:[e],userInitiated:!0})}else if(!i&&void 0!==o){o({type:"select",items:[e],userInitiated:!0})}}),h.addEventListener("contextmenu",function(s){s.preventDefault(),s.stopImmediatePropagation(),s.stopPropagation();const i=c.content.querySelectorAll(".selected").length,o=[{name:i>1?i+" selected":e.id,icon:t.makeIcon("CircleSmall",{svgClass:`fill-current fg-${d}`}),className:"text-sm",disabled:!0},null];if(i<=1&&o.push({name:"Rename",icon:"TextCursor",callback:c._renameItemPopover.bind(c,e)}),r||o.push({name:"Clone",icon:"Copy",callback:c._requestCloneItem.bind(c,e)}),o.push({name:"Move",icon:"FolderInput",callback:()=>c._moveItem(e)}),"Script"==a&&t.has("CodeEditor")&&o.push({name:"Open in Editor",icon:"Code",callback:c._openScriptInEditor.bind(c,e)}),c.itemContextMenuOptions){o.push(null);for(let t of c.itemContextMenuOptions)t.name&&t.callback&&o.push({name:t.name,icon:t.icon,callback:t.callback?.bind(c,e)})}o.push(null,{name:"Delete",icon:"Trash2",className:"fg-error",callback:c._requestDeleteItem.bind(c,e)}),t.addClass(c.contentPanel.root,"pointer-events-none"),t.addDropdownMenu(s.target,o,{side:"right",align:"start",event:s,onBlur:()=>{t.removeClass(c.contentPanel.root,"pointer-events-none")}})});const C=function(e,t){if("Folder"!==t.type.charAt(0).toUpperCase()+t.type.slice(1)||e.metadata.uid==t.metadata.uid)return void console.error("[AssetView Error] Cannot drop: Target item is not a folder or target is the dragged element!");const s=e.domEl;s&&(s.classList.add("moving-to-folder"),s.addEventListener("animationend",()=>{s.classList.remove("moving-to-folder"),c._requestMoveItemToFolder(e,t)},{once:!0}))};return h.addEventListener("dragstart",t=>{window.__av_item_dragged=e;var s=new Image;s.src="",t.dataTransfer&&(t.dataTransfer.setDragImage(s,0,0),t.dataTransfer.effectAllowed="move");const i=c.content.querySelector(`#floatingTitle_${u.uid}`);i&&(i.style.display="none")},!1),h.addEventListener("dragend",e=>{e.preventDefault();let t=window.__av_item_dragged;t&&t._nodeTarget&&C(t,t._nodeTarget),delete window.__av_item_dragged},!1),h.addEventListener("dragenter",s=>{s.preventDefault();let i=window.__av_item_dragged;i&&r&&i.metadata.uid!=u.uid&&t.addClass(e.domEl,"animate-pulse")}),h.addEventListener("dragleave",s=>{s.preventDefault(),window.__av_item_dragged&&t.removeClass(e.domEl,"animate-pulse")}),h.addEventListener("drop",t=>{t.preventDefault();let s=window.__av_item_dragged;s&&C(s,e)}),h.addEventListener("mouseenter",t=>{if(!c.useNativeTitle&&n){const e=c.content.querySelector(`#floatingTitle_${u.uid}`);e&&(e.style.display="unset")}if("video"!==e.type)return;t.preventDefault();const s=h.querySelector("video");s.style.opacity="1",s.play()}),h.addEventListener("mouseleave",t=>{if(!c.useNativeTitle&&n&&setTimeout(()=>{const e=c.content.querySelector(`#floatingTitle_${u.uid}`);e&&(e.style.display="none")},100),"video"!==e.type)return;t.preventDefault();const s=h.querySelector("video");s.pause(),s.currentTime=0,u.preview&&(s.style.opacity="0")}),!this.skipBrowser&&i&&this.tree.refresh(),h}clear(){this.previewPanel&&this.previewPanel.clear(),this.leftPanel&&this.leftPanel.clear(),this.toolsPanel&&this.toolsPanel.clear()}_processData(e,t){e.constructor!==Array&&(e.parent=t,e.dir=t?.children,e.children=e.children??[],e.metadata=e.metadata||{});const s=t?e:this.rootItem;for(let e of s.children)this._processData(e,s)}_updatePath(){if(this.path.length=0,this.currentFolder&&this.currentFolder.parent){this.path.push(this.currentFolder.id);const e=t=>{t&&(this.path.push(t.parent?t.id:"@"),e(t.parent))};e(this.currentFolder.parent)}else this.path.push("@");t.emitSignal("@on_folder_change",this.path.reverse().join("/"))}_createNavigationBar(e){e.sameLine(4,"justify-center"),e.addButton(null,"GoBackButton",()=>{this.prevData.length&&this.currentFolder&&(this.nextData.push(this.currentFolder),this._enterFolder(this.prevData.pop(),!1))},{buttonClass:"bg-none",title:"Go Back",tooltip:!0,icon:"ArrowLeft"}),e.addButton(null,"GoForwardButton",()=>{this.nextData.length&&this.currentFolder&&this._enterFolder(this.nextData.pop())},{buttonClass:"bg-none",title:"Go Forward",tooltip:!0,icon:"ArrowRight"}),e.addButton(null,"GoUpButton",()=>{const e=this.currentFolder?.parent;e&&this._enterFolder(e)},{buttonClass:"bg-none",title:"Go Upper Folder",tooltip:!0,icon:"ArrowUp"}),e.addButton(null,"GoUpButton",()=>{this._refreshContent()},{buttonClass:"bg-none",title:"Refresh",tooltip:!0,icon:"Refresh"})}_createTreePanel(e){this.leftPanel?this.leftPanel.clear():this.leftPanel=e.addPanel({className:"lexassetbrowserpanel"}),this._createNavigationBar(this.leftPanel);const s={id:"/",children:this.data},i=this.leftPanel.addTree("Content Browser",s,{filter:!1,onlyFolders:this.onlyFolders,onevent:e=>{let s=e.node,i=e.value;switch(e.type){case t.TreeEvent.NODE_SELECTED:if(e.multiple)return;if(s.parent){if(this._enterFolder("folder"===s.type?s:s.parent),this._previewAsset(s),"folder"!==s.type){this.content.querySelectorAll(".lexassetitem").forEach(e=>e.classList.remove("selected"));const e=s.domEl;e?.classList.add("selected")}this.selectedItem=s}else this.currentFolder&&this.prevData.push(this.currentFolder),this.currentFolder=void 0,this.currentData=this.data,this._refreshContent(),this._updatePath();break;case t.TreeEvent.NODE_DRAGGED:if(s.parent){const e=s.parent.children.indexOf(s);s.parent.children.splice(e,1)}i.children||(i.children=[]),i.children.push(s),s.parent=i,s.dir=i.children,this.onItemDragged&&this.onItemDragged(s,i),this._refreshContent()}}});this.tree=i.innerTree}_setContentLayout(e){this.layout=e,this.toolsPanel.refresh(),this._refreshContent()}_createContentPanel(e){const s=this;e.root.classList.add("flex","flex-col"),this.toolsPanel?this.contentPanel.clear():(this.toolsPanel=e.addPanel({className:"flex-auto",height:"auto"}),this.contentPanel=e.addPanel({className:"lexassetcontentpanel flex flex-col flex-auto-fill content-center overflow-hidden"}),this._paginator=new t.Pagination({className:"ml-auto",pages:Math.max(Math.ceil(this.data.length/this.assetsPerPage),1),onChange:()=>this._refreshContent()}),this.contentPanel.root.addEventListener("wheel",e=>{if(!e.ctrlKey)return;e.preventDefault(),this.gridScale*=e.deltaY<0?1.05:.95,this.gridScale=t.clamp(this.gridScale,.5,2);document.querySelector(":root").style.setProperty("--av-grid-scale",this.gridScale)}));const i=(e,s)=>{t.addDropdownMenu(s.target,[{name:"Name",icon:"ALargeSmall",callback:()=>this._sortData("id")},{name:"Type",icon:"Type",callback:()=>this._sortData("type")},null,{name:"Ascending",icon:"SortAsc",callback:()=>this._sortData(void 0,be.CONTENT_SORT_ASC)},{name:"Descending",icon:"SortDesc",callback:()=>this._sortData(void 0,be.CONTENT_SORT_DESC)}],{side:"bottom",align:"start"})},o=(e,s)=>{t.addDropdownMenu(s.target,[{name:"Grid",icon:"LayoutGrid",callback:()=>this._setContentLayout(be.LAYOUT_GRID)},{name:"Compact",icon:"LayoutList",callback:()=>this._setContentLayout(be.LAYOUT_COMPACT)},{name:"List",icon:"List",callback:()=>this._setContentLayout(be.LAYOUT_LIST)}],{side:"bottom",align:"start"})};this.toolsPanel.refresh=()=>{this.toolsPanel.clear();const e=Object.keys(this.allowedTypes);this.skipBrowser&&this._createNavigationBar(this.toolsPanel),this.toolsPanel.sameLine();const t=this.toolsPanel.addButton(null,"",i.bind(this),{title:"Sort",tooltip:!0,icon:this.sortMode===be.CONTENT_SORT_ASC?"SortAsc":"SortDesc"});if(this.toolsPanel.addButton(null,"",o.bind(this),{title:"View",tooltip:!0,icon:this.layout===be.LAYOUT_GRID?"LayoutGrid":"LayoutList"}),this.toolsPanel.addSelect(null,e,this.filter??e[0],e=>{this._refreshContent(void 0,e)},{overflowContainer:null}),this.toolsPanel.addText(null,this.searchValue??"",e=>this._refreshContent(e),{className:"flex flex-auto-fill",placeholder:"Search assets.."}),this.toolsPanel.endLine(),this._paginator){t.root.parentElement.appendChild(this._paginator.root)}},this.content=document.createElement("ul"),this.content.className="lexassetscontent",this.contentPanel.attach(this.content),this.skipBrowser||this.contentPanel.addText(null,this.path.join("/"),null,{inputClass:"bg-none fg-quinary text-end",disabled:!0,signal:"@on_folder_change"}),this.content.addEventListener("dragenter",function(e){e.preventDefault(),this.classList.add("dragging")}),this.content.addEventListener("dragleave",function(e){e.preventDefault(),this.classList.remove("dragging")}),this.content.addEventListener("drop",e=>{e.preventDefault(),this._processDrop(e)}),this.content.addEventListener("click",function(){this.querySelectorAll(".lexassetitem").forEach(e=>e.classList.remove("selected"))}),this.content.addEventListener("contextmenu",function(e){e.preventDefault();const i=[{name:"New Folder",icon:t.makeIcon("FolderPlus"),callback:()=>{s._requestCreateFolder()}}];t.addClass(s.contentPanel.root,"pointer-events-none"),t.addDropdownMenu(e.target,i,{side:"right",align:"start",event:e,onBlur:()=>{t.removeClass(s.contentPanel.root,"pointer-events-none")}})}),this._refreshContent(),t.doAsync(()=>this.toolsPanel.refresh(),100)}_makeNameFilterFn(e){const s=e.trim();if(s.includes("*")||s.includes("?")){const e=t.wildcardToRegExp(s);return t=>e.test(t)}return e=>e.toLowerCase().includes(s.toLowerCase())}_refreshContent(e,s){const i=this.layout==be.LAYOUT_COMPACT,o=this.layout==be.LAYOUT_LIST;if(this.filter=s??this.filter??"None",this.searchValue=e??this.searchValue??"",this.content.innerHTML="",this.content.className="lexassetscontent"+(i?" compact":o?" list":""),!this.currentData.length)return;const n=new FileReader,a=this._makeNameFilterFn(this.searchValue),l=this.currentData.filter(e=>{const t="None"===this.filter||e.type.toLowerCase()===this.filter.toLowerCase(),s=a(e.id);return t&&s});this._paginator?.setPages(Math.max(Math.ceil(l.length/this.assetsPerPage),1));const r=this._paginator?(this._paginator.page-1)*this.assetsPerPage:0,c=this._paginator?Math.min(r+this.assetsPerPage,l.length):l.length;for(let i=r;i<c;++i){let o=l[i];o.path?t.request({url:o.path,dataType:"blob",success:t=>{o.metadata.bytesize=t.size,n.readAsDataURL(t),n.onload=t=>{const i=t.currentTarget;o.src=i.result,o.metadata.path=o.path,delete o.path,this._refreshContent(e,s)}}}):o.domEl=this.addItem(o,void 0,!1)}this.onRefreshContent&&this.onRefreshContent(e,s)}_previewAsset(e){if(this.skipPreview)return;const s=e.src&&e.src.includes("data:image/");if(e.metadata=e.metadata??{},this.previewPanel.clear(),this.previewPanel.branch("Asset"),"image"==e.type||e.src){(["png","jpg"].indexOf(t.getExtension(e.src))>-1||s)&&this.previewPanel.addImage(null,e.src,{style:{width:"100%"}})}e.metadata.lastModified&&!e.metadata.lastModifiedDate&&(e.metadata.lastModifiedDate=this._lastModifiedToStringDate(e.metadata.lastModified));const i={disabled:!0};this.previewPanel.addText("Filename",e.id,null,i),e.metadata.lastModifiedDate&&this.previewPanel.addText("Last Modified",e.metadata.lastModifiedDate,null,i),(e.metadata.path||e.src)&&this.previewPanel.addText("URL",e.metadata.path?e.metadata.path:e.src,null,i),this.previewPanel.addText("Path",this.path.join("/"),null,i),this.previewPanel.addText("Type",e.type,null,i),e.metadata.bytesize&&this.previewPanel.addText("Size",t.formatBytes(e.metadata.bytesize),null,i),"folder"==e.type&&this.previewPanel.addText("Files",e.children?e.children.length.toString():"0",null,i),this.previewPanel.addSeparator();const o=[...this.previewActions];o.length||"folder"===e.type||o.push({name:"Download",callback:()=>t.downloadURL(e.src,e.id)});for(let t of o)t.type&&t.type!==e.type||t.path&&t.path!==this.path.join("/")||this.previewPanel.addButton(null,t.name,t.callback.bind(this,e));this.previewPanel.merge()}_processDrop(e){if(!e.dataTransfer||!e.dataTransfer.files||0==e.dataTransfer.files.length)return;const t=new FileReader,s=e.dataTransfer.files.length;for(let i=0;i<e.dataTransfer.files.length;++i){const o=e.dataTransfer.files[i],n=this.currentData.find(e=>e.id===o.name);n||(t.readAsDataURL(o),t.onload=e=>{let t=o.name.substring(o.name.lastIndexOf(".")+1).toLowerCase(),n=null;switch(t){case"png":case"jpg":n="image";break;case"js":case"css":n="script";break;case"json":n="json";break;case"obj":n="mesh";break;default:n=t}let a={id:o.name,src:e.currentTarget.result,type:n,children:[],metadata:{extension:t,lastModified:o.lastModified,lastModifiedDate:this._lastModifiedToStringDate(o.lastModified),unknownExtension:n==t}};this.currentData.push(a),i==s-1&&(this._refreshContent(),this.tree?.refresh())})}}_sortData(e,t){e=e??this._lastSortBy??"id";const s=(t=t??this.sortMode)===be.CONTENT_SORT_DESC;this.currentData=this.currentData.sort((t,i)=>{var o=s?i[e].localeCompare(t[e]):t[e].localeCompare(i[e]);return 0==o&&(o=s?i.id.localeCompare(t.id):t.id.localeCompare(i.id)),o}),this._lastSortBy=e,this.sortMode=t,this.toolsPanel.refresh(),this._refreshContent()}_enterFolder(e,t=!0){if(!e)return;const s=this.currentData[0],i=s?.parent?.id===e.id;t&&this.prevData.push(this.currentFolder??{id:"/",children:this.data,type:"root",metadata:{}});let o=!i;const n=this._callbacks.enterFolder;if(void 0!==n){const t=n({type:"enter_folder",to:e,userInitiated:!0});o=o||t}this.currentFolder=e,this.currentData=this.currentFolder?.children??[],o&&(this._processData(this.data),this._refreshContent()),this._updatePath()}_removeItemFromParent(e){const t=e.parent;if(t){const s=t.children?.indexOf(e)??-1;if(s<0)return!1;t.children?.splice(s,1)}else{const t=e.dir;if(t){const s=t.indexOf(e);if(s<0)return!1;t.splice(s,1)}}return!0}_requestDeleteItem(e){const t=this._callbacks.beforeDelete,s=this._callbacks.delete,i=(...t)=>{this._deleteItem(e);s&&s({type:"delete",items:[e],userInitiated:!0},...t)};if(t){t({type:"delete",items:[e],userInitiated:!0},i)}else i()}_deleteItem(e){this._removeItemFromParent(e)?(this._refreshContent(this.searchValue,this.filter),this.tree?.refresh(),this.previewPanel?.clear()):console.error("[AssetView Error] Cannot delete. Item not found.")}_requestMoveItemToFolder(e,t){const s=this._callbacks.beforeMove,i=this._callbacks.move,o=(...s)=>{this._moveItemToFolder(e,t);const o={type:"move",items:[e],from:e.parent,to:t,userInitiated:!0};i&&i(o,...s)};if(s){s({type:"move",items:[e],from:e.parent,to:t,userInitiated:!0},o)}else o()}_moveItemToFolder(e,t){this._removeItemFromParent(e)?(t.children=t.children??[],t.children.push(e),e.parent=t,e.dir=t.children,this._refreshContent(),this.tree?.refresh(),this._moveItemDialog?.destroy(),this._movingItem=void 0):console.error("[AssetView Error] Cannot move. Item not found.")}_moveItem(e,s){this._moveItemDialog&&this._moveItemDialog.destroy(),this._movingItem=e;let i,o=null;const n=function(e,s,a=!0){s.innerHTML="",o=e;for(let e of o.children??o){const i=t.makeContainer(["100%","auto"],"flex flex-row px-1 items-center","",s),a="folder"===e.type,l=t.makeContainer(["100%","auto"],`move-item flex flex-row gap-1 py-1 px-3 cursor-pointer ${a?"fg-primary font-medium":"fg-quinary"} rounded-xxl ${a?"hover:bg-secondary":"hover:bg-primary"}`,`${a?t.makeIcon("FolderOpen",{svgClass:""}).innerHTML:""}${e.id}`,i);if(a){l.addEventListener("click",()=>{s.querySelectorAll(".move-item").forEach(e=>t.removeClass(e,"bg-quinary")),t.addClass(l,"bg-quinary"),o=e});const a=new t.Button(null,"FPathButton",()=>{n(e,s)},{icon:"ChevronRight",className:"ml-auto h-8",buttonClass:"bg-none hover:bg-secondary"});i.appendChild(a.root)}}if(!a)return;const l=[];if(o&&o.parent){l.push(o.id);const e=t=>{t&&(l.push(t.parent?t.id:"@"),e(t.parent))};e(o.parent)}else l.push("@");i.innerHTML="",i.appendChild(t.makeBreadcrumb(l.reverse().map(e=>({title:e})),{maxItems:4,separatorIcon:"ChevronRight"}))};this._moveItemDialog=new t.Dialog(`Moving: ${e.id}`,a=>{const l=new t.Area({className:"flex flex-col rounded-lg"});a.attach(l);const r=t.makeContainer(["auto","100%"],"flex flex-auto-fill flex-col overflow-scroll py-2 gap-1","");{const e=l.addPanel({className:"p-2 border-bottom flex flex-auto",height:"auto"});e.sameLine(2,"w-full"),e.addButton(null,"BackButton",()=>{o&&o.parent&&n(o.parent,r)},{icon:"ArrowLeft",title:"Back",tooltip:!0,className:"flex-auto",buttonClass:"bg-none hover:bg-secondary"}),i=t.makeElement("div"),e.addContent("ITEM_MOVE_PATH",i,{signal:"@item_move_path",className:"flex-auto-fill"})}l.attach(r),n(s??this.data,r);{const t=l.addPanel({className:"p-2 border-top flex flex-auto justify-between",height:"auto"});t.addButton(null,"NewFolderButton",()=>{this._requestCreateFolder(o)},{width:"auto",icon:"FolderPlus",title:"Create Folder",tooltip:!0,className:"ml-2",buttonClass:"bg-none hover:bg-secondary"}),t.sameLine(2,"mr-2"),t.addButton(null,"Cancel",()=>{this._moveItemDialog.close()},{buttonClass:"bg-none fg-error"}),t.addButton(null,"Move",()=>{this._requestMoveItemToFolder(e,o)},{className:"",buttonClass:"contrast"})}},{modal:!0,size:["616px","500px"],closable:!0,onBeforeClose:()=>{delete this._moveItemDialog}})}_requestCloneItem(e){if("folder"===e.type)return void console.error("[AssetView Error] Cannot clone a folder.");if((e.dir??[]).indexOf(e)<0)return console.error("[AssetView Error] Cannot clone. Item not found."),!1;const t=this._callbacks.beforeClone,s=this._callbacks.clone,i=(...t)=>{const i=this._cloneItem(e);s&&s({type:"clone",items:[e],result:[i],userInitiated:!0},...t)};if(t){t({type:"clone",items:[e],userInitiated:!0},i)}else i()}_cloneItem(e){const s=e.parent,i=e.dir??[],o=i.indexOf(e);delete e.domEl,delete e.dir,delete e.parent;const n=t.deepCopy(e);return n.id=this._getClonedName(e.id,i),n.dir=e.dir=i,n.parent=e.parent=s,n.metadata.uid=t.guidGenerator(),i.splice(o+1,0,n),this._refreshContent(this.searchValue,this.filter),n}_getClonedName(e,s){const i=e.lastIndexOf(".");let o=e,n="";i>0&&(o=e.substring(0,i),n=e.substring(i));const a=o.match(/^(.*)\s\((\d+)\)$/);a&&(o=a[1]);let l=-1;for(const e of s){if(!e.id)continue;let s=e.id,i="";const a=s.lastIndexOf(".");if(a>0&&(i=s.substring(a),s=s.substring(0,a)),i!==n)continue;const r=s.match(new RegExp("^"+t.escapeRegExp(o)+"\\s\\((\\d+)\\)$"));if(r){const e=parseInt(r[1]);e>l&&(l=e)}else s===o&&(l=Math.max(l,0))}return-1===l?e:`${o} (${l+1})${n}`}_requestRenameItem(e,t){const s=this._callbacks.beforeRename,i=this._callbacks.rename,o=e.id,n=(...s)=>{this._renameItem(e,t);i&&i({type:"rename",items:[e],oldName:o,newName:t,userInitiated:!0},...s)};if(s){s({type:"rename",items:[e],oldName:o,newName:t,userInitiated:!0},n)}else n()}_renameItem(e,s){const i=this.currentData.indexOf(e);if(i<0)return;const o=t.hasClass(e.domEl,"selected"),n=this.content.querySelector(`#floatingTitle_${e.id.replace(/\s/g,"_").replaceAll(".","_")}`);n&&n.remove(),e.domEl?.remove(),e.id=s,e.domEl=this.addItem(e,2*i),o&&this._previewAsset(e),this.tree?.refresh(),this._processData(this.data)}_renameItemPopover(e){if(this.currentData.indexOf(e)<0)return;const s=t=>{n.destroy(),this._requestRenameItem(e,t)};let i=e.id;const o=new t.Panel;o.addText(null,e.id,(e,t)=>{i=e,t.constructor===KeyboardEvent&&s(e)}),o.addButton(null,"Save",()=>{s(i)},{buttonClass:"contrast"});const n=new t.Popover(e.domEl,[o],{align:"center",side:"bottom",sideOffset:-128})}_requestCreateFolder(e){if(!(e=e??this.currentFolder))return;const t=this._callbacks.beforeCreateFolder,s=this._callbacks.createFolder,i=(...t)=>{const i=this._createFolder(e);s&&s({type:"create-folder",result:[i],where:e,userInitiated:!0},...t)};if(t){t({type:"create-folder",where:e,userInitiated:!0},i)}else i()}_createFolder(e){if(!(e=e??this.currentFolder))throw"_createFolder: Something went wrong!";const t={id:this._getClonedName("New Folder",e.children),type:"folder",children:[],parent:this.currentFolder,metadata:{}};return e.children.push(t),this._refreshContent(),this.tree?.refresh(),this._moveItemDialog&&this._movingItem&&this._moveItem(this._movingItem,e),e}_openScriptInEditor(e){this._scriptCodeDialog&&this._scriptCodeDialog.destroy(),this._scriptCodeDialog=new t.Dialog(null,s=>{const i=new t.Area({className:"rounded-lg"});s.attach(i),new t.CodeEditor(i,{allowAddScripts:!1,files:[e.src]})},{size:["50%","600px"],closable:!0,onBeforeClose:()=>{delete this._scriptCodeDialog}})}_setAssetsPerPage(e){this._assetsPerPage=e,this._refreshContent()}_lastModifiedToStringDate(e){const t=new Date(e).toLocaleString();return t.substring(0,t.indexOf(","))}}if(t.AssetView=be,!t)throw"Missing LX namespace!";t.extensions.push("Audio");const _e=t.Panel,xe=t.BaseComponent,Le=t.ComponentType,Se=t.IEvent;class ke extends xe{constructor(e,s,i,o,n,a={}){s.constructor==Number&&(s=t.clamp(s,i,o),s=a.precision?t.round(s,a.precision):s),super(Le.KNOB,e,s,a),this.onGetValue=()=>d.value,this.onSetValue=(e,s,i)=>{m(e),t.BaseComponent._dispatchEvent(d,"change",s)},this.onResize=()=>{const e=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${e})`};const l=a.snap&&a.snap.constructor==Number,r=[];if(l){const e=(o-i)/a.snap;for(let t=0;t<a.snap+1;++t)r.push(i+t*e)}var c=document.createElement("div");c.className="lexknob",t.addClass(c,a.size),t.addClass(c,l?"show-ticks":null);let h=document.createElement("div");h.className="knobcircle",l&&h.style.setProperty("--knob-snap-mark",270/a.snap+"deg");let d=document.createElement("div");d.className="innerknobcircle",d.min=i,d.max=o,h.appendChild(d);let u=document.createElement("div");u.className="knobmarker",d.appendChild(u),d.value=d.iValue=s;let p=!1,m=function(e){const s=t.remapRange(e,d.min,d.max,-135,135);d.style.rotate=s+"deg",d.value=e};const g=t.remapRange(s,i,o,-135,135);d.style.rotate=g+"deg",a.disabled&&t.addClass(c,"disabled"),d.addEventListener("change",s=>{const i=s.target,o=s.detail;p&&(i.value=r.reduce((e,t)=>Math.abs(t-i.value)<Math.abs(e-i.value)?t:e));let c=i.value=t.clamp(i.value,i.min,i.max);if(c=a.precision?t.round(c,a.precision):c,m(c),!o){let t=this.root.querySelector(".lexcomponentname .lexicon");t&&(t.style.display=c!=d.iValue?"block":"none"),l&&!p||(this._trigger(new Se(e,c,s),n),p=!1)}},{passive:!1}),d.addEventListener("mousedown",function(e){if(document.activeElement==d||a.disabled)return;var t=f.root.ownerDocument;t.addEventListener("mousemove",C),t.addEventListener("mouseup",v),document.body.classList.add("noevents"),document.pointerLockElement||c.requestPointerLock();e.stopImmediatePropagation(),e.stopPropagation()});var f=this;function C(e){let s=-e.movementY;if(0!=s){let i=a.step??1;e.shiftKey?i*=10:e.altKey&&(i*=.1);let o=d.value-i*s;d.value=o,t.BaseComponent._dispatchEvent(d,"change")}e.stopPropagation(),e.preventDefault()}function v(e){var s=f.root.ownerDocument;s.removeEventListener("mousemove",C),s.removeEventListener("mouseup",v),document.body.classList.remove("noevents"),l&&(p=!0,t.BaseComponent._dispatchEvent(d,"change")),document.pointerLockElement&&document.exitPointerLock()}c.appendChild(h),this.root.appendChild(c),t.doAsync(this.onResize.bind(this))}}t.Knob=ke;if(_e.prototype.addKnob=function(e,t,s,i,o,n={}){const a=new ke(e,t,s,i,o,n);return this._attachComponent(a)},!t)throw"Missing LX namespace!";t.extensions.push("CodeEditor");const Ee=globalThis;function Te(e,t,s){[e[t],e[s]]=[e[s],e[t]]}function we(e,t,s=1){return e.substr(0,t)+e.substr(t+s)}function Me(e){const t=e.search(/\S|$/);return t<e.length?t:-1}function Ae(e){return e.split("").reverse().join("")}function Ne(e){return/[a-zA-Z]/.test(e)}function Pe(e){return/[^\w\s]/.test(e)}function Oe(e,t,s,i=!1){if(s=s??0,i){e=e.substring(0,s);for(var o=s-1;e[o]&&e[o]!=t;)o--;return e[o]?o:-1}return s+(e=e.substring(s)).indexOf(t)}t.vec2,t.Area,t.Panel,t.Tree,t.Tabs,t.ContextMenu;class Ie{root;name="";editor;isMain=!1;selection=null;_line=0;_position=0;get line(){return this._line}set line(e){this._line=e,this.isMain&&this.editor._setActiveLine(e)}get position(){return this._position}set position(e){if(this._position=e,this.isMain){const t=this.editor.state.activeLine;this.editor._updateDataInfoPanel("@cursor-data",`Ln ${t+1}, Col ${e+1}`)}}left=0;top=0;constructor(e,t=0,s=0,i=!1,o){this.name=e,this.editor=o,this.isMain=i,this.root=document.createElement("div"),this.root.name=e,this.root.className="cursor",this.root.innerHTML=" ",this.set(t,s,!1)}set(e=0,t=0,s=!0){this.left=e*this.editor.charWidth,this.top=t*this.editor.lineHeight,this.root.style.left=`calc( ${this.left}px + ${this.editor.xPadding} )`,this.root.style.top=`${this.top}px`,s?(this.line=t,this.position=e):(this._line=t,this._position=e)}print(){console.log(this.line,this.position)}isLast(){return this.editor._getLastCursor()==this}}class Re{fromX;toX;fromY;toY;chars=0;editor;cursor;className;constructor(e,t,s="lexcodeselection"){this.editor=e,this.cursor=t,this.className=s,this.fromX=t.position,this.toX=t.position,this.fromY=t.line,this.toY=t.line}sameLine(){return this.fromY===this.toY}samePosition(){return this.fromX===this.toX}isEmpty(){return this.sameLine()&&this.samePosition()}invertIfNecessary(){this.fromY>this.toY?(Te(this,"fromX","toX"),Te(this,"fromY","toY")):this.sameLine()&&this.fromX>this.toX&&Te(this,"fromX","toX")}selectInline(e,t,s,i,o){this.chars=i/this.editor.charWidth,this.fromX=t,this.toX=t+this.chars,this.fromY=this.toY=s;var n=document.createElement("div");n.className=this.className,n._top=s*this.editor.lineHeight,n.style.top=n._top+"px",n._left=t*this.editor.charWidth,n.style.left="calc("+n._left+"px + "+this.editor.xPadding+")",n.style.width=i+"px",o?this.editor.searchResultSelections.appendChild(n):this.editor.selections[e.name].appendChild(n),this.editor._hideActiveLine()}save(){return{fromX:this.fromX,fromY:this.fromY,toX:this.toX,toY:this.toY}}load(e){this.fromX=e.fromX,this.fromY=e.fromY,this.toX=e.toX,this.toY=e.toY}getText(){return this.editor.code&&this.sameLine()?this.editor.code.lines[this.fromY].substring(this.fromX,this.toX):null}}class De{static SCROLLBAR_VERTICAL=1;static SCROLLBAR_HORIZONTAL=2;static SCROLLBAR_VERTICAL_WIDTH=10;static SCROLLBAR_HORIZONTAL_HEIGHT=10;editor;type;root;thumb;lastPosition;constructor(e,s){this.editor=e,this.type=s,this.root=document.createElement("div"),this.root.className="lexcodescrollbar hidden",s&De.SCROLLBAR_VERTICAL?this.root.classList.add("vertical"):s&De.SCROLLBAR_HORIZONTAL&&this.root.classList.add("horizontal"),this.thumb=document.createElement("div"),this.thumb._top=0,this.thumb._left=0,this.root.appendChild(this.thumb),this.thumb.addEventListener("mousedown",function(t){var s=e.root.ownerDocument;s.addEventListener("mousemove",o),s.addEventListener("mouseup",n),i.lastPosition.set(t.x,t.y),t.stopPropagation(),t.preventDefault()}),this.lastPosition=new t.vec2(0,0);let i=this;function o(s){var o=i.lastPosition.sub(new t.vec2(s.x,s.y));i.type&De.SCROLLBAR_VERTICAL?e.updateVerticalScrollFromScrollBar(o.y):e.updateHorizontalScrollFromScrollBar(o.x),i.lastPosition.set(s.x,s.y),s.stopPropagation(),s.preventDefault()}function n(t){var s=e.root.ownerDocument;s.removeEventListener("mousemove",o),s.removeEventListener("mouseup",n)}}}const ze={common:[{test:e=>e.inBlockComment,className:"cm-com"},{test:e=>e.inString,action:(e,t)=>t._appendStringToken(e.token),discard:!0},{test:e=>e.token.substr(0,e.singleLineCommentToken.length)==e.singleLineCommentToken,className:"cm-com"},{test:(e,t)=>t._isKeyword(e),className:"cm-kwd"},{test:(e,t)=>t._mustHightlightWord(e.token,He.builtIn,e.lang)&&(!e.lang.tags||t._enclosedByTokens(e.token,e.tokenIndex,"<",">")),className:"cm-bln"},{test:(e,t)=>t._mustHightlightWord(e.token,He.statements,e.lang),className:"cm-std"},{test:(e,t)=>t._mustHightlightWord(e.token,He.symbols,e.lang),className:"cm-sym"},{test:(e,t)=>t._mustHightlightWord(e.token,He.types,e.lang),className:"cm-typ"},{test:(e,t)=>t._isNumber(e.token)||t._isNumber(e.token.replace(/[px]|[em]|%/g,"")),className:"cm-dec"},{test:e=>e.lang.usePreprocessor&&e.token.includes("#"),className:"cm-ppc"}],javascript:[{test:e=>"class"===e.prev&&"{"===e.next,className:"cm-typ"}],typescript:[{test:e=>e.scope&&","!==e.token&&"enum"==e.scope.type,className:"cm-enu"},{test:e=>":"===e.prev&&void 0!==e.next&&Ne(e.token)||"interface"===e.prev&&"{"===e.next||"enum"===e.prev&&"{"===e.next,className:"cm-typ"},{test:e=>"class"===e.prev&&"{"===e.next||"class"===e.prev&&"<"===e.next||"new"===e.prev&&"("===e.next||"new"===e.prev&&"<"===e.next,className:"cm-typ"},{test:(e,t)=>","!==e.token&&t._enclosedByTokens(e.token,e.tokenIndex,"<",">"),className:"cm-typ"}],cpp:[{test:e=>e.scope&&","!==e.token&&"enum"==e.scope.type,className:"cm-enu"},{test:e=>e.isEnumValueSymbol(e.token),className:"cm-enu"},{test:e=>"class"===e.prev&&"{"===e.next||"struct"===e.prev&&"{"===e.next,className:"cm-typ"},{test:e=>"<"===e.prev&&(">"===e.next||"*"===e.next),className:"cm-typ"},{test:e=>"::"===e.next||"::"===e.prev&&"("!==e.next,className:"cm-typ"},{test:e=>e.isClassSymbol(e.token)||e.isStructSymbol(e.token),className:"cm-typ"}],wgsl:[{test:e=>">"===e.prev&&(!e.next||"{"===e.next),className:"cm-typ"},{test:e=>":"===e.prev&&void 0!==e.next||"struct"===e.prev&&"{"===e.next,className:"cm-typ"},{test:(e,t)=>","!==e.token&&t._enclosedByTokens(e.token,e.tokenIndex,"<",">"),className:"cm-typ"}],css:[{test:e=>"."==e.prev||"::"==e.prev||":"==e.prev&&"{"==e.next||"#"==e.token[0]&&":"!=e.prev,className:"cm-kwd"},{test:e=>":"===e.prev&&(";"===e.next||"!important"===e.next),className:"cm-str"},{test:e=>(void 0===e.prev||"{"===e.prev||";"===e.prev)&&":"===e.next,className:"cm-typ"},{test:e=>"("===e.prev&&")"===e.next&&e.token.startsWith("--"),className:"cm-typ"}],batch:[{test:e=>"@"===e.token||":"===e.prev||"@"===e.prev,className:"cm-kwd"}],markdown:[{test:e=>e.isFirstToken&&e.token.replaceAll("#","").length!=e.token.length,action:(e,t)=>t._markdownHeader=!0,className:"cm-kwd"}],php:[{test:e=>e.token.startsWith("$"),className:"cm-var"},{test:e=>"class"===e.prev&&("{"===e.next||"implements"===e.next)||"enum"===e.prev,className:"cm-typ"}],post_common:[{test:e=>Ne(e.token)&&"@"!=e.token[0]&&","!=e.token[0]&&"("===e.next,className:"cm-mtd"}]};class Be{static __instances=[];static CURSOR_LEFT=1;static CURSOR_TOP=2;static CURSOR_LEFT_TOP=Be.CURSOR_LEFT|Be.CURSOR_TOP;static SELECTION_X=1;static SELECTION_Y=2;static SELECTION_X_Y=Be.SELECTION_X|Be.SELECTION_Y;static KEEP_VISIBLE_LINES=1;static UPDATE_VISIBLE_LINES=2;static WORD_TYPE_METHOD=0;static WORD_TYPE_CLASS=1;static CODE_MIN_FONT_SIZE=9;static CODE_MAX_FONT_SIZE=22;static LINE_GUTTER_WIDTH=48;static RESIZE_SCROLLBAR_H=1;static RESIZE_SCROLLBAR_V=2;static RESIZE_SCROLLBAR_H_V=Be.RESIZE_SCROLLBAR_H|Be.RESIZE_SCROLLBAR_V;static languages={};static keywords;static utils;static types;static builtIn;static statements;static declarationKeywords;static symbols;static nativeTypes;static debugScopes=!1;static debugSymbols=!1;static debugProcessedLines=!1;static _staticReady=!1;root;baseArea;area;codeArea;explorerArea;code;gutter;xPadding="0px";hScrollbar;vScrollbar;codeScroller;codeSizer;explorer;tabs;cursorsDOM;cursors=[];mustProcessLines=!1;blinker;statusPanel;leftStatusPanel;rightStatusPanel;lineScrollMargin;autocomplete;searchbox;searchlinebox;openedTabs={};loadedTabs={};actions={};state;pairKeys;stringKeys;visibleLinesViewport=new t.vec2(0,0);searchResultSelections;firstLineInViewport=-1;selections={};specialKeys;canOpenContextMenu=!0;wasKeyPaired=void 0;mustProcessNextLine;mustProcessPreviousLine;cursorBlinkRate=550;tabSpaces=4;maxUndoSteps=16;lineHeight=20;charWidth=7;fontSize=14;defaultSingleLineCommentToken="//";defaultBlockCommentTokens=["/*","*/"];isAutoCompleteActive=!1;isSearchboxActive=!1;isSearchlineboxActive=!1;skipInfo=!1;disableEdition=!1;skipTabs=!1;useFileExplorer=!1;useAutoComplete=!0;allowClosingTabs=!0;allowLoadingFiles=!0;highlight="Plain Text";explorerName="EXPLORER";newTabOptions;customSuggestions=[];onSave;onRun;onCtrlSpace;onCreateStatusPanel;onContextMenu;onNewTab;onSelectTab;onCreateFile;addExplorerItem;_lastTime=null;_lastProcessedLine=-1;_lastResult=void 0;_lastSelectionKeyDir=void 0;_lastProcessedCursorIndex=null;_lastMaxLineLength=void 0;_lastMouseDown=0;_lastTextFound="";_lastBaseareaWidth=void 0;_blockCommentCache=[];_pendingString=void 0;_skipTabs=void 0;_discardScroll=!1;_markdownHeader=void 0;_tabStorage={};_tripleClickSelection=void 0;_currentOcurrences=void 0;_currentLineNumber=void 0;_currentLineString=void 0;_currentTokenPositions=void 0;_buildingBlockComment=void 0;_buildingString=void 0;_verticalTopOffset=-1;_verticalBottomOffset=-1;_fullVerticalOffset=-1;_scopeStack=null;_mouseDown=void 0;_scopesUpdated=void 0;_stringEnded=!1;_stringInterpolation=void 0;_stringInterpolationOpened=void 0;constructor(e,t={}){if(t.filesAsync){t.files=[...t.filesAsync];return(async()=>(await this._init(e,t),this))()}this._init(e,t)}async _init(e,s={}){if(Ee.editor=this,Be.__instances.push(this),this.skipInfo=s.skipInfo??this.skipInfo,this.disableEdition=s.disableEdition??this.disableEdition,this.skipTabs=s.skipTabs??this.skipTabs,this.useFileExplorer=(s.fileExplorer??this.useFileExplorer)&&!this.skipTabs,this.useAutoComplete=s.autocomplete??this.useAutoComplete,this.allowClosingTabs=s.allowClosingTabs??this.allowClosingTabs,this.allowLoadingFiles=s.allowLoadingFiles??this.allowLoadingFiles,this.highlight=s.highlight??this.highlight,this.newTabOptions=s.newTabOptions,this.customSuggestions=s.customSuggestions??[],this.explorerName=s.explorerName??this.explorerName,this.onSave=s.onSave??s.onsave,this.onRun=s.onRun??s.onrun,this.onCtrlSpace=s.onCtrlSpace,this.onCreateStatusPanel=s.onCreateStatusPanel,this.onContextMenu=s.onContextMenu,this.onNewTab=s.onNewTab,this.onSelectTab=s.onSelectTab,this.useFileExplorer){let[s,i]=e.split({sizes:["15%","85%"]});this.explorerArea=s;let o=new t.Panel;o.addTitle(this.explorerName);let n=[];this.explorer=o.addTree(null,n,{filter:!1,rename:!1,skipDefaultIcon:!0,onevent:e=>{switch(e.type){case t.TreeEvent.NODE_DBLCLICKED:this.loadTab(e.node.id);break;case t.TreeEvent.NODE_DELETED:this.closeTab(e.node.id)}}}),this.addExplorerItem=function(e){this.explorer.innerTree.data.find((t,s)=>t.id===e.id)||this.explorer.innerTree.data.push(e)},s.attach(o),e=i}if(this.baseArea=e,this.area=new t.Area({className:"lexcodeeditor",height:"100%",skipAppend:!0}),this.skipTabs){this.codeArea=new t.Area({skipAppend:!0}),this.area.attach(this.codeArea);const e=t.makeElement("button","grid absolute self-center z-100 p-3 rounded-full bg-secondary hover:bg-tertiary cursor-pointer border",t.makeIcon("FolderOpen").innerHTML,this.area,{bottom:"8px"});e.addEventListener("click",s=>{const i=[];for(const[e,t]of[...Object.entries(this.loadedTabs).slice(1),...Object.entries(this._tabStorage)]){const t=this._getFileIcon(e),s=t?t.split(" "):[];i.push({name:e,icon:s[0],svgClass:s.slice(0).join(" "),callback:e=>{this.loadCode(e)}})}new t.DropdownMenu(e,i,{side:"top",align:"center"})})}else this.tabs=this.area.addTabs({onclose:e=>{delete this.openedTabs[e],Object.keys(this.openedTabs).length<2&&(clearInterval(this.blinker),t.removeClas(this.cursorsDOM,"show"))}}),t.addClass(this.tabs.root.parentElement,"rounded-t-lg"),this.disableEdition||this.tabs.root.parentElement.addEventListener("dblclick",e=>{(s.allowAddScripts??1)&&(e.preventDefault(),this._onCreateNewFile())}),this.codeArea=this.tabs.area;this.codeArea.root.classList.add("lexcodearea");new ResizeObserver(e=>{this.code&&this.resize()}).observe(this.codeArea.root),e.root.classList.add("codebasearea");new MutationObserver(e=>{"style"==e[0].attributeName&&this.resize()}).observe(e.root.parentNode,{attributes:!0,attributeFilter:["class","style"]}),this.root=this.area.root,this.root.tabIndex=-1,e.attach(this.root),this.disableEdition?this.root.classList.add("disabled"):(this.root.addEventListener("keydown",this.processKey.bind(this)),this.root.addEventListener("focus",this.processFocus.bind(this,!0)),this.root.addEventListener("focusout",this.processFocus.bind(this,!1))),this.root.addEventListener("mousedown",this.processMouse.bind(this)),this.root.addEventListener("mouseup",this.processMouse.bind(this)),this.root.addEventListener("mousemove",this.processMouse.bind(this)),this.root.addEventListener("click",this.processMouse.bind(this)),this.root.addEventListener("contextmenu",this.processMouse.bind(this)),document.body.addEventListener("mouseup",this._onMouseUp.bind(this)),this.cursorsDOM=document.createElement("div"),this.cursorsDOM.className="cursors",this.codeArea.attach(this.cursorsDOM),this.searchResultSelections=document.createElement("div"),this.searchResultSelections.id="search-selections",this.searchResultSelections.className="selections",this.codeArea.attach(this.searchResultSelections),this.selections={},this.xPadding=Be.LINE_GUTTER_WIDTH+"px",this._addCursor(0,0,!0,!0);{this.codeScroller=this.codeArea.root,this.firstLineInViewport=0,this.lineScrollMargin=new t.vec2(20,20);let e=-1;this.disableEdition||(this.codeScroller.addEventListener("scroll",t=>{if(this._discardScroll)this._discardScroll=!1;else{{this.setScrollBarValue("vertical");const t=this.getScrollTop();if(t>e){if(this.visibleLinesViewport.y<this.code.lines.length-1){const e=this.codeScroller.offsetHeight/this.lineHeight|0;t>=(Math.max(this.visibleLinesViewport.y-e,0)-1)*this.lineHeight&&this.processLines(Be.UPDATE_VISIBLE_LINES)}}else{t<parseInt(this.code.style.top)&&this.processLines(Be.UPDATE_VISIBLE_LINES)}e=t}this.setScrollBarValue("horizontal")}}),this.codeScroller.addEventListener("wheel",e=>{e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),e.deltaY>0?this._decreaseFontSize():this._increaseFontSize())}),this.codeScroller.addEventListener("wheel",e=>{if(!e.ctrlKey){const t=(e.deltaY>0?10:-10)*(e.shiftKey?1:0);0!=t&&this.setScrollBarValue("horizontal",t)}},{passive:!0}))}if(this.gutter=document.createElement("div"),this.gutter.className="lexcodegutter",e.attach(this.gutter),this.vScrollbar=new De(this,De.SCROLLBAR_VERTICAL),e.attach(this.vScrollbar.root),this.hScrollbar=new De(this,De.SCROLLBAR_HORIZONTAL),e.attach(this.hScrollbar.root),!this.disableEdition){this.autocomplete=document.createElement("div"),this.autocomplete.className="autocomplete",this.codeArea.attach(this.autocomplete);{const e=document.createElement("div");e.className="searchbox";const s=new t.Panel;e.appendChild(s.root),s.sameLine(4),s.addText(null,"",null,{placeholder:"Find",inputClass:"bg-secondary"}),s.addButton(null,"up",()=>this.search(null,!0),{icon:"ArrowUp",title:"Previous Match",tooltip:!0}),s.addButton(null,"down",()=>this.search(),{icon:"ArrowDown",title:"Next Match",tooltip:!0}),s.addButton(null,"x",this.hideSearchBox.bind(this),{icon:"X",title:"Close",tooltip:!0});const i=e.querySelector("input");i?.addEventListener("keyup",e=>{"Escape"==e.key?this.hideSearchBox():"Enter"==e.key&&this.search(e.target.value,!!e.shiftKey)}),this.searchbox=e,this.codeArea.attach(e)}{const e=document.createElement("div");e.className="searchbox";const s=new t.Panel;e.appendChild(s.root),s.sameLine(2),s.addText(null,"",e=>{i.value=":"+e.replaceAll(":",""),this.goToLine(i.value.slice(1))},{placeholder:"Go to line",trigger:"input"}),s.addButton(null,"x",this.hideSearchLineBox.bind(this),{icon:"X",title:"Close",tooltip:!0});let i=e.querySelector("input");i.addEventListener("keyup",e=>{"Escape"==e.key&&this.hideSearchLineBox()}),this.searchlinebox=e,this.codeArea.attach(e)}}for(this.codeSizer=document.createElement("div"),this.codeSizer.className="code-sizer pseudoparent-tabs";this.codeScroller.firstChild;)this.codeSizer.appendChild(this.codeScroller.firstChild);if(this.codeScroller.appendChild(this.codeSizer),this.state={focused:!1,selectingText:!1,activeLine:null,keyChain:null},this.pairKeys={'"':'"',"'":"'","(":")","{":"}","[":"]"},this.stringKeys={'@"':'"',"@'":"'"},this.specialKeys=["Backspace","Enter","ArrowUp","ArrowDown","ArrowRight","ArrowLeft","Delete","Home","End","Tab","Escape"],!Be._staticReady){for(let e in Be.keywords)Be.keywords[e]=new Set(Be.keywords[e]);for(let e in Be.utils)Be.utils[e]=new Set(Be.utils[e]);for(let e in Be.types)Be.types[e]=new Set(Be.types[e]);for(let e in Be.builtIn)Be.builtIn[e]=new Set(Be.builtIn[e]);for(let e in Be.statements)Be.statements[e]=new Set(Be.statements[e]);for(let e in Be.symbols)Be.symbols[e]=new Set(Be.symbols[e]);Be._staticReady=!0}this.action("Escape",!1,(e,t,s)=>{this.hideAutoCompleteBox()||this.hideSearchBox()||(this.endSelection(),this._removeSecondaryCursors())}),this.action("Backspace",!1,(e,t,s)=>{if(this._addUndoStep(t),t.selection)this.deleteSelection(t),this._tripleClickSelection&&(this.actions.Backspace.callback(e,t,s),this.lineDown(t,!0));else if(this.getCharAtPos(t,-1)){var i=t.position-1,o=1;if(s.ctrlKey){const[e,s,n]=this.getWordAtPos(t,-1);e.length>1&&(i=s,o=e.length-(n-t.position))}this.code.lines[e]=we(this.code.lines[e],i,o),this.processLine(e),this.cursorToPosition(t,i),this.useAutoComplete&&this.showAutoCompleteBox("foo",t)}else null!=this.code.lines[e-1]&&(this.lineUp(t),s.cancelShift=!0,this.actions.End.callback(t.line,t,s),this.code.lines[e-1]+=this.code.lines[e],this.code.lines.splice(e,1),this.processLines());this.resizeIfNecessary(t,!0)}),this.action("Delete",!1,(e,t,s)=>{(this._addUndoStep(t),t.selection)?this.actions.Backspace.callback(e,t,s):this.getCharAtPos(t)?(this.code.lines[e]=we(this.code.lines[e],t.position),this.processLine(e)):null!=this.code.lines[e+1]&&(this.code.lines[e]+=this.code.lines[e+1],this.code.lines.splice(e+1,1),this.processLines());this.resizeIfNecessary(t,!0)}),this.action("Tab",!0,(e,t,s)=>{if(this._skipTabs)this._skipTabs--,this._skipTabs||delete this._skipTabs;else if(this.isAutoCompleteActive)this.autoCompleteWord();else if(this._addUndoStep(t),s&&s.shiftKey)this._removeSpaces(t);else{const e=this.tabSpaces-t.position%this.tabSpaces;this._addSpaces(t,e)}},(e,t)=>t.shiftKey||e.selection&&!e.selection.sameLine()),this.action("Home",!1,(e,t,s)=>{let i=Me(this.code.lines[e]);i==t.position&&(i=0);const o=this.code.lines[e].substring(0,i);let n=t.position;if(this.resetCursorPos(Be.CURSOR_LEFT,t,!0),i>0?this.cursorToString(t,o):i=0,this.mergeCursors(e),s.shiftKey&&!s.cancelShift){t.selection&&(n+=t.selection.chars),t.selection||this.startSelection(t);var a=this.code.lines[e].substring(i,n);t.selection.sameLine()?t.selection.selectInline(t,i,t.line,this.measureString(a)):this._processSelection(t,s)}else s.keepSelection||this.endSelection()}),this.action("End",!1,(e,t,s)=>{if(!s.shiftKey&&!s._shiftKey||s.cancelShift)s.keepSelection||this.endSelection();else{var i=this.code.lines[e].substring(t.position);t.selection||this.startSelection(t),t.selection.sameLine()?t.selection.selectInline(t,t.position,t.line,this.measureString(i)):(this.resetCursorPos(Be.CURSOR_LEFT,t),this.cursorToString(t,this.code.lines[e]),this._processSelection(t,s))}this.resetCursorPos(Be.CURSOR_LEFT,t),this.cursorToString(t,this.code.lines[e]);var o=this.codeScroller.clientWidth+this.getScrollLeft()-Be.LINE_GUTTER_WIDTH;t.position*this.charWidth>=o&&this.setScrollLeft(this.code.lines[e].length*this.charWidth),this.mergeCursors(e)}),this.action("Enter",!0,(e,t,s)=>{if(this.isAutoCompleteActive)this.autoCompleteWord();else if(s.ctrlKey&&this.onRun)this.onRun(this.getText());else{this._addUndoStep(t,!0);var i=this.getCharAtPos(t,-1),o=this.getCharAtPos(t);this.code.lines.splice(t.line+1,0,""),this.code.lines[t.line+1]=this.code.lines[e].substr(t.position),this.code.lines[e]=this.code.lines[e].substr(0,t.position),this.lineDown(t,!0);var n=Me(this.code.lines[e]),a=Math.floor(n/this.tabSpaces);"{"==i&&"}"==o?(this.code.lines.splice(t.line,0,""),this._addSpaceTabs(t,a+1),this.code.lines[t.line+1]=" ".repeat(n)+this.code.lines[t.line+1]):this._addSpaceTabs(t,a),this.processLines()}}),this.action("ArrowUp",!1,(e,t,s)=>{this.isAutoCompleteActive?this._moveArrowSelectedAutoComplete("up"):s.shiftKey?(t.selection||this.startSelection(t),this.lineUp(t),this.getCharAtPos(t)||this.cursorToPosition(t,this.code.lines[t.line].length),this._processSelection(t,s,!1)):(this.endSelection(),this.lineUp(t),this.getCharAtPos(t)||this.actions.End.callback(t.line,t,s))}),this.action("ArrowDown",!1,(e,t,s)=>{if(this.isAutoCompleteActive)this._moveArrowSelectedAutoComplete("down");else{s.shiftKey?t.selection||this.startSelection(t):this.endSelection();const e=this.lineDown(t);this.getCharAtPos(t)&&e||(this.resetCursorPos(Be.CURSOR_LEFT,t),this.cursorToRight(this.code.lines[t.line],t)),s.shiftKey&&this._processSelection(t,s)}}),this.action("ArrowLeft",!1,(e,t,s)=>{if(0!=t.line||0!=t.position)if(s.metaKey)s.preventDefault(),this.actions.Home.callback(e,t,s);else if(s.ctrlKey){const[e,n,a]=this.getWordAtPos(t,-1);if(!e.length&&this.lineUp(t,!0)){const e=s.cancelShift,i=s.keepSelection;s.cancelShift=!0,s.keepSelection=!0,this.actions.End.callback(t.line,t,s),s.cancelShift=e,s.keepSelection=i}var i=Math.max(t.position-n,1),o=e.substr(0,i);s.shiftKey?t.selection||this.startSelection(t):this.endSelection(),this.cursorToString(t,o,!0),s.shiftKey&&this._processSelection(t,s)}else{var n=this.getCharAtPos(t,-1);n?s.shiftKey?(t.selection||this.startSelection(t),this.cursorToLeft(n,t),this._processSelection(t,s,!1,Be.SELECTION_X)):t.selection?(t.selection.invertIfNecessary(),this.resetCursorPos(Be.CURSOR_LEFT_TOP,t),this.cursorToLine(t,t.selection.fromY),this.cursorToPosition(t,t.selection.fromX,!0),this.endSelection()):(this.cursorToLeft(n,t),this.useAutoComplete&&this.isAutoCompleteActive&&this.showAutoCompleteBox("foo",t)):t.line>0&&(s.shiftKey&&!t.selection&&this.startSelection(t),this.lineUp(t),s.cancelShift=s.keepSelection=!0,this.actions.End.callback(t.line,t,s),delete s.cancelShift,delete s.keepSelection,s.shiftKey&&this._processSelection(t,s,!1))}}),this.action("ArrowRight",!1,(e,t,s)=>{if(t.line!=this.code.lines.length-1||t.position!=this.code.lines[t.line].length)if(s.metaKey)s.preventDefault(),this.actions.End.callback(e,t,s);else if(s.ctrlKey){const[e,n,a]=this.getWordAtPos(t);e.length||this.lineDown(t,!0);var i=t.position-n,o=e.substr(i);s.shiftKey?t.selection||this.startSelection(t):this.endSelection(),this.cursorToString(t,o),s.shiftKey&&this._processSelection(t,s)}else{var n=this.getCharAtPos(t);n?s.shiftKey?(t.selection||this.startSelection(t),this.cursorToRight(n,t),this._processSelection(t,s,!1,Be.SELECTION_X)):t.selection?(t.selection.invertIfNecessary(),this.resetCursorPos(Be.CURSOR_LEFT_TOP,t),this.cursorToLine(t,t.selection.toY),this.cursorToPosition(t,t.selection.toX,!0),this.endSelection(t)):(this.cursorToRight(n,t),this.useAutoComplete&&this.isAutoCompleteActive&&this.showAutoCompleteBox("foo",t)):void 0!==this.code.lines[t.line+1]&&(s.shiftKey?t.selection||this.startSelection(t):this.endSelection(),this.lineDown(t,!0),s.shiftKey&&this._processSelection(t,s,!1),this.hideAutoCompleteBox())}});const i=async()=>{this.statusPanel=this._createStatusPanel(s),this.statusPanel&&e.attach(this.statusPanel),"loading"==document.fonts.status&&await document.fonts.ready;const i=window.localStorage.getItem("lexcodeeditor-font-size");if(i)this._setFontSize(parseInt(i));else{const e=document.querySelector(":root"),t=getComputedStyle(e);this.fontSize=parseInt(t.getPropertyValue("--code-editor-font-size")),this.charWidth=this._measureChar()}t.emitSignal("@font-size",this.fontSize),t.doAsync(()=>{this._verticalTopOffset=this.tabs?.root.getBoundingClientRect().height??0,this._verticalBottomOffset=this.statusPanel?.root.getBoundingClientRect().height??0,this._fullVerticalOffset=this._verticalTopOffset+this._verticalBottomOffset,this.gutter.style.marginTop=`${this._verticalTopOffset}px`,this.gutter.style.height=`calc(100% - ${this._fullVerticalOffset}px)`,this.vScrollbar.root.style.marginTop=`${this._verticalTopOffset}px`,this.vScrollbar.root.style.height=`calc(100% - ${this._fullVerticalOffset}px)`,this.hScrollbar.root.style.bottom=`${this._verticalBottomOffset}px`,this.codeArea.root.style.height=`calc(100% - ${this._fullVerticalOffset}px)`,this.processLines()},50),s.callback&&s.callback.call(this,this),Ee.editor=this};if((s.allowAddScripts??1)&&(this.onCreateFile=s.onCreateFile,this.addTab("+",!1,"Create file")),s.files){console.assert(s.files.constructor===Array,"_files_ must be an Array!");const e=s.files.length,t=void 0!==s.filesAsync;let o=0;for(let n of s.files){const a=n.constructor===Array?n[0]:n,l=n.constructor===Array?n[1]:void 0;await this.loadFile(a,{filename:l,async:t,callback:(t,n)=>{o++,o==e&&(i(),s.onFilesLoaded&&s.onFilesLoaded(this,this.loadedTabs,e))}})}}else(s.defaultTab??1)&&this.addTab(s.name||"untitled",!0,s.title,{language:s.highlight??"Plain Text"}),i()}clear(){console.assert(this.rightStatusPanel&&this.leftStatusPanel,"No panels to clear."),this.rightStatusPanel.clear(),this.leftStatusPanel.clear()}static getInstances(){return Be.__instances}onKeyPressed(e){"b"==e.key&&e.ctrlKey&&this.useFileExplorer&&(this.explorerArea.root.classList.toggle("hidden"),this._lastBaseareaWidth?(this.baseArea.root.style.width=this._lastBaseareaWidth,delete this._lastBaseareaWidth):(this._lastBaseareaWidth=this.baseArea.root.style.width,this.baseArea.root.style.width="100%"))}getText(e=!1){return this.code.lines.join(e?" ":"\n")}setText(e="",t){let s=e.split("\n");this.code.lines=[].concat(s),this._removeSecondaryCursors();let i=this.getCurrentCursor(!0),o=s.pop();this.cursorToLine(i,s.length),this.cursorToPosition(i,o?.length??0,!0),this.mustProcessLines=!0,t&&this._changeLanguage(t),this._processLinesIfNecessary()}appendText(e,t){let s=t.line;t.selection&&(this.deleteSelection(t),s=t.line),this.endSelection();const i=e.replaceAll("\r","").split("\n");if(1!=i.length){let e=i.length;console.assert(e>0);const n=i.shift();e--;const a=this.code.lines[s].slice(t.position);this.code.lines[s]=[this.code.lines[s].slice(0,t.position),n].join(""),this.cursorToPosition(t,t.position+(n?.length??0));let l=null;for(var o=0;o<i.length;++o)l=i[o],this.cursorToLine(t,t.line++,!0),o==i.length-1&&(l+=a),this.code.lines.splice(1+s+o,0,l);l&&this.cursorToPosition(t,l.length),this.cursorToLine(t,t.line+e),this.processLines()}else this.code.lines[s]=[this.code.lines[s].slice(0,t.position),i[0],this.code.lines[s].slice(t.position)].join(""),this.cursorToPosition(t,t.position+i[0].length),this.processLine(s);this.resize(Be.RESIZE_SCROLLBAR_H_V,void 0,()=>{var e=this.codeScroller.clientWidth+this.getScrollLeft()-Be.LINE_GUTTER_WIDTH;t.position*this.charWidth>=e&&this.setScrollLeft(this.code.lines[s].length*this.charWidth)})}setCustomSuggestions(e){e&&e.constructor===Array&&(this.customSuggestions=e)}async loadFile(e,s={}){const i=(e,i,o)=>{const n=(e=e.replaceAll("\r","").replaceAll(/\t|\\t/g," ".repeat(this.tabSpaces))).split("\n");if(this.useFileExplorer||this.skipTabs){this._tabStorage[i]={lines:n,options:s};const e=Be.languages[s.language]?.ext;this.useFileExplorer&&(this.addExplorerItem({id:i,skipVisibility:!0,icon:this._getFileIcon(i,e)}),this.explorer.innerTree.frefresh(i))}else this.addTab(i,!0,o,s),this.code.lines=n,s.language||this._changeLanguageFromExtension(t.getExtension(i));s.callback&&s.callback(i,e)};if(e.constructor==String){const o=e,n=s.filename??o.substring(o.lastIndexOf("/")+1);if(s.async){const e=await this._requestFileAsync(o,"text");i(e,n,s.filename??o)}else t.request({url:o,success:e=>{i(e,n,s.filename??o)}})}else{const t=new FileReader;t.readAsText(e),t.onload=t=>{const s=t.currentTarget.result;i(s,e.name)}}}_addUndoStep(e,s=!1,i=!0){if(!e.isMain)return;const o=(new Date).getTime();if(!s)if(this._lastTime){if(!(o-this._lastTime>2e3))return void(this._lastTime=o);this._lastTime=null}else this._lastTime=o;i&&(this.code.redoSteps.length=0),this.code.undoSteps.push({lines:t.deepCopy(this.code.lines),cursors:this.saveCursors()})}_doUndo(e){if(!this.code.undoSteps.length)return;this._addRedoStep(e);const t=this.code.undoSteps.pop();this.code.lines=t.lines,this.processLines(),this._removeSecondaryCursors();for(let e=0;e<t.cursors.length;++e){var s=this.cursors[e];s||(s=this._addCursor()),this.restoreCursor(s,t.cursors[e])}this._hideActiveLine()}_addRedoStep(e){e.isMain&&this.code.redoSteps.push({lines:t.deepCopy(this.code.lines),cursors:this.saveCursors()})}_doRedo(e){if(!this.code.redoSteps.length)return;this._addUndoStep(e,!0,!1);const t=this.code.redoSteps.pop();this.code.lines=t.lines,this.processLines(),this._removeSecondaryCursors();for(let e=0;e<t.cursors.length;++e){var s=this.cursors[e];s||(s=this._addCursor()),this.restoreCursor(s,t.cursors[e])}}_changeLanguage(e,s,i=!1){this.code.language=e,this.highlight=e,i&&(this.code.languageOverride=e),this._updateDataInfoPanel("@highlight",e),this.mustProcessLines=!0;const o=s??Be.languages[e].ext,n=this._getFileIcon(null,o);if(!this.skipTabs){const e=this.tabs.tabDOMs[this.code.tabName];var a;if(e.firstChild.remove(),console.assert(null!=e),n.includes("."))(a=document.createElement("img")).src="https://raw.githubusercontent.com/jxarco/lexgui.js/master/"+n;else{const e=n.split(" ");a=t.makeIcon(e[0],{svgClass:e.slice(0).join(" ")})}e.prepend(a)}if(this.useFileExplorer){const e=this.explorer.innerTree.data.filter(e=>e.id===this.code.tabName)[0];console.assert(null!=e),e.icon=n,this.explorer.innerTree.frefresh(this.code.tabName)}}_changeLanguageFromExtension(e){if(!e)return this._changeLanguage(this.code.language);for(let t in Be.languages){const s=Be.languages[t].ext;if(s.constructor==Array){if(s.indexOf(e)>-1)return this._changeLanguage(t,e)}else if(s==e)return this._changeLanguage(t)}this._changeLanguage("Plain Text")}_createStatusPanel(e={}){if(this.skipInfo)return;let s=new t.Panel({className:"lexcodetabinfo flex flex-row",height:"auto"});this.onCreateStatusPanel&&this.onCreateStatusPanel(s,this);let i=this.leftStatusPanel=new t.Panel({id:"FontSizeZoomStatusComponent",height:"auto"});i.sameLine(),this.skipTabs&&i.addButton(null,"ZoomOutButton",this._decreaseFontSize.bind(this),{icon:"ZoomOut",width:"32px",title:"Zoom Out",tooltip:!0}),i.addButton(null,"ZoomOutButton",this._decreaseFontSize.bind(this),{icon:"ZoomOut",width:"32px",title:"Zoom Out",tooltip:!0}),i.addLabel(this.fontSize,{fit:!0,signal:"@font-size"}),i.addButton(null,"ZoomInButton",this._increaseFontSize.bind(this),{icon:"ZoomIn",width:"32px",title:"Zoom In",tooltip:!0}),i.endLine("justify-start"),s.attach(i.root);let o=this.rightStatusPanel=new t.Panel({height:"auto"});o.sameLine(),o.addLabel(this.code?.title??"",{id:"EditorFilenameStatusComponent",fit:!0,signal:"@tab-name"}),o.addButton(null,"Ln 1, Col 1",this.showSearchLineBox.bind(this),{id:"EditorSelectionStatusComponent",fit:!0,signal:"@cursor-data"}),o.addButton(null,"Spaces: "+this.tabSpaces,(e,s)=>{t.addContextMenu("Spaces",s,e=>{const t=[2,4,8];for(const s of t)e.add(s,e=>{this.tabSpaces=e,this.processLines(),this._updateDataInfoPanel("@tab-spaces","Spaces: "+this.tabSpaces)})})},{id:"EditorIndentationStatusComponent",nameWidth:"15%",signal:"@tab-spaces"}),o.addButton("<b>{ }</b>",this.highlight,(e,s)=>{t.addContextMenu("Language",s,e=>{for(const t of Object.keys(Be.languages))e.add(t,e=>{this._changeLanguage(e,void 0,!0),this.processLines()})})},{id:"EditorLanguageStatusComponent",nameWidth:"15%",signal:"@highlight"}),o.endLine("justify-end"),s.attach(o.root);const n={"Font Size Zoom":e.statusShowFontSizeZoom??!0,"Editor Filename":e.statusShowEditorFilename??!0,"Editor Selection":e.statusShowEditorSelection??!0,"Editor Indentation":e.statusShowEditorIndentation??!0,"Editor Language":e.statusShowEditorLanguage??!0},a=e=>{const t=s.root.querySelector(`#${e.replaceAll(" ","")}StatusComponent`);console.assert(t,`${e} has no status button!`),t.classList.toggle("hidden",!n[e])};for(const[e,t]of Object.entries(n))a(e);return s.root.addEventListener("contextmenu",e=>{if(e.target&&(e.target.classList.contains("lexpanel")||e.target.classList.contains("lexinlinecomponents")))return;const s=Object.keys(n).map((e,t)=>{const s={name:e,icon:"Check",callback:()=>{n[e]=!n[e],a(e)}};return n[e]||delete s.icon,s});new t.DropdownMenu(e.target,s,{side:"top",align:"start"})}),s}_getFileIcon(e,s,i){if(!!e&&"+"===e)return;if(!i){if(s){const i=[].concat(s);if(e){const o=t.getExtension(e),n=i.indexOf(o);n>-1&&(s=i[n])}else s=i[0]}else s=t.getExtension(e);for(const[e,t]of Object.entries(Be.languages)){if([].concat(t.ext).includes(s)){i=e;break}}}if(void 0===i)return"AlignLeft fg-neutral-500";const o=Be.languages[i]?.icon;return o?o[s]??o:"AlignLeft fg-neutral-500"}_onNewTab(e){if(this.processFocus(!1),this.onNewTab)return void this.onNewTab(e);const s=this.newTabOptions??[{name:"Create file",icon:"FilePlus",callback:this._onCreateNewFile.bind(this)},{name:"Load file",icon:"FileUp",disabled:!this.allowLoadingFiles,callback:this.loadTabFromFile.bind(this)}];new t.DropdownMenu(e.target,s,{side:"bottom",align:"start"})}_onCreateNewFile(){let e={};if(this.onCreateFile&&(e=this.onCreateFile(this),!e))return;const t=e.name??"unnamed.js";this.addTab(t,!0,t,{indexOffset:e.indexOffset,language:e.language??"JavaScript"})}_onSelectTab(e,s,i){if(this.disableEdition)return;if(e)return void this._onNewTab(s);this._removeSecondaryCursors();const o=this.getCurrentCursor(!0),n=this.code;n&&this.saveCursor(o,n.cursorState),this.code=this.loadedTabs[i],this.restoreCursor(o,this.code.cursorState),this.endSelection(),this.hideAutoCompleteBox(),this._updateDataInfoPanel("@tab-name",i),this.code.languageOverride?this._changeLanguage(this.code.languageOverride):this._changeLanguageFromExtension(t.getExtension(i)),this.processLines(),!e&&this.onSelectTab&&this.onSelectTab(i,this)}_onContextMenuTab(e=!1,s,i){e||new t.DropdownMenu(s.target,[{name:"Close",kbd:"MWB",disabled:!this.allowClosingTabs,callback:()=>{this.closeTab(i)}},{name:"Close Others",disabled:!this.allowClosingTabs,callback:()=>{for(const[e,t]of Object.entries(this.tabs.tabs))"+"!==e&&e!==i&&this.closeTab(e)}},{name:"Close All",disabled:!this.allowClosingTabs,callback:()=>{for(const[e,t]of Object.entries(this.tabs.tabs))"+"!==e&&this.closeTab(e)}},null,{name:"Copy Path",icon:"Copy",callback:()=>{navigator.clipboard.writeText(this.openedTabs[i].path??"")}}],{side:"bottom",align:"start",event:s})}addTab(e,t,s,i={}){const o=Object.keys(this.loadedTabs).slice(1).reduce((t,s)=>t+(s.replace(/[_\d+]/g,"")==e?1:0),0);o>0&&(e=e.split(".").join("_"+o+"."));const n="+"===e;let a=document.createElement("div"),l=a;Object.assign(a,{path:i.path??"",className:"code",lines:[""],language:i.language??"Plain Text",cursorState:{},undoSteps:[],redoSteps:[],lineScopes:[],lineSymbols:[],lineSignatures:[],symbolsTable:new Map,tabName:e,title:s??e,tokens:{}}),a.style.left="0px",a.style.top="0px",a.addEventListener("dragenter",function(e){e.preventDefault(),this.parentElement?.classList.add("dragging")}),a.addEventListener("dragleave",function(e){e.preventDefault(),this.parentElement?.classList.remove("dragging")}),a.addEventListener("drop",e=>{if(e.preventDefault(),a.parentElement?.classList.remove("dragging"),e.dataTransfer?.files)for(let t=0;t<e.dataTransfer.files.length;++t)this.loadFile(e.dataTransfer.files[t])}),this.loadedTabs[e]=a,this.openedTabs[e]=a;const r=this.code;this.code=a;const c=this._getFileIcon(e);return this.useFileExplorer&&!n&&(this.addExplorerItem({id:e,skipVisibility:!0,icon:c}),this.explorer.innerTree.frefresh(e)),this.skipTabs||this.tabs.add(e,a,{selected:t,fixed:n,title:a.title,icon:c,onSelect:this._onSelectTab.bind(this,n),onContextMenu:this._onContextMenuTab.bind(this,n),allowDelete:this.allowClosingTabs,indexOffset:i.indexOffset}),this.codeSizer.appendChild(a),this.endSelection(),i.language&&(l.languageOverride=i.language,this._changeLanguage(l.languageOverride),this.mustProcessLines=!0),i.codeLines&&(l.lines=i.codeLines,this.mustProcessLines=!0),t?(this.resetCursorPos(Be.CURSOR_LEFT_TOP,void 0,!0),this.mustProcessLines=!0):this.code=r,this._processLinesIfNecessary(),this._updateDataInfoPanel("@tab-name",e),e}loadCode(e){if(this.codeSizer.querySelectorAll(".code").forEach(e=>e.classList.add("hidden")),this.openedTabs[e]){return void this.openedTabs[e].classList.remove("hidden")}let s=this.loadedTabs[e];if(!s){this.addTab(e,!0);const s=this._tabStorage[e];return s&&(this.code.lines=s.lines,s.options.language?this._changeLanguage(s.options.language,void 0,!0):this._changeLanguageFromExtension(t.getExtension(e)),delete this._tabStorage[e]),void this._processLinesIfNecessary()}this.openedTabs[e]=s,this.codeSizer.appendChild(s),this.endSelection(),this.code=s,this.mustProcessLines=!0,this.resetCursorPos(Be.CURSOR_LEFT_TOP,void 0,!0),this.processLines(),this._changeLanguageFromExtension(t.getExtension(e)),this._processLinesIfNecessary(),this._updateDataInfoPanel("@tab-name",s.tabName)}loadTab(e){if(this.openedTabs[e])return void this.tabs.select(e);let s=this.loadedTabs[e];if(!s){this.addTab(e,!0);const s=this._tabStorage[e];return s&&(this.code.lines=s.lines,s.options.language?this._changeLanguage(s.options.language,void 0,!0):this._changeLanguageFromExtension(t.getExtension(e)),delete this._tabStorage[e]),void this._processLinesIfNecessary()}s.style.display="block",this.openedTabs[e]=s;const i="+"===e,o=this._getFileIcon(e);this.tabs.add(e,s,{selected:!0,fixed:i,title:s.title,icon:o,onSelect:this._onSelectTab.bind(this,i),onContextMenu:this._onContextMenuTab.bind(this,i),allowDelete:this.allowClosingTabs}),this.codeSizer.appendChild(s),this.endSelection(),this.code=s,this.resetCursorPos(Be.CURSOR_LEFT_TOP,void 0,!0),this._changeLanguageFromExtension(t.getExtension(e)),this._updateDataInfoPanel("@tab-name",s.tabName),this.processLines()}closeTab(e,t=!1){this.allowClosingTabs&&(this.tabs.delete(e),t&&(delete this.openedTabs[e],delete this.loadedTabs[e],delete this._tabStorage[e]))}getSelectedTabName(){return this.tabs.selected}loadTabFromFile(){const e=document.createElement("input");e.type="file",document.body.appendChild(e),e.click(),e.addEventListener("change",t=>{const s=t.target;s.files&&s.files[0]&&this.loadFile(s.files[0]),e.remove()})}processFocus(e=!1){e?this.restartBlink():(clearInterval(this.blinker),t.removeClass(this.cursorsDOM,"show"))}processMouse(e){const s=e.target;if((s.classList.contains("code")||s.classList.contains("lexcodearea"))&&this.code){var i=this.getCurrentCursor(),o=this.code.getBoundingClientRect();if(!(([e.clientX-o.x,e.clientY-o.y][1]/this.lineHeight|0)<0))if("mousedown"==e.type){if(2===e.button&&(this.processClick(e),this.canOpenContextMenu=!i.selection,i.selection&&(this.canOpenContextMenu=this.canOpenContextMenu||i.line>=i.selection.fromY&&i.line<=i.selection.toY&&i.position>=i.selection.fromX&&i.position<=i.selection.toX,this.canOpenContextMenu)))return;this._mouseDown=!0,this._lastMouseDown=t.getTime(),this.endSelection(),this.processClick(e)}else if("mouseup"==e.type)this._onMouseUp(e);else if("mousemove"==e.type)this._mouseDown&&(this.state.selectingText=!0,this.processSelections(e));else if("click"==e.type)switch(e.detail){case t.MOUSE_DOUBLE_CLICK:const[s,o,n]=this.getWordAtPos(i);this.resetCursorPos(Be.CURSOR_LEFT,i),this.cursorToPosition(i,o),this.startSelection(i),i.selection.selectInline(i,o,i.line,this.measureString(s)),this.cursorToString(i,s);break;case t.MOUSE_TRIPLE_CLICK:this.resetCursorPos(Be.CURSOR_LEFT,i),e._shiftKey=!0,this.actions.End.callback(i.line,i,e),this._tripleClickSelection=!0}else if("contextmenu"==e.type){if(e.preventDefault(),!this.canOpenContextMenu)return;t.addContextMenu(null,e,t=>{if(t.add("Copy",()=>{this._copyContent(i)}),this.disableEdition||(t.add("Cut",()=>{this._cutContent(i)}),t.add("Paste",()=>{this._pasteContent(i)})),!this.onContextMenu)return;let s=null;if(i.selection){i.selection&&i.selection.invertIfNecessary();const e="_NEWLINE_";let t=this.code.lines.join(e),o=0;for(let e=0;e<=i.selection.fromY;e++)o+=e==i.selection.fromY?i.selection.fromX:this.code.lines[e].length;o+=i.selection.fromY*e.length;const n=i.selection.chars+(i.selection.toY-i.selection.fromY)*e.length;s=t.substr(o,n).split(e).join("\n")}const o=this.onContextMenu(this,s,e);if(o.length){t.add("");for(const e of o)t.add(e.path,{disabled:e.disabled,callback:e.callback})}}),this.canOpenContextMenu=!1}}}_onMouseUp(e){t.getTime()-this._lastMouseDown<120&&(this.state.selectingText=!1,this.endSelection());const s=this.getCurrentCursor();if(s.selection){s.selection.invertIfNecessary();const e=s.selection.toY-s.selection.fromY;0==s.selection.chars&&0==e&&this.endSelection()}this._mouseDown=!1,this.state.selectingText=!1,delete this._lastSelectionKeyDir}processClick(e){var t=this.getCurrentCursor(),s=this.codeScroller.getBoundingClientRect(),i=[e.clientX-s.x+this.getScrollLeft(),e.clientY-s.y+this.getScrollTop()],o=i[1]/this.lineHeight|0;const n=o>this.code.lines.length-1;o=Math.min(o,this.code.lines.length-1);var a=(i[0]-parseInt(this.xPadding)+3)/this.charWidth|0,l=n?this.code.lines[o]:this.code.lines[o].slice(0,a);e.altKey?this._addCursor(o,l.length):(this._removeSecondaryCursors(),this.cursorToLine(t,o),this.cursorToPosition(t,l.length)),this.hideAutoCompleteBox()}updateSelections(e,t=!1,s=Be.SELECTION_X_Y){for(let i of this.cursors)i.selection&&this._processSelection(i,e,t,s)}processSelections(e,t=!1,s=Be.SELECTION_X_Y){for(let i of this.cursors)this._processSelection(i,e,t,s)}_processSelection(e,s,i=!1,o=Be.SELECTION_X_Y){const n=s&&s.constructor==MouseEvent;n&&this.processClick(s),e.selection||this.startSelection(e);const a=e.selection;if(this._hideActiveLine(),!i){let t=!0;!n&&e.line>=a.fromY&&(e.line!=a.fromY||e.position>=a.fromX)&&(t=s&&this._lastSelectionKeyDir&&("ArrowRight"==s.key||"ArrowDown"==s.key||"End"==s.key)),t?(o&Be.SELECTION_X&&(a.fromX=e.position),o&Be.SELECTION_Y&&(a.fromY=e.line)):(o&Be.SELECTION_X&&(a.toX=e.position),o&Be.SELECTION_Y&&(a.toY=e.line)),this._lastSelectionKeyDir=t}if(!n&&a.isEmpty())return void this.endSelection();a.chars=0;const l=a.fromX,r=a.fromY,c=a.toX,h=a.toY,d=h-r;let u=this.selections[e.name];if(d>=0){for(;d<u.childElementCount-1;)t.deleteElement(u.lastChild);for(let e=r;e<=h;e++){const t=e-r,s=e>=this.visibleLinesViewport.x&&e<=this.visibleLinesViewport.y;let i=null;s&&(i=u.childNodes[t],i||(i=document.createElement("div"),i.className="lexcodeselection",u.appendChild(i)));let o="";if(0==t){const t=l>c;o=0==d?t?this.code.lines[e].substring(c,l):this.code.lines[e].substring(l,c):this.code.lines[e].substr(l);const n=(t&&0==d?c:l)*this.charWidth;s&&(i.style.left=`calc(${n}px + ${this.xPadding})`)}else o=e==h?this.code.lines[e].substring(0,c):this.code.lines[e],s&&(i.style.left=this.xPadding);const n=this.measureString(o);a.chars+=n/this.charWidth,s&&(i.style.width=(n||(0==d?0:8))+"px",i._top=e*this.lineHeight,i.style.top=i._top+"px")}}else{for(;Math.abs(d)<u.childElementCount-1;)t.deleteElement(u.firstChild);for(let e=h;e<=r;e++){const t=e-h,s=e>=this.visibleLinesViewport.x&&e<=this.visibleLinesViewport.y;let i,o=null;if(s&&(o=u.childNodes[t],o||(o=document.createElement("div"),o.className="lexcodeselection",u.appendChild(o))),0==t){i=this.code.lines[e].substr(c);const t=c*this.charWidth;s&&(o.style.left="calc("+t+"px + "+this.xPadding+")")}else i=e==r?this.code.lines[e].substring(0,l):this.code.lines[e],s&&(o.style.left=this.xPadding);const n=this.measureString(i);a.chars+=n/this.charWidth,s&&(o.style.width=(n||8)+"px",o._top=e*this.lineHeight,o.style.top=o._top+"px")}}}async processKey(e){const s=this.cursors.length;if(!this.code||e.srcElement?.constructor!=HTMLDivElement)return;const i=e.detail??{},o=e.key??i.key;" "==o&&(e.preventDefault(),e.stopPropagation());const n=i.targetCursor;if(!this._processGlobalKeys(e,o))if(void 0===n){this._lastProcessedCursorIndex=null;for(var a=null,l=new t.vec2(0,0),r=0;r<s;r++){let t=this.cursors[r];if(!t)break;a&&a.line==t.line&&!o.includes("Arrow")&&(t.position+=l.x,t.line+=l.y,this.relocateCursors()),a=this.saveCursor(t),this._lastProcessedCursorIndex=r,this._processKeyAtCursor(e,o,t),l.x+=t.position-a.position,l.y+=t.line-a.line,t.selection||(t.line=t.line)}delete this._lastProcessedCursorIndex}else this.processKeyAtTargetCursor(e,o,n)}async processKeyAtTargetCursor(e,t,s){let i=this.cursors[s];i&&(this._processKeyAtCursor(e,t,i),this._processGlobalKeys(e,t))}_processGlobalKeys(e,t){let s=this.getCurrentCursor();if(e.ctrlKey||e.metaKey)switch(t.toLowerCase()){case"a":return e.preventDefault(),this.selectAll(),!0;case"b":return e.preventDefault(),"k"==this.state.keyChain&&(this._commentLines(s,!0),!0);case"c":return e.preventDefault(),"k"==this.state.keyChain&&(this._commentLines(s),!0);case"d":return e.preventDefault(),this.selectNextOcurrence(s),!0;case"f":return e.preventDefault(),this.showSearchBox(),!0;case"g":return e.preventDefault(),this.showSearchLineBox(),!0;case"k":return e.preventDefault(),this.state.keyChain="k",!0;case"s":return e.preventDefault(),this.onSave&&this.onSave(this.getText()),!0;case"u":return e.preventDefault(),"k"==this.state.keyChain&&(this._uncommentLines(s),!0);case"y":return e.preventDefault(),this._doRedo(s),!0;case"z":return e.preventDefault(),this._doUndo(s),!0;case"+":return e.preventDefault(),this._increaseFontSize(),!0;case"-":return e.preventDefault(),this._decreaseFontSize(),!0;case" ":if(this.onCtrlSpace)return e.preventDefault(),this.onCtrlSpace(s),!0}return this.state.keyChain=null,!1}async _processKeyAtCursor(e,t,s){const i=e.detail??{},o=i.skipUndo??!1,n=i.skipDeleteSelection??!1;if(t.length>1&&-1==this.specialKeys.indexOf(t))return;let a=s.line;this.code.lines[a]=this.code.lines[a]??"";const l=s.isLast();if(e.ctrlKey||e.metaKey)switch(t.toLowerCase()){case"c":return void this._copyContent(s);case"v":return void this._pasteContent(s);case"x":return this._cutContent(s),void this.hideAutoCompleteBox();case"arrowdown":if(!e.shiftKey&&l&&null!=this.code.lines[a+1]){var r=this._addCursor(s.line,s.position,!0);if(!r)return;return void this.lineDown(r)}}else if(e.altKey)switch(t){case"d":return e.preventDefault(),void this._duplicateLine(a,s);case"ArrowUp":return void this.swapLines(a,-1,s);case"ArrowDown":return void this.swapLines(a,1,s)}for(const i in this.actions)if(t==i)return e.preventDefault(),this._actionMustDelete(s,this.actions[t],e)&&this.actions.Backspace.callback(a,s,e),this.actions[t].callback(a,s,e);if(e.ctrlKey||e.metaKey)return;!o&&this.code.lines.length&&this._addUndoStep(s);if(['"',"'","(","{"].indexOf(t)>-1&&this._encloseSelectedWordWithKey(t,a,s))return;s.selection&&!n&&(this.actions.Backspace.callback(a,s,e),a=s.line);const c=Object.values(this.pairKeys).indexOf(t)>-1&&!this.wasKeyPaired&&this.code.lines[a][s.position]===t;c||(this.code.lines[a]=[this.code.lines[a].slice(0,s.position),t,this.code.lines[a].slice(s.position)].join("")),this.cursorToRight(t,s);if(void 0!==this.pairKeys[t]&&!this.wasKeyPaired){if(this.wasKeyPaired=!0,c)return;return this.root.dispatchEvent(new KeyboardEvent("keydown",{key:this.pairKeys[t]})),void this.cursorToLeft(t,s)}delete this.wasKeyPaired,this.processLine(a),this.resizeIfNecessary(s),this.useAutoComplete&&this.showAutoCompleteBox(t,s)}async _pasteContent(e){const t=!this.getText().length;let s=await navigator.clipboard.readText();s=s.replaceAll(/\t|\\t/g," ".repeat(this.tabSpaces)),this._addUndoStep(e,!0),this.appendText(s,e);if(this.getScrollTop()<Math.max(e.line*this.lineHeight-this.codeScroller.offsetWidth,0)&&this.codeScroller.scrollTo(0,e.line*this.lineHeight),t){const e=this._detectLanguage(s);e&&this._changeLanguage(e)}}async _copyContent(e){let t="";if(e.selection){e.selection&&e.selection.invertIfNecessary();const s="_NEWLINE_";let i=this.code.lines.join(s),o=0;for(let t=0;t<=e.selection.fromY;t++)o+=t==e.selection.fromY?e.selection.fromX:this.code.lines[t].length;o+=e.selection.fromY*s.length;const n=e.selection.chars+(e.selection.toY-e.selection.fromY)*s.length;t=i.substr(o,n).split(s).join("\n")}else t="\n"+this.code.lines[e.line];navigator.clipboard.writeText(t)}async _cutContent(e){let t=e.line,s="";if(this._addUndoStep(e,!0),e.selection){e.selection&&e.selection.invertIfNecessary();const t="_NEWLINE_";let i=this.code.lines.join(t),o=0;for(let t=0;t<=e.selection.fromY;t++)o+=t==e.selection.fromY?e.selection.fromX:this.code.lines[t].length;o+=e.selection.fromY*t.length;const n=e.selection.chars+(e.selection.toY-e.selection.fromY)*t.length;s=i.substr(o,n).split(t).join("\n"),this.deleteSelection(e)}else s="\n"+this.code.lines[e.line],this.code.lines.splice(t,1),this.processLines(),this.resetCursorPos(Be.CURSOR_LEFT,e),null==this.code.lines[t]&&this.lineUp(e);navigator.clipboard.writeText(s)}_duplicateLine(e,t){this.endSelection(),this._addUndoStep(t,!0),this.code.lines.splice(e,0,this.code.lines[e]),this.lineDown(t),this.processLines(),this.hideAutoCompleteBox()}_commentLines(e,t=!1){const s=Be.languages[this.highlight];if(this.state.keyChain=null,(e=e??this.getCurrentCursor()).selection){if(!((t?s.blockComments:s.singleLineComments)??1))return;this._addUndoStep(e,!0);const i=this.code.lines.slice(e.selection.fromY,e.selection.toY+1),o=Math.min(...i.map(e=>{var t=Me(e);return t<0?1e10:t}));if(t){const t=s.blockCommentsTokens??this.defaultBlockCommentTokens,i=this.code.lines[e.selection.fromY];let o=Me(i);-1==o&&(o=0),this.code.lines[e.selection.fromY]=[i.substring(0,o),t[0]+" ",i.substring(o)].join(""),this.code.lines[e.selection.toY]+=" "+t[1],e.selection.fromX+=t[0].length+1,this._processSelection(e)}else{for(let t=e.selection.fromY;t<=e.selection.toY;++t)this._commentLine(e,t,o,!1);const t=(s.singleLineCommentToken??this.defaultSingleLineCommentToken)+" ";this.cursorToString(e,t),e.selection.fromX+=t.length,e.selection.toX+=t.length,this._processSelection(e)}}else{if(!(s.singleLineComments??1))return;for(const e of this.cursors)this._addUndoStep(e,!0),this._commentLine(e,e.line)}this.processLines(),this._hideActiveLine()}_commentLine(e,t,s,i=!0){const o=Be.languages[this.highlight];if(!(o.singleLineComments??1))return;const n=(o.singleLineCommentToken??this.defaultSingleLineCommentToken)+" ",a=this.code.lines[t];let l=Me(a);-1!=l&&(l=s??l,this.code.lines[t]=[a.substring(0,l),n,a.substring(l)].join(""),i&&this.cursorToString(e,n))}_uncommentLines(e){this.state.keyChain=null;const t=this.getCurrentCursor();if(null!==t.selection){this._addUndoStep(e,!0);for(var s=t.selection.fromY;s<=t.selection.toY;++s)this._uncommentLine(e,s)}else for(let e of this.cursors)this._addUndoStep(e,!0),this._uncommentLine(e,e.line);this.processLines(),this._hideActiveLine()}_uncommentLine(e,t){const s=Be.languages[this.highlight];if(!(s.singleLineComments??1))return;const i=s.singleLineCommentToken??this.defaultSingleLineCommentToken,o=this.code.lines[t];o.includes(i)&&(this.code.lines[t]=o.replace(i+" ",""),o.length==this.code.lines[t].length&&(this.code.lines[t]=o.replace(i,"")),this.cursorToString(e,"X".repeat(Math.abs(o.length-this.code.lines[t].length)),!0))}action(e,t=!1,s,i){this.actions[e]={key:e,callback:s,deleteSelection:t,eventSkipDeleteFn:i}}_actionMustDelete(e,t,s){return e.selection&&t.deleteSelection&&!(t.eventSkipDeleteFn&&t.eventSkipDeleteFn(e,s))}scanWordSuggestions(){this.code.tokens={};for(let e=0;e<this.code.lines.length;++e){const t=this.code.lines[e];this._getTokensFromLine(t,!0).forEach(e=>this.code.tokens[e]=1)}}toLocalLine(e){const t=Math.max(this.firstLineInViewport-this.lineScrollMargin.x,0);return Math.min(Math.max(e-t,0),this.code.lines.length-1)}getMaxLineLength(){return Math.max(...this.code.lines.map(e=>e.length))}_processLinesIfNecessary(){this.mustProcessLines&&(this.mustProcessLines=!1,this.processLines())}processLines(e){if(!this.code)return;var s="";this._blockCommentCache.length=0,this.mustProcessLines=!1,this.code.innerHTML="";const i=this.getScrollTop();this.firstLineInViewport=(e??Be.KEEP_VISIBLE_LINES)&Be.UPDATE_VISIBLE_LINES?i/this.lineHeight|0:this.firstLineInViewport;const o=this.codeScroller.offsetHeight/this.lineHeight|0;this.visibleLinesViewport=new t.vec2(Math.max(this.firstLineInViewport-this.lineScrollMargin.x,0),Math.min(this.firstLineInViewport+o+this.lineScrollMargin.y,this.code.lines.length));{const e=Math.max(this.code.lines.length-this.visibleLinesViewport.y,0);e<=this.lineScrollMargin.y&&(this.visibleLinesViewport.y+=e)}this._scopeStack=[{name:"",type:"global"}];for(let e=this.visibleLinesViewport.x;e<this.visibleLinesViewport.y;++e)s+=this.processLine(e,!0);this.code.innerHTML=s,this.codeScroller.scrollTop=i,this.code.style.top=this.visibleLinesViewport.x*this.lineHeight+"px",this.updateSelections(null,!0),this._clearTmpVariables(),this._setActiveLine(),this.resize()}processLine(e,s=!1,i=!1){this._scopeStack?this.code.lineScopes[e]=[...this._scopeStack]:(this.code.lineScopes[e]=this.code.lineScopes[e]??[],this._scopeStack=[...this.code.lineScopes[e]]);const o=Be.languages[this.highlight],n=this.toLocalLine(e),a=this.code.lines[e];if(void 0===a)return;if(this._lastProcessedLine=e,delete this._buildingString,delete this._pendingString,delete this._markdownHeader,s||(t.deleteElement(this.code.childNodes[n]),t.insertChildAtIndex(this.code,document.createElement("pre"),n)),"Plain Text"==this.highlight){const t=a.replaceAll("<","<").replaceAll(">",">");return this._updateLine(s,e,t,i)}this._currentLineNumber=e,this._currentLineString=a;const l=this._getTokensFromLine(a);if(!l.length)return this._updateLine(s,e,"",i);let r="",c=!1;const h=this._getLineSignatureFromTokens(l),d=this.code.lineSignatures[e]!==h&&!s,u=o.blockComments??!0,p=o.blockCommentsTokens??this.defaultBlockCommentTokens;d&&(this._scopeStack=[{name:"",type:"global"}]);for(let s=0;s<l.length;++s){let i=s-1,o=l[i];for(;" "==o;)i--,o=l[i];i=s+1;let n=l[i];for(;" "==n||'"'==n;)i++,n=l[i];const a=l[s],h=s,d=this._currentTokenPositions[h];if(u&&a.substr(0,p[0].length)==p[0]&&(this._buildingBlockComment=[e,d]),"}"===a&&this._scopeStack.length>1&&this._scopeStack.pop(),r+=this._evaluateToken({token:a,prev:o,prevWithSpaces:l[s-1],next:n,nextWithSpaces:l[s+1],tokenIndex:h,isFirstToken:0==h,isLastToken:h==l.length-1,tokens:l}),u&&null!=this._buildingBlockComment&&a.substr(0,p[1].length)==p[1]){const[s,i]=this._buildingBlockComment;this._blockCommentCache.push([new t.vec2(s,e),new t.vec2(i,d)]),delete this._buildingBlockComment}if("{"!==a)continue;let m=[...this._getTokensFromLine(this.code.lines[e].substring(0,d))];if(!o)for(let t=1;t<50;t++){let s=this.code.lines[e-t];if(!s)break;const i=s.lastIndexOf("{"),o=s.lastIndexOf("}");if(i>-1?s=s.substr(i):o>-1&&(s=s.substr(o)),m=[...this._getTokensFromLine(s),...m],s.length!==this.code.lines[e-t])break}m=m.reverse().filter(e=>e.length&&" "!=e);const g=["class","enum","function","interface","type","struct","namespace"];let f=null,C=null;for(let e=0;e<m.length;e++){const t=m[e];if(g.includes(t)){f=t,C=m[e-1];break}}if("enum"===f&&m.includes(":")){const e=m.indexOf(":");C=m[e+1]||C}if(!f){const e=m.indexOf("(");C=m[e+1]||C,C&&(f="method")}const v=this._scopeStack.at(-1);v?.lineNumber!==e&&this._scopeStack.push({name:C??"",type:f??"anonymous",lineNumber:e}),c=!0}this.code.lineScopes[e]=[...this._scopeStack];const m=this._parseLineForSymbols(e,a,l,c);return this._updateLine(s,e,r,i,m,l)}_getLineSignatureFromTokens(e){const t=new Set(["{","}"]);return e.filter(e=>t.has(e)).join("_")}_updateBlockComments(e,t,s){const i=Be.languages[this.highlight].blockCommentsTokens??this.defaultBlockCommentTokens,o=e[0].x===t,n=e[0].y===t;if(e[0].x!==t&&e[0].y,delete this._buildingBlockComment,o){if(s.filter(e=>e.substr(0,i[0].length)==i[0]).length){const o=s.indexOf(i[0]),n=this._currentTokenPositions[o];e[1].x=n,this.processLine(t,!1,!0)}else{this._buildingBlockComment=[t-1,0],this.mustProcessPreviousLine=e=>-1===e.indexOf(i[0]),this.processLine(t-1,!1,!0),e[0].x=this._lastProcessedLine;const s=this.code.lines[this._lastProcessedLine].indexOf(i[0]);e[1].x=s>0?s:0}}else if(n){if(s.filter(e=>e.substr(0,i[1].length)==i[1]).length){const o=s.indexOf(i[1]),n=this._currentTokenPositions[o];e[1].y=n,this.processLine(t,!1,!0)}else{this._buildingBlockComment=[e[0].x,e[1].x],this.mustProcessNextLine=e=>-1===e.indexOf(i[1]),this.processLine(t+1,!1,!0),e[0].y=this._lastProcessedLine;const s=this.code.lines[this._lastProcessedLine],o=s.indexOf(i[1]);e[1].y=o>0?o:s.length-1}}}_processExtraLineIfNecessary(e,t,s,i=!1){if(!this._scopeStack)return void console.warn("CodeEditor: No scope available");{const s=this._inBlockCommentSection(e,1e10,-1e10);t&&void 0!==s&&(this._updateBlockComments(s,e,t),this._scopeStack=[...this.code.lineScopes[e]])}if(e+1===this.code.lines.length||!this.code.lineScopes[e+1])return;const o=this._getLineSignatureFromTokens(t),n=this.code.lineSignatures[e]!==o,a=function(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s].type!==t[s].type)return!1;return!0}(this._scopeStack,this.code.lineScopes[e+1]);if(!n&&!this._scopesUpdated||a||i){if(a)for(const t of s){const s=this.code.symbolsTable.get(t.name);if(void 0===s)return;for(const t of s)t.line!==e&&this.processLine(t.line,!1,!0)}}else n&&(this._scopesUpdated=!0),this.code.lineScopes[e+1]=[...this._scopeStack],this.processLine(e+1),delete this._scopesUpdated}_updateLine(e=!1,t,s,i=!1,o=[],n=[]){const a=`<span class='line-gutter'>${t+1}</span>`,l=this._updateLineSymbols(t,o),r=Be.debugScopes&&this.code.lineScopes[t]?this.code.lineScopes[t].map(e=>`${e.type}`).join(", "):"",c=Be.debugSymbols&&this.code.lineSymbols[t]?this.code.lineSymbols[t].map(e=>`${e.name}(${e.kind})`).join(", "):"",h=r+(r.length?" - ":"")+c;return e||(this.code.childNodes[this.toLocalLine(t)].innerHTML=a+s+h,i||this._processExtraLineIfNecessary(t,n,l,i),this.mustProcessNextLine&&(this.mustProcessNextLine(n)&&t+1<this.code.lines.length?this.processLine(t+1,!1,!0):delete this.mustProcessNextLine),this.mustProcessPreviousLine&&(this.mustProcessPreviousLine(n)&&t-1>=0?this.processLine(t-1,!1,!0):delete this.mustProcessPreviousLine),Be.debugProcessedLines&&this.code.childNodes[t]?.classList.add("debug"),this._setActiveLine(t),this._clearTmpVariables()),this.code.lineSignatures[t]=this._getLineSignatureFromTokens(n),e?`<pre>${a+s+h}</pre>`:void 0}_parseLineForSymbols(e,t,s,i=!1){const o=this._scopeStack.at(i?-2:-1);if(!o||this._inBlockCommentSection(e))return[];const n=o.name,a=o.type,l=[],r=new Map,c=t.trim(),h=this.code.lineScopes[e-1],d=e=>{const t=`${e.name}_${e.kind}_${e.scope}_${e.line}`;r.has(t)||(r.set(t,e),l.push(e))};if(c.startsWith("#"))return[];const u=Be.nativeTypes[this.highlight],p=[[/^class\s+([A-Za-z0-9_]+)/,"class"],[/^struct\s+([A-Za-z0-9_]+)/,"struct"],[/^enum\s+([A-Za-z0-9_]+)/,"enum"],[/^interface\s+([A-Za-z0-9_]+)/,"interface"],[/^type\s+([A-Za-z0-9_]+)/,"type"],[/^function\s+([A-Za-z0-9_]+)/,"method"],[/^fn\s+([A-Za-z0-9_]+)/,"method"],[/^def\s+([A-Za-z0-9_]+)/,"method"],[/^([A-Za-z0-9_]+)\s*=\s*\(?.*\)?\s*=>/,"method"]];{u&&(p.push([new RegExp(`^(?:${u.join("|")})\\s+([A-Za-z0-9_]+)s*[(]+`),"method"]),"WGSL"===this.highlight&&p.push([new RegExp(`[A-Za-z0-9]+(\\s*)+:(\\s*)+(${u.join("|")})`),"variable",e=>e[0].split(":")[0].trim()]));const e=Be.declarationKeywords[this.highlight]??["const","let","var"];p.push([new RegExp(`^(?:${e.join("|")})\\s+([A-Za-z0-9_]+)`),"variable"])}for(let[t,s,i]of p){const o=c.match(t);o&&d({name:i?i(o):o[1],kind:s,scope:n,line:e})}const m=[[/new\s+([A-Za-z0-9_]+)\s*\(/,"constructor-call"],[/this.([A-Za-z_][A-Za-z0-9_]*)\s*\=/,"class-property"]];for(let[t,s,i]of m){const o=c.match(t);o&&d({name:i?i(o):o[1],kind:s,scope:n,line:e})}const g=/([A-Za-z0-9_]+)\s*\(/g;let f;for(;f=g.exec(c);){const t=f[1],s=c.slice(0,f.index);/(new|function|fn|def)\s+$/.test(s)||(["constructor","location",...u??[]].indexOf(t)>-1||h&&"class"===h.at(-1)?.type||d({name:t,kind:"method-call",scope:n,line:e}))}if(l.length)return l;const C=s.filter(e=>e.trim().length);for(let t=0;t<C.length;t++){const s=C[t-1],i=C[t],o=C[t+1];if(a.startsWith("class")){if("("===o&&/^[a-zA-Z_]\w*$/.test(i)&&void 0===s){if("constructor"===i)continue;d({name:i,kind:"method",scope:n,line:e})}}else a.startsWith("enum")&&(Pe(i)||this._isNumber(i)||this._mustHightlightWord(i,Be.statements)||d({name:i,kind:"enum_value",scope:n,line:e}))}return l}_updateLineSymbols(e,s){this.code.lineSymbols[e]=this.code.lineSymbols[e]??[];const i=t.deepCopy(this.code.lineSymbols[e]);for(let t of this.code.lineSymbols[e]){let s=this.code.symbolsTable.get(t.name);s&&(s=s.filter(t=>t.line!==e),s.length?this.code.symbolsTable.set(t.name,s):this.code.symbolsTable.delete(t.name))}for(let e of s){let t=this.code.symbolsTable.get(e.name)??[];t.push(e),this.code.symbolsTable.set(e.name,t)}return this.code.lineSymbols[e]=s,i}_lineHasComment(e){const t=Be.languages[this.highlight];if(!(t.singleLineComments??1))return;const s=t.singleLineCommentToken??this.defaultSingleLineCommentToken,i=e.indexOf(s);if(i>-1){const t=Object.values(this.stringKeys);var o=!1;return(o=o||t.some(function(t){var s=new RegExp(t,"g");return(e.substring(0,i).match(s)||[]).length%2!=0}))?void 0:i}}_getTokensFromLine(e,t=!1){if(!e||!e.length)return[];const s=e,i=this._lineHasComment(e);null!=i&&(e=s.substring(0,i));let o=[],n=[],a=0;const l=function(e){t&&(e.includes('"')||e.length<3)||(o.push(e),n.push(a),a+=e.length)};let r=e.matchAll(/(<!--|-->|\*\/|\/\*|::|[\[\](){}<>.,;:*"'`%@$!/= ])/g),c=r.next();if(c.value){let t=0;for(;null!=c.value;){const s=e.substring(t,c.value.index);if(s.length&&l(s),l(c.value[0]),t=c.value.index+c.value[0].length,c=r.next(),!c.value){const s=e.substring(t);s.length&&l(s)}}}else l(e);return null!=i&&l(s.substring(i)),this._currentTokenPositions=n,this._processTokens(o)}_processTokens(e,t=0){if("C++"==this.highlight||"CSS"==this.highlight){var s=e.slice(t).findIndex((e,t)=>this._isNumber(e));if(s>-1){let i=e[s+=t]+e[++s];for(;this._isNumber(i);)e[s-1]+=e[s],e.splice(s,1),i+=e[s];return this._processTokens(e,s)}const i=e.indexOf("important");"CSS"==this.highlight&&i>-1&&"!"===e[i-1]&&(e[i-1]="!important",e.splice(i,1))}else if("PHP"==this.highlight){let t=0,s=e.indexOf("$");for(;s>-1;){const i=s+t;"this-"===e[i+1]?(e[i]="$this",e[i+1]="-"):(e[i]+=e[i+1]??"",e.splice(i+1,1)),s=e.slice(i).indexOf("$"),t=i}}else if("WGSL"==this.highlight){let t=0,s=e.indexOf("@");for(;s>-1;){const i=s+t;e[i]+=e[i+1]??"",e.splice(i+1,1),s=e.slice(i).indexOf("$"),t=i}}return e}_mustHightlightWord(e,t,s){s||(s=Be.languages[this.highlight]);let i=e;return s.ignoreCase&&(i=i.toLowerCase()),t[this.highlight]&&t[this.highlight].has(i)}_getTokenHighlighting(e,t){const s=[...ze.common,...ze[t]||[],...ze.post_common];for(const t of s){if(!t.test(e,this))continue;const s=t.action?t.action(e,this):void 0;return t.discard&&(e.discardToken=s),t.className}return null}_evaluateToken(e){let{token:t,prev:s,next:i,tokenIndex:o,isFirstToken:n,isLastToken:a}=e;const l=Be.languages[this.highlight],r=this.highlight.replace(/\s/g,"").replaceAll("+","p").toLowerCase(),c=Object.assign({},this.stringKeys),h=this._currentLineNumber,d=this._currentTokenPositions[o],u=void 0!==(this._buildingBlockComment??this._inBlockCommentSection(h,d,t.length));var p=!1;if(["cpp","c"].indexOf(r)>-1&&s&&s.includes("#")?c["@<"]=">":"markdown"!=r||"["!=e.prevWithSpaces&&"]"!=e.nextWithSpaces?"javascript"!=r&&"typescript"!=r||(c["@`"]="`"):(p=!0,c["@["]="]"),this._stringEnded=!1,p||!u&&(!l.tags||this._enclosedByTokens(t,o,"<",">"))){const o=e=>{if(this._stringInterpolation&&"$"==t&&"{"==i)return delete this._stringInterpolation,this._stringInterpolationOpened=!0,void(this._stringEnded=!0);const s=Object.values(c).indexOf(e);this._stringEnded=s>-1&&s==Object.values(c).indexOf(c["@"+this._buildingString])};null!=this._buildingString?o(p?e.nextWithSpaces:t):c["@"+(p?e.prevWithSpaces:t)]?(this._buildingString=p?e.prevWithSpaces:t,"javascript"!=r&&"typescript"!=r||"`"!=t||(this._stringInterpolation=!0),p&&o(e.nextWithSpaces)):this._stringInterpolationOpened&&"}"==s&&(delete this._stringInterpolationOpened,this._stringInterpolation=!0,this._buildingString="`")}e.discardToken=!1,e.inBlockComment=u,e.markdownHeader=this._markdownHeader,e.inString=void 0!==this._buildingString,e.singleLineCommentToken=l.singleLineCommentToken??this.defaultSingleLineCommentToken,e.lang=l,e.scope=this._scopeStack.at(-1),e.isVariableSymbol=e=>this.code.symbolsTable.has(e)&&"variable"===this.code.symbolsTable.get(e)[0].kind,e.isEnumValueSymbol=e=>this.code.symbolsTable.has(e)&&"enum_value"===this.code.symbolsTable.get(e)[0].kind,e.isClassSymbol=e=>this.code.symbolsTable.has(e)&&"class"===this.code.symbolsTable.get(e)[0].kind,e.isStructSymbol=e=>this.code.symbolsTable.has(e)&&"struct"===this.code.symbolsTable.get(e)[0].kind,e.isEnumSymbol=e=>this.code.symbolsTable.has(e)&&"enum"===this.code.symbolsTable.get(e)[0].kind;let m=this._getTokenHighlighting(e,r);return this._stringInterpolationOpened&&this._pendingString&&(this._pendingString=this._pendingString.substring(0,this._pendingString.indexOf("$")),"{"==e.tokens[o+1]&&(e.tokens[o+1]="${")),this._buildingString&&(this._stringEnded||a)&&!u&&(t=this._getCurrentString(),m="cm-str",e.discardToken=!1),this._buildingString=this._stringEnded?void 0:this._buildingString,e.discardToken?"":(t=t.replace("<","<").replace(">",">"),m?`<span class="${r} ${m}">${t}</span>`:t)}_appendStringToken(e){return this._pendingString||(this._pendingString=""),this._pendingString+=e,!0}_getCurrentString(){const e=this._pendingString;return delete this._pendingString,e}_enclosedByTokens(e,t,s,i){const o=this._currentTokenPositions[t],n=Oe(this._currentLineString,s,o,!0);if(n<0)return;const a=Oe(this._currentLineString,i,o,!0);if(a>=0&&a>n)return;const l=Oe(this._currentLineString,i,o);return l<0?void 0:n<o&&l>=o+e.length&&!this._mustHightlightWord(e,Be.symbols)?[n,l]:void 0}_inBlockCommentSection(e,t=-1,s=-1){const i=Be.languages[this.highlight].blockCommentsTokens??this.defaultBlockCommentTokens;for(let o of this._blockCommentCache){const n=o[0],a=o[1];if(e>=n.x&&e<=n.y&&(e!=n.x&&e!=n.y||e==n.x&&t>=a.x&&(e==n.y&&t+s<=a.y+i[1].length||e!==n.y)||e==n.y&&t+s<=a.y+i[1].length&&(e==n.x&&t>=a.x||e!==n.x)))return o}}_isKeyword(e){const{token:t,tokenIndex:s,tokens:i,lang:o}=e;let n=this._mustHightlightWord(t,Be.keywords)||"XML"==this.highlight;return"CMake"==this.highlight&&("$"==t&&this._enclosedByTokens(i[s+2],s+2,"{","}")?n=!0:this._enclosedByTokens(t,s,"{","}")&&(n=n||"$"==e.tokens[s-2])),"Markdown"==this.highlight?n=void 0!==this._markdownHeader:o.tags&&(n=n&&null!=this._enclosedByTokens(t,s,"<",">")),n}_isNumber(e){if(!(Be.languages[this.highlight].numbers??1))return!1;const s=e.substring(0,e.length-1);if("C++"==this.highlight){if("f"==t.lastChar(e))return this._isNumber(s);if("u"==t.lastChar(e))return!e.includes(".")&&this._isNumber(s)}else if("WGSL"==this.highlight){if("u"==t.lastChar(e))return!e.includes(".")&&this._isNumber(s)}else if("CSS"==this.highlight&&"%"==t.lastChar(e))return this._isNumber(s);return e.length>0&&" "!=e&&!Number.isNaN(+e)}_encloseSelectedWordWithKey(e,t,s){if(!s.selection||s.selection.fromY!=s.selection.toY)return!1;switch(s.selection.invertIfNecessary(),this.code.lines[t]=[this.code.lines[t].slice(0,s.selection.fromX),e,this.code.lines[t].slice(s.selection.fromX)].join(""),this.cursorToPosition(s,s.selection.toX+1),e){case"'":case'"':break;case"(":e=")";break;case"{":e="}"}return this.code.lines[t]=[this.code.lines[t].slice(0,s.position),e,this.code.lines[t].slice(s.position)].join(""),s.selection.fromX++,s.selection.toX++,this._processSelection(s),this.processLine(t),!0}_detectLanguage(e){const t=new Set(this._getTokensFromLine(e,!0)),s={},i={JavaScript:["import ","export default","console.","=>","document.","window."],TypeScript:["import ","export default","console.","=>","document.","window."],"C++":["#include","::","std::","template <","using namespace"],Python:["def ","import ","print(","self","None","True","False"],HTML:["<html","<div","<body","<script","<style"],CSS:["@media"],Markdown:["#","##","###","](","![","**"]};for(const[t,o]of Object.entries(i)){s[t]=s[t]??0;for(const i of o)e.includes(i)&&(s[t]+=20)}const o=[Be.keywords,Be.statements,Be.utils,Be.types,Be.builtIn];for(const e of o)for(let[i,o]of Object.entries(e)){s[i]=s[i]??0;for(let e of o)t.has(e)&&s[i]++}const n=Object.entries(s).sort((e,t)=>t[1]-e[1]);return n[0][1]>0?n[0][0]:void 0}lineUp(e,t=!1){return null!=this.code.lines[e.line-1]&&(e.line--,e.line=Math.max(0,e.line),this.cursorToTop(e,t),!0)}lineDown(e,t=!1){return null!=this.code.lines[e.line+1]&&(e.line++,this.cursorToBottom(e,t),!0)}swapLines(e,t,s){var i,o,n;null!=this.code.lines[e+t]&&(this._addUndoStep(s,!0),i=this.code.lines,o=e+t,n=e,[i[o],i[n]]=[i[n],i[o]],this.processLine(e+t),this.processLine(e),t>0?this.lineDown(s):this.lineUp(s),this.hideAutoCompleteBox())}restartBlink(){this.code&&(clearInterval(this.blinker),t.addClass(this.cursorsDOM,"show"),this.cursorBlinkRate>0?this.blinker=setInterval(()=>{t.toggleClass(this.cursorsDOM,"show")},this.cursorBlinkRate):this.cursorBlinkRate<0&&t.removeClass(this.cursorsDOM,"show"))}startSelection(e){let s=document.createElement("div");s.className="selections",s.classList.add("show"),t.insertChildAtIndex(this.codeSizer,s,2),this.selections[e.name]=s,e.selection=new Re(this,e)}deleteSelection(e){if(this.disableEdition)return;e.selection&&e.selection.invertIfNecessary();const t=e.selection,s="_NEWLINE_";let i=this.code.lines.join(s),o=0;for(let e=0;e<=t.fromY;e++)o+=e==t.fromY?t.fromX:this.code.lines[e].length;o+=9*t.fromY;const n=t.chars+9*(t.toY-t.fromY),a=i.slice(0,o),l=i.slice(o+n);this.code.lines=(a+l).split(s),this.cursorToLine(e,t.fromY,!0),this.cursorToPosition(e,t.fromX),this.endSelection(e),this.processLines()}endSelection(e){if(delete this._tripleClickSelection,delete this._lastSelectionKeyDir,delete this._currentOcurrences,delete this._lastResult,e)t.deleteElement(this.selections[e.name]),delete this.selections[e.name],e.selection=null,e.line=e.line;else for(let e of this.cursors)e.line=e.line,t.deleteElement(this.selections[e.name]),delete this.selections[e.name],e.selection=null}selectAll(){this.endSelection(),this._removeSecondaryCursors();var e=this.getCurrentCursor();this.resetCursorPos(Be.CURSOR_LEFT_TOP,e,!0),this.startSelection(e);const t=e.selection,s=this.code.lines.length-1;t.toX=this.code.lines[s].length,t.toY=s,this.cursorToPosition(e,t.toX),this.cursorToLine(e,t.toY),this._processSelection(e,null,!0),this.hideAutoCompleteBox()}cursorToRight(e,t){if(!e||!e.length)return;const s=e.length,i=s*this.charWidth;t.left+=i,t.root.style.left=`calc( ${t.left}px + ${this.xPadding} )`,t.position+=s,this.restartBlink(),this.updateScrollLeft(t)}cursorToLeft(e,t){if(!e||!e.length)return;const s=e.length,i=s*this.charWidth;if(t.left-=i,t.left=Math.max(t.left,0),t.root.style.left=`calc( ${t.left}px + ${this.xPadding} )`,t.position-=s,t.position=Math.max(t.position,0),this.restartBlink(),!this.updateScrollLeft(t)){const e=this.charWidth,s=t.position*this.charWidth;if(s<this.getScrollLeft()+e){const t=Math.max(s-e,0);this.setScrollLeft(t)}}}cursorToTop(e,t=!1){e.top-=this.lineHeight,e.top=Math.max(e.top,0),e.root.style.top=`calc(${e.top}px)`,this.restartBlink(),t&&this.resetCursorPos(Be.CURSOR_LEFT,e,!0);const s=this.getScrollTop();var i=s/this.lineHeight|0;e.line-1<i&&this.setScrollTop(s-this.lineHeight)}cursorToBottom(e,t=!1){e.top+=this.lineHeight,e.root.style.top=`calc(${e.top}px)`,this.restartBlink(),t&&this.resetCursorPos(Be.CURSOR_LEFT,e,!0);const s=this.getScrollTop(),i=(this.codeScroller.offsetHeight-this._fullVerticalOffset+s)/this.lineHeight|0;e.line>=i&&this.setScrollTop(s+this.lineHeight)}cursorToString(e,t,s=!1){t.length&&(s?this.cursorToLeft(t,e):this.cursorToRight(t,e))}cursorToPosition(e,t,s=!1){e.position=t,e.left=t*this.charWidth,e.root.style.left=`calc( ${e.left}px + ${this.xPadding} )`,s&&this.updateScrollLeft(e)}cursorToLine(e,t,s=!1){e.line=t,e.top=this.lineHeight*t,e.root.style.top=e.top+"px",s&&this.resetCursorPos(Be.CURSOR_LEFT,e)}saveCursor(e,t={}){return t.position=e.position,t.line=e.line,t.selection=e.selection?e.selection.save():void 0,t}saveCursors(){var e=[];for(let t of this.cursors)e.push(this.saveCursor(t));return e}getCurrentCursor(e=!1){return e&&this._removeSecondaryCursors(),this.cursors[0]}relocateCursors(){for(let e of this.cursors)e.set(e.position,e.line,!1)}mergeCursors(e){console.assert(e>=0);const t=this.cursors.filter(t=>t.line==e);for(;t.length>1;)this.removeCursor(t.pop())}restoreCursor(e,t){e.set(t.position,t.line),t.selection&&(this.endSelection(),this.startSelection(e),e.selection?.load(t.selection),this._processSelection(e,null,!0))}removeCursor(e){e&&(t.deleteElement(this.selections[e.name]),delete this.selections[e.name],t.deleteElement(e))}resetCursorPos(e,t,s=!1){t=t??this.getCurrentCursor(),e&Be.CURSOR_LEFT&&(t.left=0,t.root.style.left="calc("+this.xPadding+")",t.position=0,s&&this.setScrollLeft(0)),e&Be.CURSOR_TOP&&(t.top=0,t.root.style.top="0px",t.line=0,s&&this.setScrollTop(0))}_addCursor(e=0,t=0,s=!1,i=!1){const o=this.cursors.find(s=>s.position==t&&s.line==e);if(o&&!s)return o.isMain||o.remove(),null;let n=new Ie("cursor"+this.cursors.length,t,e,i,this);return this.cursors.push(n),this.cursorsDOM.appendChild(n.root),n}_removeSecondaryCursors(){for(;this.cursors.length>1;){const e=this.cursors.pop();e?.root.remove()}}_getLastCursor(){return this.cursors.at(-1)}_isLastCursor(e){return e===this._getLastCursor()}_logCursors(){for(let e of this.cursors)e.print()}_addSpaceTabs(e,t){for(var s=0;s<t;++s)this.actions.Tab.callback(e.line,e,null)}_addSpaces(e,t){if(!e.selection||e.selection.sameLine())for(var s=0;s<t;++s)this.root.dispatchEvent(new CustomEvent("keydown",{detail:{skipUndo:!0,key:" ",targetCursor:this._lastProcessedCursorIndex}}));else{e.selection.invertIfNecessary();for(let t=e.selection.fromY;t<=e.selection.toY;++t){const s=this.code.lines[t];if(!s.length)continue;let i=Me(s);-1==i&&(i=s.length);let o=i%this.tabSpaces;o=0==o?this.tabSpaces:this.tabSpaces-o;const n=" ".repeat(o);this.code.lines[t]=[s.slice(0,i),n,s.slice(i)].join(""),this.processLine(t),e.line===t&&this.cursorToString(e,n),e.selection.fromY===t&&(e.selection.fromX=Math.max(e.selection.fromX+o,0)),e.selection.toY===t&&(e.selection.toX=Math.max(e.selection.toX+o,0)),this._processSelection(e,void 0,!0)}}}_removeSpaces(e){e.selection&&e.selection.invertIfNecessary();const t=e.selection?e.selection.toY-e.selection.fromY+1:1;for(let s=0;s<t;++s){const t=(e.selection?e.selection.fromY:e.line)+s,i=this.code.lines[t];let o=Me(i);if(0==o)continue;-1==o&&(o=i.length);let n=o%this.tabSpaces;n=0==n?this.tabSpaces:n;const a=Math.max(o-n,0);this.code.lines[t]=[i.slice(0,a),i.slice(o)].join(""),this.processLine(t),e.line===t&&this.cursorToString(e," ".repeat(n),!0),e.selection&&(e.selection.fromY===t&&(e.selection.fromX=Math.max(e.selection.fromX-n,0)),e.selection.toY===t&&(e.selection.toX=Math.max(e.selection.toX-n,0)),this._processSelection(e,void 0,!0))}}updateScrollLeft(e){e=e??this.getCurrentCursor();const t=this.charWidth,s=e.position*this.charWidth,i=this.getScrollLeft(),o=this.codeScroller.clientWidth-Be.LINE_GUTTER_WIDTH;if(s>=o+i-t){const e=Math.max(s-(o-t),0);return this.setScrollLeft(e),!0}}getScrollLeft(){return this.codeScroller?this.codeScroller.scrollLeft:0}getScrollTop(){return this.codeScroller?this.codeScroller.scrollTop:0}setScrollLeft(e){this.codeScroller&&t.doAsync(()=>{this.codeScroller.scrollLeft=e,this.setScrollBarValue("horizontal",0)},10)}setScrollTop(e){this.codeScroller&&t.doAsync(()=>{this.codeScroller.scrollTop=e,this.setScrollBarValue("vertical")},10)}resize(e=Be.RESIZE_SCROLLBAR_H_V,t,s){setTimeout(()=>{let i,o;if(e&Be.RESIZE_SCROLLBAR_H){const e=t??this.getMaxLineLength();this._lastMaxLineLength=e,i=e*this.charWidth+Be.LINE_GUTTER_WIDTH,this.codeSizer.style.minWidth=i+"px"}e&Be.RESIZE_SCROLLBAR_V&&(o=this.code.lines.length*this.lineHeight,this.codeSizer.style.minHeight=o+"px"),this.resizeScrollBars(e),s&&s(i,o)},10)}resizeIfNecessary(e,t=!1){const s=this.getMaxLineLength(),i=Math.floor((this.codeScroller.clientWidth-Be.LINE_GUTTER_WIDTH)/this.charWidth);(t||s>=i&&s!=this._lastMaxLineLength)&&this.resize(Be.RESIZE_SCROLLBAR_H,s,()=>{e.position>i&&this.setScrollLeft(e.position*this.charWidth)})}resizeScrollBars(e=Be.RESIZE_SCROLLBAR_H_V){if(e&Be.RESIZE_SCROLLBAR_V){const e=this.codeScroller.offsetHeight/this.lineHeight|0,t=this.code.lines.length>=e;t&&(this.vScrollbar.thumb.size=e/this.code.lines.length,this.vScrollbar.thumb.style.height=100*this.vScrollbar.thumb.size+"%"),this.vScrollbar.root.classList.toggle("hidden",!t),this.hScrollbar.root.style.width=`calc(100% - ${48+(t?De.SCROLLBAR_VERTICAL_WIDTH:0)}px)`,this.codeArea.root.style.width=`calc(100% - ${t?De.SCROLLBAR_VERTICAL_WIDTH:0}px)`}if(e&Be.RESIZE_SCROLLBAR_H){const e=Math.floor((this.codeScroller.clientWidth-Be.LINE_GUTTER_WIDTH)/this.charWidth),t=this._lastMaxLineLength,s=t>=e;s&&(this.hScrollbar.thumb.size=e/t,this.hScrollbar.thumb.style.width=100*this.hScrollbar.thumb.size+"%"),this.hScrollbar.root.classList.toggle("hidden",!s),this.codeArea.root.style.height=`calc(100% - ${this._fullVerticalOffset+(s?De.SCROLLBAR_HORIZONTAL_HEIGHT:0)}px)`}}setScrollBarValue(e="vertical",t){if("vertical"==e){const e=this.codeScroller.scrollHeight-this.codeScroller.clientHeight;if(e>0){const t=this.vScrollbar.thumb.parentElement.offsetHeight,s=this.vScrollbar.thumb.offsetHeight,i=this.codeScroller.scrollTop;this.vScrollbar.thumb._top=i/e*(t-s),this.vScrollbar.thumb.style.top=this.vScrollbar.thumb._top+"px"}}else{void 0!==t&&(this.codeScroller.scrollLeft+=t);const e=this.codeScroller.scrollWidth-this.codeScroller.clientWidth;if(e>0){const t=this.hScrollbar.thumb.parentElement.offsetWidth,s=this.hScrollbar.thumb.offsetWidth,i=this.codeScroller.scrollLeft;this.hScrollbar.thumb._left=i/e*(t-s),this.hScrollbar.thumb.style.left=this.hScrollbar.thumb._left+"px"}}}updateHorizontalScrollFromScrollBar(e){e=this.hScrollbar.thumb._left-e;const s=this.hScrollbar.thumb.parentElement.offsetWidth,i=this.hScrollbar.thumb.offsetWidth;this.hScrollbar.thumb._left=t.clamp(e,0,s-i),this.hScrollbar.thumb.style.left=this.hScrollbar.thumb._left+"px";const o=this.codeScroller.scrollWidth-this.codeScroller.clientWidth,n=this.hScrollbar.thumb._left*o/(s-i);this.codeScroller.scrollLeft=n,this._discardScroll=!0}updateVerticalScrollFromScrollBar(e){e=this.vScrollbar.thumb._top-e;const s=this.vScrollbar.thumb.parentElement.offsetHeight,i=this.vScrollbar.thumb.offsetHeight;this.vScrollbar.thumb._top=t.clamp(e,0,s-i),this.vScrollbar.thumb.style.top=this.vScrollbar.thumb._top+"px";const o=this.codeScroller.scrollHeight-this.codeScroller.clientHeight,n=this.vScrollbar.thumb._top*o/(s-i);this.codeScroller.scrollTop=n}getCharAtPos(e,t=0){return this.code.lines[e.line][e.position+t]}getWordAtPos(e,t=0){const s=e.line,i=this.code.lines[s],o=e=>{const t=e.charCodeAt(0);return["_","#","!"].indexOf(e)>-1||t>47&&t<58||t>64&&t<91||t>96&&t<123};let n=e.position+t,a=e.position+t;for(;i[n]&&o(i[n]);)n--;for(n++;i[a]&&o(i[a]);)a++;let l=i.substring(n,a);if(" "==l)if(t<0){for(;null!=i[n-1]&&" "==i[n-1];)n--;a++,l=i.substring(n,a+1)}else{for(;null!=i[a]&&" "==i[a];)a++;n--,l=i.substring(n,a)}return[l,n,a]}_measureChar(e="M",s=!0,i=!1){const o=t.makeContainer(null,"lexcodeeditor","",document.body),n=t.makeContainer(null,"code","",o),a=document.createElement("pre");n.appendChild(a);const l=document.createElement("span");a.appendChild(l),l.innerText=e;var r=l.getBoundingClientRect();t.deleteElement(o);const c=[s?r.width:Math.floor(r.width),s?r.height:Math.floor(r.height)];return i?c:c[0]}measureString(e){return e.length*this.charWidth}runScript(e){const t=document.createElement("script");t.type="module",t.innerHTML=e,t.async=!1,document.getElementsByTagName("head")[0].appendChild(t)}toJSONFormat(e){let t=e.split(":");for(let e=0;e<t.length;e++){let s=t[e].split(",");if(s.length>1){if(s[s.length-1].includes("]"))continue;s=s[s.length-1]}else{if(s[0].includes("}"))continue;s=s[0]}s=s.replaceAll(/[{}\n\r]/g,"").replaceAll(" ",""),'"'!=s[0]&&'"'!=s[s.length-1]&&(t[e]=t[e].replace(s,'"'+s+'"'))}e=t.join(":");try{let t=JSON.parse(e);return JSON.stringify(t,void 0,4)}catch(e){return void alert("Invalid JSON format")}}showAutoCompleteBox(e,s){if(!s.isMain)return;const[i,o,n]=this.getWordAtPos(s,-1);if(" "==e||!i.length)return void this.hideAutoCompleteBox();this.autocomplete.innerHTML="";let a=[...Array.from(Be.keywords[this.highlight]??[]),...Array.from(Be.builtIn[this.highlight]??[]),...Array.from(Be.statements[this.highlight]??[]),...Array.from(Be.types[this.highlight]??[]),...Array.from(Be.utils[this.highlight]??[])];const l=[...this.code.lineScopes[s.line]].at(-1);if(l.type.startsWith("enum")){const e=Array.from(this.code.symbolsTable).filter(e=>"enum_value"===e[1][0].kind&&e[1][0].scope===l.name).map(e=>e[0]);a=a.concat(e.slice(0,-1))}else{const e=Array.from(this.code.symbolsTable).map(e=>e[0]);a=a.concat(e.slice(0,-1))}function r(e,t){return e.startsWith(t)?0:e.includes(t)?1:2}a=a.concat(this.customSuggestions),a=Array.from(new Set(a)).filter(e=>e.length>2&&e.toLowerCase().includes(i.toLowerCase())),a=a.sort((e,t)=>r(e,i)-r(t,i)||e.localeCompare(t));for(let e of a){const s=e,o=document.createElement("pre");this.autocomplete.appendChild(o);const n=this.code.symbolsTable.get(e);let a="CaseLower",l="foo";if(n)switch(n[0].kind){case"variable":a="Cuboid",l="fg-blue-400";break;case"method":a="Box",l="fg-fuchsia-500";break;case"class":a="CircleNodes",l="fg-orange-500"}else this._mustHightlightWord(s,Be.utils)?a="ToolCase":this._mustHightlightWord(s,Be.types)&&(a="Type",l="fg-blue-400");o.appendChild(t.makeIcon(a,{iconClass:"mr-1",svgClass:"sm "+l})),o.addEventListener("click",()=>{this.autoCompleteWord(s)});const r=s.toLowerCase().indexOf(i.toLowerCase());var c=document.createElement("span");c.innerHTML=s.substring(0,r),o.appendChild(c);var h=document.createElement("span");h.innerHTML=s.substr(r,i.length),h.classList.add("word-highlight"),o.appendChild(h);var d=document.createElement("span");d.innerHTML=s.substring(r+i.length),o.appendChild(d)}if(!this.autocomplete.childElementCount)return void this.hideAutoCompleteBox();const u=this.codeScroller.clientWidth-256;this.autocomplete.firstChild.classList.add("selected"),this.autocomplete.classList.toggle("show",!0),this.autocomplete.classList.toggle("no-scrollbar",!(this.autocomplete.scrollHeight>this.autocomplete.offsetHeight)),this.autocomplete.style.left=`${Math.min(s.left+Be.LINE_GUTTER_WIDTH-this.getScrollLeft(),u)}px`,this.autocomplete.style.top=s.top+this._verticalTopOffset+this.lineHeight-this.getScrollTop()+"px",this.isAutoCompleteActive=!0}hideAutoCompleteBox(){if(!this.autocomplete)return;const e=this.isAutoCompleteActive;return this.isAutoCompleteActive=!1,this.autocomplete.classList.remove("show"),this.autocomplete.innerHTML="",e!=this.isAutoCompleteActive}autoCompleteWord(e){if(!this.isAutoCompleteActive)return;let[t,s]=this._getSelectedAutoComplete();t=e??t;for(let e of this.cursors){const[s,i,o]=this.getWordAtPos(e,-1),n=this.code.lines[e.line];this.code.lines[e.line]=n.slice(0,i)+t+n.slice(o),this.cursorToPosition(e,i+t.length),this.processLine(e.line)}this._skipTabs=this.cursors.length-1,this.hideAutoCompleteBox()}_getSelectedAutoComplete(){for(let t=0;t<this.autocomplete.childElementCount;++t){const s=this.autocomplete.childNodes[t];if(s.classList.contains("selected")){var e="";for(let t of s.childNodes)t.constructor==HTMLSpanElement&&(e+=t.innerHTML);return[e,t]}}return[null,-1]}_moveArrowSelectedAutoComplete(e){if(!this.isAutoCompleteActive)return;const[s,i]=this._getSelectedAutoComplete(),o="down"==e?1:-1,n=i+o;if("down"==e){if(n>=this.autocomplete.childElementCount)return;22*(i+2*o)-this.autocomplete.scrollTop>132&&(this.autocomplete.scrollTop+=22)}else if("up"==e){if(n<0)return;22*n<this.autocomplete.scrollTop&&(this.autocomplete.scrollTop-=22)}t.removeClass(this.autocomplete.childNodes[i],"selected"),t.addClass(this.autocomplete.childNodes[i+o],"selected")}showSearchBox(e=!1){this.hideSearchLineBox(),t.addClass(this.searchbox,"opened"),this.isSearchboxActive=!0;const s=this.searchbox.querySelector("input");if(e)s.value="";else{const e=this.getCurrentCursor();e.selection&&(s.value=e.selection.getText()??s.value)}s.selectionStart=0,s.selectionEnd=s.value.length,s.focus()}hideSearchBox(){const e=this.isSearchboxActive;return this.isSearchboxActive?(this.searchbox.classList.remove("opened"),this.isSearchboxActive=!1):this._lastResult&&(t.deleteElement(this._lastResult.dom),delete this._lastResult),this.searchResultSelections.classList.remove("show"),e!=this.isSearchboxActive}search(e,s=!1,i,o=!1,n=!0){if(!(e=e??this._lastTextFound))return;let a=this.getCurrentCursor(),l=new t.vec2(a.position,a.line),r=null,c=-1;this._lastResult&&(t.deleteElement(this._lastResult.dom),l=this._lastResult.pos,l.x+=e.length*(s?-1:1),delete this._lastResult);const h=t=>{var i=this.code.lines[t];if(s){var o=Ae(i=i.substr(0,t==l.y?l.x:i.length)).indexOf(Ae(e));return-1==o?-1:i.length-o-e.length}return i.substr(t==l.y?l.x:0).indexOf(e)};if(s){for(var d=l.y;d>=0;--d)if(c=h(d),c>-1){r=d;break}}else for(d=l.y;d<this.code.lines.length;++d)if(c=h(d),c>-1){r=d;break}if(null==r){o||alert("No results!");const e=this.code.lines.length-1;return void(this._lastResult={dom:this.searchResultSelections.lastChild,pos:s?new t.vec2(this.code.lines[e].length,e):new t.vec2(0,0)})}if(s||(c+=r==l.y?l.x:0),this._lastTextFound=e,this.codeScroller.scrollTo(Math.max(c*this.charWidth-this.codeScroller.clientWidth,0),Math.max(r-10,0)*this.lineHeight),i?i(c,r):(this.searchResultSelections.classList.add("show"),a.selection=new Re(this,a,"lexcodesearchresult"),a.selection.selectInline(a,c,r,this.measureString(e),!0)),this._lastResult={dom:this.searchResultSelections.lastChild,pos:new t.vec2(c,r),reverse:s},n){this.searchbox.querySelector("input").focus()}}showSearchLineBox(){this.hideSearchBox(),this.searchlinebox.classList.add("opened"),this.isSearchlineboxActive=!0;const e=this.searchlinebox.querySelector("input");e.value=":",e.focus()}hideSearchLineBox(){this.isSearchlineboxActive&&(this.searchlinebox.classList.remove("opened"),this.isSearchlineboxActive=!1)}goToLine(e){if(this._isNumber(e)){this.codeScroller.scrollTo(0,Math.max(e-15)*this.lineHeight);var t=this.getCurrentCursor(!0);this.cursorToLine(t,e-1,!0)}}selectNextOcurrence(e){if(!e.selection)return;const t=e.selection.getText();if(t){if(!this._currentOcurrences){const s=[e.position-t.length,e.line].join("_");this._currentOcurrences={},this._currentOcurrences[s]=!0}this.search(t,!1,(e,s)=>{const i=[e,s].join("_");if(!this._currentOcurrences[i]){var o=this._addCursor(s,e,!0);o&&(this.startSelection(o),o?.root.selection.selectInline(o,e,s,this.measureString(t)),this.cursorToString(o,t)),this._currentOcurrences[i]=!0}},!0,!1)}}_updateDataInfoPanel(e,s){this.skipInfo||(this.cursors.length>1&&(s=""),t.emitSignal(e,s))}_setActiveLine(e){if(void 0===(e=e??this.state.activeLine))return;const t=this.getCurrentCursor();this._updateDataInfoPanel("@cursor-data",`Ln ${e+1}, Col ${t.position+1}`);const s=this.toLocalLine(this.state.activeLine);let i=this.code.childNodes[s];if(i){i.classList.remove("active-line");{this.state.activeLine=e;const t=this.toLocalLine(e);i=this.code.childNodes[t],i&&i.classList.add("active-line")}}}_hideActiveLine(){this.code.querySelectorAll(".active-line").forEach(e=>e.classList.remove("active-line"))}_setFontSize(e){this.fontSize=e;const s=document.querySelector(":root");s.style.setProperty("--code-editor-font-size",`${this.fontSize}px`),this.charWidth=this._measureChar(),window.localStorage.setItem("lexcodeeditor-font-size",`${this.fontSize}`);const i=this.fontSize+6;s.style.setProperty("--code-editor-row-height",`${i}px`),this.lineHeight=i,this.relocateCursors(),this.processLines(),t.emitSignal("@font-size",this.fontSize)}_applyFontSizeOffset(e=0){const s=t.clamp(this.fontSize+e,Be.CODE_MIN_FONT_SIZE,Be.CODE_MAX_FONT_SIZE);this._setFontSize(s)}_increaseFontSize(){this._applyFontSizeOffset(1)}_decreaseFontSize(){this._applyFontSizeOffset(-1)}_clearTmpVariables(){delete this._currentLineString,delete this._currentLineNumber,delete this._buildingString,delete this._pendingString,delete this._buildingBlockComment,delete this._markdownHeader,delete this._lastResult,delete this._scopeStack}async _requestFileAsync(e,t,s=!1){return new Promise((i,o)=>{const n="arraybuffer"===(t=t??"arraybuffer")?"application/octet-stream":void 0;var a=new XMLHttpRequest;return a.open("GET",e,!0),a.responseType=t,n&&a.overrideMimeType(n),s&&a.setRequestHeader("Cache-Control","no-cache"),a.onload=function(){var e=this.response;if(200==this.status)i(e);else{var t="Error "+this.status;o(t)}},a.onerror=function(e){o(e)},a.send(),a})}}const He=Be;if(He.languages={"Plain Text":{ext:"txt",blockComments:!1,singleLineComments:!1,numbers:!1,icon:"AlignLeft fg-neutral-500"},JavaScript:{ext:"js",icon:"Js fg-yellow-500"},TypeScript:{ext:"ts",icon:"Ts fg-blue-600"},C:{ext:["c","h"],usePreprocessor:!0,icon:{c:"C fg-sky-400",h:"C fg-fuchsia-500"}},"C++":{ext:["cpp","hpp"],usePreprocessor:!0,icon:{cpp:"CPlusPlus fg-sky-400",hpp:"CPlusPlus fg-fuchsia-500"}},CSS:{ext:"css",icon:"Hash fg-blue-700"},CMake:{ext:"cmake",singleLineCommentToken:"#",blockComments:!1,ignoreCase:!0},GLSL:{ext:"glsl",usePreprocessor:!0},WGSL:{ext:"wgsl",usePreprocessor:!0},JSON:{ext:"json",blockComments:!1,singleLineComments:!1,icon:"Json fg-yellow-400"},XML:{ext:"xml",tags:!0,icon:"Rss fg-orange-500"},Rust:{ext:"rs",icon:"Rust fg-primary"},Python:{ext:"py",singleLineCommentToken:"#",icon:"Python fg-cyan-600"},HTML:{ext:"html",tags:!0,singleLineComments:!1,blockCommentsTokens:["\x3c!--","--\x3e"],numbers:!1,icon:"Code fg-orange-500"},Batch:{ext:"bat",blockComments:!1,singleLineCommentToken:"::",ignoreCase:!0,icon:"Windows fg-blue-400"},Markdown:{ext:"md",blockComments:!1,singleLineCommentToken:"::",tags:!0,numbers:!1,icon:"Markdown fg-primary"},PHP:{ext:"php",icon:"Php fg-purple-700"}},He.nativeTypes={"C++":["int","float","double","bool","long","short","char","wchar_t","void"],WGSL:["bool","u32","i32","f16","f32","vec2","vec3","vec4","vec2f","vec3f","vec4f","mat2x2f","mat3x3f","mat4x4f","array","vec2u","vec3u","vec4u","ptr","sampler"]},He.declarationKeywords={JavaScript:["var","let","const","this","static","class"],"C++":[...He.nativeTypes["C++"],"const","auto","class","struct","namespace","enum","extern"]},He.keywords={JavaScript:["var","let","const","this","in","of","true","false","new","function","NaN","static","class","constructor","null","typeof","debugger","abstract","arguments","extends","instanceof","Infinity","get"],TypeScript:["var","let","const","this","in","of","true","false","new","function","class","extends","instanceof","Infinity","private","public","protected","interface","enum","type","get"],C:["int","float","double","long","short","char","const","void","true","false","auto","struct","typedef","signed","volatile","unsigned","static","extern","enum","register","union"],"C++":[...He.nativeTypes["C++"],"const","static_cast","dynamic_cast","new","delete","true","false","auto","class","struct","typedef","nullptr","NULL","signed","unsigned","namespace","enum","extern","union","sizeof","static","private","public"],CMake:["cmake_minimum_required","set","not","if","endif","exists","string","strequal","add_definitions","macro","endmacro","file","list","source_group","add_executable","target_include_directories","set_target_properties","set_property","add_compile_options","add_link_options","include_directories","add_library","target_link_libraries","target_link_options","add_subdirectory","add_compile_definitions","project","cache"],JSON:["true","false"],GLSL:["true","false","function","int","float","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","struct"],CSS:["body","html","canvas","div","input","span",".","table","tr","td","th","label","video","img","code","button","select","option","svg","media","all","i","a","li","h1","h2","h3","h4","h5","last-child","tbody","pre","monospace","font-face"],WGSL:[...He.nativeTypes.WGSL,"var","let","true","false","fn","atomic","struct","sampler_comparison","texture_depth_2d","texture_depth_2d_array","texture_depth_cube","texture_depth_cube_array","texture_depth_multisampled_2d","texture_external","texture_1d","texture_2d","texture_2d_array","texture_3d","texture_cube","texture_cube_array","texture_storage_1d","texture_storage_2d","texture_storage_2d_array","texture_storage_3d"],Rust:["as","const","crate","enum","extern","false","fn","impl","in","let","mod","move","mut","pub","ref","self","Self","static","struct","super","trait","true","type","unsafe","use","where","abstract","become","box","final","macro","override","priv","typeof","unsized","virtual"],Python:["False","def","None","True","in","is","and","lambda","nonlocal","not","or"],Batch:["set","echo","off","del","defined","setlocal","enabledelayedexpansion","driverquery","print"],HTML:["html","meta","title","link","script","body","DOCTYPE","head","br","i","a","li","img","tr","td","h1","h2","h3","h4","h5"],Markdown:["br","i","a","li","img","table","title","tr","td","h1","h2","h3","h4","h5"],PHP:["const","function","array","new","int","string","$this","public","null","private","protected","implements","class","use","namespace","abstract","clone","final","enum"]},He.utils={JavaScript:["querySelector","body","addEventListener","removeEventListener","remove","sort","keys","filter","isNaN","parseFloat","parseInt","EPSILON","isFinite","bind","prototype","length","assign","entries","values","concat","substring","substr","splice","slice","buffer","appendChild","createElement","prompt","alert"],WGSL:["textureSample"],Python:["abs","all","any","ascii","bin","bool","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],CSS:[...Object.keys(document.body.style).map(t.toKebabCase),"block","inline","inline-block","flex","grid","none","inherit","initial","unset","revert","sticky","relative","absolute","fixed","static","auto","visible","hidden","scroll","clip","ellipsis","nowrap","wrap","break-word","solid","dashed","dotted","double","groove","ridge","inset","outset","left","right","center","top","bottom","start","end","justify","stretch","space-between","space-around","space-evenly","baseline","middle","normal","bold","lighter","bolder","italic","blur","uppercase","lowercase","capitalize","transparent","currentColor","pointer","default","move","grab","grabbing","not-allowed","none","cover","contain","repeat","no-repeat","repeat-x","repeat-y","round","space","linear-gradient","radial-gradient","conic-gradient","url","calc","min","max","clamp","red","blue","green","black","white","gray","silver","yellow","orange","purple","pink","cyan","magenta","lime","teal","navy","transparent","currentcolor","inherit","initial","unset","revert","none","auto","fit-content","min-content","max-content"]},He.types={JavaScript:["Object","String","Function","Boolean","Symbol","Error","Number","TextEncoder","TextDecoder","Array","ArrayBuffer","InputEvent","MouseEvent","Int8Array","Int16Array","Int32Array","Float32Array","Float64Array","Element"],TypeScript:["arguments","constructor","null","typeof","debugger","abstract","Object","string","String","Function","Boolean","boolean","Error","Number","number","TextEncoder","TextDecoder","Array","ArrayBuffer","InputEvent","MouseEvent","Int8Array","Int16Array","Int32Array","Float32Array","Float64Array","Element","bigint","unknown","any","Record"],Rust:["u128"],Python:["int","type","float","map","list","ArithmeticError","AssertionError","AttributeError","Exception","EOFError","FloatingPointError","GeneratorExit","ImportError","IndentationError","IndexError","KeyError","KeyboardInterrupt","LookupError","MemoryError","NameError","NotImplementedError","OSError","OverflowError","ReferenceError","RuntimeError","StopIteration","SyntaxError","TabError","SystemError","SystemExit","TypeError","UnboundLocalError","UnicodeError","UnicodeEncodeError","UnicodeDecodeError","UnicodeTranslateError","ValueError","ZeroDivisionError"],"C++":["uint8_t","uint16_t","uint32_t"],PHP:["Exception","DateTime","JsonSerializable"]},He.builtIn={JavaScript:["document","console","window","navigator","performance"],CSS:["*","!important"],"C++":["vector","list","map"],WGSL:["@vertex","@fragment"],HTML:["type","xmlns","PUBLIC","http-equiv","src","style","lang","href","rel","content","xml","alt"],Markdown:["type","src","style","lang","href","rel","content","valign","alt"],PHP:["echo","print"]},He.statements={JavaScript:["for","if","else","case","switch","return","while","continue","break","do","import","default","export","from","throw","async","try","catch","await","as"],TypeScript:["for","if","else","case","switch","return","while","continue","break","do","import","default","export","from","throw","async","try","catch","await","as"],CSS:["@","import"],C:["for","if","else","return","continue","break","case","switch","while","using","default","goto","do"],"C++":["std","for","if","else","return","continue","break","case","switch","while","using","glm","spdlog","default"],GLSL:["for","if","else","return","continue","break"],WGSL:["const","for","if","else","return","continue","break","storage","read","read_write","uniform","function","workgroup","bitcast"],Rust:["break","else","continue","for","if","loop","match","return","while","do","yield"],Python:["if","raise","del","import","return","elif","try","else","while","as","except","with","assert","finally","yield","break","for","class","continue","global","pass","from"],Batch:["if","IF","for","FOR","in","IN","do","DO","call","CALL","goto","GOTO","exit","EXIT"],PHP:["declare","enddeclare","foreach","endforeach","if","else","elseif","endif","for","endfor","while","endwhile","switch","case","default","endswitch","return","break","continue","try","catch","die","do","exit","finally"]},He.symbols={JavaScript:["<",">","[","]","{","}","(",")",";","=","|","||","&","&&","?","??"],TypeScript:["<",">","[","]","{","}","(",")",";","=","|","||","&","&&","?","??"],C:["<",">","[","]","{","}","(",")",";","=","|","||","&","&&","?","*","-","+"],"C++":["<",">","[","]","{","}","(",")",";","=","|","||","&","&&","?","::","*","-","+"],CMake:["{","}"],JSON:["[","]","{","}","(",")"],GLSL:["[","]","{","}","(",")"],WGSL:["[","]","{","}","(",")","->"],CSS:["{","}","(",")","*"],Rust:["<",">","[","]","(",")","="],Python:["<",">","[","]","(",")","="],Batch:["[","]","(",")","%"],HTML:["<",">","/"],XML:["<",">","/"],PHP:["[","]","{","}","(",")"]},He.REGISTER_LANGUAGE=function(e,t={},s,i){He.languages[e]=t,s?.keywords&&(He.keywords[e]=new Set(s.keywords)),s?.utils&&(He.utils[e]=new Set(s.utils)),s?.types&&(He.types[e]=new Set(s.types)),s?.builtIn&&(He.builtIn[e]=new Set(s.builtIn)),s?.statements&&(He.statements[e]=new Set(s.statements)),s?.symbols&&(He.symbols[e]=new Set(s.symbols)),i&&(ze[e]=i)},t.CodeEditor=Be,!t)throw"Missing LX namespace!";t.extensions.push("DocMaker");const Fe=["int","float","double","bool","char","wchar_t","const","static_cast","dynamic_cast","new","delete","void","true","false","auto","struct","typedef","nullptr","NULL","unsigned","namespace","auto"],$e=["uint32_t","uint64_t","uint8_t"],Ve=["for","if","else","return","continue","break","case","switch","while","import","from","await"],Ke=["var","let","const","static","function","null","undefined","new","delete","true","false","NaN","this"],Ue=["html","charset","rel","src","href","crossorigin","type","lang"],Ge=["html","DOCTYPE","head","meta","title","link","script","body","style"];class We{root;_listQueued=void 0;constructor(e){this.root=e??document.body}setDomTarget(e){this.root=e}lineBreak(e){(e=e??this.root).appendChild(document.createElement("br"))}header(e,t,s){console.assert(void 0!==e&&void 0!==t);let i=document.createElement(t);i.innerHTML=e,s&&(i.id=s),this.root.appendChild(i)}paragraph(e,t=!1,s){console.assert(void 0!==e);let i=document.createElement(t?"sup":"p");i.className="leading-relaxed "+(s??""),i.innerHTML=e,this.root.appendChild(i)}code(e,s="js"){console.assert(void 0!==e),e.replaceAll("<","<"),e.replaceAll(">",">");let i="",o="";const n=(e,t)=>`<span class="${e}">${t}</span>`;for(let t=0;t<e.length;++t){const a=e[t],l=e.substr(t),r=l.indexOf("\n"),c=l.substring(0,r>-1?r:void 0);if("@"==a){const a=c.substr(1);if(!(a.indexOf("@")>-1||a.indexOf("[")>-1))continue;let l=null;const r=a.indexOf("@"),h="|"==a[r-1];if("["==e[t+1])if(i=a.substr(1,3),o=a.substring(5,r),h){const t=a.substring(6+o.length),s=o,r=t.substring(0,t.indexOf("@"));l=n(i,s.substring(0,s.length-1)+"@"+r);const c=s+"@"+r;e=e.replace(`@[${i}]${c}@`,l)}else l=n(i,o),e=e.replace(`@[${i}]${o}@`,l);else{if(o=a.substring(0,r),h){const s=a.substring(0,a.indexOf("@")-1);o=a.substring(s.length+1),o=s+o.substring(0,o.substring(1).indexOf("@")+1),e=e.substr(0,t)+"@"+o+"@"+e.substr(t+o.length+3)}if("cpp"==s&&Fe.includes(o))i="kwd";else if("js"==s&&Ke.includes(o))i="kwd";else if($e.includes(o))i="cls";else if(Ve.includes(o))i="lit";else if(Ge.includes(o))i="tag";else if(Ue.includes(o))i="atn";else if('"'==o[0]&&'"'==o[o.length-1]||"'"==o[0]&&"'"==o[o.length-1]||"`"==o[0]&&"`"==o[o.length-1])i="str";else{if(Number.isNaN(parseFloat(o)))return void console.error("ERROR[Code Parsing]: Unknown highlight type: "+o);i="dec"}l=n(i,o),e=e.replace(`@${o}@`,l)}t+=l.length-1}}let a=document.createElement("div");a.className="code-container";let l=document.createElement("pre"),r=document.createElement("code");r.innerHTML=e;let c=document.createElement("button");c.title="Copy code sample",c.appendChild(t.makeIcon("Copy")),c.addEventListener("click",this._copySnippet.bind(this,c)),a.appendChild(c),l.appendChild(r),a.appendChild(l),this.root.appendChild(a)}list(e,t,s){console.assert(e&&e.length>0&&["bullet","numbered"].includes(t),"Invalid list type or empty list"+t);const i="bullet"==t?"ul":"ol";let o=document.createElement(i);for(var n of((s=s??this.root).appendChild(o),e)){if(n.constructor===Array)return void this.list(n,t,o);let e=document.createElement("li");e.className="leading-loose",e.innerHTML=n,o.appendChild(e)}}bulletList(e){this.list(e,"bullet")}numberedList(e){this.list(e,"numbered")}startCodeBulletList(){let e=document.createElement("ul");this._listQueued=e}endCodeBulletList(){void 0!==this._listQueued&&(console.assert(void 0!==this._listQueued),this.root.appendChild(this._listQueued),this._listQueued=void 0)}codeListItem(e,t){t=t??this._listQueued;let s=e.constructor===Array;if(s&&e[0].constructor===Array)return void this.codeBulletList(e,t);let i=document.createElement("li");i.className="leading-loose",i.innerHTML=s?2==e.length?this.iCode(e[0])+": "+e[1]:this.iCode(e[0]+" <span class='desc'>("+e[1]+")</span>")+": "+e[2]:this.iCode(e),t?.appendChild(i)}codeBulletList(e,t){console.assert(void 0!==e&&e.length>0);let s=document.createElement("ul");for(var i of e)this.codeListItem(i,s);t?t.appendChild(s):this.root.appendChild(s)}image(e,t="",s){let i=document.createElement("img");i.src=e,i.alt=t,i.className="my-1",(s=s??this.root).appendChild(i)}images(e,t=[],s,i){if(navigator&&/Android|iPhone/i.test(navigator.userAgent))for(let s=0;s<e.length;++s)this.image(e[s],t[s]);else{let o=document.createElement("div");o.style.width=s??"auto",o.style.height=i??"256px",o.className="flex flex-row justify-center";for(let s=0;s<e.length;++s)this.image(e[s],t[s],o);this.root.appendChild(o)}}video(e,t="",s=!0,i=!1){let o=document.createElement("video");o.src=e,o.controls=s,o.autoplay=i,i&&(o.muted=!0),o.loop=!0,o.alt=t,this.root.appendChild(o)}note(e,s=!1,i,o){console.assert(void 0!==e);const n=t.makeContainer([],"border rounded-lg overflow-hidden text-md fg-secondary my-6","",this.root);let a=document.createElement("div");a.className="flex bg-tertiary font-semibold px-3 py-2 gap-2 fg-secondary",a.appendChild(t.makeIcon(o??(s?"MessageSquareWarning":"NotepadText"))),a.innerHTML+=i??(s?"Important":"Note"),n.appendChild(a),t.makeContainer([],"leading-6 p-3",e,n)}classCtor(e,t,s="js"){let i="";for(var o of t){const e=o[0],n=o[1];"cpp"==s?i+=e+(n?" = <span class='desc'>"+n+"</span>":"")+(t.indexOf(o)!=t.length-1?", ":""):"js"==s&&(i+=e+": <span class='desc'>"+n+"</span>"+(t.indexOf(o)!=t.length-1?", ":""))}let n=document.createElement("p");n.innerHTML=this.iCode("<span class='constructor'>"+e+"("+i+")</span>"),this.root.appendChild(n)}classMethod(e,t,s,i){this.startCodeBulletList();let o="";for(var n of s){o+=n[0]+": <span class='desc'>"+n[1]+"</span>"+(s.indexOf(n)!=s.length-1?", ":"")}let a=document.createElement("li");return a.innerHTML=this.iCode("<span class='method'>"+e+" ("+o+")"+(i?": "+i:"")+"</span>"),this._listQueued?.appendChild(a),this.endCodeBulletList(),this.paragraph(t),a.parentElement}iLink(e,t){return console.assert(void 0!==e&&void 0!==t),`<a href="${t}">${e}</a>`}iPage(e,t){console.assert(void 0!==e&&void 0!==t);const s=t.replace(".html",""),i=globalThis;if(i.setPath&&i.loadPage){return`<a onclick="loadPage('${t}', true, '${i.setPath(s)}')">${e}</a>`}console.warn("[DocMaker] Create globalThis.setPath and globalThis.loadPage to use inline pages!")}iCode(e,t){return console.assert(void 0!==e),`<code class="inline ${t??""}">${e}</code>`}_copySnippet(e){e.innerHTML="",e.appendChild(t.makeIcon("Check")),e.classList.add("copied"),setTimeout(()=>{e.innerHTML="",e.appendChild(t.makeIcon("Copy")),e.classList.remove("copied")},2e3),navigator.clipboard.writeText(e.dataset.snippet??e.parentElement.innerText),console.log("Copied!")}}if(!t)throw"Missing LX namespace!";t.extensions.push("GraphEditor");const qe=globalThis,Ye=t.vec2,Xe=t.Area;t.Panel,t.Sidebar,t.ContextMenu;const je=t.PocketDialog;class Ze{origin;size;constructor(e,t){this.origin=e??new Ye(0,0),this.size=t??new Ye(0,0)}merge(e){console.assert(e.constructor==Ze);const t=this.origin,s=this.origin.add(this.size),i=e.origin,o=e.origin.add(e.size),n=new Ye(Math.min(t.x,i.x),Math.min(t.y,i.y)),a=new Ye(Math.max(s.x,o.x),Math.max(s.y,o.y));this.origin=n,this.size=a.sub(n)}inside(e,t=!0){const s=this.origin,i=this.origin.add(this.size),o=e.origin,n=e.origin.add(e.size);return t?o.x>=s.x&&n.x<=i.x&&o.y>=s.y&&n.y<=i.y:n.x>=s.x&&o.x<=i.x&&n.y>=s.y&&o.y<=i.y}}class Je{static __instances=[];static MIN_SCALE=.25;static MAX_SCALE=4;static EVENT_MOUSEMOVE=0;static EVENT_MOUSEWHEEL=1;static LAST_GROUP_ID=0;static LAST_FUNCTION_ID=0;static STOPPED=0;static RUNNING=1;static NODE_IO_INPUT=0;static NODE_IO_OUTPUT=1;static NODE_TYPES={};static onCustomNodeRegistered=()=>{};static onNodeTypeReplaced=()=>{};root;area;propertiesDialog;currentGraph=null;keys={};graphs={};nodes={};variables={};groups={};supportedCastTypes={};selectedNodes=[];main="";mustStop=!1;state=Je.STOPPED;isFocused=!1;_graphContainer;_sidebarDom;_sidebarActive=!0;_sidebar;_domLinks;_domNodes;_mousePosition=new Ye(0,0);_deltaMousePosition=new Ye(0,0);_snappedDeltaMousePosition=new Ye(0,0);_lastMousePosition=new Ye(0,0);_lastSnappedMousePosition=new Ye(0,0);_generatingLink;_snapToGrid=!1;_snapValue=1;_nodeBackgroundOpacity=.8;_patternSizeF=15;_patternSize=new Ye(this._patternSizeF);_circlePatternSize=.04*this._patternSizeF;_circlePatternColor="#71717a9c";_background;_undoSteps=[];_redoSteps=[];_clipboardData;_lastMouseDown=0;_boxSelecting;_boxSelectRemoving;_currentBoxSelectionSVG;constructor(e,s={}){Je.__instances.push(this),this._sidebar=e.addSidebar(e=>{},{displaySelected:!0,headerIcon:"EllipsisVertical",headerTitle:"Create",headerSubtitle:"Press to rename",onHeaderPressed:()=>this._showRenameGraphDialog(),footerIcon:"Plus",footerTitle:"Create",footerSubtitle:"Graph or Function",onFooterPressed:e=>this._onSidebarCreate(e)}),this.area=new Xe({className:"lexgraph"}),e.root.classList.add("grapharea"),this.root=this.area.root,this.root.tabIndex=-1,e.attach(this.root),this._graphContainer=e.sections[1].root,this._sidebarDom=e.sections[0].root,this._sidebarActive=s.sidebar??this._sidebarActive,t.doAsync(()=>{this._sidebar.toggleCollapsed(!this._sidebarActive)},50),e.onresize=e=>{},e.addOverlayButtons([[{name:"Start Graph",icon:"Play@solid",callback:()=>this.start(),selectable:!0},{name:"Stop Graph",icon:"Stop@solid",callback:()=>this.stop(),selectable:!0}],[{name:"Enable Snapping",icon:"Frame",callback:()=>this._toggleSnapping(),selectable:!0},{name:1,options:[1,2,3],callback:e=>this._setSnappingValue(e)}],[{name:"Import",icon:"Upload",callback:()=>{this.loadGraph("../../data/graph_sample.json")}},{name:"Export",icon:"ArrowRightFromLine",callback:()=>this.currentGraph?.export()}]],{float:"htc"}),this.root.addEventListener("keydown",this._processKeyDown.bind(this),!0),this.root.addEventListener("keyup",this._processKeyUp.bind(this),!0),this.root.addEventListener("mousedown",this._processMouse.bind(this)),this.root.addEventListener("mouseup",this._processMouse.bind(this)),this.root.addEventListener("mousemove",this._processMouse.bind(this)),this.root.addEventListener("mousewheel",this._processMouse.bind(this)),this.root.addEventListener("mouseleave",this._processMouse.bind(this)),this.root.addEventListener("click",this._processMouse.bind(this)),this.root.addEventListener("contextmenu",this._processMouse.bind(this)),this.root.addEventListener("focus",this._processFocus.bind(this,!0)),this.root.addEventListener("focusout",this._processFocus.bind(this,!1)),this.propertiesDialog=new je("Properties",null,{size:["350px",null],position:["8px","8px"],float:"left",class:"lexgraphpropdialog"}),this.propertiesDialog.root.addEventListener("mousedown",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),this.propertiesDialog.root.addEventListener("mouseup",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),this.root.appendChild(this.propertiesDialog.root),this.addCastType("float","vec2",e=>[e,e]),this.addCastType("float","vec3",e=>[e,e,e]),this.addCastType("float","vec4",e=>[e,e,e,e]),this.addCastType("float","bool",e=>!!e),this.addCastType("vec4","vec3",e=>(e.slice(0,3),e)),this.addCastType("vec4","vec2",e=>(e.slice(0,2),e)),this.addCastType("vec3","vec2",e=>(e.slice(0,2),e)),this.addCastType("vec3","vec4",e=>(e.push(1),e)),this.addCastType("vec2","vec3",e=>(e.push(1),e)),this.addCastType("vec2","vec4",e=>(e.push(0,1),e)),this._nodeBackgroundOpacity=s.disableNodeOpacity?1:this._nodeBackgroundOpacity,this._generatePattern(),this._domLinks=document.createElement("div"),this._domLinks.classList.add("lexgraphlinks"),this.root.appendChild(this._domLinks),this._domNodes=document.createElement("div"),this._domNodes.classList.add("lexgraphnodes"),this.root.appendChild(this._domNodes),qe.ge=this}static getInstances(){return Je.__instances}static registerCustomNode(e,t){if(!t.prototype)throw"Cannot register a simple object, it must be a class with a prototype!";const s=e.lastIndexOf("/");t.category=e.substring(0,s),t.title=t.title??e.substring(s+1),t.type=e,t.prototype.onExecute||console.warn(`GraphNode [${t.title}] does not have a callback attached.`);const i=Je.NODE_TYPES[e];i&&console.warn(`Replacing node type [${e}]`),Je.NODE_TYPES[e]=t,Je.onCustomNodeRegistered&&Je.onCustomNodeRegistered(e,t),i&&Je.onNodeTypeReplaced&&Je.onNodeTypeReplaced(e,t,i)}static addNode(e,t,s={}){var i=Je.NODE_TYPES[e];if(!i)return console.warn(`GraphNode type [${e}] not registered.`),null;const o=new i(t=t??i.title);if(o.onCreate&&o.onCreate(),o.type=e,o.title=t,o.position=new Ye(0,0),o.color=null,"NodeFunction"==i.name&&(o.gid=i.gid),s)for(var n in s)o[n]=s[n];return o.onNodeCreated&&o.onNodeCreated(),o}setGraph(e){if(!this.currentGraph||e.id!=this.currentGraph.id)if(this.clear(),e.id=e.id??e.constructor.name+"-"+t.guidGenerator(),this.graphs[e.id]=e,e.nodes){this.currentGraph=e,this._updatePattern();for(let t of e.nodes)this._createNodeDOM(t);for(let t of e.groups){const e=this._createGroup(t);e.querySelector(".lexgraphgrouptitle").value=t.name,this._domNodes.prepend(e)}for(let t in e.links){const s=e.links[t];for(let e of s)this._createLink(e)}this._updateGraphName(e.name),this._togglePropertiesDialog(!1)}else console.warn("Graph does not contain any node!")}loadGraph(e,s){t.requestJSON(e,e=>{let t="Graph"==e.type?this.addGraph(e):this.addGraphFunction(e);s&&s(t)},e=>console.error(e))}addGraph(e){let t=new Qe;if(t.editor=this,e){for(let t of e.functions??[])this.addGraphFunction(t);t.configure(e)}return this.setGraph(t),this._sidebar.add(t.name,{icon:"CircleNodes",className:t.id,callback:()=>{this.setGraph(t)}}),this._sidebar.update(),this._sidebar.select(t.name),t}addGraphFunction(e){let t=new tt;if(t.editor=this,e){for(let t of e.functions??[])this.addGraphFunction(t);t.configure(e)}this.setGraph(t);class s extends et{static func;static gid;onCreate(){this.addInput(null,"float"),this.addOutput(null,"any")}onExecute(){const e=s.func.getOutputData(this.getInput(0));this.setOutput(0,e)}}return s.func=t,s.gid=t.id,Je.registerCustomNode("function/"+t.name,s),this._sidebar.add(t.name,{icon:"Function",className:t.id,callback:()=>{this.setGraph(t)}}),this._sidebar.update(),this._sidebar.select(t.name),t}clear(){this._domNodes.innerHTML="",this._domLinks.innerHTML="",this.nodes={}}setVariable(e,t){this.variables[e]=t}getVariable(e){return this.variables[e]}propagateEventToAllNodes(e,t){if(!this.currentGraph)return;const s=this.currentGraph.nodes;for(let i of s)i[e]&&i[e].apply(this,t)}addCastType(e,t,s){this.supportedCastTypes[e+"@"+t]=s}unSelectAll(e=!1){this._domNodes.querySelectorAll(".lexgraphnode").forEach(e=>e.classList.remove("selected")),this.selectedNodes.length=0,e||this._togglePropertiesDialog(!1)}_createNodeDOM(e){e.editor=this,e.graphID=this.currentGraph?.id;var s,i=document.createElement("div");if(i.classList.add("lexgraphnode"),i.style.left="0",i.style.top="0",this._translateNode(i,e.position),e.type&&Je.NODE_TYPES[e.type]){const t=e.constructor.category;i.classList.add(t)}else{const t=e.type.lastIndexOf("/"),s=e.type.substring(0,t);i.classList.add(s)}(s=e.color??s)&&(s.constructor==Array?s=s.join(","):(s=t.hexToRgb(s)).forEach((e,t)=>s[t]=255*e),i.style.backgroundColor="rgba("+s+", "+this._nodeBackgroundOpacity+")"),i.addEventListener("mousedown",e=>{e.button==t.MOUSE_LEFT_CLICK&&(e.altKey?this._unSelectNode(i):(this.selectedNodes.length>1&&!e.ctrlKey&&!e.shiftKey&&this.unSelectAll(!0),i.classList.contains("selected")||this._selectNode(i,e.ctrlKey||e.shiftKey)))}),i.addEventListener("contextmenu",s=>{s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),t.addContextMenu(null,s,t=>{t.add("Copy",()=>{this._clipboardData={id:e.id,gid:this.currentGraph?.id}}),t.add(""),t.add("Delete",()=>{this._deleteNode(i.dataset.id)})})}),i.addEventListener("dblclick",s=>{s.button==t.MOUSE_LEFT_CLICK&&e.constructor.func&&this._sidebar.select(e.constructor.func.name)});var o=document.createElement("div");o.classList.add("lexgraphnodeheader"),o.innerText=e.title,i.appendChild(o);var n=document.createElement("div");n.classList.add("lexgraphnodeios"),i.appendChild(n);const a=e.inputs&&e.inputs.length,l=e.outputs&&e.outputs.length;if(a){const t=document.createElement("div");t.classList.add("lexgraphnodeinputs"),t.style.width=l?"50%":"100%",n.appendChild(t);for(let s of e.inputs)if(s.type){var r=document.createElement("div");if(r.className="lexgraphnodeio ioinput",r.dataset.index=t.childElementCount.toString(),(h=document.createElement("span")).className="io__type input "+s.type,h.dataset.type=s.type,h.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",r.appendChild(h),(d=document.createElement("span")).className="io__typedesc input "+s.type,d.innerHTML=s.type,r.appendChild(d),s.name)(c=document.createElement("span")).classList.add("io__name"),c.innerText=s.name,r.appendChild(c);t.appendChild(r)}else console.warn(`Missing type for node [${e.title}], skipping...`)}if(l){const t=document.createElement("div");t.classList.add("lexgraphnodeoutputs"),t.style.width=a?"50%":"100%",n.appendChild(t);for(let s of e.outputs){s.type||console.warn(`Missing type for node [${e.title}], skipping...`);var c,h,d,u=document.createElement("div");if(u.className="lexgraphnodeio iooutput",u.dataset.index=t.childElementCount.toString(),s.name)(c=document.createElement("span")).classList.add("io__name"),c.innerText=s.name,u.appendChild(c);(h=document.createElement("span")).className="io__type output "+s.type,h.dataset.type=s.type,h.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",u.appendChild(h),(d=document.createElement("span")).className="io__typedesc output "+s.type,d.innerHTML=s.type,u.appendChild(d),t.appendChild(u)}}t.makeDraggable(i,{onMove:this._onMoveNodes.bind(this),onDragStart:this._onDragNode.bind(this)}),this._addNodeIOEvents(i);const p=e.id??e.title.toLowerCase().replaceAll(/\s/g,"-")+"-"+t.guidGenerator();return this.nodes[p]={data:e,dom:i},e.id=p,i.dataset.id=p,this._domNodes.appendChild(i),"Main"==e.title&&(this.main=p),e.size=new Ye(i.offsetWidth,i.offsetHeight),e.resizeObserver=new ResizeObserver(t=>{for(const s of t){const t=s.contentRect;t.width&&t.height&&(e.size=new Ye(i.offsetWidth,i.offsetHeight))}}),e.resizeObserver.observe(i),i}_updateNodeDOMIOs(e,t){var s=e.querySelector(".lexgraphnodeios");const i=t.inputs&&t.inputs.length,o=t.outputs&&t.outputs.length;if(i){const e=s?.querySelector(".lexgraphnodeinputs");e.innerHTML="";for(let s of t.inputs)if(s.type){var n=document.createElement("div");if(n.className="lexgraphnodeio ioinput",n.dataset.index=e.childElementCount.toString(),(l=document.createElement("span")).className="io__type input "+s.type,l.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",n.appendChild(l),(r=document.createElement("span")).className="io__typedesc input "+s.type,r.innerHTML=s.type,n.appendChild(r),s.name)(a=document.createElement("span")).classList.add("io__name"),a.innerText=s.name,n.appendChild(a);e.appendChild(n)}else console.warn(`Missing type for node [${t.constructor.name}], skipping...`)}if(o){const e=s?.querySelector(".lexgraphnodeoutputs");e.innerHTML="";for(let s of t.outputs){s.type||console.warn(`Missing type for node [${t.constructor.name}], skipping...`);var a,l,r,c=document.createElement("div");if(c.className="lexgraphnodeio iooutput",c.dataset.index=e.childElementCount.toString(),s.name)(a=document.createElement("span")).classList.add("io__name"),a.innerText=s.name,c.appendChild(a);(l=document.createElement("span")).className="io__type output "+s.type,l.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",c.appendChild(l),(r=document.createElement("span")).className="io__typedesc output "+s.type,r.innerHTML=s.type,c.appendChild(r),e.appendChild(c)}}this._addNodeIOEvents(e)}_addNodeIOEvents(e){const s=e.querySelector(".lexgraphnodeios");s?.querySelectorAll(".lexgraphnodeio").forEach(s=>{s.addEventListener("mousedown",i=>{i.button==t.MOUSE_LEFT_CLICK&&(this._lastMouseDown=t.getTime(),this._generatingLink={index:parseInt(s.dataset.index),io:s,ioType:s.classList.contains("ioinput")?Je.NODE_IO_INPUT:Je.NODE_IO_OUTPUT,domEl:e},i.stopPropagation(),i.stopImmediatePropagation())}),s.addEventListener("mouseup",e=>{e.stopPropagation(),e.stopImmediatePropagation(),t.getTime()-this._lastMouseDown<200?delete this._generatingLink:this._generatingLink&&(this._onLink(e)||t.deleteElement(this._generatingLink.path?this._generatingLink.path.parentElement:null),delete this._generatingLink)}),s.addEventListener("click",t=>{if(!s.links)return;const i=e.dataset.id;this._deleteLinks(i,s)})})}_getAllDOMNodes(e=!1,t){var s=null;return s=e?Array.from(this._domNodes.childNodes):Array.from(this._domNodes.childNodes).filter(e=>e.classList.contains("lexgraphnode")),t&&(s=s.filter(e=>e!=t)),s}_onMoveNodes(e){let t=this._snapToGrid?this._snappedDeltaMousePosition:this._deltaMousePosition;t.div(this.currentGraph?.scale,t);for(let e of this.selectedNodes){const s=this._getNodeDOMElement(e);this._translateNode(s,t),this._updateNodeLinks(e)}}_onDragNode(e,t){t.shiftKey&&this._cloneNodes()}_onMoveGroup(e){const t=e.nodes;if(!t)return;let s=this._snapToGrid?this._snappedDeltaMousePosition:this._deltaMousePosition;s.div(this.currentGraph?.scale,s),this._translateNode(e,s);for(let e of t){const t=e.constructor!==String,i=t?e:this._getNodeDOMElement(e);this._translateNode(i,s,!t),t||this._updateNodeLinks(e)}}_onDragGroup(e){const t=this._getBoundingFromGroup(e),s=[];for(let i of this._getAllDOMNodes(!0,e)){const e=parseFloat(i.style.left),o=parseFloat(i.style.top),n=new Ze(new Ye(e,o),new Ye(i.offsetWidth-6,i.offsetHeight-6));t.inside(n)&&s.push(i.dataset.id??i)}e.nodes=s}_selectNode(e,t=!1,s=!0){t||this.unSelectAll(!0),e.classList.add("selected");const i=e.dataset.id;this.selectedNodes.push(i),s&&this._domNodes.appendChild(e);const o=this.nodes[i].data;this.propertiesDialog.setTitle(o.title);var n=this.propertiesDialog.panel;n.clear(),o.constructor.description&&n.addText(null,o.constructor.description,null,{disabled:!0}),"inputs"==o.constructor.category&&n.addText("Name",o.title,t=>{o.title=t;e.querySelector(".lexgraphnodeheader").innerText=t});for(let t of o.properties)switch(t.type){case"float":case"int":n.addNumber(t.name,t.value,e=>{t.value=e});break;case"string":n.addText(t.name,t.value,e=>{t.value=e});break;case"vec2":n.addVector2(t.name,t.value,e=>{t.value=e});break;case"vec3":n.addVector3(t.name,t.value,e=>{t.value=e});break;case"vec4":n.addVector4(t.name,t.value,e=>{t.value=e});break;case"select":n.addSelect(t.name,t.options,t.value,e=>{t.value=e});break;case"array":n.addArray(t.name,t.value,s=>{t.value=s,"function/Input"==o.type&&(o.setOutputs(s),this._updateNodeDOMIOs(e,o))},{innerValues:t.options})}this._togglePropertiesDialog(!0)}_unSelectNode(e){e.classList.remove("selected");const t=this.selectedNodes.indexOf(e.dataset.id);this.selectedNodes.splice(t,1),this.selectedNodes.length||this._togglePropertiesDialog(!1)}_translateNode(e,t,s=!0){const i=t.add(new Ye(parseFloat(e.style.left),parseFloat(e.style.top)));if(this._snapToGrid&&e.mustSnap){const t=this._patternSize.x*this._snapValue*this._snapValue;i.x=Math.floor(i.x/t)*t,i.y=Math.floor(i.y/t)*t,e.mustSnap=!1}if(e.style.left=i.x+"px",e.style.top=i.y+"px",s&&e.dataset.id){this.nodes[e.dataset.id].data.position=i}}_deleteNode(e){if(!this.currentGraph)return;const s=this.nodes[e],i=s.data,o=s.dom;if(console.assert(o),i.constructor.blockDelete)return void console.warn("Can't delete node!");t.deleteElement(o),delete this.nodes[e];const n=this.currentGraph.nodes.findIndex(t=>t.id===e);console.assert(n>=0),this.currentGraph.nodes.splice(n,1);for(let s in this.currentGraph.links){if(!s.includes(e))continue;const i=s.indexOf("@"),o=s.substring(i+1)!=e,n=this.currentGraph.links[s].length;for(var a=0;a<n;++a){var l=this.currentGraph.links[s][a];t.deleteElement(l.path.parentElement);const i=o?l.inputNode:l.outputNode,n=this._getNodeDOMElement(i).querySelector(o?".lexgraphnodeinputs":".lexgraphnodeoutputs").childNodes[o?l.inputIdx:l.outputIdx],d=o?l.outputIdx:l.inputIdx,u=n.links[d].indexOf(e);if(n.links[d].splice(u,1),o)delete n.dataset.active;else{var r=!1;for(var c of n.links)if(c)for(var h of c)r=r||!!h;r||delete n.dataset.active}}delete this.currentGraph.links[s]}}_deleteGroup(e){if(!this.currentGraph)return;const s=this.groups[e];t.deleteElement(s),delete this.groups[e];const i=this.currentGraph.groups.findIndex(t=>t.id===e);console.assert(i>=0),this.currentGraph.groups.splice(i,1)}_cloneNode(e,s,i){if(!this.currentGraph)return;const o=this.graphs[s??this.currentGraph.id].getNodeById(e);if(!o)return;const n=this._getNodeDOMElement(e),a=Je.addNode(o.type);a.properties=t.deepCopy(o.properties);const l=this._createNodeDOM(a);this._translateNode(l,i??this._getNodePosition(n)),this._selectNode(l,!0),this.currentGraph.nodes.push(a)}_cloneNodes(){const e=t.deepCopy(this.selectedNodes);this.unSelectAll();for(let t of e)this._cloneNode(t)}_getNodePosition(e){return new Ye(parseFloat(e.style.left),parseFloat(e.style.top))}_getNodeDOMElement(e){return this.nodes[e]?this.nodes[e].dom:null}_getLinks(e,t){const s=e+"@"+t;return this.currentGraph?.links[s]}_deleteLinks(e,s){const i=s.classList.contains("ioinput"),o=parseInt(s.dataset.index);if(i){let i=-1;const r=s.links.filter((e,t)=>(i=t,void 0!==e))[0][0];if(!r)return;var n=(l=this._getLinks(r,e)).findIndex(e=>e.inputIdx==o&&e.outputIdx==i);t.deleteElement(l[n].path.parentElement),l.splice(n,1),delete s.links,delete s.dataset.active;const c=this._getNodeDOMElement(r).querySelector(".lexgraphnodeoutputs").childNodes[i],h=c.links[o].findIndex(t=>t==e);c.links[o].splice(h,1);let d=!1;for(var a of c.links)a&&(d=d||a.reduce(e=>void 0!==e,0));d||(delete c.links,delete c.dataset.active)}else{const i=s.links.length;for(let a=0;a<i;++a){const i=s.links[a];if(i)for(let r=i.length-1;r>=0;--r){const c=i[r];var l;n=(l=this._getLinks(e,c)).findIndex(e=>e.inputIdx==a&&e.outputIdx==o);t.deleteElement(l[n].path.parentElement),l.splice(n,1),s.links[a].splice(r,1);const h=this._getNodeDOMElement(c).querySelector(".lexgraphnodeinputs").childNodes[a];delete h.links,delete h.dataset.active}}delete s.links,delete s.dataset.active}}_processFocus(e=!1){this.isFocused=e}_processKeyDown(e){if(document.activeElement!=this.root)return;const t=e.detail;var s=e.key??t.key;switch(s){case"Escape":this.unSelectAll();break;case"Delete":case"Backspace":e.preventDefault(),this._deleteSelection(e);break;case"g":e.ctrlKey&&(e.preventDefault(),this._createGroup());break;case"y":e.ctrlKey&&(e.preventDefault(),this._doRedo());break;case"z":e.ctrlKey&&(e.preventDefault(),this._doUndo())}this.keys[s]=!0}_processKeyUp(e){if(document.activeElement!=this.root)return;const t=e.detail,s=e.key??t.key;delete this.keys[s]}_processMouse(e){if(!this.currentGraph)return;const s=this.root.getBoundingClientRect();this._mousePosition=new Ye(e.clientX-s.x,e.clientY-s.y);const i=new Ye(this._mousePosition.x,this._mousePosition.y);if(this._snapToGrid){const e=this._patternSize.x*this._snapValue*this.currentGraph.scale;i.x=Math.floor(i.x/e)*e,i.y=Math.floor(i.y/e)*e,this._snappedDeltaMousePosition=i.sub(this._lastSnappedMousePosition)}if(this._deltaMousePosition=this._mousePosition.sub(this._lastMousePosition),"mousedown"==e.type)this._lastMouseDown=t.getTime(),this._processMouseDown(e);else if("mouseup"==e.type)t.getTime()-this._lastMouseDown<200&&this._processClick(e),this._processMouseUp(e);else if("mousemove"==e.type)this._processMouseMove(e);else if("click"==e.type)switch(e.detail){case t.MOUSE_DOUBLE_CLICK:case t.MOUSE_TRIPLE_CLICK:}else"mousewheel"==e.type?(e.preventDefault(),this._processWheel(e)):"contextmenu"==e.type?(e.preventDefault(),t.getTime()-this._lastMouseDown<300&&this._processContextMenu(e)):"mouseleave"==e.type&&this._generatingLink&&this._processMouseUp(e);this._snapToGrid&&(this._lastSnappedMousePosition=i),this._lastMousePosition=this._mousePosition}_processClick(e){const t=e.target;(t.classList.contains("lexgraphnodes")||t.classList.contains("lexgraphgroup"))&&this._processBackgroundClick(e)}_processBackgroundClick(e){this.unSelectAll()}_processMouseDown(e){const s=e.target;s.classList.contains("lexgraphnode")||s.classList.contains("lexgraphgroup")||e.button!=t.MOUSE_LEFT_CLICK||(this._boxSelecting=this._mousePosition,this._boxSelectRemoving=e.altKey)}_processMouseUp(e){if(this._generatingLink){const s=Object.assign({},this._generatingLink);t.deleteElement(this._generatingLink.path?this._generatingLink.path.parentElement:null),delete this._generatingLink,this._processContextMenu(e,s)}else this._boxSelecting&&(e.ctrlKey||e.altKey||this.unSelectAll(),this._selectNodesInBox(this._boxSelecting,this._mousePosition,e.altKey),t.deleteElement(this._currentBoxSelectionSVG),delete this._currentBoxSelectionSVG,delete this._boxSelecting,delete this._boxSelectRemoving)}_processMouseMove(e){if(!this.currentGraph)return;if(3==e.which)return this.currentGraph.translation.add(this._deltaMousePosition.div(this.currentGraph.scale),this.currentGraph.translation),void this._updatePattern();this._generatingLink?this._updatePreviewLink(e):this._boxSelecting&&this._drawBoxSelection(e)}_processWheel(e){if(this._boxSelecting||!this.currentGraph)return;const s=this.root.getBoundingClientRect(),i=this._mousePosition??new Ye(.5*s.width,.5*s.height),o=this._getPatternPosition(i),n=e.deltaY;this.currentGraph.scale*=n>0?.9:1/.9,this.currentGraph.scale=t.clamp(this.currentGraph.scale,Je.MIN_SCALE,Je.MAX_SCALE);const a=this._getPatternPosition(i).sub(o);this.currentGraph.translation.add(a,this.currentGraph.translation),this._updatePattern()}_processContextMenu(e,s){this.currentGraph&&t.addContextMenu(null,e,t=>{var i=null;if(e){const t=this.root.getBoundingClientRect(),s=new Ye(e.clientX-t.x,e.clientY-t.y);i=this._getPatternPosition(s)}this._clipboardData&&(t.add("Paste",()=>{const e=this._clipboardData.id,t=this._clipboardData.gid;this._cloneNode(e,t,i)}),t.add(""));for(let e in Je.NODE_TYPES){Je.NODE_TYPES[e].blockAdd||t.add(e,()=>{const t=Je.addNode(e),o=this._createNodeDOM(t);if(this._snapToGrid&&(o.mustSnap=!0),i&&this._translateNode(o,i),this.currentGraph?.nodes.push(t),s&&t.inputs.length){const e=s.domEl.dataset.id,i=s.io.childNodes[s.index].dataset.type,o=s.ioType==Je.NODE_IO_INPUT,n={inputNode:o?e:t.id,inputIdx:o?s.index:0,inputType:o?i:t.inputs[0].type,outputNode:o?t.id:e,outputIdx:o?0:s.index,outputType:o?t.inputs[0].type:i},a=n.outputNode+"@"+n.inputNode;this.currentGraph?.links[a]||(this.currentGraph.links[a]=[]),this.currentGraph?.links[a].push(n),this._createLink(n)}})}})}start(){this.mustStop=!1,this.state=Je.RUNNING,this.propagateEventToAllNodes("onStart"),requestAnimationFrame(this._frame.bind(this))}stop(){this.mustStop=!0,this.state=Je.STOPPED,this.propagateEventToAllNodes("onStop")}_frame(){!this.mustStop&&this.currentGraph&&(requestAnimationFrame(this._frame.bind(this)),this.currentGraph._runStep(this.main))}_generatePattern(){var e=document.createElementNS("http://www.w3.org/2000/svg","pattern");e.setAttribute("id","pattern-0"),e.setAttribute("x","0"),e.setAttribute("y","0"),e.setAttribute("width",this._patternSize.x.toString()),e.setAttribute("height",this._patternSize.y.toString()),e.setAttribute("patternUnits","userSpaceOnUse");var t=document.createElementNS("http://www.w3.org/2000/svg","circle");t.setAttribute("cx",this._circlePatternSize.toString()),t.setAttribute("cy",this._circlePatternSize.toString()),t.setAttribute("r",this._circlePatternSize.toString()),t.setAttribute("fill",this._circlePatternColor),e.appendChild(t);var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.classList.add("background-svg"),s.style.width="100%",s.style.height="100%",s.style.stroke="none",s.appendChild(e);var i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("width","100%"),i.setAttribute("height","100%"),i.setAttribute("fill","url(#pattern-0)"),s.appendChild(i),this._background=s,this.root.appendChild(this._background)}_updatePattern(){if(!this._background||!this.currentGraph)return;const e=this._patternSize.mul(this.currentGraph.scale),t=this._circlePatternSize*this.currentGraph.scale,s=this.currentGraph.translation.mul(this.currentGraph.scale);let i=this._background.querySelector("pattern");i.setAttribute("x",s.x.toString()),i.setAttribute("y",s.y.toString()),i.setAttribute("width",e.x.toString()),i.setAttribute("height",e.y.toString());var o=this._background.querySelector("circle");o.setAttribute("cx",t.toString()),o.setAttribute("cy",t.toString()),o.setAttribute("r",t.toString());const n=.5*this._domNodes.offsetWidth,a=.5*this._domNodes.offsetHeight,l=n-n*this.currentGraph.scale,r=a-a*this.currentGraph.scale;this._domNodes.style.transform="\n translate("+(s.x-l)+"px, "+(s.y-r)+"px)\n scale("+this.currentGraph.scale+")\n ",this._domLinks.style.transform=this._domNodes.style.transform;const c=this._getNonVisibleNodes();for(let e of c){this._getNodeDOMElement(e.id).classList.toggle("hidden-opacity",!0)}}_getPatternPosition(e){if(this.currentGraph)return e.div(this.currentGraph.scale).sub(this.currentGraph.translation)}_getRenderPosition(e){if(this.currentGraph)return e.add(this.currentGraph.translation).mul(this.currentGraph.scale)}_onLink(e){if(!this.currentGraph)return;const t=this._generatingLink,s=e.target.classList.contains("input")?Je.NODE_IO_INPUT:Je.NODE_IO_OUTPUT;if(t.ioType==s)return void console.warn("Can't link same type of data");const i=t.domEl.dataset.id,o=this.nodes[i].data,n=this._generatingLink.index,a=e.target.offsetParent.dataset.id,l=this.nodes[a].data,r=parseInt(e.target.parentElement.dataset.index),c=t.ioType==Je.NODE_IO_INPUT,h=o[c?"inputs":"outputs"][n].type,d=l[s==Je.NODE_IO_INPUT?"inputs":"outputs"][r].type;if(h!=d&&"any"!=h&&"any"!=d){const e=c?h:d,t=c?d:h;if(!this.supportedCastTypes[t+"@"+e])return void console.warn(`Can't link ${h} to ${d}.`)}s==Je.NODE_IO_INPUT&&e.target.parentElement.dataset.active?this._deleteLinks(a,e.target.parentElement):t.ioType==Je.NODE_IO_INPUT&&t.io.dataset.active&&this._deleteLinks(i,t.io);var u=t.io;u.links=u.links??[],u.links[r]=u.links[r]??[],u.links[r].push(a);var p=e.target.parentElement;p.links=p.links??[],p.links[n]=p.links[n]??[],p.links[n].push(i);let m=this._updatePreviewLink(null,e.target.parentElement);const g=(c?a:i)+"@"+(c?i:a);return this.currentGraph.links[g]||(this.currentGraph.links[g]=[]),this.currentGraph.links[g].push({path:m,inputNode:c?i:a,inputIdx:c?n:r,inputType:c?h:d,outputNode:c?a:i,outputIdx:c?r:n,outputType:c?d:h}),m.dataset.id=g,t.io.dataset.active=!0,e.target.parentElement.dataset.active=!0,!0}_updatePreviewLink(e,s){var i=this._generatingLink.path;if(!i){var o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.classList.add("link-svg"),o.style.width="100%",o.style.height="100%",this._domLinks.appendChild(o),(i=document.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("fill","none"),o.appendChild(i),this._generatingLink.path=i}const n=this._generatingLink.index,a=this._generatingLink.ioType,l=this._generatingLink.domEl,r=this.root.getBoundingClientRect().x,c=this.root.getBoundingClientRect().y,h=l.querySelector(a==Je.NODE_IO_INPUT?".lexgraphnodeinputs":".lexgraphnodeoutputs").childNodes[n].querySelector(".io__type"),d=h.getBoundingClientRect();let u=new Ye(d.x-r,d.y-c),p=null,m=null;if(e){if(p=new Ye(e.offsetX,e.offsetY),t.hasClass(e.target,["lexgraphnode","lexgraphgroup"]))p.add(this._getNodePosition(e.target),p),p.add(new Ye(3,3),p);else if(t.hasClass(e.target,["io__type","lexgraphgroupresizer"])){var g=e.target.offsetParent;p.add(this._getNodePosition(g),p),p.add(new Ye(e.target.offsetLeft,e.target.offsetTop),p),p.add(new Ye(3,3),p)}p=this._getRenderPosition(p)}else{m=s.querySelector(".io__type");const e=m.getBoundingClientRect();p=new Ye(e.x-r,e.y-c)}if(a==Je.NODE_IO_INPUT){var f=p;p=u,u=f}let C=getComputedStyle(h).backgroundColor;return a==Je.NODE_IO_OUTPUT&&m&&(C=getComputedStyle(m).backgroundColor),this._createLinkPath(i,u,p,C,!!e),i}_createLink(e){var t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.classList.add("link-svg"),t.style.width="100%",t.style.height="100%",this._domLinks.appendChild(t);var s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("fill","none"),t.appendChild(s);const i=this._getNodeDOMElement(e.inputNode),o=this._getNodeDOMElement(e.outputNode),n=this.root.getBoundingClientRect().x,a=this.root.getBoundingClientRect().y,l=o.querySelector(".lexgraphnodeoutputs").childNodes[e.outputIdx],r=l.querySelector(".io__type").getBoundingClientRect();let c=new Ye(r.x-n,r.y-a+6);const h=i.querySelector(".lexgraphnodeinputs").childNodes[e.inputIdx],d=h.querySelector(".io__type").getBoundingClientRect();let u=new Ye(d.x-n,d.y-a+6);const p=getComputedStyle(h.querySelector(".io__type")).backgroundColor;this._createLinkPath(s,c,u,p),e.path=s,l.links=[],l.links[e.inputIdx]=l.links[e.inputIdx]??[],l.links[e.inputIdx].push(e.inputNode),h.links=[],h.links[e.outputIdx]=h.links[e.outputIdx]??[],h.links[e.outputIdx].push(e.outputNode),l.dataset.active=!0,h.dataset.active=!0}_createLinkPath(e,s,i,o,n=!1){if(!this.currentGraph)return;const a=6*this.currentGraph.scale;s.add(new Ye(a,a),s),n||i.add(new Ye(a,a),i),s=this._getPatternPosition(s),i=this._getPatternPosition(i);const l=t.clamp(Math.abs(s.x-i.x),0,256),r=128*Math.pow(l/256,.5);let c=s.add(new Ye(r,0)),h=i.sub(new Ye(r,0));e.setAttribute("d",`\n M ${s.x},${s.y}\n C ${c.x},${c.y} ${h.x},${h.y} ${i.x},${i.y}\n `),e.parentElement.style.color=o}_updateNodeLinks(e){if(!(this.nodes[e]?this.nodes[e].data:null))return void console.warn(`Can't finde node [${e}]`);const t=this._getNodeDOMElement(e);for(let i of t.querySelectorAll(".ioinput")){if(!i.links)continue;const o=i.links.filter(e=>void 0!==e)[0][0];if(!o)continue;const n=parseInt(i.dataset.index);var s=this._getLinks(o,e).find(e=>e.inputIdx==n);this._generatingLink={index:n,io:i,ioType:Je.NODE_IO_INPUT,domEl:t,path:s.path};const a=this._getNodeDOMElement(o).querySelector(".lexgraphnodeoutputs").childNodes[s.outputIdx];this._updatePreviewLink(null,a)}for(let i of t.querySelectorAll(".iooutput")){if(!i.links)continue;const o=parseInt(i.dataset.index);for(let n=0;n<i.links.length;++n){const a=i.links[n];if(a)for(let l of a){s=this._getLinks(e,l).find(e=>e.inputIdx==n&&e.outputIdx==o);this._generatingLink={index:s.outputIdx,io:i,ioType:Je.NODE_IO_OUTPUT,domEl:t,path:s.path};const a=this._getNodeDOMElement(l).querySelector(".lexgraphnodeinputs").childNodes[s.inputIdx];this._updatePreviewLink(null,a)}}}delete this._generatingLink}_drawBoxSelection(e){var t;(t=this._currentBoxSelectionSVG)||((t=document.createElementNS("http://www.w3.org/2000/svg","svg")).classList.add("box-selection-svg"),this._boxSelectRemoving&&t.classList.add("removing"),t.style.width="100%",t.style.height="100%",this._domLinks.appendChild(t),this._currentBoxSelectionSVG=t);let s=this._getPatternPosition(this._boxSelecting),i=this._getPatternPosition(this._mousePosition).sub(s);i.x<0&&(s.x+=i.x),i.y<0&&(s.y+=i.y),i=i.abs(),t.innerHTML=`<rect\n x="${s.x}" y="${s.y}"\n rx="6" ry="6"\n width="${i.x}" height="${i.y}"\n "/>`}_getNonVisibleNodes(){const e=[];if(!this.currentGraph)return console.warn("No graph set"),[];const t=new Ze(new Ye(0,0),new Ye(this.root.offsetWidth,this.root.offsetHeight));for(let s of this.currentGraph.nodes){let i=this._getRenderPosition(s.position),o=this._getNodeDOMElement(s.id);if(!o)continue;const n=new Ze(i,s.size.mul(this.currentGraph.scale));t.inside(n,!1)?(o.classList.toggle("hidden-opacity",!1),o.childNodes[1].classList.toggle("hidden-opacity",this.currentGraph.scale<.5)):e.push(s)}return e}_selectNodesInBox(e,t,s=!1){e=this._getPatternPosition(e);let i=(t=this._getPatternPosition(t)).sub(e);if(i.x<0){var o=e.x;e.x=t.x,t.x=o}if(i.y<0){o=e.y;e.y=t.y,t.y=o}const n=this._getAllDOMNodes();for(let i of n){let o=this._getNodePosition(i),n=new Ye(i.offsetWidth,i.offsetHeight);o.x<e.x&&o.x+n.x<e.x||o.x>t.x&&o.x+n.x>t.x||o.y<e.y&&o.y+n.y<e.y||o.y>t.y&&o.y+n.y>t.y||(s?this._unSelectNode(i):this._selectNode(i,!0,!1))}}_deleteSelection(e){const t=this._domNodes.childElementCount;for(let e of this.selectedNodes)this._deleteNode(e);this.selectedNodes.length=0,this._domNodes.childElementCount!=t&&this._addUndoStep()}_getBoundingFromGroup(e){const t=parseFloat(e.style.left),s=parseFloat(e.style.top);return new Ze(new Ye(t,s),new Ye(e.offsetWidth-2,e.offsetHeight-2))}_getBoundingFromNodes(e){let t=null;for(let s of e){const e=this.nodes[s].data,i=new Ze(e.position,e.size);t?t.merge(i):t=i}if(t){const e=8;t.origin.sub(new Ye(e),t.origin),t.origin.sub(new Ye(e),t.origin),t.size.add(new Ye(2*e),t.size),t.size.add(new Ye(2*e),t.size)}return t}_createGroup(e){const s=e??this._getBoundingFromNodes(this.selectedNodes);if(!s)return;const i=s.id??`group-${t.guidGenerator()}`;let o=document.createElement("div");o.id=i,o.classList.add("lexgraphgroup"),o.style.left=s.origin.x+"px",o.style.top=s.origin.y+"px",o.style.width=s.size.x+"px",o.style.height=s.size.y+"px";let n=document.createElement("div");n.classList.add("lexgraphgroupresizer"),n.addEventListener("mousedown",function(e){var t=a.root.ownerDocument;t.addEventListener("mousemove",r),t.addEventListener("mouseup",c),l[0]=e.x,l[1]=e.y,e.stopPropagation(),e.preventDefault(),document.body.classList.add("nocursor"),n.classList.add("nocursor")}),this.groups[i]=o;var a=this,l=[0,0];function r(e){let t=new Ye(l[0]-e.x,l[1]-e.y);t.div(a.currentGraph?.scale,t),o.style.width=parseFloat(o.style.width)-t.x+"px",o.style.height=parseFloat(o.style.height)-t.y+"px",l[0]=e.x,l[1]=e.y,e.stopPropagation(),e.preventDefault()}function c(e){var t=a.root.ownerDocument;t.removeEventListener("mousemove",r),t.removeEventListener("mouseup",c),document.body.classList.remove("nocursor"),n.classList.remove("nocursor")}let h=document.createElement("input"),d=`Group ${Je.LAST_GROUP_ID}`;return h.value=d,h.classList.add("lexgraphgrouptitle"),h.disabled=!0,h.addEventListener("mousedown",e=>{e.stopPropagation(),e.stopImmediatePropagation()}),h.addEventListener("focusout",e=>{h.disabled=!0,h.value.length||(h.value=d)}),h.addEventListener("keyup",e=>{"Enter"==e.key?h.blur():"Escape"==e.key&&(h.value="",h.blur())}),o.addEventListener("dblclick",e=>{e.button==t.MOUSE_LEFT_CLICK&&(h.disabled=!1,h.focus())}),o.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),t.addContextMenu(null,e,e=>{e.add("Delete",()=>{this._deleteGroup(i)})})}),o.appendChild(n),o.appendChild(h),this._domNodes.prepend(o),t.makeDraggable(o,{onMove:this._onMoveGroup.bind(this),onDragStart:this._onDragGroup.bind(this),updateLayers:!1}),Je.LAST_GROUP_ID++,o}_addUndoStep(e=!0){e&&(this._redoSteps.length=0),this._undoSteps.push({})}_doUndo(){this._undoSteps.length&&(this._addRedoStep(),this._undoSteps.pop(),console.log("Undo!!"))}_addRedoStep(){this._redoSteps.push({})}_doRedo(){this._redoSteps.length&&(this._addUndoStep(!1),this._redoSteps.pop(),console.log("Redo!!"))}_togglePropertiesDialog(e=!1){this.propertiesDialog.root.classList.toggle("opened",e),e||this.propertiesDialog.panel.clear()}_setSnappingValue(e){this._snapValue=e}_toggleSnapping(){if(this._snapToGrid=!this._snapToGrid,this._snapToGrid)for(let e of this._getAllDOMNodes(!0))e.mustSnap=!0}_onSidebarCreate(e){new t.DropdownMenu(e.target,[{name:"Create Graph",icon:"Workflow",callback:()=>this.addGraph()},{name:"Create Function",icon:"Function",callback:()=>this.addGraphFunction()}],{side:"right",align:"start"})}_showRenameGraphDialog(){if(!this.currentGraph)return;const e=new t.Dialog(this.currentGraph.constructor.name,t=>{t.addText("Name",this.currentGraph?.name,t=>{this._updateGraphName(t),e.close()})},{modal:!0,size:["350px",null]})}_updateGraphName(e){if(!this.currentGraph)return;const t=e.replace(/\s/g,"").replaceAll(".",""),s=this._sidebar.root.querySelectorAll(".lexsidebarheader span")[1];console.assert(s),s.innerText=e;const i=this._sidebar.items.find(e=>e.name===this.currentGraph?.name);if(i){const s=i.name;i.name=e,i.dom.id=t,i.dom.innerHTML=i.dom.innerHTML.replace(s,e)}const o="function/"+this.currentGraph.name,n=Je.NODE_TYPES[o];n&&(delete Je.NODE_TYPES[o],n.title=e,Je.registerCustomNode("function/"+e,n)),this.currentGraph.name=e}_addGlobalActions(){}}t.GraphEditor=Je;class Qe{name="Unnamed Graph";type="Graph";id="";editor;nodes=[];groups=[];variables={};links={};scale=1;translation=new Ye(0,0);_executionNodes=[];constructor(e,t={}){this.name=e??this.name}configure(e){this.id=e.id,this.name=e.name,this.nodes.length=0;for(let t of e.nodes){const e=Je.addNode(t.type);e.id=t.id,e.title=t.title,e.color=t.color,e.position=new Ye(t.position.x,t.position.y),e.type=t.type,e.properties=t.properties,this.nodes.push(e)}this.groups=e.groups,this.links=e.links}getNodeById(e){for(let t of this.nodes)if(t.id==e)return t}_runStep(e){if(!e)return;const t=this.nodes.reduce((e,t)=>({...e,[t.id]:t}),{});if(!t[e])return;const s={};this._executionNodes=[],this.variables={};const i=e=>{if(!s[e]){s[e]=!0;for(let t in this.links){const s=t.indexOf("@"+e);if(s<0)continue;const o=t.substring(0,s);this._executionNodes.push(o),i(o)}}};this._executionNodes.push(e),i(e);for(var o=this._executionNodes.length-1;o>=0;--o){const e=t[this._executionNodes[o]];e.onBeforeStep&&e.onBeforeStep(),e.execute(),e.onBeforeStep&&e.onAfterStep()}}serialize(e=!0){var s={};s.id=this.id,s.name=this.name,s.type=this.type,s.nodes=[],s.groups=[],s.functions=[],s.links={};for(let e of this.nodes){s.nodes.push(e.serialize());const t=this.editor?.graphs[e.gid];t&&s.functions.push(JSON.parse(t.serialize()))}for(let e in this.links){const i=t.deepCopy(this.links[e]);i.forEach(e=>delete e.path),s.links[e]=i}for(let e of this.groups){const t=this.editor?.groups[e.id],i=this.editor?._getBoundingFromGroup(t);i.id=e.id,i.name=e.name,s.groups.push(i)}try{s=JSON.stringify(s,void 0,e?2:void 0)}catch(e){s=null,console.error(`Can't export Graph [${this.name}] of type [${this.type}].`)}return s}export(){const e=this.serialize();t.downloadFile(this.name+".json",e)}}t.Graph=Qe;class et{static title;static blockDelete=!1;static blockAdd=!1;static description="";id="";type="";title="";inputs=[];outputs=[];properties=[];position=new Ye(0,0);size=new Ye(0,0);color;editor;graphID;constructor(){}_hasOutputsConnected(){return!0}onExecute(){}execute(){this._hasOutputsConnected()&&this.onExecute&&this.onExecute()}addInput(e,t){this.inputs.push({name:e,type:t})}addOutput(e,t){this.outputs.push({name:e,type:t})}addProperty(e,t,s,i){this.properties.push({name:e,type:t,value:s,options:i})}getInput(e){if(!this.inputs||!this.inputs.length||!this.inputs[e])return;const t=this.editor?.graphs[this.graphID];for(let i in t.links){if(i.indexOf("@"+this.id)<0)continue;const o=t.links[i];for(var s of o)if(s.inputIdx==e)return s.data}}setOutput(e,s){if(!this.outputs||!this.outputs.length||!this.outputs[e])return;const i=this.editor?.graphs[this.graphID];for(let a in i.links){if(a.indexOf(this.id+"@")<0)continue;const l=i.links[a];for(var o of l){if(o.outputIdx!=e)continue;let i=s;if(null!=i&&o.inputType!=o.outputType&&"any"!=o.inputType&&"any"!=o.outputType){var n=this.editor?.supportedCastTypes[o.outputType+"@"+o.inputType];i=n?n(t.deepCopy(i)):null}o.data=i}}}serialize(){var e={};return e.id=this.id,e.title=this.title,e.color=this.color,e.position=this.position,e.type=this.type,e.inputs=this.inputs,e.outputs=this.outputs,e.properties=this.properties,e}}t.GraphNode=et;class tt extends Qe{constructor(e,t={}){super(),this.name=e??"GraphFunction"+Je.LAST_FUNCTION_ID,this.type="GraphFunction",Je.LAST_FUNCTION_ID++;const s=Je.addNode("function/Input");s.position=new Ye(150,250);const i=Je.addNode("function/Output");i.position=new Ye(650,350),this.nodes.push(s,i)}getOutputData(e){this.nodes[0].setOutput(0,e);const t=this.nodes[1];return this._runStep(t.id),t.getInput(0)}}t.GraphFunction=tt;class st extends et{onCreate(){this.addOutput(null,"float"),this.addProperty("Outputs","array",["float"],["float","int","bool","vec2","vec3","vec4","mat44"])}onExecute(){}setOutputs(e){for(var t of(this.outputs.length=0,e))this.outputs.push({name:null,type:t})}}st.blockDelete=!0,st.blockAdd=!0,Je.registerCustomNode("function/Input",st);class it extends et{onCreate(){this.addInput(null,"any")}onExecute(){}}it.blockDelete=!0,it.blockAdd=!0,Je.registerCustomNode("function/Output",it);class ot extends et{onCreate(){this.addInput(null,"float"),this.addInput(null,"float"),this.addOutput(null,"float"),this.addProperty("A","float",0),this.addProperty("B","float",0)}onExecute(){var e=this.getInput(0)??this.properties[0].value,t=this.getInput(1)??this.properties[1].value;this.setOutput(0,e+t)}}ot.description="Addition of 2 values (A+B).",Je.registerCustomNode("math/Add",ot);class nt extends et{onCreate(){this.addInput(null,"float"),this.addInput(null,"float"),this.addOutput(null,"float"),this.addProperty("A","float",0),this.addProperty("B","float",0)}onExecute(){var e=this.getInput(0)??this.properties[0].value,t=this.getInput(1)??this.properties[1].value;this.setOutput(0,e-t)}}nt.description="Substraction of 2 values (A-B).",Je.registerCustomNode("math/Substract",nt);class at extends et{onCreate(){this.addInput(null,"float"),this.addInput(null,"float"),this.addOutput(null,"float"),this.addProperty("A","float",0),this.addProperty("B","float",0)}onExecute(){var e=this.getInput(0)??this.properties[0].value,t=this.getInput(1)??this.properties[1].value;this.setOutput(0,e*t)}}at.description="Multiplication of 2 values (A*B).",Je.registerCustomNode("math/Multiply",at);class lt extends et{onCreate(){this.addInput(null,"float"),this.addInput(null,"float"),this.addOutput(null,"float"),this.addProperty("A","float",0),this.addProperty("B","float",0)}onExecute(){var e=this.getInput(0)??this.properties[0].value,t=this.getInput(1)??this.properties[1].value;this.setOutput(0,e/t)}}lt.description="Division of 2 values (A/B).",Je.registerCustomNode("math/Divide",lt);class rt extends et{onCreate(){this.addInput(null,"float"),this.addOutput(null,"float"),this.addProperty("Value","float",0)}onExecute(){var e=this.getInput(0)??this.properties[0].value;this.setOutput(0,Math.sqrt(e))}}rt.description="Square root of a scalar.",Je.registerCustomNode("math/SQRT",rt);Je.registerCustomNode("logic/And",class extends et{onCreate(){this.addInput(null,"bool"),this.addInput(null,"bool"),this.addOutput(null,"bool")}onExecute(){var e=this.getInput(0),t=this.getInput(1);null!=e&&null!=t&&this.setOutput(0,!!e&&!!t)}});Je.registerCustomNode("logic/Or",class extends et{onCreate(){this.addInput(null,"bool"),this.addInput(null,"bool"),this.addOutput(null,"bool")}onExecute(){var e=this.getInput(0),t=this.getInput(1);null!=e&&null!=t&&this.setOutput(0,!!e||!!t)}});class ct extends et{onCreate(){this.addInput(null,"float"),this.addInput(null,"float"),this.addOutput(null,"bool")}logicOp(e,t){return e==t}onExecute(){var e=this.getInput(0),t=this.getInput(1);null!=e&&null!=t&&this.setOutput(0,this.logicOp(e,t))}}Je.registerCustomNode("logic/Equal",ct);Je.registerCustomNode("logic/NotEqual",class extends ct{logicOp(e,t){return e!=t}});Je.registerCustomNode("logic/Less",class extends ct{logicOp(e,t){return e<t}});Je.registerCustomNode("logic/LessEqual",class extends ct{logicOp(e,t){return e<=t}});Je.registerCustomNode("logic/Greater",class extends ct{logicOp(e,t){return e>t}});Je.registerCustomNode("logic/GreaterEqual",class extends ct{logicOp(e,t){return e>=t}});Je.registerCustomNode("logic/Select",class extends et{onCreate(){this.addInput("True","any"),this.addInput("False","any"),this.addInput("Condition","bool"),this.addOutput(null,"any")}onExecute(){var e=this.getInput(0),t=this.getInput(1),s=this.getInput(2);null!=e&&null!=t&&null!=s&&this.setOutput(0,s?e:t)}});class ht extends et{onCreate(){this.addInput("A","any"),this.addInput("B","any"),this.addInput("True","any"),this.addInput("False","any"),this.addProperty("Condition","select","Equal",["Equal","Not Equal","Less","Less Equal","Greater","Greater Equal"]),this.addOutput(null,"any")}onExecute(){var e=this.getInput(0),t=this.getInput(1),s=this.getInput(2),i=this.getInput(3),o=this.properties[0].value;if(null!=e&&null!=t&&null!=s&&null!=i){var n;switch(o){case"Equal":n=e==t?s:i;break;case"Not Equal":n=e!=t?s:i;break;case"Less":n=e<t?s:i;break;case"Less Equal":n=e<=t?s:i;break;case"Greater":n=e>t?s:i;break;case"Greater Equal":n=e>=t?s:i}this.setOutput(0,n)}}}ht.description="Compare A to B given the selected operator. If true, return value of True else return value of False.",Je.registerCustomNode("logic/Compare",ht);Je.registerCustomNode("events/KeyDown",class extends et{onCreate(){this.addOutput(null,"bool"),this.addProperty("Key","string"," ")}onExecute(){this.setOutput(0,!!this.editor?.keys[this.properties[0].value])}});Je.registerCustomNode("inputs/String",class extends et{onCreate(){this.addOutput(null,"string"),this.addProperty(null,"string","text")}onExecute(){this.setOutput(0,this.properties[0].value)}});Je.registerCustomNode("inputs/Float",class extends et{onCreate(){this.addOutput(null,"float"),this.addProperty(null,"float",0)}onExecute(){this.setOutput(0,this.properties[0].value)}});Je.registerCustomNode("inputs/Vector2",class extends et{onCreate(){this.addOutput("Value","vec2"),this.addProperty("Value","vec2",[0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});Je.registerCustomNode("inputs/Vector3",class extends et{onCreate(){this.addOutput("Value","vec3"),this.addProperty("Value","vec3",[0,0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});Je.registerCustomNode("inputs/Vector4",class extends et{onCreate(){this.addOutput("Value","vec4"),this.addProperty("Value","vec4",[0,0,0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});class dt extends et{onCreate(){this.addInput("Value","any"),this.addOutput(null,"any"),this.addProperty("Name","string","")}onExecute(){var e=this.getInput(0);if(null!=e){var t=this.getInput(1);null!=t&&(this.editor?.setVariable(e,t),this.setOutput(0,t))}}}dt.title="Set Variable",Je.registerCustomNode("variables/SetVariable",dt);class ut extends et{onCreate(){this.addOutput(null,"any"),this.addProperty("Name","string","")}onExecute(){var e=this.getInput(0);if(null!=e){var t=this.editor?.getVariable(e);null!=t&&this.setOutput(0,t)}}}ut.title="Get Variable",Je.registerCustomNode("variables/GetVariable",ut);class pt extends et{onCreate(){this.addInput(null,"any")}onExecute(){var e=this.getInput(0);null!=e&&console.log(e)}}pt.title="Console Log",Je.registerCustomNode("system/ConsoleLog",pt);class mt extends et{onCreate(){this.addInput("a","float"),this.addInput("b","bool"),this.addInput("Color","vec4")}onExecute(){var e=this.getInput(2);null!=e&&console.log(e)}}if(mt.blockDelete=!0,Je.registerCustomNode("system/Main",mt),!t)throw"Missing LX namespace!";t.extensions.push("ImUI");const gt=t.vec2;class ft{root;canvas;components={};mouseDown=!1;mousePosition=new gt;usePointerCursor=!1;eventClick=void 0;constructor(e,t={}){console.assert(void 0!==e),e.tabIndex=-1,e.addEventListener("keydown",this._processKey.bind(this),!0),e.addEventListener("mousedown",this._processMouse.bind(this)),e.addEventListener("mouseup",this._processMouse.bind(this)),e.addEventListener("mousemove",this._processMouse.bind(this)),e.addEventListener("click",this._processMouse.bind(this)),this.root=this.canvas=e}_processKey(e){const t=e.detail,s=e.key??t.key;console.log(s)}_processMouse(e){"mousedown"==e.type?this.mouseDown=!0:"mouseup"==e.type?(this._processClick(e),this.mouseDown=!1):"mousemove"==e.type&&this.mousePosition.set(e.clientX,e.clientY)}_processClick(e){this.eventClick=e}Button(e,s,i,o){const n=this.canvas.getContext("2d");n.font="16px Arial";let a=new t.vec2(12,8),l=new t.vec2(s,i);const r=n.measureText(e);let c=new t.vec2(r.width,r.actualBoundingBoxAscent+r.actualBoundingBoxDescent);const h=this.mousePosition.x>=l.x&&this.mousePosition.x<=l.x+c.x+2*a.x&&this.mousePosition.y>=l.y&&this.mousePosition.y<=l.y+c.y+2*a.y,d=h&&this.mouseDown;return n.beginPath(),n.fillStyle=d?"#666":h?"#444":"#222",n.roundRect(l.x,l.y,c.x+2*a.x,c.y+2*a.y,[8,8,8,8]),n.fill(),n.fillStyle=h?"#fff":"#ddd",n.fillText(e,l.x+a.x,l.y+r.actualBoundingBoxAscent+a.y),this.usePointerCursor=this.usePointerCursor||h,!!this.eventClick&&(o&&o(),!0)}Slider(e,s,i,o=0,n){const a=this.canvas.getContext("2d");this.components[e]?o=this.components[e].value:this.components[e]={value:o};a.font="16px Arial";let l=new t.vec2(12,8),r=new t.vec2(s,i);const c=a.measureText(e);let h=new t.vec2(c.width,c.actualBoundingBoxAscent+c.actualBoundingBoxDescent),d=h.add(l.mul(2));const u=this.mousePosition.x>=r.x&&this.mousePosition.x<=r.x+d.x&&this.mousePosition.y>=r.y&&this.mousePosition.y<=r.y+d.y,p=u&&this.mouseDown;a.beginPath(),a.fillStyle=u?"#444":"#222",a.roundRect(r.x,r.y,d.x,d.y,[8,8,8,8]),a.fill();const m=r.x,g=r.x+d.x;p&&(o=t.clamp((this.mousePosition.x-m)/(g-m),0,1),this.components[e].value=o);let f=new t.vec2(d.x*o,h.y);a.beginPath(),a.fillStyle=u?"#6074e7":"#3e57e4",f.x>d.x-8?(a.roundRect(r.x,r.y,f.x,f.y+2*l.y,[8,8,8,8]),a.fill()):a.fillRect(r.x,r.y,f.x,f.y+2*l.y),a.fillStyle=u?"#fff":"#ddd",a.fillText(e,r.x+l.x,r.y+c.actualBoundingBoxAscent+l.y),this.usePointerCursor=this.usePointerCursor||u,p&&n&&n(o)}Checkbox(e,s,i,o=!1,n){const a=this.canvas.getContext("2d");this.components[e]?o=this.components[e].value:this.components[e]={value:o};a.font="16px Arial";let l=new t.vec2(12,8),r=new t.vec2(s,i);const c=a.measureText(e);let h=new t.vec2(c.width,c.actualBoundingBoxAscent+c.actualBoundingBoxDescent),d=new t.vec2(24,0);d.add(h,d);const u=r.x+h.x+l.x+12,p=r.y+l.y,m=this.mousePosition.x>=u&&this.mousePosition.x<=u+h.y&&this.mousePosition.y>=p&&this.mousePosition.y<=p+h.y,g=m&&this.mouseDown,f=m&&this.eventClick;a.fillStyle=g?"#666":m?"#444":"#222",a.fillRect(r.x,r.y,d.x+2*l.x,d.y+2*l.y),f&&(o=!o,this.components[e].value=o,n&&n(o)),a.fillStyle=o?g?"#ddd":m?"#6074e7":"#3e57e4":g?"#bbb":m?"#777":"#888",a.fillRect(r.x+h.x+l.x+12,r.y+l.y,h.y,h.y),a.fillStyle=m?"#fff":"#ddd",a.fillText(e,r.x+l.x,r.y+c.actualBoundingBoxAscent+l.y),this.usePointerCursor=this.usePointerCursor||m}endFrame(){delete this.eventClick,document.body.style.cursor=this.usePointerCursor?"pointer":"default",this.usePointerCursor=!1}}if(t.ImUI=ft,!t)throw"Missing LX namespace!";t.extensions.push("Timeline"),t.registerIcon("TimelineLock",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path fill="none" d="M7 11V7a4 4 0 0 1 9 0v4 M5,11h13 a2 2 0 0 1 2 2 v7 a2 2 0 0 1 -2 2 h-13 a2 2 0 0 1 -2 -2 v-7 a2 2 0 0 1 2 -2 M12 16 v2"/></svg>'),t.registerIcon("TimelineLockOpen",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path fill="none" d="M14 11V7a4 4 0 0 1 9 0v2 M3,11h13 a2 2 0 0 1 2 2 v7 a2 2 0 0 1 -2 2 h-13 a2 2 0 0 1 -2 -2 v-7 a2 2 0 0 1 2 -2 M8 17 h3"/></svg>');const Ct=t.Area,vt=t.Panel,yt=t.Dialog;t.TreeEvent;class bt{static BACKGROUND_COLOR;static TRACK_COLOR_PRIMARY;static TRACK_COLOR_SECONDARY;static TRACK_COLOR_TERCIARY;static TRACK_COLOR_QUATERNARY;static TRACK_SELECTED;static TRACK_SELECTED_LIGHT;static FONT;static FONT_COLOR_PRIMARY;static FONT_COLOR_TERTIARY;static FONT_COLOR_QUATERNARY;static KEYFRAME_COLOR;static KEYFRAME_COLOR_HOVERED;static KEYFRAME_COLOR_SELECTED;static KEYFRAME_COLOR_LOCK;static KEYFRAME_COLOR_EDITED;static KEYFRAME_COLOR_INACTIVE;static TIME_MARKER_COLOR;static TIME_MARKER_COLOR_TEXT;static BOX_SELECTION_COLOR;uniqueID;timelineTitle;animationClip;duration=1;currentTime=0;visualTimeRange=[0,0];visualOriginTime=0;pixelsPerSecond=300;secondsPerPixel;clickTime=0;clickDiscardTimeout=200;lastMouse=[0,0];boxSelection=!1;boxSelectionStart=[0,0];boxSelectionEnd=[0,0];historyUndo=[];historyRedo=[];historySaveEnabler=!0;historyMaxSteps=100;clipboard=null;grabbing=!1;grabTime=0;grabbingTimeBar=!1;grabbingScroll=!1;movingKeys=!1;timeBeforeMove=0;currentScroll=0;currentScrollInPixels=0;trackHeight=32;timeSeparators=[.01,.1,.5,1,5];playing=!1;loop=!0;active=!0;skipVisibility;skipLock;disableNewTracks;optimizeThreshold=.01;selectedTracks=[];selectedItems=[];leftPanel;trackTreesPanel=null;trackTreesComponent=null;lastTrackTreesComponentOffset=0;mainArea;root;header;canvasArea;canvas;size=[1e-6,1e-6];topMargin=40;header_offset=48;updateTheme;onCreateBeforeTopBar=null;onCreateAfterTopBar=null;onCreateControlsButtons=null;onCreateSettingsButtons=null;onShowOptimizeMenu=null;onShowConfiguration=null;onMouse=null;onDblClick=null;onShowContextMenu=null;onAddNewTrackButton=null;onAddNewTrack=null;onTrackTreeEvent=null;onBeforeDrawContent=null;onStateStop=null;onStateChange=null;onChangeLoopMode=null;onSetDuration=null;onSetTime=null;onItemSelected=null;onSetTrackSelection=null;onSetTrackState=null;onSetTrackLock=null;onUpdateTrack=null;configurationDialog=null;constructor(e,s={}){this.uniqueID=e??"timeline"+Math.floor(4294967295*Math.random()),this.timelineTitle=s.title??null,this.onCreateBeforeTopBar=s.onCreateBeforeTopBar,this.onCreateAfterTopBar=s.onCreateAfterTopBar,this.onCreateControlsButtons=s.onCreateControlsButtons,this.onCreateSettingsButtons=s.onCreateSettingsButtons,this.onShowOptimizeMenu=s.onShowOptimizeMenu,this.onShowConfiguration=s.onShowConfiguration,this.canvas=document.createElement("canvas"),this.canvas.style.width="100%",this.canvas.style.height="100%",this.secondsPerPixel=1/this.pixelsPerSecond,this.animationClip=this.instantiateAnimationClip(),this.loop=s.loop??!0,this.skipVisibility=s.skipVisibility??!1,this.skipLock=s.skipLock??!1,this.disableNewTracks=s.disableNewTracks??!1,this.mainArea=new Ct({className:"lextimeline"}),this.root=this.mainArea.root,this.mainArea.split({type:"vertical",sizes:[this.header_offset,"auto"],resize:!1}),this.header=new vt({id:"lextimelineheader"}),this.mainArea.sections[0].attach(this.header),this.updateHeader();const i=this.mainArea.sections[1];i.root.id="bottom-timeline-area",i.split({type:"horizontal",sizes:["15%","85%"]});let[o,n]=i.sections;n.attach(this.canvas),this.canvasArea=n,this.canvasArea.root.classList.add("lextimelinearea"),this.leftPanel=o.addPanel({className:"lextimelinepanel",width:"100%",height:"100%"}),this.updateLeftPanel(),this.uniqueID.length&&(this.root.id=this.uniqueID,this.canvas.id=this.uniqueID+"-canvas"),this.canvas.addEventListener("mousedown",this.processMouse.bind(this)),this.canvas.addEventListener("mouseup",this.processMouse.bind(this)),this.canvas.addEventListener("mousemove",this.processMouse.bind(this)),this.canvas.addEventListener("wheel",this.processMouse.bind(this)),this.canvas.addEventListener("dblclick",this.processMouse.bind(this)),this.canvas.addEventListener("contextmenu",this.processMouse.bind(this)),this.canvas.tabIndex=1,this.canvasArea.root.addEventListener("keydown",e=>{this.processKeys(e)}),this.canvasArea.onresize=e=>{e.width&&e.height&&this.resizeCanvas()},this.resize(this.size),this.updateTheme=function(){bt.BACKGROUND_COLOR=t.getThemeColor("global-blur-background"),bt.TRACK_COLOR_PRIMARY=t.getThemeColor("global-color-primary"),bt.TRACK_COLOR_SECONDARY=t.getThemeColor("global-color-secondary"),bt.TRACK_COLOR_TERCIARY=t.getThemeColor("global-color-terciary"),bt.TRACK_COLOR_QUATERNARY=t.getThemeColor("global-color-quaternary"),bt.FONT=t.getThemeColor("global-font"),bt.FONT_COLOR_PRIMARY=t.getThemeColor("global-text-primary"),bt.FONT_COLOR_TERTIARY=t.getThemeColor("global-text-tertiary"),bt.FONT_COLOR_QUATERNARY=t.getThemeColor("global-text-quaternary"),bt.KEYFRAME_COLOR=t.getThemeColor("lxTimeline-keyframe"),bt.KEYFRAME_COLOR_SELECTED=bt.KEYFRAME_COLOR_HOVERED=t.getThemeColor("lxTimeline-keyframe-selected"),bt.KEYFRAME_COLOR_LOCK=t.getThemeColor("lxTimeline-keyframe-locked"),bt.KEYFRAME_COLOR_EDITED=t.getThemeColor("lxTimeline-keyframe-edited"),bt.KEYFRAME_COLOR_INACTIVE=t.getThemeColor("lxTimeline-keyframe-inactive")}.bind(this),t.addSignal("@on_new_color_scheme",this.updateTheme)}clear(){if(this.header&&this.header.clear(),this.leftPanel&&this.leftPanel.clear(),this.updateTheme){let e=t.signals["@on_new_color_scheme"]??[];for(let t=0;t<e.length;++t)e[t]==this.updateTheme&&e.splice(t,1)}}updateHeader(){this.header.clear();const e=this.header;e.sameLine(),this.timelineTitle&&e.addTitle(this.timelineTitle,{style:{background:"none",fontSize:"18px",fontStyle:"bold",alignItems:"center"}});const s=t.makeContainer(["auto","100%"],"flex flex-row gap-1");e.queue(s);e.addButton("playBtn","",(e,t)=>{this.changeState()},{buttonClass:"accept",title:"Play",hideName:!0,icon:"Play@solid",swap:"Pause@solid"}).setState(this.playing,!0),e.addButton("stopBtn","",(e,t)=>{this.setState(!1,!0),this.onStateStop&&this.onStateStop()},{buttonClass:"accept",title:"Stop",hideName:!0,icon:"Stop@solid"}),e.addButton("loopBtn","",(e,t)=>{this.setLoopMode(!this.loop)},{selectable:!0,selected:this.loop,title:"Loop",hideName:!0,icon:"RefreshCw"}),this.onCreateControlsButtons&&this.onCreateControlsButtons(e),e.clearQueue(s),e.addContent("header-buttons",s),this.onCreateBeforeTopBar&&this.onCreateBeforeTopBar(e),e.addNumber("Current Time",this.currentTime,(e,t)=>{this.setTime(e)},{units:"s",step:.01,min:0,precision:3,skipSlider:!0,skipReset:!0,nameWidth:"auto"}),e.addNumber("Duration",+this.duration.toFixed(3),(e,t)=>{this.setDuration(e,!1,!1)},{units:"s",step:.01,min:0,skipReset:!0,nameWidth:"auto"}),this.onCreateAfterTopBar&&this.onCreateAfterTopBar(e);const i=t.makeContainer(["auto","100%"],"flex flex-row gap-1");e.queue(i),this.onCreateSettingsButtons&&this.onCreateSettingsButtons(e),this.onShowOptimizeMenu&&e.addButton(null,"",(e,t)=>{this.onShowOptimizeMenu&&this.onShowOptimizeMenu(t)},{tooltip:!0,title:"Optimize",icon:"Filter"}),this.onShowConfiguration&&e.addButton(null,"",(e,t)=>{if(this.configurationDialog)return this.configurationDialog.close(),void(this.configurationDialog=null);this.configurationDialog=new yt("Configuration",e=>{this.onShowConfiguration&&this.onShowConfiguration(e)},{onBeforeClose:()=>{this.configurationDialog.panel.clear(),this.configurationDialog=null}})},{title:"Settings",icon:"Settings",tooltip:!0}),e.clearQueue(i),e.addContent("header-buttons-end",i),e.endLine("justify-between")}updateLeftPanel(){this.leftPanel.clear();const e=this.leftPanel;e.sameLine();let s=e.addTitle("Tracks",{style:{background:"none"},className:"fg-secondary text-lg px-4"}).root;this.disableNewTracks||e.addButton("addTrackBtn","",(e,t)=>{this.onAddNewTrackButton?this.onAddNewTrackButton():this.addNewTrack()},{hideName:!0,title:"Add Track",icon:"Plus"}),e.endLine();const i=window.getComputedStyle(s),o=s.clientHeight+parseFloat(i.marginTop)+parseFloat(i.marginBottom);let n=new t.Panel({height:"calc(100% - "+o+"px )"}),a=[];this.animationClip&&this.selectedItems.length&&(a=this.generateSelectedItemsTreeData()),this.trackTreesComponent=n.addTree(null,a,{filter:!1,rename:!1,draggable:!1,onevent:e=>{switch(e.type){case t.TreeEvent.NODE_SELECTED:if(e.event.shiftKey||this.deselectAllTracks(!1),e.node.trackData){const t=!e.event.shiftKey||!e.node.trackData.isSelected;this.setTrackSelection(e.node.trackData.trackIdx,t,!1,!1)}break;case t.TreeEvent.NODE_VISIBILITY:e.node.trackData&&this.setTrackState(e.node.trackData.trackIdx,e.value,!1,!1)}this.onTrackTreeEvent&&this.onTrackTreeEvent(e)}});const l=this;this.trackTreesComponent.innerTree._refresh=this.trackTreesComponent.innerTree.refresh,this.trackTreesComponent.innerTree.refresh=function(e,t){this._refresh(e,t),l.setTrackHeight(l.trackHeight)},this.selectedTracks.length&&this._updateTrackTreeSelection(),this.trackTreesComponent.name="tracksTrees",n.components[this.trackTreesComponent.name]=this.trackTreesComponent,this.trackTreesPanel=n,e.attach(n.root),n.root.addEventListener("scroll",e=>{e.currentTarget.scrollHeight>e.currentTarget.clientHeight?(this.currentScroll=e.currentTarget.scrollTop/(e.currentTarget.scrollHeight-e.currentTarget.clientHeight),this.currentScrollInPixels=e.currentTarget.scrollTop):(this.currentScroll=0,this.currentScrollInPixels=0)}),this.trackTreesPanel.root.scrollTop=this.currentScrollInPixels,this.setTrackHeight(this.trackHeight),!this.leftPanel.parent.root.classList.contains("hidden")&&this.root.parentElement&&(this.resizeCanvas(),this.setScroll(this.currentScroll))}setTrackHeight(e){const t=.25*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.trackHeight=e=Math.max(t,e),!this.trackTreesComponent)return;e-=t;const s=this.trackTreesComponent.root.querySelector("ul").children;for(let t=0;t<s.length;++t)s[t].style.height=e+"px"}addNewTrack(e={},t=!1){const s=this.instantiateTrack(e);return s.trackIdx=this.animationClip.tracks.length,this.animationClip.tracks.push(s),this.onAddNewTrack&&!t&&this.onAddNewTrack(s,e),s.trackIdx}getTracksInRange(e,t){let s=[];if(e>t){let s=e;e=t,t=s}const i=this.getVisibleItems();if(i.length<1)return[];const o=e-this.lastTrackTreesComponentOffset+this.currentScrollInPixels,n=t-this.lastTrackTreesComponentOffset+this.currentScrollInPixels,a=Math.max(0,Math.floor(o/this.trackHeight)),l=Math.min(i.length-1,Math.floor(n/this.trackHeight))+1;for(let e=a;e<l;++e){const t=i[e];t.treeData&&t.treeData.trackData&&s.push(t.treeData.trackData)}return s}setAnimationClip(e,t=!0){return this.deselectAllElements(),this.deselectAllTracks(!1),this.selectedItems=[],this.clearState(),e&&e.tracks&&!t?this.animationClip=e:this.animationClip=this.instantiateAnimationClip(e),this.setDuration(this.animationClip.duration,!0,!0),this.updateLeftPanel(),this.resize(),this.animationClip}drawTimeInfo(e,t=this.topMargin){let s=this.canvas.getContext("2d");s.font="11px "+bt.FONT,s.textAlign="center",s.save(),s.fillStyle=bt.BACKGROUND_COLOR,s.fillRect(0,0,this.canvas.width,t),s.strokeStyle=bt.FONT_COLOR_PRIMARY;let i=4;this.pixelsPerSecond>900?i=1:this.pixelsPerSecond>100?i=2:this.pixelsPerSecond>50&&(i=3);let o=this.timeSeparators[i-1];i=this.timeSeparators[i];const n=this.visualTimeRange[0],a=this.visualTimeRange[1];let l=this.timeToX(n+i)-this.timeToX(n),r=o*l/i,c=this.timeToX(Math.floor(n/i)*i);c+=1e-7;let h=this.timeToX(a);s.beginPath(),s.fillStyle=bt.FONT_COLOR_PRIMARY,s.globalAlpha=1;for(let e=c;e<=h;e+=l){s.moveTo(Math.round(e)+.5,.4*t+.3*t),s.lineTo(Math.round(e)+.5,.95*t);let o=e+l-.5*r;for(let i=e;i<o&&i<h;i+=r)s.moveTo(Math.round(i)+.5,.4*t+.45*t),s.lineTo(Math.round(i)+.5,.95*t);let n=this.xToTime(e);s.fillText(n.toFixed(i<1?1:0),e,.6*t)}s.stroke(),s.restore()}drawTracksBackground(e,t){let s=this.canvas,i=s.getContext("2d"),o=this.duration;i.globalAlpha=1;const n=this.topMargin,a=this.lastTrackTreesComponentOffset,l=this.trackHeight;e=e||s.width;let r=Math.ceil((t-n)/l)+1;i.save(),i.fillStyle=bt.TRACK_COLOR_SECONDARY;const c=this.currentScrollInPixels%l;for(let t=1-Math.floor(this.currentScrollInPixels/l)%2;t<=r;t+=2)i.fillRect(0,a-c+t*l,e,l);i.strokeStyle=bt.TRACK_COLOR_TERCIARY,i.beginPath();let h=this.timeToX(0);h<0&&(h=0),i.lineWidth=1,i.moveTo(h+.5,n),i.lineTo(h+.5,s.height),i.moveTo(Math.round(this.timeToX(o))+.5,n),i.lineTo(Math.round(this.timeToX(o))+.5,s.height),i.stroke(),i.restore()}draw(){let e=this.canvas.getContext("2d");e.textBaseline="bottom",e.font="11px "+bt.FONT,e.globalAlpha=1;const t=e.canvas.width,s=e.canvas.height,i=this.trackTreesComponent.root.scrollHeight,o=this.lastTrackTreesComponentOffset=this.trackTreesComponent.innerTree.domEl.offsetTop-this.canvas.offsetTop-2;let n=this.visualOriginTime;n=Math.min(this.duration,Math.max(0,n));let a=this.visualOriginTime+t*this.secondsPerPixel;if(a=Math.max(n,Math.min(this.duration,a)),this.visualTimeRange[0]=n,this.visualTimeRange[1]=a,e.globalAlpha=1,e.fillStyle=bt.TRACK_COLOR_SECONDARY,e.clearRect(0,0,this.canvas.width,this.canvas.height),this.drawTracksBackground(t,s),this.onBeforeDrawContent&&this.onBeforeDrawContent(e),this.animationClip&&(e.translate(0,o),this.drawContent(e),e.translate(0,-o)),s-this.topMargin<i){e.fillStyle="#222",e.fillRect(t-10,0,10,s),e.fillStyle=this.grabbingScroll?bt.FONT_COLOR_TERTIARY:bt.FONT_COLOR_QUATERNARY;let i=Math.max(10,(s-this.topMargin)*(s-this.topMargin)/this.trackTreesPanel.root.scrollHeight);Lt(e,t-10,this.currentScroll*(s-this.topMargin-i)+this.topMargin,10,i,5,!0)}this.drawTimeInfo(t);let l=Math.round(this.timeToX(this.currentTime)),r=.4*this.topMargin;l>=0&&(e.strokeStyle=e.fillStyle=bt.TIME_MARKER_COLOR,e.globalAlpha=1,e.beginPath(),e.moveTo(l,.6*r),e.lineTo(l,this.canvas.height),e.stroke(),e.closePath(),e.shadowBlur=8,e.shadowColor=bt.TIME_MARKER_COLOR,e.shadowOffsetX=1,e.shadowOffsetY=1,Lt(e,l-10,.6*r,20,r,5,!0),e.fill(),e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.font="11px "+bt.FONT,e.textAlign="center",e.fillStyle=bt.TIME_MARKER_COLOR_TEXT,e.fillText((.1*Math.floor(10*this.currentTime)).toFixed(1),l,.6*this.topMargin),e.strokeStyle=e.fillStyle=bt.FONT_COLOR_PRIMARY,this.boxSelection&&(e.globalAlpha=.15,e.fillStyle=bt.BOX_SELECTION_COLOR,e.strokeRect(this.boxSelectionStart[0],this.boxSelectionStart[1],this.boxSelectionEnd[0]-this.boxSelectionStart[0],this.boxSelectionEnd[1]-this.boxSelectionStart[1]),e.fillRect(this.boxSelectionStart[0],this.boxSelectionStart[1],this.boxSelectionEnd[0]-this.boxSelectionStart[0],this.boxSelectionEnd[1]-this.boxSelectionStart[1]),e.stroke(),e.globalAlpha=1)}clearState(){this.historyUndo=[],this.historyRedo=[]}setDuration(e,t=!1,s=!0){let i=Math.max(0,e);this.duration=this.animationClip.duration=i,s&&this.header.components.Duration.set(+this.duration.toFixed(2),!0),this.onSetDuration&&!t&&this.onSetDuration(this.duration)}setTime(e,t=!1){this.currentTime=Math.max(0,Math.min(e,this.duration)),this.header.components["Current Time"].set(+this.currentTime.toFixed(2),!0),this.onSetTime&&!t&&this.onSetTime(this.currentTime)}xToTime(e){return e*this.secondsPerPixel+this.visualOriginTime}timeToX(e){return(e-this.visualOriginTime)*this.pixelsPerSecond}setScale(e){const t=this.timeToX(this.currentTime);this.pixelsPerSecond=e,this.pixelsPerSecond=Math.max(1e-5,this.pixelsPerSecond),this.secondsPerPixel=1/this.pixelsPerSecond,this.visualOriginTime+=this.currentTime-this.xToTime(t)}setScroll(e,t=!0){if(!this.trackTreesPanel)return this.currentScroll=0,void(this.currentScrollInPixels=0);const s=this.trackTreesPanel.root;s.scrollHeight>s.clientHeight?t?(this.currentScroll=e,this.currentScrollInPixels=e*(s.scrollHeight-s.clientHeight)):(this.currentScroll=e/(s.scrollHeight-s.clientHeight),this.currentScrollInPixels=e):(this.currentScroll=0,this.currentScrollInPixels=0),this.trackTreesPanel.root.scrollTop=this.currentScrollInPixels}processMouse(e){if(!this.canvas)return;let s=this.canvas.height,i=this.canvas.width,o=e.offsetX,n=e.offsetY;e.deltax=o-this.lastMouse[0],e.deltay=n-this.lastMouse[1];let a=e.offsetX,l=e.offsetY,r=this.timeToX(this.currentTime),c=l<this.topMargin&&a>r-6&&a<r+6;const h=this.xToTime(o);if(c?this.canvas.style.cursor="col-resize":this.movingKeys?this.canvas.style.cursor="grabbing":e.shiftKey?this.canvas.style.cursor="crosshair":this.canvas.style.cursor="default","wheel"==e.type){if(e.shiftKey){if(e.wheelDelta){let t=this.xToTime(a);this.setScale(this.pixelsPerSecond*(e.wheelDelta<0?.95:1.05)),this.visualOriginTime=t-a*this.secondsPerPixel}}else s-this.topMargin<this.trackTreesComponent.root.scrollHeight&&(this.trackTreesPanel.root.scrollTop+=e.deltaY);return void(this.onMouse&&this.onMouse(e,h))}const d=o>=0&&o<=this.size[0]&&n>=0&&n<=this.size[1];let u=this.getTracksInRange(l,l);if(u=u.length?u[0]:null,e.track=u,e.localX=a,e.localY=l,"mouseup"==e.type){if(!this.active)return this.grabbing=!1,this.grabbingTimeBar=!1,this.grabbingScroll=!1,this.movingKeys=!1,this.timeBeforeMove=0,void(this.boxSelection=!1);const s=this.movingKeys||t.getTime()-this.clickTime>this.clickDiscardTimeout;e.discard=s,this.grabbingScroll||this.grabbingTimeBar||0!=e.button||!this.onMouseUp||this.onMouseUp(e,h),this.grabbing=!1,this.grabbingTimeBar=!1,this.grabbingScroll=!1,this.movingKeys=!1,this.timeBeforeMove=0,this.boxSelection=!1}if("mousedown"==e.type){if(window.getSelection()?.empty(),this.clickTime=t.getTime(),e.shiftKey&&this.active)return this.boxSelection=!0,this.boxSelectionEnd[0]=this.boxSelectionStart[0]=a,void(this.boxSelectionEnd[1]=this.boxSelectionStart[1]=l);e.localY<this.topMargin?(this.grabbing=!0,this.grabbingTimeBar=!0,this.setTime(h)):s-this.topMargin<this.trackTreesComponent.root.scrollHeight&&o>i-10?(this.grabbing=!0,this.grabbingScroll=!0):(this.grabbing=!0,this.grabTime=h,this.grabbingTimeBar=c,this.onMouseDown&&this.active&&this.onMouseDown(e,h))}else if("mousemove"==e.type){if(e.shiftKey&&this.active&&this.boxSelection)return this.boxSelectionEnd[0]=a,void(this.boxSelectionEnd[1]=l);if(this.grabbing&&2!=e.button&&!this.movingKeys)if(this.canvas.style.cursor="grabbing",this.grabbingTimeBar&&this.active)this.setTime(h);else if(this.grabbingScroll)n<this.topMargin?this.trackTreesPanel.root.scrollTop=0:this.trackTreesPanel.root.scrollTop+=this.trackTreesPanel.root.scrollHeight*e.deltay/(s-this.topMargin);else{var p=this.xToTime(this.lastMouse[0]),m=this.xToTime(e.offsetX);this.visualOriginTime+=p-m,this.trackTreesPanel.root.scrollTop-=e.deltay}this.onMouseMove&&this.onMouseMove(e,h)}else"dblclick"==e.type&&this.onDblClick?this.onDblClick(e):"contextmenu"==e.type&&this.onShowContextMenu&&this.active&&this.onShowContextMenu(e);return this.lastMouse[0]=o,this.lastMouse[1]=n,!(d||this.grabbing||e.metaKey||e.altKey)||(this.onMouse&&this.onMouse(e,h),!0)}processKeys(e){switch(e.key){case"Delete":case"Backspace":this.deleteSelectedContent(!1);break;case"c":case"C":e.ctrlKey&&this.copySelectedContent();break;case"v":case"V":e.ctrlKey&&this.pasteContent(this.currentTime);break;case" ":e.preventDefault(),e.stopImmediatePropagation(),this.changeState();break;case"Shift":this.canvas.style.cursor="crosshair"}}changeState(e=!1){this.setState(!this.playing,e)}setState(e,t=!1){this.playing=e,this.header.components.playBtn.setState(this.playing,!0),this.onStateChange&&!t&&this.onStateChange(this.playing)}setLoopMode(e,t=!1){this.loop=e,this.loop?this.header.components.loopBtn.root.children[0].classList.add("selected"):this.header.components.loopBtn.root.children[0].classList.remove("selected"),this.onChangeLoopMode&&!t&&this.onChangeLoopMode(this.loop)}getVisibleItems(){return this.trackTreesComponent.innerTree.domEl.children[0].children}setSelectedItems(e,t=!1){this.selectedItems=[],this.changeSelectedItems(e,null,t)}changeSelectedItems(e=null,t=null,s=!1){this.deselectAllElements(),this.deselectAllTracks(!1);const i=this.animationClip.tracks;if(t)for(let e=0;e<t.length;++e){const s=t[e];for(let e=0;e<this.selectedItems.length;++e)if(this.selectedItems[e]===s){this.selectedItems.splice(e,1);break}}if(e)for(let t=0;t<e.length;++t){const s=e[t];i[s]&&this.selectedItems.push(i[s])}this.updateLeftPanel(),this.onItemSelected&&!s&&this.onItemSelected(this.selectedItems,e,t)}getTrack(e){const t=this.animationClip.tracks;for(let s=0;s<t.length;++s)if(t[s].id==e)return t[s];return null}deselectAllTracks(e=!0){if(!this.animationClip)return;const t=this.animationClip.tracks;for(let e=0;e<t.length;e++)t[e].isSelected=!1;this.selectedTracks.length=0,e&&this._updateTrackTreeSelection()}setTrackSelection(e,t,s=!1,i=!0){const o=this.animationClip.tracks[e],n=o.isSelected;o.isSelected=t;const a=this.selectedTracks.indexOf(o);-1==a&&!t||a>-1&&t||(-1==a?this.selectedTracks.push(o):this.selectedTracks.splice(a,1),this.onSetTrackSelection&&!s&&this.onSetTrackSelection(o,n),i&&this._updateTrackTreeSelection())}_updateTrackTreeSelection(){const e=this.trackTreesComponent.innerTree.data,t=this.trackTreesComponent.innerTree.selected;t.length=0;const s=e=>{for(let i=0;i<e.length;++i)e[i].trackData&&e[i].trackData.isSelected&&t.push(e[i]),e[i].children&&s(e[i].children)};this.selectedTracks.length&&s(e),this.trackTreesComponent.innerTree.refresh()}deselectAllElements(){}setTrackState(e,t=!0,s=!1,i=!0){const o=this.animationClip.tracks[e],n=o.active;o.active=t,this.onSetTrackState&&!s&&this.onSetTrackState(o,n),i&&!this.skipVisibility&&this.updateLeftPanel()}setTrackLock(e,t=!1,s=!1,i=!0){const o=this.animationClip.tracks[e],n=o.locked;o.locked=t,this.onSetTrackLock&&!s&&this.onSetTrackLock(o,n),i&&!this.skipLock&&this.updateLeftPanel()}saveState(e,t=!1){if(!this.historySaveEnabler)return;const s=this.historyGenerateTrackStep(e);s.trackIdx=e,t&&this.historyUndo.length?this.historyUndo[this.historyUndo.length-1].push(s):this.historyUndo.push([s]),this.historyUndo.length>this.historyMaxSteps&&this.historyUndo.shift(),this.historyRedo=[]}#e(e=!0){let t=e?this.historyUndo:this.historyRedo,s=e?this.historyRedo:this.historyUndo;if(!t.length)return!1;this.deselectAllElements();const i=t.pop(),o=[];for(let t=0;t<i.length;++t){const s=i[t],n=s.trackIdx,a=this.historyApplyTrackStep(s,e);a.trackIdx=n,o.push(a),this.onUpdateTrack&&this.onUpdateTrack([s.trackIdx])}return s.push(o),!0}undo(){return this.#e(!0)}redo(){return this.#e(!1)}resize(e=null){e?(this.size[0]=e[0],this.size[1]=e[1]):this.root.parentElement&&(this.size[0]=this.root.parentElement.clientWidth,this.size[1]=this.root.parentElement.clientHeight),this.mainArea.sections[1].root.style.height="calc(100% - "+this.header_offset+"px )",this.size[0],this.leftPanel.root.clientWidth,this.mainArea.sections[1]._update(),this.resizeCanvas()}resizeCanvas(){this.canvas.width=this.canvasArea.root.clientWidth,this.canvas.height=this.canvasArea.root.clientHeight}hide(){this.mainArea.hide()}show(){this.mainArea.show(),this.resize(),this.updateLeftPanel()}generateSelectedItemsTreeData(){const e=[];for(let t=0;t<this.selectedItems.length;t++){const s=this.selectedItems[t];e.push({trackData:s,id:s.id,skipVisibility:this.skipVisibility,visible:s.active,children:[],actions:this.skipLock?null:[{name:"Lock edition",icon:s.locked?"TimelineLock":"TimelineLockOpen",swap:s.locked?"TimelineLockOpen":"TimelineLock",callback:(e,t,s)=>{this.setTrackLock(e.trackData.trackIdx,!e.trackData.locked,!1,!1)}}]})}return e}instantiateTrack(e={},t=!1){return{isTrack:!0,id:e.id??Math.floor(performance.now())+"_"+Math.floor(65535*Math.random()),active:e.active??!0,locked:e.locked??!1,isSelected:!1,trackIdx:-1,data:e.data??null}}instantiateAnimationClip(e={},t=!1){return{id:e.id??e.name??"animationClip",duration:e.duration??0,tracks:[],data:e.data??null}}}bt.BACKGROUND_COLOR=t.getThemeColor("global-blur-background"),bt.TRACK_COLOR_PRIMARY=t.getThemeColor("global-color-primary"),bt.TRACK_COLOR_SECONDARY=t.getThemeColor("global-color-secondary"),bt.TRACK_COLOR_TERCIARY=t.getThemeColor("global-color-terciary"),bt.TRACK_COLOR_QUATERNARY=t.getThemeColor("global-color-quaternary"),bt.TRACK_SELECTED=t.getThemeColor("global-color-accent"),bt.TRACK_SELECTED_LIGHT=t.getThemeColor("global-color-accent-light"),bt.FONT=t.getThemeColor("global-font"),bt.FONT_COLOR_PRIMARY=t.getThemeColor("global-text-primary"),bt.FONT_COLOR_TERTIARY=t.getThemeColor("global-text-tertiary"),bt.FONT_COLOR_QUATERNARY=t.getThemeColor("global-text-quaternary"),bt.TIME_MARKER_COLOR=t.getThemeColor("global-color-accent"),bt.TIME_MARKER_COLOR_TEXT="#ffffff",t.setThemeColor("lxTimeline-keyframe","light-dark(#2d69da,#2d69da )"),t.setThemeColor("lxTimeline-keyframe-selected","light-dark(#f5c700,#fafa14)"),t.setThemeColor("lxTimeline-keyframe-hovered","light-dark(#f5c700,#fafa14)"),t.setThemeColor("lxTimeline-keyframe-locked","light-dark(#c62e2e,#ff7d7d )"),t.setThemeColor("lxTimeline-keyframe-edited","light-dark(#00d000,#00d000 )"),t.setThemeColor("lxTimeline-keyframe-inactive","light-dark(#706b6b,#706b6b)"),bt.KEYFRAME_COLOR=t.getThemeColor("lxTimeline-keyframe"),bt.KEYFRAME_COLOR_SELECTED=bt.KEYFRAME_COLOR_HOVERED=t.getThemeColor("lxTimeline-keyframe-selected"),bt.KEYFRAME_COLOR_LOCK=t.getThemeColor("lxTimeline-keyframe-locked"),bt.KEYFRAME_COLOR_EDITED=t.getThemeColor("lxTimeline-keyframe-edited"),bt.KEYFRAME_COLOR_INACTIVE=t.getThemeColor("lxTimeline-keyframe-inactive"),bt.BOX_SELECTION_COLOR="#AAA",t.Timeline=bt;class _t extends bt{static ADDKEY_VALUESINARRAYS=1;lastKeyFramesSelected;keyValuePerPixel;defaultCurves;defaultCurvesRange;keyframeSize;keyframeSizeHovered;lastHovered=null;moveKeyMinTime=0;onContentMoved=null;onOptimizeTracks=null;onDeleteKeyFrames=null;onSelectKeyFrame=null;onDeselectKeyFrames=null;constructor(e,s={}){super(e,s),this.lastKeyFramesSelected=[],this.keyValuePerPixel=1/this.trackHeight,this.defaultCurves=!0,this.defaultCurvesRange=[0,1],this.keyframeSize=.5*this.trackHeight,this.keyframeSizeHovered=.5*this.trackHeight+5,s.onShowOptimizeMenu&&"boolean"==typeof s.onShowOptimizeMenu&&(this.onShowOptimizeMenu=e=>{0!=this.selectedItems.length&&t.addContextMenu("Optimize",e,e=>{this.selectedItems.forEach(t=>{if(t.isTrack)e.add((t.groupId?t.groupId:"")+"@"+t.id,()=>{this.optimizeTrack(t.trackIdx,!1)});else{const s=this.animationClip.tracksPerGroup[t];for(let t=0;t<s.length;++t){const i=s[t];e.add((i.groupId?i.groupId:"")+"@"+i.id,()=>{this.optimizeTrack(i.trackIdx,!1)})}}})})}),this.onShowContextMenu=e=>{e.preventDefault(),e.stopPropagation();let s=[];this.lastKeyFramesSelected&&this.lastKeyFramesSelected.length?(s.push({title:"Copy",callback:()=>{this.copySelectedContent()}}),s.push({title:"Delete",callback:()=>{this.deleteSelectedContent()}}),1==this.lastKeyFramesSelected.length&&this.clipboard&&this.clipboard.value&&s.push({title:"Paste Value",callback:()=>{this.pasteContentValue()}})):(s.push({title:"Add Here",callback:()=>{if(!e.track)return;const t=new Float32Array(e.track.dim);t.fill(0),this.addKeyFrames(e.track.trackIdx,t,[this.xToTime(e.localX)])}}),s.push({title:"Add",callback:()=>{if(!e.track)return;const t=new Float32Array(e.track.dim);t.fill(0),this.addKeyFrames(e.track.trackIdx,t,[this.currentTime])}})),this.clipboard&&this.clipboard.keyframes&&(s.push({title:"Paste Here",callback:()=>{this.pasteContent(this.xToTime(e.localX))}}),s.push({title:"Paste",callback:()=>{this.pasteContent(this.currentTime)}})),t.addContextMenu("Options",e,e=>{for(let t=0;t<s.length;t++)e.add(s[t].title,s[t].callback)})},this.animationClip&&this.setAnimationClip(this.animationClip)}generateSelectedItemsTreeData(){const e=[],t=this.animationClip.tracksPerGroup;for(let s=0;s<this.selectedItems.length;s++){const i=this.selectedItems[s],o=!i.isTrack,n=o?t[i]:[i],a=[];for(let e=0;e<n.length;e++){const t=n[e];a.push({trackData:t,id:t.id,skipVisibility:this.skipVisibility,visible:t.active,children:[],actions:this.skipLock?null:[{name:"Lock edition",icon:t.locked?"TimelineLock":"TimelineLockOpen",swap:t.locked?"TimelineLockOpen":"TimelineLock",callback:(e,t,s)=>{this.setTrackLock(e.trackData.trackIdx,!e.trackData.locked,!1,!1)}}]})}if(o){const t={id:i,skipVisibility:!0,children:a};e.push(t)}else e.push(a[0])}return e}instantiateTrack(e={},t=!1){const s=super.instantiateTrack(e);if(s.dim=Math.max(1,e.dim??1),s.groupId=null,s.groupTrackIdx=-1,s.values=new Float32Array(0),s.times=new Float32Array(0),s.selected=[],s.edited=[],s.hovered=[],e.values&&e.times){s.values=t?e.values.slice():e.values,s.times=t?e.times.slice():e.times;const i=s.times.length;e.selected&&e.selected.length==i?s.selected=t?e.selected.slice():e.selected:s.selected=new Array(i).fill(!1),e.edited&&e.edited.length==i?s.edited=t?e.edited.slice():e.edited:s.edited=new Array(i).fill(!1),e.hovered&&e.hovered.length==i?s.hovered=t?e.hovered.slice():e.hovered:s.hovered=new Array(i).fill(!1)}return s.curves=e.curves??this.defaultCurves,s.curvesRange=(e.curvesRange??this.defaultCurvesRange).slice(),s}instantiateAnimationClip(e,t=!1){const s=super.instantiateAnimationClip(e,t);if(s.tracksPerGroup={},e&&e.tracks){const i={};let o=0;for(let n=0;n<e.tracks.length;++n){let a=e.tracks[n],l=a.times??[],r=a.values??[],c=a.dim;(!c||c<0)&&(c=l.length&&r.length?Math.round(r.length/l.length):1);let h=a.id??a.name;const[d,u]=h?this._getValidTrackName(h):[null,null],p=Object.assign({},a);p.id=u,p.dim=c;const m=this.instantiateTrack(p,t);d&&(i[d]?i[d].push(m):i[d]=[m],m.groupId=d,m.groupTrackIdx=i[d].length-1),m.trackIdx=n,s.tracks.push(m),m.times.length&&(o=Math.max(o,m.times[m.times.length-1]))}if(s.tracksPerGroup=i,e&&e.duration||(s.duration=o),e.tracksPerGroup){s.tracks.forEach((e,t)=>{e.groupId=null,e.groupTrackIdx=-1}),s.tracksPerGroup={};let t=e.tracksPerGroup;for(let e in t){const i=t[e],o=[];for(let t=0;t<i.length;++t){const n=s.tracks[i[t].trackIdx];o[t]=n,n.groupId=e,n.groupTrackIdx=t}s.tracksPerGroup[e]=o}}}return s}deselectAllElements(){this.deselectAllKeyFrames(),this.unHoverAll()}changeSelectedItems(e=null,t=null,s=!1){this.deselectAllElements(),this.deselectAllTracks(!1);const i=this.animationClip.tracks,o=this.animationClip.tracksPerGroup;if(t)for(let e=0;e<t.length;++e){const s=!!t[e].substr;let n=s?t[e]:i[t[e]];for(let e=0;e<this.selectedItems.length;++e)if(this.selectedItems[e]===n){const t=s?o[n].length:1;this.selectedItems.splice(e,t);break}}if(e)for(let t=0;t<e.length;++t){const s=e[t];isNaN(s)?o[s]&&this.selectedItems.push(s):i[s]&&this.selectedItems.push(i[s])}this.updateLeftPanel(),this.onItemSelected&&!s&&this.onItemSelected(this.selectedItems,e,t)}setTracksGroup(e,t=null){const s=this.animationClip.tracks,i=this.animationClip.tracksPerGroup,o=[];let n=-1;if(i[e]){i[e].forEach(e=>{e.groupId=null,e.groupTrackIdx=-1});for(let t=0;t<this.selectedItems.length;++t)if(this.selectedItems[t]===e){n=t;break}}if(!t)return delete i.groupId,void(n>-1&&this.selectedItems.splice(n,1));for(let i=0;i<t.length;++i){const n=t[i];let a=null;if("string"==typeof n){for(let e=0;e<s.length;++e)if(s[e].id==n){a=s[e];break}}else s[n]&&(a=s[n]);a&&(a.groupId=e,a.groupTrackIdx=o.length,o.push(a))}i[e]=o,n>-1&&this.updateLeftPanel()}getTracksGroup(e){return this.animationClip.tracksPerGroup[e]??null}getTrack(e,t=null){let s=this.animationClip.tracks;t&&(s=this.animationClip.tracksPerGroup[t]??[]);for(let t=0;t<s.length;++t)if(s[t].id==e)return s[t];return null}setKeyframeSize(e,t=null){this.keyframeSizeHovered=t??e,this.keyframeSize=e}onMouseUp(e,t){let s=e.track,i=e.localX,o=e.discard;if(e.shiftKey){if(!o&&s){const e=.5*this.keyframeSize,t=this.getCurrentKeyFrame(s,this.xToTime(i),this.secondsPerPixel*e);t>-1&&(s.selected[t]?this.deselectKeyFrame(s.trackIdx,t):this.processSelectionKeyFrame(s.trackIdx,t,!0))}else if(this.boxSelection){let e=this.getTracksInRange(this.boxSelectionStart[1],this.boxSelectionEnd[1]);for(let t of e){let e=this.getKeyFramesInRange(t,this.xToTime(this.boxSelectionStart[0]),this.xToTime(this.boxSelectionEnd[0]),5*this.secondsPerPixel);if(e)for(let s=e[0];s<=e[1];++s)this.processSelectionKeyFrame(t.trackIdx,s,!0)}}}else if(!this.movingKeys&&!o&&(this.lastKeyFramesSelected.length&&(this.onDeselectKeyFrames&&this.onDeselectKeyFrames(this.lastKeyFramesSelected),this.deselectAllKeyFrames()),s)){const e=.5*this.keyframeSize,t=this.getCurrentKeyFrame(s,this.xToTime(i),this.secondsPerPixel*e);t>-1&&this.processSelectionKeyFrame(s.trackIdx,t,!1)}this.canvas.classList.remove("grabbing")}onMouseDown(e,t){let s=e.localX;if(e.localY,e.track,(e.ctrlKey||e.altKey)&&this.lastKeyFramesSelected.length){this.movingKeys=!0,this.canvas.style.cursor="grab",this.canvas.classList.add("grabbing"),this.moveKeyMinTime=1/0;const e=this.animationClip.tracks;let t=-1;for(let s of this.lastKeyFramesSelected){let[i,o,n]=s;const a=e[i];s[2]=a.times[o],t!=i&&(this.moveKeyMinTime<1/0?this.saveState(a.trackIdx,!0):this.saveState(a.trackIdx,!1),this.moveKeyMinTime=Math.min(this.moveKeyMinTime,s[2]),t=i)}this.timeBeforeMove=this.xToTime(s),this.grabbing=!1,this.grabbingTimeBar=!1}}onMouseMove(e,t){let s=e.localX;e.localY;let i=e.track;if(this.movingKeys){let t=this.xToTime(s)-this.timeBeforeMove;if(t+this.moveKeyMinTime<0&&(t=-this.moveKeyMinTime),this.timeBeforeMove=this.timeBeforeMove+t,e.ctrlKey){this.moveKeyMinTime+=t;const e=this.animationClip.tracks;for(let s=0;s<this.lastKeyFramesSelected.length;++s){let o=s;t>0&&(o=this.lastKeyFramesSelected.length-1-s);const[n,a,l]=this.lastKeyFramesSelected[o];if(i=e[n],i&&i.locked)continue;this.canvas.style.cursor="grabbing";const r=this.animationClip.tracks[i.trackIdx].times;r[a]=Math.max(0,r[a]+t),r[a]>this.duration&&this.setDuration(r[a]);let c=a;if(t>0)for(;c<r.length-1&&!(r[c]<r[c+1]);++c)this.swapKeyFrames(i,c+1,c);else for(;c>0&&!(r[c-1]<r[c]);--c)this.swapKeyFrames(i,c-1,c);this.lastKeyFramesSelected[o][1]=c,this.lastKeyFramesSelected[o][2]=r[c]}if(this.onContentMoved)for(let e=0;e<this.lastKeyFramesSelected.length;++e){const[t,s,o]=this.lastKeyFramesSelected[e];i=this.animationClip.tracks[t],i&&i.locked||this.onContentMoved(t,s)}}if(e.altKey&&1&e.buttons){const t=this.animationClip.tracks;let s=-1;for(let o=0;o<this.lastKeyFramesSelected.length;++o){const[n,a,l]=this.lastKeyFramesSelected[o];if(i=t[n],i.locked||1!=i.dim||!i.curves)continue;let r=i.values[a],c=e.deltay*this.keyValuePerPixel*(i.curvesRange[1]-i.curvesRange[0]);i.values[a]=Math.max(i.curvesRange[0],Math.min(i.curvesRange[1],r-c)),i.edited[a]=!0,this.onUpdateTrack&&i.trackIdx!=s&&s>-1&&this.onUpdateTrack([i.trackIdx]),s=i.trackIdx}return void(this.onUpdateTrack&&s>-1&&this.onUpdateTrack([i.trackIdx]))}}if(this.grabbing&&2!=e.button);else if(i){this.unHoverAll();const e=.5*this.keyframeSize;let t=this.getCurrentKeyFrame(i,this.xToTime(s),this.secondsPerPixel*e);if(t>-1){if(i&&i.locked)return;this.lastHovered=[i.trackIdx,t],i.hovered[t]=!0}}else this.unHoverAll()}drawContent(e){if(!this.animationClip)return;e.save();const t=this.trackHeight,s=-this.currentScrollInPixels,i=this.getVisibleItems();let o=s,n=0;o<-this.lastTrackTreesComponentOffset&&(n=Math.floor(-(o+this.lastTrackTreesComponentOffset)/this.trackHeight),o+=n*this.trackHeight),e.translate(0,o);let a=n+Math.ceil((e.canvas.height-this.lastTrackTreesComponentOffset-o)/this.trackHeight);a=a>i.length?i.length:a;for(let s=n;s<a;s++){const o=i[s].treeData.trackData;o&&(1==o.dim&&o.curves?this.drawTrackWithCurves(e,t,o):this.drawTrackWithKeyframes(e,t,o)),e.translate(0,t)}e.restore()}drawTrackWithKeyframes(e,t,s){s.isSelected&&(e.globalAlpha=.2,e.fillStyle=bt.TRACK_SELECTED,e.fillRect(0,0,e.canvas.width,t)),e.fillStyle=bt.KEYFRAME_COLOR,e.globalAlpha=1;const i=s.times,o=this.visualTimeRange[0],n=this.visualTimeRange[1]+1e-7,a=this.keyframeSize/Math.SQRT2,l=this.keyframeSizeHovered/Math.SQRT2;for(let r=0;r<i.length;++r){let c=i[r];if(c<o||c>n)continue;let h=this.timeToX(c),d=a;this.active&&0!=s.active?s.locked?e.fillStyle=bt.KEYFRAME_COLOR_LOCK:s.hovered[r]?(d=l,e.fillStyle=bt.KEYFRAME_COLOR_HOVERED):s.selected[r]?e.fillStyle=bt.KEYFRAME_COLOR_SELECTED:s.edited[r]?e.fillStyle=bt.KEYFRAME_COLOR_EDITED:e.fillStyle=bt.KEYFRAME_COLOR:e.fillStyle=bt.KEYFRAME_COLOR_INACTIVE,e.save(),e.translate(h,.5*t),e.rotate(45*Math.PI/180),e.fillRect(.5*-d,.5*-d,d,d),e.restore()}e.globalAlpha=1}drawTrackWithCurves(e,s,i){i.isSelected&&(e.globalAlpha=.2,e.fillStyle=bt.TRACK_SELECTED_LIGHT,e.fillRect(0,0,e.canvas.width,s)),e.globalAlpha=1;const o=i.times,n=i.values,a=.5*this.keyframeSize,l=.5*this.keyframeSizeHovered,r=i.curvesRange,c=s-2*a,h=this.visualTimeRange[0],d=this.visualTimeRange[1]+1e-7;if(e.strokeStyle=_t.FONT_COLOR_PRIMARY,e.beginPath(),o.length>1){let i=this.timeToX(o[0]),l=n[0];l=t.clamp((l-r[0])/(r[1]-r[0]),0,1)*-c+(s-a),e.moveTo(i,l);for(let i=1;i<o.length;++i){let l=o[i],u=this.timeToX(l),p=n[i];if(p=t.clamp((p-r[0])/(r[1]-r[0]),0,1)*-c+(s-a),l<h)e.moveTo(u,p);else{if(l>d){let l=this.timeToX(o[i-1]),h=u-l;if(h>0){let o=n[i-1];o=t.clamp((o-r[0])/(r[1]-r[0]),0,1)*-c+(s-a);let u=(this.timeToX(d)-l)/h;e.lineTo(l+h*u,o*(1-u)+p*u)}break}e.lineTo(u,p)}}e.stroke()}e.fillStyle=bt.KEYFRAME_COLOR;for(let u=0;u<o.length;++u){let p=o[u];if(p<h||p>d)continue;let m=a,g=this.timeToX(p);this.active&&i.active?i.locked?e.fillStyle=bt.KEYFRAME_COLOR_LOCK:i.hovered[u]?(m=l,e.fillStyle=bt.KEYFRAME_COLOR_HOVERED):i.selected[u]?e.fillStyle=bt.KEYFRAME_COLOR_SELECTED:i.edited[u]?e.fillStyle=bt.KEYFRAME_COLOR_EDITED:e.fillStyle=bt.KEYFRAME_COLOR:e.fillStyle=bt.KEYFRAME_COLOR_INACTIVE;let f=n[u];f=t.clamp((f-r[0])/(r[1]-r[0]),0,1)*-c+(s-a),e.beginPath(),e.arc(g,f,m,0,2*Math.PI),e.fill(),e.closePath()}}_getValidTrackName(e){let t,s=null,i=null;if(e.includes("[")){const s=e.indexOf("[");t=e.substring(s+1).split("].")}else t=e.split(".");return t.length>1?(s=t[0],i=t[1]):i=t[0],[s,i]}updateTrack(e,t){if(!this.animationClip)return!1;const s=this.animationClip.tracks[e];return s.values=t.values,s.times=t.times,s.selected=t.selected??new Array(s.times.length).fill(!1),s.hovered=t.hovered??new Array(s.times.length).fill(!1),s.edited=t.edited??new Array(s.times.length).fill(!1),!0}optimizeTrack(e,t=!1,s=!1){if(!this.animationClip)return;const i=this.animationClip.tracks[e],o=i.times,n=i.values,a=i.dim,l=this.optimizeThreshold;if(i.locked)return;let r=(e,t,s,i)=>Math.abs(e-t)>=i||Math.abs(e-s)>=i,c=0;const h=o.length-1;this.saveState(i.trackIdx);for(let e=1;e<h;++e){let s=!1;if(o[e]!==o[c])if(t)s=!0;else{const t=e*a,i=c*a,o=t+a;for(let e=0;e!==a;++e)if(r(n[t+e],n[i+e],n[o+e],l)){s=!0;break}}if(s&&(++c,e!==c)){o[c]=o[e];const t=e*a,s=c*a;for(let e=0;e!==a;++e)n[s+e]=n[t+e]}}if(o.length>1){++c,o[c]=o[o.length-1];const e=n.length-a,t=c*a;for(let s=0;s!==a;++s)n[t+s]=n[e+s]}c<o.length-1&&(i.times=o.slice(0,c+1),i.values=n.slice(0,(c+1)*a),this.updateTrack(i.trackIdx,i)),this.onOptimizeTracks&&!s&&this.onOptimizeTracks(e)}optimizeTracks(e=!1){if(!this.animationClip)return;if(this.historySaveEnabler)for(let e=0;e<this.animationClip.tracks.length;++e)this.saveState(e,0!=e);const t=this.historySaveEnabler;this.historySaveEnabler=!1;for(let t=0;t<this.animationClip.tracks.length;++t){const s=this.animationClip.tracks[t];this.optimizeTrack(s.trackIdx,e,!0)}this.historySaveEnabler=t,this.onOptimizeTracks&&this.onOptimizeTracks(-1)}historyGenerateTrackStep(e){const t=this.animationClip.tracks[e];return{trackIdx:e,t:t.times.slice(),v:t.values.slice(),edited:t.edited.slice(0,t.times.length)}}historyApplyTrackStep(e,t){const s=this.animationClip.tracks[e.trackIdx],i={trackIdx:e.trackIdx,t:s.times,v:s.values,edited:s.edited};return s.times=e.t,s.values=e.v,s.edited=e.edited,s.selected.length!=s.times.length&&(s.selected.length=s.times.length),s.hovered.length!=s.times.length&&(s.hovered.length=s.times.length),s.selected.fill(!1),s.hovered.fill(!1),i}swapKeyFrames(e,t,s){const i=e.times,o=e.values;let n=i[t];i[t]=i[s],i[s]=n,n=e.hovered[t],e.hovered[t]=e.hovered[s],e.hovered[s]=n,n=e.edited[t],e.edited[t]=e.edited[s],e.edited[s]=n,n=e.selected[t],e.selected[t]=e.selected[s],e.selected[s]=n;let a=t*e.dim,l=a+e.dim,r=s*e.dim;for(;a<l;++a)n=o[a],o[a]=o[r],o[r]=n,++r}copySelectedContent(){if(!this.lastKeyFramesSelected.length)return;this.clipboard=this.clipboard??{},this.clipboard.keyframes={};let e={};const t=this.animationClip.tracks;for(let s=0;s<this.lastKeyFramesSelected.length;s++){let[i,o]=this.lastKeyFramesSelected[s];const n=t[i];e[i]?e[i].idxs.push(o):e[i]={track:n,idxs:[o]},0==s&&this.copyKeyFrameValue(n,o)}for(let t in e)this.copyKeyFrames(e[t].track,e[t].idxs)}copyKeyFrameValue(e,t){const s=t*e.dim,i=this.animationClip.tracks[e.trackIdx].values.slice(s,s+e.dim);this.clipboard=this.clipboard??{},this.clipboard.value={type:e.type,values:i}}copyKeyFrames(e,t){let s=e.trackIdx;this.clipboard=this.clipboard??{},t.sort((e,t)=>e<t?-1:1);let i={track:e,values:[],times:[]};for(let s=0;s<t.length;s++){let o=t[s],n=o*e.dim,a=e.values.slice(n,n+e.dim);i.values.push(a),i.times.push(e.times[o])}this.clipboard.keyframes[s]=i}canPasteKeyFrame(){return null!=this.clipboard}#t(e,t,s){const i=t*e.dim;let o=0;for(let t=i;t<i+e.dim;++t)e.values[t]=s[o],++o;e.edited[t]=!0}pasteContentValue(){if(!this.clipboard)return!1;if(this.clipboard.value&&1==this.lastKeyFramesSelected.length){let[e,t]=this.lastKeyFramesSelected[0];return this.pasteKeyFrameValue(this.animationClip.tracks[e],t),!0}return!1}pasteContent(e=this.currentTime){if(!this.clipboard)return!1;if(this.clipboard.keyframes){for(let e in this.clipboard.keyframes){const t=this.animationClip.tracks[e];if(-1==this.selectedItems.findIndex(e=>e.isTrack?e===t:e===t.groupId))return!1}this.pasteKeyFrames(e)}return!0}pasteKeyFrameValue(e,t){e.locked||this.clipboard.value.type!=e.type||(this.saveState(e.trackIdx),this.#t(e,t,this.clipboard.value.values),this.onUpdateTrack&&this.onUpdateTrack([e.trackIdx]))}pasteKeyFrames(e=this.currentTime){if(!this.clipboard.keyframes)return!1;this.unHoverAll(),this.deselectAllKeyFrames();let t=this.clipboard.keyframes,s=1/0;for(let e in t)s>t[e].times[0]&&(s=t[e].times[0]);if(s==1/0)return!1;const i=this.onUpdateTrack;this.onUpdateTrack=null;const o=this.historySaveEnabler;let n=0;for(let i in t){const t=this.clipboard.keyframes[i],a=t.times,l=t.values,r=this.animationClip.tracks[i];r.locked||(this.saveState(r.trackIdx,Boolean(n++)),this.historySaveEnabler=!1,this.addKeyFrames(r.trackIdx,l,a,-s+e,_t.ADDKEY_VALUESINARRAYS),this.historySaveEnabler=o)}return i&&(this.onUpdateTrack=i,this.onUpdateTrack(Object.keys(t))),!0}addKeyFrames(e,t,s,i=0,o=0){const n=this.animationClip.tracks[e];if(!s.length||n.locked)return null;const a=n.dim,l=n.times,r=n.values,c=new Float32Array(l.length+s.length),h=new Float32Array(r.length+s.length*a);this.saveState(e);let d=s.length-1,u=l.length-1,p=[];if(_t.ADDKEY_VALUESINARRAYS&o)for(let e=c.length-1;e>-1;--e){if(u<0||d>-1&&l[u]<s[d]+i){const o=t[d];for(let t=0;t<a;++t)h[e*a+t]=o[t];c[e]=s[d--]+i,n.hovered.splice(u+1,0,!1),n.selected.splice(u+1,0,!1),n.edited.splice(u+1,0,!0),p.push(e);continue}for(let t=0;t<a;++t)h[e*a+t]=r[u*a+t];c[e]=l[u--]}else for(let e=c.length-1;e>-1;--e)if(u<0||d>-1&&l[u]<s[d]+i){for(let s=0;s<a;++s)h[e*a+s]=t[d*a+s];c[e]=s[d--]+i,n.hovered.splice(u+1,0,!1),n.selected.splice(u+1,0,!1),n.edited.splice(u+1,0,!0),p.push(e)}else{for(let t=0;t<a;++t)h[e*a+t]=r[u*a+t];c[e]=l[u--]}return n.times=c,n.values=h,s[s.length-1]+i>this.duration&&this.setDuration(s[s.length-1]+i),this.onUpdateTrack&&this.onUpdateTrack([e]),p}deleteSelectedContent(e=!1){if(!this.lastKeyFramesSelected.length)return;const t=this.animationClip.tracks,s=this.lastKeyFramesSelected[0][0];let i=s,o=[];const n=this.historySaveEnabler,a=this.lastKeyFramesSelected.length;for(let l=0;l<a;++l){const[a,r]=this.lastKeyFramesSelected[l];t[a].locked?t[a].selected[r]=!1:(i!=a&&(this.saveState(i,i!=s),this.historySaveEnabler=!1,this.deleteKeyFrames(i,o,e),this.historySaveEnabler=n,i=a,o.length=0),o.push(r))}this.saveState(i,i!=s),this.historySaveEnabler=!1,this.deleteKeyFrames(i,o,e),this.historySaveEnabler=n,this.lastKeyFramesSelected=[]}deleteKeyFrames(e,t,s=!1){const i=this.animationClip.tracks[e];if(!t.length||i.locked)return!1;this.saveState(e);const o=i.times.length,n=i.times.length-t.length,a=i.times.slice(0,n),l=i.values.slice(0,n*i.dim);let r=t[0],c=t[0]*i.dim;for(let e=0;e<t.length;++e){i.edited.splice(r,1),i.selected.splice(r,1),i.hovered.splice(r,1);const s=t[e],n=e<t.length-1?t[e+1]:o,h=n*i.dim;for(let e=(s+1)*i.dim;e<h;++e)l[c++]=i.values[e];for(let e=s+1;e<n;++e)a[r++]=i.times[e]}return i.times=a,i.values=l,this.onDeleteKeyFrames&&!s&&this.onDeleteKeyFrames(e,t),a[a.length-1]>this.duration&&this.setDuration(a[a.length-1]),!0}getNearestKeyFrame(e,t,s=0){if(!e||!e.times||!e.times.length)return-1;const i=e.times;let o=0,n=i.length-1;if(i[o]>t)return-1==s?-1:0;if(i[n]<t)return 1==s?-1:n;let a=Math.floor((o+n)/2);for(;o<a&&a<n;)t<i[a]?n=a:o=a,a=Math.floor((o+n)/2);return 0==s?Math.abs(t-i[o])<Math.abs(t-i[n])?o:n:-1==s?i[n]==t?n:o:i[o]==t?o:n}getCurrentKeyFrame(e,t,s=0){if(!e||!e.times.length)return-1;let i=this.getNearestKeyFrame(e,t);return i>-1&&(i=Math.abs(e.times[i]-t)>s?-1:i),i}getKeyFramesInRange(e,t,s,i=0){if(!e||!e.times.length)return null;if(t>s){let e=t;t=s,s=e}const o=this.getNearestKeyFrame(e,t-i,1),n=this.getNearestKeyFrame(e,s+i,-1);return-1==n||-1==o?null:[o,n]}unHoverAll(){this.lastHovered&&(this.animationClip.tracks[this.lastHovered[0]].hovered[this.lastHovered[1]]=!1);let e=this.lastHovered;return this.lastHovered=null,e}deselectAllKeyFrames(){for(let[e,t]of this.lastKeyFramesSelected)this.animationClip.tracks[e].selected[t]=!1;const e=this.lastKeyFramesSelected.length>0;return this.lastKeyFramesSelected.length=0,e}isKeyFrameSelected(e,t){return e.selected[t]}selectKeyFrame(e,t,s=!1){const i=this.animationClip.tracks[e];if(i.locked||!i.active||i.selected[t])return null;const o=[i.trackIdx,t,i.times[t]];let n=0;for(;n<this.lastKeyFramesSelected.length;++n){let s=this.lastKeyFramesSelected[n];if(s[0]>e||s[0]==e&&s[1]>t)break}return this.lastKeyFramesSelected.splice(n,0,o),i.selected[t]=!0,this.onSelectKeyFrame&&!s&&this.onSelectKeyFrame(o),o}deselectKeyFrame(e,t){const s=this.animationClip.tracks[e];if(s.locked||!s.active||!s.selected[t])return!1;s.selected[t]=!1;for(let s=0;s<this.lastKeyFramesSelected.length;++s){const i=this.lastKeyFramesSelected[s];if(i[0]===e&&i[1]===t){this.lastKeyFramesSelected.splice(s,1);break}}return!0}getNumKeyFramesSelected(){return this.lastKeyFramesSelected.length}processSelectionKeyFrame(e,t,s=!1){const i=this.animationClip.tracks[e];i.locked||(s||this.deselectAllKeyFrames(),this.selectKeyFrame(e,t),s||this.setTime(i.times[t]))}clearTrack(e){const t=this.animationClip.tracks[e];if(this.unHoverAll(),this.deselectAllKeyFrames(),!t.locked)return this.saveState(t.trackIdx),t.times=t.times.slice(0,0),t.values=t.values.slice(0,0),t.edited.length=0,t.hovered.length=0,t.selected.length=0,e}}t.KeyFramesTimeline=_t;class xt extends bt{static CLONEREASON_COPY=1;static CLONEREASON_PASTE=2;static CLONEREASON_HISTORY=3;static CLONEREASON_TRACKCLONE=4;lastClipsSelected=[];lastTrackClipsMove=0;dragClipMode="";lastHovered=null;onSelectClip=null;onContentMoved=null;onDeleteSelectedClips=null;onDeleteClip=null;constructor(e,s={}){super(e,s),this.lastClipsSelected=[],this.lastTrackClipsMove=0,this.dragClipMode="",this.setAnimationClip(this.animationClip),this.onDblClick=e=>{const t=e.track,s=e.localX;if(t){const e=this.getClipOnTime(t,this.xToTime(s),.001);this.selectClip(t.trackIdx,e)}},this.onShowContextMenu=e=>{e.preventDefault(),e.stopPropagation();let s=[];this.lastClipsSelected.length?(s.push({title:"Copy",callback:()=>{this.copySelectedContent()}}),s.push({title:"Delete",callback:()=>{this.deleteSelectedContent()}})):this.clipboard&&(s.push({title:"Paste",callback:()=>{this.pasteContent()}}),s.push({title:"Paste Here",callback:()=>{this.pasteContent(this.xToTime(e.localX))}})),t.addContextMenu("Options",e,e=>{for(let t=0;t<s.length;t++)e.add(s[t].title,s[t].callback)})}}instantiateAnimationClip(e,t=!1){const s=super.instantiateAnimationClip(e);if(e&&e.tracks)for(let i=0;i<e.tracks.length;++i){const o=this.instantiateTrack(e.tracks[i],t);o.trackIdx=s.tracks.length,s.tracks.push(o)}return s}instantiateTrack(e={},t=!1){const s=super.instantiateTrack(e);s.trackIdx=this.animationClip.tracks.length,s.selected=[],s.edited=[],s.hovered=[],e.clips?s.clips=t?this.cloneClips(e.clips,0,xt.CLONEREASON_TRACKCLONE):e.clips:s.clips=[];const i=s.clips.length;e.selected&&e.selected.length==i?s.selected=t?e.selected.slice():e.selected:s.selected=new Array(i).fill(!1),e.edited&&e.edited.length==i?s.edited=t?e.edited.slice():e.edited:s.edited=new Array(i).fill(!1),e.hovered&&e.hovered.length==i?s.hovered=t?e.hovered.slice():e.hovered:s.hovered=new Array(i).fill(!1);for(let e=0;e<s.clips.length;++e)s.clips[e].active=s.clips[e].active??!0;return s}instantiateClip(e={}){return{id:e.id??e.name??"clip",start:e.start??0,duration:e.duration??1,fadein:e.fadein??void 0,fadeout:e.fadeout??void 0,clipColor:e.clipColor??t.getThemeColor("global-color-accent"),fadeColor:e.fadeColor??null,active:e.active??!0,trackIdx:-1}}addNewTrack(e={},t=!0,s=!1){const i=this.instantiateTrack(e??{});return i.trackIdx=this.animationClip.tracks.length,this.animationClip.tracks.push(i),this.onAddNewTrack&&!s&&this.onAddNewTrack(i,e),this.selectedItems.push(i),t&&this.updateLeftPanel(),i.trackIdx}setAnimationClip(e,t=!0){return super.setAnimationClip(e,t),this.changeSelectedItems(),this.animationClip}deselectAllElements(){this.deselectAllClips(),this.unHoverAll()}changeSelectedItems(){this.deselectAllElements(),this.deselectAllTracks(!1),this.selectedItems=this.animationClip.tracks.slice(),this.updateLeftPanel()}unHoverAll(){this.lastHovered&&(this.animationClip.tracks[this.lastHovered[0]].hovered[this.lastHovered[1]]=!1);let e=this.lastHovered;return this.lastHovered=null,e}onMouseUp(e){let t=e.track,s=e.localX,i=e.discard;if(e.shiftKey){if(i){if(this.boxSelection){let e=this.getTracksInRange(this.boxSelectionStart[1],this.boxSelectionEnd[1]);for(let t of e){let e=this.getClipsInRange(t,this.xToTime(this.boxSelectionStart[0]),this.xToTime(this.boxSelectionEnd[0]),1e-6);if(e)for(let s of e)this.selectClip(t.trackIdx,s,!1)}}}else if(t){let e=this.getClipOnTime(t,this.xToTime(s),5*this.secondsPerPixel);e>-1&&(t.selected[e]?this.deselectClip(t.trackIdx,e):this.selectClip(t.trackIdx,e,!1))}}else{let o=this.canvas.getBoundingClientRect();if(e.y<o.top||e.y>o.bottom)return;if(!i&&t&&2!=e.button){const e=this.getClipOnTime(t,this.xToTime(s),.001);this.selectClip(t.trackIdx,e)}}this.movingKeys=!1}onMouseDown(e,t){let s=e.localX;e.localY;let i=e.track;if(!(e.button>0))if(e.ctrlKey&&i){let t=e.offsetX;const s=this.lastClipsSelected;this.canvas.style.cursor="grab";let i=-1;this.lastTrackClipsMove=Math.floor((e.localY-this.topMargin+this.trackTreesPanel.root.scrollTop)/this.trackHeight);for(let e=0;e<s.length;e++){let[o,n]=s[e];const a=this.animationClip.tracks[o].clips[n];let l=this.timeToX(a.start+a.duration);Math.abs(l-t)<5?(this.dragClipMode="duration",this.canvas.style.cursor="column-resize"):this.dragClipMode="move",i!=o&&(this.saveState(o,-1!=i),i=o)}this.movingKeys=!0}else if(!i||i&&-1==this.getClipOnTime(i,t,.001))this.lastClipsSelected.length&&(this.deselectAllClips(),this.onSelectClip&&this.onSelectClip(null));else if(i&&("duration"==this.dragClipMode||"fadein"==this.dragClipMode||"fadeout"==this.dragClipMode)){const e=this.getClipOnTime(i,this.xToTime(s),.001);this.selectClip(i.trackIdx,e),this.lastClipsSelected.length&&this.saveState(i.trackIdx),this.movingKeys=!0}}onMouseMove(e,t){if(!this.grabbingTimeBar&&!this.grabbingScroll){if(this.grabbing&&2!=e.buttons){this.unHoverAll();let s=t-this.grabTime;if(this.grabTime=t,t<0&&s>0&&(s=0),"move"!=this.dragClipMode&&1==this.lastClipsSelected.length){const e=this.animationClip.tracks[this.lastClipsSelected[0][0]];let t=e.clips[this.lastClipsSelected[0][1]];if("fadein"==this.dragClipMode)t.fadein=Math.min(Math.max(t.fadein+s,t.start),t.fadeout??t.start+t.duration);else if("fadeout"==this.dragClipMode)t.fadeout=Math.max(Math.min(t.fadeout+s,t.start+t.duration),t.fadein??t.start);else if("duration"==this.dragClipMode){let i=Math.max(0,t.duration+s);this.lastClipsSelected[0][1]<e.clips.length-1&&(i=Math.min(e.clips[this.lastClipsSelected[0][1]+1].start-t.start-1e-4,i)),t.duration=i,null!=t.fadeout&&(t.fadeout=Math.max(Math.min((t.fadeout??t.start+t.duration)+s,t.start+t.duration),t.start)),null!=t.fadein&&(t.fadein=Math.max(Math.min(t.fadein??t.start+t.duration,t.fadeout??t.start+t.duration),t.start)),this.duration<t.start+t.duration&&this.setDuration(t.start+t.duration)}this.onContentMoved&&this.onContentMoved(t,0)}else if("move"==this.dragClipMode&&this.lastClipsSelected.length){const i=this.lastTrackTreesComponentOffset;let o=Math.floor((e.localY-i)/this.trackHeight);if(e.altKey){let e=o-this.lastTrackClipsMove;if(this.lastClipsSelected[0][0]+e<0&&(e=-this.lastClipsSelected[0][0]),0!=e){for(let t=0;t<this.lastClipsSelected.length;++t){const s=this.animationClip.tracks[this.lastClipsSelected[t][0]],i=this.animationClip.tracks[this.lastClipsSelected[t][0]+e],n=s.clips[this.lastClipsSelected[t][1]],a=this.getClipsInRange(i,n.start,n.start+n.duration,1e-4);if(a)for(let s=0;s<a.length;++s)i.selected[a[s]]||(s=a.length,t=this.lastClipsSelected.length,e=0,o=this.lastTrackClipsMove)}if(0!=e){let t=this.historySaveEnabler;this.historySaveEnabler=!1;const s=this.lastClipsSelected;this.lastClipsSelected=[];for(let t=s[s.length-1][0]+e-this.animationClip.tracks.length+1;t>0;--t)this.addNewTrack(null,1==t),1==t&&this.updateLeftPanel();let i=e>0?s.length-1:0,o=i,n=s[i][0];for(let t=1;t<=s.length;++t){let a=e>0?s.length-1-t:t;if(t==s.length||s[a][0]!=n){const l=n+e,r=this.animationClip.tracks[l],c=this.animationClip.tracks[n],h=this.historyUndo[this.historyUndo.length-1];let d=0;for(;d<h.length&&l!=h[d].trackIdx;++d);d==h.length&&(this.historySaveEnabler=!0,this.saveState(l,!0),this.historySaveEnabler=!1);for(let e=i;e<=o;++e){let t=this.addClip(c.clips[s[e][1]],l,0);s[e][0]=t,r.selected[t]=!0}for(let e=o;e>=i;--e)this.#s(n,s[e][1]),s[e][1]=s[e][0],s[e][0]=l;n=t<s.length?s[a][0]:-1,i=a,o=a;continue}e>0?i=a:o=a}this.lastClipsSelected=s,this.historySaveEnabler=t}}}this.lastTrackClipsMove=o;let n=s,a=!0;for(let e=0;e<this.lastClipsSelected.length;++e){let t=this.lastClipsSelected[e][0],i=this.lastClipsSelected[e][1];const o=this.animationClip.tracks[t],l=o.clips,r=o.clips[i];if(s>=0){if(l.length-1==i)continue;if(!o.selected[i+1]){if(l[i+1].start>=r.start+r.duration+s)continue;const e=l[i+1];n=Math.max(0,Math.min(n,e.start-r.start-r.duration))}}else if(s<0){if(i>0&&l[i-1].start+l[i-1].duration<=r.start+s)continue;if(i>0){const e=l[i-1];n=Math.min(0,Math.max(n,e.start+e.duration-r.start))}r.start+s<0&&(n=Math.max(n,-r.start),a=!1)}if(!a)continue;let c=this.getClipsInRange(o,r.start+s,r.start+r.duration+s,.01);if(c&&(c[0]!=i||c[c.length-1]!=i))for(let e=0;e<c.length;++e)if(!o.selected[c[e]]){a=!1;break}}a&&(n=s),this.grabTime=t-s+n;for(let e=0;e<this.lastClipsSelected.length;++e){const t=this.lastClipsSelected[s>0?this.lastClipsSelected.length-1-e:e],i=this.animationClip.tracks[t[0]],o=i.clips;let a=t[1];const l=i.clips[a];l.start+=n,null!=l.fadein&&(l.fadein+=n),null!=l.fadeout&&(l.fadeout+=n);const r=i.edited[a],c=i.selected[a],h=i.hovered[a];if(s>0)for(;a<o.length-1&&!(o[a+1].start>=l.start);)o[a]=o[a+1],i.selected[a]=i.selected[a+1],i.edited[a]=i.edited[a+1],i.hovered[a]=i.hovered[a+1],a++;else for(;a>0&&!(o[a-1].start<=l.start);)o[a]=o[a-1],i.selected[a]=i.selected[a-1],i.edited[a]=i.edited[a-1],i.hovered[a]=i.hovered[a-1],a--;o[a]=l,i.edited[a]=r,i.selected[a]=c,i.hovered[a]=h,t[1]=a,l.start+l.duration>this.duration&&this.setDuration(l.start+l.duration),this.onContentMoved&&this.onContentMoved(l,n)}}return!0}if(e.track&&0==e.buttons){this.unHoverAll();let s=this.getClipsInRange(e.track,t,t,1e-5);if(!e.track.locked&&s){this.lastHovered=[e.track.trackIdx,s[0]],e.track.hovered[s[0]]=!0;let t=e.track.clips[s[0]];if(!t)return;Math.abs(e.localX-this.timeToX(t.start+t.duration))<8?(this.canvas.style.cursor="col-resize",this.dragClipMode="duration"):null!=t.fadein&&Math.abs(e.localX-this.timeToX(t.fadein))<8?(this.canvas.style.cursor="e-resize",this.dragClipMode="fadein"):null!=t.fadeout&&Math.abs(e.localX-this.timeToX(t.fadeout))<8?(this.canvas.style.cursor="e-resize",this.dragClipMode="fadeout"):this.dragClipMode=""}}else this.unHoverAll()}}drawContent(e){if(!this.animationClip)return;const t=this.animationClip.tracks,s=this.trackHeight,i=-this.currentScrollInPixels;e.save();for(let o=0;o<t.length;o++){let n=t[o];this.drawTrackWithBoxes(e,o*s+i,s,n)}e.restore()}drawTrackWithBoxes(e,t,s,i){e.globalAlpha=.2,e.fillStyle=bt.TRACK_SELECTED_LIGHT,i.isSelected&&e.fillRect(0,t,e.canvas.width,s);const o=i.clips,n=.4*s*.5;s*=.6;let a=null;e.font=Math.floor(.8*s)+"px"+bt.FONT,e.textAlign="left",e.textBaseline="middle";for(var l=0;l<o.length;++l){a=null;const d=o[l];var r=Math.floor(this.timeToX(d.start))+.5,c=Math.floor(this.timeToX(d.start+d.duration))+.5,h=c-r;if(c<0||r>this.canvas.width)continue;if(e.globalAlpha=1,e.fillStyle=d.clipColor||(i.hovered[l]?bt.KEYFRAME_COLOR_HOVERED:i.selected[l]?bt.TRACK_SELECTED:bt.KEYFRAME_COLOR),this.active&&i.active&&d.active||(e.fillStyle=bt.KEYFRAME_COLOR_INACTIVE),Lt(e,r,t+n,h,s,5,!0),this.active&&i.active&&d.active){if(e.fillStyle=d.fadeColor??"#0004",null!=d.fadein){Lt(e,r,t+n,this.pixelsPerSecond*(d.fadein-d.start),s,{tl:5,bl:5,tr:0,br:0},!0)}if(null!=d.fadeout){const i=this.pixelsPerSecond*(d.start+d.duration-d.fadeout);Lt(e,r+h-i,t+n,i,s,{tl:0,bl:0,tr:5,br:5},!0)}}e.fillStyle=bt.TRACK_COLOR_PRIMARY,(i.selected[l]||i.hovered[l])&&(e.strokeStyle=e.shadowColor=d.clipColor||bt.TRACK_SELECTED,e.shadowBlur=10,e.shadowOffsetX=1.5,e.shadowOffsetY=1.5,a=[r-1,t+n-1,c-r+2,s+2],Lt(e,a[0],a[1],a[2],a[3],5,!1,!0),e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.font="bold"+Math.floor(s)+"px "+bt.FONT,e.fillStyle=bt.FONT_COLOR_PRIMARY);let u=d.id??"";let p=e.measureText(u).width;if(p>h&&p>0){let e=Math.floor(h*u.length/p);u=u.substr(0,e),p=h}e.fillText(u,r+.5*(h-p),t+n+.5*s),e.fillStyle=i.hovered[l]?"white":"#f5f5f5",e.strokeStyle="rgba(125,125,125,0.4)",Lt(e,r+h-8,t+n,8,s,{tl:4,bl:4,tr:4,br:4},!0,!0)}e.font="12px"+bt.FONT}optimizeTrack(e){}optimizeTracks(){}addClip(e,s=-1,i=0,o=0){if(!this.animationClip)return-1;this.deselectAllElements();let n=e.start+i;if(null!=e.fadein&&(e.fadein+=n-e.start),null!=e.fadeout&&(e.fadeout+=n-e.start),e.start=n,e.active=e.active??!0,s>=this.animationClip.tracks.length)s=this.addNewTrack();else if(s<0){for(let i=o;i<this.animationClip.tracks.length;i++){if(!this.animationClip.tracks[i].clips.find(s=>t.compareThresholdRange(n,e.start+e.duration,s.start,s.start+s.duration))){s=i;break}}s<0&&(s=this.addNewTrack())}e.trackIdx=s;const a=this.animationClip.tracks[s];let l=a.clips.findIndex(e=>e.start>n);return l<0&&(l=a.clips.length),this.saveState(s),a.clips.splice(l,0,e),a.hovered.splice(l,0,!1),a.selected.splice(l,0,!1),a.edited.splice(l,0,!1),(!this.animationClip||e.start+e.duration>this.duration)&&this.setDuration(e.start+e.duration),this.onUpdateTrack&&this.onUpdateTrack([s]),l}addClips(e,s=0,i=0){if(!this.animationClip||!e.length)return!1;let o=new Int16Array(e.length),n=i-1,a=-1;const l=this.animationClip.tracks,r=l.length;let c=0;for(;c<e.length;++c){const i=e[c],r=i.start+s,h=r+i.duration;if(0==c){for(++n,a=n;a>=l.length;)this.addNewTrack(null,!1);if(l[n].clips.find(e=>t.compareThresholdRange(r,h,e.start,e.start+e.duration))){c=-1;continue}o[c]=n}else{let i=l[a].clips.find(e=>t.compareThresholdRange(r,h,e.start,e.start+e.duration));for(let n=c-1;n>-1&&(o[n]==a&&!i);--n)i=t.compareThresholdRange(r,h,e[n].start+s,e[n].start+s+e[n].duration);if(i&&(++a,a>=l.length&&this.addNewTrack(null,!1),i=l[a].clips.find(e=>t.compareThresholdRange(r,h,e.start,e.start+e.duration))),i){c=-1;continue}o[c]=a}}r!=l.length&&this.updateLeftPanel();for(let e=n;e<=a;++e)this.saveState(e,e!=n);let h=this.historySaveEnabler;for(this.historySaveEnabler=!1,c=0;c<e.length;++c)this.addClip(e[c],o[c],s);return this.historySaveEnabler=h,!0}deleteSelectedContent(e=!1){if(!this.lastClipsSelected.length)return;const t=this.lastClipsSelected;this.lastClipsSelected=[];let s=-1;for(let e=t.length-1;e>-1;--e){let i=t[e];i[0]!=s&&(this.saveState(i[0],-1!=s),s=i[0]),this.#s(i[0],i[1])}this.onDeleteSelectedClips&&!e&&this.onDeleteSelectedClips(t)}deleteClip(e,t,s=!1){this.saveState(e);const i=this.#s(e,t);this.onDeleteClip&&!s&&this.onDeleteClip(e,t,i)}#s(e,t){const s=this.animationClip.tracks[e];for(let s=0;s<this.lastClipsSelected.length;s++){const[i,o]=this.lastClipsSelected[s];if(i==e)o==t?this.lastClipsSelected.splice(s--,1):o>t&&this.lastClipsSelected[s][1]--;else if(e<i)break}this.lastHovered&&this.lastHovered[0]==e&&(this.lastHovered[1]==t?this.unHoverAll():this.lastHovered[1]>t&&this.lastHovered[1]--);const i=s[t];return s.hovered.splice(t,1),s.selected.splice(t,1),s.edited.splice(t,1),s.clips.splice(t,1),i}cloneClips(e,t,s=0){let i=JSON.parse(JSON.stringify(e));for(let e=0;e<i.length;++e){let s=i[e];s.start+=t,null==s.fadein||null==s.fadein?s.fadein=void 0:s.fadein+=t,null==s.fadeout||null==s.fadeout?s.fadeout=void 0:s.fadeout+=t}return i}copySelectedContent(){if(0==this.lastClipsSelected.length)return;let e=[];const t=this.lastClipsSelected,s=this.animationClip.tracks;let i=1/0;for(let o=0;o<t.length;++o){let n=s[t[o][0]].clips[t[o][1]];e.push(n),i>n.start&&(i=n.start)}i=Math.max(0,i),this.clipboard=this.cloneClips(e,-i,xt.CLONEREASON_COPY)}pasteContent(e=this.currentTime){if(this.deselectAllClips(),!this.clipboard)return;e=Math.max(0,e);let t=this.cloneClips(this.clipboard,e,xt.CLONEREASON_PASTE);this.addClips(t,0)}clearTrack(e){if(!this.animationClip)return void(this.animationClip={tracks:[]});if(this.saveState(e),this.animationClip.tracks[e].locked)return;const t=this.animationClip.tracks[e];t.selected=[],t.edited=[],t.hovered=[],t.clips=[];for(let t=0;t<this.lastClipsSelected.length;t++){const[s,i]=this.lastClipsSelected[t];if(s==e)this.lastClipsSelected.splice(t--,1);else if(e<s)break}this.lastHovered&&this.lastHovered[0]==e&&this.unHoverAll()}historyGenerateTrackStep(e){const t=this.animationClip.tracks[e],s=this.cloneClips(t.clips,0,xt.CLONEREASON_HISTORY);for(let t=0;t<s.length;++t)s[t].trackIdx=e;return{trackIdx:e,clips:s,edited:t.edited.slice(0,t.clips.length)}}historyApplyTrackStep(e,t){const s=this.animationClip.tracks[e.trackIdx],i={trackIdx:e.trackIdx,clips:s.clips,edited:s.edited};s.clips=e.clips,s.edited=e.edited,s.selected.length<s.clips.length&&(s.selected.length=s.clips.length),s.hovered.length<s.clips.length&&(s.hovered.length=s.clips.length),s.selected.fill(!1),s.hovered.fill(!1);for(let e=0;e<s.clips.length;++e)s.clips[e].active=s.clips[e].active??!0;return i}getClipOnTime(e,t,s){if(!e||!e.clips.length)return-1;if(t+s<e.clips[0].start)return-1;for(let i=0;i<e.clips.length;++i){let o=e.clips[i];if(o.start+o.duration>=t-s&&o.start<=t+s)return i}return-1}deselectAllClips(){for(let[e,t]of this.lastClipsSelected)this.animationClip.tracks[e].selected[t]=!1;const e=this.lastClipsSelected.length>0;return this.lastClipsSelected.length=0,e}selectAll(e=!1){this.deselectAllClips();for(let e=0;e<this.animationClip.tracks.length;e++)for(let t=0;t<this.animationClip.tracks[e].clips.length;t++)this.animationClip.tracks[e].selected[t]=!0,this.lastClipsSelected.push([e,t]);this.onSelectClip&&!e&&this.onSelectClip(null)}selectClip(e,t,s=!0,i=!1){if(s&&this.deselectAllClips(),t<0)return-1;const o=this.animationClip.tracks[e];if(o.selected[t])return t;let n=0;for(;n<this.lastClipsSelected.length;++n){let e=this.lastClipsSelected[n];if(!(e[0]<o.trackIdx)&&(e[0]>o.trackIdx||e[1]>t))break}return this.lastClipsSelected.splice(n,0,[o.trackIdx,t,o.clips[t]]),o.selected[t]=!0,!i&&this.onSelectClip&&this.onSelectClip(o.clips[t]),t}deselectClip(e,t){if(-1==t)return-1;const s=this.animationClip.tracks[e];if(!s.selected[t])return-1;s.selected[t]=!1;for(let s=0;s<this.lastClipsSelected.length;++s){let i=this.lastClipsSelected[s];if(i[0]==e&&i[1]==t){this.lastClipsSelected.splice(s,1);break}}return t}getClipsInRange(e,t,s,i=0){if(!e||!e.clips.length)return null;if(t>s){let e=t;t=s,s=e}t-=i,s+=i,t-=i,s+=i;const o=e.clips;if(s<o[0].start||t>o[o.length-1].start+o[o.length-1].duration)return null;let n=[];for(let e=0;e<o.length;++e){const i=o[e];if(!(i.start+i.duration<t)){if(i.start>s)break;n.push(e)}}return n.length?n:null}validateDuration(e){for(let t=0;t<this.animationClip.tracks.length;t++){const s=this.animationClip.tracks[t];if(s.clips.length){const t=s.clips[s.clips.length-1];e=Math.max(e,t.start+t.duration)}}return e}setDuration(e,t=!1,s=!0){const i=e,o=this.validateDuration(e);super.setDuration(o,t,i!=o||s)}}function Lt(e,t,s,i,o,n=5,a=!1,l=!1){if("number"==typeof n)n={tl:n,tr:n,br:n,bl:n};else{var r={tl:0,tr:0,br:0,bl:0};for(var c in r)n[c]=n[c]??r[c]}e.beginPath(),e.moveTo(t+n.tl,s),e.lineTo(t+i-n.tr,s),e.quadraticCurveTo(t+i,s,t+i,s+n.tr),e.lineTo(t+i,s+o-n.br),e.quadraticCurveTo(t+i,s+o,t+i-n.br,s+o),e.lineTo(t+n.bl,s+o),e.quadraticCurveTo(t,s+o,t,s+o-n.bl),e.lineTo(t,s+n.tl),e.quadraticCurveTo(t,s,t+n.tl,s),e.closePath(),a&&e.fill(),l&&e.stroke()}if(t.ClipsTimeline=xt,!t)throw"Missing LX namespace!";t.extensions.push("VideoEditor");const St=t.vec2;t.Area,t.Panel;class kt{static TIMEBAR_PLAY=1;static TIMEBAR_TRIM=2;static BACKGROUND_COLOR=t.getThemeColor("global-branch-darker");static COLOR=t.getThemeColor("global-button-color");static ACTIVE_COLOR="#668ee4";type=kt.TIMEBAR_PLAY;duration=1;canvas;ctx;markerWidth=8;markerHeight;offset;lineWidth;lineHeight;position;startX;endX;currentX;hovering;dragging;onChangeCurrent;onChangeStart;onChangeEnd;onDraw;onMouse;constructor(e,s,i={}){this.type=s??kt.TIMEBAR_PLAY,this.duration=i.duration??this.duration,this.canvas=document.createElement("canvas"),this.canvas.width=e.size[0],this.canvas.height=e.size[1],e.attach(this.canvas),this.ctx=this.canvas.getContext("2d"),this.markerWidth=i.markerWidth??this.markerWidth,this.markerHeight=i.markerHeight??.5*this.canvas.height,this.offset=i.offset||.5*this.markerWidth+5,this.lineWidth=this.canvas.width-2*this.offset,this.lineHeight=i.barHeight??5,this.position=new St(this.offset,.5*this.canvas.height-.5*this.lineHeight),this.startX=this.position.x,this.endX=this.position.x+this.lineWidth,this.currentX=this.startX,this._draw(),this.updateTheme(),t.addSignal("@on_new_color_scheme",()=>{this.updateTheme()}),this.canvas.onmousedown=e=>this.onMouseDown(e),this.canvas.onmousemove=e=>this.onMouseMove(e),this.canvas.onmouseup=e=>this.onMouseUp(e)}updateTheme(){kt.BACKGROUND_COLOR=t.getThemeColor("global-color-secondary"),kt.COLOR=t.getThemeColor("global-color-quaternary"),kt.ACTIVE_COLOR="#668ee4"}setDuration(e){this.duration=e}xToTime(e){return(e-this.offset)/this.lineWidth*this.duration}timeToX(e){return e/this.duration*this.lineWidth+this.offset}setCurrentTime(e){this.currentX=this.timeToX(e),this.onSetCurrentValue(this.currentX)}setStartTime(e){this.startX=this.timeToX(e),this.onSetStartValue(this.startX)}setEndTime(e){this.endX=this.timeToX(e),this.onSetEndValue(this.endX)}onSetCurrentValue(e){this.update(e);const t=this.xToTime(e);this.onChangeCurrent&&this.onChangeCurrent(t)}onSetStartValue(e){this.update(e);const t=this.xToTime(e);this.onChangeStart&&this.onChangeStart(t)}onSetEndValue(e){this.update(e);const t=this.xToTime(e);this.onChangeEnd&&this.onChangeEnd(t)}_draw(){const e=this.ctx;e&&(e.save(),e.fillStyle=kt.BACKGROUND_COLOR,e.clearRect(0,0,this.canvas.width,this.canvas.height),e.fillRect(0,0,this.canvas.width,this.canvas.height),e.fillStyle=kt.COLOR,e.fillRect(this.position.x,this.position.y,this.lineWidth,this.lineHeight),e.fillStyle=kt.ACTIVE_COLOR,e.fillRect(this.startX,this.position.y,this.endX-this.startX,this.lineHeight),e.restore(),this._drawTrimMarker("start",this.startX,{color:null,fillColor:kt.ACTIVE_COLOR||"#5f88c9"}),this._drawTrimMarker("end",this.endX,{color:null,fillColor:kt.ACTIVE_COLOR||"#5f88c9"}),this._drawTimeMarker("current",this.currentX,{color:"#e5e5e5",fillColor:kt.ACTIVE_COLOR||"#5f88c9",width:this.markerWidth}),this.onDraw&&this.onDraw())}_drawTrimMarker(e,t,s={}){const i=this.markerWidth,o=this.markerHeight,n=.5*this.canvas.height-.5*o,a=this.ctx;a&&(this.hovering==e&&(a.shadowColor="white",a.shadowBlur=2),a.globalAlpha=1,a.fillStyle=a.strokeStyle=s.fillColor||"#111",a.beginPath(),a.roundRect(t-.5*i,n,i,o,2),a.fill(),a.fillStyle=a.strokeStyle=s.fillColor||"#111",a.strokeStyle="white",a.beginPath(),a.lineWidth=2,a.moveTo(t,n+4),a.lineTo(t,n+o-4),a.stroke(),a.shadowBlur=0)}_drawTimeMarker(e,t,s={}){let i=this.offset;const o=s.width?s.width:this.dragging==e?6:4,n=this.canvas.height-2*this.offset;let a=this.ctx;a&&(a.globalAlpha=1,a.fillStyle=a.strokeStyle=s.fillColor||"#111",this.hovering==e&&(a.shadowColor="white",a.shadowBlur=2),a.fillStyle=a.strokeStyle="white",a.beginPath(),a.moveTo(t,i),a.lineTo(t,i+.5*n),a.stroke(),a.closePath(),a.fillStyle=a.strokeStyle=s.fillColor||"#111",i-=this.offset+8,a.fillStyle=s.fillColor||"#e5e5e5",a.beginPath(),a.roundRect(t-.5*o,i+this.offset,o,o,5),a.fill(),a.shadowBlur=0)}update(e){this.currentX=Math.min(Math.max(this.startX,e),this.endX),this._draw()}onMouseDown(e){if(this.onMouse&&this.onMouse(e),e.preventDefault(),!this.canvas||e.target!=this.canvas||e.cancelBubble)return;const t=this.canvas,s=e.offsetX,i=e.offsetY,o=this.markerWidth;Math.abs(this.startX-s)<o&&this.position.y<i?(this.dragging="start",t.style.cursor="grabbing"):Math.abs(this.endX-s)<o&&this.position.y<i?(this.dragging="end",t.style.cursor="grabbing"):(this.dragging="current",t.style.cursor="grabbing",s<this.startX?this.currentX=this.startX:s>this.endX?this.currentX=this.endX:this.currentX=s,this.onSetCurrentValue(this.currentX)),this._draw()}onMouseUp(e){if(this.onMouse&&this.onMouse(e),e.preventDefault(),delete this.dragging,delete this.hovering,!this.canvas||e.cancelBubble)return;this.canvas.style.cursor="default"}onMouseMove(e){if(this.onMouse&&this.onMouse(e),!this.canvas||e.cancelBubble)return;e.preventDefault();const t=this.canvas,s=e.target==t?e.offsetX:e.clientX-t.offsetLeft;if(e.target==t?e.offsetY:(e.clientY,t.offsetTop),this.dragging){switch(this.dragging){case"start":this.startX=Math.max(this.position.x,Math.min(this.endX,s)),this.currentX=this.startX,this.onSetStartValue(this.startX);break;case"end":this.endX=Math.max(this.startX,Math.min(this.position.x+this.lineWidth,s)),this.currentX=this.endX,this.onSetEndValue(this.endX);break;default:this.currentX=Math.max(this.startX,Math.min(this.endX,s))}this.onSetCurrentValue(this.currentX)}else{const e=.5*this.markerWidth;Math.abs(this.startX-s)<e?(this.hovering="start",t.style.cursor="grab"):Math.abs(this.endX-s)<e?(this.hovering="end",t.style.cursor="grab"):Math.abs(this.currentX-s)<e?(this.hovering="current",t.style.cursor="grab"):(delete this.hovering,t.style.cursor="default")}this._draw()}resize(e){this.canvas.width=Math.max(0,e[0]),this.canvas.height=Math.max(0,e[1]);let t=e[0]-2*this.offset;t=t<1e-5?1e-5:t;const s=(this.startX-this.offset)/this.lineWidth,i=(this.currentX-this.offset)/this.lineWidth,o=(this.endX-this.offset)/this.lineWidth;this.lineWidth=t,this.startX=Math.min(Math.max(t*s,0),t)+this.offset,this.currentX=Math.min(Math.max(t*i,0),t)+this.offset,this.endX=Math.min(Math.max(t*o,0),t)+this.offset,this._draw()}}t.TimeBar=kt;class Et{static CROP_HANDLE_L=1;static CROP_HANDLE_R=2;static CROP_HANDLE_T=4;static CROP_HANDLE_B=8;static CROP_HANDLE_TL=Et.CROP_HANDLE_L|Et.CROP_HANDLE_T;static CROP_HANDLE_BL=Et.CROP_HANDLE_L|Et.CROP_HANDLE_B;static CROP_HANDLE_TR=Et.CROP_HANDLE_R|Et.CROP_HANDLE_T;static CROP_HANDLE_BR=Et.CROP_HANDLE_R|Et.CROP_HANDLE_B;options={};playing=!1;videoReady=!1;controls=!0;startTimeString="0:0";endTimeString="0:0";speed=1;currentTime=0;startTime=0;endTime=0;requestId;video;loop=!1;isDragging=!1;isResizing=null;crop=!1;dragOffsetX=0;dragOffsetY=0;currentTimeString="";timebar;mainArea;cropArea;controlsArea;controlsPanelLeft;controlsPanelRight;controlsCurrentPanel;onChangeCurrent;onChangeStart;onChangeEnd;onKeyUp;onSetTime;onVideoLoaded;onCropArea;onResize;onChangeSpeed;_updateTime=!0;_onCropMouseUp;_onCropMouseMove;resize;constructor(e,s={}){this.options=s??{},this.speed=s.speed??this.speed,this.mainArea=e;let i=null,o=null;s.controlsArea?(i=e,o=s.controlsArea):[i,o]=e.split({type:"vertical",sizes:["85%",null],minimizable:!1,resize:!1}),o.root.classList.add("lexconstrolsarea"),this.cropArea=document.createElement("div"),this.cropArea.id="cropArea",this.cropArea.className="resize-area hidden",this.cropArea.normCoords={x:0,y:0,w:1,h:1};this.setCropAreaHandles(15),this.crop=s.crop,this.dragOffsetX=0,this.dragOffsetY=0;let n=this.video=s.video??document.createElement("video");this.loop=s.loop??this.loop,s.src&&(this.video.src=s.src,this.loadVideo(s)),s.videoArea?(s.videoArea.root.classList.add("lexvideoeditor"),s.videoArea.attach(this.cropArea),i.attach(s.videoArea)):(i.attach(n),i.attach(this.cropArea),i.root.classList.add("lexvideoeditor")),this.controlsArea=o;let[a,l]=o.split({type:"vertical",sizes:["50%",null],minimizable:!1,resize:!1});l.setSize([l.size[0],40]);let[r,c]=l.split({type:"horizontal",sizes:["92%",null],minimizable:!1,resize:!1}),[h,d]=r.split({type:"horizontal",sizes:["10%",null],minimizable:!1,resize:!1});a.root.classList.add("lexbar"),l.root.classList.add("lexbar"),this.controlsCurrentPanel=new t.Panel({className:"lexcontrolspanel lextime"}),this.controlsCurrentPanel.refresh=()=>{this.controlsCurrentPanel.clear(),this.controlsCurrentPanel.addLabel(this.currentTimeString,{float:"center"})},a.root.classList.add("lexflexarea"),a.attach(this.controlsCurrentPanel),this.controlsCurrentPanel.refresh();const u=getComputedStyle(l.root);let p=Number(u.getPropertyValue("padding").replace("px",""));this.timebar=new kt(d,kt.TIMEBAR_TRIM,{offset:p}),this.controlsPanelLeft=new t.Panel({className:"lexcontrolspanel"}),this.controlsPanelLeft.refresh=()=>{this.controlsPanelLeft.clear(),this.controlsPanelLeft.sameLine(),this.controlsPanelLeft.addButton("Play","",e=>{this.playing=e,this.playing?(this.video.currentTime+1e-6>=this.endTime&&(this.video.currentTime=this.startTime),this.video.play()):this.video.pause()},{width:"40px",icon:"Play@solid",swap:"Pause@solid",hideName:!0,className:"justify-center"}).setState(this.playing,!0),this.controlsPanelLeft.addButton("","",(e,s)=>{const i=new t.Panel;i.addRange("Speed",this.speed,e=>{this.speed=e,this.video.playbackRate=e,this.onChangeSpeed&&this.onChangeSpeed(e)},{min:0,max:2.5,step:.01,hideName:!0}),new t.Popover(s.target,[i],{align:"start",side:"top",sideOffset:12})},{width:"40px",title:"speed",icon:"Timer@solid",className:"justify-center"}),this.controlsPanelLeft.addButton("","Loop",e=>{this.loop=e},{width:"40px",title:"loop",icon:"Repeat@solid",className:"justify-center",selectable:!0,selected:this.loop}),this.controlsPanelLeft.addLabel(this.startTimeString,{width:"100px"}),this.controlsPanelLeft.endLine();let e=r.root.clientWidth-h.root.clientWidth;this.timebar.resize([e,d.root.clientHeight])},this.controlsPanelLeft.refresh(),h.root.style.minWidth="fit-content",h.attach(this.controlsPanelLeft),this.controlsPanelRight=new t.Panel({className:"lexcontrolspanel"}),this.controlsPanelRight.refresh=()=>{this.controlsPanelRight.clear(),this.controlsPanelRight.addLabel(this.endTimeString,{width:100})},this.controlsPanelRight.refresh(),c.root.style.minWidth="fit-content",c.attach(this.controlsPanelRight),this.timebar.onChangeCurrent=this._setCurrentTime.bind(this),this.timebar.onChangeStart=this._setStartTime.bind(this),this.timebar.onChangeEnd=this._setEndTime.bind(this),this.resize=()=>{l.setSize([this.controlsArea.root.clientWidth,40]);let e=this.controlsArea.root.clientWidth-h.root.clientWidth-c.root.clientWidth;this.timebar.resize([e,d.root.clientHeight]),this.moveCropArea(this.cropArea.normCoords.x,this.cropArea.normCoords.y,!0),this.resizeCropArea(this.cropArea.normCoords.w,this.cropArea.normCoords.h,!0),this.onResize&&this.onResize([i.root.clientWidth,i.root.clientHeight])},e.onresize=this.resize.bind(this),window.addEventListener("resize",e.onresize),this.onKeyUp=e=>{this.controls&&" "==e.key&&(e.preventDefault(),e.stopPropagation(),this.playing=!this.playing,this.playing?(this.video.currentTime+1e-6>=this.endTime&&(this.video.currentTime=this.startTime),this.video.play()):this.video.pause(),this.controlsPanelLeft.refresh())},window.addEventListener("keyup",this.onKeyUp);(o.parentElement?o.parentElement:o.root.parentElement).addEventListener("mousedown",e=>{}),this._onCropMouseUp=e=>{e.preventDefault(),e.stopPropagation(),(this.isDragging||this.isResizing)&&this.onCropArea&&this.onCropArea(this.getCroppedArea()),this.isDragging=!1,this.isResizing=!1,document.removeEventListener("mouseup",this._onCropMouseUp),document.removeEventListener("mousemove",this._onCropMouseMove)},this._onCropMouseMove=e=>{if(window.getSelection()?.removeAllRanges(),e.preventDefault(),e.stopPropagation(),this.isResizing){const t=this.cropArea.getBoundingClientRect(),s=this.video.getBoundingClientRect(),i=this.isResizing.movement;let o=t.left,n=t.top,a=t.width,l=t.height;if(i&Et.CROP_HANDLE_L){let i=Math.min(t.right-4,Math.max(s.left,e.clientX));a=t.left+t.width-i,o=i,i<t.left?(this.moveCropArea(o,n,!1),this.resizeCropArea(a,l,!1)):(this.resizeCropArea(a,l,!1),this.moveCropArea(o,n,!1))}if(i&Et.CROP_HANDLE_R&&(a=e.clientX-t.left,this.resizeCropArea(a,l,!1)),i&Et.CROP_HANDLE_T){const i=Math.min(t.bottom-4,Math.max(s.top,e.clientY));l=t.top+t.height-i,n=i,i<t.top?(this.moveCropArea(o,n,!1),this.resizeCropArea(a,l,!1)):(this.resizeCropArea(a,l,!1),this.moveCropArea(o,n,!1))}i&Et.CROP_HANDLE_B&&(l=e.clientY-t.top,this.resizeCropArea(a,l,!1))}this.isDragging&&this.moveCropArea(e.clientX-this.dragOffsetX,e.clientY-this.dragOffsetY,!1)},this.cropArea.addEventListener("mousedown",e=>{if(e.target===this.cropArea){const t=this.cropArea.getBoundingClientRect();this.isDragging=!0,this.dragOffsetX=e.clientX-t.left,this.dragOffsetY=e.clientY-t.top,document.addEventListener("mouseup",this._onCropMouseUp),document.addEventListener("mousemove",this._onCropMouseMove)}}),this.onChangeStart=null,this.onChangeEnd=null}setCropAreaHandles(e){const t=this.cropArea.getElementsByClassName("resize-handle");for(let e=t.length-1;e>-1;--e)t[e].remove();const s=(e,t)=>{const s=document.createElement("div");s.className=" resize-handle "+e,s.movement=t,this.options.handleStyle&&Object.assign(s.style,this.options.handleStyle),this.cropArea.append(s),s.addEventListener("mousedown",e=>{e.stopPropagation(),e.preventDefault(),this.isResizing=s,document.addEventListener("mouseup",this._onCropMouseUp),document.addEventListener("mousemove",this._onCropMouseMove)})};e&Et.CROP_HANDLE_L&&s("l",Et.CROP_HANDLE_L),e&Et.CROP_HANDLE_R&&s("r",Et.CROP_HANDLE_R),e&Et.CROP_HANDLE_T&&s("t",Et.CROP_HANDLE_T),e&Et.CROP_HANDLE_B&&s("b",Et.CROP_HANDLE_B),(e&Et.CROP_HANDLE_TL)==Et.CROP_HANDLE_TL&&s("tl",Et.CROP_HANDLE_TL),(e&Et.CROP_HANDLE_BL)==Et.CROP_HANDLE_BL&&s("bl",Et.CROP_HANDLE_BL),(e&Et.CROP_HANDLE_TR)==Et.CROP_HANDLE_TR&&s("tr",Et.CROP_HANDLE_TR),(e&Et.CROP_HANDLE_BR)==Et.CROP_HANDLE_BR&&s("br",Et.CROP_HANDLE_BR)}resizeCropArea(e,t,s=!0){const i=this.video.getBoundingClientRect();s||(e=i.width?e/i.width:1,t=i.height?t/i.height:1),e=Math.min(1-this.cropArea.normCoords.x,Math.max(0,e)),t=Math.min(1-this.cropArea.normCoords.y,Math.max(0,t)),this.cropArea.normCoords.w=e,this.cropArea.normCoords.h=t;const o=i.width*e,n=i.height*t,a=i.width*this.cropArea.normCoords.x+i.left,l=i.height*this.cropArea.normCoords.y+i.top;if(!this.cropArea.classList.contains("hidden")){const e=this.cropArea.parentElement.childNodes;for(let t=0;t<e.length;t++)if(e[t]!=this.cropArea){const s=e[t].getBoundingClientRect();e[t].style.webkitMask=`linear-gradient(#000 0 0) ${a-s.left}px ${l-s.top}px / ${o}px ${n}px, linear-gradient(rgba(0, 0, 0, 0.3) 0 0)`,e[t].style.webkitMaskRepeat="no-repeat"}}this.cropArea.style.width=o+"px",this.cropArea.style.height=n+"px"}moveCropArea(e,t,s=!0){const i=this.video.getBoundingClientRect();s||(e=i.width?(e-i.left)/i.width:0,t=i.height?(t-i.top)/i.height:0),e=Math.max(0,Math.min(1-this.cropArea.normCoords.w,e)),t=Math.max(0,Math.min(1-this.cropArea.normCoords.h,t)),this.cropArea.normCoords.x=e,this.cropArea.normCoords.y=t;const o=i.width*e+i.left,n=i.height*t+i.top,a=i.width*this.cropArea.normCoords.w,l=i.height*this.cropArea.normCoords.h;if(!this.cropArea.classList.contains("hidden")){const e=this.cropArea.parentElement.childNodes;for(let t=0;t<e.length;t++)if(e[t]!=this.cropArea){const s=e[t].getBoundingClientRect();e[t].style.webkitMask=`linear-gradient(#000 0 0) ${o-s.left}px ${n-s.top}px / ${a}px ${l}px, linear-gradient(rgba(0, 0, 0, 0.3) 0 0)`,e[t].style.webkitMaskRepeat="no-repeat"}}const r=this.cropArea.parentElement.getBoundingClientRect();this.cropArea.style.left=o-r.left+"px",this.cropArea.style.top=n-r.top+"px"}async loadVideo(e={}){for(this.videoReady=!1;this.video.duration===1/0||isNaN(this.video.duration)||!this.timebar;)await new Promise(e=>setTimeout(e,1e3)),this.video.currentTime=1e7*Math.random();this.video.currentTime=.01;this.video.addEventListener("canplaythrough",()=>{const e=this.videoReady;this.video.readyState>3&&(this.videoReady=!0),e||(this.video.currentTime=this.video.duration)},{passive:!0}),this.video.ondurationchange=e=>{this.video.duration!=this.endTime&&(this.video.currentTime=this.startTime,console.log("duration changed from",this.endTime," to ",this.video.duration),this.endTime=this.video.duration,this.timebar.setDuration(this.endTime),this.timebar.setEndTime(this.endTime)),this.video.currentTime=this.startTime,this.timebar.setCurrentTime(this.video.currentTime)},this.timebar.startX=this.timebar.position.x,this.timebar.endX=this.timebar.position.x+this.timebar.lineWidth,this.startTime=0,this.endTime=this.video.duration,this.timebar.setDuration(this.endTime),this.timebar.setEndTime(this.video.duration),this.timebar.setStartTime(this.startTime),this.timebar.setCurrentTime(this.startTime),this.requestId||this._update(),this.controls=e.controls??!0,this.controls||this.hideControls(),this.cropArea.style.height=this.video.clientHeight+"px",this.cropArea.style.width=this.video.clientWidth+"px",this.moveCropArea(0,0,!0),this.resizeCropArea(1,1,!0),this.crop?this.showCropArea():this.hideCropArea(),window.addEventListener("keyup",this.onKeyUp),this.onVideoLoaded&&this.onVideoLoaded(this.video)}_update(){this.playing&&(this.video.currentTime+1e-6>=this.endTime&&(this.video.pause(),this.loop?(this.video.currentTime=this.startTime,this.video.play()):(this.playing=!1,this.controlsPanelLeft.refresh())),this._updateTime=!1,this.timebar.setCurrentTime(this.video.currentTime),this._updateTime=!0),this.requestId=requestAnimationFrame(this._update.bind(this))}timeToString(e){let t=Math.floor(e/60),s=Math.floor(e-60*t),i=Math.floor(100*(e-s)),o=i<10?"0"+i:i.toString(),n=s<10?"0"+s:s.toString();return`${t<10?"0"+t:t.toString()}:${n}.${o}`}_setCurrentTime(e){this.video.currentTime!=e&&this._updateTime&&(this.video.currentTime=e),this.currentTimeString=this.timeToString(e),this.controlsCurrentPanel.refresh(),this.onSetTime&&this.onSetTime(e),this.onChangeCurrent&&this.onChangeCurrent(e)}_setStartTime(e){this.startTime=this.video.currentTime=e,this.startTimeString=this.timeToString(e),this.controlsPanelLeft.refresh(),this.onSetTime&&this.onSetTime(e),this.onChangeStart&&this.onChangeStart(e)}_setEndTime(e){this.endTime=this.video.currentTime=e,this.endTimeString=this.timeToString(e),this.controlsPanelRight.refresh(),this.onSetTime&&this.onSetTime(e),this.onChangeEnd&&this.onChangeEnd(e)}getStartTime(){return this.startTime}getEndTime(){return this.endTime}getTrimedTimes(){return{start:this.startTime,end:this.endTime}}getCroppedArea(){return this.cropArea.getBoundingClientRect()}showCropArea(){this.cropArea.classList.remove("hidden");const e=this.cropArea.parentElement?.childNodes??[],t=this.cropArea.getBoundingClientRect();for(let s=0;s<e.length;s++){const i=e[s];if(i==this.cropArea)continue;const o=i.getBoundingClientRect();i.style.webkitMask=`linear-gradient(#000 0 0) ${t.left-o.left}px ${t.top-o.top}px / ${t.width}px ${t.height}px, linear-gradient(rgba(0, 0, 0, 0.3) 0 0)`,i.style.webkitMaskRepeat="no-repeat"}}hideCropArea(){this.cropArea.classList.add("hidden");const e=this.cropArea.parentElement?.childNodes??[];for(let t=0;t<e.length;t++){const s=e[t];s!=this.cropArea&&(s.style.webkitMask="",s.style.webkitMaskRepeat="no-repeat")}}showControls(){this.controls=!0,this.controlsArea.show()}hideControls(){this.controls=!1,this.controlsArea.hide()}stopUpdates(){this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=null)}unbind(){this.stopUpdates(),this.video.pause(),this.playing=!1,this.controlsPanelLeft.refresh(),this.video.src="",window.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("mouseup",this._onCropMouseUp),document.removeEventListener("mousemove",this._onCropMouseMove)}}t.VideoEditor=Et;export{ce as AlertDialog,se as Area,te as AreaOverlayButtons,p as ArrayInput,be as AssetView,a as BaseComponent,Ze as BoundingBox,Q as Branch,l as Button,g as Checkbox,xt as ClipsTimeline,Be as CodeEditor,y as ColorInput,b as ComboButtons,n as ComponentType,he as ContextMenu,_ as Counter,L as Curve,E as DatePicker,w as Dial,re as Dialog,We as DocMaker,de as DropdownMenu,M as FileInput,pe as Footer,A as Form,Je as GraphEditor,et as GraphNode,i as IEvent,ft as ImUI,_t as KeyFramesTimeline,ke as Knob,t as LX,N as Layers,P as List,R as Map2D,D as NodeTree,h as NumberInput,B as OTPInput,H as Pad,G as Pagination,ee as Panel,me as PocketDialog,v as Popover,F as Progress,$ as RadioGroup,V as RangeInput,K as Rate,u as Select,ge as Sheet,fe as Sidebar,U as SizeInput,Ce as Skeleton,le as Spinner,q as TabSections,W as Table,c as Tabs,Y as Tags,X as TextArea,d as TextInput,kt as TimeBar,bt as Timeline,j as Title,Z as Toggle,ve as Tour,z as Tree,o as TreeEvent,J as Vector,Et as VideoEditor,ue as addDropdownMenu,O as vec2};
|
|
1
|
+
const e=globalThis;let t=e.LX;t||(t={version:"8.1.1",ready:!1,extensions:[],extraCommandbarEntries:[],signals:{},activeDraggable:null,spacingMode:"default",layoutMode:"app",MOUSE_LEFT_CLICK:0,MOUSE_MIDDLE_CLICK:1,MOUSE_RIGHT_CLICK:2,MOUSE_DOUBLE_CLICK:2,MOUSE_TRIPLE_CLICK:3,CURVE_MOVEOUT_CLAMP:0,CURVE_MOVEOUT_DELETE:1,DRAGGABLE_Z_INDEX:101},e.LX=t);const s={Abc:[24,24,[],"regular","M17 15q-.425 0-.712-.288T16 14v-4q0-.425.288-.712T17 9h3q.425 0 .713.288T21 10v1h-1.5v-.5h-2v3h2V13H21v1q0 .425-.288.713T20 15zm-7.5 0V9h4q.425 0 .713.288T14.5 10v1q0 .425-.288.713T13.5 12q.425 0 .713.288T14.5 13v1q0 .425-.288.713T13.5 15zm1.5-3.75h2v-.75h-2zm0 2.25h2v-.75h-2zM3 15v-5q0-.425.288-.712T4 9h3q.425 0 .713.288T8 10v5H6.5v-1.5h-2V15zm1.5-3h2v-1.5h-2z"],Android:[128,128,[],"solid","M21.005 43.003c-4.053-.002-7.338 3.291-7.339 7.341l.005 30.736a7.34 7.34 0 0 0 7.342 7.343a7.33 7.33 0 0 0 7.338-7.342V50.34a7.345 7.345 0 0 0-7.346-7.337m59.193-27.602l5.123-9.355a1.023 1.023 0 0 0-.401-1.388a1.02 1.02 0 0 0-1.382.407l-5.175 9.453c-4.354-1.938-9.227-3.024-14.383-3.019c-5.142-.005-10.013 1.078-14.349 3.005L44.45 5.075a1.01 1.01 0 0 0-1.378-.406a1.007 1.007 0 0 0-.404 1.38l5.125 9.349c-10.07 5.193-16.874 15.083-16.868 26.438l66.118-.008c.002-11.351-6.79-21.221-16.845-26.427M48.942 29.858a2.772 2.772 0 0 1 .003-5.545a2.78 2.78 0 0 1 2.775 2.774a2.776 2.776 0 0 1-2.778 2.771m30.106-.005a2.77 2.77 0 0 1-2.772-2.771a2.793 2.793 0 0 1 2.773-2.778a2.79 2.79 0 0 1 2.767 2.779a2.767 2.767 0 0 1-2.768 2.77M31.195 44.39l.011 47.635a7.82 7.82 0 0 0 7.832 7.831l5.333.002l.006 16.264c-.001 4.05 3.291 7.342 7.335 7.342c4.056 0 7.342-3.295 7.343-7.347l-.004-16.26l9.909-.003l.004 16.263c0 4.047 3.293 7.346 7.338 7.338c4.056.003 7.344-3.292 7.343-7.344l-.005-16.259l5.352-.004a7.835 7.835 0 0 0 7.836-7.834l-.009-47.635zm83.134 5.943a7.34 7.34 0 0 0-7.341-7.339c-4.053-.004-7.337 3.287-7.337 7.342l.006 30.738a7.334 7.334 0 0 0 7.339 7.339a7.337 7.337 0 0 0 7.338-7.343z"],Clone:[512,512,[],"regular","M64 464l224 0c8.8 0 16-7.2 16-16l0-64 48 0 0 64c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 224c0-35.3 28.7-64 64-64l64 0 0 48-64 0c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16zM224 304l224 0c8.8 0 16-7.2 16-16l0-224c0-8.8-7.2-16-16-16L224 48c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16zm-64-16l0-224c0-35.3 28.7-64 64-64L448 0c35.3 0 64 28.7 64 64l0 224c0 35.3-28.7 64-64 64l-224 0c-35.3 0-64-28.7-64-64z"],IdBadge:[384,512,[],"regular","M256 48l0 16c0 17.7-14.3 32-32 32l-64 0c-17.7 0-32-14.3-32-32l0-16L64 48c-8.8 0-16 7.2-16 16l0 384c0 8.8 7.2 16 16 16l256 0c8.8 0 16-7.2 16-16l0-384c0-8.8-7.2-16-16-16l-64 0zM0 64C0 28.7 28.7 0 64 0L320 0c35.3 0 64 28.7 64 64l0 384c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 64zM160 320l64 0c44.2 0 80 35.8 80 80c0 8.8-7.2 16-16 16L96 416c-8.8 0-16-7.2-16-16c0-44.2 35.8-80 80-80zm-32-96a64 64 0 1 1 128 0 64 64 0 1 1 -128 0z"],Paste:[512,512,[],"regular","M104.6 48L64 48C28.7 48 0 76.7 0 112L0 384c0 35.3 28.7 64 64 64l96 0 0-48-96 0c-8.8 0-16-7.2-16-16l0-272c0-8.8 7.2-16 16-16l16 0c0 17.7 14.3 32 32 32l72.4 0C202 108.4 227.6 96 256 96l62 0c-7.1-27.6-32.2-48-62-48l-40.6 0C211.6 20.9 188.2 0 160 0s-51.6 20.9-55.4 48zM144 56a16 16 0 1 1 32 0 16 16 0 1 1 -32 0zM448 464l-192 0c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l140.1 0L464 243.9 464 448c0 8.8-7.2 16-16 16zM256 512l192 0c35.3 0 64-28.7 64-64l0-204.1c0-12.7-5.1-24.9-14.1-33.9l-67.9-67.9c-9-9-21.2-14.1-33.9-14.1L256 128c-35.3 0-64 28.7-64 64l0 256c0 35.3 28.7 64 64 64z"],Trash3:[448,512,[],"regular","M170.5 51.6L151.5 80l145 0-19-28.4c-1.5-2.2-4-3.6-6.7-3.6l-93.7 0c-2.7 0-5.2 1.3-6.7 3.6zm147-26.6L354.2 80 368 80l48 0 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-8 0 0 304c0 44.2-35.8 80-80 80l-224 0c-44.2 0-80-35.8-80-80l0-304-8 0c-13.3 0-24-10.7-24-24S10.7 80 24 80l8 0 48 0 13.8 0 36.7-55.1C140.9 9.4 158.4 0 177.1 0l93.7 0c18.7 0 36.2 9.4 46.6 24.9zM80 128l0 304c0 17.7 14.3 32 32 32l224 0c17.7 0 32-14.3 32-32l0-304L80 128zm80 64l0 208c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-208c0-8.8 7.2-16 16-16s16 7.2 16 16zm80 0l0 208c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-208c0-8.8 7.2-16 16-16s16 7.2 16 16zm80 0l0 208c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-208c0-8.8 7.2-16 16-16s16 7.2 16 16z"],FilePdf:[512,512,[],"regular","M64 464l48 0 0 48-48 0c-35.3 0-64-28.7-64-64L0 64C0 28.7 28.7 0 64 0L229.5 0c17 0 33.3 6.7 45.3 18.7l90.5 90.5c12 12 18.7 28.3 18.7 45.3L384 304l-48 0 0-144-80 0c-17.7 0-32-14.3-32-32l0-80L64 48c-8.8 0-16 7.2-16 16l0 384c0 8.8 7.2 16 16 16zM176 352l32 0c30.9 0 56 25.1 56 56s-25.1 56-56 56l-16 0 0 32c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-48 0-80c0-8.8 7.2-16 16-16zm32 80c13.3 0 24-10.7 24-24s-10.7-24-24-24l-16 0 0 48 16 0zm96-80l32 0c26.5 0 48 21.5 48 48l0 64c0 26.5-21.5 48-48 48l-32 0c-8.8 0-16-7.2-16-16l0-128c0-8.8 7.2-16 16-16zm32 128c8.8 0 16-7.2 16-16l0-64c0-8.8-7.2-16-16-16l-16 0 0 96 16 0zm80-112c0-8.8 7.2-16 16-16l48 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-32 0 0 32 32 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-32 0 0 48c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-64 0-64z"],FileWord:[384,512,[],"regular","M48 448L48 64c0-8.8 7.2-16 16-16l160 0 0 80c0 17.7 14.3 32 32 32l80 0 0 288c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16zM64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-293.5c0-17-6.7-33.3-18.7-45.3L274.7 18.7C262.7 6.7 246.5 0 229.5 0L64 0zm55 241.1c-3.8-12.7-17.2-19.9-29.9-16.1s-19.9 17.2-16.1 29.9l48 160c3 10.2 12.4 17.1 23 17.1s19.9-7 23-17.1l25-83.4 25 83.4c3 10.2 12.4 17.1 23 17.1s19.9-7 23-17.1l48-160c3.8-12.7-3.4-26.1-16.1-29.9s-26.1 3.4-29.9 16.1l-25 83.4-25-83.4c-3-10.2-12.4-17.1-23-17.1s-19.9 7-23 17.1l-25 83.4-25-83.4z"],FilePowerpoint:[384,512,[],"regular","M64 464c-8.8 0-16-7.2-16-16L48 64c0-8.8 7.2-16 16-16l160 0 0 80c0 17.7 14.3 32 32 32l80 0 0 288c0 8.8-7.2 16-16 16L64 464zM64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-293.5c0-17-6.7-33.3-18.7-45.3L274.7 18.7C262.7 6.7 246.5 0 229.5 0L64 0zm72 208c-13.3 0-24 10.7-24 24l0 104 0 56c0 13.3 10.7 24 24 24s24-10.7 24-24l0-32 44 0c42 0 76-34 76-76s-34-76-76-76l-68 0zm68 104l-44 0 0-56 44 0c15.5 0 28 12.5 28 28s-12.5 28-28 28z"],FileExcel:[384,512,[],"regular","M48 448L48 64c0-8.8 7.2-16 16-16l160 0 0 80c0 17.7 14.3 32 32 32l80 0 0 288c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16zM64 0C28.7 0 0 28.7 0 64L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-293.5c0-17-6.7-33.3-18.7-45.3L274.7 18.7C262.7 6.7 246.5 0 229.5 0L64 0zm90.9 233.3c-8.1-10.5-23.2-12.3-33.7-4.2s-12.3 23.2-4.2 33.7L161.6 320l-44.5 57.3c-8.1 10.5-6.3 25.5 4.2 33.7s25.5 6.3 33.7-4.2L192 359.1l37.1 47.6c8.1 10.5 23.2 12.3 33.7 4.2s12.3-23.2 4.2-33.7L222.4 320l44.5-57.3c8.1-10.5 6.3-25.5-4.2-33.7s-25.5-6.3-33.7 4.2L192 280.9l-37.1-47.6z"],Settings3:[640,512,[],"solid","M308.5 135.3c7.1-6.3 9.9-16.2 6.2-25c-2.3-5.3-4.8-10.5-7.6-15.5L304 89.4c-3-5-6.3-9.9-9.8-14.6c-5.7-7.6-15.7-10.1-24.7-7.1l-28.2 9.3c-10.7-8.8-23-16-36.2-20.9L199 27.1c-1.9-9.3-9.1-16.7-18.5-17.8C173.9 8.4 167.2 8 160.4 8l-.7 0c-6.8 0-13.5 .4-20.1 1.2c-9.4 1.1-16.6 8.6-18.5 17.8L115 56.1c-13.3 5-25.5 12.1-36.2 20.9L50.5 67.8c-9-3-19-.5-24.7 7.1c-3.5 4.7-6.8 9.6-9.9 14.6l-3 5.3c-2.8 5-5.3 10.2-7.6 15.6c-3.7 8.7-.9 18.6 6.2 25l22.2 19.8C32.6 161.9 32 168.9 32 176s.6 14.1 1.7 20.9L11.5 216.7c-7.1 6.3-9.9 16.2-6.2 25c2.3 5.3 4.8 10.5 7.6 15.6l3 5.2c3 5.1 6.3 9.9 9.9 14.6c5.7 7.6 15.7 10.1 24.7 7.1l28.2-9.3c10.7 8.8 23 16 36.2 20.9l6.1 29.1c1.9 9.3 9.1 16.7 18.5 17.8c6.7 .8 13.5 1.2 20.4 1.2s13.7-.4 20.4-1.2c9.4-1.1 16.6-8.6 18.5-17.8l6.1-29.1c13.3-5 25.5-12.1 36.2-20.9l28.2 9.3c9 3 19 .5 24.7-7.1c3.5-4.7 6.8-9.5 9.8-14.6l3.1-5.4c2.8-5 5.3-10.2 7.6-15.5c3.7-8.7 .9-18.6-6.2-25l-22.2-19.8c1.1-6.8 1.7-13.8 1.7-20.9s-.6-14.1-1.7-20.9l22.2-19.8zM112 176a48 48 0 1 1 96 0 48 48 0 1 1 -96 0zM504.7 500.5c6.3 7.1 16.2 9.9 25 6.2c5.3-2.3 10.5-4.8 15.5-7.6l5.4-3.1c5-3 9.9-6.3 14.6-9.8c7.6-5.7 10.1-15.7 7.1-24.7l-9.3-28.2c8.8-10.7 16-23 20.9-36.2l29.1-6.1c9.3-1.9 16.7-9.1 17.8-18.5c.8-6.7 1.2-13.5 1.2-20.4s-.4-13.7-1.2-20.4c-1.1-9.4-8.6-16.6-17.8-18.5L583.9 307c-5-13.3-12.1-25.5-20.9-36.2l9.3-28.2c3-9 .5-19-7.1-24.7c-4.7-3.5-9.6-6.8-14.6-9.9l-5.3-3c-5-2.8-10.2-5.3-15.6-7.6c-8.7-3.7-18.6-.9-25 6.2l-19.8 22.2c-6.8-1.1-13.8-1.7-20.9-1.7s-14.1 .6-20.9 1.7l-19.8-22.2c-6.3-7.1-16.2-9.9-25-6.2c-5.3 2.3-10.5 4.8-15.6 7.6l-5.2 3c-5.1 3-9.9 6.3-14.6 9.9c-7.6 5.7-10.1 15.7-7.1 24.7l9.3 28.2c-8.8 10.7-16 23-20.9 36.2L315.1 313c-9.3 1.9-16.7 9.1-17.8 18.5c-.8 6.7-1.2 13.5-1.2 20.4s.4 13.7 1.2 20.4c1.1 9.4 8.6 16.6 17.8 18.5l29.1 6.1c5 13.3 12.1 25.5 20.9 36.2l-9.3 28.2c-3 9-.5 19 7.1 24.7c4.7 3.5 9.5 6.8 14.6 9.8l5.4 3.1c5 2.8 10.2 5.3 15.5 7.6c8.7 3.7 18.6 .9 25-6.2l19.8-22.2c6.8 1.1 13.8 1.7 20.9 1.7s14.1-.6 20.9-1.7l19.8 22.2zM464 304a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"],MessagesCircle:[640,512,[],"regular","M88.2 309.1c9.8-18.3 6.8-40.8-7.5-55.8C59.4 230.9 48 204 48 176c0-63.5 63.8-128 160-128s160 64.5 160 128s-63.8 128-160 128c-13.1 0-25.8-1.3-37.8-3.6c-10.4-2-21.2-.6-30.7 4.2c-4.1 2.1-8.3 4.1-12.6 6c-16 7.2-32.9 13.5-49.9 18c2.8-4.6 5.4-9.1 7.9-13.6c1.1-1.9 2.2-3.9 3.2-5.9zM208 352c114.9 0 208-78.8 208-176S322.9 0 208 0S0 78.8 0 176c0 41.8 17.2 80.1 45.9 110.3c-.9 1.7-1.9 3.5-2.8 5.1c-10.3 18.4-22.3 36.5-36.6 52.1c-6.6 7-8.3 17.2-4.6 25.9C5.8 378.3 14.4 384 24 384c43 0 86.5-13.3 122.7-29.7c4.8-2.2 9.6-4.5 14.2-6.8c15.1 3 30.9 4.5 47.1 4.5zM432 480c16.2 0 31.9-1.6 47.1-4.5c4.6 2.3 9.4 4.6 14.2 6.8C529.5 498.7 573 512 616 512c9.6 0 18.2-5.7 22-14.5c3.8-8.8 2-19-4.6-25.9c-14.2-15.6-26.2-33.7-36.6-52.1c-.9-1.7-1.9-3.4-2.8-5.1C622.8 384.1 640 345.8 640 304c0-94.4-87.9-171.5-198.2-175.8c4.1 15.2 6.2 31.2 6.2 47.8l0 .6c87.2 6.7 144 67.5 144 127.4c0 28-11.4 54.9-32.7 77.2c-14.3 15-17.3 37.6-7.5 55.8c1.1 2 2.2 4 3.2 5.9c2.5 4.5 5.2 9 7.9 13.6c-17-4.5-33.9-10.7-49.9-18c-4.3-1.9-8.5-3.9-12.6-6c-9.5-4.8-20.3-6.2-30.7-4.2c-12.1 2.4-24.8 3.6-37.8 3.6c-61.7 0-110-26.5-136.8-62.3c-16 5.4-32.8 9.4-50 11.8C279 439.8 350 480 432 480z"],LinkOff:[640,512,["ChainBroken","ChainOff","Unlink"],"solid","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM406.6 416.4L220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3zm-290-228.5L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9z"],StreetView:[512,512,[],"solid","M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64l0 48c0 17.7 14.3 32 32 32l1.8 0 11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5l38.7 0c16.3 0 30-12.3 31.8-28.5L318.2 304l1.8 0c17.7 0 32-14.3 32-32l0-48c0-35.3-28.7-64-64-64l-64 0zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"],ClosedCaptioning:[576,512,["CC"],"regular","M512 80c8.8 0 16 7.2 16 16l0 320c0 8.8-7.2 16-16 16L64 432c-8.8 0-16-7.2-16-16L48 96c0-8.8 7.2-16 16-16l448 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l448 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zM200 208c14.2 0 27 6.1 35.8 16c8.8 9.9 24 10.7 33.9 1.9s10.7-24 1.9-33.9c-17.5-19.6-43.1-32-71.5-32c-53 0-96 43-96 96s43 96 96 96c28.4 0 54-12.4 71.5-32c8.8-9.9 8-25-1.9-33.9s-25-8-33.9 1.9c-8.8 9.9-21.6 16-35.8 16c-26.5 0-48-21.5-48-48s21.5-48 48-48zm144 48c0-26.5 21.5-48 48-48c14.2 0 27 6.1 35.8 16c8.8 9.9 24 10.7 33.9 1.9s10.7-24 1.9-33.9c-17.5-19.6-43.1-32-71.5-32c-53 0-96 43-96 96s43 96 96 96c28.4 0 54-12.4 71.5-32c8.8-9.9 8-25-1.9-33.9s-25-8-33.9 1.9c-8.8 9.9-21.6 16-35.8 16c-26.5 0-48-21.5-48-48z"],ChildReaching:[384,512,[],"solid","M256 64A64 64 0 1 0 128 64a64 64 0 1 0 128 0zM152.9 169.3c-23.7-8.4-44.5-24.3-58.8-45.8L74.6 94.2C64.8 79.5 45 75.6 30.2 85.4s-18.7 29.7-8.9 44.4L40.9 159c18.1 27.1 42.8 48.4 71.1 62.4L112 480c0 17.7 14.3 32 32 32s32-14.3 32-32l0-96 32 0 0 96c0 17.7 14.3 32 32 32s32-14.3 32-32l0-258.4c29.1-14.2 54.4-36.2 72.7-64.2l18.2-27.9c9.6-14.8 5.4-34.6-9.4-44.3s-34.6-5.5-44.3 9.4L291 122.4c-21.8 33.4-58.9 53.6-98.8 53.6c-12.6 0-24.9-2-36.6-5.8c-.9-.3-1.8-.7-2.7-.9z"],HourglassHalf:[384,512,[],"regular","M0 24C0 10.7 10.7 0 24 0L360 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-8 0 0 19c0 40.3-16 79-44.5 107.5L225.9 256l81.5 81.5C336 366 352 404.7 352 445l0 19 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24L24 512c-13.3 0-24-10.7-24-24s10.7-24 24-24l8 0 0-19c0-40.3 16-79 44.5-107.5L158.1 256 76.5 174.5C48 146 32 107.3 32 67l0-19-8 0C10.7 48 0 37.3 0 24zM110.5 371.5c-3.9 3.9-7.5 8.1-10.7 12.5l184.4 0c-3.2-4.4-6.8-8.6-10.7-12.5L192 289.9l-81.5 81.5zM284.2 128C297 110.4 304 89 304 67l0-19L80 48l0 19c0 22.1 7 43.4 19.8 61l184.4 0z"],PaperPlane:[512,512,[],"regular","M16.1 260.2c-22.6 12.9-20.5 47.3 3.6 57.3L160 376l0 103.3c0 18.1 14.6 32.7 32.7 32.7c9.7 0 18.9-4.3 25.1-11.8l62-74.3 123.9 51.6c18.9 7.9 40.8-4.5 43.9-24.7l64-416c1.9-12.1-3.4-24.3-13.5-31.2s-23.3-7.5-34-1.4l-448 256zm52.1 25.5L409.7 90.6 190.1 336l1.2 1L68.2 285.7zM403.3 425.4L236.7 355.9 450.8 116.6 403.3 425.4z"],Axis3DArrows:[24,24,[],"solid","m12 2l4 4h-3v7.85l6.53 3.76L21 15.03l1.5 5.47l-5.5 1.46l1.53-2.61L12 15.58l-6.53 3.77L7 21.96L1.5 20.5L3 15.03l1.47 2.58L11 13.85V6H8z"],PersonWalkingDashedLineArrowRight:[640,512,[],"solid","M208 96a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM123.7 200.5c1-.4 1.9-.8 2.9-1.2l-16.9 63.5c-5.6 21.1-.1 43.6 14.7 59.7l70.7 77.1 22 88.1c4.3 17.1 21.7 27.6 38.8 23.3s27.6-21.7 23.3-38.8l-23-92.1c-1.9-7.8-5.8-14.9-11.2-20.8l-49.5-54 19.3-65.5 9.6 23c4.4 10.6 12.5 19.3 22.8 24.5l26.7 13.3c15.8 7.9 35 1.5 42.9-14.3s1.5-35-14.3-42.9L281 232.7l-15.3-36.8C248.5 154.8 208.3 128 163.7 128c-22.8 0-45.3 4.8-66.1 14l-8 3.5c-32.9 14.6-58.1 42.4-69.4 76.5l-2.6 7.8c-5.6 16.8 3.5 34.9 20.2 40.5s34.9-3.5 40.5-20.2l2.6-7.8c5.7-17.1 18.3-30.9 34.7-38.2l8-3.5zm-30 135.1L68.7 398 9.4 457.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L116.3 441c4.6-4.6 8.2-10.1 10.6-16.1l14.5-36.2-40.7-44.4c-2.5-2.7-4.8-5.6-7-8.6zM550.6 153.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L530.7 224 384 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l146.7 0-25.4 25.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l80-80c12.5-12.5 12.5-32.8 0-45.3l-80-80zM392 0c-13.3 0-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24s24-10.7 24-24l0-48c0-13.3-10.7-24-24-24zm24 152c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 16c0 13.3 10.7 24 24 24s24-10.7 24-24l0-16zM392 320c-13.3 0-24 10.7-24 24l0 16c0 13.3 10.7 24 24 24s24-10.7 24-24l0-16c0-13.3-10.7-24-24-24zm24 120c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24s24-10.7 24-24l0-48z"],PersonWalkingArrowLoopLeft:[640,512,[],"solid","M208 96a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM123.7 200.5c1-.4 1.9-.8 2.9-1.2l-16.9 63.5c-5.6 21.1-.1 43.6 14.7 59.7l70.7 77.1 22 88.1c4.3 17.1 21.7 27.6 38.8 23.3s27.6-21.7 23.3-38.8l-23-92.1c-1.9-7.8-5.8-14.9-11.2-20.8l-49.5-54 19.3-65.5 9.6 23c4.4 10.6 12.5 19.3 22.8 24.5l26.7 13.3c15.8 7.9 35 1.5 42.9-14.3s1.5-35-14.3-42.9L281 232.7l-15.3-36.8C248.5 154.8 208.3 128 163.7 128c-22.8 0-45.3 4.8-66.1 14l-8 3.5c-32.9 14.6-58.1 42.4-69.4 76.5l-2.6 7.8c-5.6 16.8 3.5 34.9 20.2 40.5s34.9-3.5 40.5-20.2l2.6-7.8c5.7-17.1 18.3-30.9 34.7-38.2l8-3.5zm-30 135.1L68.7 398 9.4 457.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L116.3 441c4.6-4.6 8.2-10.1 10.6-16.1l14.5-36.2-40.7-44.4c-2.5-2.7-4.8-5.6-7-8.6zm347.7 119c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L461.3 384l18.7 0c88.4 0 160-71.6 160-160s-71.6-160-160-160L352 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l128 0c53 0 96 43 96 96s-43 96-96 96l-18.7 0 25.4-25.4c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-80 80c-12.5 12.5-12.5 32.8 0 45.3l80 80z"],PersonWalkingArrowRight:[640,512,[],"solid","M208 96a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM123.7 200.5c1-.4 1.9-.8 2.9-1.2l-16.9 63.5c-5.6 21.1-.1 43.6 14.7 59.7l70.7 77.1 22 88.1c4.3 17.1 21.7 27.6 38.8 23.3s27.6-21.7 23.3-38.8l-23-92.1c-1.9-7.8-5.8-14.9-11.2-20.8l-49.5-54 19.3-65.5 9.6 23c4.4 10.6 12.5 19.3 22.8 24.5l26.7 13.3c15.8 7.9 35 1.5 42.9-14.3s1.5-35-14.3-42.9L281 232.7l-15.3-36.8C248.5 154.8 208.3 128 163.7 128c-22.8 0-45.3 4.8-66.1 14l-8 3.5c-32.9 14.6-58.1 42.4-69.4 76.5l-2.6 7.8c-5.6 16.8 3.5 34.9 20.2 40.5s34.9-3.5 40.5-20.2l2.6-7.8c5.7-17.1 18.3-30.9 34.7-38.2l8-3.5zm-30 135.1L68.7 398 9.4 457.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L116.3 441c4.6-4.6 8.2-10.1 10.6-16.1l14.5-36.2-40.7-44.4c-2.5-2.7-4.8-5.6-7-8.6zM550.6 153.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L530.7 224 384 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l146.7 0-25.4 25.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l80-80c12.5-12.5 12.5-32.8 0-45.3l-80-80z"],ClapperboardClosed:[512,512,[],"solid","M448 32l-86.1 0-1 1-127 127 92.1 0 1-1L453.8 32.3c-1.9-.2-3.8-.3-5.8-.3zm64 128l0-64c0-15.1-5.3-29.1-14-40l-104 104L512 160zM294.1 32l-92.1 0-1 1L73.9 160l92.1 0 1-1 127-127zM64 32C28.7 32 0 60.7 0 96l0 64 6.1 0 1-1 127-127L64 32zM512 192L0 192 0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-224z"],UserOff:[640,512,[],"solid","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L381.9 274c48.5-23.2 82.1-72.7 82.1-130C464 64.5 399.5 0 320 0C250.4 0 192.4 49.3 178.9 114.9L38.8 5.1zM545.5 512L528 512 284.3 320l-59 0C136.2 320 64 392.2 64 481.3c0 17 13.8 30.7 30.7 30.7l450.6 0 .3 0z"],PhotoFilm:[640,512,["Media"],"solid","M256 0L576 0c35.3 0 64 28.7 64 64l0 224c0 35.3-28.7 64-64 64l-320 0c-35.3 0-64-28.7-64-64l0-224c0-35.3 28.7-64 64-64zM476 106.7C471.5 100 464 96 456 96s-15.5 4-20 10.7l-56 84L362.7 169c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l80 0 48 0 144 0c8.9 0 17-4.9 21.2-12.7s3.7-17.3-1.2-24.6l-96-144zM336 96a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM64 128l96 0 0 256 0 32c0 17.7 14.3 32 32 32l128 0c17.7 0 32-14.3 32-32l0-32 160 0 0 64c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 192c0-35.3 28.7-64 64-64zm8 64c-8.8 0-16 7.2-16 16l0 16c0 8.8 7.2 16 16 16l16 0c8.8 0 16-7.2 16-16l0-16c0-8.8-7.2-16-16-16l-16 0zm0 104c-8.8 0-16 7.2-16 16l0 16c0 8.8 7.2 16 16 16l16 0c8.8 0 16-7.2 16-16l0-16c0-8.8-7.2-16-16-16l-16 0zm0 104c-8.8 0-16 7.2-16 16l0 16c0 8.8 7.2 16 16 16l16 0c8.8 0 16-7.2 16-16l0-16c0-8.8-7.2-16-16-16l-16 0zm336 16l0 16c0 8.8 7.2 16 16 16l16 0c8.8 0 16-7.2 16-16l0-16c0-8.8-7.2-16-16-16l-16 0c-8.8 0-16 7.2-16 16z"],Chart:[448,512,[],"solid","M160 80c0-26.5 21.5-48 48-48l32 0c26.5 0 48 21.5 48 48l0 352c0 26.5-21.5 48-48 48l-32 0c-26.5 0-48-21.5-48-48l0-352zM0 272c0-26.5 21.5-48 48-48l32 0c26.5 0 48 21.5 48 48l0 160c0 26.5-21.5 48-48 48l-32 0c-26.5 0-48-21.5-48-48L0 272zM368 96l32 0c26.5 0 48 21.5 48 48l0 288c0 26.5-21.5 48-48 48l-32 0c-26.5 0-48-21.5-48-48l0-288c0-26.5 21.5-48 48-48z"],HandsAslInterpreting:[640,512,["ASL"],"solid","M156.6 46.3c7.9-15.8 1.5-35-14.3-42.9s-35-1.5-42.9 14.3L13.5 189.4C4.6 207.2 0 226.8 0 246.7L0 256c0 70.7 57.3 128 128 128l72 0 8 0 0-.3c35.2-2.7 65.4-22.8 82.1-51.7c8.8-15.3 3.6-34.9-11.7-43.7s-34.9-3.6-43.7 11.7c-7 12-19.9 20-34.7 20c-22.1 0-40-17.9-40-40s17.9-40 40-40c14.8 0 27.7 8 34.7 20c8.8 15.3 28.4 20.5 43.7 11.7s20.5-28.4 11.7-43.7c-12.8-22.1-33.6-39.1-58.4-47.1l80.8-22c17-4.6 27.1-22.2 22.5-39.3s-22.2-27.1-39.3-22.5L194.9 124.6l81.6-68c13.6-11.3 15.4-31.5 4.1-45.1S249.1-3.9 235.5 7.4L133.6 92.3l23-46zM483.4 465.7c-7.9 15.8-1.5 35 14.3 42.9s35 1.5 42.9-14.3l85.9-171.7c8.9-17.8 13.5-37.4 13.5-57.2l0-9.3c0-70.7-57.3-128-128-128l-72 0-8 0 0 .3c-35.2 2.7-65.4 22.8-82.1 51.7c-8.9 15.3-3.6 34.9 11.7 43.7s34.9 3.6 43.7-11.7c7-12 19.9-20 34.7-20c22.1 0 40 17.9 40 40s-17.9 40-40 40c-14.8 0-27.7-8-34.7-20c-8.9-15.3-28.4-20.5-43.7-11.7s-20.5 28.4-11.7 43.7c12.8 22.1 33.6 39.1 58.4 47.1l-80.8 22c-17.1 4.7-27.1 22.2-22.5 39.3s22.2 27.1 39.3 22.5l100.7-27.5-81.6 68c-13.6 11.3-15.4 31.5-4.1 45.1s31.5 15.4 45.1 4.1l101.9-84.9-23 46z"],HandPointRight:[512,512,[],"regular","M448 128l-177.6 0c1 5.2 1.6 10.5 1.6 16l0 16 32 0 144 0c8.8 0 16-7.2 16-16s-7.2-16-16-16zM224 144c0-17.7-14.3-32-32-32c0 0 0 0 0 0l-24 0c-66.3 0-120 53.7-120 120l0 48c0 52.5 33.7 97.1 80.7 113.4c-.5-3.1-.7-6.2-.7-9.4c0-20 9.2-37.9 23.6-49.7c-4.9-9-7.6-19.4-7.6-30.3c0-15.1 5.3-29 14-40c-8.8-11-14-24.9-14-40l0-40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 40c0 8.8 7.2 16 16 16s16-7.2 16-16l0-40 0-40zM192 64s0 0 0 0c18 0 34.6 6 48 16l208 0c35.3 0 64 28.7 64 64s-28.7 64-64 64l-82 0c1.3 5.1 2 10.5 2 16c0 25.3-14.7 47.2-36 57.6c2.6 7 4 14.5 4 22.4c0 20-9.2 37.9-23.6 49.7c4.9 9 7.6 19.4 7.6 30.3c0 35.3-28.7 64-64 64l-64 0-24 0C75.2 448 0 372.8 0 280l0-48C0 139.2 75.2 64 168 64l24 0zm64 336c8.8 0 16-7.2 16-16s-7.2-16-16-16l-48 0-16 0c-8.8 0-16 7.2-16 16s7.2 16 16 16l64 0zm16-176c0 5.5-.7 10.9-2 16l2 0 32 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-32 0 0 16zm-24 64l-40 0c-8.8 0-16 7.2-16 16s7.2 16 16 16l48 0 16 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-24 0z"],HandPointUp:[384,512,[],"regular","M64 64l0 177.6c5.2-1 10.5-1.6 16-1.6l16 0 0-32L96 64c0-8.8-7.2-16-16-16s-16 7.2-16 16zM80 288c-17.7 0-32 14.3-32 32c0 0 0 0 0 0l0 24c0 66.3 53.7 120 120 120l48 0c52.5 0 97.1-33.7 113.4-80.7c-3.1 .5-6.2 .7-9.4 .7c-20 0-37.9-9.2-49.7-23.6c-9 4.9-19.4 7.6-30.3 7.6c-15.1 0-29-5.3-40-14c-11 8.8-24.9 14-40 14l-40 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l40 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-40 0-40 0zM0 320s0 0 0 0c0-18 6-34.6 16-48L16 64C16 28.7 44.7 0 80 0s64 28.7 64 64l0 82c5.1-1.3 10.5-2 16-2c25.3 0 47.2 14.7 57.6 36c7-2.6 14.5-4 22.4-4c20 0 37.9 9.2 49.7 23.6c9-4.9 19.4-7.6 30.3-7.6c35.3 0 64 28.7 64 64l0 64 0 24c0 92.8-75.2 168-168 168l-48 0C75.2 512 0 436.8 0 344l0-24zm336-64c0-8.8-7.2-16-16-16s-16 7.2-16 16l0 48 0 16c0 8.8 7.2 16 16 16s16-7.2 16-16l0-64zM160 240c5.5 0 10.9 .7 16 2l0-2 0-32c0-8.8-7.2-16-16-16s-16 7.2-16 16l0 32 16 0zm64 24l0 40c0 8.8 7.2 16 16 16s16-7.2 16-16l0-48 0-16c0-8.8-7.2-16-16-16s-16 7.2-16 16l0 24z"],HandPointDown:[384,512,[],"regular","M64 448l0-177.6c5.2 1 10.5 1.6 16 1.6l16 0 0 32 0 144c0 8.8-7.2 16-16 16s-16-7.2-16-16zM80 224c-17.7 0-32-14.3-32-32c0 0 0 0 0 0l0-24c0-66.3 53.7-120 120-120l48 0c52.5 0 97.1 33.7 113.4 80.7c-3.1-.5-6.2-.7-9.4-.7c-20 0-37.9 9.2-49.7 23.6c-9-4.9-19.4-7.6-30.3-7.6c-15.1 0-29 5.3-40 14c-11-8.8-24.9-14-40-14l-40 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l40 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-40 0-40 0zM0 192s0 0 0 0c0 18 6 34.6 16 48l0 208c0 35.3 28.7 64 64 64s64-28.7 64-64l0-82c5.1 1.3 10.5 2 16 2c25.3 0 47.2-14.7 57.6-36c7 2.6 14.5 4 22.4 4c20 0 37.9-9.2 49.7-23.6c9 4.9 19.4 7.6 30.3 7.6c35.3 0 64-28.7 64-64l0-64 0-24C384 75.2 308.8 0 216 0L168 0C75.2 0 0 75.2 0 168l0 24zm336 64c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-48 0-16c0-8.8 7.2-16 16-16s16 7.2 16 16l0 64zM160 272c5.5 0 10.9-.7 16-2l0 2 0 32c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-32 16 0zm64-24l0-40c0-8.8 7.2-16 16-16s16 7.2 16 16l0 48 0 16c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-24z"],HandPointLeft:[512,512,[],"regular","M64 128l177.6 0c-1 5.2-1.6 10.5-1.6 16l0 16-32 0L64 160c-8.8 0-16-7.2-16-16s7.2-16 16-16zm224 16c0-17.7 14.3-32 32-32c0 0 0 0 0 0l24 0c66.3 0 120 53.7 120 120l0 48c0 52.5-33.7 97.1-80.7 113.4c.5-3.1 .7-6.2 .7-9.4c0-20-9.2-37.9-23.6-49.7c4.9-9 7.6-19.4 7.6-30.3c0-15.1-5.3-29-14-40c8.8-11 14-24.9 14-40l0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-40 0-40zm32-80s0 0 0 0c-18 0-34.6 6-48 16L64 80C28.7 80 0 108.7 0 144s28.7 64 64 64l82 0c-1.3 5.1-2 10.5-2 16c0 25.3 14.7 47.2 36 57.6c-2.6 7-4 14.5-4 22.4c0 20 9.2 37.9 23.6 49.7c-4.9 9-7.6 19.4-7.6 30.3c0 35.3 28.7 64 64 64l64 0 24 0c92.8 0 168-75.2 168-168l0-48c0-92.8-75.2-168-168-168l-24 0zM256 400c-8.8 0-16-7.2-16-16s7.2-16 16-16l48 0 16 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-64 0zM240 224c0 5.5 .7 10.9 2 16l-2 0-32 0c-8.8 0-16-7.2-16-16s7.2-16 16-16l32 0 0 16zm24 64l40 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-48 0-16 0c-8.8 0-16-7.2-16-16s7.2-16 16-16l24 0z"],HandScissors:[512,512,[],"regular","M.2 276.3c-1.2-35.3 26.4-65 61.7-66.2l3.3-.1L57 208.1C22.5 200.5 .7 166.3 8.3 131.8S50.2 75.5 84.7 83.2l173 38.3c2.3-2.9 4.7-5.7 7.1-8.5l18.4-20.3C299.9 74.5 323.5 64 348.3 64l10.2 0c54.1 0 104.1 28.7 131.3 75.4l1.5 2.6c13.6 23.2 20.7 49.7 20.7 76.6L512 344c0 66.3-53.7 120-120 120l-8 0-96 0c-35.3 0-64-28.7-64-64c0-2.8 .2-5.6 .5-8.3c-19.4-11-32.5-31.8-32.5-55.7c0-.8 0-1.6 0-2.4L66.4 338c-35.3 1.2-65-26.4-66.2-61.7zm63.4-18.2c-8.8 .3-15.7 7.7-15.4 16.5s7.7 15.7 16.5 15.4l161.5-5.6c9.8-.3 18.7 5.3 22.7 14.2s2.2 19.3-4.5 26.4c-2.8 2.9-4.4 6.7-4.4 11c0 8.8 7.2 16 16 16c9.1 0 17.4 5.1 21.5 13.3s3.2 17.9-2.3 25.1c-2 2.7-3.2 6-3.2 9.6c0 8.8 7.2 16 16 16l96 0 8 0c39.8 0 72-32.2 72-72l0-125.4c0-18.4-4.9-36.5-14.2-52.4l-1.5-2.6c-18.6-32-52.8-51.6-89.8-51.6l-10.2 0c-11.3 0-22 4.8-29.6 13.1l-17.5-15.9 17.5 15.9-18.4 20.3c-.6 .6-1.1 1.3-1.7 1.9l57 13.2c8.6 2 14 10.6 12 19.2s-10.6 14-19.2 12l-85.6-19.7L74.3 130c-8.6-1.9-17.2 3.5-19.1 12.2s3.5 17.2 12.2 19.1l187.5 41.6c10.2 2.3 17.8 10.9 18.7 21.4l.1 1c.6 6.6-1.5 13.1-5.8 18.1s-10.6 7.9-17.2 8.2L63.6 258.1z"],HandSpock:[576,512,[],"regular","M170.2 80.8C161 47 180.8 12 214.6 2.4c34-9.6 69.4 10.2 79 44.2l30.3 107.1L337.1 84c6.6-34.7 40.1-57.5 74.8-50.9c31.4 6 53 33.9 52 64.9c10-2.6 20.8-2.8 31.5-.1c34.3 8.6 55.1 43.3 46.6 77.6L486.7 397.2C469.8 464.7 409.2 512 339.6 512l-33.7 0c-56.9 0-112.2-19-157.2-53.9l-92-71.6c-27.9-21.7-32.9-61.9-11.2-89.8s61.9-32.9 89.8-11.2l17 13.2L100.5 167.5c-13-32.9 3.2-70.1 36-83c11.1-4.4 22.7-5.4 33.7-3.7zm77.1-21.2c-2.4-8.5-11.2-13.4-19.7-11s-13.4 11.2-11 19.7l54.8 182.4c3.5 12.3-3.3 25.2-15.4 29.3s-25.3-2-30-13.9L174.9 138.1c-3.2-8.2-12.5-12.3-20.8-9s-12.3 12.5-9 20.8l73.3 185.6c12 30.3-23.7 57-49.4 37l-63.1-49.1c-7-5.4-17-4.2-22.5 2.8s-4.2 17 2.8 22.5l92 71.6c36.5 28.4 81.4 43.8 127.7 43.8l33.7 0c47.5 0 89-32.4 100.5-78.5l55.4-221.6c2.1-8.6-3.1-17.3-11.6-19.4s-17.3 3.1-19.4 11.6l-26 104C435.6 271.8 425 280 413 280c-16.5 0-28.9-15-25.8-31.2L415.7 99c1.7-8.7-4-17.1-12.7-18.7s-17.1 4-18.7 12.7L352.5 260c-2.2 11.6-12.4 20-24.2 20c-11 0-20.7-7.3-23.7-17.9L247.4 59.6z"],HandBackFist:[448,512,["HandRock"],"regular","M144 64c0-8.8 7.2-16 16-16s16 7.2 16 16c0 9.1 5.1 17.4 13.3 21.5s17.9 3.2 25.1-2.3c2.7-2 6-3.2 9.6-3.2c8.8 0 16 7.2 16 16c0 9.1 5.1 17.4 13.3 21.5s17.9 3.2 25.1-2.3c2.7-2 6-3.2 9.6-3.2c8.8 0 16 7.2 16 16c0 9.1 5.1 17.4 13.3 21.5s17.9 3.2 25.1-2.3c2.7-2 6-3.2 9.6-3.2c8.8 0 16 7.2 16 16l0 104c0 31.3-20 58-48 67.9c-9.6 3.4-16 12.5-16 22.6L304 488c0 13.3 10.7 24 24 24s24-10.7 24-24l0-117.8c38-20.1 64-60.1 64-106.2l0-104c0-35.3-28.7-64-64-64c-2.8 0-5.6 .2-8.3 .5C332.8 77.1 311.9 64 288 64c-2.8 0-5.6 .2-8.3 .5C268.8 45.1 247.9 32 224 32c-2.8 0-5.6 .2-8.3 .5C204.8 13.1 183.9 0 160 0C124.7 0 96 28.7 96 64l0 64.3c-11.7 7.4-22.5 16.4-32 26.9l17.8 16.1L64 155.2l-9.4 10.5C40 181.8 32 202.8 32 224.6l0 12.8c0 49.6 24.2 96.1 64.8 124.5l13.8-19.7L96.8 361.9l8.9 6.2c6.9 4.8 14.4 8.6 22.3 11.3L128 488c0 13.3 10.7 24 24 24s24-10.7 24-24l0-128.1c0-12.6-9.8-23.1-22.4-23.9c-7.3-.5-14.3-2.9-20.3-7.1l-13.1 18.7 13.1-18.7-8.9-6.2C96.6 303.1 80 271.3 80 237.4l0-12.8c0-9.9 3.7-19.4 10.3-26.8l9.4-10.5c3.8-4.2 7.9-8.1 12.3-11.6l0 32.3c0 8.8 7.2 16 16 16s16-7.2 16-16l0-65.7 0-14.3 0-64z"],HandLizard:[512,512,[],"regular","M72 112c-13.3 0-24 10.7-24 24s10.7 24 24 24l168 0c35.3 0 64 28.7 64 64s-28.7 64-64 64l-104 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l152 0c4.5 0 8.9 1.3 12.7 3.6l64 40c7 4.4 11.3 12.1 11.3 20.4l0 24c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-10.7L281.1 384 136 384c-39.8 0-72-32.2-72-72s32.2-72 72-72l104 0c8.8 0 16-7.2 16-16s-7.2-16-16-16L72 208c-39.8 0-72-32.2-72-72S32.2 64 72 64l209.6 0c46.7 0 90.9 21.5 119.7 58.3l78.4 100.1c20.9 26.7 32.3 59.7 32.3 93.7L512 424c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-107.9c0-23.2-7.8-45.8-22.1-64.1L363.5 151.9c-19.7-25.2-49.9-39.9-81.9-39.9L72 112z"],HandPeace:[512,512,[],"regular","M250.8 1.4c-35.2-3.7-66.6 21.8-70.3 57L174 119 156.7 69.6C145 36.3 108.4 18.8 75.1 30.5S24.2 78.8 35.9 112.1L88.7 262.2C73.5 276.7 64 297.3 64 320c0 0 0 0 0 0l0 24c0 92.8 75.2 168 168 168l48 0c92.8 0 168-75.2 168-168l0-72 0-16 0-32c0-35.3-28.7-64-64-64c-7.9 0-15.4 1.4-22.4 4c-10.4-21.3-32.3-36-57.6-36c-.7 0-1.5 0-2.2 0l5.9-56.3c3.7-35.2-21.8-66.6-57-70.3zm-.2 155.4C243.9 166.9 240 179 240 192l0 48c0 .7 0 1.4 0 2c-5.1-1.3-10.5-2-16-2l-7.4 0-5.4-15.3 17-161.3c.9-8.8 8.8-15.2 17.6-14.2s15.2 8.8 14.2 17.6l-9.5 90.1zM111.4 85.6L165.7 240 144 240c-4 0-8 .3-11.9 .9L81.2 96.2c-2.9-8.3 1.5-17.5 9.8-20.4s17.5 1.5 20.4 9.8zM288 192c0-8.8 7.2-16 16-16s16 7.2 16 16l0 32 0 16c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-48zm38.4 108c10.4 21.3 32.3 36 57.6 36c5.5 0 10.9-.7 16-2l0 10c0 66.3-53.7 120-120 120l-48 0c-66.3 0-120-53.7-120-120l0-24s0 0 0 0c0-17.7 14.3-32 32-32l80 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-40 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l40 0c35.3 0 64-28.7 64-64c0-.7 0-1.4 0-2c5.1 1.3 10.5 2 16 2c7.9 0 15.4-1.4 22.4-4zM400 272c0 8.8-7.2 16-16 16s-16-7.2-16-16l0-32 0-16c0-8.8 7.2-16 16-16s16 7.2 16 16l0 32 0 16z"],Html:[24,24,[],"solid","m3 2l1.578 17.824L12 22l7.467-2.175L21 2zm14.049 6.048H9.075l.172 2.016h7.697l-.626 6.565l-4.246 1.381l-4.281-1.455l-.288-2.932h2.024l.16 1.411l2.4.815l2.346-.763l.297-3.005H7.416l-.562-6.05h10.412z"],CircleNodes:[512,512,[],"solid","M418.4 157.9c35.3-8.3 61.6-40 61.6-77.9c0-44.2-35.8-80-80-80c-43.4 0-78.7 34.5-80 77.5L136.2 151.1C121.7 136.8 101.9 128 80 128c-44.2 0-80 35.8-80 80s35.8 80 80 80c12.2 0 23.8-2.7 34.1-7.6L259.7 407.8c-2.4 7.6-3.7 15.8-3.7 24.2c0 44.2 35.8 80 80 80s80-35.8 80-80c0-27.7-14-52.1-35.4-66.4l37.8-207.7zM156.3 232.2c2.2-6.9 3.5-14.2 3.7-21.7l183.8-73.5c3.6 3.5 7.4 6.7 11.6 9.5L317.6 354.1c-5.5 1.3-10.8 3.1-15.8 5.5L156.3 232.2z"],CircleRight:[512,512,[],"regular","M464 256A208 208 0 1 1 48 256a208 208 0 1 1 416 0zM0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zM294.6 151.2c-4.2-4.6-10.1-7.2-16.4-7.2C266 144 256 154 256 166.3l0 41.7-96 0c-17.7 0-32 14.3-32 32l0 32c0 17.7 14.3 32 32 32l96 0 0 41.7c0 12.3 10 22.3 22.3 22.3c6.2 0 12.1-2.6 16.4-7.2l84-91c3.5-3.8 5.4-8.7 5.4-13.9s-1.9-10.1-5.4-13.9l-84-91z"],CircleUp:[512,512,[],"regular","M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM151.2 217.4c-4.6 4.2-7.2 10.1-7.2 16.4c0 12.3 10 22.3 22.3 22.3l41.7 0 0 96c0 17.7 14.3 32 32 32l32 0c17.7 0 32-14.3 32-32l0-96 41.7 0c12.3 0 22.3-10 22.3-22.3c0-6.2-2.6-12.1-7.2-16.4l-91-84c-3.8-3.5-8.7-5.4-13.9-5.4s-10.1 1.9-13.9 5.4l-91 84z"],CircleLeft:[512,512,[],"regular","M48 256a208 208 0 1 1 416 0A208 208 0 1 1 48 256zm464 0A256 256 0 1 0 0 256a256 256 0 1 0 512 0zM217.4 376.9c4.2 4.5 10.1 7.1 16.3 7.1c12.3 0 22.3-10 22.3-22.3l0-57.7 96 0c17.7 0 32-14.3 32-32l0-32c0-17.7-14.3-32-32-32l-96 0 0-57.7c0-12.3-10-22.3-22.3-22.3c-6.2 0-12.1 2.6-16.3 7.1L117.5 242.2c-3.5 3.8-5.5 8.7-5.5 13.8s2 10.1 5.5 13.8l99.9 107.1z"],CircleDown:[512,512,[],"regular","M256 464a208 208 0 1 1 0-416 208 208 0 1 1 0 416zM256 0a256 256 0 1 0 0 512A256 256 0 1 0 256 0zM376.9 294.6c4.5-4.2 7.1-10.1 7.1-16.3c0-12.3-10-22.3-22.3-22.3L304 256l0-96c0-17.7-14.3-32-32-32l-32 0c-17.7 0-32 14.3-32 32l0 96-57.7 0C138 256 128 266 128 278.3c0 6.2 2.6 12.1 7.1 16.3l107.1 99.9c3.8 3.5 8.7 5.5 13.8 5.5s10.1-2 13.8-5.5l107.1-99.9z"],WindowRestore:[512,512,[],"solid","M432 48L208 48c-17.7 0-32 14.3-32 32l0 16-48 0 0-16c0-44.2 35.8-80 80-80L432 0c44.2 0 80 35.8 80 80l0 224c0 44.2-35.8 80-80 80l-16 0 0-48 16 0c17.7 0 32-14.3 32-32l0-224c0-17.7-14.3-32-32-32zM48 448c0 8.8 7.2 16 16 16l256 0c8.8 0 16-7.2 16-16l0-192L48 256l0 192zM64 128l256 0c35.3 0 64 28.7 64 64l0 256c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 192c0-35.3 28.7-64 64-64z"],WindowMaximize:[512,512,[],"solid","M.3 89.5C.1 91.6 0 93.8 0 96L0 224 0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-192 0-128c0-35.3-28.7-64-64-64L64 32c-2.2 0-4.4 .1-6.5 .3c-9.2 .9-17.8 3.8-25.5 8.2C21.8 46.5 13.4 55.1 7.7 65.5c-3.9 7.3-6.5 15.4-7.4 24zM48 224l416 0 0 192c0 8.8-7.2 16-16 16L64 432c-8.8 0-16-7.2-16-16l0-192z"],WindowMinimize:[512,512,[],"solid","M24 432c-13.3 0-24 10.7-24 24s10.7 24 24 24l464 0c13.3 0 24-10.7 24-24s-10.7-24-24-24L24 432z"],VrCardboard:[640,512,["VR"],"solid","M576 64L64 64C28.7 64 0 92.7 0 128L0 384c0 35.3 28.7 64 64 64l120.4 0c24.2 0 46.4-13.7 57.2-35.4l32-64c8.8-17.5 26.7-28.6 46.3-28.6s37.5 11.1 46.3 28.6l32 64c10.8 21.7 33 35.4 57.2 35.4L576 448c35.3 0 64-28.7 64-64l0-256c0-35.3-28.7-64-64-64zM96 240a64 64 0 1 1 128 0A64 64 0 1 1 96 240zm384-64a64 64 0 1 1 0 128 64 64 0 1 1 0-128z"],C:[32,32,[],"solid","M29.86 8c-.224-.385-.532-.724-.871-.921L17.234.292c-.677-.391-1.787-.391-2.464 0L3.015 7.079C2.338 7.47 1.78 8.432 1.78 9.214v13.573c0 .391.14.828.364 1.213.219.385.532.724.871.917l11.749 6.791c.683.391 1.787.391 2.464 0l11.755-6.791c.339-.193.647-.532.871-.917s.359-.823.359-1.213V9.214c.005-.391-.135-.828-.353-1.213zM16 25.479c-5.229 0-9.479-4.249-9.479-9.479S10.77 6.521 16 6.521a9.51 9.51 0 0 1 8.208 4.733l-4.104 2.376A4.76 4.76 0 0 0 16 11.259c-2.615 0-4.74 2.125-4.74 4.74s2.125 4.74 4.74 4.74a4.76 4.76 0 0 0 4.104-2.371l4.104 2.376A9.51 9.51 0 0 1 16 25.479z",{svgClass:"stroke-none"}],CPlusPlus:[32,32,[],"solid","M29.86 8c-.224-.385-.532-.724-.871-.921L17.234.292c-.677-.391-1.787-.391-2.464 0L3.015 7.079C2.338 7.47 1.78 8.432 1.78 9.214v13.573c0 .391.14.828.364 1.213c.219.385.532.724.871.917l11.749 6.791c.683.391 1.787.391 2.464 0l11.755-6.791c.339-.193.647-.532.871-.917s.359-.823.359-1.213V9.214c.005-.391-.135-.828-.353-1.213zM16 25.479c-5.229 0-9.479-4.249-9.479-9.479S10.77 6.521 16 6.521a9.51 9.51 0 0 1 8.208 4.733l-4.104 2.376A4.76 4.76 0 0 0 16 11.259c-2.615 0-4.74 2.125-4.74 4.74s2.125 4.74 4.74 4.74a4.76 4.76 0 0 0 4.104-2.371l4.104 2.376A9.51 9.51 0 0 1 16 25.477zm9.479-8.952h-1.052v1.052H23.37v-1.052h-1.052v-1.053h1.052v-1.052h1.057v1.052h1.052zm3.948 0h-1.052v1.052h-1.052v-1.052h-1.052v-1.053h1.052v-1.052h1.052v1.052h1.052z",{svgClass:"stroke-none"}],Css:[24,24,[],"solid","M0 0v20.16A3.84 3.84 0 0 0 3.84 24h16.32A3.84 3.84 0 0 0 24 20.16V3.84A3.84 3.84 0 0 0 20.16 0Zm14.256 13.08c1.56 0 2.28 1.08 2.304 2.64h-1.608c.024-.288-.048-.6-.144-.84c-.096-.192-.288-.264-.552-.264c-.456 0-.696.264-.696.84c-.024.576.288.888.768 1.08c.72.288 1.608.744 1.92 1.296q.432.648.432 1.656c0 1.608-.912 2.592-2.496 2.592c-1.656 0-2.4-1.032-2.424-2.688h1.68c0 .792.264 1.176.792 1.176c.264 0 .456-.072.552-.24c.192-.312.24-1.176-.048-1.512c-.312-.408-.912-.6-1.32-.816q-.828-.396-1.224-.936c-.24-.36-.36-.888-.36-1.536c0-1.44.936-2.472 2.424-2.448m5.4 0c1.584 0 2.304 1.08 2.328 2.64h-1.608c0-.288-.048-.6-.168-.84c-.096-.192-.264-.264-.528-.264c-.48 0-.72.264-.72.84s.288.888.792 1.08c.696.288 1.608.744 1.92 1.296c.264.432.408.984.408 1.656c.024 1.608-.888 2.592-2.472 2.592c-1.68 0-2.424-1.056-2.448-2.688h1.68c0 .744.264 1.176.792 1.176c.264 0 .456-.072.552-.24c.216-.312.264-1.176-.048-1.512c-.288-.408-.888-.6-1.32-.816c-.552-.264-.96-.576-1.2-.936s-.36-.888-.36-1.536c-.024-1.44.912-2.472 2.4-2.448m-11.031.018c.711-.006 1.419.198 1.839.63c.432.432.672 1.128.648 1.992H9.336c.024-.456-.096-.792-.432-.96c-.312-.144-.768-.048-.888.24c-.12.264-.192.576-.168.864v3.504c0 .744.264 1.128.768 1.128a.65.65 0 0 0 .552-.264c.168-.24.192-.552.168-.84h1.776c.096 1.632-.984 2.712-2.568 2.688c-1.536 0-2.496-.864-2.472-2.472v-4.032c0-.816.24-1.44.696-1.848c.432-.408 1.146-.624 1.857-.63"],Discord:[640,512,[],"solid","M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"],Godot:[32,32,[],"solid","M12.745.917c-1.458.328-2.906.781-4.266 1.464a32 32 0 0 0 .266 3.505c-.526.339-1.078.63-1.568 1.026c-.5.38-1.01.75-1.464 1.198a28 28 0 0 0-2.849-1.651C1.801 7.6.812 8.834-.001 10.214c.609.99 1.25 1.911 1.938 2.792h.016v8.474a.2.2 0 0 1 .047.005l5.198.5a.554.554 0 0 1 .5.521l.161 2.292l4.531.323l.313-2.115a.56.56 0 0 1 .552-.479h5.484a.56.56 0 0 1 .552.479l.313 2.115l4.531-.323l.161-2.292a.554.554 0 0 1 .505-.521l5.193-.5c.016 0 .031-.005.047-.005v-8.474h.021a30 30 0 0 0 1.932-2.792c-.807-1.38-1.802-2.615-2.865-3.755A29 29 0 0 0 26.28 8.11c-.453-.448-.958-.818-1.458-1.198c-.495-.396-1.047-.688-1.573-1.026c.156-1.161.234-2.307.266-3.505c-1.354-.682-2.802-1.135-4.266-1.464A31 31 0 0 0 17.671 4a11 11 0 0 0-1.661-.13h-.026c-.552.005-1.109.042-1.661.13A30 30 0 0 0 12.74.917zm-4.11 12.406a3.134 3.134 0 0 1 3.13 3.135a3.13 3.13 0 1 1-6.26 0a3.134 3.134 0 0 1 3.13-3.135m14.73 0a3.134 3.134 0 0 1 3.13 3.135a3.13 3.13 0 1 1-6.26 0a3.134 3.134 0 0 1 3.13-3.135M8.932 14.568a2.076 2.076 0 1 0 0 4.151a2.077 2.077 0 0 0 2.083-2.073a2.08 2.08 0 0 0-2.083-2.078m14.131 0a2.076 2.076 0 1 0 0 4.151a2.073 2.073 0 0 0 2.078-2.073a2.074 2.074 0 0 0-2.078-2.078M16 15.172c.557 0 1.01.406 1.01.911v2.885c0 .505-.453.917-1.01.917s-1.01-.411-1.01-.917v-2.885c0-.505.453-.911 1.01-.911M1.948 22.599c0 .505.005 1.052.005 1.161c0 4.938 6.26 7.307 14.036 7.333h.021c7.776-.026 14.031-2.396 14.031-7.333l.01-1.161l-4.672.453l-.161 2.307a.556.556 0 0 1-.516.516l-5.578.396a.56.56 0 0 1-.552-.474l-.318-2.156h-4.516l-.318 2.156a.557.557 0 0 1-.594.474l-5.531-.396a.565.565 0 0 1-.521-.516l-.156-2.307l-4.672-.448z"],Google:[488,512,[],"solid","M488 261.8C488 403.3 391.1 504 248 504 110.8 504 0 393.2 0 256S110.8 8 248 8c66.8 0 123 24.5 166.3 64.9l-67.5 64.9C258.5 52.6 94.3 116.6 94.3 256c0 86.5 69.1 156.6 153.7 156.6 98.2 0 135-70.4 140.8-106.9H248v-85.3h236.1c2.3 12.7 3.9 24.9 3.9 41.4z"],Go:[24,24,[],"solid","M1.811 10.231c-.047 0-.058-.023-.035-.059l.246-.315c.023-.035.081-.058.128-.058h4.172c.046 0 .058.035.035.07l-.199.303c-.023.036-.082.07-.117.07zM.047 11.306c-.047 0-.059-.023-.035-.058l.245-.316c.023-.035.082-.058.129-.058h5.328c.047 0 .07.035.058.07l-.093.28c-.012.047-.058.07-.105.07zm2.828 1.075c-.047 0-.059-.035-.035-.07l.163-.292c.023-.035.07-.07.117-.07h2.337c.047 0 .07.035.07.082l-.023.28c0 .047-.047.082-.082.082zm12.129-2.36c-.736.187-1.239.327-1.963.514c-.176.046-.187.058-.34-.117c-.174-.199-.303-.327-.548-.444c-.737-.362-1.45-.257-2.115.175c-.795.514-1.204 1.274-1.192 2.22c.011.935.654 1.706 1.577 1.835c.795.105 1.46-.175 1.987-.77c.105-.13.198-.27.315-.434H10.47c-.245 0-.304-.152-.222-.35c.152-.362.432-.97.596-1.274a.32.32 0 0 1 .292-.187h4.253c-.023.316-.023.631-.07.947a5 5 0 0 1-.958 2.29c-.841 1.11-1.94 1.8-3.33 1.986c-1.145.152-2.209-.07-3.143-.77c-.865-.655-1.356-1.52-1.484-2.595c-.152-1.274.222-2.419.993-3.424c.83-1.086 1.928-1.776 3.272-2.02c1.098-.2 2.15-.07 3.096.571c.62.41 1.063.97 1.356 1.648c.07.105.023.164-.117.2m3.868 6.461c-1.064-.024-2.034-.328-2.852-1.029a3.67 3.67 0 0 1-1.262-2.255c-.21-1.32.152-2.489.947-3.529c.853-1.122 1.881-1.706 3.272-1.95c1.192-.21 2.314-.095 3.33.595c.923.63 1.496 1.484 1.648 2.605c.198 1.578-.257 2.863-1.344 3.962c-.771.783-1.718 1.273-2.805 1.495c-.315.06-.63.07-.934.106m2.78-4.72c-.011-.153-.011-.27-.034-.387c-.21-1.157-1.274-1.81-2.384-1.554c-1.087.245-1.788.935-2.045 2.033c-.21.912.234 1.835 1.075 2.21c.643.28 1.285.244 1.905-.07c.923-.48 1.425-1.228 1.484-2.233z"],Git:[32,32,[],"solid","M13.172 2.828L11.78 4.22l1.91 1.91l2 2A2.986 2.986 0 0 1 20 10.81a3.25 3.25 0 0 1-.31 1.31l2.06 2a2.68 2.68 0 0 1 3.37.57a2.86 2.86 0 0 1 .88 2.117a3.02 3.02 0 0 1-.856 2.109A2.9 2.9 0 0 1 23 19.81a2.93 2.93 0 0 1-2.13-.87a2.694 2.694 0 0 1-.56-3.38l-2-2.06a3 3 0 0 1-.31.12V20a3 3 0 0 1 1.44 1.09a2.92 2.92 0 0 1 .56 1.72a2.88 2.88 0 0 1-.878 2.128a2.98 2.98 0 0 1-2.048.871a2.981 2.981 0 0 1-2.514-4.719A3 3 0 0 1 16 20v-6.38a2.96 2.96 0 0 1-1.44-1.09a2.9 2.9 0 0 1-.56-1.72a2.9 2.9 0 0 1 .31-1.31l-3.9-3.9l-7.579 7.572a4 4 0 0 0-.001 5.658l10.342 10.342a4 4 0 0 0 5.656 0l10.344-10.344a4 4 0 0 0 0-5.656L18.828 2.828a4 4 0 0 0-5.656 0"],Json:[32,32,[],"solid","M4.014 14.976a2.5 2.5 0 0 0 1.567-.518a2.38 2.38 0 0 0 .805-1.358a15.3 15.3 0 0 0 .214-2.944q.012-2.085.075-2.747a5.2 5.2 0 0 1 .418-1.686a3 3 0 0 1 .755-1.018A3.05 3.05 0 0 1 9 4.125A6.8 6.8 0 0 1 10.544 4h.7v1.96h-.387a2.34 2.34 0 0 0-1.723.468a3.4 3.4 0 0 0-.425 2.092a36 36 0 0 1-.137 4.133a4.7 4.7 0 0 1-.768 2.06A4.6 4.6 0 0 1 6.1 16a3.8 3.8 0 0 1 1.992 1.754a8.9 8.9 0 0 1 .618 3.865q0 2.435.05 2.9a1.76 1.76 0 0 0 .504 1.181a2.64 2.64 0 0 0 1.592.337h.387V28h-.7a5.7 5.7 0 0 1-1.773-.2a2.97 2.97 0 0 1-1.324-.93a3.35 3.35 0 0 1-.681-1.63a24 24 0 0 1-.165-3.234a16.5 16.5 0 0 0-.214-3.106a2.4 2.4 0 0 0-.805-1.361a2.5 2.5 0 0 0-1.567-.524Zm23.972 2.035a2.5 2.5 0 0 0-1.567.524a2.4 2.4 0 0 0-.805 1.361a16.5 16.5 0 0 0-.212 3.109a24 24 0 0 1-.169 3.234a3.35 3.35 0 0 1-.681 1.63a2.97 2.97 0 0 1-1.324.93a5.7 5.7 0 0 1-1.773.2h-.7V26.04h.387a2.64 2.64 0 0 0 1.592-.337a1.76 1.76 0 0 0 .506-1.186q.05-.462.05-2.9a8.9 8.9 0 0 1 .618-3.865A3.8 3.8 0 0 1 25.9 16a4.6 4.6 0 0 1-1.7-1.286a4.7 4.7 0 0 1-.768-2.06a36 36 0 0 1-.137-4.133a3.4 3.4 0 0 0-.425-2.092a2.34 2.34 0 0 0-1.723-.468h-.387V4h.7a6.8 6.8 0 0 1 1.54.125a3.05 3.05 0 0 1 1.149.581a3 3 0 0 1 .755 1.018a5.2 5.2 0 0 1 .418 1.686q.062.662.075 2.747a15.3 15.3 0 0 0 .212 2.947a2.38 2.38 0 0 0 .805 1.355a2.5 2.5 0 0 0 1.567.518Z"],Js:[32,32,[],"solid","M18.774 19.7a3.73 3.73 0 0 0 3.376 2.078c1.418 0 2.324-.709 2.324-1.688c0-1.173-.931-1.589-2.491-2.272l-.856-.367c-2.469-1.052-4.11-2.37-4.11-5.156c0-2.567 1.956-4.52 5.012-4.52A5.06 5.06 0 0 1 26.9 10.52l-2.665 1.711a2.33 2.33 0 0 0-2.2-1.467a1.49 1.49 0 0 0-1.638 1.467c0 1.027.636 1.442 2.1 2.078l.856.366c2.908 1.247 4.549 2.518 4.549 5.376c0 3.081-2.42 4.769-5.671 4.769a6.58 6.58 0 0 1-6.236-3.5ZM6.686 20c.538.954 1.027 1.76 2.2 1.76c1.124 0 1.834-.44 1.834-2.15V7.975h3.422v11.683c0 3.543-2.078 5.156-5.11 5.156A5.31 5.31 0 0 1 3.9 21.688Z"],Ts:[32,32,[],"solid","M23.827 8.243a4.4 4.4 0 0 1 2.223 1.281a6 6 0 0 1 .852 1.143c.011.045-1.534 1.083-2.471 1.662c-.034.023-.169-.124-.322-.35a2.01 2.01 0 0 0-1.67-1c-1.077-.074-1.771.49-1.766 1.433a1.3 1.3 0 0 0 .153.666c.237.49.677.784 2.059 1.383c2.544 1.095 3.636 1.817 4.31 2.843a5.16 5.16 0 0 1 .416 4.333a4.76 4.76 0 0 1-3.932 2.815a11 11 0 0 1-2.708-.028a6.53 6.53 0 0 1-3.616-1.884a6.3 6.3 0 0 1-.926-1.371a3 3 0 0 1 .327-.208c.158-.09.756-.434 1.32-.761l1.024-.6l.214.312a4.8 4.8 0 0 0 1.35 1.292a3.3 3.3 0 0 0 3.458-.175a1.545 1.545 0 0 0 .2-1.974c-.276-.395-.84-.727-2.443-1.422a8.8 8.8 0 0 1-3.349-2.055a4.7 4.7 0 0 1-.976-1.777a7.1 7.1 0 0 1-.062-2.268a4.33 4.33 0 0 1 3.644-3.374a9 9 0 0 1 2.691.084m-8.343 1.483l.011 1.454h-4.63v13.148H7.6V11.183H2.97V9.755a14 14 0 0 1 .04-1.466c.017-.023 2.832-.034 6.245-.028l6.211.017Z"],Linux:[448,512,[],"regular","M220.8 123.3c1 .5 1.8 1.7 3 1.7 1.1 0 2.8-.4 2.9-1.5.2-1.4-1.9-2.3-3.2-2.9-1.7-.7-3.9-1-5.5-.1-.4.2-.8.7-.6 1.1.3 1.3 2.3 1.1 3.4 1.7zm-21.9 1.7c1.2 0 2-1.2 3-1.7 1.1-.6 3.1-.4 3.5-1.6.2-.4-.2-.9-.6-1.1-1.6-.9-3.8-.6-5.5.1-1.3.6-3.4 1.5-3.2 2.9.1 1 1.8 1.5 2.8 1.4zM420 403.8c-3.6-4-5.3-11.6-7.2-19.7-1.8-8.1-3.9-16.8-10.5-22.4-1.3-1.1-2.6-2.1-4-2.9-1.3-.8-2.7-1.5-4.1-2 9.2-27.3 5.6-54.5-3.7-79.1-11.4-30.1-31.3-56.4-46.5-74.4-17.1-21.5-33.7-41.9-33.4-72C311.1 85.4 315.7.1 234.8 0 132.4-.2 158 103.4 156.9 135.2c-1.7 23.4-6.4 41.8-22.5 64.7-18.9 22.5-45.5 58.8-58.1 96.7-6 17.9-8.8 36.1-6.2 53.3-6.5 5.8-11.4 14.7-16.6 20.2-4.2 4.3-10.3 5.9-17 8.3s-14 6-18.5 14.5c-2.1 3.9-2.8 8.1-2.8 12.4 0 3.9.6 7.9 1.2 11.8 1.2 8.1 2.5 15.7.8 20.8-5.2 14.4-5.9 24.4-2.2 31.7 3.8 7.3 11.4 10.5 20.1 12.3 17.3 3.6 40.8 2.7 59.3 12.5 19.8 10.4 39.9 14.1 55.9 10.4 11.6-2.6 21.1-9.6 25.9-20.2 12.5-.1 26.3-5.4 48.3-6.6 14.9-1.2 33.6 5.3 55.1 4.1.6 2.3 1.4 4.6 2.5 6.7v.1c8.3 16.7 23.8 24.3 40.3 23 16.6-1.3 34.1-11 48.3-27.9 13.6-16.4 36-23.2 50.9-32.2 7.4-4.5 13.4-10.1 13.9-18.3.4-8.2-4.4-17.3-15.5-29.7zM223.7 87.3c9.8-22.2 34.2-21.8 44-.4 6.5 14.2 3.6 30.9-4.3 40.4-1.6-.8-5.9-2.6-12.6-4.9 1.1-1.2 3.1-2.7 3.9-4.6 4.8-11.8-.2-27-9.1-27.3-7.3-.5-13.9 10.8-11.8 23-4.1-2-9.4-3.5-13-4.4-1-6.9-.3-14.6 2.9-21.8zM183 75.8c10.1 0 20.8 14.2 19.1 33.5-3.5 1-7.1 2.5-10.2 4.6 1.2-8.9-3.3-20.1-9.6-19.6-8.4.7-9.8 21.2-1.8 28.1 1 .8 1.9-.2-5.9 5.5-15.6-14.6-10.5-52.1 8.4-52.1zm-13.6 60.7c6.2-4.6 13.6-10 14.1-10.5 4.7-4.4 13.5-14.2 27.9-14.2 7.1 0 15.6 2.3 25.9 8.9 6.3 4.1 11.3 4.4 22.6 9.3 8.4 3.5 13.7 9.7 10.5 18.2-2.6 7.1-11 14.4-22.7 18.1-11.1 3.6-19.8 16-38.2 14.9-3.9-.2-7-1-9.6-2.1-8-3.5-12.2-10.4-20-15-8.6-4.8-13.2-10.4-14.7-15.3-1.4-4.9 0-9 4.2-12.3zm3.3 334c-2.7 35.1-43.9 34.4-75.3 18-29.9-15.8-68.6-6.5-76.5-21.9-2.4-4.7-2.4-12.7 2.6-26.4v-.2c2.4-7.6.6-16-.6-23.9-1.2-7.8-1.8-15 .9-20 3.5-6.7 8.5-9.1 14.8-11.3 10.3-3.7 11.8-3.4 19.6-9.9 5.5-5.7 9.5-12.9 14.3-18 5.1-5.5 10-8.1 17.7-6.9 8.1 1.2 15.1 6.8 21.9 16l19.6 35.6c9.5 19.9 43.1 48.4 41 68.9zm-1.4-25.9c-4.1-6.6-9.6-13.6-14.4-19.6 7.1 0 14.2-2.2 16.7-8.9 2.3-6.2 0-14.9-7.4-24.9-13.5-18.2-38.3-32.5-38.3-32.5-13.5-8.4-21.1-18.7-24.6-29.9s-3-23.3-.3-35.2c5.2-22.9 18.6-45.2 27.2-59.2 2.3-1.7.8 3.2-8.7 20.8-8.5 16.1-24.4 53.3-2.6 82.4.6-20.7 5.5-41.8 13.8-61.5 12-27.4 37.3-74.9 39.3-112.7 1.1.8 4.6 3.2 6.2 4.1 4.6 2.7 8.1 6.7 12.6 10.3 12.4 10 28.5 9.2 42.4 1.2 6.2-3.5 11.2-7.5 15.9-9 9.9-3.1 17.8-8.6 22.3-15 7.7 30.4 25.7 74.3 37.2 95.7 6.1 11.4 18.3 35.5 23.6 64.6 3.3-.1 7 .4 10.9 1.4 13.8-35.7-11.7-74.2-23.3-84.9-4.7-4.6-4.9-6.6-2.6-6.5 12.6 11.2 29.2 33.7 35.2 59 2.8 11.6 3.3 23.7.4 35.7 16.4 6.8 35.9 17.9 30.7 34.8-2.2-.1-3.2 0-4.2 0 3.2-10.1-3.9-17.6-22.8-26.1-19.6-8.6-36-8.6-38.3 12.5-12.1 4.2-18.3 14.7-21.4 27.3-2.8 11.2-3.6 24.7-4.4 39.9-.5 7.7-3.6 18-6.8 29-32.1 22.9-76.7 32.9-114.3 7.2zm257.4-11.5c-.9 16.8-41.2 19.9-63.2 46.5-13.2 15.7-29.4 24.4-43.6 25.5s-26.5-4.8-33.7-19.3c-4.7-11.1-2.4-23.1 1.1-36.3 3.7-14.2 9.2-28.8 9.9-40.6.8-15.2 1.7-28.5 4.2-38.7 2.6-10.3 6.6-17.2 13.7-21.1.3-.2.7-.3 1-.5.8 13.2 7.3 26.6 18.8 29.5 12.6 3.3 30.7-7.5 38.4-16.3 9-.3 15.7-.9 22.6 5.1 9.9 8.5 7.1 30.3 17.1 41.6 10.6 11.6 14 19.5 13.7 24.6zM173.3 148.7c2 1.9 4.7 4.5 8 7.1 6.6 5.2 15.8 10.6 27.3 10.6 11.6 0 22.5-5.9 31.8-10.8 4.9-2.6 10.9-7 14.8-10.4s5.9-6.3 3.1-6.6-2.6 2.6-6 5.1c-4.4 3.2-9.7 7.4-13.9 9.8-7.4 4.2-19.5 10.2-29.9 10.2s-18.7-4.8-24.9-9.7c-3.1-2.5-5.7-5-7.7-6.9-1.5-1.4-1.9-4.6-4.3-4.9-1.4-.1-1.8 3.7 1.7 6.5z"],SquareJs:[448,512,[],"solid","M448 96c0-35.3-28.7-64-64-64H64C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96zM180.9 444.9c-33.7 0-53.2-17.4-63.2-38.5L152 385.7c6.6 11.7 12.6 21.6 27.1 21.6c13.8 0 22.6-5.4 22.6-26.5V237.7h42.1V381.4c0 43.6-25.6 63.5-62.9 63.5zm85.8-43L301 382.1c9 14.7 20.8 25.6 41.5 25.6c17.4 0 28.6-8.7 28.6-20.8c0-14.4-11.4-19.5-30.7-28l-10.5-4.5c-30.4-12.9-50.5-29.2-50.5-63.5c0-31.6 24.1-55.6 61.6-55.6c26.8 0 46 9.3 59.8 33.7L368 290c-7.2-12.9-15-18-27.1-18c-12.3 0-20.1 7.8-20.1 18c0 12.6 7.8 17.7 25.9 25.6l10.5 4.5c35.8 15.3 55.9 31 55.9 66.2c0 37.8-29.8 58.6-69.7 58.6c-39.1 0-64.4-18.6-76.7-43z"],Safari:[512,512,[],"solid","M274.69,274.69l-37.38-37.38L166,346ZM256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8ZM411.85,182.79l14.78-6.13A8,8,0,0,1,437.08,181h0a8,8,0,0,1-4.33,10.46L418,197.57a8,8,0,0,1-10.45-4.33h0A8,8,0,0,1,411.85,182.79ZM314.43,94l6.12-14.78A8,8,0,0,1,331,74.92h0a8,8,0,0,1,4.33,10.45l-6.13,14.78a8,8,0,0,1-10.45,4.33h0A8,8,0,0,1,314.43,94ZM256,60h0a8,8,0,0,1,8,8V84a8,8,0,0,1-8,8h0a8,8,0,0,1-8-8V68A8,8,0,0,1,256,60ZM181,74.92a8,8,0,0,1,10.46,4.33L197.57,94a8,8,0,1,1-14.78,6.12l-6.13-14.78A8,8,0,0,1,181,74.92Zm-63.58,42.49h0a8,8,0,0,1,11.31,0L140,128.72A8,8,0,0,1,140,140h0a8,8,0,0,1-11.31,0l-11.31-11.31A8,8,0,0,1,117.41,117.41ZM60,256h0a8,8,0,0,1,8-8H84a8,8,0,0,1,8,8h0a8,8,0,0,1-8,8H68A8,8,0,0,1,60,256Zm40.15,73.21-14.78,6.13A8,8,0,0,1,74.92,331h0a8,8,0,0,1,4.33-10.46L94,314.43a8,8,0,0,1,10.45,4.33h0A8,8,0,0,1,100.15,329.21Zm4.33-136h0A8,8,0,0,1,94,197.57l-14.78-6.12A8,8,0,0,1,74.92,181h0a8,8,0,0,1,10.45-4.33l14.78,6.13A8,8,0,0,1,104.48,193.24ZM197.57,418l-6.12,14.78a8,8,0,0,1-14.79-6.12l6.13-14.78A8,8,0,1,1,197.57,418ZM264,444a8,8,0,0,1-8,8h0a8,8,0,0,1-8-8V428a8,8,0,0,1,8-8h0a8,8,0,0,1,8,8Zm67-6.92h0a8,8,0,0,1-10.46-4.33L314.43,418a8,8,0,0,1,4.33-10.45h0a8,8,0,0,1,10.45,4.33l6.13,14.78A8,8,0,0,1,331,437.08Zm63.58-42.49h0a8,8,0,0,1-11.31,0L372,383.28A8,8,0,0,1,372,372h0a8,8,0,0,1,11.31,0l11.31,11.31A8,8,0,0,1,394.59,394.59ZM286.25,286.25,110.34,401.66,225.75,225.75,401.66,110.34ZM437.08,331h0a8,8,0,0,1-10.45,4.33l-14.78-6.13a8,8,0,0,1-4.33-10.45h0A8,8,0,0,1,418,314.43l14.78,6.12A8,8,0,0,1,437.08,331ZM444,264H428a8,8,0,0,1-8-8h0a8,8,0,0,1,8-8h16a8,8,0,0,1,8,8h0A8,8,0,0,1,444,264Z"],Php:[512,512,[],"solid","M170.322 349.808c-2.4-15.66-9-28.38-25.02-34.531c-6.27-2.4-11.7-6.78-17.88-9.54c-7.02-3.15-14.16-6.15-21.57-8.1c-5.61-1.5-10.83 1.02-14.16 5.94c-3.15 4.62-.87 8.97 1.77 12.84c2.97 4.35 6.27 8.49 9.6 12.57c5.52 6.78 11.37 13.29 16.74 20.161c5.13 6.57 9.51 13.86 8.76 22.56c-1.65 19.08-10.29 34.891-24.21 47.76c-1.53 1.38-4.23 2.37-6.21 2.19c-8.88-.96-16.95-4.32-23.46-10.53c-7.47-7.11-6.33-15.48 2.61-20.67c2.13-1.23 4.35-2.37 6.3-3.87c5.46-4.11 7.29-11.13 4.32-17.22c-1.41-2.94-3-6.12-5.34-8.25c-11.43-10.41-22.651-21.151-34.891-30.63C18.01 307.447 2.771 276.968.43 240.067c-2.64-40.981 6.87-79.231 28.5-114.242c8.19-13.29 17.73-25.951 32.37-32.52c9.96-4.47 20.88-6.99 31.531-9.78c29.311-7.71 58.89-13.5 89.401-8.34c26.28 4.41 45.511 17.94 54.331 43.77c5.79 16.89 7.17 34.35 5.37 52.231c-3.54 35.131-29.49 66.541-63.331 75.841c-14.67 4.02-22.68 1.77-31.5-10.44c-6.33-8.79-11.58-18.36-17.25-27.631c-.84-1.38-1.44-2.97-2.16-4.44c-.69-1.47-1.44-2.88-2.16-4.35c2.13 15.24 5.67 29.911 13.98 42.99c4.5 7.11 10.5 12.36 19.29 13.14c32.34 2.91 59.641-7.71 79.021-33.721c21.69-29.101 26.461-62.581 20.19-97.831c-1.23-6.96-3.3-13.77-4.77-20.7c-.99-4.47.78-7.77 5.19-9.33c2.04-.69 4.14-1.26 6.18-1.68c26.461-5.7 53.221-7.59 80.191-4.86c30.601 3.06 59.551 11.46 85.441 28.471c40.531 26.67 65.641 64.621 79.291 110.522c1.98 6.66 2.28 13.95 2.46 20.971c.12 4.68-2.88 5.91-6.45 2.97c-3.93-3.21-7.53-6.87-10.92-10.65c-3.15-3.57-5.67-7.65-8.73-11.4c-2.37-2.94-4.44-2.49-5.58 1.17c-.72 2.22-1.35 4.41-1.98 6.63c-7.08 25.26-18.24 48.3-36.33 67.711c-2.52 2.73-4.77 6.78-5.07 10.38c-.78 9.96-1.35 20.13-.39 30.06c1.98 21.331 5.07 42.57 7.47 63.871c1.35 12.03-2.52 19.11-13.83 23.281c-7.95 2.91-16.47 5.04-24.87 5.64c-13.38.93-26.88.27-40.32.27c-.36-15 .93-29.731-13.17-37.771c2.73-11.13 5.88-21.69 7.77-32.49c1.56-8.97.24-17.79-6.06-25.14c-5.91-6.93-13.32-8.82-20.101-4.86c-20.43 11.91-41.671 11.97-63.301 4.17c-9.93-3.6-16.86-1.56-22.351 7.5c-5.91 9.75-8.4 20.7-7.74 31.771c.84 13.95 3.27 27.75 5.13 41.64c1.02 7.77.15 9.78-7.56 11.76c-17.13 4.35-34.56 4.83-52.081 3.42c-.93-.09-1.86-.48-2.46-.63c-.87-14.55.66-29.671-16.68-37.411c7.68-16.29 6.63-33.18 3.99-50.07l-.06-.15zm-103.561-57.09c2.55-2.4 4.59-6.15 5.31-9.6c1.8-8.64-4.68-20.22-12.18-23.43c-3.99-1.74-7.47-1.11-10.29 2.07c-6.87 7.77-13.65 15.63-20.401 23.521c-1.14 1.35-2.16 2.94-2.97 4.53c-2.7 5.19-1.11 8.97 4.65 10.38c3.48.87 7.08 1.05 10.65 1.56c9.3-.9 18.3-2.46 25.23-9zm.78-86.371c-.03-6.18-5.19-11.34-11.28-11.37c-6.27-.03-11.67 5.58-11.46 11.76c.27 6.21 5.43 11.19 11.61 11.07c6.24-.09 11.22-5.19 11.16-11.43z"],Python:[448,512,[],"solid","M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"],Markdown:[32,32,[],"solid","m14 10l-4 3.5L6 10H4v12h4v-6l2 2l2-2v6h4V10zm12 6v-6h-4v6h-4l6 8l6-8z"],Microsoft:[448,512,[],"solid","M0 32h214.6v214.6H0V32zm233.4 0H448v214.6H233.4V32zM0 265.4h214.6V480H0V265.4zm233.4 0H448V480H233.4V265.4z"],Npm:[576,512,[],"solid","M288 288h-32v-64h32v64zm288-128v192H288v32H160v-32H0V160h576zm-416 32H32v128h64v-96h32v96h32V192zm160 0H192v160h64v-32h64V192zm224 0H352v128h64v-96h32v96h32v-96h32v96h32V192z"],Reddit:[512,512,[],"solid","M0 256C0 114.6 114.6 0 256 0S512 114.6 512 256s-114.6 256-256 256L37.1 512c-13.7 0-20.5-16.5-10.9-26.2L75 437C28.7 390.7 0 326.7 0 256zM349.6 153.6c23.6 0 42.7-19.1 42.7-42.7s-19.1-42.7-42.7-42.7c-20.6 0-37.8 14.6-41.8 34c-34.5 3.7-61.4 33-61.4 68.4l0 .2c-37.5 1.6-71.8 12.3-99 29.1c-10.1-7.8-22.8-12.5-36.5-12.5c-33 0-59.8 26.8-59.8 59.8c0 24 14.1 44.6 34.4 54.1c2 69.4 77.6 125.2 170.6 125.2s168.7-55.9 170.6-125.3c20.2-9.6 34.1-30.2 34.1-54c0-33-26.8-59.8-59.8-59.8c-13.7 0-26.3 4.6-36.4 12.4c-27.4-17-62.1-27.7-100-29.1l0-.2c0-25.4 18.9-46.5 43.4-49.9l0 0c4.4 18.8 21.3 32.8 41.5 32.8zM177.1 246.9c16.7 0 29.5 17.6 28.5 39.3s-13.5 29.6-30.3 29.6s-31.4-8.8-30.4-30.5s15.4-38.3 32.1-38.3zm190.1 38.3c1 21.7-13.7 30.5-30.4 30.5s-29.3-7.9-30.3-29.6c-1-21.7 11.8-39.3 28.5-39.3s31.2 16.6 32.1 38.3zm-48.1 56.7c-10.3 24.6-34.6 41.9-63 41.9s-52.7-17.3-63-41.9c-1.2-2.9 .8-6.2 3.9-6.5c18.4-1.9 38.3-2.9 59.1-2.9s40.7 1 59.1 2.9c3.1 .3 5.1 3.6 3.9 6.5z"],Rust:[512,512,[],"solid","M508.52,249.75,486.7,236.24c-.17-2-.34-3.93-.55-5.88l18.72-17.5a7.35,7.35,0,0,0-2.44-12.25l-24-9c-.54-1.88-1.08-3.78-1.67-5.64l15-20.83a7.35,7.35,0,0,0-4.79-11.54l-25.42-4.15c-.9-1.73-1.79-3.45-2.73-5.15l10.68-23.42a7.35,7.35,0,0,0-6.95-10.39l-25.82.91q-1.79-2.22-3.61-4.4L439,81.84A7.36,7.36,0,0,0,430.16,73L405,78.93q-2.17-1.83-4.4-3.61l.91-25.82a7.35,7.35,0,0,0-10.39-7L367.7,53.23c-1.7-.94-3.43-1.84-5.15-2.73L358.4,25.08a7.35,7.35,0,0,0-11.54-4.79L326,35.26c-1.86-.59-3.75-1.13-5.64-1.67l-9-24a7.35,7.35,0,0,0-12.25-2.44l-17.5,18.72c-1.95-.21-3.91-.38-5.88-.55L262.25,3.48a7.35,7.35,0,0,0-12.5,0L236.24,25.3c-2,.17-3.93.34-5.88.55L212.86,7.13a7.35,7.35,0,0,0-12.25,2.44l-9,24c-1.89.55-3.79,1.08-5.66,1.68l-20.82-15a7.35,7.35,0,0,0-11.54,4.79l-4.15,25.41c-1.73.9-3.45,1.79-5.16,2.73L120.88,42.55a7.35,7.35,0,0,0-10.39,7l.92,25.81c-1.49,1.19-3,2.39-4.42,3.61L81.84,73A7.36,7.36,0,0,0,73,81.84L78.93,107c-1.23,1.45-2.43,2.93-3.62,4.41l-25.81-.91a7.42,7.42,0,0,0-6.37,3.26,7.35,7.35,0,0,0-.57,7.13l10.66,23.41c-.94,1.7-1.83,3.43-2.73,5.16L25.08,153.6a7.35,7.35,0,0,0-4.79,11.54l15,20.82c-.59,1.87-1.13,3.77-1.68,5.66l-24,9a7.35,7.35,0,0,0-2.44,12.25l18.72,17.5c-.21,1.95-.38,3.91-.55,5.88L3.48,249.75a7.35,7.35,0,0,0,0,12.5L25.3,275.76c.17,2,.34,3.92.55,5.87L7.13,299.13a7.35,7.35,0,0,0,2.44,12.25l24,9c.55,1.89,1.08,3.78,1.68,5.65l-15,20.83a7.35,7.35,0,0,0,4.79,11.54l25.42,4.15c.9,1.72,1.79,3.45,2.73,5.14L42.56,391.12a7.35,7.35,0,0,0,.57,7.13,7.13,7.13,0,0,0,6.37,3.26l25.83-.91q1.77,2.22,3.6,4.4L73,430.16A7.36,7.36,0,0,0,81.84,439L107,433.07q2.18,1.83,4.41,3.61l-.92,25.82a7.35,7.35,0,0,0,10.39,6.95l23.43-10.68c1.69.94,3.42,1.83,5.14,2.73l4.15,25.42a7.34,7.34,0,0,0,11.54,4.78l20.83-15c1.86.6,3.76,1.13,5.65,1.68l9,24a7.36,7.36,0,0,0,12.25,2.44l17.5-18.72c1.95.21,3.92.38,5.88.55l13.51,21.82a7.35,7.35,0,0,0,12.5,0l13.51-21.82c2-.17,3.93-.34,5.88-.56l17.5,18.73a7.36,7.36,0,0,0,12.25-2.44l9-24c1.89-.55,3.78-1.08,5.65-1.68l20.82,15a7.34,7.34,0,0,0,11.54-4.78l4.15-25.42c1.72-.9,3.45-1.79,5.15-2.73l23.42,10.68a7.35,7.35,0,0,0,10.39-6.95l-.91-25.82q2.22-1.79,4.4-3.61L430.16,439a7.36,7.36,0,0,0,8.84-8.84L433.07,405q1.83-2.17,3.61-4.4l25.82.91a7.23,7.23,0,0,0,6.37-3.26,7.35,7.35,0,0,0,.58-7.13L458.77,367.7c.94-1.7,1.83-3.43,2.73-5.15l25.42-4.15a7.35,7.35,0,0,0,4.79-11.54l-15-20.83c.59-1.87,1.13-3.76,1.67-5.65l24-9a7.35,7.35,0,0,0,2.44-12.25l-18.72-17.5c.21-1.95.38-3.91.55-5.87l21.82-13.51a7.35,7.35,0,0,0,0-12.5Zm-151,129.08A13.91,13.91,0,0,0,341,389.51l-7.64,35.67A187.51,187.51,0,0,1,177,424.44l-7.64-35.66a13.87,13.87,0,0,0-16.46-10.68l-31.51,6.76a187.38,187.38,0,0,1-16.26-19.21H258.3c1.72,0,2.89-.29,2.89-1.91V309.55c0-1.57-1.17-1.91-2.89-1.91H213.47l.05-34.35H262c4.41,0,23.66,1.28,29.79,25.87,1.91,7.55,6.17,32.14,9.06,40,2.89,8.82,14.6,26.46,27.1,26.46H407a187.3,187.3,0,0,1-17.34,20.09Zm25.77,34.49A15.24,15.24,0,1,1,368,398.08h.44A15.23,15.23,0,0,1,383.24,413.32Zm-225.62-.68a15.24,15.24,0,1,1-15.25-15.25h.45A15.25,15.25,0,0,1,157.62,412.64ZM69.57,234.15l32.83-14.6a13.88,13.88,0,0,0,7.06-18.33L102.69,186h26.56V305.73H75.65A187.65,187.65,0,0,1,69.57,234.15ZM58.31,198.09a15.24,15.24,0,0,1,15.23-15.25H74a15.24,15.24,0,1,1-15.67,15.24Zm155.16,24.49.05-35.32h63.26c3.28,0,23.07,3.77,23.07,18.62,0,12.29-15.19,16.7-27.68,16.7ZM399,306.71c-9.8,1.13-20.63-4.12-22-10.09-5.78-32.49-15.39-39.4-30.57-51.4,18.86-11.95,38.46-29.64,38.46-53.26,0-25.52-17.49-41.59-29.4-49.48-16.76-11-35.28-13.23-40.27-13.23H116.32A187.49,187.49,0,0,1,221.21,70.06l23.47,24.6a13.82,13.82,0,0,0,19.6.44l26.26-25a187.51,187.51,0,0,1,128.37,91.43l-18,40.57A14,14,0,0,0,408,220.43l34.59,15.33a187.12,187.12,0,0,1,.4,32.54H423.71c-1.91,0-2.69,1.27-2.69,3.13v8.82C421,301,409.31,305.58,399,306.71ZM240,60.21A15.24,15.24,0,0,1,255.21,45h.45A15.24,15.24,0,1,1,240,60.21ZM436.84,214a15.24,15.24,0,1,1,0-30.48h.44a15.24,15.24,0,0,1-.44,30.48Z"],Unity:[16,16,[],"solid","M8 6.5L5 5l2-1V2L2 5v5l2-1V6.5L7 8v4.5L4 11l-2 1l6 3l6-3l-2-1l-3 1.5V8l3-1.5V9l2 1V5L9 2v2l2 1Z"],UnrealEngine:[24,24,[],"regular","M12 0a12 12 0 1 0 12 12A12 12 0 0 0 12 0m0 23.52A11.52 11.52 0 1 1 23.52 12A11.52 11.52 0 0 1 12 23.52m7.13-9.791c-.206.997-1.126 3.557-4.06 4.942l-1.179-1.325l-1.988 2a7.34 7.34 0 0 1-5.804-2.978a3 3 0 0 0 .65.123c.326.006.678-.114.678-.66v-5.394a.89.89 0 0 0-1.116-.89c-.92.212-1.656 2.509-1.656 2.509a7.3 7.3 0 0 1 2.528-5.597a7.4 7.4 0 0 1 3.73-1.721c-1.006.573-1.57 1.507-1.57 2.29c0 1.262.76 1.109.984.923v7.28a1.2 1.2 0 0 0 .148.256a1.08 1.08 0 0 0 .88.445c.76 0 1.747-.868 1.747-.868V9.172c0-.6-.452-1.324-.905-1.572c0 0 .838-.149 1.484.346a6 6 0 0 1 .387-.425c1.508-1.48 2.929-1.902 4.112-2.112c0 0-2.151 1.69-2.151 3.96c0 1.687.043 5.801.043 5.801c.799.771 1.986-.342 3.059-1.441Z"],"UnrealEngine@solid":[24,24,[],"solid","M12 23c6.075 0 11-4.925 11-11S18.075 1 12 1S1 5.925 1 12s4.925 11 11 11m-8.442-9.416c.718-2.333 2.53-6.86 7.27-8.584v10.23c.179.18.645.54 1.076.54c.67 0 1.615-.54 1.615-.54V8.77c.555-1.16 3.123-3.232 4.847-3.232c-1.044 1.204-1.532 1.91-2.154 3.231v6.462c.718.18 2.154 0 3.23-1.077c-.87 1.98-3.23 4.308-4.307 4.308l-1.616-1.077L11.904 19c-1.615 0-4.308-1.077-5.385-2.692h1.616v-6.17c-1.96-.268-2.857.973-4.577 3.446"],Ubuntu:[576,512,[],"solid","M469.2 75A75.6 75.6 0 1 0 317.9 75a75.6 75.6 0 1 0 151.2 0zM154.2 240.7A75.6 75.6 0 1 0 3 240.7a75.6 75.6 0 1 0 151.2 0zM57 346C75.6 392.9 108 433 150 461.1s91.5 42.6 142 41.7c-14.7-18.6-22.9-41.5-23.2-65.2c-6.8-.9-13.3-2.1-19.5-3.4c-26.8-5.7-51.9-17.3-73.6-34s-39.3-38.1-51.7-62.5c-20.9 9.9-44.5 12.8-67.1 8.2zm395.1 89.8a75.6 75.6 0 1 0 -151.2 0 75.6 75.6 0 1 0 151.2 0zM444 351.6c18.5 14.8 31.6 35.2 37.2 58.2c33.3-41.3 52.6-92.2 54.8-145.2s-12.5-105.4-42.2-149.4c-8.6 21.5-24 39.6-43.8 51.6c15.4 28.6 22.9 60.8 21.9 93.2s-10.7 64-28 91.6zM101.1 135.4c12.4 2.7 24.3 7.5 35.1 14.3c16.6-24.2 38.9-44.1 64.8-58S255.8 70.4 285.2 70c.2-5.9 .9-11.9 2-17.7c3.6-16.7 11.1-32.3 21.8-45.5c-47.7-3.8-95.4 6-137.6 28.5S94.3 91.7 70.8 133.4c2.7-.2 5.3-.3 8-.3c7.5 0 15 .8 22.4 2.3z"],VsCode:[16,16,[],"solid","M11.5 11.19V4.8L7.3 7.99M1.17 6.07a.6.6 0 0 1-.01-.81L2 4.48c.14-.13.48-.18.73 0l2.39 1.83l5.55-5.09c.22-.22.61-.32 1.05-.08l2.8 1.34c.25.15.49.38.49.81v9.49c0 .28-.2.58-.42.7l-3.08 1.48c-.22.09-.64 0-.79-.14L5.11 9.69l-2.38 1.83c-.27.18-.6.13-.74 0l-.84-.77c-.22-.23-.2-.61.04-.84l2.1-1.9"],Windows:[448,512,[],"solid","M0 93.7l183.6-25.3v177.4H0V93.7zm0 324.6l183.6 25.3V268.4H0v149.9zm203.8 28L448 480V268.4H203.8v177.9zm0-380.6v180.1H448V32L203.8 65.7z"],Whatsapp:[448,512,[],"regular","M380.9 97.1C339 55.1 283.2 32 223.9 32c-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480l117.7-30.9c32.4 17.7 68.9 27 106.1 27h.1c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3L72 359.2l-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1 34.8 34.9 56.2 81.2 56.1 130.5 0 101.8-84.9 184.6-186.6 184.6zm101.2-138.2c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8-3.7 5.6-14.3 18-17.6 21.8-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7.9-6.9-.5-9.7-1.4-2.8-12.5-30.1-17.1-41.2-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2-3.7 0-9.7 1.4-14.8 6.9-5.1 5.6-19.4 19-19.4 46.3 0 27.3 19.9 53.7 22.6 57.4 2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4 4.6-13 4.6-24.1 3.2-26.4-1.3-2.5-5-3.9-10.5-6.6z"],"X-Twitter":[512,512,[],"regular","M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"],Keyboard:[576,512,[],"regular","M64 112c-8.8 0-16 7.2-16 16l0 256c0 8.8 7.2 16 16 16l448 0c8.8 0 16-7.2 16-16l0-256c0-8.8-7.2-16-16-16L64 112zM0 128C0 92.7 28.7 64 64 64l448 0c35.3 0 64 28.7 64 64l0 256c0 35.3-28.7 64-64 64L64 448c-35.3 0-64-28.7-64-64L0 128zM176 320l224 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-224 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16zm-72-72c0-8.8 7.2-16 16-16l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16zm16-96l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16zm64 96c0-8.8 7.2-16 16-16l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16zm16-96l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16zm64 96c0-8.8 7.2-16 16-16l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16zm16-96l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16zm64 96c0-8.8 7.2-16 16-16l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16zm16-96l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16zm64 96c0-8.8 7.2-16 16-16l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16zm16-96l16 0c8.8 0 16 7.2 16 16l0 16c0 8.8-7.2 16-16 16l-16 0c-8.8 0-16-7.2-16-16l0-16c0-8.8 7.2-16 16-16z"],IdCard:[576,512,[],"regular","M528 160l0 256c0 8.8-7.2 16-16 16l-192 0c0-44.2-35.8-80-80-80l-64 0c-44.2 0-80 35.8-80 80l-32 0c-8.8 0-16-7.2-16-16l0-256 480 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l448 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zM272 256a64 64 0 1 0 -128 0 64 64 0 1 0 128 0zm104-48c-13.3 0-24 10.7-24 24s10.7 24 24 24l80 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-80 0zm0 96c-13.3 0-24 10.7-24 24s10.7 24 24 24l80 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-80 0z"],BookUser:[576,512,[],"regular","M512 80c8.8 0 16 7.2 16 16l0 320c0 8.8-7.2 16-16 16L64 432c-8.8 0-16-7.2-16-16L48 96c0-8.8 7.2-16 16-16l448 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l448 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zM208 256a64 64 0 1 0 0-128 64 64 0 1 0 0 128zm-32 32c-44.2 0-80 35.8-80 80c0 8.8 7.2 16 16 16l192 0c8.8 0 16-7.2 16-16c0-44.2-35.8-80-80-80l-64 0zM376 144c-13.3 0-24 10.7-24 24s10.7 24 24 24l80 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-80 0zm0 96c-13.3 0-24 10.7-24 24s10.7 24 24 24l80 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-80 0z"],Copy:[448,512,[],"regular","M384 336l-192 0c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l140.1 0L400 115.9 400 320c0 8.8-7.2 16-16 16zM192 384l192 0c35.3 0 64-28.7 64-64l0-204.1c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1L192 0c-35.3 0-64 28.7-64 64l0 256c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l192 0c35.3 0 64-28.7 64-64l0-32-48 0 0 32c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l32 0 0-48-32 0z"],Eye:[576,512,[],"regular","M288 80c-65.2 0-118.8 29.6-159.9 67.7C89.6 183.5 63 226 49.4 256c13.6 30 40.2 72.5 78.6 108.3C169.2 402.4 222.8 432 288 432s118.8-29.6 159.9-67.7C486.4 328.5 513 286 526.6 256c-13.6-30-40.2-72.5-78.6-108.3C406.8 109.6 353.2 80 288 80zM95.4 112.6C142.5 68.8 207.2 32 288 32s145.5 36.8 192.6 80.6c46.8 43.5 78.1 95.4 93 131.1c3.3 7.9 3.3 16.7 0 24.6c-14.9 35.7-46.2 87.7-93 131.1C433.5 443.2 368.8 480 288 480s-145.5-36.8-192.6-80.6C48.6 356 17.3 304 2.5 268.3c-3.3-7.9-3.3-16.7 0-24.6C17.3 208 48.6 156 95.4 112.6zM288 336c44.2 0 80-35.8 80-80s-35.8-80-80-80c-.7 0-1.3 0-2 0c1.3 5.1 2 10.5 2 16c0 35.3-28.7 64-64 64c-5.5 0-10.9-.7-16-2c0 .7 0 1.3 0 2c0 44.2 35.8 80 80 80zm0-208a128 128 0 1 1 0 256 128 128 0 1 1 0-256z"],EyeOff:[640,512,[],"regular","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zm151 118.3C226 97.7 269.5 80 320 80c65.2 0 118.8 29.6 159.9 67.7C518.4 183.5 545 226 558.6 256c-12.6 28-36.6 66.8-70.9 100.9l-53.8-42.2c9.1-17.6 14.2-37.5 14.2-58.7c0-70.7-57.3-128-128-128c-32.2 0-61.7 11.9-84.2 31.5l-46.1-36.1zM394.9 284.2l-81.5-63.9c4.2-8.5 6.6-18.2 6.6-28.3c0-5.5-.7-10.9-2-16c.7 0 1.3 0 2 0c44.2 0 80 35.8 80 80c0 9.9-1.8 19.4-5.1 28.2zm9.4 130.3C378.8 425.4 350.7 432 320 432c-65.2 0-118.8-29.6-159.9-67.7C121.6 328.5 95 286 81.4 256c8.3-18.4 21.5-41.5 39.4-64.8L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5l-41.9-33zM192 256c0 70.7 57.3 128 128 128c13.3 0 26.1-2 38.2-5.8L302 334c-23.5-5.4-43.1-21.2-53.7-42.3l-56.1-44.2c-.2 2.8-.3 5.6-.3 8.5z"],StickyNote:[448,512,[],"regular","M64 80c-8.8 0-16 7.2-16 16l0 320c0 8.8 7.2 16 16 16l224 0 0-80c0-17.7 14.3-32 32-32l80 0 0-224c0-8.8-7.2-16-16-16L64 80zM288 480L64 480c-35.3 0-64-28.7-64-64L0 96C0 60.7 28.7 32 64 32l320 0c35.3 0 64 28.7 64 64l0 224 0 5.5c0 17-6.7 33.3-18.7 45.3l-90.5 90.5c-12 12-28.3 18.7-45.3 18.7l-5.5 0z"],CreditCard:[576,512,[],"regular","M512 80c8.8 0 16 7.2 16 16l0 32L48 128l0-32c0-8.8 7.2-16 16-16l448 0zm16 144l0 192c0 8.8-7.2 16-16 16L64 432c-8.8 0-16-7.2-16-16l0-192 480 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l448 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm56 304c-13.3 0-24 10.7-24 24s10.7 24 24 24l48 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-48 0zm128 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l112 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-112 0z"],Hourglass:[384,512,[],"regular","M24 0C10.7 0 0 10.7 0 24S10.7 48 24 48l8 0 0 19c0 40.3 16 79 44.5 107.5L158.1 256 76.5 337.5C48 366 32 404.7 32 445l0 19-8 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l336 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-8 0 0-19c0-40.3-16-79-44.5-107.5L225.9 256l81.5-81.5C336 146 352 107.3 352 67l0-19 8 0c13.3 0 24-10.7 24-24s-10.7-24-24-24L24 0zM192 289.9l81.5 81.5C293 391 304 417.4 304 445l0 19L80 464l0-19c0-27.6 11-54 30.5-73.5L192 289.9zm0-67.9l-81.5-81.5C91 121 80 94.6 80 67l0-19 224 0 0 19c0 27.6-11 54-30.5 73.5L192 222.1z"],Bell:[448,512,[],"solid","M224 0c-17.7 0-32 14.3-32 32l0 19.2C119 66 64 130.6 64 208l0 18.8c0 47-17.3 92.4-48.5 127.6l-7.4 8.3c-8.4 9.4-10.4 22.9-5.3 34.4S19.4 416 32 416l384 0c12.6 0 24-7.4 29.2-18.9s3.1-25-5.3-34.4l-7.4-8.3C401.3 319.2 384 273.9 384 226.8l0-18.8c0-77.4-55-142-128-156.8L256 32c0-17.7-14.3-32-32-32zm45.3 493.3c12-12 18.7-28.3 18.7-45.3l-64 0-64 0c0 17 6.7 33.3 18.7 45.3s28.3 18.7 45.3 18.7s33.3-6.7 45.3-18.7z"],BellOff:[640,512,[],"solid","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7l-90.2-70.7c.2-.4 .4-.9 .6-1.3c5.2-11.5 3.1-25-5.3-34.4l-7.4-8.3C497.3 319.2 480 273.9 480 226.8l0-18.8c0-77.4-55-142-128-156.8L352 32c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 19.2c-42.6 8.6-79 34.2-102 69.3L38.8 5.1zM406.2 416L160 222.1l0 4.8c0 47-17.3 92.4-48.5 127.6l-7.4 8.3c-8.4 9.4-10.4 22.9-5.3 34.4S115.4 416 128 416l278.2 0zm-40.9 77.3c12-12 18.7-28.3 18.7-45.3l-64 0-64 0c0 17 6.7 33.3 18.7 45.3s28.3 18.7 45.3 18.7s33.3-6.7 45.3-18.7z"],Compass:[512,512,[],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm50.7-186.9L162.4 380.6c-19.4 7.5-38.5-11.6-31-31l55.5-144.3c3.3-8.5 9.9-15.1 18.4-18.4l144.3-55.5c19.4-7.5 38.5 11.6 31 31L325.1 306.7c-3.2 8.5-9.9 15.1-18.4 18.4zM288 256a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"],File:[384,512,[],"solid","M0 64C0 28.7 28.7 0 64 0L224 0l0 128c0 17.7 14.3 32 32 32l128 0 0 288c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 64zm384 64l-128 0L256 0 384 128z"],MessageCircle:[512,512,[],"solid","M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4c0 0 0 0 0 0s0 0 0 0s0 0 0 0c0 0 0 0 0 0l.3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"],Inbox:[512,512,[],"solid","M121 32C91.6 32 66 52 58.9 80.5L1.9 308.4C.6 313.5 0 318.7 0 323.9L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-92.1c0-5.2-.6-10.4-1.9-15.5l-57-227.9C446 52 420.4 32 391 32L121 32zm0 64l270 0 48 192-51.2 0c-12.1 0-23.2 6.8-28.6 17.7l-14.3 28.6c-5.4 10.8-16.5 17.7-28.6 17.7l-120.4 0c-12.1 0-23.2-6.8-28.6-17.7l-14.3-28.6c-5.4-10.8-16.5-17.7-28.6-17.7L73 288 121 96z"],Mail:[512,512,[],"solid","M48 64C21.5 64 0 85.5 0 112c0 15.1 7.1 29.3 19.2 38.4L236.8 313.6c11.4 8.5 27 8.5 38.4 0L492.8 150.4c12.1-9.1 19.2-23.3 19.2-38.4c0-26.5-21.5-48-48-48L48 64zM0 176L0 384c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-208L294.4 339.2c-22.8 17.1-54 17.1-76.8 0L0 176z"],MailOpen:[512,512,[],"solid","M64 208.1L256 65.9 448 208.1l0 47.4L289.5 373c-9.7 7.2-21.4 11-33.5 11s-23.8-3.9-33.5-11L64 255.5l0-47.4zM256 0c-12.1 0-23.8 3.9-33.5 11L25.9 156.7C9.6 168.8 0 187.8 0 208.1L0 448c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-239.9c0-20.3-9.6-39.4-25.9-51.4L289.5 11C279.8 3.9 268.1 0 256 0z"],Mic:[384,512,[],"solid","M192 0C139 0 96 43 96 96l0 160c0 53 43 96 96 96s96-43 96-96l0-160c0-53-43-96-96-96zM64 216c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 89.1 66.2 162.7 152 174.4l0 33.6-48 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l72 0 72 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-48 0 0-33.6c85.8-11.7 152-85.3 152-174.4l0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 70.7-57.3 128-128 128s-128-57.3-128-128l0-40z"],MicOff:[640,512,[],"solid","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L472.1 344.7c15.2-26 23.9-56.3 23.9-88.7l0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c0 21.2-5.1 41.1-14.2 58.7L416 300.8 416 96c0-53-43-96-96-96s-96 43-96 96l0 54.3L38.8 5.1zM344 430.4c20.4-2.8 39.7-9.1 57.3-18.2l-43.1-33.9C346.1 382 333.3 384 320 384c-70.7 0-128-57.3-128-128l0-8.7L144.7 210c-.5 1.9-.7 3.9-.7 6l0 40c0 89.1 66.2 162.7 152 174.4l0 33.6-48 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l72 0 72 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-48 0 0-33.6z"],Link:[640,512,["Chain"],"solid","M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"],House:[576,512,[],"solid","M575.8 255.5c0 18-15 32.1-32 32.1l-32 0 .7 160.2c0 2.7-.2 5.4-.5 8.1l0 16.2c0 22.1-17.9 40-40 40l-16 0c-1.1 0-2.2 0-3.3-.1c-1.4 .1-2.8 .1-4.2 .1L416 512l-24 0c-22.1 0-40-17.9-40-40l0-24 0-64c0-17.7-14.3-32-32-32l-64 0c-17.7 0-32 14.3-32 32l0 64 0 24c0 22.1-17.9 40-40 40l-24 0-31.9 0c-1.5 0-3-.1-4.5-.2c-1.2 .1-2.4 .2-3.6 .2l-16 0c-22.1 0-40-17.9-40-40l0-112c0-.9 0-1.9 .1-2.8l0-69.7-32 0c-18 0-32-14-32-32.1c0-9 3-17 10-24L266.4 8c7-7 15-8 22-8s15 2 21 7L564.8 231.5c8 7 12 15 11 24z"],Gamepad:[640,512,[],"solid","M192 64C86 64 0 150 0 256S86 448 192 448l256 0c106 0 192-86 192-192s-86-192-192-192L192 64zM496 168a40 40 0 1 1 0 80 40 40 0 1 1 0-80zM392 304a40 40 0 1 1 80 0 40 40 0 1 1 -80 0zM168 200c0-13.3 10.7-24 24-24s24 10.7 24 24l0 32 32 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-32 0 0 32c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-32-32 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l32 0 0-32z"],Camera:[512,512,[],"solid","M149.1 64.8L138.7 96 64 96C28.7 96 0 124.7 0 160L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-256c0-35.3-28.7-64-64-64l-74.7 0L362.9 64.8C356.4 45.2 338.1 32 317.4 32L194.6 32c-20.7 0-39 13.2-45.5 32.8zM256 192a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"],Printer:[512,512,[],"solid","M128 0C92.7 0 64 28.7 64 64l0 96 64 0 0-96 226.7 0L384 93.3l0 66.7 64 0 0-66.7c0-17-6.7-33.3-18.7-45.3L400 18.7C388 6.7 371.7 0 354.7 0L128 0zM384 352l0 32 0 64-256 0 0-64 0-16 0-16 256 0zm64 32l32 0c17.7 0 32-14.3 32-32l0-96c0-35.3-28.7-64-64-64L64 192c-35.3 0-64 28.7-64 64l0 96c0 17.7 14.3 32 32 32l32 0 0 64c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-64zM432 248a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"],Server:[512,512,[],"solid","M64 32C28.7 32 0 60.7 0 96l0 64c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-64c0-35.3-28.7-64-64-64L64 32zm280 72a24 24 0 1 1 0 48 24 24 0 1 1 0-48zm48 24a24 24 0 1 1 48 0 24 24 0 1 1 -48 0zM64 288c-35.3 0-64 28.7-64 64l0 64c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-64c0-35.3-28.7-64-64-64L64 288zm280 72a24 24 0 1 1 0 48 24 24 0 1 1 0-48zm56 24a24 24 0 1 1 48 0 24 24 0 1 1 -48 0z"],Calendar:[448,512,[],"solid","M96 32l0 32L48 64C21.5 64 0 85.5 0 112l0 48 448 0 0-48c0-26.5-21.5-48-48-48l-48 0 0-32c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 32L160 64l0-32c0-17.7-14.3-32-32-32S96 14.3 96 32zM448 192L0 192 0 464c0 26.5 21.5 48 48 48l352 0c26.5 0 48-21.5 48-48l0-272z"],Pipette:[512,512,[],"solid","M341.6 29.2L240.1 130.8l-9.4-9.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-9.4-9.4L482.8 170.4c39-39 39-102.2 0-141.1s-102.2-39-141.1 0zM55.4 323.3c-15 15-23.4 35.4-23.4 56.6l0 42.4L5.4 462.2c-8.5 12.7-6.8 29.6 4 40.4s27.7 12.5 40.4 4L89.7 480l42.4 0c21.2 0 41.6-8.4 56.6-23.4L309.4 335.9l-45.3-45.3L143.4 411.3c-3 3-7.1 4.7-11.3 4.7L96 416l0-36.1c0-4.2 1.7-8.3 4.7-11.3L221.4 247.9l-45.3-45.3L55.4 323.3z"],Scroll:[576,512,[],"solid","M0 80l0 48c0 17.7 14.3 32 32 32l16 0 48 0 0-80c0-26.5-21.5-48-48-48S0 53.5 0 80zM112 32c10 13.4 16 30 16 48l0 304c0 35.3 28.7 64 64 64s64-28.7 64-64l0-5.3c0-32.4 26.3-58.7 58.7-58.7L480 320l0-192c0-53-43-96-96-96L112 32zM464 480c61.9 0 112-50.1 112-112c0-8.8-7.2-16-16-16l-245.3 0c-14.7 0-26.7 11.9-26.7 26.7l0 5.3c0 53-43 96-96 96l176 0 96 0z"],Smartphone:[384,512,[],"solid","M16 64C16 28.7 44.7 0 80 0L304 0c35.3 0 64 28.7 64 64l0 384c0 35.3-28.7 64-64 64L80 512c-35.3 0-64-28.7-64-64L16 64zM144 448c0 8.8 7.2 16 16 16l64 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-64 0c-8.8 0-16 7.2-16 16zM304 64L80 64l0 320 224 0 0-320z"],Settings:[512,512,[],"solid","M495.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4L83.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4C64.6 273.1 64 264.6 64 256s.6-17.1 1.7-25.4L22.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z"],Map:[576,512,[],"solid","M384 476.1L192 421.2l0-385.3L384 90.8l0 385.3zm32-1.2l0-386.5L543.1 37.5c15.8-6.3 32.9 5.3 32.9 22.3l0 334.8c0 9.8-6 18.6-15.1 22.3L416 474.8zM15.1 95.1L160 37.2l0 386.5L32.9 474.5C17.1 480.8 0 469.2 0 452.2L0 117.4c0-9.8 6-18.6 15.1-22.3z"],Folder:[512,512,[],"solid","M64 480H448c35.3 0 64-28.7 64-64V160c0-35.3-28.7-64-64-64H288c-10.1 0-19.6-4.7-25.6-12.8L243.2 57.6C231.1 41.5 212.1 32 192 32H64C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64z"],FolderOpen:[576,512,[],"solid","M384 480l48 0c11.4 0 21.9-6 27.6-15.9l112-192c5.8-9.9 5.8-22.1 .1-32.1S555.5 224 544 224l-400 0c-11.4 0-21.9 6-27.6 15.9L48 357.1 48 96c0-8.8 7.2-16 16-16l117.5 0c4.2 0 8.3 1.7 11.3 4.7l26.5 26.5c21 21 49.5 32.8 79.2 32.8L416 144c8.8 0 16 7.2 16 16l0 32 48 0 0-32c0-35.3-28.7-64-64-64L298.5 96c-17 0-33.3-6.7-45.3-18.7L226.7 50.7c-12-12-28.3-18.7-45.3-18.7L64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l23.7 0L384 480z"],FolderClosed:[512,512,[],"solid","M448 480L64 480c-35.3 0-64-28.7-64-64L0 192l512 0 0 224c0 35.3-28.7 64-64 64zm64-320L0 160 0 96C0 60.7 28.7 32 64 32l128 0c20.1 0 39.1 9.5 51.2 25.6l19.2 25.6c6 8.1 15.5 12.8 25.6 12.8l160 0c35.3 0 64 28.7 64 64z"],Function:[384,512,[],"solid","M314.7 32c-38.8 0-73.7 23.3-88.6 59.1L170.7 224 64 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l80 0L98.9 396.3c-5 11.9-16.6 19.7-29.5 19.7L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l37.3 0c38.8 0 73.7-23.3 88.6-59.1L213.3 288 320 288c17.7 0 32-14.3 32-32s-14.3-32-32-32l-80 0 45.1-108.3c5-11.9 16.6-19.7 29.5-19.7L352 96c17.7 0 32-14.3 32-32s-14.3-32-32-32l-37.3 0z"],Stop:[384,512,[],"solid","M0 128C0 92.7 28.7 64 64 64H320c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V128z"],Image:[512,512,[],"solid","M448 80c8.8 0 16 7.2 16 16l0 319.8-5-6.5-136-176c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3L202 340.7l-30.5-42.7C167 291.7 159.8 288 152 288s-15 3.7-19.5 10.1l-80 112L48 416.3l0-.3L48 96c0-8.8 7.2-16 16-16l384 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm80 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"],Images:[576,512,[],"solid","M160 80l352 0c8.8 0 16 7.2 16 16l0 224c0 8.8-7.2 16-16 16l-21.2 0L388.1 178.9c-4.4-6.8-12-10.9-20.1-10.9s-15.7 4.1-20.1 10.9l-52.2 79.8-12.4-16.9c-4.5-6.2-11.7-9.8-19.4-9.8s-14.8 3.6-19.4 9.8L175.6 336 160 336c-8.8 0-16-7.2-16-16l0-224c0-8.8 7.2-16 16-16zM96 96l0 224c0 35.3 28.7 64 64 64l352 0c35.3 0 64-28.7 64-64l0-224c0-35.3-28.7-64-64-64L160 32c-35.3 0-64 28.7-64 64zM48 120c0-13.3-10.7-24-24-24S0 106.7 0 120L0 344c0 75.1 60.9 136 136 136l320 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-320 0c-48.6 0-88-39.4-88-88l0-224zm208 24a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"],Info:[512,512,[],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336l24 0 0-64-24 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l48 0c13.3 0 24 10.7 24 24l0 88 8 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"],Bone:[576,512,[],"solid","M153.7 144.8c6.9 16.3 20.6 31.2 38.3 31.2l192 0c17.7 0 31.4-14.9 38.3-31.2C434.4 116.1 462.9 96 496 96c44.2 0 80 35.8 80 80c0 30.4-17 56.9-42 70.4c-3.6 1.9-6 5.5-6 9.6s2.4 7.7 6 9.6c25 13.5 42 40 42 70.4c0 44.2-35.8 80-80 80c-33.1 0-61.6-20.1-73.7-48.8C415.4 350.9 401.7 336 384 336l-192 0c-17.7 0-31.4 14.9-38.3 31.2C141.6 395.9 113.1 416 80 416c-44.2 0-80-35.8-80-80c0-30.4 17-56.9 42-70.4c3.6-1.9 6-5.5 6-9.6s-2.4-7.7-6-9.6C17 232.9 0 206.4 0 176c0-44.2 35.8-80 80-80c33.1 0 61.6 20.1 73.7 48.8z"],Puzzle:[512,512,[],"solid","M192 104.8c0-9.2-5.8-17.3-13.2-22.8C167.2 73.3 160 61.3 160 48c0-26.5 28.7-48 64-48s64 21.5 64 48c0 13.3-7.2 25.3-18.8 34c-7.4 5.5-13.2 13.6-13.2 22.8c0 12.8 10.4 23.2 23.2 23.2l56.8 0c26.5 0 48 21.5 48 48l0 56.8c0 12.8 10.4 23.2 23.2 23.2c9.2 0 17.3-5.8 22.8-13.2c8.7-11.6 20.7-18.8 34-18.8c26.5 0 48 28.7 48 64s-21.5 64-48 64c-13.3 0-25.3-7.2-34-18.8c-5.5-7.4-13.6-13.2-22.8-13.2c-12.8 0-23.2 10.4-23.2 23.2L384 464c0 26.5-21.5 48-48 48l-56.8 0c-12.8 0-23.2-10.4-23.2-23.2c0-9.2 5.8-17.3 13.2-22.8c11.6-8.7 18.8-20.7 18.8-34c0-26.5-28.7-48-64-48s-64 21.5-64 48c0 13.3 7.2 25.3 18.8 34c7.4 5.5 13.2 13.6 13.2 22.8c0 12.8-10.4 23.2-23.2 23.2L48 512c-26.5 0-48-21.5-48-48L0 343.2C0 330.4 10.4 320 23.2 320c9.2 0 17.3 5.8 22.8 13.2C54.7 344.8 66.7 352 80 352c26.5 0 48-28.7 48-64s-21.5-64-48-64c-13.3 0-25.3 7.2-34 18.8C40.5 250.2 32.4 256 23.2 256C10.4 256 0 245.6 0 232.8L0 176c0-26.5 21.5-48 48-48l120.8 0c12.8 0 23.2-10.4 23.2-23.2z"],Lock:[448,512,[],"solid","M144 144l0 48 160 0 0-48c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192l0-48C80 64.5 144.5 0 224 0s144 64.5 144 144l0 48 16 0c35.3 0 64 28.7 64 64l0 192c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 256c0-35.3 28.7-64 64-64l16 0z"],LockOpen:[576,512,[],"solid","M352 144c0-44.2 35.8-80 80-80s80 35.8 80 80l0 48c0 17.7 14.3 32 32 32s32-14.3 32-32l0-48C576 64.5 511.5 0 432 0S288 64.5 288 144l0 48L64 192c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l320 0c35.3 0 64-28.7 64-64l0-192c0-35.3-28.7-64-64-64l-32 0 0-48z"],Shuffle:[512,512,[],"solid","M403.8 34.4c12-5 25.7-2.2 34.9 6.9l64 64c6 6 9.4 14.1 9.4 22.6s-3.4 16.6-9.4 22.6l-64 64c-9.2 9.2-22.9 11.9-34.9 6.9s-19.8-16.6-19.8-29.6l0-32-32 0c-10.1 0-19.6 4.7-25.6 12.8L284 229.3 244 176l31.2-41.6C293.3 110.2 321.8 96 352 96l32 0 0-32c0-12.9 7.8-24.6 19.8-29.6zM164 282.7L204 336l-31.2 41.6C154.7 401.8 126.2 416 96 416l-64 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l64 0c10.1 0 19.6-4.7 25.6-12.8L164 282.7zm274.6 188c-9.2 9.2-22.9 11.9-34.9 6.9s-19.8-16.6-19.8-29.6l0-32-32 0c-30.2 0-58.7-14.2-76.8-38.4L121.6 172.8c-6-8.1-15.5-12.8-25.6-12.8l-64 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l64 0c30.2 0 58.7 14.2 76.8 38.4L326.4 339.2c6 8.1 15.5 12.8 25.6 12.8l32 0 0-32c0-12.9 7.8-24.6 19.8-29.6s25.7-2.2 34.9 6.9l64 64c6 6 9.4 14.1 9.4 22.6s-3.4 16.6-9.4 22.6l-64 64z"],Play:[384,512,[],"solid","M73 39c-14.8-9.1-33.4-9.4-48.5-.9S0 62.6 0 80L0 432c0 17.4 9.4 33.4 24.5 41.9s33.7 8.1 48.5-.9L361 297c14.3-8.7 23-24.2 23-41s-8.7-32.2-23-41L73 39z"],Pause:[320,512,[],"solid","M48 64C21.5 64 0 85.5 0 112L0 400c0 26.5 21.5 48 48 48l32 0c26.5 0 48-21.5 48-48l0-288c0-26.5-21.5-48-48-48L48 64zm192 0c-26.5 0-48 21.5-48 48l0 288c0 26.5 21.5 48 48 48l32 0c26.5 0 48-21.5 48-48l0-288c0-26.5-21.5-48-48-48l-32 0z"],LogIn:[512,512,[],"solid","M352 96l64 0c17.7 0 32 14.3 32 32l0 256c0 17.7-14.3 32-32 32l-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0c53 0 96-43 96-96l0-256c0-53-43-96-96-96l-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32zm-9.4 182.6c12.5-12.5 12.5-32.8 0-45.3l-128-128c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L242.7 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l210.7 0-73.4 73.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l128-128z"],LogOut:[512,512,[],"solid","M502.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-128-128c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L402.7 224 192 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l210.7 0-73.4 73.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l128-128zM160 96c17.7 0 32-14.3 32-32s-14.3-32-32-32L96 32C43 32 0 75 0 128L0 384c0 53 43 96 96 96l64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-64 0c-17.7 0-32-14.3-32-32l0-256c0-17.7 14.3-32 32-32l64 0z"],MousePointer:[320,512,[],"solid","M0 55.2L0 426c0 12.2 9.9 22 22 22c6.3 0 12.4-2.7 16.6-7.5L121.2 346l58.1 116.3c7.9 15.8 27.1 22.2 42.9 14.3s22.2-27.1 14.3-42.9L179.8 320l118.1 0c12.2 0 22.1-9.9 22.1-22.1c0-6.3-2.7-12.3-7.4-16.5L38.6 37.9C34.3 34.1 28.9 32 23.2 32C10.4 32 0 42.4 0 55.2z"],User:[512,512,[],"solid","M256 288A144 144 0 1 0 256 0a144 144 0 1 0 0 288zm-94.7 32C72.2 320 0 392.2 0 481.3c0 17 13.8 30.7 30.7 30.7l450.6 0c17 0 30.7-13.8 30.7-30.7C512 392.2 439.8 320 350.7 320l-189.4 0z"],HardDriveDownload:[512,512,[],"solid","M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 242.7-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7 288 32zM64 352c-35.3 0-64 28.7-64 64l0 32c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-32c0-35.3-28.7-64-64-64l-101.5 0-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352 64 352zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"],HardDriveUpload:[512,512,[],"solid","M288 109.3L288 352c0 17.7-14.3 32-32 32s-32-14.3-32-32l0-242.7-73.4 73.4c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l128-128c12.5-12.5 32.8-12.5 45.3 0l128 128c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L288 109.3zM64 352l128 0c0 35.3 28.7 64 64 64s64-28.7 64-64l128 0c35.3 0 64 28.7 64 64l0 32c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64l0-32c0-35.3 28.7-64 64-64zM432 456a24 24 0 1 0 0-48 24 24 0 1 0 0 48z"],CircleCheck:[512,512,["CheckCircle2"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"],CirclePlay:[512,512,[],"solid","M0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zM188.3 147.1c-7.6 4.2-12.3 12.3-12.3 20.9l0 176c0 8.7 4.7 16.7 12.3 20.9s16.8 4.1 24.3-.5l144-88c7.1-4.4 11.5-12.1 11.5-20.5s-4.4-16.1-11.5-20.5l-144-88c-7.4-4.5-16.7-4.7-24.3-.5z"],CirclePause:[512,512,[],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM224 192l0 128c0 17.7-14.3 32-32 32s-32-14.3-32-32l0-128c0-17.7 14.3-32 32-32s32 14.3 32 32zm128 0l0 128c0 17.7-14.3 32-32 32s-32-14.3-32-32l0-128c0-17.7 14.3-32 32-32s32 14.3 32 32z"],CirclePlus:[512,512,["PlusCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM232 344l0-64-64 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l64 0 0-64c0-13.3 10.7-24 24-24s24 10.7 24 24l0 64 64 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-64 0 0 64c0 13.3-10.7 24-24 24s-24-10.7-24-24z"],CircleMinus:[512,512,["MinusCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM184 232l144 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-144 0c-13.3 0-24-10.7-24-24s10.7-24 24-24z"],CircleStop:[512,512,[],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM192 160l128 0c17.7 0 32 14.3 32 32l0 128c0 17.7-14.3 32-32 32l-128 0c-17.7 0-32-14.3-32-32l0-128c0-17.7 14.3-32 32-32z"],CircleDot:[512,512,[],"solid","M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256-96a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"],CircleHelp:[512,512,["HelpCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM169.8 165.3c7.9-22.3 29.1-37.3 52.8-37.3l58.3 0c34.9 0 63.1 28.3 63.1 63.1c0 22.6-12.1 43.5-31.7 54.8L280 264.4c-.2 13-10.9 23.6-24 23.6c-13.3 0-24-10.7-24-24l0-13.5c0-8.6 4.6-16.5 12.1-20.8l44.3-25.4c4.7-2.7 7.6-7.7 7.6-13.1c0-8.4-6.8-15.1-15.1-15.1l-58.3 0c-3.4 0-6.4 2.1-7.5 5.3l-.4 1.2c-4.4 12.5-18.2 19-30.6 14.6s-19-18.2-14.6-30.6l.4-1.2zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"],CircleArrowUp:[512,512,["ArrowUpCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM385 215c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-71-71L280 392c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-214.1-71 71c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9L239 103c9.4-9.4 24.6-9.4 33.9 0L385 215z"],CircleArrowDown:[512,512,["ArrowDownCircle"],"solid","M256 0a256 256 0 1 0 0 512A256 256 0 1 0 256 0zM127 297c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l71 71L232 120c0-13.3 10.7-24 24-24s24 10.7 24 24l0 214.1 71-71c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L273 409c-9.4 9.4-24.6 9.4-33.9 0L127 297z"],CircleArrowLeft:[512,512,["ArrowLeftCircle"],"solid","M512 256A256 256 0 1 0 0 256a256 256 0 1 0 512 0zM215 127c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-71 71L392 232c13.3 0 24 10.7 24 24s-10.7 24-24 24l-214.1 0 71 71c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L103 273c-9.4-9.4-9.4-24.6 0-33.9L215 127z"],CircleArrowRight:[512,512,["ArrowRightCircle"],"solid","M0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zM297 385c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l71-71L120 280c-13.3 0-24-10.7-24-24s10.7-24 24-24l214.1 0-71-71c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0L409 239c9.4 9.4 9.4 24.6 0 33.9L297 385z"],CircleAlert:[512,512,["AlertCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z"],CircleUser:[512,512,["UserCircle"],"solid","M399 384.2C376.9 345.8 335.4 320 288 320l-64 0c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"],CircleChevronRight:[512,512,["ChevronRightCircle"],"solid","M0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zM241 377c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l87-87-87-87c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0L345 239c9.4 9.4 9.4 24.6 0 33.9L241 377z"],CircleChevronDown:[512,512,["ChevronDownCircle"],"solid","M256 0a256 256 0 1 0 0 512A256 256 0 1 0 256 0zM135 241c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l87 87 87-87c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9L273 345c-9.4 9.4-24.6 9.4-33.9 0L135 241z"],CircleChevronUp:[512,512,["ChevronUpCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM377 271c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-87-87-87 87c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9L239 167c9.4-9.4 24.6-9.4 33.9 0L377 271z"],CircleChevronLeft:[512,512,["ChevronLeftCircle"],"solid","M512 256A256 256 0 1 0 0 256a256 256 0 1 0 512 0zM271 135c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-87 87 87 87c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L167 273c-9.4-9.4-9.4-24.6 0-33.9L271 135z"],CircleX:[512,512,["XCircle"],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM175 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"],Apple:[384,512,[],"solid","M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"],Chrome:[512,512,[],"solid","M0 256C0 209.4 12.47 165.6 34.27 127.1L144.1 318.3C166 357.5 207.9 384 256 384C270.3 384 283.1 381.7 296.8 377.4L220.5 509.6C95.9 492.3 0 385.3 0 256zM365.1 321.6C377.4 302.4 384 279.1 384 256C384 217.8 367.2 183.5 340.7 160H493.4C505.4 189.6 512 222.1 512 256C512 397.4 397.4 511.1 256 512L365.1 321.6zM477.8 128H256C193.1 128 142.3 172.1 130.5 230.7L54.19 98.47C101 38.53 174 0 256 0C350.8 0 433.5 51.48 477.8 128V128zM168 256C168 207.4 207.4 168 256 168C304.6 168 344 207.4 344 256C344 304.6 304.6 344 256 344C207.4 344 168 304.6 168 256z"],Facebook:[512,512,[],"solid","M512 256C512 114.6 397.4 0 256 0S0 114.6 0 256C0 376 82.7 476.8 194.2 504.5V334.2H141.4V256h52.8V222.3c0-87.1 39.4-127.5 125-127.5c16.2 0 44.2 3.2 55.7 6.4V172c-6-.6-16.5-1-29.6-1c-42 0-58.2 15.9-58.2 57.2V256h83.6l-14.4 78.2H287V510.1C413.8 494.8 512 386.9 512 256h0z"],Github:[496,512,[],"solid","M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"],Youtube:[576,512,[],"solid","M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z"],"CircleRight@solid":[512,512,[],"solid","M0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zm395.3 11.3l-112 112c-4.6 4.6-11.5 5.9-17.4 3.5s-9.9-8.3-9.9-14.8l0-64-96 0c-17.7 0-32-14.3-32-32l0-32c0-17.7 14.3-32 32-32l96 0 0-64c0-6.5 3.9-12.3 9.9-14.8s12.9-1.1 17.4 3.5l112 112c6.2 6.2 6.2 16.4 0 22.6z"],"CircleUp@solid":[512,512,[],"solid","M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm11.3-395.3l112 112c4.6 4.6 5.9 11.5 3.5 17.4s-8.3 9.9-14.8 9.9l-64 0 0 96c0 17.7-14.3 32-32 32l-32 0c-17.7 0-32-14.3-32-32l0-96-64 0c-6.5 0-12.3-3.9-14.8-9.9s-1.1-12.9 3.5-17.4l112-112c6.2-6.2 16.4-6.2 22.6 0z"],"CircleLeft@solid":[512,512,[],"solid","M512 256A256 256 0 1 0 0 256a256 256 0 1 0 512 0zM116.7 244.7l112-112c4.6-4.6 11.5-5.9 17.4-3.5s9.9 8.3 9.9 14.8l0 64 96 0c17.7 0 32 14.3 32 32l0 32c0 17.7-14.3 32-32 32l-96 0 0 64c0 6.5-3.9 12.3-9.9 14.8s-12.9 1.1-17.4-3.5l-112-112c-6.2-6.2-6.2-16.4 0-22.6z"],"CircleDown@solid":[512,512,[],"solid","M256 0a256 256 0 1 0 0 512A256 256 0 1 0 256 0zM244.7 395.3l-112-112c-4.6-4.6-5.9-11.5-3.5-17.4s8.3-9.9 14.8-9.9l64 0 0-96c0-17.7 14.3-32 32-32l32 0c17.7 0 32 14.3 32 32l0 96 64 0c6.5 0 12.3 3.9 14.8 9.9s1.1 12.9-3.5 17.4l-112 112c-6.2 6.2-16.4 6.2-22.6 0z"],"PaperPlane@solid":[512,512,[],"solid","M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480l0-83.6c0-4 1.5-7.8 4.2-10.8L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"]};t.LucideIconAlias={Stop:"Square",Refresh:"RefreshCw",Left:"ChevronLeft",Right:"ChevronRight",Up:"ChevronUp",Down:"ChevronDown",MenuArrows:"ChevronsUpDown",RotateForward:"RotateCw",RotateRight:"RotateCw",RotateBack:"RotateCcw",RotateLeft:"RotateCcw"},t.ICONS=(()=>{const e={};for(let t in s){s[t][2].forEach(s=>e[s]=t)}return{...s,...e}})();let i=class{name;value;domEvent;constructor(e,t,s){this.name=e,this.value=t,this.domEvent=s}};t.IEvent=i;class o{static NONE=0;static NODE_SELECTED=1;static NODE_DELETED=2;static NODE_DBLCLICKED=3;static NODE_CONTEXTMENU=4;static NODE_DRAGGED=5;static NODE_RENAMED=6;static NODE_VISIBILITY=7;static NODE_CARETCHANGED=8;type=o.NONE;node;value;event;multiple=!1;panel=null;constructor(e,t,s,i){this.type=e||o.NONE,this.node=t,this.value=s,this.event=i}string(){switch(this.type){case o.NONE:return"tree_event_none";case o.NODE_SELECTED:return"tree_event_selected";case o.NODE_DELETED:return"tree_event_deleted";case o.NODE_DBLCLICKED:return"tree_event_dblclick";case o.NODE_CONTEXTMENU:return"tree_event_contextmenu";case o.NODE_DRAGGED:return"tree_event_dragged";case o.NODE_RENAMED:return"tree_event_renamed";case o.NODE_VISIBILITY:return"tree_event_visibility";case o.NODE_CARETCHANGED:return"tree_event_caretchanged"}}}var n;t.TreeEvent=o,function(e){e[e.NONE=0]="NONE",e[e.TEXT=1]="TEXT",e[e.TEXTAREA=2]="TEXTAREA",e[e.BUTTON=3]="BUTTON",e[e.SELECT=4]="SELECT",e[e.CHECKBOX=5]="CHECKBOX",e[e.TOGGLE=6]="TOGGLE",e[e.RADIO=7]="RADIO",e[e.BUTTONS=8]="BUTTONS",e[e.COLOR=9]="COLOR",e[e.RANGE=10]="RANGE",e[e.NUMBER=11]="NUMBER",e[e.TITLE=12]="TITLE",e[e.VECTOR=13]="VECTOR",e[e.TREE=14]="TREE",e[e.PROGRESS=15]="PROGRESS",e[e.FILE=16]="FILE",e[e.LAYERS=17]="LAYERS",e[e.ARRAY=18]="ARRAY",e[e.LIST=19]="LIST",e[e.TAGS=20]="TAGS",e[e.CURVE=21]="CURVE",e[e.CARD=22]="CARD",e[e.IMAGE=23]="IMAGE",e[e.CONTENT=24]="CONTENT",e[e.CUSTOM=25]="CUSTOM",e[e.SEPARATOR=26]="SEPARATOR",e[e.KNOB=27]="KNOB",e[e.SIZE=28]="SIZE",e[e.OTP=29]="OTP",e[e.PAD=30]="PAD",e[e.FORM=31]="FORM",e[e.DIAL=32]="DIAL",e[e.COUNTER=33]="COUNTER",e[e.TABLE=34]="TABLE",e[e.TABS=35]="TABS",e[e.DATE=36]="DATE",e[e.MAP2D=37]="MAP2D",e[e.LABEL=39]="LABEL",e[e.BLANK=40]="BLANK",e[e.RATE=41]="RATE"}(n||(n={})),t.ComponentType=n;let a=class e{type;name;customName;options;root;customIdx=-1;disabled=!1;onSetValue;onGetValue;onAllowPaste;onResize;_initialValue;static NO_CONTEXT_TYPES=[n.BUTTON,n.LIST,n.FILE,n.PROGRESS];constructor(e,s,i,o={}){this.type=e,this.name=s,this.options=o,this._initialValue=i;const a=document.createElement("div");if(a.className="lexcomponent",this.onResize=()=>{},o.id&&(a.id=o.id),o.title&&(a.title=o.title),o.className&&(a.className+=" "+o.className),e!=n.TITLE&&(o.width&&(a.style.width=a.style.minWidth=o.width),o.maxWidth&&(a.style.maxWidth=o.maxWidth),o.minWidth&&(a.style.minWidth=o.minWidth),o.height&&(a.style.height=a.style.minHeight=o.height),t.componentResizeObserver.observe(a)),null!=s){if(!o.hideName){let e=document.createElement("div");e.className="lexcomponentname",o.justifyName&&e.classList.add("float-"+o.justifyName),e.innerHTML=s,e.title=o.title??e.innerHTML,e.style.width=o.nameWidth||t.DEFAULT_NAME_WIDTH,e.style.minWidth=e.style.width,a.appendChild(e),a.domName=e;const n=this;e.addEventListener("contextmenu",function(e){e.preventDefault(),n.oncontextmenu(e)}),o.skipReset||null==i||this._addResetProperty(e,function(e,t){n.set(n._initialValue,!1,t),e.style.display="none"})}}else o.hideName=!0;o.signal&&t.addSignal(o.signal,this),this.root=a,this.root.jsInstance=this,this.options=o}static _dispatchEvent(e,t,s,i,o){let n=new CustomEvent(t,{detail:s,bubbles:i,cancelable:o});e.dispatchEvent(n)}_addResetProperty(e,s){const i=t.makeIcon("Undo2",{iconClass:"ml-0 mr-1 px-1",title:"Reset"});return i.style.display="none",i.addEventListener("click",s.bind(i,i)),e.appendChild(i),i}_canPaste(){const e=navigator.clipboard;let t=this.type===n.CUSTOM?void 0!==e.customIdx&&this.customIdx==e.customIdx:e.type===this.type;return t=t&&!0!==this.disabled,this.onAllowPaste&&(t=this.onAllowPaste(t)),t}_trigger(e,t,s=this){t&&t.call(s,e.value,e.domEvent,e.name)}value(){if(this.onGetValue)return this.onGetValue();console.warn("Can't get value of "+this.typeName())}set(e,t,s){if(this.onSetValue){let i=this.root.querySelector(".lexcomponentname .lexicon");if(i){i.style.display=e!=this.value()?"block":"none";const t=e.constructor===Array?function(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var s=0;s<e.length;++s)if(e[s]!==t[s])return!1;return!0}(e,this._initialValue):e==this._initialValue;i.style.display=t?"none":"block"}return this.onSetValue(e,t??!1,s)}console.warn(`Can't set value of ${this.typeName()}`)}oncontextmenu(s){e.NO_CONTEXT_TYPES.includes(this.type)||t.addContextMenu(this.typeName(),s,e=>{e.add("Copy",()=>{this.copy()}),e.add("Paste",{disabled:!this._canPaste(),callback:()=>{this.paste()}})})}copy(){const e=navigator.clipboard;e.type=this.type,e.customIdx=this.customIdx,e.data=this.value(),e.writeText(e.data)}paste(){if(!this._canPaste())return;const e=navigator.clipboard;this.set(e.data)}typeName(){switch(this.type){case n.TEXT:return"Text";case n.TEXTAREA:return"TextArea";case n.BUTTON:return"Button";case n.SELECT:return"Select";case n.CHECKBOX:return"Checkbox";case n.TOGGLE:return"Toggle";case n.RADIO:return"Radio";case n.COLOR:return"Color";case n.RANGE:return"Range";case n.NUMBER:return"Number";case n.VECTOR:return"Vector";case n.TREE:return"Tree";case n.PROGRESS:return"Progress";case n.FILE:return"File";case n.LAYERS:return"Layers";case n.ARRAY:return"Array";case n.LIST:return"List";case n.TAGS:return"Tags";case n.CURVE:return"Curve";case n.KNOB:return"Knob";case n.SIZE:return"Size";case n.PAD:return"Pad";case n.FORM:return"Form";case n.DIAL:return"Dial";case n.COUNTER:return"Counter";case n.TABLE:return"Table";case n.TABS:return"Tabs";case n.DATE:return"Date";case n.MAP2D:return"Map2D";case n.RATE:return"Rate";case n.LABEL:return"Label";case n.BLANK:return"Blank";case n.CUSTOM:return this.customName}console.error(`Unknown Component type: ${this.type}`)}refresh(e){}};t.BaseComponent=a;class l extends a{selectable=!1;callback;setState;swap;constructor(e,s,o,a={}){super(n.BUTTON,e,null,a),this.callback=o,this.selectable=a.selectable??this.selectable,this.onGetValue=()=>{const e=t.hasClass(l,"selected"),i=l.querySelector("input");return i?i.checked:this.selectable?e:s},this.onSetValue=(e,s,i)=>{if(a.swap)this.setState(e,s);else if(l.innerHTML="",a.icon){const e=t.makeIcon(a.icon);l.prepend(e)}else if(a.img){let e=document.createElement("img");e.src=a.img,l.prepend(e)}else l.innerHTML=`<span>${e??""}</span>`},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`},this.setState=function(t,n){const r=l.querySelector("input");r?r.checked=t:this.selectable&&(a.parent&&a.parent.querySelectorAll(".lexbutton.selected").forEach(e=>{e!=l&&e.classList.remove("selected")}),l.classList.toggle("selected",t)),n||this._trigger(new i(e,r?r.checked:this.selectable?t:s,null),o)};var l=document.createElement("button");if(l.title=a.tooltip?"":a.title??"",l.className="lexbutton px-3 "+(a.buttonClass??""),this.root.appendChild(l),a.selected&&l.classList.add("selected"),a.img){let e=document.createElement("img");e.src=a.img,l.prepend(e)}else if(a.icon){const e=t.makeIcon(a.icon,{iconClass:a.iconClass,svgClass:a.svgClass}),i=a.iconPosition??"cover";"cover"==i||void 0!==a.swap?l.prepend(e):(l.innerHTML=`<span>${s||""}</span>`,"start"==i?l.querySelector("span").prepend(e):l.querySelector("span").appendChild(e)),l.classList.add("justify-center")}else l.innerHTML=`<span>${s||""}</span>`;if(a.fileInput){const e=document.createElement("input");e.type="file",e.className="file-input",e.style.display="none",l.appendChild(e),e.addEventListener("change",function(e){if(!e.target)return;const t=e.target.files;if(!t.length)return;const s=new FileReader;"text"===a.fileInputType?s.readAsText(t[0]):"buffer"===a.fileInputType?s.readAsArrayBuffer(t[0]):"bin"===a.fileInputType?s.readAsBinaryString(t[0]):"url"===a.fileInputType&&s.readAsDataURL(t[0]),s.onload=e=>{o.call(this,e.target?.result,t[0])}})}a.disabled&&(this.disabled=!0,l.setAttribute("disabled",!0));let r=l;if(a.swap){l.classList.add("swap"),l.querySelector("a").classList.add("swap-off");const e=document.createElement("input");e.className="p-0 border-0",e.type="checkbox",l.prepend(e);const s=t.makeIcon(a.swap,{iconClass:"swap-on"});l.appendChild(s),this.swap=function(e){const t=l.querySelector("input");t.checked=!t.checked,e||r.click()}}r.addEventListener("click",n=>{let r;if(this.selectable&&(a.parent&&a.parent.querySelectorAll(".lexbutton.selected").forEach(e=>{e!=l&&e.classList.remove("selected")}),r=l.classList.toggle("selected")),a.fileInput)l.querySelector(".file-input").click();else if(a.mustConfirm){const r=l.querySelector("input");new t.PopConfirm(l,{onConfirm:()=>{a.swap&&(r.checked=!0),this._trigger(new i(e,s,n),o)},side:a.confirmSide,align:a.confirmAlign,confirmText:a.confirmText,cancelText:a.confirmCancelText,title:a.confirmTitle,content:a.confirmContent}),a.swap&&(r.checked=!1)}else{const t=l.querySelector("input");this._trigger(new i(e,t?.checked??(this.selectable?r:s),n),o)}}),a.tooltip&&t.asTooltip(l,a.title??e),t.doAsync(this.onResize.bind(this))}click(){this.root.querySelector("button").click()}setSwapIcon(e){const s=this.root.querySelector(".swap-on");if(!s)return;const i=t.makeIcon(e,{iconClass:"swap-on"});s.replaceWith(i)}}t.Button=l;class r{root;siblingArea;buttonContainer;items=[];buttons={};icons={};shorts={};focused=!1;_currentDropdown;constructor(e,t={}){this.root=document.createElement("div"),this.root.className="lexmenubar",t.float&&(this.root.style.justifyContent=t.float),this.items=e??[],this.createEntries()}_resetMenubar(e){this.root.querySelectorAll(".lexmenuentry").forEach(e=>{e.classList.remove("selected"),delete e.dataset.built}),this._currentDropdown&&(this._currentDropdown.destroy(),this._currentDropdown=null),this.focused=e??!1}createEntries(){for(let e of this.items){let s=e.name,i=t.getSupportedDOMName(s);if(this.root.querySelector("#"+i))continue;let o=document.createElement("div");o.className="lexmenuentry",o.id=i,o.innerHTML="<span>"+s+"</span>",o.tabIndex=1,this.root.appendChild(o);const n=()=>{this._resetMenubar(!0),o.classList.add("selected"),o.dataset.built="true",this._currentDropdown=t.addDropdownMenu(o,e.submenu??[],{side:"bottom",align:"start",onBlur:()=>{this._resetMenubar()}})};o.addEventListener("mousedown",e=>{e.preventDefault()}),o.addEventListener("mouseup",t=>{t.preventDefault();const i=e.callback;if(!i)return n(),this.focused=!0,!1;i.call(this,s,o,t)}),o.addEventListener("mouseover",e=>{this.focused&&!o.dataset.built&&n()})}}getButton(e){return this.buttons[e]}getSubitem(e,t){for(const s of e)if(s?.name==t[0]){if(1==t.length)return s;if(s.submenu)return t.shift(),this.getSubitem(s.submenu,t)}}getItem(e){const t=e.split("/");return this.getSubitem(this.items,t)}setButtonIcon(e,s,i,o={}){if(!e)throw"Set Button Name!";let n=this.buttons[e];n&&(delete this.buttons[e],t.deleteElement(n.root)),n=new l(e,void 0,i,{title:e,buttonClass:"lexmenubutton main bg-none",disabled:o.disabled,icon:s,svgClass:"xl",hideName:!0,swap:o.swap}),"right"==o.float&&(n.root.right=!0),this.root.lastChild&&this.root.lastChild.right?this.root.lastChild.before(n.root):"left"==o.float?this.root.prepend(n.root):this.root.appendChild(n.root),this.buttons[e]=n}setButtonImage(e,t,s,i={}){if(!e)throw"Set Button Name!";let o=this.buttons[e];if(o)return void(o.querySelector("img").src=t);o=document.createElement("div");const n=i.disabled??!1;o.className="lexmenubutton main"+(n?" disabled":""),o.title=e,o.innerHTML="<a><image src='"+t+"' class='lexicon' style='height:32px;'></a>","right"==i.float&&(o.right=!0),this.root.lastChild&&this.root.lastChild.right?this.root.lastChild.before(o):"left"==i.float?this.root.prepend(o):this.root.appendChild(o);const a=o.querySelector("a");a.addEventListener("mousedown",e=>{e.preventDefault()}),a.addEventListener("mouseup",e=>{s&&!n&&s.call(this,a,e)}),this.buttons[e]=o}addButtons(e,t={}){if(!e)throw"No buttons to add!";this.buttonContainer||(this.buttonContainer=document.createElement("div"),this.buttonContainer.className="lexmenubuttons",this.buttonContainer.classList.add(t.float??"center"),"right"==t.float&&(this.buttonContainer.right=!0),this.root.lastChild&&this.root.lastChild.right?this.root.lastChild.before(this.buttonContainer):this.root.appendChild(this.buttonContainer));for(const t of e){const e=t.title,s=new l(e,t.label,t.callback,{title:e,buttonClass:"bg-none",disabled:t.disabled,icon:t.icon,hideName:!0,swap:t.swap,iconPosition:"start"});this.buttonContainer.appendChild(s.root),e&&(this.buttons[e]=s)}}}class c{static TAB_ID=0;root;area;tabs={};tabDOMs={};thumb;selected=null;folding=!1;folded=!1;onclose;constructor(e,s={}){this.onclose=s.onclose;let i=document.createElement("div");i.className="lexareatabs "+(s.fit?"fit":"row");const o=s.folding??!1;o&&i.classList.add("folding");let n=this;i.addEventListener("dragenter",function(e){e.preventDefault(),this.classList.add("dockingtab")}),i.addEventListener("dragleave",function(e){e.preventDefault(),this.contains(e.relatedTarget)||this.classList.remove("dockingtab")}),i.addEventListener("drop",function(e){e.preventDefault();const t=e.dataTransfer.getData("source"),s=document.getElementById(t);if(!s)return;const i=s.parentElement,o=e.target,a=o.getBoundingClientRect();e.offsetX<.5*a.width?this.insertBefore(s,o):o.nextElementSibling?this.insertBefore(s,o.nextElementSibling):this.appendChild(s);{i.childNodes.forEach((e,t)=>e.childIndex=t-1);const t=/true/.test(e.dataTransfer.getData("fit"));let s=null;if(i.childElementCount==(t?2:1))s=i.lastChild;else{s=i.querySelector(".selected")??i.childNodes[t?1:0]}s._forceSelect=!0,s.click()}this.childNodes.forEach((e,t)=>e.childIndex=t-1);const l=document.getElementById(t+"_content");n.area.attach(l),this.classList.remove("dockingtab"),s.instance=n,s._forceSelect=!0,s.click(),n.tabs[s.dataset.name]=l}),e.root.classList.add("lexareatabscontainer");const[a,l]=e.split({type:"vertical",sizes:s.sizes??"auto",resize:!1,top:2});if(a.attach(i),s.parentClass&&i.parentElement&&(i.parentElement.className+=` ${s.parentClass}`),this.area=l,this.area.root.className+=" lexareatabscontent",s.contentClass&&(this.area.root.className+=` ${s.contentClass}`),this.selected=null,this.root=i,s.fit){let e=document.createElement("span");e.className="lexareatab thumb",this.thumb=e,this.root.appendChild(e);new ResizeObserver(e=>{const s=this.thumb.item;if(s){var i=this.thumb.style.transition;this.thumb.style.transition="none",this.thumb.style.transform="translate( "+s.childIndex*s.offsetWidth+"px )",this.thumb.style.width=s.offsetWidth+"px",t.flushCss(this.thumb),this.thumb.style.transition=i}}).observe(this.area.root)}if(o){this.folded=!0,this.folding=o,"up"==o&&t.insertChildAtIndex(e.root,e.sections[1].root,0);new ResizeObserver(t=>{for(const s of t){const t=s.contentRect,i=e.parentArea?.sections[0].root;i.style.height="calc(100% - "+(42+t.height)+"px )"}}).observe(this.area.root),this.area.root.classList.add("folded")}}add(e,s,i={}){let o=i.selected??!1;if(o){this.root.querySelectorAll("span").forEach(e=>e.classList.remove("selected"));(this.area.root.querySelector(":scope > .pseudoparent-tabs")??this.area.root).querySelectorAll(":scope > .lextabcontent").forEach(e=>e.style.display="none")}o=!Object.keys(this.tabs).length&&!this.folding||o;let n=s.root?s.root:s;if(n.originalDisplay=n.style.display,n.style.display=o?n.originalDisplay:"none",n.classList.add("lextabcontent"),i.icon)if(i.icon.includes(".")){const e="https://raw.githubusercontent.com/jxarco/lexgui.js/master/";i.icon="<img src='"+(e+i.icon)+"'>"}else{const e=i.icon.split(" ");i.icon=t.makeIcon(e[0],{svgClass:"sm "+e.slice(0).join(" ")}).innerHTML}let a=document.createElement("span");if(a.dataset.name=e,a.className="lexareatab flex flex-row gap-1"+(o?" selected":""),a.innerHTML=(i.icon??"")+e,a.id=e.replace(/\s/g,"")+c.TAB_ID++,a.title=i.title??"",a.selected=o??!1,a.fixed=i.fixed,a.instance=this,n.id=a.id+"_content",i.badge){const e={};(i.badge.asChild??!1)&&(e.parent=a),a.innerHTML+=t.badge(i.badge.content??"",i.badge.className,e)}a.selected&&(this.selected=e),a.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation();const t=a.instance;if(!a.fixed){const e=a.selected;a.parentElement.querySelectorAll("span").forEach(e=>e.selected=!1),a.selected=!e||!!a._forceSelect,a.parentElement.querySelectorAll("span").forEach(e=>e.classList.remove("selected")),a.classList.toggle("selected",a.selected);(t.area.root.querySelector(":scope > .pseudoparent-tabs")??t.area.root).querySelectorAll(":scope > .lextabcontent").forEach(e=>e.style.display="none"),n.style.display=n.originalDisplay,t.selected=a.dataset.name}t.folding&&(t.folded=a.selected,t.area.root.classList.toggle("folded",!t.folded)),i.onSelect&&i.onSelect(e,a.dataset.name),t.thumb&&(t.thumb.style.transform="translate( "+a.childIndex*a.offsetWidth+"px )",t.thumb.style.width=a.offsetWidth+"px",t.thumb.item=a),delete a._forceSelect}),a.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation(),i.onContextMenu&&i.onContextMenu(e,a.dataset.name)}),i.allowDelete&&(a.addEventListener("mousedown",e=>{e.button==t.MOUSE_MIDDLE_CLICK&&e.preventDefault()}),a.addEventListener("mouseup",e=>{e.preventDefault(),e.stopPropagation(),e.button==t.MOUSE_MIDDLE_CLICK&&this.delete(a.dataset.name)})),a.setAttribute("draggable",!0),a.addEventListener("dragstart",e=>{const t=!!this.thumb;a.parentElement.childNodes.length!=(t?2:1)?(e.dataTransfer.setData("source",e.target.id),e.dataTransfer.setData("fit",t)):e.preventDefault()});const l=i.indexOffset??-1;a.childIndex=this.root.childElementCount+l,t.insertChildAtIndex(this.root,a,a.childIndex+1),this.area.attach(n),this.tabDOMs[e]=a,this.tabs[e]=s,setTimeout(()=>{i.onCreate&&i.onCreate.call(this,this.area.root.getBoundingClientRect()),o&&this.thumb&&(this.thumb.classList.add("no-transition"),this.thumb.style.transform="translate( "+a.childIndex*a.offsetWidth+"px )",this.thumb.style.width=a.offsetWidth+"px",this.thumb.item=a,this.thumb.classList.remove("no-transition"))},10)}select(e){this.tabDOMs[e]&&this.tabDOMs[e].click()}delete(e){this.selected==e&&(this.selected=null);const t=this.tabDOMs[e];if(!t||t.fixed)return;this.onclose&&this.onclose(e),this.tabDOMs[e].remove(),delete this.tabDOMs[e],this.tabs[e].remove(),delete this.tabs[e];const s=this.root.lastChild;s&&!s.fixed&&this.root.lastChild.click()}}t.Tabs=c;class h extends a{setLimits;constructor(e,s,o,a={}){super(n.NUMBER,e,s,a),this.onGetValue=()=>s,this.onSetValue=(n,l,c)=>{if(isNaN(n))return;s=t.clamp(+n,+h.min,+h.max),h.value=s=t.round(s,a.precision);const d=r.querySelector(".lexinputslider");d&&(d.value=s),l||this._trigger(new i(e,s,c),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=a.inputWidth??`calc( 100% - ${t})`},this.setLimits=(e,t,s)=>{};var l=document.createElement("div");l.className="lexnumber",this.root.appendChild(l);let r=document.createElement("div");r.className="numberbox",l.appendChild(r);let c=t.makeContainer(["auto","100%"],"relative flex flex-row cursor-text","",r),h=document.createElement("input");h.id="number_"+t.guidGenerator(),h.className="vecinput",h.min=a.min??-1e24,h.max=a.max??1e24,h.step=a.step??"any",h.type="number",s.constructor==Number&&(s=t.clamp(s,+h.min,+h.max),s=t.round(s,a.precision)),h.value=h.iValue=s,c.appendChild(h);const d=t.makeIcon("MoveVertical",{iconClass:"drag-icon hidden-opacity",svgClass:"sm"});if(c.appendChild(d),a.units){let e=t.makeContainer(["auto","auto"],"px-2 bg-secondary content-center",a.units,c,{"word-break":"keep-all"});h.unitBox=e}if(a.disabled&&(this.disabled=h.disabled=!0),!a.skipSlider&&void 0!==a.min&&void 0!==a.max){let e=t.makeContainer(["100%","auto"],"z-1 input-box","",r),i=document.createElement("input");i.className="lexinputslider",i.min=a.min,i.max=a.max,i.step=a.step??1,i.type="range",i.value=s,i.disabled=this.disabled,i.addEventListener("input",e=>{this.set(i.valueAsNumber,!1,e)},!1),i.addEventListener("mousedown",function(e){a.onPress&&a.onPress.bind(i)(e,i)},!1),i.addEventListener("mouseup",function(e){a.onRelease&&a.onRelease.bind(i)(e,i)},!1),e.appendChild(i),this.setLimits=(e,t,o)=>{h.min=i.min=e??h.min,h.max=i.max=t??h.max,h.step=o??h.step,i.step=o??i.step,this.set(s,!0)}}h.addEventListener("input",function(e){s=+h.valueAsNumber,s=t.round(s,a.precision)},!1),h.addEventListener("wheel",e=>{if(e.preventDefault(),h!==document.activeElement)return;let t=a.step??1;e.shiftKey?t*=10:e.altKey&&(t*=.1),s=+h.valueAsNumber-t*(e.deltaY>0?1:-1),this.set(s,!1,e)},{passive:!1}),h.addEventListener("change",e=>{this.set(h.valueAsNumber,!1,e)},{passive:!1});var u=this;let p=e=>{let t=-e.movementY;if(0!=t){let i=a.step??1;e.shiftKey?i*=10:e.altKey&&(i*=.1),s=+h.valueAsNumber+i*t,this.set(s,!1,e)}e.stopPropagation(),e.preventDefault()},m=e=>{var t=u.root.ownerDocument;t.removeEventListener("mousemove",p),t.removeEventListener("mouseup",m),document.body.classList.remove("noevents"),d.classList.add("hidden-opacity"),document.pointerLockElement&&document.exitPointerLock(),a.onRelease&&a.onRelease.bind(h)(e,h)};c.addEventListener("mousedown",e=>{if(document.activeElement!=h&&e.button==t.MOUSE_LEFT_CLICK){var s=u.root.ownerDocument;s.addEventListener("mousemove",p),s.addEventListener("mouseup",m),document.body.classList.add("noevents"),d.classList.remove("hidden-opacity"),e.stopImmediatePropagation(),e.stopPropagation(),document.pointerLockElement||c.requestPointerLock(),a.onPress&&a.onPress.bind(h)(e,h)}}),t.doAsync(this.onResize.bind(this))}}t.NumberInput=h;class d extends a{valid;_triggerEvent;_lastValueTriggered;constructor(e,s,o,a={}){super(n.TEXT,e,String(s),a),this.onGetValue=()=>s,this.onSetValue=(t,n,l)=>{let c=this._lastValueTriggered==t;a.ignoreValidation||(c=c||!this.valid(t)),c||(this._lastValueTriggered=s=t,r.value=t,delete this._triggerEvent,n||this._trigger(new i(e,t,l),o))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=a.inputWidth??`calc( 100% - ${t})`},this.valid=(e,s)=>{if(e=e??this.value(),!a.pattern)return!0;return 0==t.validateValueAtPattern(e,a.pattern,s).length};let l=document.createElement("div");l.className=a.warning?" lexwarning":"",l.style.display="flex",l.style.position="relative",this.root.appendChild(l),this.disabled=(a.disabled||a.warning)??!!a.url;let r=null;if(this.disabled)a.url?(r=document.createElement("a"),r.href=a.url,r.target="_blank",r.innerHTML=s??"",r.style.textAlign=a.float??"",r.className="lextext ellipsis-overflow"):(r=document.createElement("input"),r.disabled=!0,r.value=s,r.style.textAlign=a.float??"",r.className="lextext ellipsis-overflow "+(a.inputClass??""));else{r=document.createElement("input"),r.className="lextext "+(a.inputClass??""),r.type=a.type||"",r.value=s||"",r.style.textAlign=a.float??"",r.setAttribute("placeholder",a.placeholder??""),a.required&&r.setAttribute("required",a.required),a.pattern&&r.setAttribute("pattern",t.buildTextPattern(a.pattern));const e=a.trigger??"default";if("default"==e?(r.addEventListener("keyup",e=>{"Enter"==e.key&&(this._triggerEvent=e,r.blur())}),r.addEventListener("focusout",e=>{this._triggerEvent=this._triggerEvent??e,this.set(e.target.value,!1,this._triggerEvent)})):"input"==e&&r.addEventListener("input",e=>{this.set(e.target.value,!1,e)}),r.addEventListener("mousedown",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),a.icon){r.style.paddingLeft="1.75rem";const e=t.makeIcon(a.icon,{iconClass:"absolute z-1 ml-2",svgClass:"sm"});l.appendChild(e)}}a.fit&&r.classList.add("size-content"),Object.assign(r.style,a.style??{}),l.appendChild(r),t.doAsync(this.onResize.bind(this))}}t.TextInput=d;class u extends a{_lastPlacement=[!1,!1];constructor(e,s,o,a,r={}){super(n.SELECT,e,o,r),this.onGetValue=()=>o,this.onSetValue=(n,l,c)=>{o=n;let h=null;if(C.childNodes.forEach(e=>{e.classList.remove("selected"),e.getAttribute("value")==n&&(h=e)}),console.assert(h,`Item ${n} does not exist in the Select.`),h.classList.add("selected"),p.refresh(o),f){f.root.querySelector("input").value="";const e=this._filterOptions(s,"");g.refresh(e)}const d=this.root.querySelector(".lexcustomcontainer"),u=r[`on_${o}`];if(d.toggleAttribute("hidden",!u),u){d.innerHTML="";const e=new t.Panel;e.queue(d),u.call(this,e),e.clearQueue()}this.root.dataset.opened=!!u,g.style.height="",l||this._trigger(new i(e,o,c),a)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=r.inputWidth??`calc( 100% - ${t})`};let c=document.createElement("div");c.className="lexselect",this.root.appendChild(c);let h=document.createElement("div");h.className="lexselect lexoption",h.name=e,h.iValue=o,void 0!==r.overflowContainer&&(r.overflowContainerX=r.overflowContainerY=r.overflowContainer);const u=(e,s)=>{const i=p.root,o=i.getBoundingClientRect(),n=e.parentElement.closest("dialog")??e.parentElement.closest(".lexcolorpicker");{const a=void 0!==r.overflowContainerY?r.overflowContainerY:t.getParentArea(e),l=e.offsetHeight;let c=o.y,h=window.innerHeight;if(a){const e=a.getBoundingClientRect();h=e.y+e.height}if(n){const e=n.getBoundingClientRect();c-=e.y,h-=e.y}e.style.top=c+i.offsetHeight+"px",g.style.height="";const d=s?this._lastPlacement[0]:c-l<0,u=s?this._lastPlacement[1]:c+l>h;u&&!d?(e.style.top=c-l+"px",e.classList.add("place-above")):u&&d&&(g.style.height=h-c-32+"px"),this._lastPlacement=[d,u]}{const s=void 0!==r.overflowContainerX?r.overflowContainerX:t.getParentArea(e),i=e.offsetWidth;let a=o.x;if(e.style.minWidth=o.width+"px",n){a-=n.getBoundingClientRect().x}e.style.left=a+"px";let l=window.innerWidth;if(s){const e=s.getBoundingClientRect();l=e.x+e.width}a+i>l&&(e.style.left=a-(i-o.width)+"px")}};let p=new l(null,o,(e,t)=>{if(g.unfocus_event)return void delete g.unfocus_event;m.classList.remove("place-above");m.hasAttribute("open")?m.close():(m.show(),u(m)),f&&f.root.querySelector("input").focus()},{buttonClass:"array",skipInlineCount:!0,disabled:r.disabled});p.root.style.width="100%",p.root.querySelector("span").appendChild(t.makeIcon("Down",{svgClass:"sm"})),c.appendChild(p.root),p.refresh=e=>{const t=p.root.querySelector("span");""==t.innerText?t.innerText=e:t.innerHTML=t.innerHTML.replaceAll(t.innerText,e)};const m=document.createElement("dialog");m.className="lexselectoptions";let g=document.createElement("ul");g.tabIndex=-1,g.className="lexoptions",m.appendChild(g),g.addEventListener("focusout",function(e){if(e.stopPropagation(),e.stopImmediatePropagation(),e.relatedTarget===p.root.querySelector("button"))g.unfocus_event=!0,setTimeout(()=>delete g.unfocus_event,200);else{if(e.relatedTarget&&m.contains(e.relatedTarget))return;if("lexinput-filter"==e.target.className)return}m.close()});let f=null;if(r.filter){const e=t.deepCopy(r);e.placeholder=e.placeholder??"Search...",e.skipComponent=e.skipComponent??!0,e.trigger="input",e.icon="Search",e.className="lexfilter",e.inputClass="outline",f=new d(null,r.filterValue??"",e=>{const t=this._filterOptions(s,e);g.refresh(t),u(m,!0)},e),f.root.querySelector(".lextext").style.border="1px solid transparent";f.root.querySelector("input").addEventListener("focusout",function(e){e.relatedTarget&&"UL"==e.relatedTarget.tagName&&e.relatedTarget.classList.contains("lexoptions")||m.close()}),g.appendChild(f.root)}const C=document.createElement("span");C.className="lexselectinnerlist",g.appendChild(C),g.refresh=e=>{if(C.innerHTML="",!e.length){let e=r.emptyMsg??"No options found.",s=document.createElement("div");s.className="option",s.innerHTML=t.makeIcon("Inbox",{svgClass:"mr-2"}).innerHTML+e;let i=document.createElement("li");return i.className="lexselectitem empty",i.appendChild(s),void C.appendChild(i)}for(let s=0;s<e.length;s++){let i=e[s],n=document.createElement("li"),a=document.createElement("div");a.className="option",n.appendChild(a);const l=e=>{this.set(e.currentTarget?.getAttribute("value"),!1,e),m.close()};if(n.addEventListener("click",l),i.constructor!=Object){const e="@"===i[0];e?(a.innerHTML="<span>"+i.substr(1)+"</span>",n.removeEventListener("click",l)):(a.innerHTML=`<span>${i}</span>`,a.appendChild(t.makeIcon("Check")),a.value=i,n.setAttribute("value",i),i==o&&(n.classList.add("selected"),h.innerHTML=i)),n.classList.add(e?"lexselectlabel":"lexselectitem")}else{let e=document.createElement("img");e.src=i.src,n.setAttribute("value",i.value),n.className="lexlistitem",a.innerText=i.value,a.className+=" media",a.prepend(e),a.setAttribute("value",i.value),a.setAttribute("data-index",s),a.setAttribute("data-src",i.src),a.setAttribute("title",i.value),o==i.value&&n.classList.add("selected")}C.appendChild(n)}},g.refresh(s),c.appendChild(m);let v=document.createElement("div");v.className="lexcustomcontainer w-full";const y=r[`on_${o}`];if(v.toggleAttribute("hidden",!y),y){v.innerHTML="";const e=new t.Panel;e.queue(v),y.call(this,e),e.clearQueue()}this.root.appendChild(v),this.root.dataset.opened=!!y,t.doAsync(this.onResize.bind(this))}_filterOptions(e,t){const s=!t.length;let i=[];for(let o=0;o<e.length;o++){let n=e[o];if(!s){let e="string"==typeof n?n:n.value;const s=t.toLowerCase();if(!e.toLowerCase().includes(s))continue}i.push(n)}return i}}t.Select=u;class p extends a{_updateItems;constructor(e,s=[],o,a={}){a.nameWidth="100%",super(n.ARRAY,e,null,a),this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{s=t,this._updateItems(),n||this._trigger(new i(e,s,a),o)};let r=document.createElement("div");r.className="lexarray",r.style.width="100%",this.root.appendChild(r),this.root.dataset.opened=!1;let c=`Array (size ${s.length})`;const p=new l(null,c,()=>{this.root.dataset.opened="true"!=this.root.dataset.opened,this.root.querySelector(".lexarrayitems").toggleAttribute("hidden")},{buttonClass:"array"});p.root.querySelector("span").appendChild(t.makeIcon("Down",{svgClass:"sm"})),r.appendChild(p.root);let m=document.createElement("div");m.className="lexarrayitems",m.toggleAttribute("hidden",!0),this.root.appendChild(m),this._updateItems=()=>{let n=this.root.querySelector(".lexbutton.array span");for(let e of n.childNodes)if(e.nodeType===Node.TEXT_NODE){e.textContent=`Array (size ${s.length})`;break}m.innerHTML="";for(let t=0;t<s.length;++t){const n=s[t];let r=a.innerValues?"select":n.constructor,c=null;switch(r){case String:c=new d(t+"",n,function(e){s[t]=e,o(s)},{nameWidth:"12px",className:"p-0",skipReset:!0});break;case Number:c=new h(t+"",n,function(e){s[t]=e,o(s)},{nameWidth:"12px",className:"p-0",skipReset:!0});break;case"select":c=new u(t+"",a.innerValues,n,function(e){s[t]=e,o(s)},{nameWidth:"12px",className:"p-0",skipReset:!0})}console.assert(c,`Value of type ${r} cannot be modified in ArrayInput`),m.appendChild(c.root);const p=new l(null,"",(t,a)=>{s.splice(s.indexOf(n),1),this._updateItems(),this._trigger(new i(e,s,a),o)},{title:"Remove item",icon:"Trash3"});c.root.appendChild(p.root)}const r=new l(null,t.makeIcon("Plus",{svgClass:"sm"}).innerHTML+"Add item",(t,n)=>{s.push(a.innerValues?a.innerValues[0]:""),this._updateItems(),this._trigger(new i(e,s,n),o)},{buttonClass:"array"});m.appendChild(r.root)},this._updateItems()}}t.ArrayInput=p;class m extends a{constructor(e,s={}){s.hideName=!0,super(n.CARD,e,null,s),this.root.classList.add("place-content-center");const o=t.makeContainer(["100%","auto"],"lexcard max-w-sm flex flex-col gap-4 bg-primary border rounded-xl py-6","",this.root);if(s.header){const e=void 0!==s.header.action;let i=t.makeContainer(["100%","auto"],`flex ${e?"flex-row gap-4":"flex-col gap-1"} px-6`,"",o);if(e){const e=new l(null,s.header.action.name,s.header.action.callback);i.appendChild(e.root);const o=t.makeContainer(["75%","auto"],"flex flex-col gap-1","");i.prepend(o),i=o}s.header.title&&t.makeElement("div","text-md leading-none font-semibold",s.header.title,i),s.header.description&&t.makeElement("div","text-sm fg-tertiary",s.header.description,i)}if(s.content){const e=t.makeContainer(["100%","auto"],"flex flex-col gap-2 px-6","",o),i=[].concat(s.content);for(let t of i)e.appendChild(t.root?t.root:t)}if(s.footer){const e=t.makeContainer(["100%","auto"],"flex flex-col gap-1 px-6","",o),i=[].concat(s.footer);for(let t of i)e.appendChild(t.root?t.root:t)}s.callback&&(o.classList.add("selectable"),o.style.cursor="pointer",o.addEventListener("click",t=>{this._trigger(new i(e,null,t),s.callback)}))}}t.Card=m;class g extends a{constructor(e,s,o,a={}){if(!e&&!a.label)throw"Set Component Name or at least a label!";super(n.CHECKBOX,e,s,a),this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{t!=s&&(r.checked=s=t,this.root.querySelector(".lexcheckboxsubmenu")?.toggleAttribute("hidden",!t),n||this._trigger(new i(e,t,a),o))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=a.inputWidth??`calc( 100% - ${t})`};var l=document.createElement("div");l.className="lexcheckboxcont",this.root.appendChild(l);let r=document.createElement("input");r.type="checkbox",r.className="lexcheckbox "+(a.className??"primary"),r.checked=s,r.disabled=a.disabled??!1,l.appendChild(r);let c=document.createElement("span");if(c.className="checkboxtext",c.innerHTML=a.label??"On",l.appendChild(c),r.addEventListener("change",e=>{this.set(r.checked,!1,e)}),a.suboptions){let e=document.createElement("div");e.className="lexcheckboxsubmenu",e.toggleAttribute("hidden",!r.checked);const s=new t.Panel;s.queue(e),a.suboptions.call(this,s),s.clearQueue(),this.root.appendChild(e)}t.doAsync(this.onResize.bind(this))}}t.Checkbox=g;class f{_rgb;_hex="#000000";_hsv;css;get rgb(){return this._rgb}set rgb(e){this._fromRGB(e)}get hex(){return this._hex}set hex(e){this._fromHex(e)}get hsv(){return this._hsv}set hsv(e){this._fromHSV(e)}constructor(e){this.set(e)}set(e){if("string"==typeof e&&e.startsWith("#"))this._fromHex(e);else if("r"in e&&"g"in e&&"b"in e)e.a=e.a??1,this._fromRGB(e);else{if(!("h"in e&&"s"in e&&"v"in e))throw"Bad color model!";e.a=e.a??1,this._fromHSV(e)}}setHSV(e){this._fromHSV(e)}setRGB(e){this._fromRGB(e)}setHex(e){this._fromHex(e)}_fromHex(e){this._fromRGB(t.hexToRgb(e))}_fromRGB(e){this._rgb=e,this._hsv=t.rgbToHsv(e),this._hex=t.rgbToHex(e),this.css=t.rgbToCss(this._rgb)}_fromHSV(e){this._hsv=e,this._rgb=t.hsvToRgb(e),this._hex=t.rgbToHex(this._rgb),this.css=t.rgbToCss(this._rgb)}}t.Color=f;class C{static currentPicker=!1;root;colorModel;useAlpha;callback;markerHalfSize;markerSize;currentColor;labelComponent;colorPickerBackground;intSatMarker;colorPickerTracker;alphaTracker;hueMarker;alphaMarker;onPopover;constructor(e,s={}){this.colorModel=s.colorModel??"Hex",this.useAlpha=s.useAlpha??!1,this.callback=s.onChange,this.callback||console.warn("Define a callback in _options.onChange_ to allow getting new Color values!"),this.root=document.createElement("div"),this.root.className="lexcolorpicker",this.markerHalfSize=8,this.markerSize=2*this.markerHalfSize,this.currentColor=new f(e);const i=new f({h:this.currentColor.hsv.h,s:1,v:1});this.colorPickerBackground=document.createElement("div"),this.colorPickerBackground.className="lexcolorpickerbg",this.colorPickerBackground.style.backgroundColor=`rgb(${i.css.r}, ${i.css.g}, ${i.css.b})`,this.root.appendChild(this.colorPickerBackground),this.intSatMarker=document.createElement("div"),this.intSatMarker.className="lexcolormarker",this.intSatMarker.style.backgroundColor=this.currentColor.hex,this.colorPickerBackground.appendChild(this.intSatMarker);let o=null,n=e=>{const s=e.movementX,i=e.movementY,n=e.x-o.x,a=e.y-o.y;0!=s&&(n>=0||s<0)&&(n<this.colorPickerBackground.offsetWidth||s>0)&&(this.intSatMarker.style.left=t.clamp(parseInt(this.intSatMarker.style.left)+s,-this.markerHalfSize,this.colorPickerBackground.offsetWidth-this.markerHalfSize)+"px"),0!=i&&(a>=0||i<0)&&(a<this.colorPickerBackground.offsetHeight||i>0)&&(this.intSatMarker.style.top=t.clamp(parseInt(this.intSatMarker.style.top)+i,-this.markerHalfSize,this.colorPickerBackground.offsetHeight-this.markerHalfSize)+"px"),this._positionToSv(parseInt(this.intSatMarker.style.left),parseInt(this.intSatMarker.style.top)),this._updateColorValue(),e.stopPropagation(),e.preventDefault()},a=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",n),t.removeEventListener("mouseup",a),document.body.classList.remove("noevents")};this.colorPickerBackground.addEventListener("mousedown",e=>{var t=this.root.ownerDocument;t.addEventListener("mousemove",n),t.addEventListener("mouseup",a),document.body.classList.add("noevents"),e.stopImmediatePropagation(),e.stopPropagation();const s=e.offsetX-this.markerHalfSize;this.intSatMarker.style.left=s+"px";const i=e.offsetY-this.markerHalfSize;this.intSatMarker.style.top=i+"px",this._positionToSv(s,i),this._updateColorValue(),o=this.colorPickerBackground.getBoundingClientRect()});const r=t.makeContainer(["100%","auto"],"flex flex-row gap-1 items-center","",this.root),c=window.EyeDropper;c&&r.appendChild(new l(null,"eyedrop",async()=>{const e=new c;try{const t=await e.open();this.fromHexColor(t.sRGBHex)}catch(e){}},{icon:"Pipette",buttonClass:"bg-none",title:"Sample Color"}).root);const h=t.makeContainer(["100%","100%"],"flex flex-col gap-2","",r);this.colorPickerTracker=document.createElement("div"),this.colorPickerTracker.className="lexhuetracker",h.appendChild(this.colorPickerTracker),this.hueMarker=document.createElement("div"),this.hueMarker.className="lexcolormarker",this.hueMarker.style.backgroundColor=`rgb(${i.css.r}, ${i.css.g}, ${i.css.b})`,this.colorPickerTracker.appendChild(this.hueMarker);const p=e=>{this.hueMarker.style.left=e+"px",this.currentColor.hsv.h=t.remapRange(e,0,this.colorPickerTracker.offsetWidth-this.markerSize,0,360);const s=new f({h:this.currentColor.hsv.h,s:1,v:1});this.hueMarker.style.backgroundColor=`rgb(${s.css.r}, ${s.css.g}, ${s.css.b})`,this.colorPickerBackground.style.backgroundColor=`rgb(${s.css.r}, ${s.css.g}, ${s.css.b})`,this._updateColorValue()};let m=null,g=e=>{const s=e.movementX,i=e.x-m.x;if(0!=s&&(i>=this.markerHalfSize||s<0)&&(i<this.colorPickerTracker.offsetWidth-this.markerHalfSize||s>0)){const e=t.clamp(parseInt(this.hueMarker.style.left)+s,0,this.colorPickerTracker.offsetWidth-this.markerSize);p(e)}e.stopPropagation(),e.preventDefault()},C=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",g),t.removeEventListener("mouseup",C),document.body.classList.remove("noevents")};if(this.colorPickerTracker.addEventListener("mousedown",e=>{const s=this.root.ownerDocument;s.addEventListener("mousemove",g),s.addEventListener("mouseup",C),document.body.classList.add("noevents"),e.stopImmediatePropagation(),e.stopPropagation();const i=t.clamp(e.offsetX-this.markerHalfSize,0,this.colorPickerTracker.offsetWidth-this.markerSize);p(i),m=this.colorPickerTracker.getBoundingClientRect()}),this.useAlpha){this.alphaTracker=document.createElement("div"),this.alphaTracker.className="lexalphatracker",this.alphaTracker.style.color=`rgb(${this.currentColor.css.r}, ${this.currentColor.css.g}, ${this.currentColor.css.b})`,h.appendChild(this.alphaTracker),this.alphaMarker=document.createElement("div"),this.alphaMarker.className="lexcolormarker",this.alphaMarker.style.backgroundColor=`rgb(${this.currentColor.css.r}, ${this.currentColor.css.g}, ${this.currentColor.css.b},${this.currentColor.css.a})`,this.alphaTracker.appendChild(this.alphaMarker);const e=e=>{this.alphaMarker.style.left=e+"px",this.currentColor.hsv.a=t.remapRange(e,0,this.alphaTracker.offsetWidth-this.markerSize,0,1),this._updateColorValue(),this.alphaMarker.style.backgroundColor=`rgb(${this.currentColor.css.r}, ${this.currentColor.css.g}, ${this.currentColor.css.b},${this.currentColor.css.a})`};let s=null,i=i=>{const a=this.root.ownerDocument;a.addEventListener("mousemove",o),a.addEventListener("mouseup",n),document.body.classList.add("noevents"),i.stopImmediatePropagation(),i.stopPropagation();const l=t.clamp(i.offsetX-this.markerHalfSize,0,this.alphaTracker.offsetWidth-this.markerSize);e(l),s=this.alphaTracker.getBoundingClientRect()},o=i=>{const o=i.movementX,n=i.x-s.x;if(0!=o&&(n>=this.markerHalfSize||o<0)&&(n<this.alphaTracker.offsetWidth-this.markerHalfSize||o>0)){const s=t.clamp(parseInt(this.alphaMarker.style.left)+o,0,this.alphaTracker.offsetWidth-this.markerSize);e(s)}i.stopPropagation(),i.preventDefault()},n=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",o),t.removeEventListener("mouseup",n),document.body.classList.remove("noevents")};this.alphaTracker.addEventListener("mousedown",i)}const v=t.makeContainer(["100%","auto"],"flex flex-row gap-1","",this.root);v.appendChild(new u(null,["CSS","Hex","HSV","RGB"],this.colorModel,e=>{this.colorModel=e,this._updateColorValue(null,!0)}).root),this.labelComponent=new d(null,"",null,{inputClass:"bg-none",fit:!0,disabled:!0}),v.appendChild(this.labelComponent.root);{const e=new l(null,"copy",async()=>{navigator.clipboard.writeText(this.labelComponent.value()),e.root.querySelector("input[type='checkbox']").style.pointerEvents="none",t.doAsync(()=>{e.swap&&e.swap(!0),e.root.querySelector("input[type='checkbox']").style.pointerEvents="auto"},3e3)},{swap:"Check",icon:"Copy",buttonClass:"bg-none",className:"ml-auto",title:"Copy"});e.root.querySelector(".swap-on svg").classList.add("fg-success"),v.appendChild(e.root)}this._updateColorValue(e,!0),t.doAsync(this._placeMarkers.bind(this)),this.onPopover=this._placeMarkers.bind(this)}_placeMarkers(){this._svToPosition(this.currentColor.hsv.s,this.currentColor.hsv.v);const e=t.remapRange(this.currentColor.hsv.h,0,360,0,this.colorPickerTracker.offsetWidth-this.markerSize);if(this.hueMarker.style.left=e+"px",this.useAlpha){const e=t.remapRange(this.currentColor.hsv.a,0,1,0,this.alphaTracker.offsetWidth-this.markerSize);this.alphaMarker.style.left=e+"px"}}_svToPosition(e,s){this.intSatMarker.style.left=`${t.remapRange(e,0,1,-this.markerHalfSize,this.colorPickerBackground.offsetWidth-this.markerHalfSize)}px`,this.intSatMarker.style.top=`${t.remapRange(1-s,0,1,-this.markerHalfSize,this.colorPickerBackground.offsetHeight-this.markerHalfSize)}px`}_positionToSv(e,s){this.currentColor.hsv.s=t.remapRange(e,-this.markerHalfSize,this.colorPickerBackground.offsetWidth-this.markerHalfSize,0,1),this.currentColor.hsv.v=1-t.remapRange(s,-this.markerHalfSize,this.colorPickerBackground.offsetHeight-this.markerHalfSize,0,1)}_updateColorValue(e,t=!1){this.currentColor.set(e??this.currentColor.hsv),this.callback&&!t&&this.callback(this.currentColor),this.intSatMarker.style.backgroundColor=this.currentColor.hex,this.useAlpha&&(this.alphaTracker.style.color=`rgb(${this.currentColor.css.r}, ${this.currentColor.css.g}, ${this.currentColor.css.b})`);const s=(e,t=2)=>e.toFixed(t).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,"$1");if("CSS"==this.colorModel){const{r:e,g:t,b:i,a:o}=this.currentColor.css;this.labelComponent.set(`rgb${this.useAlpha?"a":""}(${e},${t},${i}${this.useAlpha?","+s(o):""})`)}else if("Hex"==this.colorModel)this.labelComponent.set((this.useAlpha?this.currentColor.hex:this.currentColor.hex.substr(0,7)).toUpperCase());else if("HSV"==this.colorModel){const{h:e,s:t,v:i,a:o}=this.currentColor.hsv,n=[Math.floor(e)+"º",Math.floor(100*t)+"%",Math.floor(100*i)+"%"];this.useAlpha&&n.push(s(o)),this.labelComponent.set(n.join(" "))}else{const{r:e,g:t,b:i,a:o}=this.currentColor.rgb,n=[s(e),s(t),s(i)];this.useAlpha&&n.push(s(o)),this.labelComponent.set(n.join(" "))}}fromHexColor(e){this.currentColor.setHex(e);const{h:s,s:i,v:o}=this.currentColor.hsv;this._svToPosition(i,o);const n=new f({h:s,s:1,v:1});this.hueMarker.style.backgroundColor=this.colorPickerBackground.style.backgroundColor=`rgb(${n.css.r}, ${n.css.g}, ${n.css.b})`,this.hueMarker.style.left=t.remapRange(s,0,360,-this.markerHalfSize,this.colorPickerTracker.offsetWidth-this.markerHalfSize)+"px",this._updateColorValue(e)}}t.ColorPicker=C;class v{static activeElement=null;root;side="bottom";align="center";sideOffset=0;alignOffset=0;avoidCollisions=!0;reference;_windowPadding=4;_trigger;_parent;_onClick;constructor(e,s,i={}){if(v.activeElement)return void v.activeElement.destroy();this._trigger=e,e&&(e.classList.add("triggered"),e.active=this),this.side=i.side??this.side,this.align=i.align??this.align,this.sideOffset=i.sideOffset??this.sideOffset,this.alignOffset=i.alignOffset??this.alignOffset,this.avoidCollisions=i.avoidCollisions??!0,this.reference=i.reference,this.root=document.createElement("div"),this.root.dataset.side=this.side,this.root.tabIndex="1",this.root.className="lexpopover";const o=(e??this.reference).closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=t.root,this._parent.appendChild(this.root),this.root.addEventListener("keydown",e=>{"Escape"==e.key&&(e.preventDefault(),e.stopPropagation(),this.destroy())}),s&&(s=[].concat(s)).forEach(e=>{const t=e.root??e;this.root.appendChild(t),e.onPopover&&e.onPopover()}),v.activeElement=this,t.doAsync(()=>{this._adjustPosition(),this._trigger&&(this.root.focus(),this._onClick=e=>{e.target&&(this.root.contains(e.target)||e.target==this._trigger)||this.destroy()},document.body.addEventListener("mousedown",this._onClick,!0),document.body.addEventListener("focusin",this._onClick,!0))},10)}destroy(){this._trigger&&(this._trigger.classList.remove("triggered"),delete this._trigger.active,document.body.removeEventListener("mousedown",this._onClick,!0),document.body.removeEventListener("focusin",this._onClick,!0)),this.root.remove(),v.activeElement=null}_adjustPosition(){const e=[0,0];{const t=this.reference??this._trigger;console.assert(t,"Popover needs a trigger or reference element!");const s=t.getBoundingClientRect();let i=!0;switch(this.side){case"left":e[0]+=s.x-this.root.offsetWidth-this.sideOffset,i=!1;break;case"right":e[0]+=s.x+s.width+this.sideOffset,i=!1;break;case"top":e[1]+=s.y-this.root.offsetHeight-this.sideOffset,i=!0;break;case"bottom":e[1]+=s.y+s.height+this.sideOffset,i=!0}switch(this.align){case"start":i?e[0]+=s.x:e[1]+=s.y;break;case"center":i?e[0]+=s.x+.5*s.width-.5*this.root.offsetWidth:e[1]+=s.y+.5*s.height-.5*this.root.offsetHeight;break;case"end":i?e[0]+=s.x-this.root.offsetWidth+s.width:e[1]+=s.y-this.root.offsetHeight+s.height}i?e[0]+=this.alignOffset:e[1]+=this.alignOffset}if(this.avoidCollisions&&(e[0]=t.clamp(e[0],0,window.innerWidth-this.root.offsetWidth-this._windowPadding),e[1]=t.clamp(e[1],0,window.innerHeight-this.root.offsetHeight-this._windowPadding)),this._parent instanceof HTMLDialogElement){let t=this._parent.getBoundingClientRect();e[0]-=t.x,e[1]-=t.y}this.root.style.left=`${e[0]}px`,this.root.style.top=`${e[1]}px`}}t.Popover=v;t.PopConfirm=class{_popover=null;constructor(e,s={}){const i=s.confirmText??"Yes",o=s.cancelText??"No",n=s.title??"Confirm",a=s.content??"Are you sure you want to proceed?",l=s.onConfirm,r=s.onCancel,c=t.makeContainer(["auto","auto"],"tour-step-container");{const e=t.makeContainer(["100%","auto"],"flex flex-row","",c);t.makeContainer(["100%","auto"],"p-1 font-medium text-md",n,e)}t.makeContainer(["100%","auto"],"p-1 text-md",a,c,{maxWidth:"400px"});const h=t.makeContainer(["100%","auto"],"flex flex-row text-md","",c),d=t.makeContainer(["100%","auto"],"text-md","",h),u=new t.Panel;d.appendChild(u.root),u.sameLine(2,"justify-end"),u.addButton(null,o,()=>{r&&r(),this._popover?.destroy()},{xbuttonClass:"contrast"}),u.addButton(null,i,()=>{l&&l(),this._popover?.destroy()},{buttonClass:"accent"}),this._popover?.destroy(),this._popover=new t.Popover(null,[c],{reference:e,side:s.side??"top",align:s.align,sideOffset:s.sideOffset,alignOffset:s.alignOffset})}};class y extends a{picker;_skipTextUpdate=!1;_popover=void 0;constructor(e,s,o,a={}){s=s??"#000000";const l=a.useAlpha??(s.constructor===Object&&"a"in s||s.constructor===String&&[5,9].includes(s.length)),r=new f(s);s=l?r.hex:r.hex.substr(0,7),super(n.COLOR,e,s,a),this.onGetValue=()=>{const e=new f(s);return a.useRGB?e.rgb:s},this.onSetValue=(t,n,r)=>{const c=new f(t);if(u.style.color=s=c.hex.substr(0,7),l&&(p.style.color=s=c.hex),this._skipTextUpdate||m.set(s,!0,r),!n){let t=s;a.useRGB&&(t=c.rgb,l||delete t.a),this._trigger(new i(e,t,r),o)}},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${t})`};var c=document.createElement("span");c.className="lexcolor",this.root.appendChild(c),this.picker=new C(s,{colorModel:a.useRGB?"RGB":"Hex",useAlpha:l,onChange:e=>{this.set(e.hex)}});let h=t.makeContainer(["18px","18px"],"flex flex-row bg-contrast rounded overflow-hidden","",c);h.tabIndex="1",h.addEventListener("click",e=>{a.disabled||(this._popover=new v(h,[this.picker]))});let u=document.createElement("div");u.className="lexcolorsample",u.style.color=s,h.appendChild(u);let p=null;l?(p=document.createElement("div"),p.className="lexcolorsample",p.style.color=s,h.appendChild(p)):u.style.width="18px";const m=new d(null,s,e=>{this._skipTextUpdate=!0,this.set(e),delete this._skipTextUpdate,this.picker.fromHexColor(e)},{width:"calc( 100% - 24px )",disabled:a.disabled});m.root.style.marginLeft="6px",c.appendChild(m.root),t.doAsync(this.onResize.bind(this))}}t.Color=f,t.ColorPicker=C,t.ColorInput=y;class b extends a{constructor(e,s,o={}){const a=!o.noSelection;let l=a&&(o.toggle??!1),r=document.createElement("div");r.className="lexcombobuttons ",o.skipReset=!0,o.float&&(r.className+=o.float);let c=[],h=document.createElement("div");h.className="lexcombobuttonsbox ",r.appendChild(h);for(let e of s){if(!e.value)throw"Set 'value' for each button!";let s=document.createElement("button");if(s.className="lexbutton combo",s.title=e.icon?e.value:"",s.id=e.id??"",s.dataset.value=e.value,o.buttonClass&&s.classList.add(o.buttonClass),a&&(e.selected||o.selected?.includes(e.value))&&(s.classList.add("selected"),c=c.concat([e.value])),e.icon){const i=t.makeIcon(e.icon);s.appendChild(i)}else s.innerHTML=`<span>${e.value}</span>`;e.disabled&&s.setAttribute("disabled","true"),s.addEventListener("click",t=>{c=[],a&&(l?s.classList.toggle("selected"):(r.querySelectorAll("button").forEach(e=>e.classList.remove("selected")),s.classList.add("selected"))),r.querySelectorAll("button").forEach(e=>{e.classList.contains("selected")&&c.push(e.dataset.value)}),!l&&c.length>1?console.error("Enable _options.toggle_ to allow selecting multiple options in ComboButtons."):(c=c[0],this.set(e.value,!1,s.classList.contains("selected")))}),h.appendChild(s)}c.length>1?l||(o.toggle=!0,l=a,console.warn(`Multiple options selected in '${e}' ComboButtons. Enabling _toggle_ mode.`)):c=c[0],super(n.BUTTONS,e,null,o),this.onGetValue=()=>c,this.onSetValue=(t,o,n)=>{if(a&&null==n&&(r.querySelectorAll("button").forEach(e=>e.classList.remove("selected")),r.querySelectorAll("button").forEach(e=>{c&&c.indexOf(e.dataset.value)>-1&&e.classList.add("selected")})),!o&&t.constructor!=Array){const o=n,a=s.filter(e=>e.value==t)[0]?.callback;this._trigger(new i(e,l?[t,o]:t,null),a)}},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${t})`},this.root.appendChild(r),t.doAsync(this.onResize.bind(this))}}t.ComboButtons=b;class _ extends a{count;constructor(e,s,o,a={}){super(n.COUNTER,e,s,a),this.onGetValue=()=>this.count,this.onSetValue=(s,n,a)=>{this.count=t.clamp(s,r,c),u.value=this.count,n||this._trigger(new i(e,s,a),o)},this.count=s;const r=a.min??0,c=a.max??100,h=a.step??1,d=document.createElement("div");d.className="flex flex-row border bg-primary rounded-lg shadow",this.root.appendChild(d);const u=t.makeElement("input","lexcounter w-12 bg-primary px-2 fg-primary","",d);u.type="number",u.value=s,a.disabled&&u.setAttribute("disabled","true");const p=new l(null,"",(e,t)=>{let s=h??1;t.shiftKey&&(s*=10),this.set(this.count-s,!1,t)},{disabled:a.disabled,className:`p-0 ${a.disabled?"":"hover:bg-secondary"} border-left border-right`,buttonClass:"bg-none",icon:"Minus"});d.appendChild(p.root);const m=new l(null,"",(e,t)=>{let s=h??1;t.shiftKey&&(s*=10),this.set(this.count+s,!1,t)},{disabled:a.disabled,className:`p-0 ${a.disabled?"":"hover:bg-secondary"} rounded-r-lg`,buttonClass:"bg-none",icon:"Plus"});d.appendChild(m.root)}}t.Counter=_;class x{element;canvas;constructor(e,s={}){let i=document.createElement("div");i.className="curve "+(s.className?s.className:""),i.style.minHeight="50px",i.style.width=s.width||"100%",i.style.minWidth="50px",i.style.minHeight="20px",i.bgcolor=s.bgColor||t.getThemeColor("global-background"),i.pointscolor=s.pointsColor||t.getThemeColor("global-color-accent"),i.activepointscolor=s.activePointsColor||t.getThemeColor("global-color-accent-light"),i.linecolor=s.lineColor||"#555",i.value=e||[],i.xrange=s.xrange||[0,1],i.yrange=s.yrange||[0,1],i.defaulty=null!=s.defaulty?s.defaulty:0,i.no_overlap=s.noOverlap||!1,i.show_samples=s.showSamples||0,i.allow_add_values=s.allowAddValues??!0,i.draggable_x=s.draggableX??!0,i.draggable_y=s.draggableY??!0,i.smooth=(s.smooth&&"number"==typeof s.smooth?s.smooth:.3)||!1,i.move_out=s.moveOutAction??t.CURVE_MOVEOUT_DELETE,t.addSignal("@on_new_color_scheme",(e,o)=>{i.bgcolor=s.bgColor||t.getThemeColor("global-background"),i.pointscolor=s.pointsColor||t.getThemeColor("global-color-accent"),i.activepointscolor=s.activePointsColor||t.getThemeColor("global-color-accent-light"),this.redraw()}),this.element=i;let o=document.createElement("canvas");function n(e){return[o.width*(e[0]-i.xrange[0])/i.xrange[1],o.height*(e[1]-i.yrange[0])/i.yrange[1]]}function a(e){return[e[0]*i.xrange[1]/o.width+i.xrange[0],e[1]*i.yrange[1]/o.height+i.yrange[0]]}o.width=s.width||200,o.height=s.height||50,i.appendChild(o),this.canvas=o,i.addEventListener("mousedown",function(e){document.addEventListener("mousemove",c),document.addEventListener("mouseup",h);var s=o.getBoundingClientRect(),d=e.clientX-s.left,m=e.clientY-s.top;if(l=function(e,t){for(var s=1e5,o=-1,a=0;a<i.value.length;a++){var l=u([e,t],n(i.value[a]));l<s&&l<8&&(s=l,o=a)}return o}(d,o.height-m),e.button==t.MOUSE_LEFT_CLICK&&-1==l&&i.allow_add_values){var g=a([d,o.height-m]);i.value.push(g),p(),l=i.value.indexOf(g)}r=[d,m],i.redraw(),e.preventDefault(),e.stopPropagation()}),i.getValueAt=function(e){if(e<i.xrange[0]||e>i.xrange[1])return i.defaulty;let t=[i.xrange[0],i.defaulty],s=0;for(let o=0;o<i.value.length;o+=1){let n=i.value[o];if(e==n[0])return n[1];if(e<n[0])return s=(e-t[0])/(n[0]-t[0]),t[1]*(1-s)+n[1]*s;t=n}let o=[i.xrange[1],i.defaulty];return s=(e-t[0])/(o[0]-t[0]),t[1]*(1-s)+o[1]*s},i.resample=function(e){let t=[],s=(i.xrange[1]-i.xrange[0])/e;for(let e=i.xrange[0];e<=i.xrange[1];e+=s)t.push(i.getValueAt(e));return t},i.addValue=function(e){for(let t=0;t<i.value;t++){if(!(i.value[t][0]<e[0]))return i.value.splice(t,0,e),void this.redraw()}i.value.push(e),this.redraw()};let l=-1;i.redraw=function(e={}){e.value&&(i.value=e.value),e.xrange&&(i.xrange=e.xrange),e.yrange&&(i.yrange=e.yrange),e.smooth&&(i.smooth=e.smooth);var s=o.getContext("2d");if(!s)return;s.setTransform(1,0,0,1,0,0),s.translate(0,o.height),s.scale(1,-1),s.fillStyle=i.bgcolor,s.fillRect(0,0,o.width,o.height),s.strokeStyle=i.linecolor,s.beginPath();var a=n([i.xrange[0],i.defaulty]);s.moveTo(a[0],a[1]);let r=[a[0],a[1]];for(var c in i.value){a=n(i.value[c]),r.push(a[0]),r.push(a[1]),i.smooth||s.lineTo(a[0],a[1])}a=n([i.xrange[1],i.defaulty]),r.push(a[0]),r.push(a[1]),i.smooth?t.drawSpline(s,r,i.smooth):(s.lineTo(a[0],a[1]),s.stroke());for(var h=0;h<i.value.length;h+=1){a=n(i.value[h]);const e=h==l;s.fillStyle=e?i.activepointscolor:i.pointscolor,s.beginPath(),s.arc(a[0],a[1],e?4:3,0,2*Math.PI),s.fill()}if(i.show_samples){var d=i.resample(i.show_samples);s.fillStyle="#888";for(h=0;h<d.length;h+=1){a=n([h*((i.xrange[1]-i.xrange[0])/i.show_samples)+i.xrange[0],d[h]]),s.beginPath(),s.arc(a[0],a[1],2,0,2*Math.PI),s.fill()}}};var r=[0,0];function c(e){var s=o.getBoundingClientRect(),n=e.clientX-s.left,c=e.clientY-s.top;n<0?n=0:n>o.width&&(n=o.width),c<0?c=0:c>o.height&&(c=o.height);const m=[e.clientX-s.left,e.clientY-s.top];if(-1!=l&&u(m,[n,c])>.5*o.height){if(i.move_out==t.CURVE_MOVEOUT_DELETE)i.value.splice(l,1);else{const e=[m[0]-n,m[1]-c];let t=i.value[l];t[0]=0==e[0]?t[0]:e[0]<0?i.xrange[0]:i.xrange[1],t[1]=0==e[1]?t[1]:e[1]<0?i.yrange[1]:i.yrange[0]}h(e)}else{var g=a([-(i.draggable_x?r[0]-n:0),i.draggable_y?r[1]-c:0]);if(-1!=l){var f=i.xrange[0],C=i.xrange[1];i.no_overlap&&(l>0&&(f=i.value[l-1][0]),l<i.value.length-1&&(C=i.value[l+1][0]));var v=i.value[l];v[0]+=g[0],v[1]+=g[1],v[0]<f?v[0]=f:[0]>C&&(v[0]=C),v[1]<i.yrange[0]?v[1]=i.yrange[0]:v[1]>i.yrange[1]&&(v[1]=i.yrange[1])}p(),i.redraw(),r[0]=n,r[1]=c,d(e),e.preventDefault(),e.stopPropagation()}}function h(e){l=-1,i.redraw(),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",h),d(e),e.preventDefault(),e.stopPropagation()}function d(e){s.callback&&s.callback.call(i,i.value,e)}function u(e,t){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function p(){var e=null;-1!=l&&(e=i.value[l]),i.value.sort(function(e,t){return e[0]-t[0]}),e&&(l=i.value.indexOf(e))}return i.redraw(),this}redraw(e={}){this.element.redraw(e)}}class L extends a{curveInstance;constructor(e,s,o,a={}){let l=JSON.parse(JSON.stringify(s));super(n.CURVE,e,l,a),this.onGetValue=()=>JSON.parse(JSON.stringify(c.element.value)),this.onSetValue=(t,s,n)=>{c.element.value=JSON.parse(JSON.stringify(t)),c.redraw(),s||this._trigger(new i(e,c.element.value,n),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${t})`};var r=document.createElement("div");r.className="lexcurve",this.root.appendChild(r),a.callback=(t,s)=>{this._trigger(new i(e,t,s),o)},a.name=e;let c=new x(s,a);r.appendChild(c.element),this.curveInstance=c;new ResizeObserver(e=>{for(const t of e)c.canvas.width=t.contentRect.width,c.redraw()}).observe(r),t.doAsync(this.onResize.bind(this))}}t.CanvasCurve=x,t.Curve=L;class S{root;day=-1;month=-1;year=-1;monthName="";firstDay=-1;daysInMonth=-1;calendarDays=[];currentDate;range;untilToday;fromToday;skipPrevMonth;skipNextMonth;onChange;onPreviousMonth;onNextMonth;constructor(e,s={}){if(this.root=t.makeContainer(["256px","auto"],"p-1 text-md"),this.onChange=s.onChange,this.onPreviousMonth=s.onPreviousMonth,this.onNextMonth=s.onNextMonth,this.untilToday=s.untilToday,this.fromToday=s.fromToday,this.range=s.range,this.skipPrevMonth=s.skipPrevMonth,this.skipNextMonth=s.skipNextMonth,e)this.fromDateString(e);else{const e=new Date;this.month=e.getMonth()+1,this.year=e.getFullYear(),this.fromMonthYear(this.month,this.year)}}_getCurrentDate(){return{day:this.day,month:this.month,year:this.year,fullDate:this.getFullDate()}}_previousMonth(e){this.month=Math.max(1,this.month-1),1==this.month&&(this.month=12,this.year--),this.fromMonthYear(this.month,this.year),!e&&this.onPreviousMonth&&this.onPreviousMonth(this.currentDate)}_nextMonth(e){this.month=Math.min(this.month+1,13),13==this.month&&(this.month=1,this.year++),this.fromMonthYear(this.month,this.year),!e&&this.onNextMonth&&this.onNextMonth(this.currentDate)}refresh(){this.root.innerHTML="";{const e=t.makeContainer(["100%","auto"],"flex flex-row p-1","",this.root);if(!this.skipPrevMonth){const s=t.makeIcon("Left",{title:"Previous Month",iconClass:"border p-1 rounded hover:bg-secondary",svgClass:"sm"});e.appendChild(s),s.addEventListener("click",()=>{this._previousMonth()})}if(t.makeContainer(["100%","auto"],"text-center font-medium select-none",`${this.monthName} ${this.year}`,e),!this.skipNextMonth){const s=t.makeIcon("Right",{title:"Next Month",iconClass:"border p-1 rounded hover:bg-secondary",svgClass:"sm"});e.appendChild(s),s.addEventListener("click",()=>{this._nextMonth()})}}{const e=document.createElement("table");e.className="w-full",this.root.appendChild(e);{const t=document.createElement("thead");e.appendChild(t);const s=document.createElement("tr");for(const e of["Mo","Tu","We","Th","Fr","Sa","Su"]){const t=document.createElement("th");t.className="fg-tertiary text-sm font-normal select-none",t.innerHTML=`<span>${e}</span>`,s.appendChild(t)}t.appendChild(s)}{const s=document.createElement("tbody");e.appendChild(s);let i=this.range?t.dateFromDateString(this.range[0]):null,o=this.range?t.dateFromDateString(this.range[1]):null;for(let e=0;e<6;e++){const t=document.createElement("tr"),n=this.calendarDays.slice(7*e,7*e+7);for(const e of n){const s=document.createElement("th");s.className="leading-loose font-normal rounded select-none cursor-pointer";const n=new Date(`${this.month}/${e.day}/${this.year}`),a=new Date,l=!this.untilToday||n.getTime()<a.getTime(),r=!this.fromToday||(n.getFullYear()>a.getFullYear()||n.getFullYear()===a.getFullYear()&&n.getMonth()>a.getMonth()||n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()>=a.getDate()),c=e.currentMonth&&l&&r,h=this.currentDate&&e.day==this.currentDate.day&&this.month==this.currentDate.month&&this.year==this.currentDate.year&&e.currentMonth,d=c&&i&&e.day==i.getDate()&&this.month==i.getMonth()+1&&this.year==i.getFullYear(),u=c&&o&&e.day==o.getDate()&&this.month==o.getMonth()+1&&this.year==o.getFullYear();!this.range&&h||this.range&&(d||u)?s.className+=" bg-contrast fg-contrast":this.range&&c&&n>i&&n<o?s.className+=" bg-accent fg-contrast":s.className+=` ${c?"fg-primary":"fg-tertiary"} hover:bg-secondary`,s.innerHTML=`<span>${e.day}</span>`,t.appendChild(s),c?s.addEventListener("click",()=>{this.day=e.day,this.currentDate=this._getCurrentDate(),this.onChange&&this.onChange(this.currentDate)}):void 0!==this.range||e.currentMonth||s.addEventListener("click",()=>{e?.prevMonth?this._previousMonth():this._nextMonth()})}s.appendChild(t)}}}}fromDateString(e){const t=e.split("/");this.day=parseInt(t[0]),this.month=parseInt(t[1]),this.monthName=this.getMonthName(this.month-1),this.year=parseInt(t[2]),this.currentDate=this._getCurrentDate(),this.fromMonthYear(this.month,this.year)}fromMonthYear(e,t){e=Math.max(e-1,0),t=t??(new Date).getFullYear();const s=new Date(t,e,1).getDay(),i=0===s?6:s-1,o=new Date(t,e+1,0).getDate(),n=new Date(0===e?t-1:t,(0===e?11:e-1)+1,0).getDate(),a=[];for(let e=i-1;e>=0;e--)a.push({day:n-e,currentMonth:!1,prevMonth:!0});for(let e=1;e<=o;e++)a.push({day:e,currentMonth:!0});const l=42-a.length;for(let e=1;e<=l;e++)a.push({day:e,currentMonth:!1,nextMonth:!0});this.monthName=this.getMonthName(e),this.firstDay=i,this.daysInMonth=o,this.calendarDays=a,this.refresh()}getMonthName(e,t="en-US"){return new Intl.DateTimeFormat(t,{month:"long"}).format(new Date(2e3,e,1))}getFullDate(e,t,s){return`${e??this.monthName} ${t??this.day}${this._getOrdinalSuffix(t??this.day)}, ${s??this.year}`}setRange(e){console.assert(e.constructor===Array,"Date Range must be in Array format"),this.range=e,this.refresh()}setMonth(e){this.month=e,this.fromMonthYear(this.month,this.year)}_getOrdinalSuffix(e){if(e>3&&e<21)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}}t.Calendar=S;class k{root;fromCalendar;toCalendar;from;to;_selectingRange=!1;constructor(e,s={}){this.root=t.makeContainer(["auto","auto"],"flex flex-row"),console.assert(e&&e.constructor===Array,"Range cannot be empty and has to be an Array!");let i=null,o=!1;{const s=t.dateFromDateString(e[0]),n=t.dateFromDateString(e[1]);if(s>n){const t=e[0];e[0]=e[1],e[1]=t,o=!0}i=(o?n.getMonth():s.getMonth())+2}this.from=e[0],this.to=e[1];const n=e=>{const t=`${e.day}/${e.month}/${e.year}`;this._selectingRange?(this.to=t,this._selectingRange=!1):(this.from=this.to=t,this._selectingRange=!0);const i=[this.from,this.to];this.fromCalendar.setRange(i),this.toCalendar.setRange(i),s.onChange&&s.onChange(i)};this.fromCalendar=new S(this.from,{skipNextMonth:!0,onChange:n,onPreviousMonth:()=>{this.toCalendar._previousMonth()},range:e}),this.toCalendar=new S(this.to,{skipPrevMonth:!0,onChange:n,onNextMonth:()=>{this.fromCalendar._nextMonth()},range:e}),console.assert(i&&"New Month must be valid"),this.toCalendar.setMonth(i),this.root.appendChild(this.fromCalendar.root),this.root.appendChild(this.toCalendar.root)}getFullDate(){const e=t.dateFromDateString(this.from),s=this.fromCalendar.getMonthName(e.getMonth()),i=t.dateFromDateString(this.to),o=this.toCalendar.getMonthName(i.getMonth());return`${this.fromCalendar.getFullDate(s,e.getDate(),e.getFullYear())} to ${this.toCalendar.getFullDate(o,i.getDate(),i.getFullYear())}`}}t.CalendarRange=k;class E extends a{calendar;_popover=void 0;constructor(e,s,o,a={}){super(n.DATE,e,null,a);const r=s?.constructor===Array;if(!r&&a.today){const e=new Date;s=`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()}`}this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{r||this.calendar.fromDateString(t),s=t,h(this.calendar.getFullDate()),n||this._trigger(new i(e,t,a),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${t})`};const c=t.makeContainer(["auto","auto"],"lexdate flex flex-row");this.root.appendChild(c),this.calendar=r?new k(s,{onChange:e=>{this.set(e)},...a}):new S(s,{onChange:e=>{const t=`${e.day}/${e.month}/${e.year}`;this.set(t)},...a});const h=e=>{const s=!!e;c.innerHTML="";const i=(e=e??"Pick a date").split(" to "),o=r?i[0]:e,n=t.makeIcon("Calendar"),a=new l(null,o,()=>{this._popover=new v(a.root,[this.calendar])},{buttonClass:`flex flex-row px-3 ${s?"":"fg-tertiary"} justify-between`});if(a.root.querySelector("button").appendChild(n),a.root.style.width="100%",c.appendChild(a.root),r){const e=t.makeIcon("ArrowRight");t.makeContainer(["32px","auto"],"content-center",e.innerHTML,c);const o=i[1],n=t.makeIcon("Calendar"),a=new l(null,o,()=>{this._popover=new v(a.root,[this.calendar])},{buttonClass:`flex flex-row px-3 ${s?"":"fg-tertiary"} justify-between`});a.root.querySelector("button").appendChild(n),a.root.style.width="100%",c.appendChild(a.root)}};s?h(this.calendar.getFullDate()):h(),t.doAsync(this.onResize.bind(this))}}t.Calendar=S,t.CalendarRange=k,t.DatePicker=E;class T{element;canvas;constructor(e,s={}){let i=document.createElement("div");i.className="dial "+(s.className?s.className:""),i.style.width=i.style.height=s.size||"100%",i.style.minWidth=i.style.minHeight="50px",i.bgcolor=s.bgColor||t.getThemeColor("global-background"),i.pointscolor=s.pointsColor||t.getThemeColor("global-color-accent-light"),i.linecolor=s.lineColor||"#555",i.value=e||[],i.xrange=s.xrange||[0,1],i.yrange=s.yrange||[0,1],i.defaulty=null!=s.defaulty?s.defaulty:0,i.no_overlap=s.noOverlap||!1,i.show_samples=s.showSamples||0,i.allow_add_values=s.allowAddValues??!0,i.draggable_x=s.draggableX??!0,i.draggable_y=s.draggableY??!0,i.smooth=(s.smooth&&"number"==typeof s.smooth?s.smooth:.3)||!1,i.move_out=s.moveOutAction??t.CURVE_MOVEOUT_DELETE,t.addSignal("@on_new_color_scheme",(e,o)=>{i.bgcolor=s.bgColor||t.getThemeColor("global-background"),i.pointscolor=s.pointsColor||t.getThemeColor("global-color-accent-light"),this.redraw()}),this.element=i;let o=document.createElement("canvas");function n(e){return[o.width*(e[0]-i.xrange[0])/i.xrange[1],o.height*(e[1]-i.yrange[0])/i.yrange[1]]}function a(e){return[e[0]*i.xrange[1]/o.width+i.xrange[0],e[1]*i.yrange[1]/o.height+i.yrange[0]]}o.width=o.height=s.size||200,i.appendChild(o),this.canvas=o,i.addEventListener("mousedown",function(e){document.addEventListener("mousemove",c),document.addEventListener("mouseup",h);var s=o.getBoundingClientRect(),d=e.clientX-s.left,m=e.clientY-s.top;if(l=function(e,t){for(var s=1e5,o=-1,a=0;a<i.value.length;a++){var l=u([e,t],n(i.value[a]));l<s&&l<8&&(s=l,o=a)}return o}(d,o.height-m),e.button==t.MOUSE_LEFT_CLICK&&-1==l&&i.allow_add_values){var g=a([d,o.height-m]);i.value.push(g),p(),l=i.value.indexOf(g)}r=[d,m],i.redraw(),e.preventDefault(),e.stopPropagation()}),i.getValueAt=function(e){if(e<i.xrange[0]||e>i.xrange[1])return i.defaulty;for(var t=[i.xrange[0],i.defaulty],s=0,o=0;o<i.value.length;o+=1){var n=i.value[o];if(e==n[0])return n[1];if(e<n[0])return s=(e-t[0])/(n[0]-t[0]),t[1]*(1-s)+n[1]*s;t=n}return n=[i.xrange[1],i.defaulty],s=(e-t[0])/(n[0]-t[0]),t[1]*(1-s)+n[1]*s},i.resample=function(e){for(var t=[],s=(i.xrange[1]-i.xrange[0])/e,o=i.xrange[0];o<=i.xrange[1];o+=s)t.push(i.getValueAt(o));return t},i.addValue=function(e){for(var t=0;t<i.value;t++){if(!(i.value[t][0]<e[0]))return i.value.splice(t,0,e),void this.redraw()}i.value.push(e),this.redraw()};var l=-1;i.redraw=function(e={}){e.value&&(i.value=e.value),e.xrange&&(i.xrange=e.xrange),e.yrange&&(i.yrange=e.yrange),e.smooth&&(i.smooth=e.smooth);var t=o.getContext("2d");if(!t)return;t.setTransform(1,0,0,1,0,0),t.translate(0,o.height),t.scale(1,-1),t.fillStyle=i.bgcolor,t.fillRect(0,0,o.width,o.height),t.strokeStyle=i.linecolor,t.beginPath();var s=n([i.xrange[0],i.defaulty]);t.moveTo(s[0],s[1]);let a=[s[0],s[1]];for(var r in i.value){s=n(i.value[r]),a.push(s[0]),a.push(s[1])}s=n([i.xrange[1],i.defaulty]),a.push(s[0]),a.push(s[1]);s=n([0,0]),t.fillStyle="gray",t.beginPath(),t.arc(s[0],s[1],3,0,2*Math.PI),t.fill();for(var c=0;c<i.value.length;c+=1){s=n(i.value[c]);const e=c==l;t.fillStyle=e?"white":i.pointscolor,t.beginPath(),t.arc(s[0],s[1],e?4:3,0,2*Math.PI),t.fill()}if(i.show_samples){var h=i.resample(i.show_samples);t.fillStyle="#888";for(c=0;c<h.length;c+=1){s=n([c*((i.xrange[1]-i.xrange[0])/i.show_samples)+i.xrange[0],h[c]]),t.beginPath(),t.arc(s[0],s[1],2,0,2*Math.PI),t.fill()}}};var r=[0,0];function c(e){var s=o.getBoundingClientRect(),n=e.clientX-s.left,c=e.clientY-s.top;n<0?n=0:n>o.width&&(n=o.width),c<0?c=0:c>o.height&&(c=o.height);const m=[e.clientX-s.left,e.clientY-s.top];if(-1!=l&&u(m,[n,c])>.5*o.height){if(i.move_out==t.CURVE_MOVEOUT_DELETE)i.value.splice(l,1);else{const e=[m[0]-n,m[1]-c];let t=i.value[l];t[0]=0==e[0]?t[0]:e[0]<0?i.xrange[0]:i.xrange[1],t[1]=0==e[1]?t[1]:e[1]<0?i.yrange[1]:i.yrange[0]}h(e)}else{var g=a([-(i.draggable_x?r[0]-n:0),i.draggable_y?r[1]-c:0]);if(-1!=l){var f=i.xrange[0],C=i.xrange[1];i.no_overlap&&(l>0&&(f=i.value[l-1][0]),l<i.value.length-1&&(C=i.value[l+1][0]));var v=i.value[l];v[0]+=g[0],v[1]+=g[1],v[0]<f?v[0]=f:v[0]>C&&(v[0]=C),v[1]<i.yrange[0]?v[1]=i.yrange[0]:v[1]>i.yrange[1]&&(v[1]=i.yrange[1])}p(),i.redraw(),r[0]=n,r[1]=c,d(e),e.preventDefault(),e.stopPropagation()}}function h(e){l=-1,i.redraw(),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",h),d(e),e.preventDefault(),e.stopPropagation()}function d(e){s.callback&&s.callback.call(i,i.value,e)}function u(e,t){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function p(){var e=null;-1!=l&&(e=i.value[l]),i.value.sort(function(e,t){return e[0]-t[0]}),e&&(l=i.value.indexOf(e))}return i.redraw(),this}redraw(e={}){this.element.redraw(e)}}t.CanvasDial=T;class w extends a{dialInstance;constructor(e,s,o,a={}){let l=JSON.parse(JSON.stringify(s));super(n.DIAL,e,l,a),this.onGetValue=()=>JSON.parse(JSON.stringify(c.element.value)),this.onSetValue=(t,s,n)=>{c.element.value=JSON.parse(JSON.stringify(t)),c.redraw(),s||this._trigger(new i(e,c.element.value,n),o)},this.onResize=e=>{const s=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${s})`,t.flushCss(r),c.element.style.height=c.element.offsetWidth+"px",c.canvas.width=c.element.offsetWidth,r.style.width=c.element.offsetWidth+"px",c.canvas.height=c.canvas.width,c.redraw()};var r=document.createElement("div");r.className="lexcurve",this.root.appendChild(r),a.callback=(t,s)=>{this._trigger(new i(e,t,s),o)},a.name=e;let c=new T(s,a);r.appendChild(c.element),this.dialInstance=c,t.doAsync(this.onResize.bind(this))}}t.CanvasDial=T,t.Dial=w;class M extends a{constructor(e,s,i={}){super(n.FILE,e,null,i);let o=i.local??!0,a=i.type??"text",r=i.read??!0;this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${t})`};let c=document.createElement("input");if(c.className="lexfileinput",c.type="file",c.disabled=i.disabled??!1,this.root.appendChild(c),i.placeholder&&(c.placeholder=i.placeholder),c.addEventListener("change",function(e){const t=e.target.files;if(t.length)if(r){i.onBeforeRead&&i.onBeforeRead();const e=new FileReader;"text"===a?e.readAsText(t[0]):"buffer"===a?e.readAsArrayBuffer(t[0]):"bin"===a?e.readAsBinaryString(t[0]):"url"===a&&e.readAsDataURL(t[0]),e.onload=e=>{s.call(this,e.target?.result,t[0])}}else s(t[0])}),c.addEventListener("cancel",function(e){s(null)}),o){let e=null;const s=new l(null,"",()=>{e||(e=new t.Dialog("Load Settings",e=>{e.addSelect("Type",["text","buffer","bin","url"],a,e=>{a=e}),e.addButton(null,"Reload",()=>{c.dispatchEvent(new Event("change"))})},{onclose:t=>{t.remove(),e=null}}))},{skipInlineCount:!0,title:"Settings",disabled:i.disabled,icon:"Settings"});this.root.appendChild(s.root)}t.doAsync(this.onResize.bind(this))}}t.FileInput=M;class A extends a{constructor(e,s,i,o={}){if(s.constructor!=Object)return void console.error("Form data must be an Object");o.hideName=!0,super(n.FORM,e,null,o),this.onGetValue=()=>r.formData,this.onSetValue=(e,t,s)=>{r.formData=e;const i=r.querySelectorAll(".lexcomponent");for(let s=0;s<i.length;++s){if(i[s].jsInstance.type!=n.TEXT)continue;let o=i[s].querySelector(".lexcomponentname").innerText,l=i[s].querySelector(".lextext input");l.value=e[o]??"",a._dispatchEvent(l,"focusout",t)}};let r=document.createElement("div");r.className="lexformdata",r.style.width="100%",r.formData={},this.root.appendChild(r);for(let e in s){let i=s[e];if(i.constructor!=Object){const o=t.deepCopy(i);i={value:o},s[e]=i}if(i.width="100%",i.placeholder=i.placeholder??i.label??`Enter ${e}`,i.ignoreValidation=!0,!o.skipLabels){const t=new d(null,i.label??e,null,{disabled:!0,inputClass:"formlabel bg-none"});r.appendChild(t.root)}i.textComponent=new d(null,i.constructor==Object?i.value:i,(t,s)=>{r.formData[e]=t,i.submit&&s.constructor===KeyboardEvent&&h?.click()},i),r.appendChild(i.textComponent.root),r.formData[e]=i.constructor==Object?i.value:i}const c=t.makeContainer(["100%","auto"],"flex flex-row mt-2","",r);if(o.secondaryActionName||o.secondaryActionCallback){const e=new l(null,o.secondaryActionName??"Cancel",(e,t)=>{o.secondaryActionCallback&&o.secondaryActionCallback(r.formData,t)},{width:"100%",minWidth:"0",buttonClass:o.secondaryButtonClass??"primary"});c.appendChild(e.root)}const h=new l(null,o.primaryActionName??"Submit",(e,o)=>{const n=[];for(let e in s){let i=s[e];const o=i.pattern,a=o?.fieldMatchName?r.formData[o.fieldMatchName]:void 0;if(!i.textComponent.valid(void 0,a)){const s={entry:e,type:"input_not_valid",messages:[]};o&&(s.messages=t.validateValueAtPattern(r.formData[e],o,a)),n.push(s)}}i&&i(r.formData,n,o)},{width:"100%",minWidth:"0",buttonClass:o.primaryButtonClass??"contrast"});c.appendChild(h.root)}}t.Form=A;class N extends a{setLayers;constructor(e,s,o,a={}){super(n.LAYERS,e,s,a),this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{s=t,this.setLayers(s),n||this._trigger(new i(e,s,a),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};const l=document.createElement("div");l.className="lexlayers",this.root.appendChild(l);const r=a.maxBits??16;this.setLayers=e=>{l.innerHTML="";let t=e.toString(2),s=t.length;for(let e=0;e<r-s;++e)t="0"+t;for(let s=0;s<r;++s){let i=document.createElement("div");if(i.className="lexlayer",null!=e){const e=t[r-s-1];null!=e&&"1"==e&&i.classList.add("selected")}i.innerText=s+1,i.title="Bit "+s+", value "+(1<<s),l.appendChild(i),i.addEventListener("click",t=>{t.stopPropagation(),t.stopImmediatePropagation(),t.target.classList.toggle("selected");const i=e^1<<s;this.set(i,!1,t)})}},this.setLayers(s),t.doAsync(this.onResize.bind(this))}}t.Layers=N;class P extends a{_updateValues;constructor(e,s,o,a,l={}){super(n.LIST,e,o,l),this.onGetValue=()=>o,this.onSetValue=(t,n,l)=>{r.querySelectorAll(".lexlistitem").forEach(e=>e.classList.remove("selected"));let c=null;for(let e=0;e<s.length;++e){const i=s[e];if(i==t||i.constructor==Array&&i[0]==t){c=e;break}}c?(r.children[c].classList.toggle("selected"),o=t,n||this._trigger(new i(e,t,l),a)):console.error(`Cannot find item ${t} in List.`)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${t})`},this._updateValues=n=>{s=n,r.innerHTML="";for(let n=0;n<s.length;++n){let l=null,c=s[n];c.constructor===Array&&(l=c[1],c=c[0]);let h=document.createElement("div");h.className="lexlistitem"+(o==c?" selected":""),l&&h.appendChild(t.makeIcon(l)),h.innerHTML+=`<span>${c}</span>`,h.addEventListener("click",t=>{r.querySelectorAll(".lexlistitem").forEach(e=>e.classList.remove("selected")),h.classList.toggle("selected"),o=c,this._trigger(new i(e,c,t),a)}),r.appendChild(h)}};let r=document.createElement("div");r.className="lexlist",this.root.appendChild(r),this._updateValues(s),t.doAsync(this.onResize.bind(this))}}t.List=P;let O=class e{x;y;constructor(e,t){this.x=e??0,this.y=t??e??0}get xy(){return[this.x,this.y]}get yx(){return[this.y,this.x]}set(e,t){this.x=e,this.y=t}add(t,s=new e){return s.set(this.x+t.x,this.y+t.y),s}sub(t,s=new e){return s.set(this.x-t.x,this.y-t.y),s}mul(t,s=new e){return t.constructor==Number&&(t=new e(t)),s.set(this.x*t.x,this.y*t.y),s}div(t,s=new e){return t.constructor==Number&&(t=new e(t)),s.set(this.x/t.x,this.y/t.y),s}abs(t=new e){return t.set(Math.abs(this.x),Math.abs(this.y)),t}dot(e){return this.x*e.x+this.y*e.y}len2(){return this.dot(this)}len(){return Math.sqrt(this.len2())}nrm(t=new e){return t.set(this.x,this.y),t.mul(1/this.len(),t)}dst(e){return e.sub(this).len()}clp(s,i,o=new e){return o.set(t.clamp(this.x,s,i),t.clamp(this.y,s,i)),o}fromArray(e){this.x=e[0],this.y=e[1]}toArray(){return this.xy}};t.vec2=O;class I{static COLORS=[[255,0,0],[0,255,0],[0,0,255],[0,128,128],[128,0,128],[128,128,0],[255,128,0],[255,0,128],[0,128,255],[128,0,255]];static GRID_SIZE=64;canvas;imageCanvas=null;root;circular;showNames;size;points;callback;weights=[];weightsObj={};currentPosition=new O(0,0);circleCenter=[0,0];circleRadius=1;margin=8;dragging=!1;_valuesChanged=!0;_selectedPoint=null;_precomputedWeightsGridSize=0;_precomputedWeights=null;constructor(e,s,i={}){this.circular=i.circular??!1,this.showNames=i.showNames??!0,this.size=i.size??[200,200],this.points=e??[],this.callback=s,this._valuesChanged=!0,this._selectedPoint=null,this.root=t.makeContainer(["auto","auto"]),this.root.tabIndex="1",this.root.addEventListener("mousedown",function(e){var t=o.root.ownerDocument;return t.addEventListener("mouseup",a),t.addEventListener("mousemove",n),e.stopPropagation(),e.preventDefault(),o.dragging=!0,!0});const o=this;function n(e){if(!o.dragging)return;const s=o.margin,i=o.root.getBoundingClientRect();let n=new O;n.set(e.x-i.x-.5*o.size[0],e.y-i.y-.5*o.size[1]);var a=o.currentPosition;if(a.set(t.clamp(n.x/(.5*o.size[0]-s),-1,1),t.clamp(n.y/(.5*o.size[1]-s),-1,1)),o.circular){const e=new O(0,0);a.dst(e)>1&&(a=a.nrm())}return o.renderToCanvas(o.canvas.getContext("2d",{willReadFrequently:!0})),o.computeWeights(a),o.callback&&o.callback(o.weightsObj,o.weights,a),!0}function a(e){o.dragging=!1;var t=o.root.ownerDocument;t.removeEventListener("mouseup",a),t.removeEventListener("mousemove",n)}this.canvas=document.createElement("canvas"),this.canvas.width=this.size[0],this.canvas.height=this.size[1],this.root.appendChild(this.canvas);const l=this.canvas.getContext("2d",{willReadFrequently:!0});this.renderToCanvas(l)}computeWeights(e){if(!this.points.length)return;let t=this._precomputedWeights;t&&!this._valuesChanged||(t=this.precomputeWeights());let s=this.weights;s.length=this.points.length;for(var i=0;i<s.length;++i)s[i]=0;const o=I.GRID_SIZE;let n=0,a=new O;for(var l=0;l<o;++l)for(var r=0;r<o;++r){a.set(r/o*2-1,l/o*2-1);var c=2*r+l*o*2,h=t[c];e.dst(a)<t[c+1]+.001&&(s[h]+=1,n++)}for(i=0;i<s.length;++i)s[i]/=n,this.weightsObj[this.points[i].name]=s[i];return s}precomputeWeights(){this._valuesChanged=!1;const e=this.points.length,t=I.GRID_SIZE,s=2*t*t;let i=new O;this._precomputedWeights&&this._precomputedWeights.length==s||(this._precomputedWeights=new Float32Array(s));let o=this._precomputedWeights;this._precomputedWeightsGridSize=t;for(let s=0;s<t;++s)for(let n=0;n<t;++n){let a=-1,l=1e5;for(let o=0;o<e;++o){i.set(n/t*2-1,s/t*2-1);let e=new O;e.fromArray(this.points[o].pos);let r=i.dst(e);r>l||(a=o,l=r)}o[2*n+2*s*t]=a,o[2*n+2*s*t+1]=l}return o}precomputeWeightsToImage(e){if(!this.points.length)return null;const t=I.GRID_SIZE;var s=this._precomputedWeights;s&&!this._valuesChanged&&this._precomputedWeightsGridSize==t||(s=this.precomputeWeights());var i=this.imageCanvas;i||(i=this.imageCanvas=document.createElement("canvas")),i.width=i.height=t;var o=i.getContext("2d",{willReadFrequently:!0});if(!o)return;var n=this.weights;n.length=this.points.length;for(var a=0;a<n.length;++a)n[a]=0;let l=0,r=o.getImageData(0,0,t,t),c=new O;for(var h=0;h<t;++h)for(var d=0;d<t;++d){c.set(d/t*2-1,h/t*2-1);const i=4*d+h*t*4,o=2*d+h*t*2,a=s[o],p=I.COLORS[a%I.COLORS.length];var u=e.dst(c)<s[o+1]+.001;u&&(n[a]+=1,l++),r.data[i]=p[0]+(u?128:0),r.data[i+1]=p[1]+(u?128:0),r.data[i+2]=p[2]+(u?128:0),r.data[i+3]=255}for(let e=0;e<n.length;++e)n[e]/=l;return o.putImageData(r,0,0),i}addPoint(e,s=null){if(this.findPoint(e))return void console.warn("CanvasMap2D.addPoint: There is already a point with that name");s||(s=[this.currentPosition.x,this.currentPosition.y]),s[0]=t.clamp(s[0],-1,1),s[1]=t.clamp(s[1],-1,1);const i={name:e,pos:s};return this.points.push(i),this._valuesChanged=!0,i}removePoint(e){const t=this.points.findIndex(t=>t.name==e);t>-1&&(this.points.splice(t,1),this._valuesChanged=!0)}findPoint(e){return this.points.find(t=>t.name==e)}clear(){this.points.length=0,this._precomputedWeights=null,this._selectedPoint=null}renderToCanvas(e){if(!e)return;const s=this.margin,i=this.size[0],o=this.size[1];e.fillStyle="black",e.strokeStyle="#BBB",e.clearRect(0,0,i,o),this.circular?(this.circleCenter[0]=.5*i,this.circleCenter[1]=.5*o,this.circleRadius=.5*o-s,e.lineWidth=1,e.beginPath(),e.arc(this.circleCenter[0],this.circleCenter[1],this.circleRadius,0,2*Math.PI),e.fill(),e.stroke(),e.beginPath(),e.moveTo(this.circleCenter[0]+.5,this.circleCenter[1]-this.circleRadius),e.lineTo(this.circleCenter[0]+.5,this.circleCenter[1]+this.circleRadius),e.moveTo(this.circleCenter[0]-this.circleRadius,this.circleCenter[1]),e.lineTo(this.circleCenter[0]+this.circleRadius,this.circleCenter[1]),e.stroke()):(e.fillRect(s,s,i-2*s,o-2*s),e.strokeRect(s,s,i-2*s,o-2*s));var n=this.precomputeWeightsToImage(this.currentPosition);n&&(e.globalAlpha=.5,e.imageSmoothingEnabled=!1,this.circular?(e.save(),e.beginPath(),e.arc(this.circleCenter[0],this.circleCenter[1],this.circleRadius,0,2*Math.PI),e.clip(),e.drawImage(n,this.circleCenter[0]-this.circleRadius,this.circleCenter[1]-this.circleRadius,2*this.circleRadius,2*this.circleRadius),e.restore()):e.drawImage(n,s,s,i-2*s,o-2*s),e.imageSmoothingEnabled=!0,e.globalAlpha=1);for(let n=0;n<this.points.length;++n){const a=this.points[n];let l=.5*a.pos[0]+.5,r=.5*a.pos[1]+.5;l=l*(i-2*s)+s,r=r*(o-2*s)+s,l=t.clamp(l,s,i-s),r=t.clamp(r,s,o-s),e.fillStyle=a==this._selectedPoint?"#CDF":"#BCD",e.beginPath(),e.arc(l,r,3,0,2*Math.PI),e.fill(),this.showNames&&e.fillText(a.name,l+5,r+5)}e.fillStyle="white",e.beginPath();var a=.5*this.currentPosition.x+.5,l=.5*this.currentPosition.y+.5;a=a*(i-2*s)+s,l=l*(o-2*s)+s,a=t.clamp(a,s,i-s),l=t.clamp(l,s,o-s),e.arc(a,l,4,0,2*Math.PI),e.fill()}}t.CanvasMap2D=I;class R extends a{map2d;_popover=null;constructor(e,s,i,o={}){super(n.MAP2D,e,null,o),this.onGetValue=()=>this.map2d.weightsObj,this.onSetValue=(e,t,s)=>{},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=`calc( 100% - ${t})`};var a=document.createElement("div");a.className="lexmap2d",this.root.appendChild(a),this.map2d=new I(s,i,o);const r=t.makeIcon("SquareMousePointer"),c=new l(null,"Open Map",()=>{this._popover=new v(c.root,[this.map2d])},{buttonClass:"flex flex-row px-3 fg-secondary justify-between"});c.root.querySelector("button").appendChild(r),a.appendChild(c.root),t.doAsync(this.onResize.bind(this))}}t.Map2D=R;class D{domEl;data;onevent;options;selected=[];_forceClose=!1;constructor(e,t,s={}){if(this.domEl=e,this.data=t,this.onevent=s.onevent,this.options=s,t.constructor===Object)this._createItem(null,t);else for(let e of t)this._createItem(null,e)}_createItem(e,s,i=0,n){const a=this,r=this.domEl.querySelector(".lexnodetreefilter");if(s.children=s.children??[],r&&""!=r.value&&!s.id.includes(r.value)){for(var c=0;c<s.children.length;++c)this._createItem(s,s.children[c],i+1,n);return}const h=this.domEl.querySelector("ul");s.visible=s.visible??!0,s.parent=e;let d=s.children.length>0,u=this.selected.indexOf(s)>-1||s.selected;if(this.options.onlyFolders){let e=!1;s.children.forEach(t=>{e=e||"folder"==t.type}),d=!!e}let p=document.createElement("li");p.className="lextreeitem datalevel"+i+(d?" parent":"")+(u?" selected":""),p.id=t.getSupportedDOMName(s.id),p.tabIndex="0",p.treeData=s;let m=this.options.skipDefaultIcon??1?null:"Dot";if(d&&(m=s.closed?"Right":"Down"),m&&p.appendChild(t.makeIcon(m,{iconClass:"hierarchy",svgClass:"xs"})),m=s.icon,m)if(s.icon.includes(".")){const e="https://raw.githubusercontent.com/jxarco/lexgui.js/master/";p.innerHTML+="<img src='"+(e+s.icon)+"'>"}else{const e=s.icon.split(" "),i=t.makeIcon(e[0],{iconClass:"tree-item-icon mr-2",svgClass:"md"+(e.length>1?` ${e.slice(0).join(" ")}`:"")});p.appendChild(i)}p.innerHTML+=s.rename?"":s.id,p.setAttribute("draggable",!0),p.style.paddingLeft=3+15*(i+1)+"px",h.appendChild(p),p.addEventListener("click",e=>{if(f)return void(f=!1);e.shiftKey||(h.querySelectorAll("li").forEach(e=>{e.classList.remove("selected")}),this.selected.length=0);const t=this.selected.indexOf(s);if(t>-1?(p.classList.remove("selected"),this.selected.splice(t,1)):(p.classList.add("selected"),this.selected.push(s)),d&&s.id.length>1){if(s.closed=!1,a.onevent){const t=new o(o.NODE_CARETCHANGED,s,s.closed,e);a.onevent(t)}a.frefresh(s.id)}if(a.onevent){const t=new o(o.NODE_SELECTED,s,this.selected,e);t.multiple=e.shiftKey,a.onevent(t)}}),p.addEventListener("dblclick",function(e){if((a.options.rename??1)&&(s.rename=!0,a.refresh()),a.onevent){const t=new o(o.NODE_DBLCLICKED,s,null,e);a.onevent(t)}}),p.addEventListener("contextmenu",e=>{if(e.preventDefault(),!a.onevent)return;const i=new o(o.NODE_CONTEXTMENU,s,this.selected,e);i.multiple=this.selected.length>1,t.addContextMenu(i.multiple?"Selected Nodes":i.node.id,i.event,e=>{i.panel=e}),a.onevent(i),this.options.addDefault&&(i.panel.items&&i.panel.add(""),i.panel.add("Select Children",()=>{const e=t=>{if(!t.closed)for(let s of t.children??[]){if(!s)continue;this.domEl.querySelector("#"+s.id).classList.add("selected"),this.selected.push(s),e(s)}};this.domEl.querySelectorAll(".selected").forEach(e=>e.classList.remove("selected")),this.selected.length=0,e(s)}),i.panel.add("Delete",{callback:()=>{if(a.deleteNode(s)&&a.onevent){const e=new o(o.NODE_DELETED,s,[s],null);a.onevent(e)}this.refresh()}}))}),p.addEventListener("keydown",e=>{if(!s.rename)if(e.preventDefault(),"Delete"==e.key){const t=[];for(let e of this.selected)a.deleteNode(e)&&t.push(e);if(t.length&&a.onevent){const i=new o(o.NODE_DELETED,s,t,e);i.multiple=t.length>1,a.onevent(i)}this.selected.length=0,this.refresh()}else if("ArrowUp"==e.key||"ArrowDown"==e.key){var i=this.selected.length>1?"ArrowUp"==e.key?this.selected.shift():this.selected.pop():this.selected[0],n=this.domEl.querySelector("#"+t.getSupportedDOMName(i.id)),l="ArrowUp"==e.key?n.previousSibling:n.nextSibling;l&&l.click()}});const g=document.createElement("input");g.toggleAttribute("hidden",!s.rename),g.className="bg-none",g.value=s.id,p.appendChild(g),s.rename&&(p.classList.add("selected"),g.focus()),g.addEventListener("keyup",function(e){if("Enter"==e.key){if(this.value=this.value.replace(/\s/g,"_"),a.onevent){const t=new o(o.NODE_RENAMED,s,this.value,e);a.onevent(t)}s.id=t.getSupportedDOMName(this.value),delete s.rename,a.frefresh(s.id),h.querySelector("#"+s.id).classList.add("selected")}else"Escape"==e.key&&(delete s.rename,a.frefresh(s.id))}),g.addEventListener("blur",function(e){delete s.rename,a.refresh()}),(this.options.draggable??1)&&(e&&p.addEventListener("dragstart",e=>{window.__tree_node_dragged=s}),p.addEventListener("dragover",e=>{e.preventDefault()},!1),p.addEventListener("dragenter",e=>{e.target.classList.add("draggingover")}),p.addEventListener("dragend",e=>{e.target.classList.remove("draggingover")}),p.addEventListener("dragleave",e=>{e.target.classList.remove("draggingover")}),p.addEventListener("drop",e=>{e.preventDefault();let t=window.__tree_node_dragged;if(!t)return t=window.__av_item_dragged,void(t&&(t._nodeTarget=s));let i=s;if(t.id==i.id)return void console.warn("Cannot parent node to itself!");const n=function(e,t){var s=!1;for(var i of t.children){if(i.id==e.id)return!0;s=s||n(e,i)}return s};if(n(i,t))return void console.warn("Cannot parent node to a current child!");if(a.onevent){const s=new o(o.NODE_DRAGGED,t,i,e);a.onevent(s)}const l=t.parent.children.findIndex(e=>e.id==t.id),r=t.parent.children.splice(l,1);i.children.push(r[0]),a.refresh(),delete window.__tree_node_dragged}));let f=!1;d&&p.querySelector("a.hierarchy").addEventListener("click",function(e){if(f=!0,e.stopImmediatePropagation(),e.stopPropagation(),e.altKey){const e=function(t){for(var s of(t.closed=!t.closed,t.children))e(s)};e(s)}else s.closed=!s.closed;if(a.onevent){const t=new o(o.NODE_CARETCHANGED,s,s.closed,e);a.onevent(t)}a.frefresh(s.id)});const C=document.createElement("div");if(p.appendChild(C),s.actions)for(let e=0;e<s.actions.length;++e){const t=s.actions[e],i=new l(null,"",(e,i)=>{i.stopPropagation(),t.callback&&t.callback(s,e,i)},{icon:t.icon,swap:t.swap,title:t.name,hideName:!0,className:"p-0 m-0",buttonClass:"p-0 m-0 bg-none no-h"});i.root.style.minWidth="fit-content",i.root.style.margin="0",i.root.style.padding="0";const o=i.root.querySelector("button");o.style.minWidth="fit-content",o.style.margin="0",o.style.padding="0",C.appendChild(i.root)}if(!s.skipVisibility){const e=new l(null,"",(e,t)=>{if(t.stopPropagation(),s.visible=void 0!==s.visible&&!s.visible,a.onevent){const e=new o(o.NODE_VISIBILITY,s,s.visible,t);a.onevent(e)}},{icon:s.visible?"Eye":"EyeOff",swap:s.visible?"EyeOff":"Eye",title:"Toggle visible",className:"p-0 m-0",buttonClass:"bg-none"});C.appendChild(e.root)}const v=function(e,t){if(e.id==t)return!0;let s=!1;for(var i of e?.children??[])s=s||v(i,t);return s},y=v(s,n);if(!s.closed||y)for(c=0;c<s.children.length;++c){let e=s.children[c];this.options.onlyFolders&&"folder"!=e.type||this._createItem(s,e,i+1,n)}}refresh(e,t){if(this.data=e??this.data,this.domEl.querySelector("ul").innerHTML="",this.data.constructor===Object)this._createItem(null,this.data,0,t);else for(let e of this.data)this._createItem(null,e,0,t)}frefresh(e){this.refresh();var t=this.domEl.querySelector(`#${e}`);t&&t.focus()}select(e){const t=this.domEl.querySelector(".lexnodetreefilter");if(t&&(t.value=""),this.refresh(null,e),this.domEl.querySelectorAll(".selected").forEach(e=>e.classList.remove("selected")),!e)return void(this.selected.length=0);const s=this.domEl.querySelector("#"+e);console.assert(s,"NodeTree: Can't select node "+e),s.classList.add("selected"),this.selected=[s.treeData],s.focus()}deleteNode(e){const t=this.data.constructor===Array;if(e.parent){let t=e.parent.children;const s=t.indexOf(e);t.splice(s,1)}else{if(!t)return console.warn("NodeTree: Can't delete root node from object data!"),!1;{const t=this.data.indexOf(e);console.assert(t>-1,"NodeTree: Can't delete root node "+e.id+" from data array!"),this.data.splice(t,1)}}return!0}}t.NodeTree=D;class z extends a{innerTree;constructor(e,s,i={}){i.hideName=!0,super(n.TREE,e,null,i);let o=document.createElement("div");if(o.className="lextree",this.root.appendChild(o),e){let t=document.createElement("span");t.innerHTML=e,o.appendChild(t)}let a=document.createElement("div");if(a.className="lextreetools",e||(a.className+=" notitle"),i.icons)for(let e of i.icons){const s=t.makeIcon(e.icon,{title:e.name});s.addEventListener("click",e.callback),a.appendChild(s)}i.filter=i.filter??!0;let l=null;if(i.filter){l=document.createElement("input"),l.className="lexnodetreefilter",l.setAttribute("placeholder","Filter.."),l.style.width="100%",l.addEventListener("input",()=>{this.innerTree.refresh()});let e=t.makeIcon("Search");a.appendChild(l),a.appendChild(e)}(i.icons||i.filter)&&o.appendChild(a);let r=document.createElement("ul");r.addEventListener("contextmenu",function(e){e.preventDefault()}),o.appendChild(r),this.innerTree=new D(o,s,i)}}t.Tree=z;class B extends a{constructor(e,s,o,a={}){const l=a.pattern??"xxx-xxx",r=(l.match(/x/g)||[]).length;(s=String(s)).length||(s="x".repeat(r)),super(n.OTP,e,s,a),this.onGetValue=()=>+s,this.onSetValue=(t,n,a)=>{d(s=t),n||this._trigger(new i(e,+t,a),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${t})`},this.disabled=a.disabled??!1;const c=document.createElement("div");c.className="lexotp flex flex-row items-center",this.root.appendChild(c);const h=l.split("-"),d=e=>{c.innerHTML="";let s=0,i=0;for(let o=0;o<h.length;++o){const n=h[o];for(let o=0;o<n.length;++o){let a=e[s++];a="x"==a?"":a;const l=t.makeContainer(["36px","30px"],"lexotpslot border-top border-bottom border-left px-3 cursor-text select-none font-medium outline-none",a,c);l.tabIndex="1",this.disabled&&l.classList.add("disabled");const r=s;0==o?l.className+=" rounded-l":o==n.length-1&&(l.className+=" rounded-r border-right"),l.addEventListener("click",()=>{if(this.disabled)return;c.querySelectorAll(".lexotpslot").forEach(e=>e.classList.remove("active"));const e=c.querySelectorAll(".lexotpslot")[i];e.classList.add("active"),e.focus()}),l.addEventListener("blur",()=>{this.disabled||t.doAsync(()=>{c.contains(document.activeElement)||c.querySelectorAll(".lexotpslot").forEach(e=>e.classList.remove("active"))},10)}),l.addEventListener("keyup",t=>{if(!this.disabled)if(/[^0-9]+/g.test(t.key))if("ArrowLeft"==t.key||"ArrowRight"==t.key){const e="ArrowLeft"==t.key?-1:1,s=c.querySelectorAll(".lexotpslot")[i+e];s&&(c.querySelectorAll(".lexotpslot")[i].classList.remove("active"),s.classList.add("active"),s.focus(),i+=e)}else"Enter"!=t.key||e.includes("x")||this.set(e);else{const s=t.key;console.assert(!Number.isNaN(parseInt(s))),l.innerHTML=s,e=e.substring(0,r-1)+s+e.substring(r);const o=c.querySelectorAll(".lexotpslot")[i+1];o?(c.querySelectorAll(".lexotpslot")[i].classList.remove("active"),o.classList.add("active"),o.focus(),i++):this.set(e)}})}o<h.length-1&&t.makeContainer(["auto","auto"],"mx-2","-",c)}console.assert(s==e.length,"OTP Value/Pattern Mismatch!")};d(s)}}t.OTPInput=B;class H extends a{constructor(e,s,o,a={}){super(n.PAD,e,null,a),this.onGetValue=()=>c.value.xy,this.onSetValue=(t,s,n)=>{c.value.set(t[0],t[1]),h(c.value),s||this._trigger(new i(e,c.value.xy,n),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};var l=document.createElement("div");l.className="lexpad",this.root.appendChild(l);let r=document.createElement("div");r.id="lexpad-"+e,r.className="lexinnerpad",r.style.width=a.padSize??"96px",r.style.height=a.padSize??"96px",l.appendChild(r);let c=document.createElement("div");c.className="lexpadthumb",c.value=new O(s[0],s[1]),c.min=a.min??0,c.max=a.max??1,r.appendChild(c);let h=e=>{const[s,i]=[r.offsetWidth,r.offsetHeight],o=new O(t.remapRange(e.x,c.min,c.max,0,1),t.remapRange(e.y,c.min,c.max,0,1));c.style.transform=`translate(calc( ${s*o.x}px - 50% ), calc( ${i*o.y}px - 50%)`};r.addEventListener("mousedown",function(e){if(document.activeElement==c)return;var t=d.root.ownerDocument;t.addEventListener("mousemove",u),t.addEventListener("mouseup",p),document.body.classList.add("nocursor"),document.body.classList.add("noevents"),e.stopImmediatePropagation(),e.stopPropagation(),c.classList.add("active"),a.onPress&&a.onPress.bind(c)(e,c)});let d=this;function u(s){const n=r.getBoundingClientRect(),a=new O(s.x-n.x,s.y-n.y);a.clp(0,r.offsetWidth,a);const[l,h]=[r.offsetWidth,r.offsetHeight],u=a.div(new O(r.offsetWidth,r.offsetHeight));c.style.transform=`translate(calc( ${l*u.x}px - 50% ), calc( ${h*u.y}px - 50%)`,c.value=new O(t.remapRange(u.x,0,1,c.min,c.max),t.remapRange(u.y,0,1,c.min,c.max)),d._trigger(new i(e,c.value.xy,s),o),s.stopPropagation(),s.preventDefault()}function p(e){var t=d.root.ownerDocument;t.removeEventListener("mousemove",u),t.removeEventListener("mouseup",p),document.body.classList.remove("nocursor"),document.body.classList.remove("noevents"),c.classList.remove("active"),a.onRelease&&a.onRelease.bind(c)(e,c)}t.doAsync(()=>{this.onResize(),h(c.value)})}}t.Pad=H;class F extends a{constructor(e,s,o={}){super(n.PROGRESS,e,s,o),this.onGetValue=()=>l.value,this.onSetValue=(s,n,a)=>{s=t.clamp(s,l.min,l.max),this.root.querySelector("meter").value=s,r(),this.root.querySelector("span")&&(this.root.querySelector("span").innerText=s),n||this._trigger(new i(e,s,a),o.callback)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=`calc( 100% - ${t})`};const a=document.createElement("div");a.className="lexprogress",this.root.appendChild(a);let l=document.createElement("meter");l.id="lexprogressbar-"+e,l.className="lexprogressbar",l.step="any",l.min=o.min??0,l.max=o.max??1,l.low=o.low??l.low,l.high=o.high??l.high,l.optimum=o.optimum??l.optimum,l.value=s,a.appendChild(l);const r=()=>{let e=t.getThemeColor("global-selected");null!=l.low&&l.value<l.low?e=t.getThemeColor("global-color-error"):null!=l.high&&l.value<l.high&&(e=t.getThemeColor("global-color-warning")),l.style.background=`color-mix(in srgb, ${e} 20%, transparent)`};if(o.showValue){const t=document.getElementById("progressvalue-"+e);t&&t.remove();let i=document.createElement("span");i.id="progressvalue-"+e,i.style.padding="0px 5px",i.innerText=s,a.appendChild(i)}if(o.editable){l.classList.add("editable");let e=e=>{var o=this.root.ownerDocument;o.addEventListener("mousemove",s),o.addEventListener("mouseup",i),document.body.classList.add("noevents"),l.classList.add("grabbing"),e.stopImmediatePropagation(),e.stopPropagation();const n=l.getBoundingClientRect(),a=t.round(t.remapRange(e.offsetX,0,n.width,l.min,l.max));this.set(a,!1,e)},s=e=>{if(0!=e.movementX){const s=l.getBoundingClientRect(),i=t.round(t.remapRange(e.offsetX-s.x,0,s.width,l.min,l.max));this.set(i,!1,e)}e.stopPropagation(),e.preventDefault()},i=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",s),t.removeEventListener("mouseup",i),document.body.classList.remove("noevents"),l.classList.remove("grabbing")};l.addEventListener("mousedown",e)}r(),t.doAsync(this.onResize.bind(this))}}t.Progress=F;class $ extends a{constructor(e,t,s,o,a={}){super(n.RADIO,e,null,a);let l=null;this.onGetValue=()=>{const e=r.querySelectorAll("button");return l?[l,e[l]]:void 0},this.onSetValue=(e,t,n)=>{e=e[0]??e,console.assert(e.constructor==Number,"RadioGroup _value_ must be an Array index!");const a=r.querySelectorAll("button");a.forEach(e=>{e.checked=!1,e.classList.remove("checked")});const l=a[e];l.checked=!l.checked,l.classList.toggle("checked"),t||this._trigger(new i(null,[e,s[e]],n),o)};var r=document.createElement("div");r.className="lexradiogroup "+(a.className??""),this.root.appendChild(r);let c=document.createElement("span");c.innerHTML=t,r.appendChild(c);for(let e=0;e<s.length;++e){const t=document.createElement("div");t.className="lexradiogroupitem",r.appendChild(t);const i=document.createElement("button");i.className="flex p-0 rounded-lg cursor-pointer",i.disabled=a.disabled??!1,t.appendChild(i),i.addEventListener("click",t=>{this.set(e,!1,t)});const o=document.createElement("span");i.appendChild(o);const n=document.createElement("span");n.innerHTML=s[e],t.appendChild(n)}a.selected&&(console.assert(a.selected.constructor==Number,"RadioGroup _selected_ must be an Array index!"),l=a.selected,this.set(l,!0))}}t.RadioGroup=$;class V extends a{_maxSlider=null;_labelTooltip=null;setLimits;constructor(e,s,o,l={}){const r=t.deepCopy(s);super(n.RANGE,e,t.deepCopy(r),l);const c=s.constructor==Array&&2==s.length;c&&(s=r[0],l.fill=!1),this.onGetValue=()=>{let e=s;return c?e=[s,r[1]]:l.left&&(e=+d.max-s+ +d.min),e},this.onSetValue=(n,a,u)=>{let p="";const m=l.max-l.min;if(c&&this._maxSlider){d.value=s=t.clamp(+n[0],+d.min,+d.max),this._maxSlider.value=r[1]=t.clamp(+n[1],+d.min,+d.max);const e=s/m-.5,i=r[1]/m-.5,o=t.remapRange(s,l.min,l.max,0,1),a=t.remapRange(r[1],l.min,l.max,0,1);d.style.setProperty("--range-min-value",100*o+"%"),d.style.setProperty("--range-max-value",100*a+"%"),d.style.setProperty("--range-fix-min-offset",-e+"rem"),d.style.setProperty("--range-fix-max-offset",`${i}rem`),h.dataset.tooltipOffsetX=""+(h.offsetWidth*o+h.offsetWidth*(a-o)*.5-.5*h.offsetWidth),p=`${s} - ${r[1]}`}else{if(isNaN(n))return;d.value=s=t.clamp(+n,+d.min,+d.max);const e=.5*t.remapRange(s,l.min,l.max,0,1);h.dataset.tooltipOffsetX=""+(h.offsetWidth*e-.5*h.offsetWidth),p=`${s}`}if(h.dataset.tooltipContent=p,this._labelTooltip&&(this._labelTooltip.innerHTML=p),!a){let t=s;c?t=[s,r[1]]:l.left&&(t=+d.max-s+ +d.min),this._trigger(new i(e,t,u),o)}},this.onResize=e=>{const i=this.root.domName?.style.width??"0px";if(h.style.width=l.inputWidth??`calc( 100% - ${i})`,c){const e=l.max-l.min,i=s/e-.5,o=r[1]/e-.5;d.style.setProperty("--range-min-value",100*t.remapRange(s,l.min,l.max,0,1)+"%"),d.style.setProperty("--range-max-value",100*t.remapRange(r[1],l.min,l.max,0,1)+"%"),d.style.setProperty("--range-fix-min-offset",-i+"rem"),d.style.setProperty("--range-fix-max-offset",`${o}rem`)}};const h=document.createElement("div");h.className="lexrange relative",this.root.appendChild(h);let d=document.createElement("input");if(d.className="lexrangeslider "+(c?"pointer-events-none ":"")+(l.className??""),d.min=l.min??0,d.max=l.max??100,d.step=l.step??1,d.type="range",d.disabled=l.disabled??!1,s.constructor==Number&&(s=t.clamp(s,+d.min,+d.max)),l.left&&(s=+d.max-s+ +d.min,d.classList.add("left")),(l.fill??1)||d.classList.add("no-fill"),d.value=s,h.appendChild(d),d.addEventListener("input",e=>{this.set(c?[Math.min(e.target.valueAsNumber,r[1]),r[1]]:e.target.valueAsNumber,!1,e)},{passive:!1}),c||(d.addEventListener("mousedown",function(e){l.onPress&&l.onPress.bind(d)(e,d)},!1),d.addEventListener("mouseup",function(e){l.onRelease&&l.onRelease.bind(d)(e,d)},!1)),this.setLimits=(e,t,s)=>{d.min=e??d.min,d.max=t??d.max,d.step=s??d.step,a._dispatchEvent(d,"input",!0)},t.doAsync(()=>{this.onResize();let e=0;if(c){const i=t.remapRange(s,l.min,l.max,0,1),o=t.remapRange(r[1],l.min,l.max,0,1);e=h.offsetWidth*i+h.offsetWidth*(o-i)*.5-.5*h.offsetWidth}else{const i=.5*t.remapRange(s,l.min,l.max,0,1);e=h.offsetWidth*i-.5*h.offsetWidth}t.asTooltip(h,`${s}${c?`- ${r[1]}`:""}`,{offsetX:e,callback:e=>{this._labelTooltip=e}})}),r.constructor==Array){let e=document.createElement("input");e.className="lexrangeslider no-fill pointer-events-none overlap absolute top-0 left-0 "+(l.className??""),e.min=l.min??0,e.max=l.max??100,e.step=l.step??1,e.type="range",e.disabled=l.disabled??!1,this._maxSlider=e;let i=r[1];e.value=i=t.clamp(i,+e.min,+e.max),h.appendChild(e),e.addEventListener("input",e=>{r[1]=Math.max(s,+e.target.valueAsNumber),this.set([s,r[1]],!1,e)},{passive:!1})}}}t.RangeInput=V;class K extends a{constructor(e,s,o,a={}){const l=a.allowHalf??!1;l||(s=Math.floor(s)),super(n.RATE,e,s,a),this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{u(s=t),n||this._trigger(new i(e,t,a),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${t})`};const r=document.createElement("div");r.className="lexrate relative",this.root.appendChild(r);const c=t.makeContainer(["fit-content","auto"],"flex flex-row gap-1","",r),h=t.makeContainer(["fit-content","auto"],"absolute top-0 flex flex-row gap-1 pointer-events-none","",r),d=t.makeContainer(["fit-content","auto"],"absolute top-0 flex flex-row gap-1 pointer-events-none","",r);c.addEventListener("mousemove",e=>{const t=e.target,s=t.dataset.idx;if(void 0!==s){const i=t.getBoundingClientRect(),o=l&&e.offsetX<.5*i.width;u(s-(o?.5:0))}},!1),c.addEventListener("mouseleave",e=>{u(s)},!1);for(let e=0;e<5;++e){const s=t.makeIcon("Star",{svgClass:"lg fill-current fg-secondary"});s.dataset.idx=e+1,c.appendChild(s),s.addEventListener("click",e=>{const t=e.target,s=t.getBoundingClientRect(),i=l&&e.offsetX<.5*s.width;this.set(parseFloat(t.dataset.idx)-(i?.5:0))},!1);const i=t.makeIcon("Star",{svgClass:"lg fill-current fg-yellow-500"});h.appendChild(i);const o=t.makeIcon("StarHalf",{svgClass:"lg fill-current fg-yellow-500"});d.appendChild(o)}const u=e=>{for(let t=0;t<5;++t){const s=e>t+.5,i=h.childNodes[t],o=d.childNodes[t];if(s)i.style.opacity=1;else{i.style.opacity=0;const s=l&&e>t;o.style.opacity=s?1:0}}};u(s),t.doAsync(this.onResize.bind(this))}}t.Rate=K;class U extends a{constructor(e,s,i,o={}){super(n.SIZE,e,s,o),this.onGetValue=()=>{const e=[];for(let t=0;t<this.root.dimensions.length;++t)e.push(this.root.dimensions[t].value());return e},this.onSetValue=(e,t,s)=>{for(let s=0;s<this.root.dimensions.length;++s)this.root.dimensions[s].set(e[s],t)},this.root.aspectRatio=2==s.length?s[0]/s[1]:null,this.root.dimensions=[];for(let e=0;e<s.length;++e){const n=new t.Panel;if(this.root.dimensions[e]=n.addNumber(null,s[e],t=>{const s=this.value();if(this.root.locked){const i=0==e?1/this.root.aspectRatio:this.root.aspectRatio,o=(1+e)%2;s[o]=t*i,this.root.dimensions[o].set(s[o],!0)}i&&i(s)},{min:0,disabled:o.disabled,precision:o.precision,className:"flex-fill"}),this.root.appendChild(this.root.dimensions[e].root),e+1!=s.length){const e=t.makeIcon("X",{svgClass:"fg-accent font-bold"});this.root.appendChild(e)}}if(o.units){let e=document.createElement("span");e.className="select-none fg-tertiary font-medium",e.innerText=o.units,this.root.appendChild(e)}if(this.root.aspectRatio){const e=new l(null,"",e=>{if(this.root.locked=e,e){const e=this.value();this.root.aspectRatio=e[0]/e[1]}},{title:"Lock Aspect Ratio",icon:"LockOpen",swap:"Lock",buttonClass:"bg-none p-0"});this.root.appendChild(e.root)}}}t.SizeInput=U;class G{static ITEMS_PER_PAGE_VALUES=[8,12,24,48,96];root;pagesRoot;page=1;pages=1;_alwaysShowEdges=!0;_useEllipsis=!0;_maxButtons=3;_itemsPerPage=12;_itemsPerPageValues=G.ITEMS_PER_PAGE_VALUES;onChange=()=>{};onItemsPerPageChange=()=>{};constructor(e={}){if(this.pages=e.pages??1,this.page=t.clamp(e.page??1,1,this.pages),this._alwaysShowEdges=e.alwaysShowEdges??this._alwaysShowEdges,this._useEllipsis=e.useEllipsis??this._useEllipsis,this._maxButtons=e.maxButtons??this._maxButtons,this._itemsPerPage=e.itemsPerPage??this._itemsPerPage,-1===this._itemsPerPageValues.indexOf(this._itemsPerPage)&&(this._itemsPerPageValues.push(this._itemsPerPage),this._itemsPerPageValues=this._itemsPerPageValues.sort((e,t)=>e<t?-1:e>t?1:0)),"function"==typeof e.onChange&&(this.onChange=e.onChange),"function"==typeof e.onItemsPerPageChange&&(this.onItemsPerPageChange=e.onItemsPerPageChange),this.root=t.makeContainer(["auto","auto"],"flex flex-row gap-2 "+(e.className??"")),e.allowChangeItemsPerPage){const e=t.makeContainer(["auto","auto"],"flex flex-row items-center","",this.root),s=new u(null,G.ITEMS_PER_PAGE_VALUES,this._itemsPerPage,e=>{this._itemsPerPage=e,this.onItemsPerPageChange?.(this._itemsPerPage)},{overflowContainer:null});e.appendChild(s.root)}this.pagesRoot=t.makeContainer(["auto","auto"],"flex flex-row overflow-scroll","",this.root),this.refresh()}setPage(e){const s=t.clamp(e,1,this.pages);s!==this.page&&(this.page=s,this.refresh(),this._emitChange())}setPages(e){this.pages=Math.max(1,e),this.page>this.pages&&(this.page=this.pages),this.refresh()}next(){this.setPage(this.page+1)}prev(){this.setPage(this.page-1)}refresh(){this.pagesRoot.innerHTML="",this._makeButton(t.makeIcon("ChevronLeft").innerHTML,1===this.page,()=>this.prev(),"bg-none "+(1===this.page?"":"hover:bg-tertiary"));const e=t.makeContainer(["auto","auto"],"flex flex-row items-center","",this.pagesRoot),s=this._maxButtons+2;if(this.pages<=s)for(let t=1;t<=this.pages;t++)this._makePageButton(e,t);else{const i=this.page,o=this.pages,n=1,a=o,l=this._alwaysShowEdges?1:0,r=s-2,c=Math.floor(r/2);let h=Math.max(1+l,i-c),d=Math.min(o-l,i+c);h<=2&&(h=1+l,d=h+r-1),d>=o-1&&(d=o-l,h=d-r+1),this._alwaysShowEdges&&this._makePageButton(e,n),this._useEllipsis&&h>2&&t.makeElement("span","h-6 px-2 text-lg font-semibold whitespace-nowrap","...",e);for(let t=h;t<=d;t++)this._makePageButton(e,t);this._useEllipsis&&d<o-1&&t.makeElement("span","h-6 px-2 text-lg font-semibold whitespace-nowrap","...",e),this._alwaysShowEdges&&this._makePageButton(e,a)}this._makeButton(t.makeIcon("ChevronRight").innerHTML,this.page===this.pages,()=>this.next(),"bg-none "+(this.page===this.pages?"":"hover:bg-tertiary"))}_emitChange(){this.onChange?.(this.page),this.root.dispatchEvent(new CustomEvent("change",{detail:{page:this.page}}))}_makeButton(e,t,s,i,o){const n=new l(null,e,s,{disabled:t,buttonClass:i});return n.root.querySelector("button").style.paddingInline="0.5rem",(o=o??this.pagesRoot).appendChild(n.root),n.root}_makePageButton(e,t){const s=t===this.page?"bg-secondary border":"bg-none";return this._makeButton(String(t),!1,()=>this.setPage(t),s,e)}}t.Pagination=G;class W extends a{data;filter;customFilters;activeCustomFilters;rowOffsetCount=0;_currentFilter;_toggleColumns;_sortColumns;_resetCustomFiltersBtn=null;_hiddenColumns=[];_paginator;_showSelectedNumber;_centered;get centered(){return this._centered}set centered(e){this._setCentered(e)}_rowsPerPage=-1;get rowsPerPage(){return this._rowsPerPage}set rowsPerPage(e){this._setRowsPerPage(e)}constructor(e,s,i={}){if(!s)throw"Data is needed to create a table!";super(n.TABLE,e,null,i),this.onResize=e=>{const t=this.root.domName?.style.width??"0px";o.style.width=`calc( 100% - ${t})`};const o=document.createElement("div");o.className="lextable",this.root.appendChild(o),this._centered=i.centered??!1,!0===this._centered&&o.classList.add("centered"),this.data=s,this.filter=i.filter??!1,this.customFilters=i.customFilters??null,this.activeCustomFilters={},this._toggleColumns=i.toggleColumns??!1,this._sortColumns=i.sortColumns??!0,this._showSelectedNumber=i.showSelectedNumber??!0,this._currentFilter=i.filterValue,this._hiddenColumns=i.hiddenColumns??[],s.head=s.head??[],s.body=s.body??[],s.checkMap={},s.colVisibilityMap={},s.head.forEach((e,t)=>{const i=this._hiddenColumns.indexOf(e),o=!this._toggleColumns||-1===i;s.colVisibilityMap[t]=o}),i.pagination&&(this._rowsPerPage=i.rowsPerPage??12,this._paginator=new G({pages:this._getNumPages(),itemsPerPage:this._rowsPerPage,allowChangeItemsPerPage:i.allowChangeItemsPerPage??!0,onChange:this._onChangePage.bind(this),onItemsPerPageChange:e=>{this.rowsPerPage=e}}));const a=e=>{const t=e.match(/^(\d{1,2})[\/-](\d{1,2})[\/-](\d{2}|\d{4})$/);if(!t)return null;let s=Number(t[1]),i=Number(t[2])-1,o=Number(t[3]);o<100&&(o+=2e3);const n=new Date(o,i,s);return n.getFullYear()!==o||n.getMonth()!==i||n.getDate()!==s?null:n},r=(e,t,s,i)=>{const o=s[e],n=i[e],l=a(o),r=a(n);if(l&&r)return l.getTime()<r.getTime()?-t:l.getTime()>r.getTime()?t:0;const c=Number(o),h=Number(n);return isNaN(c)||isNaN(h)?o<n?-t:o>n?t:0:c<h?-t:c>h?t:0},c=(e,t)=>{s.body=s.body.sort(r.bind(this,e,t)),this.refresh()},h=this;if(this.filter||this.customFilters||this._toggleColumns){const e=t.makeContainer(["100%","auto"],"flex flex-row mb-2");if(this.filter){const s=t.deepCopy(i);s.placeholder=`Filter ${this.filter}...`,s.skipComponent=!0,s.trigger="input",s.inputClass="outline";let o=new d(null,this._currentFilter??"",e=>{this._currentFilter=e,this.refresh()},s);e.appendChild(o.root)}if(null!==this.customFilters){const s=t.makeIcon("CirclePlus",{svgClass:"sm"}),i='<div class="lexcontainer border-right self-center mx-1" style="width: 1px; height: 70%;"></div>';for(let o of this.customFilters)o.component=new l(null,s.innerHTML+o.name,e=>{const n=o.component.root.querySelector("span");if(o.options){const e=o.options.map((e,a)=>{const l={name:e,checked:!!this.activeCustomFilters[e],callback:(e,a,l)=>{a?this.activeCustomFilters[e]=o.name:delete this.activeCustomFilters[e];const r=Object.keys(this.activeCustomFilters).filter(e=>this.activeCustomFilters[e]==o.name),c=r.reduce((e,s)=>e+t.badge(s,"bg-tertiary fg-secondary text-sm border-0"),"");n.innerHTML=s.innerHTML+o.name+(r.length?i:"")+c,this.refresh()}};return l});t.addDropdownMenu(o.component.root,e,{side:"bottom",align:"start"})}else if("range"==o.type){console.assert(null!=o.min&&null!=o.max,"Range filter needs min and max values!");const e=t.makeContainer(["240px","auto"],"text-md"),a=new t.Panel;t.makeContainer(["100%","auto"],"px-3 p-2 pb-0 text-md font-medium",o.name,e),o.start=o.start??o.min,o.end=o.end??o.max,a.refresh=()=>{a.clear(),a.sameLine(2,"justify-center"),a.addNumber(null,o.start,e=>{o.start=e;const a=o.start!=o.min||o.end!=o.max;n.innerHTML=s.innerHTML+o.name+(a?i+t.badge(`${o.start} - ${o.end} ${o.units??""}`,"bg-tertiary fg-secondary text-sm border-0"):""),a&&this._resetCustomFiltersBtn?.root.classList.remove("hidden"),this.refresh()},{skipSlider:!0,min:o.min,max:o.max,step:o.step,units:o.units}),a.addNumber(null,o.end,e=>{o.end=e;const a=o.start!=o.min||o.end!=o.max;n.innerHTML=s.innerHTML+o.name+(a?i+t.badge(`${o.start} - ${o.end} ${o.units??""}`,"bg-tertiary fg-secondary text-sm border-0"):""),a&&this._resetCustomFiltersBtn?.root.classList.remove("hidden"),this.refresh()},{skipSlider:!0,min:o.min,max:o.max,step:o.step,units:o.units}),a.addButton(null,"Reset",()=>{o.start=o.min,o.end=o.max,n.innerHTML=s.innerHTML+o.name,a.refresh(),this.refresh()},{buttonClass:"contrast"})},a.refresh(),e.appendChild(a.root),new v(o.component.root,[e],{side:"bottom"})}else if("date"==o.type){const e=t.makeContainer(["auto","auto"],"text-md"),a=new t.Panel;t.makeContainer(["100%","auto"],"px-3 p-2 pb-0 text-md font-medium",o.name,e),a.refresh=()=>{if(a.clear(),!o.default){const e=new Date,t=`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()}`;o.default=[t,t]}const e=new k(o.value??o.default,{onChange:a=>{o.value=a,n.innerHTML=s.innerHTML+o.name+(i+t.badge(`${e.getFullDate()}`,"bg-tertiary fg-secondary text-sm border-0")),this._resetCustomFiltersBtn?.root.classList.remove("hidden"),this.refresh()}});a.attach(e)},a.refresh(),e.appendChild(a.root),new v(o.component.root,[e],{side:"bottom"})}},{buttonClass:"px-2 primary dashed"}),e.appendChild(o.component.root);this._resetCustomFiltersBtn=new l(null,"resetButton",()=>{this.activeCustomFilters={},this._resetCustomFiltersBtn?.root.classList.add("hidden");for(let e of this.customFilters??[])e.component.root.querySelector("span").innerHTML=s.innerHTML+e.name,"range"==e.type?(e.start=e.min,e.end=e.max):"date"==e.type&&delete e.value;this.refresh()},{title:"Reset filters",tooltip:!0,icon:"X"}),e.appendChild(this._resetCustomFiltersBtn?.root),this._resetCustomFiltersBtn?.root.classList.add("hidden")}if(this._toggleColumns){const i=t.makeIcon("Settings2"),o=new l("toggleColumnsBtn",i.innerHTML+"View",(e,i)=>{const o=s.head.map((e,t)=>{const i={name:e,icon:"Check",callback:()=>{s.colVisibilityMap[t]=!s.colVisibilityMap[t];u.querySelectorAll(`tr > *:nth-child(${t+this.rowOffsetCount+1})`).forEach(e=>{e.style.display="none"===e.style.display?"":"none"})}};return s.colVisibilityMap[t]||delete i.icon,i});t.addDropdownMenu(i.target,o,{side:"bottom",align:"end"})},{hideName:!0});e.appendChild(o.root),o.root.style.marginLeft="auto"}o.appendChild(e)}const u=document.createElement("table");t.addClass(u,i.tableClass),o.appendChild(u),this.refresh=()=>{this._currentFilter=this._currentFilter??"",u.innerHTML="",this.rowOffsetCount=0;{const e=document.createElement("thead");e.className="lextablehead",u.appendChild(e);const o=document.createElement("tr");if(i.sortable){const e=document.createElement("th");e.style.width="0px",o.appendChild(e),this.rowOffsetCount++}if(i.selectable){const e=document.createElement("th");e.style.width="0px";const i=document.createElement("input");i.type="checkbox",i.className="lexcheckbox accent",i.checked=s.checkMap[":root"]??!1,e.appendChild(i),i.addEventListener("change",function(){s.checkMap[":root"]=this.checked;const e=u.querySelector("tbody");for(const t of e.childNodes){const e=t.getAttribute("rowId");e&&(s.checkMap[e]=this.checked,t.querySelector("input[type='checkbox']").checked=this.checked)}const i=h.getSelectedRows();t.emitSignal("@rows_selected_changed",i.length)}),this.rowOffsetCount++,o.appendChild(e)}for(const e of s.head){const n=document.createElement("th");n.innerHTML=`<span>${e}</span>`,n.querySelector("span").appendChild(t.makeIcon("MenuArrows",{svgClass:"sm"}));const a=s.head.indexOf(e);this._centered?.indexOf&&(this._centered.indexOf(a)>-1||this._centered.indexOf(e)>-1)&&n.classList.add("centered");const l=[];if(i.columnActions)for(let e of i.columnActions)e.name?l.push({name:e.name,icon:e.icon,className:e.className,callback:()=>{const t=this.data.body.map(e=>[e[a]]);e.callback(t,u)&&this.refresh()}}):console.warn("Invalid column action (missing name):",e);this._sortColumns&&(l.length>0&&l.push(null),l.push({name:"Asc",icon:"ArrowUpZA",callback:c.bind(this,a,1)},{name:"Desc",icon:"ArrowDownZA",callback:c.bind(this,a,-1)})),this._toggleColumns&&(l.length>0&&l.push(null),l.push({name:"Hide",icon:"EyeOff",callback:()=>{s.colVisibilityMap[a]=!1;u.querySelectorAll(`tr > *:nth-child(${a+this.rowOffsetCount+1})`).forEach(e=>{e.style.display="none"===e.style.display?"":"none"})}})),n.addEventListener("click",e=>{0!==l.length&&t.addDropdownMenu(e.target,l,{side:"bottom",align:"start"})}),o.appendChild(n)}if(i.rowActions){const e=document.createElement("th");e.className="sm",o.appendChild(e)}e.appendChild(o)}{const e=document.createElement("tbody");e.className="lextablebody",u.appendChild(e);let o=null,n=!1,a=null;document.addEventListener("mouseup",e=>{if(null===o)return;document.removeEventListener("mousemove",l);const i=u.rows[o];if(i.dY=0,i.classList.remove("dragging"),Array.from(u.rows).forEach(e=>{e.style.transform="",e.style.transition="none"}),t.flushCss(i),a){const e=this._paginator?(this._paginator.page-1)*this.rowsPerPage:0,i=o-1+e,n=a[1]-1+e;t.emitSignal("@on_table_sort",{instance:this,fromIdx:i,targetIdx:n});const l=s.body[i];let r=0;if(i==n)return;if(i>n)for(let e=i;e>n;--e)s.body[e]=s.body[e-1];else{r=1;for(let e=i;e<n;++e)s.body[e]=s.body[e+1]}s.body[n]=l;const c=a[0].parentNode;t.insertChildAtIndex(c,a[0],n+r-e),a=null}o=null,t.doAsync(()=>{Array.from(u.rows).forEach(e=>{e.style.transition="transform 0.2s ease-in"})})});let l=e=>{if(!o)return;const t=u.rows[o];t.dY=t.dY??0,t.dY+=e.movementY,t.style.transform=`translateY(${t.dY}px)`};const r=[];for(let e=0;e<s.body.length;++e){const i=s.body[e];if(this.filter){const e=s.head.indexOf(this.filter);if(e>-1){if(!t.stripHTML(i[e]).toLowerCase().includes(this._currentFilter.toLowerCase()))continue}}if(Object.keys(this.activeCustomFilters).length){let e={};this._resetCustomFiltersBtn?.root.classList.remove("hidden");for(let o in this.activeCustomFilters){const n=this.activeCustomFilters[o];e[n]=e[n]??!1;const a=s.head.indexOf(n);if(a>-1){const s=i[a],l=t.stripTags(s)??s;e[n]=e[n]||l===o}}if(!Object.values(e).reduce((e,t)=>e&&t,!0))continue}if(this.customFilters){let e={};for(let o of this.customFilters){const n=o.name;if("range"==o.type){e[n]=e[n]??!1;const t=s.head.indexOf(n);if(t>-1){const s=parseFloat(i[t]),a=o.start??o.min,l=o.end??o.max;e[n]=e[n]||s>=a&&s<=l}}else if("date"==o.type){e[n]=e[n]??!1;const a=s.head.indexOf(n);if(a>-1){if(!o.value){e[n]=!0;continue}o.value=o.value??o.default;const s=i[a],l=t.dateFromDateString(s),r=t.dateFromDateString(o.value[0]),c=t.dateFromDateString(o.value[1]);e[n]=e[n]||l>=r&&l<=c}}}if(!Object.values(e).reduce((e,t)=>e&&t,!0))continue}r.push(i)}this._paginator&&this._paginator.setPages(this._getNumPages(r.length));const c=this._paginator?(this._paginator.page-1)*this.rowsPerPage:0,d=this._paginator?Math.min(c+this.rowsPerPage,r.length):r.length;for(let p=c;p<d;++p){const c=r[p],d=this.data.body.indexOf(c),m=document.createElement("tr"),g=this._makeRowId(c);if(m.setAttribute("rowId",g),i.sortable){const e=document.createElement("td");e.style.width="0px";const s=t.makeIcon("GripVertical");e.appendChild(s),s.draggable=!0,s.addEventListener("dragstart",e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),o=m.rowIndex,m.classList.add("dragging"),document.addEventListener("mousemove",l)},!1),m.addEventListener("mouseenter",function(e){if(e.preventDefault(),null!=o&&this.rowIndex!=o&&n!=this.rowIndex){n=this.rowIndex;const e=u.rows[o],s=""!=this.style.transform;this.rowIndex>o?(a=[e,s?this.rowIndex-1:this.rowIndex],this.style.transform=s?"":`translateY(-${this.offsetHeight}px)`):(a=[e,s?this.rowIndex+1:this.rowIndex],this.style.transform=s?"":`translateY(${this.offsetHeight}px)`),t.doAsync(()=>{n=!1})}}),m.appendChild(e)}if(i.selectable){const e=document.createElement("td"),i=document.createElement("input");i.type="checkbox",i.className="lexcheckbox accent",i.checked=s.checkMap[g],e.appendChild(i),i.addEventListener("change",function(){s.checkMap[g]=this.checked;const e=u.querySelector("thead input[type='checkbox']");if(console.assert(e,"Header checkbox not found!"),this.checked){Array.from(u.querySelectorAll("tbody input[type='checkbox']")).filter(e=>!e.checked).length||(e.checked=s.checkMap[":root"]=!0)}else e.checked=s.checkMap[":root"]=!1;const i=h.getSelectedRows();t.emitSignal("@rows_selected_changed",i.length)}),m.appendChild(e)}for(let e=0;e<c.length;++e){const t=c[e],i=document.createElement("td");i.innerHTML=`${t}`;const o=s.head[e];this._centered?.indexOf&&(this._centered.indexOf(e)>-1||this._centered.indexOf(o)>-1)&&i.classList.add("centered"),m.appendChild(i)}if(i.rowActions){const e=document.createElement("td");e.style.width="0px";const o=document.createElement("div");o.className="lextablebuttons",e.appendChild(o);for(const e of i.rowActions){let n=null;"delete"==e?(n=t.makeIcon("Trash3",{title:"Delete Row"}),n.addEventListener("click",()=>{s.body.splice(d,1),this.refresh()})):"menu"==e?(n=t.makeIcon("EllipsisVertical",{title:"Menu"}),n.addEventListener("click",function(e){if(!i.onMenuAction)return;const o=i.onMenuAction(d,s);console.assert(o.length,"Add items to the Menu Action Dropdown!"),t.addDropdownMenu(e.target,o,{side:"bottom",align:"end"})})):(console.assert(e.constructor==Object),n=t.makeIcon(e.icon,{title:e.title}),e.callback&&n.addEventListener("click",t=>{e.callback(d,c,u,t)&&this.refresh()})),console.assert(n),o.appendChild(n)}m.appendChild(e)}e.appendChild(m)}if(i.selectable){const e=this.getSelectedRows();t.emitSignal("@rows_selected_changed",e.length)}if(0==e.childNodes.length){const t=document.createElement("tr"),i=document.createElement("td");i.setAttribute("colspan",s.head.length+this.rowOffsetCount+1),i.className="empty-row",i.innerHTML="No results.",t.appendChild(i),e.appendChild(t)}}for(const e in s.colVisibilityMap){const t=parseInt(e);if(!s.colVisibilityMap[t]){u.querySelectorAll(`tr > *:nth-child(${t+this.rowOffsetCount+1})`).forEach(e=>{e.style.display="none"===e.style.display?"":"none"})}}};const p=this._showSelectedNumber&&i.selectable;if(p||this._paginator){const e=t.makeContainer(["100%","auto"],"flex flex-row px-3 my-1 align-center","",o);if(p){const s=t.makeContainer(["100%","auto"],"flex justify-start items-center fg-secondary","0 row(s) selected.",e);t.addSignal("@rows_selected_changed",(e,t)=>{this._showSelectedNumber&&(s.innerHTML=0===t?"":`${t??0} row(s) selected.`)})}if(this._paginator){t.makeContainer(["100%","auto"],"flex justify-end","",e).appendChild(this._paginator.root)}}this.refresh(),t.doAsync(this.onResize.bind(this))}getSelectedRows(){const e=[];for(const t of this.data.body){const s=this._makeRowId(t);!0===this.data.checkMap[s]&&e.push(t)}return e}_makeRowId(e){return t.getSupportedDOMName(e.join("-")).substr(0,32)}_onChangePage(e){this.refresh()}_getNumPages(e){return-1===this.rowsPerPage?1:(e=e??this.data.body?.length,Math.ceil((e??0)/this.rowsPerPage))}_setRowsPerPage(e){this._rowsPerPage=e,this.refresh()}_setCentered(e){if(e.constructor==Boolean){this.root.querySelector(".lextable").classList.toggle("centered",e)}else e=Array.isArray(e)?e:[e];this._centered=e,this.refresh()}}t.Table=W;class q extends a{tabs;tabDOMs;constructor(e,s,i={}){if(i.hideName=!0,super(n.TABS,e,null,i),s.constructor!=Array)throw"Param @tabs must be an Array!";if(!s.length)throw"Tab list cannot be empty!";const o=i.vertical??!0,a=!o&&(i.showNames??!1);this.tabDOMs={};let l=document.createElement("div");l.className="lextabscontainer",o||(l.className+=" horizontal");let r=document.createElement("div");r.className="tabs",l.appendChild(r),this.root.appendChild(l),s.findIndex(e=>!0===e.selected)<0&&(s[0].selected=!0);for(let e of s){console.assert(e.name);let s=document.createElement("div");s.className="lextab "+(e.selected?"selected":""),s.innerHTML=a?e.name:"",s.appendChild(t.makeIcon(e.icon??"Hash",{title:e.name,iconClass:e.iconClass,svgClass:e.svgClass})),this.tabDOMs[e.name]=s;let i=document.createElement("div");if(i.id=e.name.replace(/\s/g,""),i.className="components",i.toggleAttribute("hidden",!e.selected),l.appendChild(i),s.addEventListener("click",t=>{r.querySelectorAll(".lextab").forEach(e=>{e.classList.remove("selected")}),s.classList.add("selected"),l.querySelectorAll(".components").forEach(e=>{e.toggleAttribute("hidden",!0)});const o=l.querySelector("#"+i.id);o?.toggleAttribute("hidden"),e.onSelect&&e.onSelect(this,i)}),r.appendChild(s),e.onCreate){const s=new t.Panel;s.queue(i),e.onCreate.call(this,s,i),s.clearQueue()}}this.tabs=s}select(e){const t=this.tabDOMs[e];t&&t.click()}}t.TabSections=q;class Y extends a{generateTags;constructor(e,s,o,a={}){let l=s.replace(/\s/g,"").split(","),r=t.deepCopy(l);super(n.TAGS,e,r,a),this.options.skipDuplicates=a.skipDuplicates??!0,this.onGetValue=()=>t.deepCopy(s),this.onSetValue=(t,s,n)=>{l=[].concat(t),this.generateTags(l),s||this._trigger(new i(e,l,n),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${t})`};const c=document.createElement("div");c.className="lextags",this.root.appendChild(c),this.generateTags=e=>{c.innerHTML="";for(let s=0;s<e.length;++s){const i=e[s],o=document.createElement("span");o.className="lextag",o.innerHTML=i;const n=t.makeIcon("X",{svgClass:"sm"});o.appendChild(n),n.addEventListener("click",t=>{o.remove(),e.splice(e.indexOf(i),1),this.set(e,!1,t)}),c.appendChild(o)}let s=document.createElement("input");s.value="",s.placeholder="Add tag...",c.appendChild(s),s.onkeydown=t=>{if(" "==t.key||"Enter"==t.key){const i=s.value.replace(/\s/g,"");if(t.preventDefault(),!i.length||a.skipDuplicates&&e.indexOf(i)>-1)return;e.push(i),this.set(e,!1,t),c.querySelector("input")?.focus()}}},this.generateTags(l),t.doAsync(this.onResize.bind(this))}}t.Tags=Y;class X extends a{constructor(e,s,o,a={}){super(n.TEXTAREA,e,s,a),this.onGetValue=()=>s,this.onSetValue=(t,n,a)=>{r.value=s=t,n||this._trigger(new i(e,t,a),o)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=a.inputWidth??`calc( 100% - ${t})`};let l=document.createElement("div");l.className="lextextarea",l.style.display="flex",this.root.appendChild(l);let r=document.createElement("textarea");r.value=s??"",r.className=a.inputClass??"",r.style.textAlign=a.float??"",Object.assign(r.style,a.style??{}),a.fitHeight&&r.classList.add("size-content"),(a.resize??1)||r.classList.add("resize-none"),l.appendChild(r),a.disabled&&(this.disabled=!0,r.setAttribute("disabled","true")),a.placeholder&&r.setAttribute("placeholder",a.placeholder);const c=a.trigger??"default";if("default"==c?(r.addEventListener("keyup",function(e){"Enter"==e.key&&r.blur()}),r.addEventListener("focusout",e=>{this.set(e.target?.value,!1,e)})):"input"==c&&r.addEventListener("input",e=>{this.set(e.target?.value,!1,e)}),a.icon){const e=t.makeIcon(a.icon,{iconClass:"absolute z-1 ml-2",svgClass:"sm"});l.appendChild(e)}t.doAsync(()=>{l.style.height=a.height??"",this.onResize()},10)}}t.TextArea=X;class j extends a{constructor(e,s={}){if(console.assert(0!==e.length,"Can't create Title Component without text!"),super(n.TITLE,null,null,s),this.root.className=`lextitle ${this.root.className}`,s.icon){let e=t.makeIcon(s.icon,{iconClass:"mr-2"});e.querySelector("svg").style.color=s.iconColor||"",this.root.appendChild(e)}let i=document.createElement("span");if(i.innerText=e,this.root.appendChild(i),Object.assign(this.root.style,s.style??{}),null!=s.link){let t=document.createElement("a");t.innerText=e,t.href=s.link,t.target=s.target??"",t.className="lextitle link",Object.assign(t.style,s.style??{}),this.root.replaceWith(t)}}}t.Title=j;class Z extends a{constructor(e,s,o,a={}){if(!e&&!a.label)throw"Set Component Name or at least a label!";super(n.TOGGLE,e,s,a),this.onGetValue=()=>r.checked,this.onSetValue=(t,n,a)=>{t!=s&&(r.checked=s=t,this.root.querySelector(".lextogglesubmenu")?.toggleAttribute("hidden",!t),n||this._trigger(new i(e,t,a),o))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=a.inputWidth??`calc( 100% - ${t})`};var l=document.createElement("div");l.className="lextogglecont",this.root.appendChild(l);let r=document.createElement("input");r.type="checkbox",r.className="lextoggle "+(a.className??""),r.checked=s,r.iValue=s,r.disabled=a.disabled??!1,l.appendChild(r);let c=document.createElement("span");if(c.className="toggletext",c.innerHTML=a.label??"On",l.appendChild(c),r.addEventListener("change",e=>{this.set(r.checked,!1,e)}),a.suboptions){let e=document.createElement("div");e.className="lextogglesubmenu",e.toggleAttribute("hidden",!r.checked);const s=new t.Panel;s.queue(e),a.suboptions.call(this,s),s.clearQueue(),this.root.appendChild(e)}t.doAsync(this.onResize.bind(this))}}t.Toggle=Z;class J extends a{setLimits;constructor(e,s,o,r,c={}){e=t.clamp(e,2,4),o=o??new Array(e).fill(0),super(n.VECTOR,s,t.deepCopy(o),c),this.onGetValue=()=>{let e=this.root.querySelectorAll("input[type='number']"),t=[];for(var s of e)t.push(+s.value);return t},this.onSetValue=(e,n,a)=>{if(h.length==e.length){for(let s=0;s<h.length;++s){let i=e[s];i=t.clamp(i,+h[s].min,+h[s].max),i=t.round(i,c.precision)??0,h[s].value=o[s]=i}n||this._trigger(new i(s,o,a),r)}else console.error("Input length does not match vector length.")},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";d.style.width=`calc( 100% - ${t})`},this.setLimits=(e,t,s)=>{};const h=[];var d=document.createElement("div");d.className="lexvector",this.root.appendChild(d),this.disabled=c.disabled??!1;const u=this;for(let m=0;m<e;++m){let g=document.createElement("div");g.className="vecbox",g.innerHTML="<span class='"+t.Panel.VECTOR_COMPONENTS[m]+"'></span>";let f=document.createElement("input");f.className="vecinput v"+e,f.min=c.min??-1e24,f.max=c.max??1e24,f.step=c.step??"any",f.type="number",f.id="vec"+e+"_"+t.guidGenerator(),f.idx=m,h[m]=f,g.appendChild(f),o[m].constructor==Number&&(o[m]=t.clamp(o[m],+f.min,+f.max),o[m]=t.round(o[m],c.precision)),f.value=f.iValue=o[m];const C=t.makeIcon("MoveVertical",{iconClass:"drag-icon hidden-opacity",svgClass:"sm"});function v(e){if(document.activeElement!=f&&e.button==t.MOUSE_LEFT_CLICK){var s=u.root.ownerDocument;s.addEventListener("mousemove",y),s.addEventListener("mouseup",b),document.body.classList.add("noevents"),C.classList.remove("hidden-opacity"),e.stopImmediatePropagation(),e.stopPropagation(),document.pointerLockElement||g.requestPointerLock(),c.onPress&&c.onPress.bind(f)(e,f)}}function y(e){let s=-e.movementY;if(0!=s){let i=c.step??1;if(e.shiftKey?i=10:e.altKey&&(i=.1),p.locked)for(let e of h)e.value=t.round(+e.valueAsNumber+i*s,c.precision),a._dispatchEvent(e,"change");else f.value=t.round(+f.valueAsNumber+i*s,c.precision),a._dispatchEvent(f,"change")}e.stopPropagation(),e.preventDefault()}function b(e){var t=u.root.ownerDocument;t.removeEventListener("mousemove",y),t.removeEventListener("mouseup",b),document.body.classList.remove("noevents"),C.classList.add("hidden-opacity"),document.pointerLockElement&&document.exitPointerLock(),c.onRelease&&c.onRelease.bind(f)(e,f)}g.appendChild(C),this.disabled&&(f.disabled=!0),f.addEventListener("wheel",function(e){if(e.preventDefault(),f!==document.activeElement)return;let s=c.step??1;if(e.shiftKey?s=10:e.altKey&&(s=.1),p.locked)for(let i of h)i.value=t.round(+i.valueAsNumber-s*(e.deltaY>0?1:-1),c.precision),a._dispatchEvent(i,"change");else f.value=t.round(+f.valueAsNumber-s*(e.deltaY>0?1:-1),c.precision),a._dispatchEvent(f,"change")},{passive:!1}),f.addEventListener("change",e=>{if(isNaN(e.target.value))return;let s=t.clamp(e.target.value,+f.min,+f.max);if(s=t.round(s,c.precision),p.locked)for(let e of h)e.value=s,o[e.idx]=s;else f.value=s,o[e.target.idx]=s;this.set(o,!1,e)},!1),g.addEventListener("mousedown",v),d.appendChild(g)}void 0===c.min&&void 0===c.max||(this.setLimits=(e,t,s)=>{for(let i of h)i.min=e??i.min,i.max=t??i.max,i.step=s??i.step;this.set(o,!0)});const p=new l(null,"",e=>{p.locked=e},{title:"Lock",icon:"LockOpen",swap:"Lock",buttonClass:"no-h bg-none p-0"});d.appendChild(p.root),t.doAsync(this.onResize.bind(this))}}t.Vector=J;class Q{name;components;closed;root;content;grabber;panel;onclick;oncontextmenu;constructor(e,s={}){this.name=e;var i=document.createElement("div");i.className="lexbranch",s.id&&(i.id=s.id),s.className&&(i.className+=" "+s.className),i.style.margin="0 auto";var o=this;this.closed=s.closed??!1,this.root=i,this.components=[],this.panel=null;const n=document.createElement("div");if(n.className="lexbranchtitle",s.icon){const e=t.makeIcon(s.icon,{iconClass:"mr-2"});n.appendChild(e)}n.innerHTML+=e||"Branch";const a=t.makeIcon("Right",{iconClass:"switch-branch-button",svgClass:"sm"});n.appendChild(a),i.appendChild(n);var l=document.createElement("div");l.id=e.replace(/\s/g,""),l.className="lexbranchcontent",i.appendChild(l),this.content=l,this._addBranchSeparator(),this.closed&&(n.classList.add("closed"),i.classList.add("closed"),this.grabber.setAttribute("hidden",!0),t.doAsync(()=>{this.content.setAttribute("hidden",!0)},10)),this.onclick=function(){n.classList.toggle("closed"),n.parentElement.classList.toggle("closed"),o.content.toggleAttribute("hidden"),o.grabber.toggleAttribute("hidden"),t.emitSignal("@on_branch_closed",n.classList.contains("closed"))},this.oncontextmenu=function(e){e.preventDefault(),e.stopPropagation(),n.parentElement.classList.contains("dialog")||t.addContextMenu("Dock",e,t=>{e.preventDefault(),t.add("Floating",o._onMakeFloating.bind(o))},{icon:"WindowRestore"})},n.addEventListener("click",this.onclick),n.addEventListener("contextmenu",this.oncontextmenu)}_onMakeFloating(){const e=new t.Dialog(this.name,e=>{for(let t of this.components)e.root.appendChild(t.root)},{dockable:!0}),s=Array.from(this.root.parentElement.childNodes).indexOf(this.root);console.assert(s>=0,"Branch not found!"),e.branchData={name:this.name,components:this.components,closed:this.closed,panel:this.panel,childIndex:s},this.root.remove()}_addBranchSeparator(){const e=document.createElement("div");e.className="lexcomponentseparator",e.style.width="100%",e.style.background="none";const s=document.createElement("div");s.innerHTML="▾",e.appendChild(s),t.doAsync(()=>{s.style.marginLeft=parseFloat(t.DEFAULT_NAME_WIDTH)/100*this.content.offsetWidth+"px"},10);const i=document.createElement("div");i.style.width="1px",i.style.marginLeft="6px",i.style.marginTop="2px",i.style.height="0px",s.appendChild(i),s.addEventListener("mousedown",function(e){var t=o.root.ownerDocument;t.addEventListener("mouseup",a),t.addEventListener("mousemove",n),e.stopPropagation(),e.preventDefault();const s=o.root.offsetHeight-o.root.children[0].offsetHeight;i.style.height=s-3+"px",document.body.classList.add("nocursor")}),this.grabber=s;let o=this;function n(e){let i=e.movementX;if(0!=i){const e=parseFloat(s.style.marginLeft);s.style.marginLeft=t.clamp(e+i,32,o.content.offsetWidth-32)+"px"}}function a(e){o._updateComponents(),i.style.height="0px";var t=o.root.ownerDocument;t.removeEventListener("mouseup",a),t.removeEventListener("mousemove",n),document.body.classList.remove("nocursor")}this.content.appendChild(e)}_updateComponents(){var e=this.grabber.style.marginLeft;for(let s=0;s<this.components.length;s++){let i=this.components[s];const o=i.root;if(o.children.length<2)continue;let n=o.children[0],a=o.children[1];switch(n.style.width=e,n.style.minWidth=e,i.type){case t.BaseComponent.CUSTOM:case t.BaseComponent.ARRAY:continue}a.style.width="-moz-calc( 100% - "+e+" )",a.style.width="-webkit-calc( 100% - "+e+" )",a.style.width="calc( 100% - "+e+" )"}}}t.Branch=Q;let ee=class{root;branches;components;signals;queuedContainer;_branchOpen;_currentBranch;_queue;_inlineComponentsLeft;_inlineQueuedContainer;_inlineExtraClass;_inlineContainer;_inlineComponents;constructor(e={}){var t=document.createElement("div");t.className="lexpanel",e.id&&(t.id=e.id),e.className&&(t.className+=" "+e.className),t.style.width=e.width||"100%",t.style.height=e.height||"100%",Object.assign(t.style,e.style??{}),this.root=t,this.branches=[],this.signals=[],this.components={},this._branchOpen=!1,this._currentBranch=null,this._queue=[],this._inlineComponentsLeft=-1,this._inlineQueuedContainer=null,this._inlineExtraClass=null,this._inlineComponents=[]}get(e){return this.components[e]}getValue(e){let t=this.components[e];if(!t)throw"No component called "+e;return t.value()}setValue(e,t,s){let i=this.components[e];if(!i)throw"No component called "+e;return i.set(t,s)}attach(e){console.assert(e,"No content to attach!"),e.parent=this,this.root.appendChild(e.root?e.root:e)}clear(){this.branches=[],this._branchOpen=!1,this._currentBranch=null;for(let e in this.components)if(this.components[e].options&&this.components[e].options.signal){const s=this.components[e].options.signal;for(let i=0;i<t.signals[s].length;i++)t.signals[s][i]==this.components[e]&&(t.signals[s]=[...t.signals[s].slice(0,i),...t.signals[s].slice(i+1)])}if(this.signals)for(let e=0;e<this.signals.length;e++){let s=Object.values(this.signals[e])[0],i=s.options.signal;for(let e=0;e<t.signals[i].length;e++)t.signals[i][e]==s&&(t.signals[i]=[...t.signals[i].slice(0,e),...t.signals[i].slice(e+1)])}this.components={},this.root.innerHTML=""}sameLine(e,t){this._inlineQueuedContainer=this.queuedContainer,this._inlineComponentsLeft=e??1/0,this._inlineExtraClass=t??null}endLine(e){if(e=e??this._inlineExtraClass,-1!=this._inlineComponentsLeft){this._inlineComponentsLeft=-1,this._inlineContainer||(this._inlineContainer=document.createElement("div"),this._inlineContainer.className="lexinlinecomponents",e&&(this._inlineContainer.className+=` ${e}`));for(let e of this._inlineComponents){e.constructor==Array?this._inlineQueuedContainer?this._inlineContainer.appendChild(e[0]):e[1].appendChild(e[0]):this._inlineContainer.appendChild(e)}this._inlineQueuedContainer?this._inlineQueuedContainer.appendChild(this._inlineContainer):this._currentBranch?this._currentBranch.content.appendChild(this._inlineContainer):this.root.appendChild(this._inlineContainer),this._inlineComponents=[],this._inlineContainer=null,this._inlineExtraClass=null}else console.warn("No pending components to be inlined!")}branch(e,t={}){this._branchOpen&&this.merge();var s=new Q(e,t);return s.panel=this,this._branchOpen=!0,this._currentBranch=s,this.branches.push(s),this.root.appendChild(s.root),t.filter&&this._addFilter(t.filter,{callback:this._searchComponents.bind(this,s.name)}),s}merge(){this._branchOpen=!1,this._currentBranch=null}_pick(e,t){return void 0===e?t:e}_attachComponent(e,t={}){null!=e.name&&(this.components[e.name]=e),e.options.signal&&!e.name&&(this.signals||(this.signals=[]),this.signals.push({[e.options.signal]:e}));const s=s=>{t.container?t.container.appendChild(s):this.queuedContainer?this.queuedContainer.appendChild(s):this._currentBranch?(t.skipComponent||this._currentBranch.components.push(e),this._currentBranch.content.appendChild(s)):(s.className+=" nobranch w-full",this.root.appendChild(s))},i=e=>{this.queuedContainer?this._inlineComponents.push([e,this.queuedContainer]):this._inlineComponents.push(e)};return this._inlineComponentsLeft>0&&!t.skipInlineCount?(i(e.root),this._inlineComponentsLeft--,this._inlineComponentsLeft||this.endLine()):s(e.root),e}_addFilter(e,s={}){s.placeholder=e.constructor==String?e:"Filter properties..",s.skipComponent=s.skipComponent??!0,s.skipInlineCount=!0;const i=new d(null,void 0,null,s).root;i.className+=" lexfilter";let o=document.createElement("input");o.className="lexinput-filter",o.setAttribute("placeholder",s.placeholder),o.style.width="100%",o.value=s.filterValue||"";let n=t.makeIcon("Search");return i.appendChild(n),i.appendChild(o),o.addEventListener("input",e=>{s.callback&&s.callback(o.value,e)}),i}_searchComponents(e,t){for(let s of this.branches){if(s.name!==e)continue;for(let e of s.components)e.domEl.classList.contains("lexfilter")||e.domEl.remove();this.queue(s.content);const i=!t.length;for(let e of s.components){if(!i){if(!e.name)continue;if(!e.name.toLowerCase().includes(t))continue}this.queuedContainer.appendChild(e.domEl)}return void this.clearQueue()}}getBranch(e){return e?this.branches.find(t=>t.name==e):this._currentBranch}queue(e){!e&&this._currentBranch&&(e=this._currentBranch.root),this.queuedContainer&&this._queue.push(this.queuedContainer),this.queuedContainer=e}clearQueue(){this._queue&&this._queue.length?this.queuedContainer=this._queue.pop():delete this.queuedContainer}addSeparator(){var e=document.createElement("div");e.className="lexseparator";let t=new a(n.SEPARATOR);t.root=e,this._currentBranch?(this._currentBranch.content.appendChild(e),this._currentBranch.components.push(t)):this.root.appendChild(e)}addTitle(e,t={}){const s=new j(e,t);return this._attachComponent(s)}addText(e,t,s,i={}){const o=new d(e,t,s,i);return this._attachComponent(o)}addTextArea(e,t,s,i={}){const o=new X(e,t,s,i);return this._attachComponent(o)}addLabel(e,t={}){t.disabled=!0,t.inputClass=(t.inputClass??"")+" bg-none";const s=this.addText(null,e,null,t);return s.type=n.LABEL,s}addButton(e,t,s,i={}){const o=new l(e,t,s,i);return this._attachComponent(o)}addComboButtons(e,t,s={}){const i=new b(e,t,s);return this._attachComponent(i)}addCard(e,t={}){const s=new m(e,t);return this._attachComponent(s)}addForm(e,t,s,i={}){const o=new A(e,t,s,i);return this._attachComponent(o)}addContent(e,t,s={}){if(console.assert(t,"Empty content!"),t.constructor==String){const e=document.createElement("div");e.innerHTML=t,t=e.childElementCount>1?e:e.firstElementChild}s.hideName=!0;let i=new a(n.CONTENT,e,null,s);return i.root.appendChild(t),this._attachComponent(i)}async addImage(e,t,s={}){console.assert(0!==t.length,"Empty src/url for Image!");let i=document.createElement("div");i.className="leximage",i.style.width="100%";let o=document.createElement("img");o.src=t,Object.assign(o.style,s.style??{}),i.appendChild(o);let l=new a(n.IMAGE,e,null,s);return l.root.appendChild(i),o.decode(),this._attachComponent(l)}addSelect(e,t,s,i,o={}){const n=new u(e,t,s,i,o);return this._attachComponent(n)}addCurve(e,t,s,i={}){const o=new L(e,t,s,i);return this._attachComponent(o)}addDial(e,t,s,i={}){const o=new w(e,t,s,i);return this._attachComponent(o)}addLayers(e,t,s,i={}){const o=new N(e,t,s,i);return this._attachComponent(o)}addArray(e,t=[],s,i={}){const o=new p(e,t,s,i);return this._attachComponent(o)}addList(e,t,s,i,o={}){const n=new P(e,t,s,i,o);return this._attachComponent(n)}addTags(e,t,s,i={}){const o=new Y(e,t,s,i);return this._attachComponent(o)}addCheckbox(e,t,s,i={}){const o=new g(e,t,s,i);return this._attachComponent(o)}addToggle(e,t,s,i={}){const o=new Z(e,t,s,i);return this._attachComponent(o)}addRadioGroup(e,t,s,i,o={}){const n=new $(e,t,s,i,o);return this._attachComponent(n)}addColor(e,t,s,i={}){const o=new y(e,t,s,i);return this._attachComponent(o)}addRange(e,t,s,i={}){const o=new V(e,t,s,i);return this._attachComponent(o)}addNumber(e,t,s,i={}){const o=new h(e,t,s,i);return this._attachComponent(o)}static VECTOR_COMPONENTS={0:"x",1:"y",2:"z",3:"w"};_addVector(e,t,s,i,o={}){const n=new J(e,t,s,i,o);return this._attachComponent(n)}addVector2(e,t,s,i){return this._addVector(2,e,t,s,i)}addVector3(e,t,s,i){return this._addVector(3,e,t,s,i)}addVector4(e,t,s,i){return this._addVector(4,e,t,s,i)}addSize(e,t,s,i={}){const o=new U(e,t,s,i);return this._attachComponent(o)}addOTP(e,t,s,i={}){const o=new B(e,t,s,i);return this._attachComponent(o)}addPad(e,t,s,i={}){const o=new H(e,t,s,i);return this._attachComponent(o)}addProgress(e,t,s={}){const i=new F(e,t,s);return this._attachComponent(i)}addFile(e,t,s={}){const i=new M(e,t,s);return this._attachComponent(i)}addTree(e,t,s={}){const i=new z(e,t,s);return this._attachComponent(i)}addTabSections(e,t,s={}){const i=new q(e,t,s);return this._attachComponent(i)}addCounter(e,t,s,i={}){const o=new _(e,t,s,i);return this._attachComponent(o)}addTable(e,t,s={}){const i=new W(e,t,s);return this._attachComponent(i)}addDate(e,t,s,i={}){const o=new E(e,t,s,i);return this._attachComponent(o)}addMap2D(e,t,s,i={}){const o=new R(e,t,s,i);return this._attachComponent(o)}addRate(e,t,s,i={}){const o=new K(e,t,s,i);return this._attachComponent(o)}};t.Panel=ee;class te{area;options;buttons;constructor(e,t,s={}){this.area=e,this.options=s,this.buttons={},this._buildButtons(t,s)}_buildButtons(e,t={}){t.className="lexoverlaybuttons";let s=this.area.addPanel(t),i=null;const o=document.createElement("div");o.className="lexoverlaybuttonscontainer",o.appendChild(s.root),this.area.attach(o);const n=t.float;let a="";if(n){for(let e=0;e<n.length;e++){switch(n[e]){case"h":case"t":case"l":break;case"v":a+=" vertical";break;case"m":a+=" middle";break;case"b":a+=" bottom";break;case"c":a+=" center";break;case"r":a+=" right"}}o.className+=` ${a}`}const l=(e,t,o)=>{const n={width:"auto",selectable:e.selectable,selected:e.selected,icon:e.icon,img:e.img,className:e.class??"",title:e.name,overflowContainerX:s.root,swap:e.swap};t&&(i||(i=document.createElement("div"),i.className="lexoverlaygroup",s.queuedContainer=i),n.parent=i);let a=e.callback,l=null;l=e.options?s.addSelect(null,e.options,e.value??e.name,a,n):s.addButton(null,e.name,function(t,s){if(e.selectable)if(e.group){let t=e.selected;e.group.forEach(e=>e.selected=!1),e.selected=!t}else e.selected=!e.selected;a&&a(t,s,l.root)},n),this.buttons[e.name]=l,i&&o&&(s.root.appendChild(i),i=null,s.clearQueue())};!function(){s.clear();for(let t of e){if(null===t){const e=document.createElement("div");e.className="lexoverlayseparator"+a,s.root.appendChild(e);continue}if(t.constructor===Array)for(let e=0;e<t.length;++e){let s=t[e];s.group=t,l(s,!0,e==t.length-1)}else l(t)}if(n){var t=0;s.root.childNodes.forEach(e=>{t+=e.offsetHeight}),o.className.includes("middle")&&(o.style.top="-moz-calc( 50% - "+.5*t+"px )",o.style.top="-webkit-calc( 50% - "+.5*t+"px )",o.style.top="calc( 50% - "+.5*t+"px )")}}()}}t.AreaOverlayButtons=te;let se=class e{offset=0;root;size;resize=!1;sections=[];panels=[];minWidth=0;minHeight=0;maxWidth=1/0;maxHeight=1/0;layout;type;parentArea;splitBar;splitExtended;overlayButtons;onresize;_autoVerticalResizeObserver;_root;constructor(e={}){var s=document.createElement("div");s.className="lexarea",e.id&&(s.id=e.id),e.className&&(s.className+=" "+e.className);var i=e.width||"100%",o=e.height||"100%";this.setLimitBox(e.minWidth,e.minHeight,e.maxWidth,e.maxHeight),i.constructor==Number&&(i=`${i}px`),o.constructor==Number&&(o=`${o}px`),s.style.width=i,s.style.height=o,this.root=s,this.size=[this.root.offsetWidth,this.root.offsetHeight];let n=document.getElementById("lexroot");n&&!e.skipAppend&&n.appendChild(this.root),e.layout&&this.setLayout(e.layout);let a=e.overlay;if(a){this.root.classList.add("overlay-"+a),e.left?this.root.style.left=e.left:e.right?this.root.style.right=e.right:e.top?this.root.style.top=e.top:e.bottom&&(this.root.style.bottom=e.bottom);if((e.draggable??!0)&&t.makeDraggable(s,e),e.resizeable&&s.classList.add("resizeable"),e.resize){this.splitBar=document.createElement("div");let l="left"==a||"right"==a?"horizontal":"vertical";if(this.type=a,this.splitBar.className="lexsplitbar "+l,"right"==a)this.splitBar.style.width=t.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.left=-t.DEFAULT_SPLITBAR_SIZE/2+"px";else if("left"==a){let p=Math.min(document.body.clientWidth-t.DEFAULT_SPLITBAR_SIZE,this.root.clientWidth);this.splitBar.style.width=t.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.left=p+t.DEFAULT_SPLITBAR_SIZE/2+"px"}else if("top"==a){let m=Math.min(document.body.clientHeight-t.DEFAULT_SPLITBAR_SIZE,this.root.clientHeight);this.splitBar.style.height=t.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.top=m+t.DEFAULT_SPLITBAR_SIZE/2+"px"}else"bottom"==a&&(this.splitBar.style.height=t.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.top=-t.DEFAULT_SPLITBAR_SIZE/2+"px");this.splitBar.addEventListener("mousedown",h),this.root.appendChild(this.splitBar);const r=this;let c=[0,0];function h(e){const t=r.root.ownerDocument;t.addEventListener("mousemove",d),t.addEventListener("mouseup",u),c[0]=e.x,c[1]=e.y,e.stopPropagation(),e.preventDefault(),document.body.classList.add("nocursor"),r.splitBar.classList.add("nocursor")}function d(e){switch(r.type){case"right":var s=c[0]-e.x,i=r.root.offsetWidth+s;r.root.style.width=i+"px";break;case"left":s=c[0]-e.x,i=Math.min(document.body.clientWidth-t.DEFAULT_SPLITBAR_SIZE,r.root.offsetWidth-s);r.root.style.width=i+"px",r.splitBar.style.left=i+t.DEFAULT_SPLITBAR_SIZE/2+"px";break;case"top":s=c[1]-e.y,i=Math.min(document.body.clientHeight-t.DEFAULT_SPLITBAR_SIZE,r.root.offsetHeight-s);r.root.style.height=i+"px",r.splitBar.style.top=i+t.DEFAULT_SPLITBAR_SIZE/2+"px";break;case"bottom":s=c[1]-e.y,i=r.root.offsetHeight+s;r.root.style.height=i+"px"}c[0]=e.x,c[1]=e.y,e.stopPropagation(),e.preventDefault(),r.onresize&&r.onresize(r.root.getBoundingClientRect())}function u(e){const t=r.root.ownerDocument;t.removeEventListener("mousemove",d),t.removeEventListener("mouseup",u),document.body.classList.remove("nocursor"),r.splitBar.classList.remove("nocursor")}}}}attach(e){if(this.sections.length)return void this.sections[1].attach(e);if(!e)throw"no content to attach";e.parent=this;let t=e.root?e.root:e;this.root.appendChild(t)}setLayout(e){if(this.layout=t.deepCopy(e),!e.splits)return void console.warn("Area layout has no splits!");const s=(e,t)=>{if(t.className&&(e.root.className+=` ${t.className}`),!t.splits)return;const i=t.type??"horizontal",o=t.resize??!0,n=t.minimizable??!1,[a,l]=e.split({type:i,resize:o,minimizable:n,sizes:[t.splits[0].size,t.splits[1].size]});s(a,t.splits[0]),s(l,t.splits[1])};s(this,e)}split(s={}){this.sections.length&&(this.offset=this.root.childNodes[0].offsetHeight,this._root=this.sections[0].root,this.root=this.sections[1].root);const i=s.type??"horizontal",o=s.sizes||["50%","50%"],n="auto"===s.sizes||s.sizes&&"auto"==s.sizes[0]&&"auto"==s.sizes[1],a=this.root.getBoundingClientRect();if(!o[1]||"auto"!=o[0]&&"auto"==o[1]){let e=o[0],t=s.top?s.top:0;e.constructor==Number&&(e+=t,e=`${e}px`),o[1]="calc( 100% - "+e+" )"}let l=s.minimizable??!1,r=(s.resize??!0)||l,c=s.fixedSize??!r,h=0,d=[],u=[];if(this.offset=0,r&&(this.resize=r,this.splitBar=document.createElement("div"),this.splitBar.className="lexsplitbar "+i,"horizontal"==i?this.splitBar.style.width=t.DEFAULT_SPLITBAR_SIZE+"px":this.splitBar.style.height=t.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.addEventListener("mousedown",function(e){const t=g.root.ownerDocument;t.addEventListener("mousemove",f),t.addEventListener("mouseup",C),e.stopPropagation(),e.preventDefault()}),h=t.DEFAULT_SPLITBAR_SIZE/2),"horizontal"==i){if(this.root.style.display="flex",c)d[0]=`calc(${o[0]} - ${h}px)`,u[0]=`calc(${o[1]} - ${h}px)`;else{const e=a.width,s=t.parsePixelSize(o[0],e)/e*100,i=t.parsePixelSize(o[1],e)/e*100;d[0]=`calc(${s}% - ${h}px)`,u[0]=`calc(${i}% - ${h}px)`}d[1]="100%",u[1]="100%"}else{if(n)d[1]="auto",u[1]="auto";else if(c)d[1]="auto"==o[0]?"auto":`calc(${o[0]} - ${h}px)`,u[1]="auto"==o[1]?"auto":`calc(${o[1]} - ${h}px)`;else{const e=a.height,s=t.parsePixelSize(o[0],e)/e*100,i=t.parsePixelSize(o[1],e)/e*100;d[1]="auto"==o[0]?"auto":`calc(${s}% - ${h}px)`,u[1]="auto"==o[1]?"auto":`calc(${i}% - ${h}px)`}d[0]="100%",u[0]="100%"}let p=new e({width:d[0],height:d[1],skipAppend:!0,className:"split"+(s.menubar||s.sidebar?"":" origin")}),m=new e({width:u[0],height:u[1],skipAppend:!0,className:"split"});if(!(c||a.width&&a.height)){const e=new ResizeObserver(s=>{console.assert(1==s.length,"AreaResizeObserver: more than one entry");const a=s[0].contentRect;if(a.width&&a.height){if(this._update([a.width,a.height],!1),!n){if("horizontal"==i){const e=a.width,s=t.parsePixelSize(o[0],e)/e*100,i=t.parsePixelSize(o[1],e)/e*100;d[0]=`calc(${s}% - ${h}px)`,u[0]=`calc(${i}% - ${h}px)`}else{const e=a.height,s=t.parsePixelSize(o[0],e)/e*100,i=t.parsePixelSize(o[1],e)/e*100;d[1]="auto"==o[0]?"auto":`calc(${s}% - ${h}px)`,u[1]="auto"==o[1]?"auto":`calc(${i}% - ${h}px)`}p.root.style.width=d[0],p.root.style.height=d[1],m.root.style.width=u[0],m.root.style.height=u[1]}p._update(),m._update(),e.disconnect()}});t.doAsync(()=>{e.observe(this.root)},100)}if(n&&"vertical"==i&&(this._autoVerticalResizeObserver=new ResizeObserver(e=>{for(const s of e){const e=t.getComputedSize(s.target);m.root.style.height="calc(100% - "+e.height+"px )"}}),this._autoVerticalResizeObserver.observe(p.root)),r&&l&&(this.splitExtended=!1,m.root.addEventListener("animationend",e=>{const s=getComputedStyle(m.root).opacity;m.root.classList.remove(e.animationName+"-"+i),m.root.style.opacity=s,t.flushCss(m.root)}),this.splitBar.addEventListener("contextmenu",e=>{e.preventDefault(),t.addContextMenu(null,e,e=>{e.add("Extend",{disabled:this.splitExtended,callback:()=>{this.extend()}}),e.add("Reduce",{disabled:!this.splitExtended,callback:()=>{this.reduce()}})})})),p.parentArea=this,m.parentArea=this,this.root.appendChild(p.root),r&&this.root.appendChild(this.splitBar),this.root.appendChild(m.root),this.sections=[p,m],this.type=i,this._update(a.width||a.height?[a.width,a.height]:void 0),!r)return this.sections;const g=this;function f(e){const t=g.root.getBoundingClientRect();e.x<t.x||e.x>t.x+t.width||e.y<t.y||e.y>t.y+t.height||("horizontal"==g.type?g._moveSplit(-e.movementX):g._moveSplit(-e.movementY),e.stopPropagation(),e.preventDefault())}function C(e){const t=g.root.ownerDocument;t.removeEventListener("mousemove",f),t.removeEventListener("mouseup",C)}return this.sections}setLimitBox(e=0,t=0,s=1/0,i=1/0){this.minWidth=e,this.minHeight=t,this.maxWidth=s,this.maxHeight=i,0!=e&&(this.root.style.minWidth=`${e}px`),0!=t&&(this.root.style.minHeight=`${t}px`),s!=1/0&&(this.root.style.maxWidth=`${s}px`),i!=1/0&&(this.root.style.maxHeight=`${i}px`)}setSize(e){let[s,i]=e;null!=s&&s.constructor==Number&&(s=`${s}px`),null!=i&&i.constructor==Number&&(i=`${i}px`),s&&(this.root.style.width=s),i&&(this.root.style.height=i),this.onresize&&this.onresize(this.root.getBoundingClientRect()),t.doAsync(()=>{this.size=[this.root.clientWidth,this.root.clientHeight],this.propagateEvent("onresize")},150)}extend(){if(this.splitExtended)return;let[e,s]=this.sections;this.splitExtended=!0,e.root.classList.add(`maximize-${this.type}`),s.root.classList.add(`minimize-${this.type}`),s.root.classList.add(`fadeout-${this.type}`),s.root.classList.remove(`fadein-${this.type}`),"vertical"==this.type?(this.offset=s.root.offsetHeight,this._moveSplit(-1/0,!0)):(this.offset=s.root.offsetWidth-8,this._moveSplit(-1/0,!0,8)),t.doAsync(()=>{this.propagateEvent("onresize")},100)}reduce(){if(!this.splitExtended)return;this.splitExtended=!1;let[e,s]=this.sections;e.root.classList.add(`minimize-${this.type}`),s.root.classList.add(`maximize-${this.type}`),s.root.classList.add(`fadein-${this.type}`),s.root.classList.remove(`fadeout-${this.type}`),this._moveSplit(this.offset),t.doAsync(()=>{this.propagateEvent("onresize")},100)}hide(){this.root.classList.add("hidden")}show(){this.root.classList.remove("hidden")}toggle(e){this.root.classList.toggle("hidden",e)}propagateEvent(e){for(let t=0;t<this.sections.length;t++){const s=this.sections[t];s[e]&&s[e].call(this,s.root.getBoundingClientRect()),s.propagateEvent(e)}}addPanel(e){let t=new ee(e);return this.attach(t),this.panels.push(t),t}addMenubar(e,s={}){let i=new r(e,s);t.menubars.push(i);const[o,n]=this.split({type:"vertical",sizes:["48px",null],resize:!1,menubar:!0});return i.siblingArea=n,o.attach(i),o.isMenubar=!0,(s.sticky??1)&&(o.root.className+=" sticky top-0 z-1000"),s.parentClass&&(o.root.className+=` ${s.parentClass}`),i}addSidebar(e,s={}){let i=new t.Sidebar({callback:e,...s});e&&e(i),i.update(),t.sidebars.push(i);const o=s.side??"left";console.assert("left"==o||"right"==o,"Invalid sidebar side: "+o);const n="left"==o,a=s.width??"16rem",l=n?[a,null]:[null,a],[r,c]=this.split({type:"horizontal",sizes:l,resize:!1,sidebar:!0});i.siblingArea=n?c:r;let h=n?r:c;return h.attach(i),h.isSidebar=!0,s.parentClass&&(h.root.className+=` ${s.parentClass}`),i}addOverlayButtons(e,t={}){return this.sections.length?this.sections[1].addOverlayButtons(e,t):(console.assert(e.constructor==Array&&0!==e.length),this.root.style.position="relative",this.overlayButtons=new te(this,e,t),this.overlayButtons)}addTabs(e={}){const t=new c(this,e);return e.folding&&(this.parentArea?._disableSplitResize(),this.root.style.paddingTop="4px"),t}_moveSplit(e,s=!1,i=0){if(!this.type)throw"No split area";if(void 0===e)return;this._autoVerticalResizeObserver&&this._autoVerticalResizeObserver.disconnect();const o=this.sections[0];var n=o.root;n.classList.contains("origin")||(n=n.parentElement);const a=this.sections[1],l=a.root,r="- "+t.DEFAULT_SPLITBAR_SIZE+"px";let c=null;if(s||(c=n.style.transition,n.style.transition=l.style.transition="none"),"horizontal"==this.type){var h=Math.max(l.offsetWidth+e,parseInt(a.minWidth));i&&(h=i);const t=h/this.size[0]*100,s=Math.max(0,100-t);n.style.width=`-moz-calc(${s}% ${r})`,n.style.width=`-webkit-calc( ${s}% ${r})`,n.style.width=`calc( ${s}% ${r})`,l.style.width=`${t}%`,l.style.width=`${t}%`,l.style.width=`${t}%`,o.maxWidth!=1/0&&(l.style.minWidth=`calc( 100% - ${parseInt(o.maxWidth)}px )`)}else{const s=this.size[1];h=Math.max(l.offsetHeight+e+a.offset,parseInt(a.minHeight));h=Math.min(s-t.DEFAULT_SPLITBAR_SIZE,h),i&&(h=i);const c=h/s*100,d=Math.max(0,100-c);n.style.height=`-moz-calc(${d}% ${r})`,n.style.height=`-webkit-calc( ${d}% ${r})`,n.style.height=`calc( ${d}% ${r})`,l.style.height=`${c}%`,l.style.height=`${c}%`,l.style.height=`${c}%`,o.maxHeight!=1/0&&(l.style.minHeight=`calc( 100% - ${parseInt(o.maxHeight)}px )`)}s||(n.style.transition=l.style.transition=c),t.doAsync(()=>{this._update(),this.propagateEvent("onresize")},10)}_disableSplitResize(){this.resize=!1,this.splitBar.remove(),delete this.splitBar}_update(e,t=!0){if(e)this.size=e;else{const e=this.root.getBoundingClientRect();this.size=[e.width,e.height]}if(t)for(var s=0;s<this.sections.length;s++)this.sections[s]._update()}};function ie(e,s=!0){e="light"==e?"light":"dark",document.documentElement.setAttribute("data-theme",e),s&&localStorage.setItem("lxColorScheme",e),t.emitSignal("@on_new_color_scheme",e)}function oe(){return document.documentElement.getAttribute("data-theme")??"dark"}function ne(e){if(!/^#(?:[A-Fa-f0-9]{3,4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e))throw`Invalid Hex Color: ${e}`;3!==(e=e.replace(/^#/,"")).length&&4!==e.length||(e=e.split("").map(e=>e+e).join(""));const t=parseInt(e,16);return{r:(t>>(8===e.length?24:16)&255)/255,g:(t>>(8===e.length?16:8)&255)/255,b:(t>>(8===e.length?8:0)&255)/255,a:(8===e.length?255&t:4===e.length?parseInt(e.slice(-2),16):255)/255}}function ae(e){let{r:t,g:s,b:i,a:o}=e;o=o??1;const n=Math.max(t,s,i),a=n-Math.min(t,s,i);let l=0;0!==a&&(l=n===t?(s-i)/a%6:n===s?(i-t)/a+2:(t-s)/a+4,l*=60,l<0&&(l+=360));return{h:l,s:0===n?0:a/n,v:n,a:o}}t.Area=se,t.clamp=function(e,t,s){return Math.min(Math.max(e,t),s)},t.round=function(e,t){return 0==t?Math.floor(e):+e.toFixed(t??2).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,"$1")},t.remapRange=function(e,t,s,i,o){return(e-t)*(o-i)/(s-t)+i},"undefined"!=typeof performance?t.getTime=performance.now.bind(performance):"undefined"!=typeof Date&&Date.now?t.getTime=Date.now.bind(Date):t.getTime=function(){return(new Date).getTime()},t.doAsync=function(e,t){setTimeout(e,t??0)},t.flushCss=function(e){e.offsetHeight},t.deleteElement=function(e){e&&e.remove()},t.toCamelCase=function(e){return e.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(e,t)=>t.toUpperCase())},t.toTitleCase=function(e){return e.replace(/-/g," ").toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())},t.toKebabCase=function(e){return e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())},t.getSupportedDOMName=function(e){console.assert("string"==typeof e,"getSupportedDOMName: Text is not a string!");let t=e.trim();return t=t.replace(/@/g,"_at_").replace(/\+/g,"_plus_").replace(/\./g,"_dot_"),t=t.replace(/[^a-zA-Z0-9_-]/g,"_"),/^[0-9]/.test(t)&&(t="_"+t),t},t.has=function(e){return t.extensions.indexOf(e)>-1},t.getExtension=function(e){return e.includes(".")?e.split(".").pop():null},t.stripHTML=function(e){const t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||""},t.stripTags=function(e,t){t=(((t||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join("");const s=/<\/?([a-z0-9]*)\b[^>]*>?/gi,i=/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;let o=e;for(o="<"===o.substring(o.length-1)?o.substring(0,o.length-1):o;;){const e=o;if(o=e.replace(i,"").replace(s,function(e,s){return t.indexOf("<"+s.toLowerCase()+">")>-1?e:""}),e===o)return o}},t.parsePixelSize=function e(t,s){if(t.constructor===Number)return t;if(t.constructor===String){const i=parseFloat(t);if(t.endsWith("px"))return i;if(t.endsWith("%"))return i/100*s;if(t.endsWith("rem")||t.endsWith("em")){return i*16}if(t.endsWith("vw"))return i/100*window.innerWidth;if(t.endsWith("vh"))return i/100*window.innerHeight;if(t.startsWith("calc(")){const i=t.slice(5,-1).split(/([+\-])/);let o=0,n="+";for(let t of i)if(t=t.trim(),"+"===t||"-"===t)n=t;else{let i=e(t,s);o="+"===n?o+i:o-i}return o}}throw"Bad size format!"},t.deepCopy=function(e){return JSON.parse(JSON.stringify(e))},t.concatTypedArray=function(e,t){let s=new t(e.reduce((e,t)=>e+t.length,0)),i=0;for(let t=0;t<e.length;++t)s.set(e[t],i),i+=e[t].length;return s},t.setTheme=ie,t.getTheme=oe,t.switchTheme=function(){ie("dark"==oe()?"light":"dark")},t.setSystemTheme=function(){ie(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"),localStorage.removeItem("lxColorScheme"),t._mqlPrefersDarkScheme&&(t._mqlPrefersDarkScheme.removeEventListener("change",t._onChangeSystemTheme),t._mqlPrefersDarkScheme.addEventListener("change",t._onChangeSystemTheme))},t.setThemeColor=function(e,t){document.querySelector(":root").style.setProperty("--"+e,t)},t.getThemeColor=function(e){const t=document.querySelector(":root"),s=getComputedStyle(t),i=s.getPropertyValue("--"+e);if(i.includes("light-dark")){return"light"==s.getPropertyValue("color-scheme")?i.substring(i.indexOf("(")+1,i.indexOf(",")).replace(/\s/g,""):i.substring(i.indexOf(",")+1,i.indexOf(")")).replace(/\s/g,"")}return i},t.switchSpacing=function(){const e=document.documentElement.getAttribute("data-spacing")??"default";document.documentElement.setAttribute("data-spacing","default"==e?"compact":"default"),t.emitSignal("@on_new_spacing_layout",e)},t.getBase64Image=function(e){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");return s&&s.drawImage(e,0,0),t.toDataURL("image/png")},t.hexToRgb=ne,t.hexToHsv=function(e){return ae(ne(e))},t.rgbToHex=function(e,t=255){const s=[e.r,e.g,e.b];return null!=e.a&&s.push(e.a),"#"+s.map(e=>{const s=(e=Math.floor(e*t)).toString(16);return 1===s.length?"0"+s:s}).join("")},t.rgbToCss=function(e){return{r:Math.floor(255*e.r),g:Math.floor(255*e.g),b:Math.floor(255*e.b),a:e.a}},t.rgbToHsv=ae,t.hsvToRgb=function(e){const{h:t,s:s,v:i,a:o}=e,n=i*s,a=n*(1-Math.abs(t/60%2-1)),l=i-n;let r=0,c=0,h=0;return t<60?(r=n,c=a,h=0):t<120?(r=a,c=n,h=0):t<180?(r=0,c=n,h=a):t<240?(r=0,c=a,h=n):t<300?(r=a,c=0,h=n):(r=n,c=0,h=a),{r:r+l,g:c+l,b:h+l,a:o}},t.dateFromDateString=function(e){const t=e.split("/"),s=parseInt(t[0]),i=parseInt(t[1]),o=parseInt(t[2]);return new Date(`${i}/${s}/${o}`)},t.measureRealWidth=function(e,s=8){var i=document.createElement("span");i.className="lexinputmeasure",i.innerHTML=e,document.body.appendChild(i);var o=i.getBoundingClientRect();return t.deleteElement(i),o.width+s},t.guidGenerator=function(){var e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+"-"+e()+"-"+e()},t.escapeRegExp=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},t.wildcardToRegExp=function(e){const t=e.replace(/([.+^${}()|[\]\\])/g,"\\$1").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp("^"+t+"$","i")},t.buildTextPattern=function(e={}){let t=[];e.lowercase&&t.push("(?=.*[a-z])"),e.uppercase&&t.push("(?=.*[A-Z])"),e.digit&&t.push("(?=.*\\d)"),e.specialChar&&t.push("(?=.*[@#$%^&+=!])"),e.noSpaces&&t.push("(?!.*\\s)"),e.email&&t.push("(^[^s@]+@[^s@]+.[^s@]+$)");let s=e.minLength||0,i=e.maxLength||"",o=`^${t.join("")}.{${s},${i}}$`;return e.asRegExp?new RegExp(o):o},t.validateValueAtPattern=function(e,t={},...s){const i=[],o=t.minLength||0,n=t.maxLength;return e.length<o?i.push(`Must be at least ${o} characters long.`):void 0!==n&&e.length>n&&i.push(`Must be no more than ${n} characters long.`),t.lowercase&&!/[a-z]/.test(e)&&i.push("Must contain at least one lowercase letter (a-z)."),t.uppercase&&!/[A-Z]/.test(e)&&i.push("Must contain at least one uppercase letter (A-Z)."),t.digit&&!/\d/.test(e)&&i.push("Must contain at least one number (0-9)."),t.noSpaces&&/\s/.test(e)&&i.push("Must NOT contain any spaces."),t.specialChar&&!/[@#$%^&+=!]/.test(e)&&i.push("Must contain at least one special character (e.g., @, #, $, %, ^, &, +, =, !)."),t.email&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)&&i.push("Must have a valid email format."),t.fieldMatchName&&e!==s[0]&&i.push(`Must match ${t.fieldMatchName} field.`),i},t.makeDraggable=function(e,s={}){let i=0,o=0,n=null,a=s.targetClass,l=s.dragMargin??3,r=(s,n,a)=>{const r=e.parentElement?e.parentElement.getBoundingClientRect():{x:0,y:0,width:0,height:0},c="fixed"==e.style.position?new O(r.x,r.y):new O;a=a??s.clientX-i-r.x,n=n??s.clientY-o-r.y,e.style.left=t.clamp(a,l+c.x,c.x+r.width-e.offsetWidth-l)+"px",e.style.top=t.clamp(n,l+c.y,c.y+r.height-e.offsetHeight-l)+"px",e.style.translate="none"};s.autoAdjust&&r(null,parseInt(e.style.left),parseInt(e.style.top));let c=t.guidGenerator();e["draggable-id"]=c;let h=s.onMove?e=>{n&&s.onMove&&s.onMove(n)}:e=>{n&&r(e)},d=s.onDragStart;e.setAttribute("draggable","true"),e.addEventListener("mousedown",function(e){n=e.target.classList.contains(a)||!a?e.target:null}),e.addEventListener("dragstart",function(a){if(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation(),!n)return;var l=new Image;l.src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=",a.dataTransfer&&(a.dataTransfer.setDragImage(l,0,0),a.dataTransfer.effectAllowed="move");const r=a.target.getBoundingClientRect(),c=n.parentElement.getBoundingClientRect(),u="fixed"==n.style.position?new O(c.x,c.y):new O;i=a.clientX-r.x-u.x,o=a.clientY-r.y-u.y,document.addEventListener("mousemove",h),n.eventCatched=!0,(s.updateLayers??1)&&(t.activeDraggable&&(t.activeDraggable.style.zIndex=t.DRAGGABLE_Z_INDEX),t.activeDraggable=e,t.activeDraggable.style.zIndex=t.DRAGGABLE_Z_INDEX+1),d&&d(n,a)},!1),document.addEventListener("mouseup",e=>{n&&(n=null,document.removeEventListener("mousemove",h))})},t.makeCollapsible=function(e,s,i,o={}){e.classList.add("collapsible");const n=o.collapsed??!0,a=t.makeIcon("Right");a.classList.add("collapser"),n&&(a.dataset.collapsed=`${n}`),a.style.marginLeft="auto",a.style.marginRight="0.2rem",a.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),this.dataset.collapsed?(delete this.dataset.collapsed,s.style.display=o.display??"block"):(this.dataset.collapsed="true",s.style.display="none")}),e.appendChild(a),(i=i??e.parentElement).appendChild(s)},t.makeCodeSnippet=function(e,s,i={}){if(!t.has("CodeEditor"))return void console.error("Import the CodeEditor component to create snippets!");const o=document.createElement("div");o.className="lexcodesnippet "+(i.className??""),o.style.width=s?s[0]:"auto",o.style.height=s?s[1]:"auto";const n=new se({xskipAppend:!0});return new t.CodeEditor(n,{skipInfo:!0,disableEdition:!0,allowAddScripts:!1,name:i.tabName,callback:t=>{if(t.setText(e,i.language??"Plain Text"),i.linesAdded){const e=t.root.querySelector(".code");for(let t of i.linesAdded){const s=t;if(s.constructor==Number)e.childNodes[s-1].classList.add("added");else if(s.constructor==Array)for(let t=s[0]-1;t<=s[1]-1;t++)e.childNodes[t].classList.add("added")}}if(i.linesRemoved){const e=t.root.querySelector(".code");for(let t of i.linesRemoved){const s=t;if(s.constructor==Number)e.childNodes[s-1].classList.add("removed");else if(s.constructor==Array)for(let t=s[0]-1;t<=s[1]-1;t++)e.childNodes[t].classList.add("removed")}}if(i.windowMode){const e=document.createElement("div");e.className="lexwindowbuttons";const s=document.createElement("span");s.style.background="#ee4f50";const i=document.createElement("span");i.style.background="#f5b720";const o=document.createElement("span");o.style.background="#53ca29",e.appendChild(s),e.appendChild(i),e.appendChild(o);t.root.querySelector(".lexareatabs").prepend(e)}(i.lineNumbers??1)||t.root.classList.add("no-gutter")}}),o.appendChild(n.root),o},t.makeKbd=function(e,s=!0,i=""){const o={Ctrl:"⌃",Enter:"↩",Shift:"⇧",CapsLock:"⇪",Meta:"⌘",Option:"⌥",Alt:"⌥",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Space:"␣"},n=t.makeContainer(["auto","auto"],"flex flex-row ml-auto");for(const a of e)t.makeContainer(["auto","auto"],"self-center text-xs fg-secondary select-none "+i,s?o[a]??a:a,n);return n},t.makeBreadcrumb=function(e,s={}){const i=t.makeContainer(["auto","auto"],"flex flex-row gap-1"),o=s.separatorIcon??"ChevronRight",n=s.maxItems??4,a=e.length-n;if(a>0){const t={title:"...",ellipsis:e.splice(1,a+1).map(e=>e.title).join("/")};e.splice(1,0,t)}for(let s=0;s<e.length;++s){const n=e[s];if(console.assert(n.title,"Breadcrumb item must have a title!"),0!=s){const e=t.makeIcon(o,{svgClass:"sm fg-secondary separator"});i.appendChild(e)}const a=s==e.length-1,l=t.makeContainer(["auto","auto"],"p-1 flex flex-row gap-1 items-center "+(a?"":"fg-secondary"));i.appendChild(l);let r=t.makeElement("p","",n.title);if(n.icon&&l.appendChild(t.makeIcon(n.icon,{svgClass:"sm"})),void 0!==n.items){const e=t.makeContainer(["auto","auto"],""+(a?"":"fg-secondary"));t.listen(e,"click",e=>{t.addDropdownMenu(e.target,n.items,{side:"bottom",align:"start"})}),e.append(r),l.appendChild(e)}else if(void 0!==n.url){let e=t.makeElement("a","decoration-none fg-"+(a?"primary":"secondary"),"",l);e.href=n.url,e.appendChild(r)}else l.appendChild(r);n.ellipsis&&t.asTooltip(l,n.ellipsis,{side:"bottom",offset:4})}return i},t.makeIcon=function(e,s={}){let i=null;const o=t=>{s.svgClass&&s.svgClass.length&&s.svgClass.split(" ").forEach(e=>t.classList.add(e));const i=document.createElement("a");return i.title=s.title??"",i.className="lexicon "+(s.iconClass??""),i.appendChild(t),t.dataset.name=e,i};if(e.includes("@")){const t=e.split("@");e=t[0],s.variant=t[1]}let n=t.ICONS[e];const a=window.lucide,l=a[e]??a[t.LucideIconAlias[e]];if(n){n.constructor!=Array&&(n=t.ICONS[n]);const a=s.variant??"regular";n=("solid"==a?t.ICONS[`${e}@solid`]:n)??n;const r=n[3];if(a==r||!l||"regular"==r){if(i=document.createElementNS("http://www.w3.org/2000/svg","svg"),i.setAttribute("viewBox",`0 0 ${n[0]} ${n[1]}`),n[5]){const e=n[5].svgClass;e?.split(" ").forEach(e=>{i.classList.add(e)});const t=n[5].svgAttributes;t?.split(" ").forEach(e=>{const t=e.split("=");i.setAttribute(t[0],t[1])})}const e=document.createElement("path");if(e.setAttribute("fill","currentColor"),e.setAttribute("d",n[4]),i.appendChild(e),n[5]){const t=n[5].pathClass;t?.split(" ").forEach(t=>{e.classList.add(t)});const s=n[5].pathAttributes;s?.split(" ").forEach(t=>{const s=t.split("=");e.setAttribute(s[0],s[1])})}const t="\x3c!-- This icon might belong to a collection from Iconify - https://iconify.design/ - or !Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc. --\x3e";return i.innerHTML+=t,o(i)}}return console.assert(l,`No existing icon named _${e}_`),i=a.createElement(l,s),o(i)},t.registerIcon=function(e,s,i="none",o=[]){const n=(new DOMParser).parseFromString(s,"image/svg+xml").documentElement,a=n.querySelector("path"),l=n.getAttribute("viewBox").split(" "),r=a.getAttribute("d");let c=[],h=[];for(const e of n.attributes)switch(e.name){case"transform":case"fill":case"stroke-width":case"stroke-linecap":case"stroke-linejoin":c.push(`${e.name}=${e.value}`)}for(const e of a.attributes)switch(e.name){case"transform":case"fill":case"stroke-width":case"stroke-linecap":case"stroke-linejoin":h.push(`${e.name}=${e.value}`)}const d=[parseInt(l[2]),parseInt(l[3]),o,i,r,{svgAttributes:c.length?c.join(" "):null,pathAttributes:h.length?h.join(" "):null}];t.ICONS[e]&&console.warn(`${e} will be added/replaced in LX.ICONS`),t.ICONS[e]=d},t.registerCommandbarEntry=function(e,s){t.extraCommandbarEntries.push({name:e,callback:s})},t.message=function(e,s,i={}){if(!e)throw"No message to show";return i.modal=!0,new t.Dialog(s,t=>{t.addTextArea(null,e,null,{disabled:!0,fitHeight:!0})},i)},t.popup=function(e,s,i={}){if(!e)throw"No message to show";i.size=i.size??["max-content","auto"],i.class="lexpopup";const o=i.timeout||3e3,n=new t.Dialog(s,t=>{t.addTextArea(null,e,null,{disabled:!0,fitHeight:!0})},i);return setTimeout(()=>{n.close()},Math.max(o,150)),n},t.prompt=function e(s,i,o,n={}){n.modal=!0,n.className="prompt";let a="";const l=new t.Dialog(i,r=>{r.addTextArea(null,s,null,{disabled:!0,fitHeight:!0}),(n.input??1)&&r.addText(null,n.input||a,e=>a=e,{placeholder:"..."}),r.sameLine(2),r.addButton(null,"Cancel",()=>{n.on_cancel&&n.on_cancel(),l.close()}),r.addButton(null,n.accept||"Continue",()=>{n.required&&""===a?(s+=s.includes("You must fill the input text.")?"":"\nYou must fill the input text.",l.close(),e(s,i,o,n)):(o&&o.call(t,a),l.close())},{buttonClass:"primary"})},n);return(n.input??1)&&l.root.querySelector("input").focus(),l},t.toast=function(e,s,i={}){if(!e)throw"The toast needs at least a title!";const o=t.notifications;console.assert(o);const n=document.createElement("li");n.className="lextoast",o.prepend(n);const[a,l]=i.position?i.position.split("-"):["bottom","right"];switch(o.style.right="unset",o.style.left="unset",o.style.top="unset",o.style.bottom="unset",o.style.placeSelf="unset",a){case"top":n.style.translate="0 -30px",o.style.top="1rem",o.style.flexDirection="column";break;case"bottom":n.style.translate="0 calc(100% + 30px)",o.style.top="auto",o.style.bottom="1rem",o.style.flexDirection="column-reverse"}switch(l){case"left":o.style.left="1rem";break;case"center":o.style.placeSelf="center";break;case"right":o.style.right="1rem"}n.classList.add(a),n.classList.add(l),t.doAsync(()=>{o.offsetWidth>o.iWidth&&(o.iWidth=Math.min(o.offsetWidth,480),o.style.width=o.iWidth+"px"),n.dataset.open=!0},10);const r=document.createElement("div");r.className="lextoastcontent",n.appendChild(r);const c=document.createElement("div");if(c.className="title",c.innerHTML=e,r.appendChild(c),s){const e=document.createElement("div");e.className="desc",e.innerHTML=s,r.appendChild(e)}if(i.action){const e=new ee;e.addButton(null,i.action.name??"Accept",i.action.callback.bind(t,n),{width:"auto",maxWidth:"150px",className:"right",buttonClass:"border"}),n.appendChild(e.root.childNodes[0])}if(n.close=function(){this.dataset.open="false",t.doAsync(()=>{this.remove(),t.notifications.childElementCount||(t.notifications.style.width="unset",t.notifications.iWidth=0)},500)},i.closable??1){const e=t.makeIcon("X",{iconClass:"closer"});e.addEventListener("click",()=>{n.close()}),n.appendChild(e)}const h=i.timeout??3e3;-1!=h&&t.doAsync(()=>{n.close()},h)},t.badge=function(e,s,i={}){const o=document.createElement("div");if(o.innerHTML=e,o.className="lexbadge "+(s??""),i.chip&&o.classList.add("chip"),Object.assign(o.style,i.style??{}),i.callback){const e=t.makeIcon("ArrowUpRight",{svgClass:"xs fg-contrast"});e.querySelector("svg").style.marginLeft="-0.25rem",o.innerHTML+=e.innerHTML,o.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),i.callback()})}return i.parent&&(i.parent.classList.add("lexbadge-parent"),i.parent.appendChild(o)),i.asElement?o:o.outerHTML},t.makeElement=function(e,t,s,i,o={}){const n=document.createElement(e);return n.className=t??"",n.innerHTML=s??"",Object.assign(n.style,o),i&&(i.attach?i.attach(n):i.appendChild(n)),n},t.makeContainer=function(e,s,i,o,n={}){const a=t.makeElement("div","lexcontainer "+(s??""),i,o,n);return a.style.width=e&&e[0]?e[0]:"100%",a.style.height=e&&e[1]?e[1]:"100%",a},t.asTooltip=function(e,s,i={}){console.assert(e,"You need a trigger to generate a tooltip!"),e.dataset.disableTooltip=!(i.active??1);let o=null;const n=i.offset,a=i.offsetX??n??0,l=i.offsetY??n??6;e.addEventListener("mouseenter",function(n){if("true"==e.dataset.disableTooltip)return;o=document.createElement("div"),o.className="lextooltip",o.innerHTML=e.dataset.tooltipContent??s;const r=e.closest("dialog"),c=r??t.root;t.root.querySelectorAll(".lextooltip").forEach(e=>e.remove()),c.appendChild(o),t.doAsync(()=>{const s=[0,0],n=parseFloat(e.dataset.tooltipOffsetX??a),h=parseFloat(e.dataset.tooltipOffsetY??l),d=e.getBoundingClientRect();let u=!0;switch(i.side??"top"){case"left":s[0]+=d.x-o.offsetWidth-n,u=!1;break;case"right":s[0]+=d.x+d.width+n,u=!1;break;case"top":s[1]+=d.y-o.offsetHeight-h,u=!0;break;case"bottom":s[1]+=d.y+d.height+h,u=!0}if(u?s[0]+=d.x+.5*d.width-.5*o.offsetWidth+n:s[1]+=d.y+.5*d.height-.5*o.offsetHeight+h,s[0]=t.clamp(s[0],0,window.innerWidth-o.offsetWidth-4),s[1]=t.clamp(s[1],0,window.innerHeight-o.offsetHeight-4),r){let e=c.getBoundingClientRect();s[0]-=e.x,s[1]-=e.y}o.style.left=`${s[0]}px`,o.style.top=`${s[1]}px`,i.callback&&i.callback(o,e)})}),e.addEventListener("mouseleave",function(e){o&&o.remove()})},t.insertChildAtIndex=function(e,t,s=1/0){s>=e.children.length?e.appendChild(t):e.insertBefore(t,e.children[s])},t.getComputedSize=function(e){return{width:e.offsetWidth,height:e.offsetHeight}},t.listen=function(e,t,s,i){e[i=i??"_on"+t]=s,e.addEventListener(t,s)},t.ignore=function(e,t,s){const i=e[s=s??"_on"+t];e.removeEventListener(t,i)},t.getParentArea=function(e){let t=e.parentElement;for(;t;){if(t.classList.contains("lexarea"))return t;t=t.parentElement}},t.hasClass=function(e,t){return!!(t=[].concat(t)).filter(t=>e.classList.contains(t)).length},t.addClass=function(e,t){t&&e.classList.add(t)},t.removeClass=function(e,t){t&&e.classList.remove(t)},t.toggleClass=function(e,t,s){t&&e.classList.toggle(t,s)},t.lastChar=function(e){return e[e.length-1]},Object.assign(t,{request(e){var t=e.dataType||"text";"json"==t||"xml"==t?t="text":"binary"==t&&(t="arraybuffer",e.mimeType="application/octet-stream");var s=new XMLHttpRequest;s.open(e.data?"POST":"GET",e.url,!0),t&&(s.responseType=t),e.mimeType&&s.overrideMimeType(e.mimeType),e.nocache&&s.setRequestHeader("Cache-Control","no-cache"),s.onload=function(t){var s=this.response;if(200==this.status){if("json"==e.dataType)try{s=JSON.parse(s)}catch(i){if(!e.error)throw i;e.error(i)}else if("xml"==e.dataType)try{s=(new DOMParser).parseFromString(s,"text/xml")}catch(i){if(!e.error)throw i;e.error(i)}e.success&&e.success.call(this,s,this)}else{var i="Error "+this.status;e.error&&e.error(i)}},s.onerror=function(t){e.error&&e.error(t)};var i=new FormData;if(e.data)for(var o in e.data)i.append(o,e.data[o]);return s.send(i),s},requestText(e,t,s){return this.request({url:e,dataType:"text",success:t,error:s})},requestJSON(e,t,s){return this.request({url:e,dataType:"json",success:t,error:s})},requestBinary(e,t,s){return this.request({url:e,dataType:"binary",success:t,error:s})},requireScript(e,t,s,i,o){if(!e)throw"invalid URL";e.constructor===String&&(e=[e]);var n=e.length,a=[];for(var l in e){var r=document.createElement("script");r.num=l,r.type="text/javascript",r.src=e[l]+(o?"?version="+o:""),r.original_src=e[l],r.async=!1,r.onload=function(e){n--,a.push(this),n?i&&i(this.original_src,this.num):t&&t(a)},s&&(r.onerror=function(e){s(e,this.original_src,this.num)}),document.getElementsByTagName("head")[0].appendChild(r)}},loadScriptSync:e=>new Promise((t,s)=>{const i=document.createElement("script");i.src=e,i.async=!1,i.onload=()=>t(1),i.onerror=()=>s(new Error(`Failed to load ${e}`)),document.head.appendChild(i)}),downloadURL(e,s){const i=new FileReader,o=function(e){var t=document.createElement("a");t.href=e,t.download=s,document.body.appendChild(t),t.click(),document.body.removeChild(t)};e.includes("http")?t.request({url:e,dataType:"blob",success:e=>{i.readAsDataURL(e),i.onload=e=>{o(e.currentTarget.result)}}}):o(e)},downloadFile:function(e,t,s){if(t){s||(s=t.constructor===String?"text/plain":"application/octet-stream");var i=null;i=t.constructor!==File&&t.constructor!==Blob?new Blob([t],{type:s}):t;var o=URL.createObjectURL(i),n=document.createElement("a");n.setAttribute("href",o),n.setAttribute("download",e),n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),setTimeout(function(){URL.revokeObjectURL(o)},6e4)}else console.warn("No file provided to download")}}),t.formatBytes=function(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toFixed(2)+" "+["B","KB","MB","GB","TB"][t]},t.compareThreshold=function(e,t,s,i){return Math.abs(e-t)>=i||Math.abs(e-s)>=i},t.compareThresholdRange=function(e,t,s,i){return e>=s&&e<=i||t>=s&&t<=i||e<=s&&t>=i},t.getControlPoints=function(e,t,s,i,o,n,a){var l=Math.sqrt(Math.pow(s-e,2)+Math.pow(i-t,2)),r=a*l/(l+Math.sqrt(Math.pow(o-s,2)+Math.pow(n-i,2))),c=a-r;return[s+r*(e-o),i+r*(t-n),s-c*(e-o),i-c*(t-n)]},t.drawSpline=function(e,s,i){e.save();for(var o=[],n=s.length,a=0;a<n-4;a+=2)o=o.concat(t.getControlPoints(s[a],s[a+1],s[a+2],s[a+3],s[a+4],s[a+5],i));for(a=2;a<s.length-5;a+=2)e.beginPath(),e.moveTo(s[a],s[a+1]),e.bezierCurveTo(o[2*a-2],o[2*a-1],o[2*a],o[2*a+1],s[a+2],s[a+3]),e.stroke(),e.closePath();e.beginPath(),e.moveTo(s[0],s[1]),e.quadraticCurveTo(o[0],o[1],s[2],s[3]),e.stroke(),e.closePath(),e.beginPath(),e.moveTo(s[n-2],s[n-1]),e.quadraticCurveTo(o[2*n-10],o[2*n-9],s[n-4],s[n-3]),e.stroke(),e.closePath(),e.restore()};class le{root;constructor(e={}){const s=e.icon??"LoaderCircle",i=e.size??"md",o=`flex ${e.iconClass??""}`.trim(),n=`animate-spin ${i} ${e.svgClass??""}`.trim();this.root=t.makeIcon(s,{iconClass:o,svgClass:n})}html(){return this.root.innerHTML}destroy(){this.root.remove()}}t.Spinner=le;let re=class e{static _last_id=0;id;root;panel;title;size=[];branchData;close=()=>{};_oncreate;constructor(s,i,o={}){i||console.warn("Content is empty, add some components using 'callback' parameter!"),this._oncreate=i,this.id=t.guidGenerator();const n=o.size??[],a=o.position??[],l=o.draggable??!0,r=o.dockable??!1,c=o.modal??!1;let h=document.createElement("dialog");h.className="lexdialog "+(o.className??""),h.id=o.id??"dialog"+e._last_id++,h.dataset.modal=c,t.root.appendChild(h),t.doAsync(()=>{c?h.showModal():h.show()},10);let d=this;const u=document.createElement("div");if(s&&(u.className="lexdialogtitle",u.innerHTML=s,u.setAttribute("draggable","false"),h.appendChild(u)),o.closable??1){this.close=()=>{o.onBeforeClose&&o.onBeforeClose(this),o.onclose?o.onclose(this.root):(h.close(),t.doAsync(()=>{d.panel.clear(),h.remove()},150))};const e=t.makeIcon("X",{title:"Close",iconClass:"lexdialogcloser"});e.addEventListener("click",this.close);const i=t.makeIcon("Minus",{title:"Dock",iconClass:"ml-auto mr-2"});i.addEventListener("click",()=>{const e=this.branchData,t=e.panel,s=t.root.childElementCount,i=t.branch(e.name,{closed:e.closed});i.components=e.components;for(let e of i.components)i.content.appendChild(e.root);e.childIndex<s&&t.root.insertChildAtIndex(i.root,e.childIndex),this.close()}),s?(r&&u.appendChild(i),u.appendChild(e)):(e.classList.add("notitle"),h.appendChild(e))}const p=new t.Panel;p.root.classList.add("lexdialogcontent"),s||p.root.classList.add("notitle"),i&&i.call(this,p),h.appendChild(p.root),p.root.querySelectorAll(".lexbranch").forEach(e=>e.classList.add("dialog")),this.panel=p,this.root=h,this.title=u,l&&t.makeDraggable(h,Object.assign({targetClass:"lexdialogtitle"},o)),n.length&&"string"!=typeof n[0]&&(n[0]+="px"),n.length&&"string"!=typeof n[1]&&(n[1]+="px"),h.style.width=n[0]?n[0]:"25%",h.style.height=n[1]?n[1]:"auto",h.style.translate=o.position?"unset":"-50% -50%",o.size&&(this.size=n),h.style.left=a[0]??"50%",h.style.top=a[1]??"50%",p.root.style.height=s?"calc( 100% - "+(u.offsetHeight+30)+"px )":"calc(100%)"}destroy(){this.root.remove()}refresh(){this.panel.root.innerHTML="",this._oncreate.call(this,this.panel)}setPosition(e,t){this.root.style.left=`${e}px`,this.root.style.top=`${t}px`}setTitle(e){const t=this.root.querySelector(".lexdialogtitle");t&&(t.innerText=e)}};t.Dialog=re;class ce extends re{constructor(e,s,i,o={}){o.closable=!1,o.draggable=!1,o.modal=!0,super(void 0,n=>{n.root.classList.add("p-4","flex","flex-col","gap-2"),t.makeContainer(["100%","100%"],"text-xl font-medium",e,n),n.addTextArea(null,s,null,{disabled:!0,fitHeight:!0,inputClass:"bg-none fg-tertiary"}),n.sameLine(2,"justify-end"),n.addButton(null,o.cancelText??"Cancel",()=>this.destroy(),{buttonClass:"border bg-primary"}),n.addButton(null,o.continueText??"Continue",()=>{this.destroy(),i&&i()},{buttonClass:"contrast"})},o)}}t.AlertDialog=ce;class he{root;items;colors;_parent;constructor(e,s,i={}){if(document.body.querySelectorAll(".lexcontextmenu").forEach(e=>e.remove()),this.root=document.createElement("div"),this.root.className="lexcontextmenu",this.root.addEventListener("mouseleave",function(){this.remove()}),this.items=[],this.colors={},s){let e={};e[s]=[],e.className="cmtitle",e.icon=i.icon,this.items.push(e)}const o=e.target.closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=t.root,this._parent.appendChild(this.root);const n=[e.x-48,e.y-8];if(this._parent instanceof HTMLDialogElement){let e=this._parent.getBoundingClientRect();n[0]-=e.x,n[1]-=e.y}this.root.style.left=`${n[0]}px`,this.root.style.top=`${n[1]}px`}_adjustPosition(e,t,s=!1){let i=e.getBoundingClientRect(),o=parseInt(e.style.left),n=parseInt(e.style.top);if(s){let s=window.innerWidth-i.right;s<0&&(o=e.offsetLeft+(s-t)),s=window.innerHeight-(i.top+i.height),s<0&&(n=e.offsetTop+(s-t+20))}else{let s=i.width;i.left<0?o=t:window.innerWidth-i.right<0&&(o=window.innerWidth-s-t),i.top<0?n=t:i.top+i.height>window.innerHeight&&(e.style.marginTop="",n=window.innerHeight-i.height-t)}e.style.left=`${o}px`,e.style.top=`${n}px`}_createSubmenu(e,t,s,i){this.root.querySelectorAll(".lexcontextmenu").forEach(e=>e.remove());let o=document.createElement("div");o.className="lexcontextmenu",s.appendChild(o);for(let s=0;s<e[t].length;++s){const n=e[t][s],a=Object.keys(n)[0];this._createEntry(n,a,o,i)}const n=s.getBoundingClientRect();o.style.left=n.x+n.width+"px",o.style.marginTop="-31px",this._adjustPosition(o,6)}_createEntry(e,s,i,o){const n=e[s].length;let a=document.createElement("div");a.className="lexmenuboxentry"+(e.className?" "+e.className:""),a.id=e.id??"eId"+t.getSupportedDOMName(s),a.innerHTML="";const l=e.icon;l&&a.appendChild(t.makeIcon(l,{svgClass:"sm"}));const r=e.disabled;if(a.innerHTML+="<div class='lexentryname"+(r?" disabled":"")+"'>"+s+"</div>",i.appendChild(a),this.colors[s]&&(a.style.borderColor=this.colors[s]),""==s)return void(a.className+=" cmseparator");if(a.addEventListener("click",i=>{if(i.stopPropagation(),i.stopImmediatePropagation(),r)return;const l=e.callback;l&&(l.call(this,s,a),this.root.remove()),n&&"click"==t.OPEN_CONTEXTMENU_ENTRY&&this._createSubmenu(e,s,a,++o)}),!n)return;const c=t.makeIcon("Menu",{svgClass:"sm"});a.appendChild(c),"mouseover"==t.OPEN_CONTEXTMENU_ENTRY&&a.addEventListener("mouseover",t=>{"true"!=a.dataset.built&&(a.dataset.built="true",this._createSubmenu(e,s,a,++o),t.stopPropagation())}),a.addEventListener("mouseleave",()=>{o=-1,i.querySelectorAll(".lexcontextmenu").forEach(e=>e.remove())})}onCreate(){t.doAsync(()=>this._adjustPosition(this.root,6))}add(e,s={}){s.constructor==Function&&(s={callback:s});const i=(e+="").split("/"),o=i[i.length-1];this.colors[o]=s.color;let n=0;const a=(e,t)=>{if(null==e)return;let o=null;if(t.forEach(t=>{const s=Object.keys(t).find(t=>t==e);s&&(o=t[s])}),o)a(i[n++],o);else{let o={};o[e]=[];const l=i[n++];l||(o.id=s.id,o.icon=s.icon,o.callback=s.callback,o.disabled=s.disabled??!1),t.push(o),a(l,o[e])}};a(i[n++],this.items);const l=e=>{let t=Object.keys(e)[0],s=e[t];if(s.length){if(null==s.find(e=>Object.keys(e)[0]==t)){let s={};s[t]=[],s.className="cmtitle",e[t].unshift(s)}for(let s of e[t]){let e=Object.keys(s)[0];for(let t=0;t<s[e].length;++t)l(s)}}};for(let e of this.items)l(e);for(let e of this.items){let s=Object.keys(e)[0],i="eId"+t.getSupportedDOMName(s);const o="#"+(e.id??i);this.root.querySelector(o)||this._createEntry(e,s,this.root,-1)}}setColor(e,s){"#"!==s[0]&&(s=t.rgbToHex(s)),this.colors[e]=s}}t.ContextMenu=he,t.addContextMenu=function(e,t,s,i={}){const o=new he(t,e,i);return s&&s(o),o.onCreate(),o};class de{static currentMenu=null;root;side="bottom";align="center";sideOffset=0;alignOffset=0;avoidCollisions=!0;onBlur;event;inPlace=!1;_trigger;_items=[];_parent;_windowPadding=4;_onClick;_radioGroup;invalid=!1;constructor(e,s,i={}){if(console.assert(e,"DropdownMenu needs a DOM element as trigger!"),de.currentMenu||!s?.length)return de.currentMenu?.destroy(),void(this.invalid=!0);this._trigger=e,e.classList.add("triggered"),e.ddm=this,this._items=s,this.side=i.side??"bottom",this.align=i.align??"center",this.sideOffset=i.sideOffset??0,this.alignOffset=i.alignOffset??0,this.avoidCollisions=i.avoidCollisions??!0,this.onBlur=i.onBlur,this.event=i.event,this.root=document.createElement("div"),this.root.id="root",this.root.dataset.side=this.side,this.root.tabIndex="1",this.root.className="lexdropdownmenu";const o=e.closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=t.root,this._parent.appendChild(this.root),this._create(this._items),de.currentMenu=this,t.doAsync(()=>{this._adjustPosition(),this.root.focus(),this._onClick=e=>{(!e.target||null==e.target.closest(".lexdropdownmenu")&&e.target!=this._trigger)&&this.destroy(!0)},document.body.addEventListener("mousedown",this._onClick,!0),document.body.addEventListener("focusin",this._onClick,!0)},10)}destroy(e=!1){this._trigger.classList.remove("triggered"),delete this._trigger.ddm,document.body.removeEventListener("mousedown",this._onClick,!0),document.body.removeEventListener("focusin",this._onClick,!0),this._parent.querySelectorAll(".lexdropdownmenu").forEach(e=>{e.remove()}),de.currentMenu=null,e&&this.onBlur&&this.onBlur()}_create(e,s){if(s){const e=s.getBoundingClientRect();let i=document.createElement("div");i.tabIndex="1",i.className="lexdropdownmenu",i.dataset.id=s.dataset.id,i.dataset.side="right",this._parent.appendChild(i),i.currentParent=s,s=i,t.doAsync(()=>{const s=[e.x+e.width,e.y];if(this._parent instanceof HTMLDialogElement){let e=this._parent.getBoundingClientRect();s[0]-=e.x,s[1]-=e.y}this.avoidCollisions&&(s[0]=t.clamp(s[0],0,window.innerWidth-i.offsetWidth-this._windowPadding),s[1]=t.clamp(s[1],0,window.innerHeight-i.offsetHeight-this._windowPadding)),i.style.left=`${s[0]}px`,i.style.top=`${s[1]}px`},10)}else s=this.root;let i=e.filter(e=>null!=e?.icon||null!=e?.checked).length>0;for(let t of e)this._createItem(t,s,i)}_createItem(e,s,i){if(!e)return void this._addSeparator(s);const o=e.name??e,n=t.getSupportedDOMName(o);if(s.querySelector("#"+n))return;const a=document.createElement("div");if(a.className="lexdropdownmenuitem"+(e.name||e.options?"":" label")+(e.disabled?" disabled":"")+` ${e.className??""}`,a.dataset.id=n,a.innerHTML=`<span class="ellipsis-overflow">${o}</span>`,a.tabIndex="1",s.appendChild(a),e.constructor===String)return;if(e.submenu){const e=t.makeIcon("Right",{svgClass:"sm"});a.appendChild(e)}else if(e.kbd){e.kbd=[].concat(e.kbd);const s=t.makeKbd(e.kbd);a.appendChild(s),document.addEventListener("keydown",t=>{if(!this._trigger.ddm)return;t.preventDefault();let s=e.kbd.join("");s=1==s.length?s.toLowerCase():s,s==t.key&&a.click()})}const l=e.disabled??!1;if(void 0!==this._radioGroup){if(e.name===this._radioGroup.selected){const e=t.makeIcon("Circle",{svgClass:"xxs fill-current"});a.prepend(e)}a.setAttribute("data-radioname",this._radioGroup.name)}else if(e.icon){const s=e.icon.constructor===String?t.makeIcon(e.icon,{svgClass:l?"fg-tertiary":e.svgClass??e.className}):e.icon;a.prepend(s)}else null==e.checked&&i&&a.classList.add("pl-8");if(!l){if(null!=e.checked){const t=new g(n+"_entryChecked",e.checked,t=>{const s=e.callback;e.checked=t,s&&s.call(this,o,t,a)},{className:"accent"}),s=t.root.querySelector("input");s.classList.add("ml-auto"),a.appendChild(s),a.addEventListener("click",e=>{"checkbox"!=e.target.type&&(s.checked=!s.checked,t.set(s.checked))})}else a.addEventListener("click",t=>{const s=a.getAttribute("data-radioname");s&&(this._trigger[s]=o);const i=e.callback;i&&i.call(this,o,a,s),!e.options&&(e.closeOnClick??1)&&this.destroy(!0)});if(a.addEventListener("mouseover",t=>{let i=a.dataset.id;if(!i)return;let o=s;for(;o;)i+="/"+o.dataset.id,o=o.currentParent?.parentElement;if(this._parent.querySelectorAll(".lexdropdownmenu").forEach(e=>{i.includes(e.dataset.id)||(e.currentParent.built=!1,e.remove())}),e.submenu&&this.inPlace){if(a.built)return;a.built=!0,this._create(e.submenu,a)}t.stopPropagation()}),e.options){console.assert(this._trigger[e.name]&&"An item of the radio group must be selected!"),this._radioGroup={name:e.name,selected:this._trigger[e.name]};for(let t of e.options)this._createItem(t,s,i);delete this._radioGroup,this._addSeparator()}}}_adjustPosition(){const e=[0,0],s=this._trigger.getBoundingClientRect();if(this.event)e[0]=this.event.x,e[1]=this.event.y;else{let t=!0;switch(this.side){case"left":e[0]+=s.x-this.root.offsetWidth-this.sideOffset,t=!1;break;case"right":e[0]+=s.x+s.width+this.sideOffset,t=!1;break;case"top":e[1]+=s.y-this.root.offsetHeight-this.sideOffset,t=!0;break;case"bottom":e[1]+=s.y+s.height+this.sideOffset,t=!0}switch(this.align){case"start":t?e[0]+=s.x:e[1]+=s.y;break;case"center":t?e[0]+=s.x+.5*s.width-.5*this.root.offsetWidth:e[1]+=s.y+.5*s.height-.5*this.root.offsetHeight;break;case"end":t?e[0]+=s.x-this.root.offsetWidth+s.width:e[1]+=s.y-this.root.offsetHeight+s.height}t?e[0]+=this.alignOffset:e[1]+=this.alignOffset}if(this._parent instanceof HTMLDialogElement){let t=this._parent.getBoundingClientRect();e[0]-=t.x,e[1]-=t.y}this.avoidCollisions&&(e[0]=t.clamp(e[0],0,window.innerWidth-this.root.offsetWidth-this._windowPadding),e[1]=t.clamp(e[1],0,window.innerHeight-this.root.offsetHeight-this._windowPadding)),this.root.style.left=`${e[0]}px`,this.root.style.top=`${e[1]}px`,this.inPlace=!0}_addSeparator(e=null){const t=document.createElement("div");t.className="separator",e=e??this.root,e?.appendChild(t)}}function ue(e,t,s={}){const i=new de(e,t,s);return i.invalid?null:i}t.DropdownMenu=de,t.addDropdownMenu=ue;class pe{root;constructor(e={}){const s=document.createElement("footer");s.className=`lexfooter ${e.className??""}`;const i=document.createElement("div");if(i.style.minHeight="48px",i.className="w-full",s.appendChild(i),e.columns&&e.columns.constructor==Array){const t=document.createElement("div");t.className="columns",t.style.gridTemplateColumns="1fr ".repeat(e.columns.length),i.appendChild(t);for(let s of e.columns){const e=document.createElement("div");e.className="col",t.appendChild(e);const i=document.createElement("h2");if(i.innerHTML=s.title,e.appendChild(i),!s.items||!s.items.length)continue;const o=document.createElement("ul");e.appendChild(o);for(let e of s.items){const t=document.createElement("li");t.innerHTML=`<a class="" href="${e.link}">${e.title}</a>`,o.appendChild(t)}}}if(e.credits||e.socials){const s=document.createElement("div");if(s.className="credits-and-socials",i.appendChild(s),e.credits){const t=document.createElement("p");t.innerHTML=e.credits,s.appendChild(t)}if(e.socials){const i=document.createElement("div");i.className="socials flex flex-row gap-1 my-2 justify-end";for(let s of e.socials){const e=t.makeIcon(s.icon,{title:s.title,svgClass:"xl"});e.href=s.link,e.target="_blank",i.appendChild(e)}s.appendChild(i)}}(e.parent??document.body).appendChild(s),s.previousElementSibling&&(s.previousElementSibling.style.flexGrow="1"),this.root=s}}t.Footer=pe;let me=class e extends re{static TOP=0;static BOTTOM=1;dockPosition=e.TOP;minimized=!1;constructor(s,i,o={}){o.draggable=o.draggable??!1,o.closable=o.closable??!1;super(s,i,o);let n=this;t.addSignal("@on_branch_closed",this.panel,t=>{this.dockPosition==e.BOTTOM&&(this.root.style.top=`calc(100% - ${this.root.offsetHeight+3}px)`)}),this.root.classList.add("pocket"),this.root.style.translate="none",this.root.style.top="0",this.root.style.left="unset",o.position||(this.root.style.right="3px",this.root.style.top="3px"),this.panel.root.style.width="100%",this.panel.root.style.height="100%";const a=this.title;if(a.tabIndex=-1,a.addEventListener("click",t=>{a.eventCatched?a.eventCatched=!1:(this.size&&(this.minimized?this.root.style.height=this.size[1]:this.root.style.height="auto"),this.root.classList.toggle("minimized"),this.minimized=!this.minimized,this.dockPosition==e.BOTTOM&&(n.root.style.top=this.root.classList.contains("minimized")?`calc(100% - ${n.title.offsetHeight+6}px)`:`calc(100% - ${n.root.offsetHeight+3}px)`))}),!o.draggable){const t=o.float;if(t)for(let e=0;e<t.length;e++){switch(t[e]){case"b":this.root.style.top=`calc(100% - ${this.root.offsetHeight+3}px)`;break;case"l":this.root.style.right="unset",this.root.style.left=o.position?o.position[1]:"3px"}}this.root.classList.add("dockable"),a.addEventListener("keydown",function(t){t.ctrlKey&&(n.root.style.right="unset","ArrowLeft"==t.key?n.root.style.left="0px":"ArrowRight"==t.key?n.root.style.left=`calc(100% - ${n.root.offsetWidth+3}px)`:"ArrowUp"==t.key?(n.root.style.top="0px",n.dockPosition=e.TOP):"ArrowDown"==t.key&&(n.root.style.top=`calc(100% - ${n.root.offsetHeight+3}px)`,n.dockPosition=e.BOTTOM))})}}};t.PocketDialog=me;class ge{side="left";root;_onClick;constructor(e,s,i={}){this.side=i.side??this.side,this.root=document.createElement("div"),this.root.dataset.side=this.side,this.root.tabIndex="1",this.root.role="dialog",this.root.className="lexsheet fixed z-1000 bg-primary",document.body.appendChild(this.root),this.root.addEventListener("keydown",e=>{"Escape"==e.key&&(e.preventDefault(),e.stopPropagation(),this.destroy())}),s&&(s=[].concat(s)).forEach(e=>{const t=e.root??e;this.root.appendChild(t),e.onSheet&&e.onSheet()}),t.doAsync(()=>{switch(t.modal.toggle(!1),this.side){case"left":this.root.style.left="0",this.root.style.width=e,this.root.style.height="100%";break;case"right":this.root.style.right="0",this.root.style.width=e,this.root.style.height="100%";break;case"top":this.root.style.left="0",this.root.style.top="0",this.root.style.width="100%",this.root.style.height=e;break;case"bottom":this.root.style.left="0",this.root.style.bottom="0",this.root.style.width="100%",this.root.style.height=e}document.documentElement.setAttribute("data-scale",`sheet-${this.side}`),this.root.focus(),this._onClick=e=>{e.target&&this.root.contains(e.target)||this.destroy()},document.body.addEventListener("mousedown",this._onClick,!0),document.body.addEventListener("focusin",this._onClick,!0)},10)}destroy(){document.documentElement.setAttribute("data-scale",""),document.body.removeEventListener("mousedown",this._onClick,!0),document.body.removeEventListener("focusin",this._onClick,!0),this.root.remove(),t.modal.toggle(!0)}}t.Sheet=ge;class fe{root;callback;items=[];icons={};groups={};side;collapsable;collapsed;filterString;filter;header;content;footer;resizeObserver=void 0;siblingArea=void 0;currentGroup;collapseQueue;collapseContainer;_collapseWidth;_displaySelected=!0;get displaySelected(){return this._displaySelected}set displaySelected(e){this._displaySelected=e,e||this.root.querySelectorAll(".lexsidebarentry").forEach(e=>e.classList.remove("selected"))}constructor(e={}){const s=navigator&&/Android|iPhone/i.test(navigator.userAgent);if(this.root=document.createElement("div"),this.root.className="lexsidebar flex flex-col "+(e.className??""),this.callback=e.callback??null,this._displaySelected=e.displaySelected??!1,this.side=e.side??"left",this.collapsable=e.collapsable??!0,this._collapseWidth=e.collapseToIcons??1?"58px":"0px",this.collapsed=e.collapsed??s,this.filterString="",t.doAsync(()=>{if(this.root.parentElement.ogWidth=this.root.parentElement.style.width,this.root.parentElement.style.transition=this.collapsed?"":"width 0.25s ease-out",this.resizeObserver=new ResizeObserver(e=>{for(const t of e)this.siblingArea?.setSize(["calc(100% - "+t.contentRect.width+"px )",null])}),this.collapsed){if(this.root.classList.toggle("collapsed",this.collapsed),this.root.parentElement.style.width=this._collapseWidth,!this.resizeObserver)throw"Wait until ResizeObserver has been created!";this.resizeObserver.observe(this.root.parentElement),t.doAsync(()=>{this.resizeObserver?.unobserve(this.root.parentElement),this.root.querySelectorAll(".lexsidebarentrycontent").forEach(e=>e.dataset.disableTooltip=`${!this.collapsed}`)},10)}},10),!e.skipHeader&&(this.header=e.header??this._generateDefaultHeader(e),console.assert(this.header.constructor===HTMLDivElement,"Use an HTMLDivElement to build your custom header"),this.header.className="lexsidebarheader flex-auto",this.root.appendChild(this.header),this.collapsable)){const i=t.makeIcon("left"==this.side?"PanelLeft":"PanelRight",{title:"Toggle Sidebar",iconClass:"toggler"});if(this.header.appendChild(i),s){const s=new se({skipAppend:!0}),o=t.deepCopy(e);o.collapsed=!1,o.collapsable=!1,s.addSidebar(this.callback,o),i.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),new t.Sheet("256px",[s],{side:this.side})})}else i.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.toggleCollapsed()})}if(e.filter){const e=new d(null,"",(e,t)=>{this.filterString=e,this.update()},{inputClass:"outline",placeholder:"Search...",icon:"Search",className:"lexsidebarfilter"});this.filter=e.root,this.root.appendChild(this.filter)}this.content=document.createElement("div"),this.content.className="lexsidebarcontent flex-auto-fill",this.root.appendChild(this.content),e.skipFooter||(this.footer=e.footer??this._generateDefaultFooter(e),console.assert(this.footer.constructor===HTMLDivElement,"Use an HTMLDivElement to build your custom footer"),this.footer.className="lexsidebarfooter flex-auto",this.root.appendChild(this.footer))}_generateDefaultHeader(e={}){const s=document.createElement("div");s.addEventListener("click",t=>{this.collapsed?(t.preventDefault(),t.stopPropagation(),this.toggleCollapsed()):e.onHeaderPressed&&e.onHeaderPressed(t)});const i=document.createElement("span");if(i.className="lexavatar",s.appendChild(i),e.headerImage){const t=document.createElement("img");t.src=e.headerImage,i.appendChild(t)}else if(e.headerIcon){const s=t.makeIcon(e.headerIcon);i.appendChild(s)}{const t=document.createElement("div");t.className="infodefault",s.appendChild(t);const i=document.createElement("span");i.innerHTML=e.headerTitle??"",t.appendChild(i);const o=document.createElement("span");o.innerHTML=e.headerSubtitle??"",t.appendChild(o)}if(e.onHeaderPressed&&!this.collapsable){const e=t.makeIcon("MenuArrows");s.appendChild(e)}return s}_generateDefaultFooter(e={}){const s=document.createElement("div");s.addEventListener("click",t=>{e.onFooterPressed&&e.onFooterPressed(t,s)});const i=document.createElement("span");if(i.className="lexavatar",s.appendChild(i),e.footerImage){const t=document.createElement("img");t.src=e.footerImage,i.appendChild(t)}else if(e.footerIcon){const s=t.makeIcon(e.footerIcon);i.appendChild(s)}{const t=document.createElement("div");t.className="infodefault",s.appendChild(t);const i=document.createElement("span");i.innerHTML=e.footerTitle??"",t.appendChild(i);const o=document.createElement("span");o.innerHTML=e.footerSubtitle??"",t.appendChild(o)}if(e.onFooterPressed){const e=t.makeIcon("MenuArrows");s.appendChild(e)}return s}toggleCollapsed(e){if(this.collapsable){if(this.collapsed=e??!this.collapsed,this.collapsed?(this.root.classList.add("collapsing"),this.root.parentElement.style.width=this._collapseWidth):(this.root.classList.remove("collapsing"),this.root.classList.remove("collapsed"),this.root.parentElement.style.width=this.root.parentElement.ogWidth),!this.resizeObserver)throw"Wait until ResizeObserver has been created!";this.resizeObserver.observe(this.root.parentElement),t.doAsync(()=>{this.root.classList.toggle("collapsed",this.collapsed),this.resizeObserver?.unobserve(this.root.parentElement),this.root.querySelectorAll(".lexsidebarentrycontent").forEach(e=>e.dataset.disableTooltip=`${!this.collapsed}`)},250)}}separator(){this.currentGroup=null,this.add("")}group(e,t){this.currentGroup=e,this.groups[e]=t}add(e,t={}){t.constructor==Function&&(t={callback:t});const s=e.split("/"),i=s[s.length-1];this.icons[i]=t.icon;let o=0;const n=(e,i)=>{if(null==e)return;let a=null;if(i.forEach(t=>{const s=Object.keys(t).find(t=>t==e);s&&(a=t[s])}),a)n(s[o++],a);else{let a={};a[e]=[];const l=s[o++];l||(a.callback=t.callback,a.group=this.currentGroup,a.options=t),i.push(a),n(l,a[e])}};n(s[o++],this.items)}select(e){let s=t.getSupportedDOMName(e);const i=this.items.find(e=>e.name===s);i&&i.dom.click()}update(){this.content.innerHTML="";for(let e of this.items)delete e.dom;for(let e of this.items){const s=e.options??{};if(e.dom)continue;let i=e.name=Object.keys(e)[0];if(this.filterString.length&&!i.toLowerCase().includes(this.filterString.toLowerCase()))continue;let o=t.getSupportedDOMName(i),n=null,a=document.createElement("div");if(a.id=o,a.className="lexsidebarentry "+(s.className??""),this.displaySelected&&s.selected&&a.classList.add("selected"),e.group){const s=e.group.replace(/\s/g,"").replaceAll(".","");if(n=this.content.querySelector("#"+s),n){if(!n.classList.contains("lexsidebargroup"))throw"Bad id: "+e.group}else{n=document.createElement("div"),n.id=s,n.className="lexsidebargroup",this.content.appendChild(n);let i=document.createElement("div");i.className="lexsidebargrouptitle",n.appendChild(i);let o=document.createElement("div");if(o.innerHTML=e.group,i.appendChild(o),null!=this.groups[e.group]){const s=t.makeIcon(this.groups[e.group].icon,{svgClass:"sm"});i.appendChild(s),s.addEventListener("click",t=>{this.groups[e.group].callback&&this.groups[e.group].callback(e.group,t)})}}}if(""==o){let e=document.createElement("div");e.className="lexsidebarseparator",this.content.appendChild(e);continue}this.collapseContainer?(this.collapseContainer.appendChild(a),this.collapseQueue--,this.collapseQueue||delete this.collapseContainer):n?n.appendChild(a):this.content.appendChild(a);let l=document.createElement("div");if(l.className="lexsidebarentrycontent",a.appendChild(l),e.dom=a,"checkbox"==s.type){e.value=s.value??!1;const t=new ee;e.checkbox=t.addCheckbox(null,e.value,(t,o)=>{o.preventDefault(),o.stopPropagation();const n=s.callback;e.value=t,n&&n.call(this,i,t,o)},{className:"accent",label:i,signal:"@checkbox_"+i}),l.appendChild(t.root.childNodes[0])}else{if(s.icon){const e=t.makeIcon(s.icon,{iconClass:"lexsidebarentryicon"});l.appendChild(e),t.asTooltip(l,i,{side:"right",offset:16,active:!1})}if(t.makeElement("a","grid-column-start-2",i,l),s.swap){l.classList.add("swap","inline-grid"),l.querySelector("a")?.classList.add("swap-off");const e=document.createElement("input");e.className="p-0 border-0",e.type="checkbox",l.prepend(e);const i=t.makeIcon(s.swap,{iconClass:"lexsidebarentryicon swap-on"});l.appendChild(i)}s.content&&l.appendChild(s.content)}const r=null!=s.collapsable?s.collapsable:s.collapsable||e[i].length;if(a.addEventListener("click",t=>{if(t.target&&t.target.classList.contains("lexcheckbox"))return;let o;if(r)l.querySelector(".collapser")?.click();else if(e.checkbox)e.value=!e.value,e.checkbox.set(e.value,!0),o=e.value;else if(s.swap&&!(t.target instanceof HTMLInputElement)){const e=l.querySelector("input");e.checked=!e.checked,o=e.checked}const n=s.callback;n&&n.call(this,i,o??a,t),this.displaySelected&&!s.skipSelection&&(this.root.querySelectorAll(".lexsidebarentry").forEach(e=>e.classList.remove("selected")),a.classList.add("selected"))}),s.action){const e=t.makeIcon(s.action.icon??"Ellipsis",{title:s.action.name});l.appendChild(e),e.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation();const t=s.action.callback;t&&t.call(this,i,e)})}else if(r){const e=document.createElement("div");e.className="collapsablecontainer",Object.assign(e.style,{width:"100%",display:"none"}),t.makeCollapsible(l,e,n??this.content),this.collapseQueue=s.collapsable,this.collapseContainer=e}if(!e[i].length)continue;let c=document.createElement("div");c.className="lexsidebarsubentrycontainer",r?(this.collapseContainer.appendChild(c),delete this.collapseContainer):n?(c.classList.add("collapsablecontainer"),n.appendChild(c)):this.content.appendChild(c);for(let s=0;s<e[i].length;++s){const o=e[i][s],n=o.options??{},a=o.name=Object.keys(o)[0];if(this.filterString.length&&!a.toLowerCase().includes(this.filterString.toLowerCase()))continue;let l=document.createElement("div");if(l.innerHTML=`<span>${a}</span>`,n.action){const e=t.makeIcon(n.action.icon??"Ellipsis",{title:n.action.name});l.appendChild(e),e.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation();const t=n.action.callback;t&&t.call(this,a,e)})}if(l.className="lexsidebarentry",l.id=a,n.content){const e=t.makeElement("div");e.appendChild(n.content),l.appendChild(e)}c.appendChild(l),l.addEventListener("click",e=>{const t=n.callback;t&&t.call(this,a,l,e),this.displaySelected&&!n.skipSelection&&(this.root.querySelectorAll(".lexsidebarentry").forEach(e=>e.classList.remove("selected")),l.classList.add("selected"))})}}}}t.Sidebar=fe;class Ce{root;constructor(e){if(this.root=t.makeContainer(["auto","auto"],"flex flex-row lexskeleton"),e.constructor===String)this.root.innerHTML=e;else{e=[].concat(e);for(let t of e)this.root.appendChild(t)}}destroy(){this.root.dataset.closed=!0,t.doAsync(()=>{this.root.remove(),this.root=null},200)}}t.Skeleton=Ce;class ve{static ACTIVE_TOURS=[];steps;currentStep=0;useModal;offset;horizontalOffset;verticalOffset;radius;tourContainer;tourMask=void 0;_popover=null;constructor(e,s={}){this.steps=e||[],this.useModal=s.useModal??!0,this.offset=s.offset??8,this.horizontalOffset=s.horizontalOffset,this.verticalOffset=s.verticalOffset,this.radius=s.radius??12,this.tourContainer=document.querySelector(".tour-container"),this.tourContainer||(this.tourContainer=t.makeContainer(["100%","100%"],"tour-container"),this.tourContainer.style.display="none",document.body.appendChild(this.tourContainer),window.addEventListener("resize",()=>{for(const e of ve.ACTIVE_TOURS)e._showStep(0)}))}begin(){this.currentStep=0,this.tourContainer.style.display="block",ve.ACTIVE_TOURS.push(this),this._showStep(0)}stop(){this.useModal&&(this.tourMask?.remove(),this.tourMask=void 0),this._popover?.destroy();const e=ve.ACTIVE_TOURS.indexOf(this);-1!==e&&ve.ACTIVE_TOURS.splice(e,1),this.tourContainer.innerHTML="",this.tourContainer.style.display="none"}_showStep(e=1){this.currentStep+=e;const t=this.steps[this.currentStep];if(!t)return void this.stop();const s=this.steps[this.currentStep-1],i=this.steps[this.currentStep+1];this.useModal&&this._generateMask(t.reference),this._createHighlight(t,s,i)}_generateMask(e){this.tourContainer.innerHTML="",this.tourMask=t.makeContainer(["100%","100%"],"tour-mask"),this.tourContainer.appendChild(this.tourMask);const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.style.width="100%",s.style.height="100%",this.tourMask?.appendChild(s);const i=document.createElementNS("http://www.w3.org/2000/svg","clipPath");function o(e,t){const s=Math.ceil(e);return[s,t-(s-e)]}i.setAttribute("id","svgTourClipPath"),s.appendChild(i);const n=e.getBoundingClientRect(),[a,l]=o(n.x,n.width),[r,c]=o(n.y,n.height),h=this.verticalOffset??this.offset,d=this.horizontalOffset??this.offset;{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x","0"),e.setAttribute("y","0"),e.setAttribute("width",`${Math.max(0,a-d)}`),e.setAttribute("height",`${window.innerHeight}`),e.setAttribute("stroke","none"),i.appendChild(e)}{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x",""+(a-d)),e.setAttribute("y","0"),e.setAttribute("width",`${Math.max(0,l+2*d)}`),e.setAttribute("height",`${Math.max(0,r-h)}`),e.setAttribute("stroke","none"),i.appendChild(e)}{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x",""+(a-d)),e.setAttribute("y",`${r+c+h}`),e.setAttribute("width",`${Math.max(0,l+2*d)}`),e.setAttribute("height",`${Math.max(0,window.innerHeight-r-c-h)}`),e.setAttribute("stroke","none"),i.appendChild(e)}{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x",`${a+l+d}`),e.setAttribute("y","0"),e.setAttribute("width",`${Math.max(0,window.innerWidth-a-l)}`),e.setAttribute("height",`${Math.max(0,window.innerHeight)}`),e.setAttribute("stroke","none"),i.appendChild(e)}const u=t.makeContainer(["0","0"],"tour-ref-mask");u.style.left=a-d-1+"px",u.style.top=r-h-1+"px",u.style.width=`${l+2*d+2}px`,u.style.height=`${c+2*h+2}px`,this.tourContainer.appendChild(u);const p=document.createElementNS("http://www.w3.org/2000/svg","mask");p.setAttribute("id","svgTourReferenceMask"),s.appendChild(p);{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("width",`${l+2*d+2}`),e.setAttribute("height",`${c+2*h+2}`),e.setAttribute("stroke","none"),e.setAttribute("fill","white"),p.appendChild(e);const t=document.createElementNS("http://www.w3.org/2000/svg","rect");t.setAttribute("rx",`${this.radius}`),t.setAttribute("width",`${l+2*d+2}`),t.setAttribute("height",`${c+2*h+2}`),t.setAttribute("stroke","none"),t.setAttribute("fill","black"),p.appendChild(t)}}_createHighlight(e,s,i){const o=t.makeContainer(["auto","auto"],"tour-step-container");{const s=t.makeContainer(["100%","auto"],"flex flex-row","",o);t.makeContainer(["70%","auto"],"p-2 font-medium",e.title,s);const i=t.makeContainer(["30%","auto"],"flex flex-row p-2 justify-end","",s),n=t.makeIcon("X");i.appendChild(n),t.listen(n,"click",()=>{this.stop()})}t.makeContainer(["100%","auto"],"p-2 text-md",e.content,o,{maxWidth:"400px"});const n=t.makeContainer(["100%","auto"],"flex flex-row text-md","",o);{const e=t.makeContainer(["50%","auto"],"p-2 gap-1 self-center flex flex-row text-md","",n);for(let t=0;t<this.steps.length;t++){const s=document.createElement("span");s.className="tour-step-indicator",t===this.currentStep&&s.classList.add("active"),e.appendChild(s)}}const a=t.makeContainer(["50%","auto"],"text-md","",n),l=new ee;let r=1;s&&r++,r>1&&l.sameLine(2,"justify-end"),s&&l.addButton(null,"Previous",()=>{this._showStep(-1)},{buttonClass:"contrast"}),i?l.addButton(null,"Next",()=>{this._showStep(1)},{buttonClass:"accent"}):l.addButton(null,"Finish",()=>{this.stop()}),a.appendChild(l.root);const c=("left"===e.side||"right"===e.side?this.horizontalOffset:this.verticalOffset)??this.offset,h="start"===e.align||"end"===e.align?c:0;this._popover?.destroy(),this._popover=new v(null,[o],{reference:e.reference,side:e.side,align:e.align,sideOffset:c,alignOffset:"start"===e.align?-h:h})}}if(t.Tour=ve,t.init=async function(e={}){if(this.ready)return this.mainArea;await t.loadScriptSync("https://unpkg.com/lucide@latest"),console.log(`LexGUI v${this.version}`);var s=document.createElement("div");s.id="lexroot",s.className="lexcontainer",s.tabIndex=-1,e.rootClass&&(s.className+=` ${e.rootClass}`),this.modal=document.createElement("div"),this.modal.id="modal",this.modal.classList.add("hidden-opacity"),this.modal.toggle=function(e){this.classList.toggle("hidden-opacity",e)},this.root=s,this.container=document.body,e.container&&(this.container=e.container.constructor===String?document.getElementById(e.container):e.container),this.layoutMode=e.layoutMode??"app",document.documentElement.setAttribute("data-layout",this.layoutMode),this.layoutMode,this.spacingMode=e.spacingMode??"default",document.documentElement.setAttribute("data-spacing",this.spacingMode),this.container.appendChild(this.modal),e.skipRoot?this.root=document.body:this.container.appendChild(s);{const e=document.createElement("section");e.className="notifications",this.notifications=document.createElement("ol"),this.notifications.className="",this.notifications.iWidth=0,e.appendChild(this.notifications),document.body.appendChild(e),this.notifications.addEventListener("mouseenter",()=>{this.notifications.classList.add("list")}),this.notifications.addEventListener("mouseleave",()=>{this.notifications.classList.remove("list")})}s.addEventListener("dragover",function(e){e.preventDefault()},!1),document.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.DEFAULT_NAME_WIDTH="30%",this.DEFAULT_SPLITBAR_SIZE=4,this.OPEN_CONTEXTMENU_ENTRY="click",this.componentResizeObserver=new ResizeObserver(e=>{for(const t of e){const e=t.target?.jsInstance;e&&e.onResize&&e.onResize(t.contentRect)}}),this.ready=!0,this.menubars=[],this.sidebars=[],this.commandbar=this._createCommandbar(this.container),e.skipRoot||e.skipDefaultArea||(this.mainArea=new se({id:e.id??"mainarea"})),this._onChangeSystemTheme=function(e){localStorage.getItem("lxColorScheme")||t.setTheme(e.matches?"dark":"light",!1)},this._mqlPrefersDarkScheme=window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)"):null;const i=localStorage.getItem("lxColorScheme");return i?t.setTheme(i):this._mqlPrefersDarkScheme&&(e.autoTheme??1)&&(window.matchMedia("(prefers-color-scheme: light)").matches&&t.setTheme("light",!1),this._mqlPrefersDarkScheme.addEventListener("change",this._onChangeSystemTheme)),this.mainArea},t.setSpacingMode=function(e){this.spacingMode=e,document.documentElement.setAttribute("data-spacing",this.spacingMode)},t.setLayoutMode=function(e){this.layoutMode=e,document.documentElement.setAttribute("data-layout",this.layoutMode)},t.addSignal=function(e,s,i){s[e]=i,t.signals[e]||(t.signals[e]=[]),t.signals[e].indexOf(s)>-1||t.signals[e].push(s)},t.emitSignal=function(e,s,i={}){const o=t.signals[e];if(!o)return;const n=i.target;if(n)n[e]&&n[e].call(n,s);else for(let t of o)if(t instanceof a)t.set(s,i.skipCallback??!0);else if(t.constructor===Function){t(null,s)}else{const i=t[e];console.assert(i,`No callback registered with _${e}_ signal`),i.bind(t)(s)}},t._createCommandbar=function(e){let s=document.createElement("dialog");s.className="commandbar",s.tabIndex=-1,e.appendChild(s);let i=[],o=null;s.addEventListener("keydown",function(e){if(e.stopPropagation(),e.stopImmediatePropagation(),o=o??-1,"Escape"==e.key)s.close(),h(!0);else if("Enter"==e.key){const e=i[o];e&&(null!=e.item.checked&&(e.item.checked=!e.item.checked),s.close(),e.callback.call(window,e.item.name,e.item.checked))}else if("ArrowDown"==e.key&&o<i.length-1){o++,s.querySelectorAll(".hovered").forEach(e=>e.classList.remove("hovered"));const e=i[o];e.classList.add("hovered");let t=e.offsetHeight*(o+1)-r.offsetHeight;t>0&&r.scrollTo({top:t,behavior:"smooth"})}else if("ArrowUp"==e.key&&o>0){o--,s.querySelectorAll(".hovered").forEach(e=>e.classList.remove("hovered"));i[o].classList.add("hovered")}}),s.addEventListener("focusout",function(e){e.relatedTarget!=e.currentTarget&&(e.stopPropagation(),e.stopImmediatePropagation(),s.close(),h(!0))}),e.addEventListener("keydown",e=>{if(" "==e.key&&e.ctrlKey)e.stopImmediatePropagation(),e.stopPropagation(),t.setCommandbarState(!0);else for(let s of t.extensions){if(!t[s]||!t[s].prototype.onKeyPressed)continue;const i=t.CodeEditor.getInstances();for(let t of i)t.onKeyPressed(e)}});const n=t.makeContainer(["100%","auto"],"flex flex-row"),a=new d(null,"",e=>{s._addElements(e.toLowerCase())},{width:"100%",icon:"Search",trigger:"input",placeholder:"Search..."});n.appendChild(a.root);const l=new se({width:"100%",skipAppend:!0,className:"cb-tabs"});{const e=(e,t)=>{};l.addTabs({parentClass:"p-2"}).add("All",document.createElement("div"),{selected:!0,onSelect:e})}const r=document.createElement("div");r.className="searchitembox";let c=null;const h=e=>{r.innerHTML="",i.length=0,o=null,e&&a.set("",!0)},u=(e,n,a,l)=>{if(!e.length)return;c&&c.classList.remove("last");let d=document.createElement("div");if(d.className="searchitem last",void 0!==l?.checked){const s=l.checked?t.makeIcon("Check").innerHTML:"";d.innerHTML=s+(a+e)}else d.innerHTML=a+e;d.callback=n,d.item=l,d.addEventListener("click",s=>{null!=l.checked&&(l.checked=!l.checked),n.call(window,e,l.checked),t.setCommandbarState(!1),h(!0)}),d.addEventListener("mouseenter",function(e){s.querySelectorAll(".hovered").forEach(e=>e.classList.remove("hovered")),d.classList.add("hovered"),o=i.indexOf(d)}),d.addEventListener("mouseleave",function(e){d.classList.remove("hovered")}),i.push(d),r.appendChild(d),c=d},p=(e,s,i,o)=>{if(!e||e.constructor!=Object)return;let n=e.name;n.toLowerCase().includes(s)&&e.callback&&u(n,e.callback,i,e);const a=e.submenu??e[n];if(!a)return;i+=n+t.makeIcon("ChevronRight",{svgClass:"sm fg-secondary separator"}).innerHTML;for(let e of a)p(e,s,i)};return s._addElements=e=>{h();for(let s of t.menubars)for(let t of s.items)p(t,e,"");for(let s of t.sidebars)for(let t of s.items)p(t,e,"");for(let s of t.extraCommandbarEntries){const t=s.name;t.toLowerCase().includes(e)&&u(t,s.callback,"",{})}if(t.has("CodeEditor")){const s=t.CodeEditor.getInstances();if(!s.length||!s[0].area.root.offsetHeight)return;const i=t.CodeEditor.languages;for(let o of Object.keys(i)){const n="Language: "+o,a=s[0]._getFileIcon(null,i[o].ext).split(" ");let l=t.makeIcon(a[0],{svgClass:`${a.slice(0).join(" ")}`}).innerHTML;l+=n+" <span class='lang-ext'>("+i[o].ext+")</span>",n.toLowerCase().includes(e)&&u(l,()=>{for(let e of s)e._changeLanguage(o)},"",{})}}},s.appendChild(n),s.appendChild(l.root),s.appendChild(r),s},t.setCommandbarState=function(e,t=!0){const s=this.commandbar;e?(s.show(),s.querySelector("input").focus(),t&&s._addElements(void 0)):s.close()},t.REGISTER_COMPONENT=function(e,s={}){let o=t.guidGenerator();ee.prototype["add"+e]=function(l,r,c){const h=Array.from(arguments).slice(3);let d=new a(n.CUSTOM,l,null,s);this._attachComponent(d),d.customName=e,d.customIdx=o,d.onGetValue=()=>r,d.onSetValue=(e,t,s)=>{r=e,f(),u.querySelector(".lexcustomitems").toggleAttribute("hidden",!1),t||d._trigger(new i(l,r,s),c)},d.onResize=()=>{const e=d.root.domName?.style.width??"0px";p.style.width=`calc( 100% - ${e})`};const u=d.root;let p,m,g=s.default??{};const f=()=>{p&&p.remove(),m&&m.remove(),p=document.createElement("div"),p.className="lexcustomcontainer w-full",u.appendChild(p),u.dataset.opened=!1;const o=t.makeIcon(s.icon??"Box"),n=t.makeIcon("Menu");let a=e+(r?"":" [empty]"),C=this.addButton(null,a,(s,i)=>{r?(u.querySelector(".lexcustomitems").toggleAttribute("hidden"),u.dataset.opened=!u.querySelector(".lexcustomitems").hasAttribute("hidden")):t.addContextMenu(null,i,t=>{t.add("New "+e,()=>{r={},f(),u.querySelector(".lexcustomitems").toggleAttribute("hidden",!1),u.dataset.opened=!u.querySelector(".lexcustomitems").hasAttribute("hidden")})})},{buttonClass:"custom"});const v=C.root.querySelector("span");if(v.prepend(o),v.appendChild(n),p.appendChild(C.root),r&&n.addEventListener("click",e=>{e.stopImmediatePropagation(),e.stopPropagation(),t.addContextMenu(null,e,e=>{e.add("Clear",()=>{r=null,f()})})}),m=document.createElement("div"),m.className="lexcustomitems",m.toggleAttribute("hidden",!0),u.appendChild(m),r){this.queue(m);const e=(e,t,o)=>{const n=s[`_set_${e}`];n?n.call(r,t):r[e]=t,d._trigger(new i(l,r,o),c)};for(let t in g){let i=null;const o=s[`_get_${t}`];if(i=o?r[t]?o.call(r):o.call(g):r[t]??g[t],i)switch(i.constructor){case String:"#"===i[0]?this.addColor(t,i,e.bind(this,t)):this.addText(t,i,e.bind(this,t));break;case Number:this.addNumber(t,i,e.bind(this,t));break;case Boolean:this.addCheckbox(t,i,e.bind(this,t));break;case Array:i.length>4?this.addArray(t,i,e.bind(this,t)):this._addVector(i.length,t,i,e.bind(this,t));break;default:console.warn(`Unsupported property type: ${i.constructor.name}`)}}s.onCreate&&s.onCreate.call(this,this,...h),this.clearQueue()}};f()}},!t)throw"Missing LX namespace!";t.extensions.push("AssetView");const ye=t.Area;t.Panel,t.NodeTree,t.TreeEvent;class be{static LAYOUT_GRID=0;static LAYOUT_COMPACT=1;static LAYOUT_LIST=2;static CONTENT_SORT_ASC=0;static CONTENT_SORT_DESC=1;root;area=null;content;leftPanel=null;toolsPanel;contentPanel;previewPanel;tree=null;prevData=[];nextData=[];data=[];currentData=[];currentFolder=void 0;rootItem;path=[];rootPath="";selectedItem=void 0;allowedTypes;searchValue="";filter="None";gridScale=1;layout=be.LAYOUT_GRID;sortMode=be.CONTENT_SORT_ASC;skipBrowser=!1;skipPreview=!1;useNativeTitle=!1;onlyFolders=!0;allowMultipleSelection=!1;previewActions=[];contextMenu=[];onRefreshContent=null;itemContextMenuOptions=null;onItemDragged=null;_assetsPerPage=24;get assetsPerPage(){return this._assetsPerPage}set assetsPerPage(e){this._setAssetsPerPage(e)}_callbacks={};_lastSortBy="";_paginator;_scriptCodeDialog;_moveItemDialog;_movingItem;constructor(e={}){this.rootPath="https://raw.githubusercontent.com/jxarco/lexgui.js/master/",this.layout=e.layout??this.layout,this.sortMode=e.sortMode??this.sortMode,e.rootPath&&(e.rootPath.constructor!==String?console.warn(`Asset Root Path must be a String (now is a ${e.rootPath.constructor.name})`):this.rootPath=e.rootPath);let s=document.createElement("div");s.className="lexassetbrowser",this.root=s;let i=new ye({width:"100%",height:"100%"});s.appendChild(i.root);let o,n,a=i;if(this.skipBrowser=e.skipBrowser??this.skipBrowser,this.skipPreview=e.skipPreview??this.skipPreview,this.useNativeTitle=e.useNativeTitle??this.useNativeTitle,this.onlyFolders=e.onlyFolders??this.onlyFolders,this.allowMultipleSelection=e.allowMultipleSelection??this.allowMultipleSelection,this.previewActions=e.previewActions??[],this.itemContextMenuOptions=e.itemContextMenuOptions,this.onRefreshContent=e.onRefreshContent,this.onItemDragged=e.onItemDragged,this.gridScale=e.gridScale??this.gridScale,1!==this.gridScale){document.querySelector(":root").style.setProperty("--av-grid-scale",this.gridScale)}document.body.appendChild(this.root),this.skipBrowser||([o,n]=i.split({type:"horizontal",sizes:["15%","85%"]}),a=n,o.setLimitBox(210,0),n.setLimitBox(512,0)),this.skipPreview||([a,n]=a.split({type:"horizontal",sizes:["80%","20%"]})),this.allowedTypes={None:{},Image:{color:"yellow-500"},JSON:{color:"sky-200"},Video:{color:"indigo-400"},...e.allowedTypes??{}},this.path=["@"],this.rootItem={id:"/",children:this.data,type:"folder",metadata:{uid:t.guidGenerator()}},this.currentFolder=this.rootItem,this._processData(this.data),this.currentData=this.data,this.skipBrowser||this._createTreePanel(o),this._createContentPanel(a),this.skipPreview||(this.previewPanel=n.addPanel({className:"lexassetcontentpanel",style:{overflow:"scroll"}})),document.body.removeChild(this.root)}on(e,t){this._callbacks[e]=t}load(e){this.prevData.length=0,this.nextData.length=0,this.data=e,this.rootItem.children=this.data,this._processData(this.data),this.currentData=this.data,this.path=["@"],this.skipBrowser||this.tree.refresh({id:"/",children:this.data,type:"folder",metadata:{uid:t.guidGenerator()}}),this._refreshContent()}addItem(e,s,i=!0){const o=this.layout==be.LAYOUT_LIST,n=this.layout==be.LAYOUT_GRID,a=e.type.charAt(0).toUpperCase()+e.type.slice(1),l=t.getExtension(e.id),r="Folder"===a,c=this;let h=document.createElement("li");h.className="lexassetitem "+e.type.toLowerCase(),h.tabIndex=-1,t.insertChildAtIndex(this.content,h,s);const d=this.allowedTypes[a]?.color;d&&t.makeElement("span",`rounded-full w-2 h-2 z-100 flex absolute ml-2 mt-2 bg-${d}`,"",h);const u=e.metadata;if(u.uid||(u.uid=t.guidGenerator()),u.lastModified&&!u.lastModifiedDate&&(u.lastModifiedDate=this._lastModifiedToStringDate(u.lastModified)),this.useNativeTitle)h.title=a+": "+e.id;else{let i=document.createElement("span");i.className="lexitemdesc",i.id=`floatingTitle_${u.uid}`,i.innerHTML=`File: ${e.id}<br>Type: ${a}`,t.insertChildAtIndex(this.content,i,s?s+1:void 0),h.addEventListener("mousemove",e=>{if(!n)return;const t=e.target,s=h.closest("dialog"),o=h.getBoundingClientRect(),a=t.getBoundingClientRect();let l=o.x+e.offsetX,r=o.y+e.offsetY;if(s){const e=s.getBoundingClientRect();l-=e.x,r-=e.y}t.classList.contains("lexassettitle")&&(r+=a.y-o.y),i.style.left=l+"px",i.style.top=r-36+"px"})}if(this.allowMultipleSelection){let t=document.createElement("input");t.type="checkbox",t.className="lexcheckbox",t.checked=u.selected,t.addEventListener("change",t=>{u.selected=!u.selected;const s=c._callbacks.check;if(void 0!==s){s({type:"check",items:[e],userInitiated:!0})}t.stopPropagation(),t.stopImmediatePropagation()}),h.appendChild(t)}let p=document.createElement("span");if(p.className="lexassettitle",p.innerText=e.id,h.appendChild(p),!this.skipPreview){if("video"===e.type){const s=t.makeElement("video","absolute left-0 top-0 w-full border-none pointer-events-none","",h);s.setAttribute("disablePictureInPicture",!1),s.setAttribute("disableRemotePlayback",!1),s.setAttribute("loop",!0),s.setAttribute("async",!0),s.style.transition="opacity 0.2s ease-out",s.style.opacity=u.preview?"0":"1",s.src=e.src,s.volume=u.volume??.4}let s=null;const i=u.preview??e.src;if(i&&((()=>{const e=t.getExtension(i.split("?")[0].split("#")[0]);return!!e&&["png","jpg","jpeg","gif","bmp","avif"].includes(e.toLowerCase())})()||i.startsWith("data:image/"))||r||!n){const e=`${this.rootPath}images/file.png`,t=`${this.rootPath}images/folder.png`;s=document.createElement("img");let o=u.unknownExtension?e:r?t:i;s.src=n||r?o:e,s.setAttribute("draggable","false"),s.className="pointer-events-none",h.appendChild(s)}else{s=document.createElement("svg"),s.className="asset-file-preview",h.appendChild(s);let t=document.createElement("text");t.innerText=l&&l!=e.id?`${l.toUpperCase()}`:e.type.toUpperCase(),s.appendChild(t);var m=2.5/t.innerText.length;if(m<1){var g=64*m;t.style.fontSize=g+"px",s.style.paddingTop=`calc(50% - ${.5*t.offsetHeight+10}px)`}}}let f=a;o&&(u.bytesize&&(f+=` | ${t.formatBytes(u.bytesize)}`),u.lastModifiedDate&&(f+=` | ${u.lastModifiedDate}`)),t.makeContainer(["auto","auto"],"lexassetinfo",f,h),h.addEventListener("click",function(s){s.stopImmediatePropagation(),s.stopPropagation();const i=s.detail==t.MOUSE_DOUBLE_CLICK;if(i){if(r)return void c._enterFolder(e)}else s.shiftKey||c.content.querySelectorAll(".lexassetitem").forEach(e=>e.classList.remove("selected")),this.classList.add("selected"),c.selectedItem=e,c.skipPreview||c._previewAsset(e);const o=c._callbacks.select,n=c._callbacks.dblClick;if(i&&void 0!==n){n({type:"dbl_click",items:[e],userInitiated:!0})}else if(!i&&void 0!==o){o({type:"select",items:[e],userInitiated:!0})}}),h.addEventListener("contextmenu",function(s){s.preventDefault(),s.stopImmediatePropagation(),s.stopPropagation();const i=c.content.querySelectorAll(".selected").length,o=[{name:i>1?i+" selected":e.id,icon:t.makeIcon("CircleSmall",{svgClass:`fill-current fg-${d}`}),className:"text-sm",disabled:!0},null];if(i<=1&&o.push({name:"Rename",icon:"TextCursor",callback:c._renameItemPopover.bind(c,e)}),r||o.push({name:"Clone",icon:"Copy",callback:c._requestCloneItem.bind(c,e)}),o.push({name:"Move",icon:"FolderInput",callback:()=>c._moveItem(e)}),"Script"==a&&t.has("CodeEditor")&&o.push({name:"Open in Editor",icon:"Code",callback:c._openScriptInEditor.bind(c,e)}),c.itemContextMenuOptions){o.push(null);for(let t of c.itemContextMenuOptions)t.name&&t.callback&&o.push({name:t.name,icon:t.icon,callback:t.callback?.bind(c,e)})}o.push(null,{name:"Delete",icon:"Trash2",className:"fg-error",callback:c._requestDeleteItem.bind(c,e)}),t.addClass(c.contentPanel.root,"pointer-events-none"),t.addDropdownMenu(s.target,o,{side:"right",align:"start",event:s,onBlur:()=>{t.removeClass(c.contentPanel.root,"pointer-events-none")}})});const C=function(e,t){if("Folder"!==t.type.charAt(0).toUpperCase()+t.type.slice(1)||e.metadata.uid==t.metadata.uid)return void console.error("[AssetView Error] Cannot drop: Target item is not a folder or target is the dragged element!");const s=e.domEl;s&&(s.classList.add("moving-to-folder"),s.addEventListener("animationend",()=>{s.classList.remove("moving-to-folder"),c._requestMoveItemToFolder(e,t)},{once:!0}))};return h.addEventListener("dragstart",t=>{window.__av_item_dragged=e;var s=new Image;s.src="",t.dataTransfer&&(t.dataTransfer.setDragImage(s,0,0),t.dataTransfer.effectAllowed="move");const i=c.content.querySelector(`#floatingTitle_${u.uid}`);i&&(i.style.display="none")},!1),h.addEventListener("dragend",e=>{e.preventDefault();let t=window.__av_item_dragged;t&&t._nodeTarget&&C(t,t._nodeTarget),delete window.__av_item_dragged},!1),h.addEventListener("dragenter",s=>{s.preventDefault();let i=window.__av_item_dragged;i&&r&&i.metadata.uid!=u.uid&&t.addClass(e.domEl,"animate-pulse")}),h.addEventListener("dragleave",s=>{s.preventDefault(),window.__av_item_dragged&&t.removeClass(e.domEl,"animate-pulse")}),h.addEventListener("drop",t=>{t.preventDefault();let s=window.__av_item_dragged;s&&C(s,e)}),h.addEventListener("mouseenter",t=>{if(!c.useNativeTitle&&n){const e=c.content.querySelector(`#floatingTitle_${u.uid}`);e&&(e.style.display="unset")}if("video"!==e.type)return;t.preventDefault();const s=h.querySelector("video");s.style.opacity="1",s.play()}),h.addEventListener("mouseleave",t=>{if(!c.useNativeTitle&&n&&setTimeout(()=>{const e=c.content.querySelector(`#floatingTitle_${u.uid}`);e&&(e.style.display="none")},100),"video"!==e.type)return;t.preventDefault();const s=h.querySelector("video");s.pause(),s.currentTime=0,u.preview&&(s.style.opacity="0")}),!this.skipBrowser&&i&&this.tree.refresh(),h}clear(){this.previewPanel&&this.previewPanel.clear(),this.leftPanel&&this.leftPanel.clear(),this.toolsPanel&&this.toolsPanel.clear()}_processData(e,t){e.constructor!==Array&&(e.parent=t,e.dir=t?.children,e.children=e.children??[],e.metadata=e.metadata||{});const s=t?e:this.rootItem;for(let e of s.children)this._processData(e,s)}_updatePath(){if(this.path.length=0,this.currentFolder&&this.currentFolder.parent){this.path.push(this.currentFolder.id);const e=t=>{t&&(this.path.push(t.parent?t.id:"@"),e(t.parent))};e(this.currentFolder.parent)}else this.path.push("@");t.emitSignal("@on_folder_change",this.path.reverse().join("/"))}_createNavigationBar(e){e.sameLine(4,"justify-center"),e.addButton(null,"GoBackButton",()=>{this.prevData.length&&this.currentFolder&&(this.nextData.push(this.currentFolder),this._enterFolder(this.prevData.pop(),!1))},{buttonClass:"bg-none",title:"Go Back",tooltip:!0,icon:"ArrowLeft"}),e.addButton(null,"GoForwardButton",()=>{this.nextData.length&&this.currentFolder&&this._enterFolder(this.nextData.pop())},{buttonClass:"bg-none",title:"Go Forward",tooltip:!0,icon:"ArrowRight"}),e.addButton(null,"GoUpButton",()=>{const e=this.currentFolder?.parent;e&&this._enterFolder(e)},{buttonClass:"bg-none",title:"Go Upper Folder",tooltip:!0,icon:"ArrowUp"}),e.addButton(null,"GoUpButton",()=>{this._refreshContent()},{buttonClass:"bg-none",title:"Refresh",tooltip:!0,icon:"Refresh"})}_createTreePanel(e){this.leftPanel?this.leftPanel.clear():this.leftPanel=e.addPanel({className:"lexassetbrowserpanel"}),this._createNavigationBar(this.leftPanel);const s={id:"/",children:this.data},i=this.leftPanel.addTree("Content Browser",s,{filter:!1,onlyFolders:this.onlyFolders,onevent:e=>{let s=e.node,i=e.value;switch(e.type){case t.TreeEvent.NODE_SELECTED:if(e.multiple)return;if(s.parent){if(this._enterFolder("folder"===s.type?s:s.parent),this._previewAsset(s),"folder"!==s.type){this.content.querySelectorAll(".lexassetitem").forEach(e=>e.classList.remove("selected"));const e=s.domEl;e?.classList.add("selected")}this.selectedItem=s}else this.currentFolder&&this.prevData.push(this.currentFolder),this.currentFolder=void 0,this.currentData=this.data,this._refreshContent(),this._updatePath();break;case t.TreeEvent.NODE_DRAGGED:if(s.parent){const e=s.parent.children.indexOf(s);s.parent.children.splice(e,1)}i.children||(i.children=[]),i.children.push(s),s.parent=i,s.dir=i.children,this.onItemDragged&&this.onItemDragged(s,i),this._refreshContent()}}});this.tree=i.innerTree}_setContentLayout(e){this.layout=e,this.toolsPanel.refresh(),this._refreshContent()}_createContentPanel(e){const s=this;e.root.classList.add("flex","flex-col"),this.toolsPanel?this.contentPanel.clear():(this.toolsPanel=e.addPanel({className:"flex-auto",height:"auto"}),this.contentPanel=e.addPanel({className:"lexassetcontentpanel flex flex-col flex-auto-fill content-center overflow-hidden"}),this._paginator=new t.Pagination({className:"ml-auto",pages:Math.max(Math.ceil(this.data.length/this.assetsPerPage),1),onChange:()=>this._refreshContent()}),this.contentPanel.root.addEventListener("wheel",e=>{if(!e.ctrlKey)return;e.preventDefault(),this.gridScale*=e.deltaY<0?1.05:.95,this.gridScale=t.clamp(this.gridScale,.5,2);document.querySelector(":root").style.setProperty("--av-grid-scale",this.gridScale)}));const i=(e,s)=>{t.addDropdownMenu(s.target,[{name:"Name",icon:"ALargeSmall",callback:()=>this._sortData("id")},{name:"Type",icon:"Type",callback:()=>this._sortData("type")},null,{name:"Ascending",icon:"SortAsc",callback:()=>this._sortData(void 0,be.CONTENT_SORT_ASC)},{name:"Descending",icon:"SortDesc",callback:()=>this._sortData(void 0,be.CONTENT_SORT_DESC)}],{side:"bottom",align:"start"})},o=(e,s)=>{t.addDropdownMenu(s.target,[{name:"Grid",icon:"LayoutGrid",callback:()=>this._setContentLayout(be.LAYOUT_GRID)},{name:"Compact",icon:"LayoutList",callback:()=>this._setContentLayout(be.LAYOUT_COMPACT)},{name:"List",icon:"List",callback:()=>this._setContentLayout(be.LAYOUT_LIST)}],{side:"bottom",align:"start"})};this.toolsPanel.refresh=()=>{this.toolsPanel.clear();const e=Object.keys(this.allowedTypes);this.skipBrowser&&this._createNavigationBar(this.toolsPanel),this.toolsPanel.sameLine();const t=this.toolsPanel.addButton(null,"",i.bind(this),{title:"Sort",tooltip:!0,icon:this.sortMode===be.CONTENT_SORT_ASC?"SortAsc":"SortDesc"});if(this.toolsPanel.addButton(null,"",o.bind(this),{title:"View",tooltip:!0,icon:this.layout===be.LAYOUT_GRID?"LayoutGrid":"LayoutList"}),this.toolsPanel.addSelect(null,e,this.filter??e[0],e=>{this._refreshContent(void 0,e)},{overflowContainer:null}),this.toolsPanel.addText(null,this.searchValue??"",e=>this._refreshContent(e),{className:"flex flex-auto-fill",placeholder:"Search assets.."}),this.toolsPanel.endLine(),this._paginator){t.root.parentElement.appendChild(this._paginator.root)}},this.content=document.createElement("ul"),this.content.className="lexassetscontent",this.contentPanel.attach(this.content),this.skipBrowser||this.contentPanel.addText(null,this.path.join("/"),null,{inputClass:"bg-none fg-quinary text-end",disabled:!0,signal:"@on_folder_change"}),this.content.addEventListener("dragenter",function(e){e.preventDefault(),this.classList.add("dragging")}),this.content.addEventListener("dragleave",function(e){e.preventDefault(),this.classList.remove("dragging")}),this.content.addEventListener("drop",e=>{e.preventDefault(),this._processDrop(e)}),this.content.addEventListener("click",function(){this.querySelectorAll(".lexassetitem").forEach(e=>e.classList.remove("selected"))}),this.content.addEventListener("contextmenu",function(e){e.preventDefault();const i=[{name:"New Folder",icon:t.makeIcon("FolderPlus"),callback:()=>{s._requestCreateFolder()}}];t.addClass(s.contentPanel.root,"pointer-events-none"),t.addDropdownMenu(e.target,i,{side:"right",align:"start",event:e,onBlur:()=>{t.removeClass(s.contentPanel.root,"pointer-events-none")}})}),this._refreshContent(),t.doAsync(()=>this.toolsPanel.refresh(),100)}_makeNameFilterFn(e){const s=e.trim();if(s.includes("*")||s.includes("?")){const e=t.wildcardToRegExp(s);return t=>e.test(t)}return e=>e.toLowerCase().includes(s.toLowerCase())}_refreshContent(e,s){const i=this.layout==be.LAYOUT_COMPACT,o=this.layout==be.LAYOUT_LIST;if(this.filter=s??this.filter??"None",this.searchValue=e??this.searchValue??"",this.content.innerHTML="",this.content.className="lexassetscontent"+(i?" compact":o?" list":""),!this.currentData.length)return;const n=new FileReader,a=this._makeNameFilterFn(this.searchValue),l=this.currentData.filter(e=>{const t="None"===this.filter||e.type.toLowerCase()===this.filter.toLowerCase(),s=a(e.id);return t&&s});this._paginator?.setPages(Math.max(Math.ceil(l.length/this.assetsPerPage),1));const r=this._paginator?(this._paginator.page-1)*this.assetsPerPage:0,c=this._paginator?Math.min(r+this.assetsPerPage,l.length):l.length;for(let i=r;i<c;++i){let o=l[i];o.path?t.request({url:o.path,dataType:"blob",success:t=>{o.metadata.bytesize=t.size,n.readAsDataURL(t),n.onload=t=>{const i=t.currentTarget;o.src=i.result,o.metadata.path=o.path,delete o.path,this._refreshContent(e,s)}}}):o.domEl=this.addItem(o,void 0,!1)}this.onRefreshContent&&this.onRefreshContent(e,s)}_previewAsset(e){if(this.skipPreview)return;const s=e.src&&e.src.includes("data:image/");if(e.metadata=e.metadata??{},this.previewPanel.clear(),this.previewPanel.branch("Asset"),"image"==e.type||e.src){(["png","jpg"].indexOf(t.getExtension(e.src))>-1||s)&&this.previewPanel.addImage(null,e.src,{style:{width:"100%"}})}e.metadata.lastModified&&!e.metadata.lastModifiedDate&&(e.metadata.lastModifiedDate=this._lastModifiedToStringDate(e.metadata.lastModified));const i={disabled:!0};this.previewPanel.addText("Filename",e.id,null,i),e.metadata.lastModifiedDate&&this.previewPanel.addText("Last Modified",e.metadata.lastModifiedDate,null,i),(e.metadata.path||e.src)&&this.previewPanel.addText("URL",e.metadata.path?e.metadata.path:e.src,null,i),this.previewPanel.addText("Path",this.path.join("/"),null,i),this.previewPanel.addText("Type",e.type,null,i),e.metadata.bytesize&&this.previewPanel.addText("Size",t.formatBytes(e.metadata.bytesize),null,i),"folder"==e.type&&this.previewPanel.addText("Files",e.children?e.children.length.toString():"0",null,i),this.previewPanel.addSeparator();const o=[...this.previewActions];o.length||"folder"===e.type||o.push({name:"Download",callback:()=>t.downloadURL(e.src,e.id)});for(let t of o)t.type&&t.type!==e.type||t.path&&t.path!==this.path.join("/")||this.previewPanel.addButton(null,t.name,t.callback.bind(this,e));this.previewPanel.merge()}_processDrop(e){if(!e.dataTransfer||!e.dataTransfer.files||0==e.dataTransfer.files.length)return;const t=new FileReader,s=e.dataTransfer.files.length;for(let i=0;i<e.dataTransfer.files.length;++i){const o=e.dataTransfer.files[i],n=this.currentData.find(e=>e.id===o.name);n||(t.readAsDataURL(o),t.onload=e=>{let t=o.name.substring(o.name.lastIndexOf(".")+1).toLowerCase(),n=null;switch(t){case"png":case"jpg":n="image";break;case"js":case"css":n="script";break;case"json":n="json";break;case"obj":n="mesh";break;default:n=t}let a={id:o.name,src:e.currentTarget.result,type:n,children:[],metadata:{extension:t,lastModified:o.lastModified,lastModifiedDate:this._lastModifiedToStringDate(o.lastModified),unknownExtension:n==t}};this.currentData.push(a),i==s-1&&(this._refreshContent(),this.tree?.refresh())})}}_sortData(e,t){e=e??this._lastSortBy??"id";const s=(t=t??this.sortMode)===be.CONTENT_SORT_DESC;this.currentData=this.currentData.sort((t,i)=>{var o=s?i[e].localeCompare(t[e]):t[e].localeCompare(i[e]);return 0==o&&(o=s?i.id.localeCompare(t.id):t.id.localeCompare(i.id)),o}),this._lastSortBy=e,this.sortMode=t,this.toolsPanel.refresh(),this._refreshContent()}async _enterFolder(e,t=!0){if(!e)return;const s=this.currentData[0],i=s?.parent?.id===e.id;t&&this.prevData.push(this.currentFolder??{id:"/",children:this.data,type:"root",metadata:{}});let o=!i;const n=this._callbacks.enterFolder;if(void 0!==n){const t={type:"enter_folder",to:e,userInitiated:!0},s=await n(t);o=o||s}this.currentFolder=e,this.currentData=this.currentFolder?.children??[],o&&(this._processData(this.data),this._refreshContent()),this._updatePath()}_removeItemFromParent(e){const t=e.parent;if(t){const s=t.children?.indexOf(e)??-1;if(s<0)return!1;t.children?.splice(s,1)}else{const t=e.dir;if(t){const s=t.indexOf(e);if(s<0)return!1;t.splice(s,1)}}return!0}_requestDeleteItem(e){const t=this._callbacks.beforeDelete,s=this._callbacks.delete,i=(...t)=>{this._deleteItem(e);s&&s({type:"delete",items:[e],userInitiated:!0},...t)};if(t){t({type:"delete",items:[e],userInitiated:!0},i)}else i()}_deleteItem(e){this._removeItemFromParent(e)?(this._refreshContent(this.searchValue,this.filter),this.tree?.refresh(),this.previewPanel?.clear()):console.error("[AssetView Error] Cannot delete. Item not found.")}_requestMoveItemToFolder(e,t){const s=this._callbacks.beforeMove,i=this._callbacks.move,o=(...s)=>{this._moveItemToFolder(e,t);const o={type:"move",items:[e],from:e.parent,to:t,userInitiated:!0};i&&i(o,...s)};if(s){s({type:"move",items:[e],from:e.parent,to:t,userInitiated:!0},o)}else o()}_moveItemToFolder(e,t){this._removeItemFromParent(e)?(t.children=t.children??[],t.children.push(e),e.parent=t,e.dir=t.children,this._refreshContent(),this.tree?.refresh(),this._moveItemDialog?.destroy(),this._movingItem=void 0):console.error("[AssetView Error] Cannot move. Item not found.")}_moveItem(e,s){this._moveItemDialog&&this._moveItemDialog.destroy(),this._movingItem=e;let i,o=null;const n=function(e,s,a=!0){s.innerHTML="",o=e;for(let e of o.children??o){const i=t.makeContainer(["100%","auto"],"flex flex-row px-1 items-center","",s),a="folder"===e.type,l=t.makeContainer(["100%","auto"],`move-item flex flex-row gap-1 py-1 px-3 cursor-pointer ${a?"fg-primary font-medium":"fg-quinary"} rounded-xxl ${a?"hover:bg-secondary":"hover:bg-primary"}`,`${a?t.makeIcon("FolderOpen",{svgClass:""}).innerHTML:""}${e.id}`,i);if(a){l.addEventListener("click",()=>{s.querySelectorAll(".move-item").forEach(e=>t.removeClass(e,"bg-quinary")),t.addClass(l,"bg-quinary"),o=e});const a=new t.Button(null,"FPathButton",()=>{n(e,s)},{icon:"ChevronRight",className:"ml-auto h-8",buttonClass:"bg-none hover:bg-secondary"});i.appendChild(a.root)}}if(!a)return;const l=[];if(o&&o.parent){l.push(o.id);const e=t=>{t&&(l.push(t.parent?t.id:"@"),e(t.parent))};e(o.parent)}else l.push("@");i.innerHTML="",i.appendChild(t.makeBreadcrumb(l.reverse().map(e=>({title:e})),{maxItems:4,separatorIcon:"ChevronRight"}))};this._moveItemDialog=new t.Dialog(`Moving: ${e.id}`,a=>{const l=new t.Area({className:"flex flex-col rounded-lg"});a.attach(l);const r=t.makeContainer(["auto","100%"],"flex flex-auto-fill flex-col overflow-scroll py-2 gap-1","");{const e=l.addPanel({className:"p-2 border-bottom flex flex-auto",height:"auto"});e.sameLine(2,"w-full"),e.addButton(null,"BackButton",()=>{o&&o.parent&&n(o.parent,r)},{icon:"ArrowLeft",title:"Back",tooltip:!0,className:"flex-auto",buttonClass:"bg-none hover:bg-secondary"}),i=t.makeElement("div"),e.addContent("ITEM_MOVE_PATH",i,{signal:"@item_move_path",className:"flex-auto-fill"})}l.attach(r),n(s??this.data,r);{const t=l.addPanel({className:"p-2 border-top flex flex-auto justify-between",height:"auto"});t.addButton(null,"NewFolderButton",()=>{this._requestCreateFolder(o)},{width:"auto",icon:"FolderPlus",title:"Create Folder",tooltip:!0,className:"ml-2",buttonClass:"bg-none hover:bg-secondary"}),t.sameLine(2,"mr-2"),t.addButton(null,"Cancel",()=>{this._moveItemDialog.close()},{buttonClass:"bg-none fg-error"}),t.addButton(null,"Move",()=>{this._requestMoveItemToFolder(e,o)},{className:"",buttonClass:"contrast"})}},{modal:!0,size:["616px","500px"],closable:!0,onBeforeClose:()=>{delete this._moveItemDialog}})}_requestCloneItem(e){if("folder"===e.type)return void console.error("[AssetView Error] Cannot clone a folder.");if((e.dir??[]).indexOf(e)<0)return console.error("[AssetView Error] Cannot clone. Item not found."),!1;const t=this._callbacks.beforeClone,s=this._callbacks.clone,i=(...t)=>{const i=this._cloneItem(e);s&&s({type:"clone",items:[e],result:[i],userInitiated:!0},...t)};if(t){t({type:"clone",items:[e],userInitiated:!0},i)}else i()}_cloneItem(e){const s=e.parent,i=e.dir??[],o=i.indexOf(e);delete e.domEl,delete e.dir,delete e.parent;const n=t.deepCopy(e);return n.id=this._getClonedName(e.id,i),n.dir=e.dir=i,n.parent=e.parent=s,n.metadata.uid=t.guidGenerator(),i.splice(o+1,0,n),this._refreshContent(this.searchValue,this.filter),n}_getClonedName(e,s){const i=e.lastIndexOf(".");let o=e,n="";i>0&&(o=e.substring(0,i),n=e.substring(i));const a=o.match(/^(.*)\s\((\d+)\)$/);a&&(o=a[1]);let l=-1;for(const e of s){if(!e.id)continue;let s=e.id,i="";const a=s.lastIndexOf(".");if(a>0&&(i=s.substring(a),s=s.substring(0,a)),i!==n)continue;const r=s.match(new RegExp("^"+t.escapeRegExp(o)+"\\s\\((\\d+)\\)$"));if(r){const e=parseInt(r[1]);e>l&&(l=e)}else s===o&&(l=Math.max(l,0))}return-1===l?e:`${o} (${l+1})${n}`}_requestRenameItem(e,t){const s=this._callbacks.beforeRename,i=this._callbacks.rename,o=e.id,n=(...s)=>{this._renameItem(e,t);i&&i({type:"rename",items:[e],oldName:o,newName:t,userInitiated:!0},...s)};if(s){s({type:"rename",items:[e],oldName:o,newName:t,userInitiated:!0},n)}else n()}_renameItem(e,s){const i=this.currentData.indexOf(e);if(i<0)return;const o=t.hasClass(e.domEl,"selected"),n=this.content.querySelector(`#floatingTitle_${e.id.replace(/\s/g,"_").replaceAll(".","_")}`);n&&n.remove(),e.domEl?.remove(),e.id=s,e.domEl=this.addItem(e,2*i),o&&this._previewAsset(e),this.tree?.refresh(),this._processData(this.data)}_renameItemPopover(e){if(this.currentData.indexOf(e)<0)return;const s=t=>{n.destroy(),this._requestRenameItem(e,t)};let i=e.id;const o=new t.Panel;o.addText(null,e.id,(e,t)=>{i=e,t.constructor===KeyboardEvent&&s(e)}),o.addButton(null,"Save",()=>{s(i)},{buttonClass:"contrast"});const n=new t.Popover(e.domEl,[o],{align:"center",side:"bottom",sideOffset:-128})}_requestCreateFolder(e){if(!(e=e??this.currentFolder))return;const t=this._callbacks.beforeCreateFolder,s=this._callbacks.createFolder,i=(...t)=>{const i=this._createFolder(e);s&&s({type:"create-folder",result:[i],where:e,userInitiated:!0},...t)};if(t){t({type:"create-folder",where:e,userInitiated:!0},i)}else i()}_createFolder(e){if(!(e=e??this.currentFolder))throw"_createFolder: Something went wrong!";const t={id:this._getClonedName("New Folder",e.children),type:"folder",children:[],parent:this.currentFolder,metadata:{}};return e.children.push(t),this._refreshContent(),this.tree?.refresh(),this._moveItemDialog&&this._movingItem&&this._moveItem(this._movingItem,e),e}_openScriptInEditor(e){this._scriptCodeDialog&&this._scriptCodeDialog.destroy(),this._scriptCodeDialog=new t.Dialog(null,s=>{const i=new t.Area({className:"rounded-lg"});s.attach(i),new t.CodeEditor(i,{allowAddScripts:!1,files:[e.src]})},{size:["50%","600px"],closable:!0,onBeforeClose:()=>{delete this._scriptCodeDialog}})}_setAssetsPerPage(e){this._assetsPerPage=e,this._refreshContent()}_lastModifiedToStringDate(e){const t=new Date(e).toLocaleString();return t.substring(0,t.indexOf(","))}}if(t.AssetView=be,!t)throw"Missing LX namespace!";t.extensions.push("Audio");const _e=t.Panel,xe=t.BaseComponent,Le=t.ComponentType,Se=t.IEvent;class ke extends xe{constructor(e,s,i,o,n,a={}){s.constructor==Number&&(s=t.clamp(s,i,o),s=a.precision?t.round(s,a.precision):s),super(Le.KNOB,e,s,a),this.onGetValue=()=>d.value,this.onSetValue=(e,s,i)=>{m(e),t.BaseComponent._dispatchEvent(d,"change",s)},this.onResize=()=>{const e=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${e})`};const l=a.snap&&a.snap.constructor==Number,r=[];if(l){const e=(o-i)/a.snap;for(let t=0;t<a.snap+1;++t)r.push(i+t*e)}var c=document.createElement("div");c.className="lexknob",t.addClass(c,a.size),t.addClass(c,l?"show-ticks":null);let h=document.createElement("div");h.className="knobcircle",l&&h.style.setProperty("--knob-snap-mark",270/a.snap+"deg");let d=document.createElement("div");d.className="innerknobcircle",d.min=i,d.max=o,h.appendChild(d);let u=document.createElement("div");u.className="knobmarker",d.appendChild(u),d.value=d.iValue=s;let p=!1,m=function(e){const s=t.remapRange(e,d.min,d.max,-135,135);d.style.rotate=s+"deg",d.value=e};const g=t.remapRange(s,i,o,-135,135);d.style.rotate=g+"deg",a.disabled&&t.addClass(c,"disabled"),d.addEventListener("change",s=>{const i=s.target,o=s.detail;p&&(i.value=r.reduce((e,t)=>Math.abs(t-i.value)<Math.abs(e-i.value)?t:e));let c=i.value=t.clamp(i.value,i.min,i.max);if(c=a.precision?t.round(c,a.precision):c,m(c),!o){let t=this.root.querySelector(".lexcomponentname .lexicon");t&&(t.style.display=c!=d.iValue?"block":"none"),l&&!p||(this._trigger(new Se(e,c,s),n),p=!1)}},{passive:!1}),d.addEventListener("mousedown",function(e){if(document.activeElement==d||a.disabled)return;var t=f.root.ownerDocument;t.addEventListener("mousemove",C),t.addEventListener("mouseup",v),document.body.classList.add("noevents"),document.pointerLockElement||c.requestPointerLock();e.stopImmediatePropagation(),e.stopPropagation()});var f=this;function C(e){let s=-e.movementY;if(0!=s){let i=a.step??1;e.shiftKey?i*=10:e.altKey&&(i*=.1);let o=d.value-i*s;d.value=o,t.BaseComponent._dispatchEvent(d,"change")}e.stopPropagation(),e.preventDefault()}function v(e){var s=f.root.ownerDocument;s.removeEventListener("mousemove",C),s.removeEventListener("mouseup",v),document.body.classList.remove("noevents"),l&&(p=!0,t.BaseComponent._dispatchEvent(d,"change")),document.pointerLockElement&&document.exitPointerLock()}c.appendChild(h),this.root.appendChild(c),t.doAsync(this.onResize.bind(this))}}t.Knob=ke;if(_e.prototype.addKnob=function(e,t,s,i,o,n={}){const a=new ke(e,t,s,i,o,n);return this._attachComponent(a)},!t)throw"Missing LX namespace!";t.extensions.push("CodeEditor");const Ee=globalThis;function Te(e,t,s){[e[t],e[s]]=[e[s],e[t]]}function we(e,t,s=1){return e.substr(0,t)+e.substr(t+s)}function Me(e){const t=e.search(/\S|$/);return t<e.length?t:-1}function Ae(e){return e.split("").reverse().join("")}function Ne(e){return/[a-zA-Z]/.test(e)}function Pe(e){return/[^\w\s]/.test(e)}function Oe(e,t,s,i=!1){if(s=s??0,i){e=e.substring(0,s);for(var o=s-1;e[o]&&e[o]!=t;)o--;return e[o]?o:-1}return s+(e=e.substring(s)).indexOf(t)}t.vec2,t.Area,t.Panel,t.Tree,t.Tabs,t.ContextMenu;class Ie{root;name="";editor;isMain=!1;selection=null;_line=0;_position=0;get line(){return this._line}set line(e){this._line=e,this.isMain&&this.editor._setActiveLine(e)}get position(){return this._position}set position(e){if(this._position=e,this.isMain){const t=this.editor.state.activeLine;this.editor._updateDataInfoPanel("@cursor-data",`Ln ${t+1}, Col ${e+1}`)}}left=0;top=0;constructor(e,t=0,s=0,i=!1,o){this.name=e,this.editor=o,this.isMain=i,this.root=document.createElement("div"),this.root.name=e,this.root.className="cursor",this.root.innerHTML=" ",this.set(t,s,!1)}set(e=0,t=0,s=!0){this.left=e*this.editor.charWidth,this.top=t*this.editor.lineHeight,this.root.style.left=`calc( ${this.left}px + ${this.editor.xPadding} )`,this.root.style.top=`${this.top}px`,s?(this.line=t,this.position=e):(this._line=t,this._position=e)}print(){console.log(this.line,this.position)}isLast(){return this.editor._getLastCursor()==this}}class Re{fromX;toX;fromY;toY;chars=0;editor;cursor;className;constructor(e,t,s="lexcodeselection"){this.editor=e,this.cursor=t,this.className=s,this.fromX=t.position,this.toX=t.position,this.fromY=t.line,this.toY=t.line}sameLine(){return this.fromY===this.toY}samePosition(){return this.fromX===this.toX}isEmpty(){return this.sameLine()&&this.samePosition()}invertIfNecessary(){this.fromY>this.toY?(Te(this,"fromX","toX"),Te(this,"fromY","toY")):this.sameLine()&&this.fromX>this.toX&&Te(this,"fromX","toX")}selectInline(e,t,s,i,o){this.chars=i/this.editor.charWidth,this.fromX=t,this.toX=t+this.chars,this.fromY=this.toY=s;var n=document.createElement("div");n.className=this.className,n._top=s*this.editor.lineHeight,n.style.top=n._top+"px",n._left=t*this.editor.charWidth,n.style.left="calc("+n._left+"px + "+this.editor.xPadding+")",n.style.width=i+"px",o?this.editor.searchResultSelections.appendChild(n):this.editor.selections[e.name].appendChild(n),this.editor._hideActiveLine()}save(){return{fromX:this.fromX,fromY:this.fromY,toX:this.toX,toY:this.toY}}load(e){this.fromX=e.fromX,this.fromY=e.fromY,this.toX=e.toX,this.toY=e.toY}getText(){return this.editor.code&&this.sameLine()?this.editor.code.lines[this.fromY].substring(this.fromX,this.toX):null}}class De{static SCROLLBAR_VERTICAL=1;static SCROLLBAR_HORIZONTAL=2;static SCROLLBAR_VERTICAL_WIDTH=10;static SCROLLBAR_HORIZONTAL_HEIGHT=10;editor;type;root;thumb;lastPosition;constructor(e,s){this.editor=e,this.type=s,this.root=document.createElement("div"),this.root.className="lexcodescrollbar hidden",s&De.SCROLLBAR_VERTICAL?this.root.classList.add("vertical"):s&De.SCROLLBAR_HORIZONTAL&&this.root.classList.add("horizontal"),this.thumb=document.createElement("div"),this.thumb._top=0,this.thumb._left=0,this.root.appendChild(this.thumb),this.thumb.addEventListener("mousedown",function(t){var s=e.root.ownerDocument;s.addEventListener("mousemove",o),s.addEventListener("mouseup",n),i.lastPosition.set(t.x,t.y),t.stopPropagation(),t.preventDefault()}),this.lastPosition=new t.vec2(0,0);let i=this;function o(s){var o=i.lastPosition.sub(new t.vec2(s.x,s.y));i.type&De.SCROLLBAR_VERTICAL?e.updateVerticalScrollFromScrollBar(o.y):e.updateHorizontalScrollFromScrollBar(o.x),i.lastPosition.set(s.x,s.y),s.stopPropagation(),s.preventDefault()}function n(t){var s=e.root.ownerDocument;s.removeEventListener("mousemove",o),s.removeEventListener("mouseup",n)}}}const ze={common:[{test:e=>e.inBlockComment,className:"cm-com"},{test:e=>e.inString,action:(e,t)=>t._appendStringToken(e.token),discard:!0},{test:e=>e.token.substr(0,e.singleLineCommentToken.length)==e.singleLineCommentToken,className:"cm-com"},{test:(e,t)=>t._isKeyword(e),className:"cm-kwd"},{test:(e,t)=>t._mustHightlightWord(e.token,He.builtIn,e.lang)&&(!e.lang.tags||t._enclosedByTokens(e.token,e.tokenIndex,"<",">")),className:"cm-bln"},{test:(e,t)=>t._mustHightlightWord(e.token,He.statements,e.lang),className:"cm-std"},{test:(e,t)=>t._mustHightlightWord(e.token,He.symbols,e.lang),className:"cm-sym"},{test:(e,t)=>t._mustHightlightWord(e.token,He.types,e.lang),className:"cm-typ"},{test:(e,t)=>t._isNumber(e.token)||t._isNumber(e.token.replace(/[px]|[em]|%/g,"")),className:"cm-dec"},{test:e=>e.lang.usePreprocessor&&e.token.includes("#"),className:"cm-ppc"}],javascript:[{test:e=>"class"===e.prev&&"{"===e.next,className:"cm-typ"}],typescript:[{test:e=>e.scope&&","!==e.token&&"enum"==e.scope.type,className:"cm-enu"},{test:e=>":"===e.prev&&void 0!==e.next&&Ne(e.token)||"interface"===e.prev&&"{"===e.next||"enum"===e.prev&&"{"===e.next,className:"cm-typ"},{test:e=>"class"===e.prev&&"{"===e.next||"class"===e.prev&&"<"===e.next||"new"===e.prev&&"("===e.next||"new"===e.prev&&"<"===e.next,className:"cm-typ"},{test:(e,t)=>","!==e.token&&t._enclosedByTokens(e.token,e.tokenIndex,"<",">"),className:"cm-typ"}],cpp:[{test:e=>e.scope&&","!==e.token&&"enum"==e.scope.type,className:"cm-enu"},{test:e=>e.isEnumValueSymbol(e.token),className:"cm-enu"},{test:e=>"class"===e.prev&&"{"===e.next||"struct"===e.prev&&"{"===e.next,className:"cm-typ"},{test:e=>"<"===e.prev&&(">"===e.next||"*"===e.next),className:"cm-typ"},{test:e=>"::"===e.next||"::"===e.prev&&"("!==e.next,className:"cm-typ"},{test:e=>e.isClassSymbol(e.token)||e.isStructSymbol(e.token),className:"cm-typ"}],wgsl:[{test:e=>">"===e.prev&&(!e.next||"{"===e.next),className:"cm-typ"},{test:e=>":"===e.prev&&void 0!==e.next||"struct"===e.prev&&"{"===e.next,className:"cm-typ"},{test:(e,t)=>","!==e.token&&t._enclosedByTokens(e.token,e.tokenIndex,"<",">"),className:"cm-typ"}],css:[{test:e=>"."==e.prev||"::"==e.prev||":"==e.prev&&"{"==e.next||"#"==e.token[0]&&":"!=e.prev,className:"cm-kwd"},{test:e=>":"===e.prev&&(";"===e.next||"!important"===e.next),className:"cm-str"},{test:e=>(void 0===e.prev||"{"===e.prev||";"===e.prev)&&":"===e.next,className:"cm-typ"},{test:e=>"("===e.prev&&")"===e.next&&e.token.startsWith("--"),className:"cm-typ"}],batch:[{test:e=>"@"===e.token||":"===e.prev||"@"===e.prev,className:"cm-kwd"}],markdown:[{test:e=>e.isFirstToken&&e.token.replaceAll("#","").length!=e.token.length,action:(e,t)=>t._markdownHeader=!0,className:"cm-kwd"}],php:[{test:e=>e.token.startsWith("$"),className:"cm-var"},{test:e=>"class"===e.prev&&("{"===e.next||"implements"===e.next)||"enum"===e.prev,className:"cm-typ"}],post_common:[{test:e=>Ne(e.token)&&"@"!=e.token[0]&&","!=e.token[0]&&"("===e.next,className:"cm-mtd"}]};class Be{static __instances=[];static CURSOR_LEFT=1;static CURSOR_TOP=2;static CURSOR_LEFT_TOP=Be.CURSOR_LEFT|Be.CURSOR_TOP;static SELECTION_X=1;static SELECTION_Y=2;static SELECTION_X_Y=Be.SELECTION_X|Be.SELECTION_Y;static KEEP_VISIBLE_LINES=1;static UPDATE_VISIBLE_LINES=2;static WORD_TYPE_METHOD=0;static WORD_TYPE_CLASS=1;static CODE_MIN_FONT_SIZE=9;static CODE_MAX_FONT_SIZE=22;static LINE_GUTTER_WIDTH=48;static RESIZE_SCROLLBAR_H=1;static RESIZE_SCROLLBAR_V=2;static RESIZE_SCROLLBAR_H_V=Be.RESIZE_SCROLLBAR_H|Be.RESIZE_SCROLLBAR_V;static languages={};static keywords;static utils;static types;static builtIn;static statements;static declarationKeywords;static symbols;static nativeTypes;static debugScopes=!1;static debugSymbols=!1;static debugProcessedLines=!1;static _staticReady=!1;root;baseArea;area;codeArea;explorerArea;code;gutter;xPadding="0px";hScrollbar;vScrollbar;codeScroller;codeSizer;explorer;tabs;cursorsDOM;cursors=[];mustProcessLines=!1;blinker;statusPanel;leftStatusPanel;rightStatusPanel;lineScrollMargin;autocomplete;searchbox;searchlinebox;openedTabs={};loadedTabs={};actions={};state;pairKeys;stringKeys;visibleLinesViewport=new t.vec2(0,0);searchResultSelections;firstLineInViewport=-1;selections={};specialKeys;canOpenContextMenu=!0;wasKeyPaired=void 0;mustProcessNextLine;mustProcessPreviousLine;cursorBlinkRate=550;tabSpaces=4;maxUndoSteps=16;lineHeight=20;charWidth=7;fontSize=14;defaultSingleLineCommentToken="//";defaultBlockCommentTokens=["/*","*/"];isAutoCompleteActive=!1;isSearchboxActive=!1;isSearchlineboxActive=!1;skipInfo=!1;disableEdition=!1;skipTabs=!1;useFileExplorer=!1;useAutoComplete=!0;allowClosingTabs=!0;allowLoadingFiles=!0;highlight="Plain Text";explorerName="EXPLORER";newTabOptions;customSuggestions=[];onSave;onRun;onCtrlSpace;onCreateStatusPanel;onContextMenu;onNewTab;onSelectTab;onCreateFile;addExplorerItem;_lastTime=null;_lastProcessedLine=-1;_lastResult=void 0;_lastSelectionKeyDir=void 0;_lastProcessedCursorIndex=null;_lastMaxLineLength=void 0;_lastMouseDown=0;_lastTextFound="";_lastBaseareaWidth=void 0;_blockCommentCache=[];_pendingString=void 0;_skipTabs=void 0;_discardScroll=!1;_markdownHeader=void 0;_tabStorage={};_tripleClickSelection=void 0;_currentOcurrences=void 0;_currentLineNumber=void 0;_currentLineString=void 0;_currentTokenPositions=void 0;_buildingBlockComment=void 0;_buildingString=void 0;_verticalTopOffset=-1;_verticalBottomOffset=-1;_fullVerticalOffset=-1;_scopeStack=null;_mouseDown=void 0;_scopesUpdated=void 0;_stringEnded=!1;_stringInterpolation=void 0;_stringInterpolationOpened=void 0;constructor(e,t={}){if(t.filesAsync){t.files=[...t.filesAsync];return(async()=>(await this._init(e,t),this))()}this._init(e,t)}async _init(e,s={}){if(Ee.editor=this,Be.__instances.push(this),this.skipInfo=s.skipInfo??this.skipInfo,this.disableEdition=s.disableEdition??this.disableEdition,this.skipTabs=s.skipTabs??this.skipTabs,this.useFileExplorer=(s.fileExplorer??this.useFileExplorer)&&!this.skipTabs,this.useAutoComplete=s.autocomplete??this.useAutoComplete,this.allowClosingTabs=s.allowClosingTabs??this.allowClosingTabs,this.allowLoadingFiles=s.allowLoadingFiles??this.allowLoadingFiles,this.highlight=s.highlight??this.highlight,this.newTabOptions=s.newTabOptions,this.customSuggestions=s.customSuggestions??[],this.explorerName=s.explorerName??this.explorerName,this.onSave=s.onSave??s.onsave,this.onRun=s.onRun??s.onrun,this.onCtrlSpace=s.onCtrlSpace,this.onCreateStatusPanel=s.onCreateStatusPanel,this.onContextMenu=s.onContextMenu,this.onNewTab=s.onNewTab,this.onSelectTab=s.onSelectTab,this.useFileExplorer){let[s,i]=e.split({sizes:["15%","85%"]});this.explorerArea=s;let o=new t.Panel;o.addTitle(this.explorerName);let n=[];this.explorer=o.addTree(null,n,{filter:!1,rename:!1,skipDefaultIcon:!0,onevent:e=>{switch(e.type){case t.TreeEvent.NODE_DBLCLICKED:this.loadTab(e.node.id);break;case t.TreeEvent.NODE_DELETED:this.closeTab(e.node.id)}}}),this.addExplorerItem=function(e){this.explorer.innerTree.data.find((t,s)=>t.id===e.id)||this.explorer.innerTree.data.push(e)},s.attach(o),e=i}if(this.baseArea=e,this.area=new t.Area({className:"lexcodeeditor",height:"100%",skipAppend:!0}),this.skipTabs){this.codeArea=new t.Area({skipAppend:!0}),this.area.attach(this.codeArea);const e=t.makeElement("button","grid absolute self-center z-100 p-3 rounded-full bg-secondary hover:bg-tertiary cursor-pointer border",t.makeIcon("FolderOpen").innerHTML,this.area,{bottom:"8px"});e.addEventListener("click",s=>{const i=[];for(const[e,t]of[...Object.entries(this.loadedTabs).slice(1),...Object.entries(this._tabStorage)]){const t=this._getFileIcon(e),s=t?t.split(" "):[];i.push({name:e,icon:s[0],svgClass:s.slice(0).join(" "),callback:e=>{this.loadCode(e)}})}new t.DropdownMenu(e,i,{side:"top",align:"center"})})}else this.tabs=this.area.addTabs({onclose:e=>{delete this.openedTabs[e],Object.keys(this.openedTabs).length<2&&(clearInterval(this.blinker),t.removeClas(this.cursorsDOM,"show"))}}),t.addClass(this.tabs.root.parentElement,"rounded-t-lg"),this.disableEdition||this.tabs.root.parentElement.addEventListener("dblclick",e=>{(s.allowAddScripts??1)&&(e.preventDefault(),this._onCreateNewFile())}),this.codeArea=this.tabs.area;this.codeArea.root.classList.add("lexcodearea");new ResizeObserver(e=>{this.code&&this.resize()}).observe(this.codeArea.root),e.root.classList.add("codebasearea");new MutationObserver(e=>{"style"==e[0].attributeName&&this.resize()}).observe(e.root.parentNode,{attributes:!0,attributeFilter:["class","style"]}),this.root=this.area.root,this.root.tabIndex=-1,e.attach(this.root),this.disableEdition?this.root.classList.add("disabled"):(this.root.addEventListener("keydown",this.processKey.bind(this)),this.root.addEventListener("focus",this.processFocus.bind(this,!0)),this.root.addEventListener("focusout",this.processFocus.bind(this,!1))),this.root.addEventListener("mousedown",this.processMouse.bind(this)),this.root.addEventListener("mouseup",this.processMouse.bind(this)),this.root.addEventListener("mousemove",this.processMouse.bind(this)),this.root.addEventListener("click",this.processMouse.bind(this)),this.root.addEventListener("contextmenu",this.processMouse.bind(this)),document.body.addEventListener("mouseup",this._onMouseUp.bind(this)),this.cursorsDOM=document.createElement("div"),this.cursorsDOM.className="cursors",this.codeArea.attach(this.cursorsDOM),this.searchResultSelections=document.createElement("div"),this.searchResultSelections.id="search-selections",this.searchResultSelections.className="selections",this.codeArea.attach(this.searchResultSelections),this.selections={},this.xPadding=Be.LINE_GUTTER_WIDTH+"px",this._addCursor(0,0,!0,!0);{this.codeScroller=this.codeArea.root,this.firstLineInViewport=0,this.lineScrollMargin=new t.vec2(20,20);let e=-1;this.disableEdition||(this.codeScroller.addEventListener("scroll",t=>{if(this._discardScroll)this._discardScroll=!1;else{{this.setScrollBarValue("vertical");const t=this.getScrollTop();if(t>e){if(this.visibleLinesViewport.y<this.code.lines.length-1){const e=this.codeScroller.offsetHeight/this.lineHeight|0;t>=(Math.max(this.visibleLinesViewport.y-e,0)-1)*this.lineHeight&&this.processLines(Be.UPDATE_VISIBLE_LINES)}}else{t<parseInt(this.code.style.top)&&this.processLines(Be.UPDATE_VISIBLE_LINES)}e=t}this.setScrollBarValue("horizontal")}}),this.codeScroller.addEventListener("wheel",e=>{e.ctrlKey&&(e.preventDefault(),e.stopPropagation(),e.deltaY>0?this._decreaseFontSize():this._increaseFontSize())}),this.codeScroller.addEventListener("wheel",e=>{if(!e.ctrlKey){const t=(e.deltaY>0?10:-10)*(e.shiftKey?1:0);0!=t&&this.setScrollBarValue("horizontal",t)}},{passive:!0}))}if(this.gutter=document.createElement("div"),this.gutter.className="lexcodegutter",e.attach(this.gutter),this.vScrollbar=new De(this,De.SCROLLBAR_VERTICAL),e.attach(this.vScrollbar.root),this.hScrollbar=new De(this,De.SCROLLBAR_HORIZONTAL),e.attach(this.hScrollbar.root),!this.disableEdition){this.autocomplete=document.createElement("div"),this.autocomplete.className="autocomplete",this.codeArea.attach(this.autocomplete);{const e=document.createElement("div");e.className="searchbox";const s=new t.Panel;e.appendChild(s.root),s.sameLine(4),s.addText(null,"",null,{placeholder:"Find",inputClass:"bg-secondary"}),s.addButton(null,"up",()=>this.search(null,!0),{icon:"ArrowUp",title:"Previous Match",tooltip:!0}),s.addButton(null,"down",()=>this.search(),{icon:"ArrowDown",title:"Next Match",tooltip:!0}),s.addButton(null,"x",this.hideSearchBox.bind(this),{icon:"X",title:"Close",tooltip:!0});const i=e.querySelector("input");i?.addEventListener("keyup",e=>{"Escape"==e.key?this.hideSearchBox():"Enter"==e.key&&this.search(e.target.value,!!e.shiftKey)}),this.searchbox=e,this.codeArea.attach(e)}{const e=document.createElement("div");e.className="searchbox";const s=new t.Panel;e.appendChild(s.root),s.sameLine(2),s.addText(null,"",e=>{i.value=":"+e.replaceAll(":",""),this.goToLine(i.value.slice(1))},{placeholder:"Go to line",trigger:"input"}),s.addButton(null,"x",this.hideSearchLineBox.bind(this),{icon:"X",title:"Close",tooltip:!0});let i=e.querySelector("input");i.addEventListener("keyup",e=>{"Escape"==e.key&&this.hideSearchLineBox()}),this.searchlinebox=e,this.codeArea.attach(e)}}for(this.codeSizer=document.createElement("div"),this.codeSizer.className="code-sizer pseudoparent-tabs";this.codeScroller.firstChild;)this.codeSizer.appendChild(this.codeScroller.firstChild);if(this.codeScroller.appendChild(this.codeSizer),this.state={focused:!1,selectingText:!1,activeLine:null,keyChain:null},this.pairKeys={'"':'"',"'":"'","(":")","{":"}","[":"]"},this.stringKeys={'@"':'"',"@'":"'"},this.specialKeys=["Backspace","Enter","ArrowUp","ArrowDown","ArrowRight","ArrowLeft","Delete","Home","End","Tab","Escape"],!Be._staticReady){for(let e in Be.keywords)Be.keywords[e]=new Set(Be.keywords[e]);for(let e in Be.utils)Be.utils[e]=new Set(Be.utils[e]);for(let e in Be.types)Be.types[e]=new Set(Be.types[e]);for(let e in Be.builtIn)Be.builtIn[e]=new Set(Be.builtIn[e]);for(let e in Be.statements)Be.statements[e]=new Set(Be.statements[e]);for(let e in Be.symbols)Be.symbols[e]=new Set(Be.symbols[e]);Be._staticReady=!0}this.action("Escape",!1,(e,t,s)=>{this.hideAutoCompleteBox()||this.hideSearchBox()||(this.endSelection(),this._removeSecondaryCursors())}),this.action("Backspace",!1,(e,t,s)=>{if(this._addUndoStep(t),t.selection)this.deleteSelection(t),this._tripleClickSelection&&(this.actions.Backspace.callback(e,t,s),this.lineDown(t,!0));else if(this.getCharAtPos(t,-1)){var i=t.position-1,o=1;if(s.ctrlKey){const[e,s,n]=this.getWordAtPos(t,-1);e.length>1&&(i=s,o=e.length-(n-t.position))}this.code.lines[e]=we(this.code.lines[e],i,o),this.processLine(e),this.cursorToPosition(t,i),this.useAutoComplete&&this.showAutoCompleteBox("foo",t)}else null!=this.code.lines[e-1]&&(this.lineUp(t),s.cancelShift=!0,this.actions.End.callback(t.line,t,s),this.code.lines[e-1]+=this.code.lines[e],this.code.lines.splice(e,1),this.processLines());this.resizeIfNecessary(t,!0)}),this.action("Delete",!1,(e,t,s)=>{(this._addUndoStep(t),t.selection)?this.actions.Backspace.callback(e,t,s):this.getCharAtPos(t)?(this.code.lines[e]=we(this.code.lines[e],t.position),this.processLine(e)):null!=this.code.lines[e+1]&&(this.code.lines[e]+=this.code.lines[e+1],this.code.lines.splice(e+1,1),this.processLines());this.resizeIfNecessary(t,!0)}),this.action("Tab",!0,(e,t,s)=>{if(this._skipTabs)this._skipTabs--,this._skipTabs||delete this._skipTabs;else if(this.isAutoCompleteActive)this.autoCompleteWord();else if(this._addUndoStep(t),s&&s.shiftKey)this._removeSpaces(t);else{const e=this.tabSpaces-t.position%this.tabSpaces;this._addSpaces(t,e)}},(e,t)=>t.shiftKey||e.selection&&!e.selection.sameLine()),this.action("Home",!1,(e,t,s)=>{let i=Me(this.code.lines[e]);i==t.position&&(i=0);const o=this.code.lines[e].substring(0,i);let n=t.position;if(this.resetCursorPos(Be.CURSOR_LEFT,t,!0),i>0?this.cursorToString(t,o):i=0,this.mergeCursors(e),s.shiftKey&&!s.cancelShift){t.selection&&(n+=t.selection.chars),t.selection||this.startSelection(t);var a=this.code.lines[e].substring(i,n);t.selection.sameLine()?t.selection.selectInline(t,i,t.line,this.measureString(a)):this._processSelection(t,s)}else s.keepSelection||this.endSelection()}),this.action("End",!1,(e,t,s)=>{if(!s.shiftKey&&!s._shiftKey||s.cancelShift)s.keepSelection||this.endSelection();else{var i=this.code.lines[e].substring(t.position);t.selection||this.startSelection(t),t.selection.sameLine()?t.selection.selectInline(t,t.position,t.line,this.measureString(i)):(this.resetCursorPos(Be.CURSOR_LEFT,t),this.cursorToString(t,this.code.lines[e]),this._processSelection(t,s))}this.resetCursorPos(Be.CURSOR_LEFT,t),this.cursorToString(t,this.code.lines[e]);var o=this.codeScroller.clientWidth+this.getScrollLeft()-Be.LINE_GUTTER_WIDTH;t.position*this.charWidth>=o&&this.setScrollLeft(this.code.lines[e].length*this.charWidth),this.mergeCursors(e)}),this.action("Enter",!0,(e,t,s)=>{if(this.isAutoCompleteActive)this.autoCompleteWord();else if(s.ctrlKey&&this.onRun)this.onRun(this.getText());else{this._addUndoStep(t,!0);var i=this.getCharAtPos(t,-1),o=this.getCharAtPos(t);this.code.lines.splice(t.line+1,0,""),this.code.lines[t.line+1]=this.code.lines[e].substr(t.position),this.code.lines[e]=this.code.lines[e].substr(0,t.position),this.lineDown(t,!0);var n=Me(this.code.lines[e]),a=Math.floor(n/this.tabSpaces);"{"==i&&"}"==o?(this.code.lines.splice(t.line,0,""),this._addSpaceTabs(t,a+1),this.code.lines[t.line+1]=" ".repeat(n)+this.code.lines[t.line+1]):this._addSpaceTabs(t,a),this.processLines()}}),this.action("ArrowUp",!1,(e,t,s)=>{this.isAutoCompleteActive?this._moveArrowSelectedAutoComplete("up"):s.shiftKey?(t.selection||this.startSelection(t),this.lineUp(t),this.getCharAtPos(t)||this.cursorToPosition(t,this.code.lines[t.line].length),this._processSelection(t,s,!1)):(this.endSelection(),this.lineUp(t),this.getCharAtPos(t)||this.actions.End.callback(t.line,t,s))}),this.action("ArrowDown",!1,(e,t,s)=>{if(this.isAutoCompleteActive)this._moveArrowSelectedAutoComplete("down");else{s.shiftKey?t.selection||this.startSelection(t):this.endSelection();const e=this.lineDown(t);this.getCharAtPos(t)&&e||(this.resetCursorPos(Be.CURSOR_LEFT,t),this.cursorToRight(this.code.lines[t.line],t)),s.shiftKey&&this._processSelection(t,s)}}),this.action("ArrowLeft",!1,(e,t,s)=>{if(0!=t.line||0!=t.position)if(s.metaKey)s.preventDefault(),this.actions.Home.callback(e,t,s);else if(s.ctrlKey){const[e,n,a]=this.getWordAtPos(t,-1);if(!e.length&&this.lineUp(t,!0)){const e=s.cancelShift,i=s.keepSelection;s.cancelShift=!0,s.keepSelection=!0,this.actions.End.callback(t.line,t,s),s.cancelShift=e,s.keepSelection=i}var i=Math.max(t.position-n,1),o=e.substr(0,i);s.shiftKey?t.selection||this.startSelection(t):this.endSelection(),this.cursorToString(t,o,!0),s.shiftKey&&this._processSelection(t,s)}else{var n=this.getCharAtPos(t,-1);n?s.shiftKey?(t.selection||this.startSelection(t),this.cursorToLeft(n,t),this._processSelection(t,s,!1,Be.SELECTION_X)):t.selection?(t.selection.invertIfNecessary(),this.resetCursorPos(Be.CURSOR_LEFT_TOP,t),this.cursorToLine(t,t.selection.fromY),this.cursorToPosition(t,t.selection.fromX,!0),this.endSelection()):(this.cursorToLeft(n,t),this.useAutoComplete&&this.isAutoCompleteActive&&this.showAutoCompleteBox("foo",t)):t.line>0&&(s.shiftKey&&!t.selection&&this.startSelection(t),this.lineUp(t),s.cancelShift=s.keepSelection=!0,this.actions.End.callback(t.line,t,s),delete s.cancelShift,delete s.keepSelection,s.shiftKey&&this._processSelection(t,s,!1))}}),this.action("ArrowRight",!1,(e,t,s)=>{if(t.line!=this.code.lines.length-1||t.position!=this.code.lines[t.line].length)if(s.metaKey)s.preventDefault(),this.actions.End.callback(e,t,s);else if(s.ctrlKey){const[e,n,a]=this.getWordAtPos(t);e.length||this.lineDown(t,!0);var i=t.position-n,o=e.substr(i);s.shiftKey?t.selection||this.startSelection(t):this.endSelection(),this.cursorToString(t,o),s.shiftKey&&this._processSelection(t,s)}else{var n=this.getCharAtPos(t);n?s.shiftKey?(t.selection||this.startSelection(t),this.cursorToRight(n,t),this._processSelection(t,s,!1,Be.SELECTION_X)):t.selection?(t.selection.invertIfNecessary(),this.resetCursorPos(Be.CURSOR_LEFT_TOP,t),this.cursorToLine(t,t.selection.toY),this.cursorToPosition(t,t.selection.toX,!0),this.endSelection(t)):(this.cursorToRight(n,t),this.useAutoComplete&&this.isAutoCompleteActive&&this.showAutoCompleteBox("foo",t)):void 0!==this.code.lines[t.line+1]&&(s.shiftKey?t.selection||this.startSelection(t):this.endSelection(),this.lineDown(t,!0),s.shiftKey&&this._processSelection(t,s,!1),this.hideAutoCompleteBox())}});const i=async()=>{this.statusPanel=this._createStatusPanel(s),this.statusPanel&&e.attach(this.statusPanel),"loading"==document.fonts.status&&await document.fonts.ready;const i=window.localStorage.getItem("lexcodeeditor-font-size");if(i)this._setFontSize(parseInt(i));else{const e=document.querySelector(":root"),t=getComputedStyle(e);this.fontSize=parseInt(t.getPropertyValue("--code-editor-font-size")),this.charWidth=this._measureChar()}t.emitSignal("@font-size",this.fontSize),t.doAsync(()=>{this._verticalTopOffset=this.tabs?.root.getBoundingClientRect().height??0,this._verticalBottomOffset=this.statusPanel?.root.getBoundingClientRect().height??0,this._fullVerticalOffset=this._verticalTopOffset+this._verticalBottomOffset,this.gutter.style.marginTop=`${this._verticalTopOffset}px`,this.gutter.style.height=`calc(100% - ${this._fullVerticalOffset}px)`,this.vScrollbar.root.style.marginTop=`${this._verticalTopOffset}px`,this.vScrollbar.root.style.height=`calc(100% - ${this._fullVerticalOffset}px)`,this.hScrollbar.root.style.bottom=`${this._verticalBottomOffset}px`,this.codeArea.root.style.height=`calc(100% - ${this._fullVerticalOffset}px)`,this.processLines()},50),s.callback&&s.callback.call(this,this),Ee.editor=this};if((s.allowAddScripts??1)&&(this.onCreateFile=s.onCreateFile,this.addTab("+",!1,"Create file")),s.files){console.assert(s.files.constructor===Array,"_files_ must be an Array!");const e=s.files.length,t=void 0!==s.filesAsync;let o=0;for(let n of s.files){const a=n.constructor===Array?n[0]:n,l=n.constructor===Array?n[1]:void 0;await this.loadFile(a,{filename:l,async:t,callback:(t,n)=>{o++,o==e&&(i(),s.onFilesLoaded&&s.onFilesLoaded(this,this.loadedTabs,e))}})}}else(s.defaultTab??1)&&this.addTab(s.name||"untitled",!0,s.title,{language:s.highlight??"Plain Text"}),i()}clear(){console.assert(this.rightStatusPanel&&this.leftStatusPanel,"No panels to clear."),this.rightStatusPanel.clear(),this.leftStatusPanel.clear()}static getInstances(){return Be.__instances}onKeyPressed(e){"b"==e.key&&e.ctrlKey&&this.useFileExplorer&&(this.explorerArea.root.classList.toggle("hidden"),this._lastBaseareaWidth?(this.baseArea.root.style.width=this._lastBaseareaWidth,delete this._lastBaseareaWidth):(this._lastBaseareaWidth=this.baseArea.root.style.width,this.baseArea.root.style.width="100%"))}getText(e=!1){return this.code.lines.join(e?" ":"\n")}setText(e="",t){let s=e.split("\n");this.code.lines=[].concat(s),this._removeSecondaryCursors();let i=this.getCurrentCursor(!0),o=s.pop();this.cursorToLine(i,s.length),this.cursorToPosition(i,o?.length??0,!0),this.mustProcessLines=!0,t&&this._changeLanguage(t),this._processLinesIfNecessary()}appendText(e,t){let s=t.line;t.selection&&(this.deleteSelection(t),s=t.line),this.endSelection();const i=e.replaceAll("\r","").split("\n");if(1!=i.length){let e=i.length;console.assert(e>0);const n=i.shift();e--;const a=this.code.lines[s].slice(t.position);this.code.lines[s]=[this.code.lines[s].slice(0,t.position),n].join(""),this.cursorToPosition(t,t.position+(n?.length??0));let l=null;for(var o=0;o<i.length;++o)l=i[o],this.cursorToLine(t,t.line++,!0),o==i.length-1&&(l+=a),this.code.lines.splice(1+s+o,0,l);l&&this.cursorToPosition(t,l.length),this.cursorToLine(t,t.line+e),this.processLines()}else this.code.lines[s]=[this.code.lines[s].slice(0,t.position),i[0],this.code.lines[s].slice(t.position)].join(""),this.cursorToPosition(t,t.position+i[0].length),this.processLine(s);this.resize(Be.RESIZE_SCROLLBAR_H_V,void 0,()=>{var e=this.codeScroller.clientWidth+this.getScrollLeft()-Be.LINE_GUTTER_WIDTH;t.position*this.charWidth>=e&&this.setScrollLeft(this.code.lines[s].length*this.charWidth)})}setCustomSuggestions(e){e&&e.constructor===Array&&(this.customSuggestions=e)}async loadFile(e,s={}){const i=(e,i,o)=>{const n=(e=e.replaceAll("\r","").replaceAll(/\t|\\t/g," ".repeat(this.tabSpaces))).split("\n");if(this.useFileExplorer||this.skipTabs){this._tabStorage[i]={lines:n,options:s};const e=Be.languages[s.language]?.ext;this.useFileExplorer&&(this.addExplorerItem({id:i,skipVisibility:!0,icon:this._getFileIcon(i,e)}),this.explorer.innerTree.frefresh(i))}else this.addTab(i,!0,o,s),this.code.lines=n,s.language||this._changeLanguageFromExtension(t.getExtension(i));s.callback&&s.callback(i,e)};if(e.constructor==String){const o=e,n=s.filename??o.substring(o.lastIndexOf("/")+1);if(s.async){const e=await this._requestFileAsync(o,"text");i(e,n,s.filename??o)}else t.request({url:o,success:e=>{i(e,n,s.filename??o)}})}else{const t=new FileReader;t.readAsText(e),t.onload=t=>{const s=t.currentTarget.result;i(s,e.name)}}}_addUndoStep(e,s=!1,i=!0){if(!e.isMain)return;const o=(new Date).getTime();if(!s)if(this._lastTime){if(!(o-this._lastTime>2e3))return void(this._lastTime=o);this._lastTime=null}else this._lastTime=o;i&&(this.code.redoSteps.length=0),this.code.undoSteps.push({lines:t.deepCopy(this.code.lines),cursors:this.saveCursors()})}_doUndo(e){if(!this.code.undoSteps.length)return;this._addRedoStep(e);const t=this.code.undoSteps.pop();this.code.lines=t.lines,this.processLines(),this._removeSecondaryCursors();for(let e=0;e<t.cursors.length;++e){var s=this.cursors[e];s||(s=this._addCursor()),this.restoreCursor(s,t.cursors[e])}this._hideActiveLine()}_addRedoStep(e){e.isMain&&this.code.redoSteps.push({lines:t.deepCopy(this.code.lines),cursors:this.saveCursors()})}_doRedo(e){if(!this.code.redoSteps.length)return;this._addUndoStep(e,!0,!1);const t=this.code.redoSteps.pop();this.code.lines=t.lines,this.processLines(),this._removeSecondaryCursors();for(let e=0;e<t.cursors.length;++e){var s=this.cursors[e];s||(s=this._addCursor()),this.restoreCursor(s,t.cursors[e])}}_changeLanguage(e,s,i=!1){this.code.language=e,this.highlight=e,i&&(this.code.languageOverride=e),this._updateDataInfoPanel("@highlight",e),this.mustProcessLines=!0;const o=s??Be.languages[e].ext,n=this._getFileIcon(null,o);if(!this.skipTabs){const e=this.tabs.tabDOMs[this.code.tabName];var a;if(e.firstChild.remove(),console.assert(null!=e),n.includes("."))(a=document.createElement("img")).src="https://raw.githubusercontent.com/jxarco/lexgui.js/master/"+n;else{const e=n.split(" ");a=t.makeIcon(e[0],{svgClass:e.slice(0).join(" ")})}e.prepend(a)}if(this.useFileExplorer){const e=this.explorer.innerTree.data.filter(e=>e.id===this.code.tabName)[0];console.assert(null!=e),e.icon=n,this.explorer.innerTree.frefresh(this.code.tabName)}}_changeLanguageFromExtension(e){if(!e)return this._changeLanguage(this.code.language);for(let t in Be.languages){const s=Be.languages[t].ext;if(s.constructor==Array){if(s.indexOf(e)>-1)return this._changeLanguage(t,e)}else if(s==e)return this._changeLanguage(t)}this._changeLanguage("Plain Text")}_createStatusPanel(e={}){if(this.skipInfo)return;let s=new t.Panel({className:"lexcodetabinfo flex flex-row",height:"auto"});this.onCreateStatusPanel&&this.onCreateStatusPanel(s,this);let i=this.leftStatusPanel=new t.Panel({id:"FontSizeZoomStatusComponent",height:"auto"});i.sameLine(),this.skipTabs&&i.addButton(null,"ZoomOutButton",this._decreaseFontSize.bind(this),{icon:"ZoomOut",width:"32px",title:"Zoom Out",tooltip:!0}),i.addButton(null,"ZoomOutButton",this._decreaseFontSize.bind(this),{icon:"ZoomOut",width:"32px",title:"Zoom Out",tooltip:!0}),i.addLabel(this.fontSize,{fit:!0,signal:"@font-size"}),i.addButton(null,"ZoomInButton",this._increaseFontSize.bind(this),{icon:"ZoomIn",width:"32px",title:"Zoom In",tooltip:!0}),i.endLine("justify-start"),s.attach(i.root);let o=this.rightStatusPanel=new t.Panel({height:"auto"});o.sameLine(),o.addLabel(this.code?.title??"",{id:"EditorFilenameStatusComponent",fit:!0,signal:"@tab-name"}),o.addButton(null,"Ln 1, Col 1",this.showSearchLineBox.bind(this),{id:"EditorSelectionStatusComponent",fit:!0,signal:"@cursor-data"}),o.addButton(null,"Spaces: "+this.tabSpaces,(e,s)=>{t.addContextMenu("Spaces",s,e=>{const t=[2,4,8];for(const s of t)e.add(s,e=>{this.tabSpaces=e,this.processLines(),this._updateDataInfoPanel("@tab-spaces","Spaces: "+this.tabSpaces)})})},{id:"EditorIndentationStatusComponent",nameWidth:"15%",signal:"@tab-spaces"}),o.addButton("<b>{ }</b>",this.highlight,(e,s)=>{t.addContextMenu("Language",s,e=>{for(const t of Object.keys(Be.languages))e.add(t,e=>{this._changeLanguage(e,void 0,!0),this.processLines()})})},{id:"EditorLanguageStatusComponent",nameWidth:"15%",signal:"@highlight"}),o.endLine("justify-end"),s.attach(o.root);const n={"Font Size Zoom":e.statusShowFontSizeZoom??!0,"Editor Filename":e.statusShowEditorFilename??!0,"Editor Selection":e.statusShowEditorSelection??!0,"Editor Indentation":e.statusShowEditorIndentation??!0,"Editor Language":e.statusShowEditorLanguage??!0},a=e=>{const t=s.root.querySelector(`#${e.replaceAll(" ","")}StatusComponent`);console.assert(t,`${e} has no status button!`),t.classList.toggle("hidden",!n[e])};for(const[e,t]of Object.entries(n))a(e);return s.root.addEventListener("contextmenu",e=>{if(e.target&&(e.target.classList.contains("lexpanel")||e.target.classList.contains("lexinlinecomponents")))return;const s=Object.keys(n).map((e,t)=>{const s={name:e,icon:"Check",callback:()=>{n[e]=!n[e],a(e)}};return n[e]||delete s.icon,s});new t.DropdownMenu(e.target,s,{side:"top",align:"start"})}),s}_getFileIcon(e,s,i){if(!!e&&"+"===e)return;if(!i){if(s){const i=[].concat(s);if(e){const o=t.getExtension(e),n=i.indexOf(o);n>-1&&(s=i[n])}else s=i[0]}else s=t.getExtension(e);for(const[e,t]of Object.entries(Be.languages)){if([].concat(t.ext).includes(s)){i=e;break}}}if(void 0===i)return"AlignLeft fg-neutral-500";const o=Be.languages[i]?.icon;return o?o[s]??o:"AlignLeft fg-neutral-500"}_onNewTab(e){if(this.processFocus(!1),this.onNewTab)return void this.onNewTab(e);const s=this.newTabOptions??[{name:"Create file",icon:"FilePlus",callback:this._onCreateNewFile.bind(this)},{name:"Load file",icon:"FileUp",disabled:!this.allowLoadingFiles,callback:this.loadTabFromFile.bind(this)}];new t.DropdownMenu(e.target,s,{side:"bottom",align:"start"})}_onCreateNewFile(){let e={};if(this.onCreateFile&&(e=this.onCreateFile(this),!e))return;const t=e.name??"unnamed.js";this.addTab(t,!0,t,{indexOffset:e.indexOffset,language:e.language??"JavaScript"})}_onSelectTab(e,s,i){if(this.disableEdition)return;if(e)return void this._onNewTab(s);this._removeSecondaryCursors();const o=this.getCurrentCursor(!0),n=this.code;n&&this.saveCursor(o,n.cursorState),this.code=this.loadedTabs[i],this.restoreCursor(o,this.code.cursorState),this.endSelection(),this.hideAutoCompleteBox(),this._updateDataInfoPanel("@tab-name",i),this.code.languageOverride?this._changeLanguage(this.code.languageOverride):this._changeLanguageFromExtension(t.getExtension(i)),this.processLines(),!e&&this.onSelectTab&&this.onSelectTab(i,this)}_onContextMenuTab(e=!1,s,i){e||new t.DropdownMenu(s.target,[{name:"Close",kbd:"MWB",disabled:!this.allowClosingTabs,callback:()=>{this.closeTab(i)}},{name:"Close Others",disabled:!this.allowClosingTabs,callback:()=>{for(const[e,t]of Object.entries(this.tabs.tabs))"+"!==e&&e!==i&&this.closeTab(e)}},{name:"Close All",disabled:!this.allowClosingTabs,callback:()=>{for(const[e,t]of Object.entries(this.tabs.tabs))"+"!==e&&this.closeTab(e)}},null,{name:"Copy Path",icon:"Copy",callback:()=>{navigator.clipboard.writeText(this.openedTabs[i].path??"")}}],{side:"bottom",align:"start",event:s})}addTab(e,t,s,i={}){const o=Object.keys(this.loadedTabs).slice(1).reduce((t,s)=>t+(s.replace(/[_\d+]/g,"")==e?1:0),0);o>0&&(e=e.split(".").join("_"+o+"."));const n="+"===e;let a=document.createElement("div"),l=a;Object.assign(a,{path:i.path??"",className:"code",lines:[""],language:i.language??"Plain Text",cursorState:{},undoSteps:[],redoSteps:[],lineScopes:[],lineSymbols:[],lineSignatures:[],symbolsTable:new Map,tabName:e,title:s??e,tokens:{}}),a.style.left="0px",a.style.top="0px",a.addEventListener("dragenter",function(e){e.preventDefault(),this.parentElement?.classList.add("dragging")}),a.addEventListener("dragleave",function(e){e.preventDefault(),this.parentElement?.classList.remove("dragging")}),a.addEventListener("drop",e=>{if(e.preventDefault(),a.parentElement?.classList.remove("dragging"),e.dataTransfer?.files)for(let t=0;t<e.dataTransfer.files.length;++t)this.loadFile(e.dataTransfer.files[t])}),this.loadedTabs[e]=a,this.openedTabs[e]=a;const r=this.code;this.code=a;const c=this._getFileIcon(e);return this.useFileExplorer&&!n&&(this.addExplorerItem({id:e,skipVisibility:!0,icon:c}),this.explorer.innerTree.frefresh(e)),this.skipTabs||this.tabs.add(e,a,{selected:t,fixed:n,title:a.title,icon:c,onSelect:this._onSelectTab.bind(this,n),onContextMenu:this._onContextMenuTab.bind(this,n),allowDelete:this.allowClosingTabs,indexOffset:i.indexOffset}),this.codeSizer.appendChild(a),this.endSelection(),i.language&&(l.languageOverride=i.language,this._changeLanguage(l.languageOverride),this.mustProcessLines=!0),i.codeLines&&(l.lines=i.codeLines,this.mustProcessLines=!0),t?(this.resetCursorPos(Be.CURSOR_LEFT_TOP,void 0,!0),this.mustProcessLines=!0):this.code=r,this._processLinesIfNecessary(),this._updateDataInfoPanel("@tab-name",e),e}loadCode(e){if(this.codeSizer.querySelectorAll(".code").forEach(e=>e.classList.add("hidden")),this.openedTabs[e]){return void this.openedTabs[e].classList.remove("hidden")}let s=this.loadedTabs[e];if(!s){this.addTab(e,!0);const s=this._tabStorage[e];return s&&(this.code.lines=s.lines,s.options.language?this._changeLanguage(s.options.language,void 0,!0):this._changeLanguageFromExtension(t.getExtension(e)),delete this._tabStorage[e]),void this._processLinesIfNecessary()}this.openedTabs[e]=s,this.codeSizer.appendChild(s),this.endSelection(),this.code=s,this.mustProcessLines=!0,this.resetCursorPos(Be.CURSOR_LEFT_TOP,void 0,!0),this.processLines(),this._changeLanguageFromExtension(t.getExtension(e)),this._processLinesIfNecessary(),this._updateDataInfoPanel("@tab-name",s.tabName)}loadTab(e){if(this.openedTabs[e])return void this.tabs.select(e);let s=this.loadedTabs[e];if(!s){this.addTab(e,!0);const s=this._tabStorage[e];return s&&(this.code.lines=s.lines,s.options.language?this._changeLanguage(s.options.language,void 0,!0):this._changeLanguageFromExtension(t.getExtension(e)),delete this._tabStorage[e]),void this._processLinesIfNecessary()}s.style.display="block",this.openedTabs[e]=s;const i="+"===e,o=this._getFileIcon(e);this.tabs.add(e,s,{selected:!0,fixed:i,title:s.title,icon:o,onSelect:this._onSelectTab.bind(this,i),onContextMenu:this._onContextMenuTab.bind(this,i),allowDelete:this.allowClosingTabs}),this.codeSizer.appendChild(s),this.endSelection(),this.code=s,this.resetCursorPos(Be.CURSOR_LEFT_TOP,void 0,!0),this._changeLanguageFromExtension(t.getExtension(e)),this._updateDataInfoPanel("@tab-name",s.tabName),this.processLines()}closeTab(e,t=!1){this.allowClosingTabs&&(this.tabs.delete(e),t&&(delete this.openedTabs[e],delete this.loadedTabs[e],delete this._tabStorage[e]))}getSelectedTabName(){return this.tabs.selected}loadTabFromFile(){const e=document.createElement("input");e.type="file",document.body.appendChild(e),e.click(),e.addEventListener("change",t=>{const s=t.target;s.files&&s.files[0]&&this.loadFile(s.files[0]),e.remove()})}processFocus(e=!1){e?this.restartBlink():(clearInterval(this.blinker),t.removeClass(this.cursorsDOM,"show"))}processMouse(e){const s=e.target;if((s.classList.contains("code")||s.classList.contains("lexcodearea"))&&this.code){var i=this.getCurrentCursor(),o=this.code.getBoundingClientRect();if(!(([e.clientX-o.x,e.clientY-o.y][1]/this.lineHeight|0)<0))if("mousedown"==e.type){if(2===e.button&&(this.processClick(e),this.canOpenContextMenu=!i.selection,i.selection&&(this.canOpenContextMenu=this.canOpenContextMenu||i.line>=i.selection.fromY&&i.line<=i.selection.toY&&i.position>=i.selection.fromX&&i.position<=i.selection.toX,this.canOpenContextMenu)))return;this._mouseDown=!0,this._lastMouseDown=t.getTime(),this.endSelection(),this.processClick(e)}else if("mouseup"==e.type)this._onMouseUp(e);else if("mousemove"==e.type)this._mouseDown&&(this.state.selectingText=!0,this.processSelections(e));else if("click"==e.type)switch(e.detail){case t.MOUSE_DOUBLE_CLICK:const[s,o,n]=this.getWordAtPos(i);this.resetCursorPos(Be.CURSOR_LEFT,i),this.cursorToPosition(i,o),this.startSelection(i),i.selection.selectInline(i,o,i.line,this.measureString(s)),this.cursorToString(i,s);break;case t.MOUSE_TRIPLE_CLICK:this.resetCursorPos(Be.CURSOR_LEFT,i),e._shiftKey=!0,this.actions.End.callback(i.line,i,e),this._tripleClickSelection=!0}else if("contextmenu"==e.type){if(e.preventDefault(),!this.canOpenContextMenu)return;t.addContextMenu(null,e,t=>{if(t.add("Copy",()=>{this._copyContent(i)}),this.disableEdition||(t.add("Cut",()=>{this._cutContent(i)}),t.add("Paste",()=>{this._pasteContent(i)})),!this.onContextMenu)return;let s=null;if(i.selection){i.selection&&i.selection.invertIfNecessary();const e="_NEWLINE_";let t=this.code.lines.join(e),o=0;for(let e=0;e<=i.selection.fromY;e++)o+=e==i.selection.fromY?i.selection.fromX:this.code.lines[e].length;o+=i.selection.fromY*e.length;const n=i.selection.chars+(i.selection.toY-i.selection.fromY)*e.length;s=t.substr(o,n).split(e).join("\n")}const o=this.onContextMenu(this,s,e);if(o.length){t.add("");for(const e of o)t.add(e.path,{disabled:e.disabled,callback:e.callback})}}),this.canOpenContextMenu=!1}}}_onMouseUp(e){t.getTime()-this._lastMouseDown<120&&(this.state.selectingText=!1,this.endSelection());const s=this.getCurrentCursor();if(s.selection){s.selection.invertIfNecessary();const e=s.selection.toY-s.selection.fromY;0==s.selection.chars&&0==e&&this.endSelection()}this._mouseDown=!1,this.state.selectingText=!1,delete this._lastSelectionKeyDir}processClick(e){var t=this.getCurrentCursor(),s=this.codeScroller.getBoundingClientRect(),i=[e.clientX-s.x+this.getScrollLeft(),e.clientY-s.y+this.getScrollTop()],o=i[1]/this.lineHeight|0;const n=o>this.code.lines.length-1;o=Math.min(o,this.code.lines.length-1);var a=(i[0]-parseInt(this.xPadding)+3)/this.charWidth|0,l=n?this.code.lines[o]:this.code.lines[o].slice(0,a);e.altKey?this._addCursor(o,l.length):(this._removeSecondaryCursors(),this.cursorToLine(t,o),this.cursorToPosition(t,l.length)),this.hideAutoCompleteBox()}updateSelections(e,t=!1,s=Be.SELECTION_X_Y){for(let i of this.cursors)i.selection&&this._processSelection(i,e,t,s)}processSelections(e,t=!1,s=Be.SELECTION_X_Y){for(let i of this.cursors)this._processSelection(i,e,t,s)}_processSelection(e,s,i=!1,o=Be.SELECTION_X_Y){const n=s&&s.constructor==MouseEvent;n&&this.processClick(s),e.selection||this.startSelection(e);const a=e.selection;if(this._hideActiveLine(),!i){let t=!0;!n&&e.line>=a.fromY&&(e.line!=a.fromY||e.position>=a.fromX)&&(t=s&&this._lastSelectionKeyDir&&("ArrowRight"==s.key||"ArrowDown"==s.key||"End"==s.key)),t?(o&Be.SELECTION_X&&(a.fromX=e.position),o&Be.SELECTION_Y&&(a.fromY=e.line)):(o&Be.SELECTION_X&&(a.toX=e.position),o&Be.SELECTION_Y&&(a.toY=e.line)),this._lastSelectionKeyDir=t}if(!n&&a.isEmpty())return void this.endSelection();a.chars=0;const l=a.fromX,r=a.fromY,c=a.toX,h=a.toY,d=h-r;let u=this.selections[e.name];if(d>=0){for(;d<u.childElementCount-1;)t.deleteElement(u.lastChild);for(let e=r;e<=h;e++){const t=e-r,s=e>=this.visibleLinesViewport.x&&e<=this.visibleLinesViewport.y;let i=null;s&&(i=u.childNodes[t],i||(i=document.createElement("div"),i.className="lexcodeselection",u.appendChild(i)));let o="";if(0==t){const t=l>c;o=0==d?t?this.code.lines[e].substring(c,l):this.code.lines[e].substring(l,c):this.code.lines[e].substr(l);const n=(t&&0==d?c:l)*this.charWidth;s&&(i.style.left=`calc(${n}px + ${this.xPadding})`)}else o=e==h?this.code.lines[e].substring(0,c):this.code.lines[e],s&&(i.style.left=this.xPadding);const n=this.measureString(o);a.chars+=n/this.charWidth,s&&(i.style.width=(n||(0==d?0:8))+"px",i._top=e*this.lineHeight,i.style.top=i._top+"px")}}else{for(;Math.abs(d)<u.childElementCount-1;)t.deleteElement(u.firstChild);for(let e=h;e<=r;e++){const t=e-h,s=e>=this.visibleLinesViewport.x&&e<=this.visibleLinesViewport.y;let i,o=null;if(s&&(o=u.childNodes[t],o||(o=document.createElement("div"),o.className="lexcodeselection",u.appendChild(o))),0==t){i=this.code.lines[e].substr(c);const t=c*this.charWidth;s&&(o.style.left="calc("+t+"px + "+this.xPadding+")")}else i=e==r?this.code.lines[e].substring(0,l):this.code.lines[e],s&&(o.style.left=this.xPadding);const n=this.measureString(i);a.chars+=n/this.charWidth,s&&(o.style.width=(n||8)+"px",o._top=e*this.lineHeight,o.style.top=o._top+"px")}}}async processKey(e){const s=this.cursors.length;if(!this.code||e.srcElement?.constructor!=HTMLDivElement)return;const i=e.detail??{},o=e.key??i.key;" "==o&&(e.preventDefault(),e.stopPropagation());const n=i.targetCursor;if(!this._processGlobalKeys(e,o))if(void 0===n){this._lastProcessedCursorIndex=null;for(var a=null,l=new t.vec2(0,0),r=0;r<s;r++){let t=this.cursors[r];if(!t)break;a&&a.line==t.line&&!o.includes("Arrow")&&(t.position+=l.x,t.line+=l.y,this.relocateCursors()),a=this.saveCursor(t),this._lastProcessedCursorIndex=r,this._processKeyAtCursor(e,o,t),l.x+=t.position-a.position,l.y+=t.line-a.line,t.selection||(t.line=t.line)}delete this._lastProcessedCursorIndex}else this.processKeyAtTargetCursor(e,o,n)}async processKeyAtTargetCursor(e,t,s){let i=this.cursors[s];i&&(this._processKeyAtCursor(e,t,i),this._processGlobalKeys(e,t))}_processGlobalKeys(e,t){let s=this.getCurrentCursor();if(e.ctrlKey||e.metaKey)switch(t.toLowerCase()){case"a":return e.preventDefault(),this.selectAll(),!0;case"b":return e.preventDefault(),"k"==this.state.keyChain&&(this._commentLines(s,!0),!0);case"c":return e.preventDefault(),"k"==this.state.keyChain&&(this._commentLines(s),!0);case"d":return e.preventDefault(),this.selectNextOcurrence(s),!0;case"f":return e.preventDefault(),this.showSearchBox(),!0;case"g":return e.preventDefault(),this.showSearchLineBox(),!0;case"k":return e.preventDefault(),this.state.keyChain="k",!0;case"s":return e.preventDefault(),this.onSave&&this.onSave(this.getText()),!0;case"u":return e.preventDefault(),"k"==this.state.keyChain&&(this._uncommentLines(s),!0);case"y":return e.preventDefault(),this._doRedo(s),!0;case"z":return e.preventDefault(),this._doUndo(s),!0;case"+":return e.preventDefault(),this._increaseFontSize(),!0;case"-":return e.preventDefault(),this._decreaseFontSize(),!0;case" ":if(this.onCtrlSpace)return e.preventDefault(),this.onCtrlSpace(s),!0}return this.state.keyChain=null,!1}async _processKeyAtCursor(e,t,s){const i=e.detail??{},o=i.skipUndo??!1,n=i.skipDeleteSelection??!1;if(t.length>1&&-1==this.specialKeys.indexOf(t))return;let a=s.line;this.code.lines[a]=this.code.lines[a]??"";const l=s.isLast();if(e.ctrlKey||e.metaKey)switch(t.toLowerCase()){case"c":return void this._copyContent(s);case"v":return void this._pasteContent(s);case"x":return this._cutContent(s),void this.hideAutoCompleteBox();case"arrowdown":if(!e.shiftKey&&l&&null!=this.code.lines[a+1]){var r=this._addCursor(s.line,s.position,!0);if(!r)return;return void this.lineDown(r)}}else if(e.altKey)switch(t){case"d":return e.preventDefault(),void this._duplicateLine(a,s);case"ArrowUp":return void this.swapLines(a,-1,s);case"ArrowDown":return void this.swapLines(a,1,s)}for(const i in this.actions)if(t==i)return e.preventDefault(),this._actionMustDelete(s,this.actions[t],e)&&this.actions.Backspace.callback(a,s,e),this.actions[t].callback(a,s,e);if(e.ctrlKey||e.metaKey)return;!o&&this.code.lines.length&&this._addUndoStep(s);if(['"',"'","(","{"].indexOf(t)>-1&&this._encloseSelectedWordWithKey(t,a,s))return;s.selection&&!n&&(this.actions.Backspace.callback(a,s,e),a=s.line);const c=Object.values(this.pairKeys).indexOf(t)>-1&&!this.wasKeyPaired&&this.code.lines[a][s.position]===t;c||(this.code.lines[a]=[this.code.lines[a].slice(0,s.position),t,this.code.lines[a].slice(s.position)].join("")),this.cursorToRight(t,s);if(void 0!==this.pairKeys[t]&&!this.wasKeyPaired){if(this.wasKeyPaired=!0,c)return;return this.root.dispatchEvent(new KeyboardEvent("keydown",{key:this.pairKeys[t]})),void this.cursorToLeft(t,s)}delete this.wasKeyPaired,this.processLine(a),this.resizeIfNecessary(s),this.useAutoComplete&&this.showAutoCompleteBox(t,s)}async _pasteContent(e){const t=!this.getText().length;let s=await navigator.clipboard.readText();s=s.replaceAll(/\t|\\t/g," ".repeat(this.tabSpaces)),this._addUndoStep(e,!0),this.appendText(s,e);if(this.getScrollTop()<Math.max(e.line*this.lineHeight-this.codeScroller.offsetWidth,0)&&this.codeScroller.scrollTo(0,e.line*this.lineHeight),t){const e=this._detectLanguage(s);e&&this._changeLanguage(e)}}async _copyContent(e){let t="";if(e.selection){e.selection&&e.selection.invertIfNecessary();const s="_NEWLINE_";let i=this.code.lines.join(s),o=0;for(let t=0;t<=e.selection.fromY;t++)o+=t==e.selection.fromY?e.selection.fromX:this.code.lines[t].length;o+=e.selection.fromY*s.length;const n=e.selection.chars+(e.selection.toY-e.selection.fromY)*s.length;t=i.substr(o,n).split(s).join("\n")}else t="\n"+this.code.lines[e.line];navigator.clipboard.writeText(t)}async _cutContent(e){let t=e.line,s="";if(this._addUndoStep(e,!0),e.selection){e.selection&&e.selection.invertIfNecessary();const t="_NEWLINE_";let i=this.code.lines.join(t),o=0;for(let t=0;t<=e.selection.fromY;t++)o+=t==e.selection.fromY?e.selection.fromX:this.code.lines[t].length;o+=e.selection.fromY*t.length;const n=e.selection.chars+(e.selection.toY-e.selection.fromY)*t.length;s=i.substr(o,n).split(t).join("\n"),this.deleteSelection(e)}else s="\n"+this.code.lines[e.line],this.code.lines.splice(t,1),this.processLines(),this.resetCursorPos(Be.CURSOR_LEFT,e),null==this.code.lines[t]&&this.lineUp(e);navigator.clipboard.writeText(s)}_duplicateLine(e,t){this.endSelection(),this._addUndoStep(t,!0),this.code.lines.splice(e,0,this.code.lines[e]),this.lineDown(t),this.processLines(),this.hideAutoCompleteBox()}_commentLines(e,t=!1){const s=Be.languages[this.highlight];if(this.state.keyChain=null,(e=e??this.getCurrentCursor()).selection){if(!((t?s.blockComments:s.singleLineComments)??1))return;this._addUndoStep(e,!0);const i=this.code.lines.slice(e.selection.fromY,e.selection.toY+1),o=Math.min(...i.map(e=>{var t=Me(e);return t<0?1e10:t}));if(t){const t=s.blockCommentsTokens??this.defaultBlockCommentTokens,i=this.code.lines[e.selection.fromY];let o=Me(i);-1==o&&(o=0),this.code.lines[e.selection.fromY]=[i.substring(0,o),t[0]+" ",i.substring(o)].join(""),this.code.lines[e.selection.toY]+=" "+t[1],e.selection.fromX+=t[0].length+1,this._processSelection(e)}else{for(let t=e.selection.fromY;t<=e.selection.toY;++t)this._commentLine(e,t,o,!1);const t=(s.singleLineCommentToken??this.defaultSingleLineCommentToken)+" ";this.cursorToString(e,t),e.selection.fromX+=t.length,e.selection.toX+=t.length,this._processSelection(e)}}else{if(!(s.singleLineComments??1))return;for(const e of this.cursors)this._addUndoStep(e,!0),this._commentLine(e,e.line)}this.processLines(),this._hideActiveLine()}_commentLine(e,t,s,i=!0){const o=Be.languages[this.highlight];if(!(o.singleLineComments??1))return;const n=(o.singleLineCommentToken??this.defaultSingleLineCommentToken)+" ",a=this.code.lines[t];let l=Me(a);-1!=l&&(l=s??l,this.code.lines[t]=[a.substring(0,l),n,a.substring(l)].join(""),i&&this.cursorToString(e,n))}_uncommentLines(e){this.state.keyChain=null;const t=this.getCurrentCursor();if(null!==t.selection){this._addUndoStep(e,!0);for(var s=t.selection.fromY;s<=t.selection.toY;++s)this._uncommentLine(e,s)}else for(let e of this.cursors)this._addUndoStep(e,!0),this._uncommentLine(e,e.line);this.processLines(),this._hideActiveLine()}_uncommentLine(e,t){const s=Be.languages[this.highlight];if(!(s.singleLineComments??1))return;const i=s.singleLineCommentToken??this.defaultSingleLineCommentToken,o=this.code.lines[t];o.includes(i)&&(this.code.lines[t]=o.replace(i+" ",""),o.length==this.code.lines[t].length&&(this.code.lines[t]=o.replace(i,"")),this.cursorToString(e,"X".repeat(Math.abs(o.length-this.code.lines[t].length)),!0))}action(e,t=!1,s,i){this.actions[e]={key:e,callback:s,deleteSelection:t,eventSkipDeleteFn:i}}_actionMustDelete(e,t,s){return e.selection&&t.deleteSelection&&!(t.eventSkipDeleteFn&&t.eventSkipDeleteFn(e,s))}scanWordSuggestions(){this.code.tokens={};for(let e=0;e<this.code.lines.length;++e){const t=this.code.lines[e];this._getTokensFromLine(t,!0).forEach(e=>this.code.tokens[e]=1)}}toLocalLine(e){const t=Math.max(this.firstLineInViewport-this.lineScrollMargin.x,0);return Math.min(Math.max(e-t,0),this.code.lines.length-1)}getMaxLineLength(){return Math.max(...this.code.lines.map(e=>e.length))}_processLinesIfNecessary(){this.mustProcessLines&&(this.mustProcessLines=!1,this.processLines())}processLines(e){if(!this.code)return;var s="";this._blockCommentCache.length=0,this.mustProcessLines=!1,this.code.innerHTML="";const i=this.getScrollTop();this.firstLineInViewport=(e??Be.KEEP_VISIBLE_LINES)&Be.UPDATE_VISIBLE_LINES?i/this.lineHeight|0:this.firstLineInViewport;const o=this.codeScroller.offsetHeight/this.lineHeight|0;this.visibleLinesViewport=new t.vec2(Math.max(this.firstLineInViewport-this.lineScrollMargin.x,0),Math.min(this.firstLineInViewport+o+this.lineScrollMargin.y,this.code.lines.length));{const e=Math.max(this.code.lines.length-this.visibleLinesViewport.y,0);e<=this.lineScrollMargin.y&&(this.visibleLinesViewport.y+=e)}this._scopeStack=[{name:"",type:"global"}];for(let e=this.visibleLinesViewport.x;e<this.visibleLinesViewport.y;++e)s+=this.processLine(e,!0);this.code.innerHTML=s,this.codeScroller.scrollTop=i,this.code.style.top=this.visibleLinesViewport.x*this.lineHeight+"px",this.updateSelections(null,!0),this._clearTmpVariables(),this._setActiveLine(),this.resize()}processLine(e,s=!1,i=!1){this._scopeStack?this.code.lineScopes[e]=[...this._scopeStack]:(this.code.lineScopes[e]=this.code.lineScopes[e]??[],this._scopeStack=[...this.code.lineScopes[e]]);const o=Be.languages[this.highlight],n=this.toLocalLine(e),a=this.code.lines[e];if(void 0===a)return;if(this._lastProcessedLine=e,delete this._buildingString,delete this._pendingString,delete this._markdownHeader,s||(t.deleteElement(this.code.childNodes[n]),t.insertChildAtIndex(this.code,document.createElement("pre"),n)),"Plain Text"==this.highlight){const t=a.replaceAll("<","<").replaceAll(">",">");return this._updateLine(s,e,t,i)}this._currentLineNumber=e,this._currentLineString=a;const l=this._getTokensFromLine(a);if(!l.length)return this._updateLine(s,e,"",i);let r="",c=!1;const h=this._getLineSignatureFromTokens(l),d=this.code.lineSignatures[e]!==h&&!s,u=o.blockComments??!0,p=o.blockCommentsTokens??this.defaultBlockCommentTokens;d&&(this._scopeStack=[{name:"",type:"global"}]);for(let s=0;s<l.length;++s){let i=s-1,o=l[i];for(;" "==o;)i--,o=l[i];i=s+1;let n=l[i];for(;" "==n||'"'==n;)i++,n=l[i];const a=l[s],h=s,d=this._currentTokenPositions[h];if(u&&a.substr(0,p[0].length)==p[0]&&(this._buildingBlockComment=[e,d]),"}"===a&&this._scopeStack.length>1&&this._scopeStack.pop(),r+=this._evaluateToken({token:a,prev:o,prevWithSpaces:l[s-1],next:n,nextWithSpaces:l[s+1],tokenIndex:h,isFirstToken:0==h,isLastToken:h==l.length-1,tokens:l}),u&&null!=this._buildingBlockComment&&a.substr(0,p[1].length)==p[1]){const[s,i]=this._buildingBlockComment;this._blockCommentCache.push([new t.vec2(s,e),new t.vec2(i,d)]),delete this._buildingBlockComment}if("{"!==a)continue;let m=[...this._getTokensFromLine(this.code.lines[e].substring(0,d))];if(!o)for(let t=1;t<50;t++){let s=this.code.lines[e-t];if(!s)break;const i=s.lastIndexOf("{"),o=s.lastIndexOf("}");if(i>-1?s=s.substr(i):o>-1&&(s=s.substr(o)),m=[...this._getTokensFromLine(s),...m],s.length!==this.code.lines[e-t])break}m=m.reverse().filter(e=>e.length&&" "!=e);const g=["class","enum","function","interface","type","struct","namespace"];let f=null,C=null;for(let e=0;e<m.length;e++){const t=m[e];if(g.includes(t)){f=t,C=m[e-1];break}}if("enum"===f&&m.includes(":")){const e=m.indexOf(":");C=m[e+1]||C}if(!f){const e=m.indexOf("(");C=m[e+1]||C,C&&(f="method")}const v=this._scopeStack.at(-1);v?.lineNumber!==e&&this._scopeStack.push({name:C??"",type:f??"anonymous",lineNumber:e}),c=!0}this.code.lineScopes[e]=[...this._scopeStack];const m=this._parseLineForSymbols(e,a,l,c);return this._updateLine(s,e,r,i,m,l)}_getLineSignatureFromTokens(e){const t=new Set(["{","}"]);return e.filter(e=>t.has(e)).join("_")}_updateBlockComments(e,t,s){const i=Be.languages[this.highlight].blockCommentsTokens??this.defaultBlockCommentTokens,o=e[0].x===t,n=e[0].y===t;if(e[0].x!==t&&e[0].y,delete this._buildingBlockComment,o){if(s.filter(e=>e.substr(0,i[0].length)==i[0]).length){const o=s.indexOf(i[0]),n=this._currentTokenPositions[o];e[1].x=n,this.processLine(t,!1,!0)}else{this._buildingBlockComment=[t-1,0],this.mustProcessPreviousLine=e=>-1===e.indexOf(i[0]),this.processLine(t-1,!1,!0),e[0].x=this._lastProcessedLine;const s=this.code.lines[this._lastProcessedLine].indexOf(i[0]);e[1].x=s>0?s:0}}else if(n){if(s.filter(e=>e.substr(0,i[1].length)==i[1]).length){const o=s.indexOf(i[1]),n=this._currentTokenPositions[o];e[1].y=n,this.processLine(t,!1,!0)}else{this._buildingBlockComment=[e[0].x,e[1].x],this.mustProcessNextLine=e=>-1===e.indexOf(i[1]),this.processLine(t+1,!1,!0),e[0].y=this._lastProcessedLine;const s=this.code.lines[this._lastProcessedLine],o=s.indexOf(i[1]);e[1].y=o>0?o:s.length-1}}}_processExtraLineIfNecessary(e,t,s,i=!1){if(!this._scopeStack)return void console.warn("CodeEditor: No scope available");{const s=this._inBlockCommentSection(e,1e10,-1e10);t&&void 0!==s&&(this._updateBlockComments(s,e,t),this._scopeStack=[...this.code.lineScopes[e]])}if(e+1===this.code.lines.length||!this.code.lineScopes[e+1])return;const o=this._getLineSignatureFromTokens(t),n=this.code.lineSignatures[e]!==o,a=function(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s].type!==t[s].type)return!1;return!0}(this._scopeStack,this.code.lineScopes[e+1]);if(!n&&!this._scopesUpdated||a||i){if(a)for(const t of s){const s=this.code.symbolsTable.get(t.name);if(void 0===s)return;for(const t of s)t.line!==e&&this.processLine(t.line,!1,!0)}}else n&&(this._scopesUpdated=!0),this.code.lineScopes[e+1]=[...this._scopeStack],this.processLine(e+1),delete this._scopesUpdated}_updateLine(e=!1,t,s,i=!1,o=[],n=[]){const a=`<span class='line-gutter'>${t+1}</span>`,l=this._updateLineSymbols(t,o),r=Be.debugScopes&&this.code.lineScopes[t]?this.code.lineScopes[t].map(e=>`${e.type}`).join(", "):"",c=Be.debugSymbols&&this.code.lineSymbols[t]?this.code.lineSymbols[t].map(e=>`${e.name}(${e.kind})`).join(", "):"",h=r+(r.length?" - ":"")+c;return e||(this.code.childNodes[this.toLocalLine(t)].innerHTML=a+s+h,i||this._processExtraLineIfNecessary(t,n,l,i),this.mustProcessNextLine&&(this.mustProcessNextLine(n)&&t+1<this.code.lines.length?this.processLine(t+1,!1,!0):delete this.mustProcessNextLine),this.mustProcessPreviousLine&&(this.mustProcessPreviousLine(n)&&t-1>=0?this.processLine(t-1,!1,!0):delete this.mustProcessPreviousLine),Be.debugProcessedLines&&this.code.childNodes[t]?.classList.add("debug"),this._setActiveLine(t),this._clearTmpVariables()),this.code.lineSignatures[t]=this._getLineSignatureFromTokens(n),e?`<pre>${a+s+h}</pre>`:void 0}_parseLineForSymbols(e,t,s,i=!1){const o=this._scopeStack.at(i?-2:-1);if(!o||this._inBlockCommentSection(e))return[];const n=o.name,a=o.type,l=[],r=new Map,c=t.trim(),h=this.code.lineScopes[e-1],d=e=>{const t=`${e.name}_${e.kind}_${e.scope}_${e.line}`;r.has(t)||(r.set(t,e),l.push(e))};if(c.startsWith("#"))return[];const u=Be.nativeTypes[this.highlight],p=[[/^class\s+([A-Za-z0-9_]+)/,"class"],[/^struct\s+([A-Za-z0-9_]+)/,"struct"],[/^enum\s+([A-Za-z0-9_]+)/,"enum"],[/^interface\s+([A-Za-z0-9_]+)/,"interface"],[/^type\s+([A-Za-z0-9_]+)/,"type"],[/^function\s+([A-Za-z0-9_]+)/,"method"],[/^fn\s+([A-Za-z0-9_]+)/,"method"],[/^def\s+([A-Za-z0-9_]+)/,"method"],[/^([A-Za-z0-9_]+)\s*=\s*\(?.*\)?\s*=>/,"method"]];{u&&(p.push([new RegExp(`^(?:${u.join("|")})\\s+([A-Za-z0-9_]+)s*[(]+`),"method"]),"WGSL"===this.highlight&&p.push([new RegExp(`[A-Za-z0-9]+(\\s*)+:(\\s*)+(${u.join("|")})`),"variable",e=>e[0].split(":")[0].trim()]));const e=Be.declarationKeywords[this.highlight]??["const","let","var"];p.push([new RegExp(`^(?:${e.join("|")})\\s+([A-Za-z0-9_]+)`),"variable"])}for(let[t,s,i]of p){const o=c.match(t);o&&d({name:i?i(o):o[1],kind:s,scope:n,line:e})}const m=[[/new\s+([A-Za-z0-9_]+)\s*\(/,"constructor-call"],[/this.([A-Za-z_][A-Za-z0-9_]*)\s*\=/,"class-property"]];for(let[t,s,i]of m){const o=c.match(t);o&&d({name:i?i(o):o[1],kind:s,scope:n,line:e})}const g=/([A-Za-z0-9_]+)\s*\(/g;let f;for(;f=g.exec(c);){const t=f[1],s=c.slice(0,f.index);/(new|function|fn|def)\s+$/.test(s)||(["constructor","location",...u??[]].indexOf(t)>-1||h&&"class"===h.at(-1)?.type||d({name:t,kind:"method-call",scope:n,line:e}))}if(l.length)return l;const C=s.filter(e=>e.trim().length);for(let t=0;t<C.length;t++){const s=C[t-1],i=C[t],o=C[t+1];if(a.startsWith("class")){if("("===o&&/^[a-zA-Z_]\w*$/.test(i)&&void 0===s){if("constructor"===i)continue;d({name:i,kind:"method",scope:n,line:e})}}else a.startsWith("enum")&&(Pe(i)||this._isNumber(i)||this._mustHightlightWord(i,Be.statements)||d({name:i,kind:"enum_value",scope:n,line:e}))}return l}_updateLineSymbols(e,s){this.code.lineSymbols[e]=this.code.lineSymbols[e]??[];const i=t.deepCopy(this.code.lineSymbols[e]);for(let t of this.code.lineSymbols[e]){let s=this.code.symbolsTable.get(t.name);s&&(s=s.filter(t=>t.line!==e),s.length?this.code.symbolsTable.set(t.name,s):this.code.symbolsTable.delete(t.name))}for(let e of s){let t=this.code.symbolsTable.get(e.name)??[];t.push(e),this.code.symbolsTable.set(e.name,t)}return this.code.lineSymbols[e]=s,i}_lineHasComment(e){const t=Be.languages[this.highlight];if(!(t.singleLineComments??1))return;const s=t.singleLineCommentToken??this.defaultSingleLineCommentToken,i=e.indexOf(s);if(i>-1){const t=Object.values(this.stringKeys);var o=!1;return(o=o||t.some(function(t){var s=new RegExp(t,"g");return(e.substring(0,i).match(s)||[]).length%2!=0}))?void 0:i}}_getTokensFromLine(e,t=!1){if(!e||!e.length)return[];const s=e,i=this._lineHasComment(e);null!=i&&(e=s.substring(0,i));let o=[],n=[],a=0;const l=function(e){t&&(e.includes('"')||e.length<3)||(o.push(e),n.push(a),a+=e.length)};let r=e.matchAll(/(<!--|-->|\*\/|\/\*|::|[\[\](){}<>.,;:*"'`%@$!/= ])/g),c=r.next();if(c.value){let t=0;for(;null!=c.value;){const s=e.substring(t,c.value.index);if(s.length&&l(s),l(c.value[0]),t=c.value.index+c.value[0].length,c=r.next(),!c.value){const s=e.substring(t);s.length&&l(s)}}}else l(e);return null!=i&&l(s.substring(i)),this._currentTokenPositions=n,this._processTokens(o)}_processTokens(e,t=0){if("C++"==this.highlight||"CSS"==this.highlight){var s=e.slice(t).findIndex((e,t)=>this._isNumber(e));if(s>-1){let i=e[s+=t]+e[++s];for(;this._isNumber(i);)e[s-1]+=e[s],e.splice(s,1),i+=e[s];return this._processTokens(e,s)}const i=e.indexOf("important");"CSS"==this.highlight&&i>-1&&"!"===e[i-1]&&(e[i-1]="!important",e.splice(i,1))}else if("PHP"==this.highlight){let t=0,s=e.indexOf("$");for(;s>-1;){const i=s+t;"this-"===e[i+1]?(e[i]="$this",e[i+1]="-"):(e[i]+=e[i+1]??"",e.splice(i+1,1)),s=e.slice(i).indexOf("$"),t=i}}else if("WGSL"==this.highlight){let t=0,s=e.indexOf("@");for(;s>-1;){const i=s+t;e[i]+=e[i+1]??"",e.splice(i+1,1),s=e.slice(i).indexOf("$"),t=i}}return e}_mustHightlightWord(e,t,s){s||(s=Be.languages[this.highlight]);let i=e;return s.ignoreCase&&(i=i.toLowerCase()),t[this.highlight]&&t[this.highlight].has(i)}_getTokenHighlighting(e,t){const s=[...ze.common,...ze[t]||[],...ze.post_common];for(const t of s){if(!t.test(e,this))continue;const s=t.action?t.action(e,this):void 0;return t.discard&&(e.discardToken=s),t.className}return null}_evaluateToken(e){let{token:t,prev:s,next:i,tokenIndex:o,isFirstToken:n,isLastToken:a}=e;const l=Be.languages[this.highlight],r=this.highlight.replace(/\s/g,"").replaceAll("+","p").toLowerCase(),c=Object.assign({},this.stringKeys),h=this._currentLineNumber,d=this._currentTokenPositions[o],u=void 0!==(this._buildingBlockComment??this._inBlockCommentSection(h,d,t.length));var p=!1;if(["cpp","c"].indexOf(r)>-1&&s&&s.includes("#")?c["@<"]=">":"markdown"!=r||"["!=e.prevWithSpaces&&"]"!=e.nextWithSpaces?"javascript"!=r&&"typescript"!=r||(c["@`"]="`"):(p=!0,c["@["]="]"),this._stringEnded=!1,p||!u&&(!l.tags||this._enclosedByTokens(t,o,"<",">"))){const o=e=>{if(this._stringInterpolation&&"$"==t&&"{"==i)return delete this._stringInterpolation,this._stringInterpolationOpened=!0,void(this._stringEnded=!0);const s=Object.values(c).indexOf(e);this._stringEnded=s>-1&&s==Object.values(c).indexOf(c["@"+this._buildingString])};null!=this._buildingString?o(p?e.nextWithSpaces:t):c["@"+(p?e.prevWithSpaces:t)]?(this._buildingString=p?e.prevWithSpaces:t,"javascript"!=r&&"typescript"!=r||"`"!=t||(this._stringInterpolation=!0),p&&o(e.nextWithSpaces)):this._stringInterpolationOpened&&"}"==s&&(delete this._stringInterpolationOpened,this._stringInterpolation=!0,this._buildingString="`")}e.discardToken=!1,e.inBlockComment=u,e.markdownHeader=this._markdownHeader,e.inString=void 0!==this._buildingString,e.singleLineCommentToken=l.singleLineCommentToken??this.defaultSingleLineCommentToken,e.lang=l,e.scope=this._scopeStack.at(-1),e.isVariableSymbol=e=>this.code.symbolsTable.has(e)&&"variable"===this.code.symbolsTable.get(e)[0].kind,e.isEnumValueSymbol=e=>this.code.symbolsTable.has(e)&&"enum_value"===this.code.symbolsTable.get(e)[0].kind,e.isClassSymbol=e=>this.code.symbolsTable.has(e)&&"class"===this.code.symbolsTable.get(e)[0].kind,e.isStructSymbol=e=>this.code.symbolsTable.has(e)&&"struct"===this.code.symbolsTable.get(e)[0].kind,e.isEnumSymbol=e=>this.code.symbolsTable.has(e)&&"enum"===this.code.symbolsTable.get(e)[0].kind;let m=this._getTokenHighlighting(e,r);return this._stringInterpolationOpened&&this._pendingString&&(this._pendingString=this._pendingString.substring(0,this._pendingString.indexOf("$")),"{"==e.tokens[o+1]&&(e.tokens[o+1]="${")),this._buildingString&&(this._stringEnded||a)&&!u&&(t=this._getCurrentString(),m="cm-str",e.discardToken=!1),this._buildingString=this._stringEnded?void 0:this._buildingString,e.discardToken?"":(t=t.replace("<","<").replace(">",">"),m?`<span class="${r} ${m}">${t}</span>`:t)}_appendStringToken(e){return this._pendingString||(this._pendingString=""),this._pendingString+=e,!0}_getCurrentString(){const e=this._pendingString;return delete this._pendingString,e}_enclosedByTokens(e,t,s,i){const o=this._currentTokenPositions[t],n=Oe(this._currentLineString,s,o,!0);if(n<0)return;const a=Oe(this._currentLineString,i,o,!0);if(a>=0&&a>n)return;const l=Oe(this._currentLineString,i,o);return l<0?void 0:n<o&&l>=o+e.length&&!this._mustHightlightWord(e,Be.symbols)?[n,l]:void 0}_inBlockCommentSection(e,t=-1,s=-1){const i=Be.languages[this.highlight].blockCommentsTokens??this.defaultBlockCommentTokens;for(let o of this._blockCommentCache){const n=o[0],a=o[1];if(e>=n.x&&e<=n.y&&(e!=n.x&&e!=n.y||e==n.x&&t>=a.x&&(e==n.y&&t+s<=a.y+i[1].length||e!==n.y)||e==n.y&&t+s<=a.y+i[1].length&&(e==n.x&&t>=a.x||e!==n.x)))return o}}_isKeyword(e){const{token:t,tokenIndex:s,tokens:i,lang:o}=e;let n=this._mustHightlightWord(t,Be.keywords)||"XML"==this.highlight;return"CMake"==this.highlight&&("$"==t&&this._enclosedByTokens(i[s+2],s+2,"{","}")?n=!0:this._enclosedByTokens(t,s,"{","}")&&(n=n||"$"==e.tokens[s-2])),"Markdown"==this.highlight?n=void 0!==this._markdownHeader:o.tags&&(n=n&&null!=this._enclosedByTokens(t,s,"<",">")),n}_isNumber(e){if(!(Be.languages[this.highlight].numbers??1))return!1;const s=e.substring(0,e.length-1);if("C++"==this.highlight){if("f"==t.lastChar(e))return this._isNumber(s);if("u"==t.lastChar(e))return!e.includes(".")&&this._isNumber(s)}else if("WGSL"==this.highlight){if("u"==t.lastChar(e))return!e.includes(".")&&this._isNumber(s)}else if("CSS"==this.highlight&&"%"==t.lastChar(e))return this._isNumber(s);return e.length>0&&" "!=e&&!Number.isNaN(+e)}_encloseSelectedWordWithKey(e,t,s){if(!s.selection||s.selection.fromY!=s.selection.toY)return!1;switch(s.selection.invertIfNecessary(),this.code.lines[t]=[this.code.lines[t].slice(0,s.selection.fromX),e,this.code.lines[t].slice(s.selection.fromX)].join(""),this.cursorToPosition(s,s.selection.toX+1),e){case"'":case'"':break;case"(":e=")";break;case"{":e="}"}return this.code.lines[t]=[this.code.lines[t].slice(0,s.position),e,this.code.lines[t].slice(s.position)].join(""),s.selection.fromX++,s.selection.toX++,this._processSelection(s),this.processLine(t),!0}_detectLanguage(e){const t=new Set(this._getTokensFromLine(e,!0)),s={},i={JavaScript:["import ","export default","console.","=>","document.","window."],TypeScript:["import ","export default","console.","=>","document.","window."],"C++":["#include","::","std::","template <","using namespace"],Python:["def ","import ","print(","self","None","True","False"],HTML:["<html","<div","<body","<script","<style"],CSS:["@media"],Markdown:["#","##","###","](","![","**"]};for(const[t,o]of Object.entries(i)){s[t]=s[t]??0;for(const i of o)e.includes(i)&&(s[t]+=20)}const o=[Be.keywords,Be.statements,Be.utils,Be.types,Be.builtIn];for(const e of o)for(let[i,o]of Object.entries(e)){s[i]=s[i]??0;for(let e of o)t.has(e)&&s[i]++}const n=Object.entries(s).sort((e,t)=>t[1]-e[1]);return n[0][1]>0?n[0][0]:void 0}lineUp(e,t=!1){return null!=this.code.lines[e.line-1]&&(e.line--,e.line=Math.max(0,e.line),this.cursorToTop(e,t),!0)}lineDown(e,t=!1){return null!=this.code.lines[e.line+1]&&(e.line++,this.cursorToBottom(e,t),!0)}swapLines(e,t,s){var i,o,n;null!=this.code.lines[e+t]&&(this._addUndoStep(s,!0),i=this.code.lines,o=e+t,n=e,[i[o],i[n]]=[i[n],i[o]],this.processLine(e+t),this.processLine(e),t>0?this.lineDown(s):this.lineUp(s),this.hideAutoCompleteBox())}restartBlink(){this.code&&(clearInterval(this.blinker),t.addClass(this.cursorsDOM,"show"),this.cursorBlinkRate>0?this.blinker=setInterval(()=>{t.toggleClass(this.cursorsDOM,"show")},this.cursorBlinkRate):this.cursorBlinkRate<0&&t.removeClass(this.cursorsDOM,"show"))}startSelection(e){let s=document.createElement("div");s.className="selections",s.classList.add("show"),t.insertChildAtIndex(this.codeSizer,s,2),this.selections[e.name]=s,e.selection=new Re(this,e)}deleteSelection(e){if(this.disableEdition)return;e.selection&&e.selection.invertIfNecessary();const t=e.selection,s="_NEWLINE_";let i=this.code.lines.join(s),o=0;for(let e=0;e<=t.fromY;e++)o+=e==t.fromY?t.fromX:this.code.lines[e].length;o+=9*t.fromY;const n=t.chars+9*(t.toY-t.fromY),a=i.slice(0,o),l=i.slice(o+n);this.code.lines=(a+l).split(s),this.cursorToLine(e,t.fromY,!0),this.cursorToPosition(e,t.fromX),this.endSelection(e),this.processLines()}endSelection(e){if(delete this._tripleClickSelection,delete this._lastSelectionKeyDir,delete this._currentOcurrences,delete this._lastResult,e)t.deleteElement(this.selections[e.name]),delete this.selections[e.name],e.selection=null,e.line=e.line;else for(let e of this.cursors)e.line=e.line,t.deleteElement(this.selections[e.name]),delete this.selections[e.name],e.selection=null}selectAll(){this.endSelection(),this._removeSecondaryCursors();var e=this.getCurrentCursor();this.resetCursorPos(Be.CURSOR_LEFT_TOP,e,!0),this.startSelection(e);const t=e.selection,s=this.code.lines.length-1;t.toX=this.code.lines[s].length,t.toY=s,this.cursorToPosition(e,t.toX),this.cursorToLine(e,t.toY),this._processSelection(e,null,!0),this.hideAutoCompleteBox()}cursorToRight(e,t){if(!e||!e.length)return;const s=e.length,i=s*this.charWidth;t.left+=i,t.root.style.left=`calc( ${t.left}px + ${this.xPadding} )`,t.position+=s,this.restartBlink(),this.updateScrollLeft(t)}cursorToLeft(e,t){if(!e||!e.length)return;const s=e.length,i=s*this.charWidth;if(t.left-=i,t.left=Math.max(t.left,0),t.root.style.left=`calc( ${t.left}px + ${this.xPadding} )`,t.position-=s,t.position=Math.max(t.position,0),this.restartBlink(),!this.updateScrollLeft(t)){const e=this.charWidth,s=t.position*this.charWidth;if(s<this.getScrollLeft()+e){const t=Math.max(s-e,0);this.setScrollLeft(t)}}}cursorToTop(e,t=!1){e.top-=this.lineHeight,e.top=Math.max(e.top,0),e.root.style.top=`calc(${e.top}px)`,this.restartBlink(),t&&this.resetCursorPos(Be.CURSOR_LEFT,e,!0);const s=this.getScrollTop();var i=s/this.lineHeight|0;e.line-1<i&&this.setScrollTop(s-this.lineHeight)}cursorToBottom(e,t=!1){e.top+=this.lineHeight,e.root.style.top=`calc(${e.top}px)`,this.restartBlink(),t&&this.resetCursorPos(Be.CURSOR_LEFT,e,!0);const s=this.getScrollTop(),i=(this.codeScroller.offsetHeight-this._fullVerticalOffset+s)/this.lineHeight|0;e.line>=i&&this.setScrollTop(s+this.lineHeight)}cursorToString(e,t,s=!1){t.length&&(s?this.cursorToLeft(t,e):this.cursorToRight(t,e))}cursorToPosition(e,t,s=!1){e.position=t,e.left=t*this.charWidth,e.root.style.left=`calc( ${e.left}px + ${this.xPadding} )`,s&&this.updateScrollLeft(e)}cursorToLine(e,t,s=!1){e.line=t,e.top=this.lineHeight*t,e.root.style.top=e.top+"px",s&&this.resetCursorPos(Be.CURSOR_LEFT,e)}saveCursor(e,t={}){return t.position=e.position,t.line=e.line,t.selection=e.selection?e.selection.save():void 0,t}saveCursors(){var e=[];for(let t of this.cursors)e.push(this.saveCursor(t));return e}getCurrentCursor(e=!1){return e&&this._removeSecondaryCursors(),this.cursors[0]}relocateCursors(){for(let e of this.cursors)e.set(e.position,e.line,!1)}mergeCursors(e){console.assert(e>=0);const t=this.cursors.filter(t=>t.line==e);for(;t.length>1;)this.removeCursor(t.pop())}restoreCursor(e,t){e.set(t.position,t.line),t.selection&&(this.endSelection(),this.startSelection(e),e.selection?.load(t.selection),this._processSelection(e,null,!0))}removeCursor(e){e&&(t.deleteElement(this.selections[e.name]),delete this.selections[e.name],t.deleteElement(e))}resetCursorPos(e,t,s=!1){t=t??this.getCurrentCursor(),e&Be.CURSOR_LEFT&&(t.left=0,t.root.style.left="calc("+this.xPadding+")",t.position=0,s&&this.setScrollLeft(0)),e&Be.CURSOR_TOP&&(t.top=0,t.root.style.top="0px",t.line=0,s&&this.setScrollTop(0))}_addCursor(e=0,t=0,s=!1,i=!1){const o=this.cursors.find(s=>s.position==t&&s.line==e);if(o&&!s)return o.isMain||o.remove(),null;let n=new Ie("cursor"+this.cursors.length,t,e,i,this);return this.cursors.push(n),this.cursorsDOM.appendChild(n.root),n}_removeSecondaryCursors(){for(;this.cursors.length>1;){const e=this.cursors.pop();e?.root.remove()}}_getLastCursor(){return this.cursors.at(-1)}_isLastCursor(e){return e===this._getLastCursor()}_logCursors(){for(let e of this.cursors)e.print()}_addSpaceTabs(e,t){for(var s=0;s<t;++s)this.actions.Tab.callback(e.line,e,null)}_addSpaces(e,t){if(!e.selection||e.selection.sameLine())for(var s=0;s<t;++s)this.root.dispatchEvent(new CustomEvent("keydown",{detail:{skipUndo:!0,key:" ",targetCursor:this._lastProcessedCursorIndex}}));else{e.selection.invertIfNecessary();for(let t=e.selection.fromY;t<=e.selection.toY;++t){const s=this.code.lines[t];if(!s.length)continue;let i=Me(s);-1==i&&(i=s.length);let o=i%this.tabSpaces;o=0==o?this.tabSpaces:this.tabSpaces-o;const n=" ".repeat(o);this.code.lines[t]=[s.slice(0,i),n,s.slice(i)].join(""),this.processLine(t),e.line===t&&this.cursorToString(e,n),e.selection.fromY===t&&(e.selection.fromX=Math.max(e.selection.fromX+o,0)),e.selection.toY===t&&(e.selection.toX=Math.max(e.selection.toX+o,0)),this._processSelection(e,void 0,!0)}}}_removeSpaces(e){e.selection&&e.selection.invertIfNecessary();const t=e.selection?e.selection.toY-e.selection.fromY+1:1;for(let s=0;s<t;++s){const t=(e.selection?e.selection.fromY:e.line)+s,i=this.code.lines[t];let o=Me(i);if(0==o)continue;-1==o&&(o=i.length);let n=o%this.tabSpaces;n=0==n?this.tabSpaces:n;const a=Math.max(o-n,0);this.code.lines[t]=[i.slice(0,a),i.slice(o)].join(""),this.processLine(t),e.line===t&&this.cursorToString(e," ".repeat(n),!0),e.selection&&(e.selection.fromY===t&&(e.selection.fromX=Math.max(e.selection.fromX-n,0)),e.selection.toY===t&&(e.selection.toX=Math.max(e.selection.toX-n,0)),this._processSelection(e,void 0,!0))}}updateScrollLeft(e){e=e??this.getCurrentCursor();const t=this.charWidth,s=e.position*this.charWidth,i=this.getScrollLeft(),o=this.codeScroller.clientWidth-Be.LINE_GUTTER_WIDTH;if(s>=o+i-t){const e=Math.max(s-(o-t),0);return this.setScrollLeft(e),!0}}getScrollLeft(){return this.codeScroller?this.codeScroller.scrollLeft:0}getScrollTop(){return this.codeScroller?this.codeScroller.scrollTop:0}setScrollLeft(e){this.codeScroller&&t.doAsync(()=>{this.codeScroller.scrollLeft=e,this.setScrollBarValue("horizontal",0)},10)}setScrollTop(e){this.codeScroller&&t.doAsync(()=>{this.codeScroller.scrollTop=e,this.setScrollBarValue("vertical")},10)}resize(e=Be.RESIZE_SCROLLBAR_H_V,t,s){setTimeout(()=>{let i,o;if(e&Be.RESIZE_SCROLLBAR_H){const e=t??this.getMaxLineLength();this._lastMaxLineLength=e,i=e*this.charWidth+Be.LINE_GUTTER_WIDTH,this.codeSizer.style.minWidth=i+"px"}e&Be.RESIZE_SCROLLBAR_V&&(o=this.code.lines.length*this.lineHeight,this.codeSizer.style.minHeight=o+"px"),this.resizeScrollBars(e),s&&s(i,o)},10)}resizeIfNecessary(e,t=!1){const s=this.getMaxLineLength(),i=Math.floor((this.codeScroller.clientWidth-Be.LINE_GUTTER_WIDTH)/this.charWidth);(t||s>=i&&s!=this._lastMaxLineLength)&&this.resize(Be.RESIZE_SCROLLBAR_H,s,()=>{e.position>i&&this.setScrollLeft(e.position*this.charWidth)})}resizeScrollBars(e=Be.RESIZE_SCROLLBAR_H_V){if(e&Be.RESIZE_SCROLLBAR_V){const e=this.codeScroller.offsetHeight/this.lineHeight|0,t=this.code.lines.length>=e;t&&(this.vScrollbar.thumb.size=e/this.code.lines.length,this.vScrollbar.thumb.style.height=100*this.vScrollbar.thumb.size+"%"),this.vScrollbar.root.classList.toggle("hidden",!t),this.hScrollbar.root.style.width=`calc(100% - ${48+(t?De.SCROLLBAR_VERTICAL_WIDTH:0)}px)`,this.codeArea.root.style.width=`calc(100% - ${t?De.SCROLLBAR_VERTICAL_WIDTH:0}px)`}if(e&Be.RESIZE_SCROLLBAR_H){const e=Math.floor((this.codeScroller.clientWidth-Be.LINE_GUTTER_WIDTH)/this.charWidth),t=this._lastMaxLineLength,s=t>=e;s&&(this.hScrollbar.thumb.size=e/t,this.hScrollbar.thumb.style.width=100*this.hScrollbar.thumb.size+"%"),this.hScrollbar.root.classList.toggle("hidden",!s),this.codeArea.root.style.height=`calc(100% - ${this._fullVerticalOffset+(s?De.SCROLLBAR_HORIZONTAL_HEIGHT:0)}px)`}}setScrollBarValue(e="vertical",t){if("vertical"==e){const e=this.codeScroller.scrollHeight-this.codeScroller.clientHeight;if(e>0){const t=this.vScrollbar.thumb.parentElement.offsetHeight,s=this.vScrollbar.thumb.offsetHeight,i=this.codeScroller.scrollTop;this.vScrollbar.thumb._top=i/e*(t-s),this.vScrollbar.thumb.style.top=this.vScrollbar.thumb._top+"px"}}else{void 0!==t&&(this.codeScroller.scrollLeft+=t);const e=this.codeScroller.scrollWidth-this.codeScroller.clientWidth;if(e>0){const t=this.hScrollbar.thumb.parentElement.offsetWidth,s=this.hScrollbar.thumb.offsetWidth,i=this.codeScroller.scrollLeft;this.hScrollbar.thumb._left=i/e*(t-s),this.hScrollbar.thumb.style.left=this.hScrollbar.thumb._left+"px"}}}updateHorizontalScrollFromScrollBar(e){e=this.hScrollbar.thumb._left-e;const s=this.hScrollbar.thumb.parentElement.offsetWidth,i=this.hScrollbar.thumb.offsetWidth;this.hScrollbar.thumb._left=t.clamp(e,0,s-i),this.hScrollbar.thumb.style.left=this.hScrollbar.thumb._left+"px";const o=this.codeScroller.scrollWidth-this.codeScroller.clientWidth,n=this.hScrollbar.thumb._left*o/(s-i);this.codeScroller.scrollLeft=n,this._discardScroll=!0}updateVerticalScrollFromScrollBar(e){e=this.vScrollbar.thumb._top-e;const s=this.vScrollbar.thumb.parentElement.offsetHeight,i=this.vScrollbar.thumb.offsetHeight;this.vScrollbar.thumb._top=t.clamp(e,0,s-i),this.vScrollbar.thumb.style.top=this.vScrollbar.thumb._top+"px";const o=this.codeScroller.scrollHeight-this.codeScroller.clientHeight,n=this.vScrollbar.thumb._top*o/(s-i);this.codeScroller.scrollTop=n}getCharAtPos(e,t=0){return this.code.lines[e.line][e.position+t]}getWordAtPos(e,t=0){const s=e.line,i=this.code.lines[s],o=e=>{const t=e.charCodeAt(0);return["_","#","!"].indexOf(e)>-1||t>47&&t<58||t>64&&t<91||t>96&&t<123};let n=e.position+t,a=e.position+t;for(;i[n]&&o(i[n]);)n--;for(n++;i[a]&&o(i[a]);)a++;let l=i.substring(n,a);if(" "==l)if(t<0){for(;null!=i[n-1]&&" "==i[n-1];)n--;a++,l=i.substring(n,a+1)}else{for(;null!=i[a]&&" "==i[a];)a++;n--,l=i.substring(n,a)}return[l,n,a]}_measureChar(e="M",s=!0,i=!1){const o=t.makeContainer(null,"lexcodeeditor","",document.body),n=t.makeContainer(null,"code","",o),a=document.createElement("pre");n.appendChild(a);const l=document.createElement("span");a.appendChild(l),l.innerText=e;var r=l.getBoundingClientRect();t.deleteElement(o);const c=[s?r.width:Math.floor(r.width),s?r.height:Math.floor(r.height)];return i?c:c[0]}measureString(e){return e.length*this.charWidth}runScript(e){const t=document.createElement("script");t.type="module",t.innerHTML=e,t.async=!1,document.getElementsByTagName("head")[0].appendChild(t)}toJSONFormat(e){let t=e.split(":");for(let e=0;e<t.length;e++){let s=t[e].split(",");if(s.length>1){if(s[s.length-1].includes("]"))continue;s=s[s.length-1]}else{if(s[0].includes("}"))continue;s=s[0]}s=s.replaceAll(/[{}\n\r]/g,"").replaceAll(" ",""),'"'!=s[0]&&'"'!=s[s.length-1]&&(t[e]=t[e].replace(s,'"'+s+'"'))}e=t.join(":");try{let t=JSON.parse(e);return JSON.stringify(t,void 0,4)}catch(e){return void alert("Invalid JSON format")}}showAutoCompleteBox(e,s){if(!s.isMain)return;const[i,o,n]=this.getWordAtPos(s,-1);if(" "==e||!i.length)return void this.hideAutoCompleteBox();this.autocomplete.innerHTML="";let a=[...Array.from(Be.keywords[this.highlight]??[]),...Array.from(Be.builtIn[this.highlight]??[]),...Array.from(Be.statements[this.highlight]??[]),...Array.from(Be.types[this.highlight]??[]),...Array.from(Be.utils[this.highlight]??[])];const l=[...this.code.lineScopes[s.line]].at(-1);if(l.type.startsWith("enum")){const e=Array.from(this.code.symbolsTable).filter(e=>"enum_value"===e[1][0].kind&&e[1][0].scope===l.name).map(e=>e[0]);a=a.concat(e.slice(0,-1))}else{const e=Array.from(this.code.symbolsTable).map(e=>e[0]);a=a.concat(e.slice(0,-1))}function r(e,t){return e.startsWith(t)?0:e.includes(t)?1:2}a=a.concat(this.customSuggestions),a=Array.from(new Set(a)).filter(e=>e.length>2&&e.toLowerCase().includes(i.toLowerCase())),a=a.sort((e,t)=>r(e,i)-r(t,i)||e.localeCompare(t));for(let e of a){const s=e,o=document.createElement("pre");this.autocomplete.appendChild(o);const n=this.code.symbolsTable.get(e);let a="CaseLower",l="foo";if(n)switch(n[0].kind){case"variable":a="Cuboid",l="fg-blue-400";break;case"method":a="Box",l="fg-fuchsia-500";break;case"class":a="CircleNodes",l="fg-orange-500"}else this._mustHightlightWord(s,Be.utils)?a="ToolCase":this._mustHightlightWord(s,Be.types)&&(a="Type",l="fg-blue-400");o.appendChild(t.makeIcon(a,{iconClass:"mr-1",svgClass:"sm "+l})),o.addEventListener("click",()=>{this.autoCompleteWord(s)});const r=s.toLowerCase().indexOf(i.toLowerCase());var c=document.createElement("span");c.innerHTML=s.substring(0,r),o.appendChild(c);var h=document.createElement("span");h.innerHTML=s.substr(r,i.length),h.classList.add("word-highlight"),o.appendChild(h);var d=document.createElement("span");d.innerHTML=s.substring(r+i.length),o.appendChild(d)}if(!this.autocomplete.childElementCount)return void this.hideAutoCompleteBox();const u=this.codeScroller.clientWidth-256;this.autocomplete.firstChild.classList.add("selected"),this.autocomplete.classList.toggle("show",!0),this.autocomplete.classList.toggle("no-scrollbar",!(this.autocomplete.scrollHeight>this.autocomplete.offsetHeight)),this.autocomplete.style.left=`${Math.min(s.left+Be.LINE_GUTTER_WIDTH-this.getScrollLeft(),u)}px`,this.autocomplete.style.top=s.top+this._verticalTopOffset+this.lineHeight-this.getScrollTop()+"px",this.isAutoCompleteActive=!0}hideAutoCompleteBox(){if(!this.autocomplete)return;const e=this.isAutoCompleteActive;return this.isAutoCompleteActive=!1,this.autocomplete.classList.remove("show"),this.autocomplete.innerHTML="",e!=this.isAutoCompleteActive}autoCompleteWord(e){if(!this.isAutoCompleteActive)return;let[t,s]=this._getSelectedAutoComplete();t=e??t;for(let e of this.cursors){const[s,i,o]=this.getWordAtPos(e,-1),n=this.code.lines[e.line];this.code.lines[e.line]=n.slice(0,i)+t+n.slice(o),this.cursorToPosition(e,i+t.length),this.processLine(e.line)}this._skipTabs=this.cursors.length-1,this.hideAutoCompleteBox()}_getSelectedAutoComplete(){for(let t=0;t<this.autocomplete.childElementCount;++t){const s=this.autocomplete.childNodes[t];if(s.classList.contains("selected")){var e="";for(let t of s.childNodes)t.constructor==HTMLSpanElement&&(e+=t.innerHTML);return[e,t]}}return[null,-1]}_moveArrowSelectedAutoComplete(e){if(!this.isAutoCompleteActive)return;const[s,i]=this._getSelectedAutoComplete(),o="down"==e?1:-1,n=i+o;if("down"==e){if(n>=this.autocomplete.childElementCount)return;22*(i+2*o)-this.autocomplete.scrollTop>132&&(this.autocomplete.scrollTop+=22)}else if("up"==e){if(n<0)return;22*n<this.autocomplete.scrollTop&&(this.autocomplete.scrollTop-=22)}t.removeClass(this.autocomplete.childNodes[i],"selected"),t.addClass(this.autocomplete.childNodes[i+o],"selected")}showSearchBox(e=!1){this.hideSearchLineBox(),t.addClass(this.searchbox,"opened"),this.isSearchboxActive=!0;const s=this.searchbox.querySelector("input");if(e)s.value="";else{const e=this.getCurrentCursor();e.selection&&(s.value=e.selection.getText()??s.value)}s.selectionStart=0,s.selectionEnd=s.value.length,s.focus()}hideSearchBox(){const e=this.isSearchboxActive;return this.isSearchboxActive?(this.searchbox.classList.remove("opened"),this.isSearchboxActive=!1):this._lastResult&&(t.deleteElement(this._lastResult.dom),delete this._lastResult),this.searchResultSelections.classList.remove("show"),e!=this.isSearchboxActive}search(e,s=!1,i,o=!1,n=!0){if(!(e=e??this._lastTextFound))return;let a=this.getCurrentCursor(),l=new t.vec2(a.position,a.line),r=null,c=-1;this._lastResult&&(t.deleteElement(this._lastResult.dom),l=this._lastResult.pos,l.x+=e.length*(s?-1:1),delete this._lastResult);const h=t=>{var i=this.code.lines[t];if(s){var o=Ae(i=i.substr(0,t==l.y?l.x:i.length)).indexOf(Ae(e));return-1==o?-1:i.length-o-e.length}return i.substr(t==l.y?l.x:0).indexOf(e)};if(s){for(var d=l.y;d>=0;--d)if(c=h(d),c>-1){r=d;break}}else for(d=l.y;d<this.code.lines.length;++d)if(c=h(d),c>-1){r=d;break}if(null==r){o||alert("No results!");const e=this.code.lines.length-1;return void(this._lastResult={dom:this.searchResultSelections.lastChild,pos:s?new t.vec2(this.code.lines[e].length,e):new t.vec2(0,0)})}if(s||(c+=r==l.y?l.x:0),this._lastTextFound=e,this.codeScroller.scrollTo(Math.max(c*this.charWidth-this.codeScroller.clientWidth,0),Math.max(r-10,0)*this.lineHeight),i?i(c,r):(this.searchResultSelections.classList.add("show"),a.selection=new Re(this,a,"lexcodesearchresult"),a.selection.selectInline(a,c,r,this.measureString(e),!0)),this._lastResult={dom:this.searchResultSelections.lastChild,pos:new t.vec2(c,r),reverse:s},n){this.searchbox.querySelector("input").focus()}}showSearchLineBox(){this.hideSearchBox(),this.searchlinebox.classList.add("opened"),this.isSearchlineboxActive=!0;const e=this.searchlinebox.querySelector("input");e.value=":",e.focus()}hideSearchLineBox(){this.isSearchlineboxActive&&(this.searchlinebox.classList.remove("opened"),this.isSearchlineboxActive=!1)}goToLine(e){if(this._isNumber(e)){this.codeScroller.scrollTo(0,Math.max(e-15)*this.lineHeight);var t=this.getCurrentCursor(!0);this.cursorToLine(t,e-1,!0)}}selectNextOcurrence(e){if(!e.selection)return;const t=e.selection.getText();if(t){if(!this._currentOcurrences){const s=[e.position-t.length,e.line].join("_");this._currentOcurrences={},this._currentOcurrences[s]=!0}this.search(t,!1,(e,s)=>{const i=[e,s].join("_");if(!this._currentOcurrences[i]){var o=this._addCursor(s,e,!0);o&&(this.startSelection(o),o?.root.selection.selectInline(o,e,s,this.measureString(t)),this.cursorToString(o,t)),this._currentOcurrences[i]=!0}},!0,!1)}}_updateDataInfoPanel(e,s){this.skipInfo||(this.cursors.length>1&&(s=""),t.emitSignal(e,s))}_setActiveLine(e){if(void 0===(e=e??this.state.activeLine))return;const t=this.getCurrentCursor();this._updateDataInfoPanel("@cursor-data",`Ln ${e+1}, Col ${t.position+1}`);const s=this.toLocalLine(this.state.activeLine);let i=this.code.childNodes[s];if(i){i.classList.remove("active-line");{this.state.activeLine=e;const t=this.toLocalLine(e);i=this.code.childNodes[t],i&&i.classList.add("active-line")}}}_hideActiveLine(){this.code.querySelectorAll(".active-line").forEach(e=>e.classList.remove("active-line"))}_setFontSize(e){this.fontSize=e;const s=document.querySelector(":root");s.style.setProperty("--code-editor-font-size",`${this.fontSize}px`),this.charWidth=this._measureChar(),window.localStorage.setItem("lexcodeeditor-font-size",`${this.fontSize}`);const i=this.fontSize+6;s.style.setProperty("--code-editor-row-height",`${i}px`),this.lineHeight=i,this.relocateCursors(),this.processLines(),t.emitSignal("@font-size",this.fontSize)}_applyFontSizeOffset(e=0){const s=t.clamp(this.fontSize+e,Be.CODE_MIN_FONT_SIZE,Be.CODE_MAX_FONT_SIZE);this._setFontSize(s)}_increaseFontSize(){this._applyFontSizeOffset(1)}_decreaseFontSize(){this._applyFontSizeOffset(-1)}_clearTmpVariables(){delete this._currentLineString,delete this._currentLineNumber,delete this._buildingString,delete this._pendingString,delete this._buildingBlockComment,delete this._markdownHeader,delete this._lastResult,delete this._scopeStack}async _requestFileAsync(e,t,s=!1){return new Promise((i,o)=>{const n="arraybuffer"===(t=t??"arraybuffer")?"application/octet-stream":void 0;var a=new XMLHttpRequest;return a.open("GET",e,!0),a.responseType=t,n&&a.overrideMimeType(n),s&&a.setRequestHeader("Cache-Control","no-cache"),a.onload=function(){var e=this.response;if(200==this.status)i(e);else{var t="Error "+this.status;o(t)}},a.onerror=function(e){o(e)},a.send(),a})}}const He=Be;if(He.languages={"Plain Text":{ext:"txt",blockComments:!1,singleLineComments:!1,numbers:!1,icon:"AlignLeft fg-neutral-500"},JavaScript:{ext:"js",icon:"Js fg-yellow-500"},TypeScript:{ext:"ts",icon:"Ts fg-blue-600"},C:{ext:["c","h"],usePreprocessor:!0,icon:{c:"C fg-sky-400",h:"C fg-fuchsia-500"}},"C++":{ext:["cpp","hpp"],usePreprocessor:!0,icon:{cpp:"CPlusPlus fg-sky-400",hpp:"CPlusPlus fg-fuchsia-500"}},CSS:{ext:"css",icon:"Hash fg-blue-700"},CMake:{ext:"cmake",singleLineCommentToken:"#",blockComments:!1,ignoreCase:!0},GLSL:{ext:"glsl",usePreprocessor:!0},WGSL:{ext:"wgsl",usePreprocessor:!0},JSON:{ext:"json",blockComments:!1,singleLineComments:!1,icon:"Json fg-yellow-400"},XML:{ext:"xml",tags:!0,icon:"Rss fg-orange-500"},Rust:{ext:"rs",icon:"Rust fg-primary"},Python:{ext:"py",singleLineCommentToken:"#",icon:"Python fg-cyan-600"},HTML:{ext:"html",tags:!0,singleLineComments:!1,blockCommentsTokens:["\x3c!--","--\x3e"],numbers:!1,icon:"Code fg-orange-500"},Batch:{ext:"bat",blockComments:!1,singleLineCommentToken:"::",ignoreCase:!0,icon:"Windows fg-blue-400"},Markdown:{ext:"md",blockComments:!1,singleLineCommentToken:"::",tags:!0,numbers:!1,icon:"Markdown fg-primary"},PHP:{ext:"php",icon:"Php fg-purple-700"}},He.nativeTypes={"C++":["int","float","double","bool","long","short","char","wchar_t","void"],WGSL:["bool","u32","i32","f16","f32","vec2","vec3","vec4","vec2f","vec3f","vec4f","mat2x2f","mat3x3f","mat4x4f","array","vec2u","vec3u","vec4u","ptr","sampler"]},He.declarationKeywords={JavaScript:["var","let","const","this","static","class"],"C++":[...He.nativeTypes["C++"],"const","auto","class","struct","namespace","enum","extern"]},He.keywords={JavaScript:["var","let","const","this","in","of","true","false","new","function","NaN","static","class","constructor","null","typeof","debugger","abstract","arguments","extends","instanceof","Infinity","get"],TypeScript:["var","let","const","this","in","of","true","false","new","function","class","extends","instanceof","Infinity","private","public","protected","interface","enum","type","get"],C:["int","float","double","long","short","char","const","void","true","false","auto","struct","typedef","signed","volatile","unsigned","static","extern","enum","register","union"],"C++":[...He.nativeTypes["C++"],"const","static_cast","dynamic_cast","new","delete","true","false","auto","class","struct","typedef","nullptr","NULL","signed","unsigned","namespace","enum","extern","union","sizeof","static","private","public"],CMake:["cmake_minimum_required","set","not","if","endif","exists","string","strequal","add_definitions","macro","endmacro","file","list","source_group","add_executable","target_include_directories","set_target_properties","set_property","add_compile_options","add_link_options","include_directories","add_library","target_link_libraries","target_link_options","add_subdirectory","add_compile_definitions","project","cache"],JSON:["true","false"],GLSL:["true","false","function","int","float","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","struct"],CSS:["body","html","canvas","div","input","span",".","table","tr","td","th","label","video","img","code","button","select","option","svg","media","all","i","a","li","h1","h2","h3","h4","h5","last-child","tbody","pre","monospace","font-face"],WGSL:[...He.nativeTypes.WGSL,"var","let","true","false","fn","atomic","struct","sampler_comparison","texture_depth_2d","texture_depth_2d_array","texture_depth_cube","texture_depth_cube_array","texture_depth_multisampled_2d","texture_external","texture_1d","texture_2d","texture_2d_array","texture_3d","texture_cube","texture_cube_array","texture_storage_1d","texture_storage_2d","texture_storage_2d_array","texture_storage_3d"],Rust:["as","const","crate","enum","extern","false","fn","impl","in","let","mod","move","mut","pub","ref","self","Self","static","struct","super","trait","true","type","unsafe","use","where","abstract","become","box","final","macro","override","priv","typeof","unsized","virtual"],Python:["False","def","None","True","in","is","and","lambda","nonlocal","not","or"],Batch:["set","echo","off","del","defined","setlocal","enabledelayedexpansion","driverquery","print"],HTML:["html","meta","title","link","script","body","DOCTYPE","head","br","i","a","li","img","tr","td","h1","h2","h3","h4","h5"],Markdown:["br","i","a","li","img","table","title","tr","td","h1","h2","h3","h4","h5"],PHP:["const","function","array","new","int","string","$this","public","null","private","protected","implements","class","use","namespace","abstract","clone","final","enum"]},He.utils={JavaScript:["querySelector","body","addEventListener","removeEventListener","remove","sort","keys","filter","isNaN","parseFloat","parseInt","EPSILON","isFinite","bind","prototype","length","assign","entries","values","concat","substring","substr","splice","slice","buffer","appendChild","createElement","prompt","alert"],WGSL:["textureSample"],Python:["abs","all","any","ascii","bin","bool","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],CSS:[...Object.keys(document.body.style).map(t.toKebabCase),"block","inline","inline-block","flex","grid","none","inherit","initial","unset","revert","sticky","relative","absolute","fixed","static","auto","visible","hidden","scroll","clip","ellipsis","nowrap","wrap","break-word","solid","dashed","dotted","double","groove","ridge","inset","outset","left","right","center","top","bottom","start","end","justify","stretch","space-between","space-around","space-evenly","baseline","middle","normal","bold","lighter","bolder","italic","blur","uppercase","lowercase","capitalize","transparent","currentColor","pointer","default","move","grab","grabbing","not-allowed","none","cover","contain","repeat","no-repeat","repeat-x","repeat-y","round","space","linear-gradient","radial-gradient","conic-gradient","url","calc","min","max","clamp","red","blue","green","black","white","gray","silver","yellow","orange","purple","pink","cyan","magenta","lime","teal","navy","transparent","currentcolor","inherit","initial","unset","revert","none","auto","fit-content","min-content","max-content"]},He.types={JavaScript:["Object","String","Function","Boolean","Symbol","Error","Number","TextEncoder","TextDecoder","Array","ArrayBuffer","InputEvent","MouseEvent","Int8Array","Int16Array","Int32Array","Float32Array","Float64Array","Element"],TypeScript:["arguments","constructor","null","typeof","debugger","abstract","Object","string","String","Function","Boolean","boolean","Error","Number","number","TextEncoder","TextDecoder","Array","ArrayBuffer","InputEvent","MouseEvent","Int8Array","Int16Array","Int32Array","Float32Array","Float64Array","Element","bigint","unknown","any","Record"],Rust:["u128"],Python:["int","type","float","map","list","ArithmeticError","AssertionError","AttributeError","Exception","EOFError","FloatingPointError","GeneratorExit","ImportError","IndentationError","IndexError","KeyError","KeyboardInterrupt","LookupError","MemoryError","NameError","NotImplementedError","OSError","OverflowError","ReferenceError","RuntimeError","StopIteration","SyntaxError","TabError","SystemError","SystemExit","TypeError","UnboundLocalError","UnicodeError","UnicodeEncodeError","UnicodeDecodeError","UnicodeTranslateError","ValueError","ZeroDivisionError"],"C++":["uint8_t","uint16_t","uint32_t"],PHP:["Exception","DateTime","JsonSerializable"]},He.builtIn={JavaScript:["document","console","window","navigator","performance"],CSS:["*","!important"],"C++":["vector","list","map"],WGSL:["@vertex","@fragment"],HTML:["type","xmlns","PUBLIC","http-equiv","src","style","lang","href","rel","content","xml","alt"],Markdown:["type","src","style","lang","href","rel","content","valign","alt"],PHP:["echo","print"]},He.statements={JavaScript:["for","if","else","case","switch","return","while","continue","break","do","import","default","export","from","throw","async","try","catch","await","as"],TypeScript:["for","if","else","case","switch","return","while","continue","break","do","import","default","export","from","throw","async","try","catch","await","as"],CSS:["@","import"],C:["for","if","else","return","continue","break","case","switch","while","using","default","goto","do"],"C++":["std","for","if","else","return","continue","break","case","switch","while","using","glm","spdlog","default"],GLSL:["for","if","else","return","continue","break"],WGSL:["const","for","if","else","return","continue","break","storage","read","read_write","uniform","function","workgroup","bitcast"],Rust:["break","else","continue","for","if","loop","match","return","while","do","yield"],Python:["if","raise","del","import","return","elif","try","else","while","as","except","with","assert","finally","yield","break","for","class","continue","global","pass","from"],Batch:["if","IF","for","FOR","in","IN","do","DO","call","CALL","goto","GOTO","exit","EXIT"],PHP:["declare","enddeclare","foreach","endforeach","if","else","elseif","endif","for","endfor","while","endwhile","switch","case","default","endswitch","return","break","continue","try","catch","die","do","exit","finally"]},He.symbols={JavaScript:["<",">","[","]","{","}","(",")",";","=","|","||","&","&&","?","??"],TypeScript:["<",">","[","]","{","}","(",")",";","=","|","||","&","&&","?","??"],C:["<",">","[","]","{","}","(",")",";","=","|","||","&","&&","?","*","-","+"],"C++":["<",">","[","]","{","}","(",")",";","=","|","||","&","&&","?","::","*","-","+"],CMake:["{","}"],JSON:["[","]","{","}","(",")"],GLSL:["[","]","{","}","(",")"],WGSL:["[","]","{","}","(",")","->"],CSS:["{","}","(",")","*"],Rust:["<",">","[","]","(",")","="],Python:["<",">","[","]","(",")","="],Batch:["[","]","(",")","%"],HTML:["<",">","/"],XML:["<",">","/"],PHP:["[","]","{","}","(",")"]},He.REGISTER_LANGUAGE=function(e,t={},s,i){He.languages[e]=t,s?.keywords&&(He.keywords[e]=new Set(s.keywords)),s?.utils&&(He.utils[e]=new Set(s.utils)),s?.types&&(He.types[e]=new Set(s.types)),s?.builtIn&&(He.builtIn[e]=new Set(s.builtIn)),s?.statements&&(He.statements[e]=new Set(s.statements)),s?.symbols&&(He.symbols[e]=new Set(s.symbols)),i&&(ze[e]=i)},t.CodeEditor=Be,!t)throw"Missing LX namespace!";t.extensions.push("DocMaker");const Fe=["int","float","double","bool","char","wchar_t","const","static_cast","dynamic_cast","new","delete","void","true","false","auto","struct","typedef","nullptr","NULL","unsigned","namespace","auto"],$e=["uint32_t","uint64_t","uint8_t"],Ve=["for","if","else","return","continue","break","case","switch","while","import","from","await"],Ke=["var","let","const","static","function","null","undefined","new","delete","true","false","NaN","this"],Ue=["html","charset","rel","src","href","crossorigin","type","lang"],Ge=["html","DOCTYPE","head","meta","title","link","script","body","style"];class We{root;_listQueued=void 0;constructor(e){this.root=e??document.body}setDomTarget(e){this.root=e}lineBreak(e){(e=e??this.root).appendChild(document.createElement("br"))}header(e,t,s){console.assert(void 0!==e&&void 0!==t);let i=document.createElement(t);i.innerHTML=e,s&&(i.id=s),this.root.appendChild(i)}paragraph(e,t=!1,s){console.assert(void 0!==e);let i=document.createElement(t?"sup":"p");i.className="leading-relaxed "+(s??""),i.innerHTML=e,this.root.appendChild(i)}code(e,s="js"){console.assert(void 0!==e),e.replaceAll("<","<"),e.replaceAll(">",">");let i="",o="";const n=(e,t)=>`<span class="${e}">${t}</span>`;for(let t=0;t<e.length;++t){const a=e[t],l=e.substr(t),r=l.indexOf("\n"),c=l.substring(0,r>-1?r:void 0);if("@"==a){const a=c.substr(1);if(!(a.indexOf("@")>-1||a.indexOf("[")>-1))continue;let l=null;const r=a.indexOf("@"),h="|"==a[r-1];if("["==e[t+1])if(i=a.substr(1,3),o=a.substring(5,r),h){const t=a.substring(6+o.length),s=o,r=t.substring(0,t.indexOf("@"));l=n(i,s.substring(0,s.length-1)+"@"+r);const c=s+"@"+r;e=e.replace(`@[${i}]${c}@`,l)}else l=n(i,o),e=e.replace(`@[${i}]${o}@`,l);else{if(o=a.substring(0,r),h){const s=a.substring(0,a.indexOf("@")-1);o=a.substring(s.length+1),o=s+o.substring(0,o.substring(1).indexOf("@")+1),e=e.substr(0,t)+"@"+o+"@"+e.substr(t+o.length+3)}if("cpp"==s&&Fe.includes(o))i="kwd";else if("js"==s&&Ke.includes(o))i="kwd";else if($e.includes(o))i="cls";else if(Ve.includes(o))i="lit";else if(Ge.includes(o))i="tag";else if(Ue.includes(o))i="atn";else if('"'==o[0]&&'"'==o[o.length-1]||"'"==o[0]&&"'"==o[o.length-1]||"`"==o[0]&&"`"==o[o.length-1])i="str";else{if(Number.isNaN(parseFloat(o)))return void console.error("ERROR[Code Parsing]: Unknown highlight type: "+o);i="dec"}l=n(i,o),e=e.replace(`@${o}@`,l)}t+=l.length-1}}let a=document.createElement("div");a.className="code-container";let l=document.createElement("pre"),r=document.createElement("code");r.innerHTML=e;let c=document.createElement("button");c.title="Copy code sample",c.appendChild(t.makeIcon("Copy")),c.addEventListener("click",this._copySnippet.bind(this,c)),a.appendChild(c),l.appendChild(r),a.appendChild(l),this.root.appendChild(a)}list(e,t,s){console.assert(e&&e.length>0&&["bullet","numbered"].includes(t),"Invalid list type or empty list"+t);const i="bullet"==t?"ul":"ol";let o=document.createElement(i);for(var n of((s=s??this.root).appendChild(o),e)){if(n.constructor===Array)return void this.list(n,t,o);let e=document.createElement("li");e.className="leading-loose",e.innerHTML=n,o.appendChild(e)}}bulletList(e){this.list(e,"bullet")}numberedList(e){this.list(e,"numbered")}startCodeBulletList(){let e=document.createElement("ul");this._listQueued=e}endCodeBulletList(){void 0!==this._listQueued&&(console.assert(void 0!==this._listQueued),this.root.appendChild(this._listQueued),this._listQueued=void 0)}codeListItem(e,t){t=t??this._listQueued;let s=e.constructor===Array;if(s&&e[0].constructor===Array)return void this.codeBulletList(e,t);let i=document.createElement("li");i.className="leading-loose",i.innerHTML=s?2==e.length?this.iCode(e[0])+": "+e[1]:this.iCode(e[0]+" <span class='desc'>("+e[1]+")</span>")+": "+e[2]:this.iCode(e),t?.appendChild(i)}codeBulletList(e,t){console.assert(void 0!==e&&e.length>0);let s=document.createElement("ul");for(var i of e)this.codeListItem(i,s);t?t.appendChild(s):this.root.appendChild(s)}image(e,t="",s){let i=document.createElement("img");i.src=e,i.alt=t,i.className="my-1",(s=s??this.root).appendChild(i)}images(e,t=[],s,i){if(navigator&&/Android|iPhone/i.test(navigator.userAgent))for(let s=0;s<e.length;++s)this.image(e[s],t[s]);else{let o=document.createElement("div");o.style.width=s??"auto",o.style.height=i??"256px",o.className="flex flex-row justify-center";for(let s=0;s<e.length;++s)this.image(e[s],t[s],o);this.root.appendChild(o)}}video(e,t="",s=!0,i=!1){let o=document.createElement("video");o.src=e,o.controls=s,o.autoplay=i,i&&(o.muted=!0),o.loop=!0,o.alt=t,this.root.appendChild(o)}note(e,s=!1,i,o){console.assert(void 0!==e);const n=t.makeContainer([],"border rounded-lg overflow-hidden text-md fg-secondary my-6","",this.root);let a=document.createElement("div");a.className="flex bg-tertiary font-semibold px-3 py-2 gap-2 fg-secondary",a.appendChild(t.makeIcon(o??(s?"MessageSquareWarning":"NotepadText"))),a.innerHTML+=i??(s?"Important":"Note"),n.appendChild(a),t.makeContainer([],"leading-6 p-3",e,n)}classCtor(e,t,s="js"){let i="";for(var o of t){const e=o[0],n=o[1];"cpp"==s?i+=e+(n?" = <span class='desc'>"+n+"</span>":"")+(t.indexOf(o)!=t.length-1?", ":""):"js"==s&&(i+=e+": <span class='desc'>"+n+"</span>"+(t.indexOf(o)!=t.length-1?", ":""))}let n=document.createElement("p");n.innerHTML=this.iCode("<span class='constructor'>"+e+"("+i+")</span>"),this.root.appendChild(n)}classMethod(e,t,s,i){this.startCodeBulletList();let o="";for(var n of s){o+=n[0]+": <span class='desc'>"+n[1]+"</span>"+(s.indexOf(n)!=s.length-1?", ":"")}let a=document.createElement("li");return a.innerHTML=this.iCode("<span class='method'>"+e+" ("+o+")"+(i?": "+i:"")+"</span>"),this._listQueued?.appendChild(a),this.endCodeBulletList(),this.paragraph(t),a.parentElement}iLink(e,t){return console.assert(void 0!==e&&void 0!==t),`<a href="${t}">${e}</a>`}iPage(e,t){console.assert(void 0!==e&&void 0!==t);const s=t.replace(".html",""),i=globalThis;if(i.setPath&&i.loadPage){return`<a onclick="loadPage('${t}', true, '${i.setPath(s)}')">${e}</a>`}console.warn("[DocMaker] Create globalThis.setPath and globalThis.loadPage to use inline pages!")}iCode(e,t){return console.assert(void 0!==e),`<code class="inline ${t??""}">${e}</code>`}_copySnippet(e){e.innerHTML="",e.appendChild(t.makeIcon("Check")),e.classList.add("copied"),setTimeout(()=>{e.innerHTML="",e.appendChild(t.makeIcon("Copy")),e.classList.remove("copied")},2e3),navigator.clipboard.writeText(e.dataset.snippet??e.parentElement.innerText),console.log("Copied!")}}if(!t)throw"Missing LX namespace!";t.extensions.push("GraphEditor");const qe=globalThis,Ye=t.vec2,Xe=t.Area;t.Panel,t.Sidebar,t.ContextMenu;const je=t.PocketDialog;class Ze{origin;size;constructor(e,t){this.origin=e??new Ye(0,0),this.size=t??new Ye(0,0)}merge(e){console.assert(e.constructor==Ze);const t=this.origin,s=this.origin.add(this.size),i=e.origin,o=e.origin.add(e.size),n=new Ye(Math.min(t.x,i.x),Math.min(t.y,i.y)),a=new Ye(Math.max(s.x,o.x),Math.max(s.y,o.y));this.origin=n,this.size=a.sub(n)}inside(e,t=!0){const s=this.origin,i=this.origin.add(this.size),o=e.origin,n=e.origin.add(e.size);return t?o.x>=s.x&&n.x<=i.x&&o.y>=s.y&&n.y<=i.y:n.x>=s.x&&o.x<=i.x&&n.y>=s.y&&o.y<=i.y}}class Je{static __instances=[];static MIN_SCALE=.25;static MAX_SCALE=4;static EVENT_MOUSEMOVE=0;static EVENT_MOUSEWHEEL=1;static LAST_GROUP_ID=0;static LAST_FUNCTION_ID=0;static STOPPED=0;static RUNNING=1;static NODE_IO_INPUT=0;static NODE_IO_OUTPUT=1;static NODE_TYPES={};static onCustomNodeRegistered=()=>{};static onNodeTypeReplaced=()=>{};root;area;propertiesDialog;currentGraph=null;keys={};graphs={};nodes={};variables={};groups={};supportedCastTypes={};selectedNodes=[];main="";mustStop=!1;state=Je.STOPPED;isFocused=!1;_graphContainer;_sidebarDom;_sidebarActive=!0;_sidebar;_domLinks;_domNodes;_mousePosition=new Ye(0,0);_deltaMousePosition=new Ye(0,0);_snappedDeltaMousePosition=new Ye(0,0);_lastMousePosition=new Ye(0,0);_lastSnappedMousePosition=new Ye(0,0);_generatingLink;_snapToGrid=!1;_snapValue=1;_nodeBackgroundOpacity=.8;_patternSizeF=15;_patternSize=new Ye(this._patternSizeF);_circlePatternSize=.04*this._patternSizeF;_circlePatternColor="#71717a9c";_background;_undoSteps=[];_redoSteps=[];_clipboardData;_lastMouseDown=0;_boxSelecting;_boxSelectRemoving;_currentBoxSelectionSVG;constructor(e,s={}){Je.__instances.push(this),this._sidebar=e.addSidebar(e=>{},{displaySelected:!0,headerIcon:"EllipsisVertical",headerTitle:"Create",headerSubtitle:"Press to rename",onHeaderPressed:()=>this._showRenameGraphDialog(),footerIcon:"Plus",footerTitle:"Create",footerSubtitle:"Graph or Function",onFooterPressed:e=>this._onSidebarCreate(e)}),this.area=new Xe({className:"lexgraph"}),e.root.classList.add("grapharea"),this.root=this.area.root,this.root.tabIndex=-1,e.attach(this.root),this._graphContainer=e.sections[1].root,this._sidebarDom=e.sections[0].root,this._sidebarActive=s.sidebar??this._sidebarActive,t.doAsync(()=>{this._sidebar.toggleCollapsed(!this._sidebarActive)},50),e.onresize=e=>{},e.addOverlayButtons([[{name:"Start Graph",icon:"Play@solid",callback:()=>this.start(),selectable:!0},{name:"Stop Graph",icon:"Stop@solid",callback:()=>this.stop(),selectable:!0}],[{name:"Enable Snapping",icon:"Frame",callback:()=>this._toggleSnapping(),selectable:!0},{name:1,options:[1,2,3],callback:e=>this._setSnappingValue(e)}],[{name:"Import",icon:"Upload",callback:()=>{this.loadGraph("../../data/graph_sample.json")}},{name:"Export",icon:"ArrowRightFromLine",callback:()=>this.currentGraph?.export()}]],{float:"htc"}),this.root.addEventListener("keydown",this._processKeyDown.bind(this),!0),this.root.addEventListener("keyup",this._processKeyUp.bind(this),!0),this.root.addEventListener("mousedown",this._processMouse.bind(this)),this.root.addEventListener("mouseup",this._processMouse.bind(this)),this.root.addEventListener("mousemove",this._processMouse.bind(this)),this.root.addEventListener("mousewheel",this._processMouse.bind(this)),this.root.addEventListener("mouseleave",this._processMouse.bind(this)),this.root.addEventListener("click",this._processMouse.bind(this)),this.root.addEventListener("contextmenu",this._processMouse.bind(this)),this.root.addEventListener("focus",this._processFocus.bind(this,!0)),this.root.addEventListener("focusout",this._processFocus.bind(this,!1)),this.propertiesDialog=new je("Properties",null,{size:["350px",null],position:["8px","8px"],float:"left",class:"lexgraphpropdialog"}),this.propertiesDialog.root.addEventListener("mousedown",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),this.propertiesDialog.root.addEventListener("mouseup",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),this.root.appendChild(this.propertiesDialog.root),this.addCastType("float","vec2",e=>[e,e]),this.addCastType("float","vec3",e=>[e,e,e]),this.addCastType("float","vec4",e=>[e,e,e,e]),this.addCastType("float","bool",e=>!!e),this.addCastType("vec4","vec3",e=>(e.slice(0,3),e)),this.addCastType("vec4","vec2",e=>(e.slice(0,2),e)),this.addCastType("vec3","vec2",e=>(e.slice(0,2),e)),this.addCastType("vec3","vec4",e=>(e.push(1),e)),this.addCastType("vec2","vec3",e=>(e.push(1),e)),this.addCastType("vec2","vec4",e=>(e.push(0,1),e)),this._nodeBackgroundOpacity=s.disableNodeOpacity?1:this._nodeBackgroundOpacity,this._generatePattern(),this._domLinks=document.createElement("div"),this._domLinks.classList.add("lexgraphlinks"),this.root.appendChild(this._domLinks),this._domNodes=document.createElement("div"),this._domNodes.classList.add("lexgraphnodes"),this.root.appendChild(this._domNodes),qe.ge=this}static getInstances(){return Je.__instances}static registerCustomNode(e,t){if(!t.prototype)throw"Cannot register a simple object, it must be a class with a prototype!";const s=e.lastIndexOf("/");t.category=e.substring(0,s),t.title=t.title??e.substring(s+1),t.type=e,t.prototype.onExecute||console.warn(`GraphNode [${t.title}] does not have a callback attached.`);const i=Je.NODE_TYPES[e];i&&console.warn(`Replacing node type [${e}]`),Je.NODE_TYPES[e]=t,Je.onCustomNodeRegistered&&Je.onCustomNodeRegistered(e,t),i&&Je.onNodeTypeReplaced&&Je.onNodeTypeReplaced(e,t,i)}static addNode(e,t,s={}){var i=Je.NODE_TYPES[e];if(!i)return console.warn(`GraphNode type [${e}] not registered.`),null;const o=new i(t=t??i.title);if(o.onCreate&&o.onCreate(),o.type=e,o.title=t,o.position=new Ye(0,0),o.color=null,"NodeFunction"==i.name&&(o.gid=i.gid),s)for(var n in s)o[n]=s[n];return o.onNodeCreated&&o.onNodeCreated(),o}setGraph(e){if(!this.currentGraph||e.id!=this.currentGraph.id)if(this.clear(),e.id=e.id??e.constructor.name+"-"+t.guidGenerator(),this.graphs[e.id]=e,e.nodes){this.currentGraph=e,this._updatePattern();for(let t of e.nodes)this._createNodeDOM(t);for(let t of e.groups){const e=this._createGroup(t);e.querySelector(".lexgraphgrouptitle").value=t.name,this._domNodes.prepend(e)}for(let t in e.links){const s=e.links[t];for(let e of s)this._createLink(e)}this._updateGraphName(e.name),this._togglePropertiesDialog(!1)}else console.warn("Graph does not contain any node!")}loadGraph(e,s){t.requestJSON(e,e=>{let t="Graph"==e.type?this.addGraph(e):this.addGraphFunction(e);s&&s(t)},e=>console.error(e))}addGraph(e){let t=new Qe;if(t.editor=this,e){for(let t of e.functions??[])this.addGraphFunction(t);t.configure(e)}return this.setGraph(t),this._sidebar.add(t.name,{icon:"CircleNodes",className:t.id,callback:()=>{this.setGraph(t)}}),this._sidebar.update(),this._sidebar.select(t.name),t}addGraphFunction(e){let t=new tt;if(t.editor=this,e){for(let t of e.functions??[])this.addGraphFunction(t);t.configure(e)}this.setGraph(t);class s extends et{static func;static gid;onCreate(){this.addInput(null,"float"),this.addOutput(null,"any")}onExecute(){const e=s.func.getOutputData(this.getInput(0));this.setOutput(0,e)}}return s.func=t,s.gid=t.id,Je.registerCustomNode("function/"+t.name,s),this._sidebar.add(t.name,{icon:"Function",className:t.id,callback:()=>{this.setGraph(t)}}),this._sidebar.update(),this._sidebar.select(t.name),t}clear(){this._domNodes.innerHTML="",this._domLinks.innerHTML="",this.nodes={}}setVariable(e,t){this.variables[e]=t}getVariable(e){return this.variables[e]}propagateEventToAllNodes(e,t){if(!this.currentGraph)return;const s=this.currentGraph.nodes;for(let i of s)i[e]&&i[e].apply(this,t)}addCastType(e,t,s){this.supportedCastTypes[e+"@"+t]=s}unSelectAll(e=!1){this._domNodes.querySelectorAll(".lexgraphnode").forEach(e=>e.classList.remove("selected")),this.selectedNodes.length=0,e||this._togglePropertiesDialog(!1)}_createNodeDOM(e){e.editor=this,e.graphID=this.currentGraph?.id;var s,i=document.createElement("div");if(i.classList.add("lexgraphnode"),i.style.left="0",i.style.top="0",this._translateNode(i,e.position),e.type&&Je.NODE_TYPES[e.type]){const t=e.constructor.category;i.classList.add(t)}else{const t=e.type.lastIndexOf("/"),s=e.type.substring(0,t);i.classList.add(s)}(s=e.color??s)&&(s.constructor==Array?s=s.join(","):(s=t.hexToRgb(s)).forEach((e,t)=>s[t]=255*e),i.style.backgroundColor="rgba("+s+", "+this._nodeBackgroundOpacity+")"),i.addEventListener("mousedown",e=>{e.button==t.MOUSE_LEFT_CLICK&&(e.altKey?this._unSelectNode(i):(this.selectedNodes.length>1&&!e.ctrlKey&&!e.shiftKey&&this.unSelectAll(!0),i.classList.contains("selected")||this._selectNode(i,e.ctrlKey||e.shiftKey)))}),i.addEventListener("contextmenu",s=>{s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),t.addContextMenu(null,s,t=>{t.add("Copy",()=>{this._clipboardData={id:e.id,gid:this.currentGraph?.id}}),t.add(""),t.add("Delete",()=>{this._deleteNode(i.dataset.id)})})}),i.addEventListener("dblclick",s=>{s.button==t.MOUSE_LEFT_CLICK&&e.constructor.func&&this._sidebar.select(e.constructor.func.name)});var o=document.createElement("div");o.classList.add("lexgraphnodeheader"),o.innerText=e.title,i.appendChild(o);var n=document.createElement("div");n.classList.add("lexgraphnodeios"),i.appendChild(n);const a=e.inputs&&e.inputs.length,l=e.outputs&&e.outputs.length;if(a){const t=document.createElement("div");t.classList.add("lexgraphnodeinputs"),t.style.width=l?"50%":"100%",n.appendChild(t);for(let s of e.inputs)if(s.type){var r=document.createElement("div");if(r.className="lexgraphnodeio ioinput",r.dataset.index=t.childElementCount.toString(),(h=document.createElement("span")).className="io__type input "+s.type,h.dataset.type=s.type,h.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",r.appendChild(h),(d=document.createElement("span")).className="io__typedesc input "+s.type,d.innerHTML=s.type,r.appendChild(d),s.name)(c=document.createElement("span")).classList.add("io__name"),c.innerText=s.name,r.appendChild(c);t.appendChild(r)}else console.warn(`Missing type for node [${e.title}], skipping...`)}if(l){const t=document.createElement("div");t.classList.add("lexgraphnodeoutputs"),t.style.width=a?"50%":"100%",n.appendChild(t);for(let s of e.outputs){s.type||console.warn(`Missing type for node [${e.title}], skipping...`);var c,h,d,u=document.createElement("div");if(u.className="lexgraphnodeio iooutput",u.dataset.index=t.childElementCount.toString(),s.name)(c=document.createElement("span")).classList.add("io__name"),c.innerText=s.name,u.appendChild(c);(h=document.createElement("span")).className="io__type output "+s.type,h.dataset.type=s.type,h.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",u.appendChild(h),(d=document.createElement("span")).className="io__typedesc output "+s.type,d.innerHTML=s.type,u.appendChild(d),t.appendChild(u)}}t.makeDraggable(i,{onMove:this._onMoveNodes.bind(this),onDragStart:this._onDragNode.bind(this)}),this._addNodeIOEvents(i);const p=e.id??e.title.toLowerCase().replaceAll(/\s/g,"-")+"-"+t.guidGenerator();return this.nodes[p]={data:e,dom:i},e.id=p,i.dataset.id=p,this._domNodes.appendChild(i),"Main"==e.title&&(this.main=p),e.size=new Ye(i.offsetWidth,i.offsetHeight),e.resizeObserver=new ResizeObserver(t=>{for(const s of t){const t=s.contentRect;t.width&&t.height&&(e.size=new Ye(i.offsetWidth,i.offsetHeight))}}),e.resizeObserver.observe(i),i}_updateNodeDOMIOs(e,t){var s=e.querySelector(".lexgraphnodeios");const i=t.inputs&&t.inputs.length,o=t.outputs&&t.outputs.length;if(i){const e=s?.querySelector(".lexgraphnodeinputs");e.innerHTML="";for(let s of t.inputs)if(s.type){var n=document.createElement("div");if(n.className="lexgraphnodeio ioinput",n.dataset.index=e.childElementCount.toString(),(l=document.createElement("span")).className="io__type input "+s.type,l.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",n.appendChild(l),(r=document.createElement("span")).className="io__typedesc input "+s.type,r.innerHTML=s.type,n.appendChild(r),s.name)(a=document.createElement("span")).classList.add("io__name"),a.innerText=s.name,n.appendChild(a);e.appendChild(n)}else console.warn(`Missing type for node [${t.constructor.name}], skipping...`)}if(o){const e=s?.querySelector(".lexgraphnodeoutputs");e.innerHTML="";for(let s of t.outputs){s.type||console.warn(`Missing type for node [${t.constructor.name}], skipping...`);var a,l,r,c=document.createElement("div");if(c.className="lexgraphnodeio iooutput",c.dataset.index=e.childElementCount.toString(),s.name)(a=document.createElement("span")).classList.add("io__name"),a.innerText=s.name,c.appendChild(a);(l=document.createElement("span")).className="io__type output "+s.type,l.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",c.appendChild(l),(r=document.createElement("span")).className="io__typedesc output "+s.type,r.innerHTML=s.type,c.appendChild(r),e.appendChild(c)}}this._addNodeIOEvents(e)}_addNodeIOEvents(e){const s=e.querySelector(".lexgraphnodeios");s?.querySelectorAll(".lexgraphnodeio").forEach(s=>{s.addEventListener("mousedown",i=>{i.button==t.MOUSE_LEFT_CLICK&&(this._lastMouseDown=t.getTime(),this._generatingLink={index:parseInt(s.dataset.index),io:s,ioType:s.classList.contains("ioinput")?Je.NODE_IO_INPUT:Je.NODE_IO_OUTPUT,domEl:e},i.stopPropagation(),i.stopImmediatePropagation())}),s.addEventListener("mouseup",e=>{e.stopPropagation(),e.stopImmediatePropagation(),t.getTime()-this._lastMouseDown<200?delete this._generatingLink:this._generatingLink&&(this._onLink(e)||t.deleteElement(this._generatingLink.path?this._generatingLink.path.parentElement:null),delete this._generatingLink)}),s.addEventListener("click",t=>{if(!s.links)return;const i=e.dataset.id;this._deleteLinks(i,s)})})}_getAllDOMNodes(e=!1,t){var s=null;return s=e?Array.from(this._domNodes.childNodes):Array.from(this._domNodes.childNodes).filter(e=>e.classList.contains("lexgraphnode")),t&&(s=s.filter(e=>e!=t)),s}_onMoveNodes(e){let t=this._snapToGrid?this._snappedDeltaMousePosition:this._deltaMousePosition;t.div(this.currentGraph?.scale,t);for(let e of this.selectedNodes){const s=this._getNodeDOMElement(e);this._translateNode(s,t),this._updateNodeLinks(e)}}_onDragNode(e,t){t.shiftKey&&this._cloneNodes()}_onMoveGroup(e){const t=e.nodes;if(!t)return;let s=this._snapToGrid?this._snappedDeltaMousePosition:this._deltaMousePosition;s.div(this.currentGraph?.scale,s),this._translateNode(e,s);for(let e of t){const t=e.constructor!==String,i=t?e:this._getNodeDOMElement(e);this._translateNode(i,s,!t),t||this._updateNodeLinks(e)}}_onDragGroup(e){const t=this._getBoundingFromGroup(e),s=[];for(let i of this._getAllDOMNodes(!0,e)){const e=parseFloat(i.style.left),o=parseFloat(i.style.top),n=new Ze(new Ye(e,o),new Ye(i.offsetWidth-6,i.offsetHeight-6));t.inside(n)&&s.push(i.dataset.id??i)}e.nodes=s}_selectNode(e,t=!1,s=!0){t||this.unSelectAll(!0),e.classList.add("selected");const i=e.dataset.id;this.selectedNodes.push(i),s&&this._domNodes.appendChild(e);const o=this.nodes[i].data;this.propertiesDialog.setTitle(o.title);var n=this.propertiesDialog.panel;n.clear(),o.constructor.description&&n.addText(null,o.constructor.description,null,{disabled:!0}),"inputs"==o.constructor.category&&n.addText("Name",o.title,t=>{o.title=t;e.querySelector(".lexgraphnodeheader").innerText=t});for(let t of o.properties)switch(t.type){case"float":case"int":n.addNumber(t.name,t.value,e=>{t.value=e});break;case"string":n.addText(t.name,t.value,e=>{t.value=e});break;case"vec2":n.addVector2(t.name,t.value,e=>{t.value=e});break;case"vec3":n.addVector3(t.name,t.value,e=>{t.value=e});break;case"vec4":n.addVector4(t.name,t.value,e=>{t.value=e});break;case"select":n.addSelect(t.name,t.options,t.value,e=>{t.value=e});break;case"array":n.addArray(t.name,t.value,s=>{t.value=s,"function/Input"==o.type&&(o.setOutputs(s),this._updateNodeDOMIOs(e,o))},{innerValues:t.options})}this._togglePropertiesDialog(!0)}_unSelectNode(e){e.classList.remove("selected");const t=this.selectedNodes.indexOf(e.dataset.id);this.selectedNodes.splice(t,1),this.selectedNodes.length||this._togglePropertiesDialog(!1)}_translateNode(e,t,s=!0){const i=t.add(new Ye(parseFloat(e.style.left),parseFloat(e.style.top)));if(this._snapToGrid&&e.mustSnap){const t=this._patternSize.x*this._snapValue*this._snapValue;i.x=Math.floor(i.x/t)*t,i.y=Math.floor(i.y/t)*t,e.mustSnap=!1}if(e.style.left=i.x+"px",e.style.top=i.y+"px",s&&e.dataset.id){this.nodes[e.dataset.id].data.position=i}}_deleteNode(e){if(!this.currentGraph)return;const s=this.nodes[e],i=s.data,o=s.dom;if(console.assert(o),i.constructor.blockDelete)return void console.warn("Can't delete node!");t.deleteElement(o),delete this.nodes[e];const n=this.currentGraph.nodes.findIndex(t=>t.id===e);console.assert(n>=0),this.currentGraph.nodes.splice(n,1);for(let s in this.currentGraph.links){if(!s.includes(e))continue;const i=s.indexOf("@"),o=s.substring(i+1)!=e,n=this.currentGraph.links[s].length;for(var a=0;a<n;++a){var l=this.currentGraph.links[s][a];t.deleteElement(l.path.parentElement);const i=o?l.inputNode:l.outputNode,n=this._getNodeDOMElement(i).querySelector(o?".lexgraphnodeinputs":".lexgraphnodeoutputs").childNodes[o?l.inputIdx:l.outputIdx],d=o?l.outputIdx:l.inputIdx,u=n.links[d].indexOf(e);if(n.links[d].splice(u,1),o)delete n.dataset.active;else{var r=!1;for(var c of n.links)if(c)for(var h of c)r=r||!!h;r||delete n.dataset.active}}delete this.currentGraph.links[s]}}_deleteGroup(e){if(!this.currentGraph)return;const s=this.groups[e];t.deleteElement(s),delete this.groups[e];const i=this.currentGraph.groups.findIndex(t=>t.id===e);console.assert(i>=0),this.currentGraph.groups.splice(i,1)}_cloneNode(e,s,i){if(!this.currentGraph)return;const o=this.graphs[s??this.currentGraph.id].getNodeById(e);if(!o)return;const n=this._getNodeDOMElement(e),a=Je.addNode(o.type);a.properties=t.deepCopy(o.properties);const l=this._createNodeDOM(a);this._translateNode(l,i??this._getNodePosition(n)),this._selectNode(l,!0),this.currentGraph.nodes.push(a)}_cloneNodes(){const e=t.deepCopy(this.selectedNodes);this.unSelectAll();for(let t of e)this._cloneNode(t)}_getNodePosition(e){return new Ye(parseFloat(e.style.left),parseFloat(e.style.top))}_getNodeDOMElement(e){return this.nodes[e]?this.nodes[e].dom:null}_getLinks(e,t){const s=e+"@"+t;return this.currentGraph?.links[s]}_deleteLinks(e,s){const i=s.classList.contains("ioinput"),o=parseInt(s.dataset.index);if(i){let i=-1;const r=s.links.filter((e,t)=>(i=t,void 0!==e))[0][0];if(!r)return;var n=(l=this._getLinks(r,e)).findIndex(e=>e.inputIdx==o&&e.outputIdx==i);t.deleteElement(l[n].path.parentElement),l.splice(n,1),delete s.links,delete s.dataset.active;const c=this._getNodeDOMElement(r).querySelector(".lexgraphnodeoutputs").childNodes[i],h=c.links[o].findIndex(t=>t==e);c.links[o].splice(h,1);let d=!1;for(var a of c.links)a&&(d=d||a.reduce(e=>void 0!==e,0));d||(delete c.links,delete c.dataset.active)}else{const i=s.links.length;for(let a=0;a<i;++a){const i=s.links[a];if(i)for(let r=i.length-1;r>=0;--r){const c=i[r];var l;n=(l=this._getLinks(e,c)).findIndex(e=>e.inputIdx==a&&e.outputIdx==o);t.deleteElement(l[n].path.parentElement),l.splice(n,1),s.links[a].splice(r,1);const h=this._getNodeDOMElement(c).querySelector(".lexgraphnodeinputs").childNodes[a];delete h.links,delete h.dataset.active}}delete s.links,delete s.dataset.active}}_processFocus(e=!1){this.isFocused=e}_processKeyDown(e){if(document.activeElement!=this.root)return;const t=e.detail;var s=e.key??t.key;switch(s){case"Escape":this.unSelectAll();break;case"Delete":case"Backspace":e.preventDefault(),this._deleteSelection(e);break;case"g":e.ctrlKey&&(e.preventDefault(),this._createGroup());break;case"y":e.ctrlKey&&(e.preventDefault(),this._doRedo());break;case"z":e.ctrlKey&&(e.preventDefault(),this._doUndo())}this.keys[s]=!0}_processKeyUp(e){if(document.activeElement!=this.root)return;const t=e.detail,s=e.key??t.key;delete this.keys[s]}_processMouse(e){if(!this.currentGraph)return;const s=this.root.getBoundingClientRect();this._mousePosition=new Ye(e.clientX-s.x,e.clientY-s.y);const i=new Ye(this._mousePosition.x,this._mousePosition.y);if(this._snapToGrid){const e=this._patternSize.x*this._snapValue*this.currentGraph.scale;i.x=Math.floor(i.x/e)*e,i.y=Math.floor(i.y/e)*e,this._snappedDeltaMousePosition=i.sub(this._lastSnappedMousePosition)}if(this._deltaMousePosition=this._mousePosition.sub(this._lastMousePosition),"mousedown"==e.type)this._lastMouseDown=t.getTime(),this._processMouseDown(e);else if("mouseup"==e.type)t.getTime()-this._lastMouseDown<200&&this._processClick(e),this._processMouseUp(e);else if("mousemove"==e.type)this._processMouseMove(e);else if("click"==e.type)switch(e.detail){case t.MOUSE_DOUBLE_CLICK:case t.MOUSE_TRIPLE_CLICK:}else"mousewheel"==e.type?(e.preventDefault(),this._processWheel(e)):"contextmenu"==e.type?(e.preventDefault(),t.getTime()-this._lastMouseDown<300&&this._processContextMenu(e)):"mouseleave"==e.type&&this._generatingLink&&this._processMouseUp(e);this._snapToGrid&&(this._lastSnappedMousePosition=i),this._lastMousePosition=this._mousePosition}_processClick(e){const t=e.target;(t.classList.contains("lexgraphnodes")||t.classList.contains("lexgraphgroup"))&&this._processBackgroundClick(e)}_processBackgroundClick(e){this.unSelectAll()}_processMouseDown(e){const s=e.target;s.classList.contains("lexgraphnode")||s.classList.contains("lexgraphgroup")||e.button!=t.MOUSE_LEFT_CLICK||(this._boxSelecting=this._mousePosition,this._boxSelectRemoving=e.altKey)}_processMouseUp(e){if(this._generatingLink){const s=Object.assign({},this._generatingLink);t.deleteElement(this._generatingLink.path?this._generatingLink.path.parentElement:null),delete this._generatingLink,this._processContextMenu(e,s)}else this._boxSelecting&&(e.ctrlKey||e.altKey||this.unSelectAll(),this._selectNodesInBox(this._boxSelecting,this._mousePosition,e.altKey),t.deleteElement(this._currentBoxSelectionSVG),delete this._currentBoxSelectionSVG,delete this._boxSelecting,delete this._boxSelectRemoving)}_processMouseMove(e){if(!this.currentGraph)return;if(3==e.which)return this.currentGraph.translation.add(this._deltaMousePosition.div(this.currentGraph.scale),this.currentGraph.translation),void this._updatePattern();this._generatingLink?this._updatePreviewLink(e):this._boxSelecting&&this._drawBoxSelection(e)}_processWheel(e){if(this._boxSelecting||!this.currentGraph)return;const s=this.root.getBoundingClientRect(),i=this._mousePosition??new Ye(.5*s.width,.5*s.height),o=this._getPatternPosition(i),n=e.deltaY;this.currentGraph.scale*=n>0?.9:1/.9,this.currentGraph.scale=t.clamp(this.currentGraph.scale,Je.MIN_SCALE,Je.MAX_SCALE);const a=this._getPatternPosition(i).sub(o);this.currentGraph.translation.add(a,this.currentGraph.translation),this._updatePattern()}_processContextMenu(e,s){this.currentGraph&&t.addContextMenu(null,e,t=>{var i=null;if(e){const t=this.root.getBoundingClientRect(),s=new Ye(e.clientX-t.x,e.clientY-t.y);i=this._getPatternPosition(s)}this._clipboardData&&(t.add("Paste",()=>{const e=this._clipboardData.id,t=this._clipboardData.gid;this._cloneNode(e,t,i)}),t.add(""));for(let e in Je.NODE_TYPES){Je.NODE_TYPES[e].blockAdd||t.add(e,()=>{const t=Je.addNode(e),o=this._createNodeDOM(t);if(this._snapToGrid&&(o.mustSnap=!0),i&&this._translateNode(o,i),this.currentGraph?.nodes.push(t),s&&t.inputs.length){const e=s.domEl.dataset.id,i=s.io.childNodes[s.index].dataset.type,o=s.ioType==Je.NODE_IO_INPUT,n={inputNode:o?e:t.id,inputIdx:o?s.index:0,inputType:o?i:t.inputs[0].type,outputNode:o?t.id:e,outputIdx:o?0:s.index,outputType:o?t.inputs[0].type:i},a=n.outputNode+"@"+n.inputNode;this.currentGraph?.links[a]||(this.currentGraph.links[a]=[]),this.currentGraph?.links[a].push(n),this._createLink(n)}})}})}start(){this.mustStop=!1,this.state=Je.RUNNING,this.propagateEventToAllNodes("onStart"),requestAnimationFrame(this._frame.bind(this))}stop(){this.mustStop=!0,this.state=Je.STOPPED,this.propagateEventToAllNodes("onStop")}_frame(){!this.mustStop&&this.currentGraph&&(requestAnimationFrame(this._frame.bind(this)),this.currentGraph._runStep(this.main))}_generatePattern(){var e=document.createElementNS("http://www.w3.org/2000/svg","pattern");e.setAttribute("id","pattern-0"),e.setAttribute("x","0"),e.setAttribute("y","0"),e.setAttribute("width",this._patternSize.x.toString()),e.setAttribute("height",this._patternSize.y.toString()),e.setAttribute("patternUnits","userSpaceOnUse");var t=document.createElementNS("http://www.w3.org/2000/svg","circle");t.setAttribute("cx",this._circlePatternSize.toString()),t.setAttribute("cy",this._circlePatternSize.toString()),t.setAttribute("r",this._circlePatternSize.toString()),t.setAttribute("fill",this._circlePatternColor),e.appendChild(t);var s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.classList.add("background-svg"),s.style.width="100%",s.style.height="100%",s.style.stroke="none",s.appendChild(e);var i=document.createElementNS("http://www.w3.org/2000/svg","rect");i.setAttribute("x","0"),i.setAttribute("y","0"),i.setAttribute("width","100%"),i.setAttribute("height","100%"),i.setAttribute("fill","url(#pattern-0)"),s.appendChild(i),this._background=s,this.root.appendChild(this._background)}_updatePattern(){if(!this._background||!this.currentGraph)return;const e=this._patternSize.mul(this.currentGraph.scale),t=this._circlePatternSize*this.currentGraph.scale,s=this.currentGraph.translation.mul(this.currentGraph.scale);let i=this._background.querySelector("pattern");i.setAttribute("x",s.x.toString()),i.setAttribute("y",s.y.toString()),i.setAttribute("width",e.x.toString()),i.setAttribute("height",e.y.toString());var o=this._background.querySelector("circle");o.setAttribute("cx",t.toString()),o.setAttribute("cy",t.toString()),o.setAttribute("r",t.toString());const n=.5*this._domNodes.offsetWidth,a=.5*this._domNodes.offsetHeight,l=n-n*this.currentGraph.scale,r=a-a*this.currentGraph.scale;this._domNodes.style.transform="\n translate("+(s.x-l)+"px, "+(s.y-r)+"px)\n scale("+this.currentGraph.scale+")\n ",this._domLinks.style.transform=this._domNodes.style.transform;const c=this._getNonVisibleNodes();for(let e of c){this._getNodeDOMElement(e.id).classList.toggle("hidden-opacity",!0)}}_getPatternPosition(e){if(this.currentGraph)return e.div(this.currentGraph.scale).sub(this.currentGraph.translation)}_getRenderPosition(e){if(this.currentGraph)return e.add(this.currentGraph.translation).mul(this.currentGraph.scale)}_onLink(e){if(!this.currentGraph)return;const t=this._generatingLink,s=e.target.classList.contains("input")?Je.NODE_IO_INPUT:Je.NODE_IO_OUTPUT;if(t.ioType==s)return void console.warn("Can't link same type of data");const i=t.domEl.dataset.id,o=this.nodes[i].data,n=this._generatingLink.index,a=e.target.offsetParent.dataset.id,l=this.nodes[a].data,r=parseInt(e.target.parentElement.dataset.index),c=t.ioType==Je.NODE_IO_INPUT,h=o[c?"inputs":"outputs"][n].type,d=l[s==Je.NODE_IO_INPUT?"inputs":"outputs"][r].type;if(h!=d&&"any"!=h&&"any"!=d){const e=c?h:d,t=c?d:h;if(!this.supportedCastTypes[t+"@"+e])return void console.warn(`Can't link ${h} to ${d}.`)}s==Je.NODE_IO_INPUT&&e.target.parentElement.dataset.active?this._deleteLinks(a,e.target.parentElement):t.ioType==Je.NODE_IO_INPUT&&t.io.dataset.active&&this._deleteLinks(i,t.io);var u=t.io;u.links=u.links??[],u.links[r]=u.links[r]??[],u.links[r].push(a);var p=e.target.parentElement;p.links=p.links??[],p.links[n]=p.links[n]??[],p.links[n].push(i);let m=this._updatePreviewLink(null,e.target.parentElement);const g=(c?a:i)+"@"+(c?i:a);return this.currentGraph.links[g]||(this.currentGraph.links[g]=[]),this.currentGraph.links[g].push({path:m,inputNode:c?i:a,inputIdx:c?n:r,inputType:c?h:d,outputNode:c?a:i,outputIdx:c?r:n,outputType:c?d:h}),m.dataset.id=g,t.io.dataset.active=!0,e.target.parentElement.dataset.active=!0,!0}_updatePreviewLink(e,s){var i=this._generatingLink.path;if(!i){var o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.classList.add("link-svg"),o.style.width="100%",o.style.height="100%",this._domLinks.appendChild(o),(i=document.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("fill","none"),o.appendChild(i),this._generatingLink.path=i}const n=this._generatingLink.index,a=this._generatingLink.ioType,l=this._generatingLink.domEl,r=this.root.getBoundingClientRect().x,c=this.root.getBoundingClientRect().y,h=l.querySelector(a==Je.NODE_IO_INPUT?".lexgraphnodeinputs":".lexgraphnodeoutputs").childNodes[n].querySelector(".io__type"),d=h.getBoundingClientRect();let u=new Ye(d.x-r,d.y-c),p=null,m=null;if(e){if(p=new Ye(e.offsetX,e.offsetY),t.hasClass(e.target,["lexgraphnode","lexgraphgroup"]))p.add(this._getNodePosition(e.target),p),p.add(new Ye(3,3),p);else if(t.hasClass(e.target,["io__type","lexgraphgroupresizer"])){var g=e.target.offsetParent;p.add(this._getNodePosition(g),p),p.add(new Ye(e.target.offsetLeft,e.target.offsetTop),p),p.add(new Ye(3,3),p)}p=this._getRenderPosition(p)}else{m=s.querySelector(".io__type");const e=m.getBoundingClientRect();p=new Ye(e.x-r,e.y-c)}if(a==Je.NODE_IO_INPUT){var f=p;p=u,u=f}let C=getComputedStyle(h).backgroundColor;return a==Je.NODE_IO_OUTPUT&&m&&(C=getComputedStyle(m).backgroundColor),this._createLinkPath(i,u,p,C,!!e),i}_createLink(e){var t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.classList.add("link-svg"),t.style.width="100%",t.style.height="100%",this._domLinks.appendChild(t);var s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("fill","none"),t.appendChild(s);const i=this._getNodeDOMElement(e.inputNode),o=this._getNodeDOMElement(e.outputNode),n=this.root.getBoundingClientRect().x,a=this.root.getBoundingClientRect().y,l=o.querySelector(".lexgraphnodeoutputs").childNodes[e.outputIdx],r=l.querySelector(".io__type").getBoundingClientRect();let c=new Ye(r.x-n,r.y-a+6);const h=i.querySelector(".lexgraphnodeinputs").childNodes[e.inputIdx],d=h.querySelector(".io__type").getBoundingClientRect();let u=new Ye(d.x-n,d.y-a+6);const p=getComputedStyle(h.querySelector(".io__type")).backgroundColor;this._createLinkPath(s,c,u,p),e.path=s,l.links=[],l.links[e.inputIdx]=l.links[e.inputIdx]??[],l.links[e.inputIdx].push(e.inputNode),h.links=[],h.links[e.outputIdx]=h.links[e.outputIdx]??[],h.links[e.outputIdx].push(e.outputNode),l.dataset.active=!0,h.dataset.active=!0}_createLinkPath(e,s,i,o,n=!1){if(!this.currentGraph)return;const a=6*this.currentGraph.scale;s.add(new Ye(a,a),s),n||i.add(new Ye(a,a),i),s=this._getPatternPosition(s),i=this._getPatternPosition(i);const l=t.clamp(Math.abs(s.x-i.x),0,256),r=128*Math.pow(l/256,.5);let c=s.add(new Ye(r,0)),h=i.sub(new Ye(r,0));e.setAttribute("d",`\n M ${s.x},${s.y}\n C ${c.x},${c.y} ${h.x},${h.y} ${i.x},${i.y}\n `),e.parentElement.style.color=o}_updateNodeLinks(e){if(!(this.nodes[e]?this.nodes[e].data:null))return void console.warn(`Can't finde node [${e}]`);const t=this._getNodeDOMElement(e);for(let i of t.querySelectorAll(".ioinput")){if(!i.links)continue;const o=i.links.filter(e=>void 0!==e)[0][0];if(!o)continue;const n=parseInt(i.dataset.index);var s=this._getLinks(o,e).find(e=>e.inputIdx==n);this._generatingLink={index:n,io:i,ioType:Je.NODE_IO_INPUT,domEl:t,path:s.path};const a=this._getNodeDOMElement(o).querySelector(".lexgraphnodeoutputs").childNodes[s.outputIdx];this._updatePreviewLink(null,a)}for(let i of t.querySelectorAll(".iooutput")){if(!i.links)continue;const o=parseInt(i.dataset.index);for(let n=0;n<i.links.length;++n){const a=i.links[n];if(a)for(let l of a){s=this._getLinks(e,l).find(e=>e.inputIdx==n&&e.outputIdx==o);this._generatingLink={index:s.outputIdx,io:i,ioType:Je.NODE_IO_OUTPUT,domEl:t,path:s.path};const a=this._getNodeDOMElement(l).querySelector(".lexgraphnodeinputs").childNodes[s.inputIdx];this._updatePreviewLink(null,a)}}}delete this._generatingLink}_drawBoxSelection(e){var t;(t=this._currentBoxSelectionSVG)||((t=document.createElementNS("http://www.w3.org/2000/svg","svg")).classList.add("box-selection-svg"),this._boxSelectRemoving&&t.classList.add("removing"),t.style.width="100%",t.style.height="100%",this._domLinks.appendChild(t),this._currentBoxSelectionSVG=t);let s=this._getPatternPosition(this._boxSelecting),i=this._getPatternPosition(this._mousePosition).sub(s);i.x<0&&(s.x+=i.x),i.y<0&&(s.y+=i.y),i=i.abs(),t.innerHTML=`<rect\n x="${s.x}" y="${s.y}"\n rx="6" ry="6"\n width="${i.x}" height="${i.y}"\n "/>`}_getNonVisibleNodes(){const e=[];if(!this.currentGraph)return console.warn("No graph set"),[];const t=new Ze(new Ye(0,0),new Ye(this.root.offsetWidth,this.root.offsetHeight));for(let s of this.currentGraph.nodes){let i=this._getRenderPosition(s.position),o=this._getNodeDOMElement(s.id);if(!o)continue;const n=new Ze(i,s.size.mul(this.currentGraph.scale));t.inside(n,!1)?(o.classList.toggle("hidden-opacity",!1),o.childNodes[1].classList.toggle("hidden-opacity",this.currentGraph.scale<.5)):e.push(s)}return e}_selectNodesInBox(e,t,s=!1){e=this._getPatternPosition(e);let i=(t=this._getPatternPosition(t)).sub(e);if(i.x<0){var o=e.x;e.x=t.x,t.x=o}if(i.y<0){o=e.y;e.y=t.y,t.y=o}const n=this._getAllDOMNodes();for(let i of n){let o=this._getNodePosition(i),n=new Ye(i.offsetWidth,i.offsetHeight);o.x<e.x&&o.x+n.x<e.x||o.x>t.x&&o.x+n.x>t.x||o.y<e.y&&o.y+n.y<e.y||o.y>t.y&&o.y+n.y>t.y||(s?this._unSelectNode(i):this._selectNode(i,!0,!1))}}_deleteSelection(e){const t=this._domNodes.childElementCount;for(let e of this.selectedNodes)this._deleteNode(e);this.selectedNodes.length=0,this._domNodes.childElementCount!=t&&this._addUndoStep()}_getBoundingFromGroup(e){const t=parseFloat(e.style.left),s=parseFloat(e.style.top);return new Ze(new Ye(t,s),new Ye(e.offsetWidth-2,e.offsetHeight-2))}_getBoundingFromNodes(e){let t=null;for(let s of e){const e=this.nodes[s].data,i=new Ze(e.position,e.size);t?t.merge(i):t=i}if(t){const e=8;t.origin.sub(new Ye(e),t.origin),t.origin.sub(new Ye(e),t.origin),t.size.add(new Ye(2*e),t.size),t.size.add(new Ye(2*e),t.size)}return t}_createGroup(e){const s=e??this._getBoundingFromNodes(this.selectedNodes);if(!s)return;const i=s.id??`group-${t.guidGenerator()}`;let o=document.createElement("div");o.id=i,o.classList.add("lexgraphgroup"),o.style.left=s.origin.x+"px",o.style.top=s.origin.y+"px",o.style.width=s.size.x+"px",o.style.height=s.size.y+"px";let n=document.createElement("div");n.classList.add("lexgraphgroupresizer"),n.addEventListener("mousedown",function(e){var t=a.root.ownerDocument;t.addEventListener("mousemove",r),t.addEventListener("mouseup",c),l[0]=e.x,l[1]=e.y,e.stopPropagation(),e.preventDefault(),document.body.classList.add("nocursor"),n.classList.add("nocursor")}),this.groups[i]=o;var a=this,l=[0,0];function r(e){let t=new Ye(l[0]-e.x,l[1]-e.y);t.div(a.currentGraph?.scale,t),o.style.width=parseFloat(o.style.width)-t.x+"px",o.style.height=parseFloat(o.style.height)-t.y+"px",l[0]=e.x,l[1]=e.y,e.stopPropagation(),e.preventDefault()}function c(e){var t=a.root.ownerDocument;t.removeEventListener("mousemove",r),t.removeEventListener("mouseup",c),document.body.classList.remove("nocursor"),n.classList.remove("nocursor")}let h=document.createElement("input"),d=`Group ${Je.LAST_GROUP_ID}`;return h.value=d,h.classList.add("lexgraphgrouptitle"),h.disabled=!0,h.addEventListener("mousedown",e=>{e.stopPropagation(),e.stopImmediatePropagation()}),h.addEventListener("focusout",e=>{h.disabled=!0,h.value.length||(h.value=d)}),h.addEventListener("keyup",e=>{"Enter"==e.key?h.blur():"Escape"==e.key&&(h.value="",h.blur())}),o.addEventListener("dblclick",e=>{e.button==t.MOUSE_LEFT_CLICK&&(h.disabled=!1,h.focus())}),o.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),t.addContextMenu(null,e,e=>{e.add("Delete",()=>{this._deleteGroup(i)})})}),o.appendChild(n),o.appendChild(h),this._domNodes.prepend(o),t.makeDraggable(o,{onMove:this._onMoveGroup.bind(this),onDragStart:this._onDragGroup.bind(this),updateLayers:!1}),Je.LAST_GROUP_ID++,o}_addUndoStep(e=!0){e&&(this._redoSteps.length=0),this._undoSteps.push({})}_doUndo(){this._undoSteps.length&&(this._addRedoStep(),this._undoSteps.pop(),console.log("Undo!!"))}_addRedoStep(){this._redoSteps.push({})}_doRedo(){this._redoSteps.length&&(this._addUndoStep(!1),this._redoSteps.pop(),console.log("Redo!!"))}_togglePropertiesDialog(e=!1){this.propertiesDialog.root.classList.toggle("opened",e),e||this.propertiesDialog.panel.clear()}_setSnappingValue(e){this._snapValue=e}_toggleSnapping(){if(this._snapToGrid=!this._snapToGrid,this._snapToGrid)for(let e of this._getAllDOMNodes(!0))e.mustSnap=!0}_onSidebarCreate(e){new t.DropdownMenu(e.target,[{name:"Create Graph",icon:"Workflow",callback:()=>this.addGraph()},{name:"Create Function",icon:"Function",callback:()=>this.addGraphFunction()}],{side:"right",align:"start"})}_showRenameGraphDialog(){if(!this.currentGraph)return;const e=new t.Dialog(this.currentGraph.constructor.name,t=>{t.addText("Name",this.currentGraph?.name,t=>{this._updateGraphName(t),e.close()})},{modal:!0,size:["350px",null]})}_updateGraphName(e){if(!this.currentGraph)return;const t=e.replace(/\s/g,"").replaceAll(".",""),s=this._sidebar.root.querySelectorAll(".lexsidebarheader span")[1];console.assert(s),s.innerText=e;const i=this._sidebar.items.find(e=>e.name===this.currentGraph?.name);if(i){const s=i.name;i.name=e,i.dom.id=t,i.dom.innerHTML=i.dom.innerHTML.replace(s,e)}const o="function/"+this.currentGraph.name,n=Je.NODE_TYPES[o];n&&(delete Je.NODE_TYPES[o],n.title=e,Je.registerCustomNode("function/"+e,n)),this.currentGraph.name=e}_addGlobalActions(){}}t.GraphEditor=Je;class Qe{name="Unnamed Graph";type="Graph";id="";editor;nodes=[];groups=[];variables={};links={};scale=1;translation=new Ye(0,0);_executionNodes=[];constructor(e,t={}){this.name=e??this.name}configure(e){this.id=e.id,this.name=e.name,this.nodes.length=0;for(let t of e.nodes){const e=Je.addNode(t.type);e.id=t.id,e.title=t.title,e.color=t.color,e.position=new Ye(t.position.x,t.position.y),e.type=t.type,e.properties=t.properties,this.nodes.push(e)}this.groups=e.groups,this.links=e.links}getNodeById(e){for(let t of this.nodes)if(t.id==e)return t}_runStep(e){if(!e)return;const t=this.nodes.reduce((e,t)=>({...e,[t.id]:t}),{});if(!t[e])return;const s={};this._executionNodes=[],this.variables={};const i=e=>{if(!s[e]){s[e]=!0;for(let t in this.links){const s=t.indexOf("@"+e);if(s<0)continue;const o=t.substring(0,s);this._executionNodes.push(o),i(o)}}};this._executionNodes.push(e),i(e);for(var o=this._executionNodes.length-1;o>=0;--o){const e=t[this._executionNodes[o]];e.onBeforeStep&&e.onBeforeStep(),e.execute(),e.onBeforeStep&&e.onAfterStep()}}serialize(e=!0){var s={};s.id=this.id,s.name=this.name,s.type=this.type,s.nodes=[],s.groups=[],s.functions=[],s.links={};for(let e of this.nodes){s.nodes.push(e.serialize());const t=this.editor?.graphs[e.gid];t&&s.functions.push(JSON.parse(t.serialize()))}for(let e in this.links){const i=t.deepCopy(this.links[e]);i.forEach(e=>delete e.path),s.links[e]=i}for(let e of this.groups){const t=this.editor?.groups[e.id],i=this.editor?._getBoundingFromGroup(t);i.id=e.id,i.name=e.name,s.groups.push(i)}try{s=JSON.stringify(s,void 0,e?2:void 0)}catch(e){s=null,console.error(`Can't export Graph [${this.name}] of type [${this.type}].`)}return s}export(){const e=this.serialize();t.downloadFile(this.name+".json",e)}}t.Graph=Qe;class et{static title;static blockDelete=!1;static blockAdd=!1;static description="";id="";type="";title="";inputs=[];outputs=[];properties=[];position=new Ye(0,0);size=new Ye(0,0);color;editor;graphID;constructor(){}_hasOutputsConnected(){return!0}onExecute(){}execute(){this._hasOutputsConnected()&&this.onExecute&&this.onExecute()}addInput(e,t){this.inputs.push({name:e,type:t})}addOutput(e,t){this.outputs.push({name:e,type:t})}addProperty(e,t,s,i){this.properties.push({name:e,type:t,value:s,options:i})}getInput(e){if(!this.inputs||!this.inputs.length||!this.inputs[e])return;const t=this.editor?.graphs[this.graphID];for(let i in t.links){if(i.indexOf("@"+this.id)<0)continue;const o=t.links[i];for(var s of o)if(s.inputIdx==e)return s.data}}setOutput(e,s){if(!this.outputs||!this.outputs.length||!this.outputs[e])return;const i=this.editor?.graphs[this.graphID];for(let a in i.links){if(a.indexOf(this.id+"@")<0)continue;const l=i.links[a];for(var o of l){if(o.outputIdx!=e)continue;let i=s;if(null!=i&&o.inputType!=o.outputType&&"any"!=o.inputType&&"any"!=o.outputType){var n=this.editor?.supportedCastTypes[o.outputType+"@"+o.inputType];i=n?n(t.deepCopy(i)):null}o.data=i}}}serialize(){var e={};return e.id=this.id,e.title=this.title,e.color=this.color,e.position=this.position,e.type=this.type,e.inputs=this.inputs,e.outputs=this.outputs,e.properties=this.properties,e}}t.GraphNode=et;class tt extends Qe{constructor(e,t={}){super(),this.name=e??"GraphFunction"+Je.LAST_FUNCTION_ID,this.type="GraphFunction",Je.LAST_FUNCTION_ID++;const s=Je.addNode("function/Input");s.position=new Ye(150,250);const i=Je.addNode("function/Output");i.position=new Ye(650,350),this.nodes.push(s,i)}getOutputData(e){this.nodes[0].setOutput(0,e);const t=this.nodes[1];return this._runStep(t.id),t.getInput(0)}}t.GraphFunction=tt;class st extends et{onCreate(){this.addOutput(null,"float"),this.addProperty("Outputs","array",["float"],["float","int","bool","vec2","vec3","vec4","mat44"])}onExecute(){}setOutputs(e){for(var t of(this.outputs.length=0,e))this.outputs.push({name:null,type:t})}}st.blockDelete=!0,st.blockAdd=!0,Je.registerCustomNode("function/Input",st);class it extends et{onCreate(){this.addInput(null,"any")}onExecute(){}}it.blockDelete=!0,it.blockAdd=!0,Je.registerCustomNode("function/Output",it);class ot extends et{onCreate(){this.addInput(null,"float"),this.addInput(null,"float"),this.addOutput(null,"float"),this.addProperty("A","float",0),this.addProperty("B","float",0)}onExecute(){var e=this.getInput(0)??this.properties[0].value,t=this.getInput(1)??this.properties[1].value;this.setOutput(0,e+t)}}ot.description="Addition of 2 values (A+B).",Je.registerCustomNode("math/Add",ot);class nt extends et{onCreate(){this.addInput(null,"float"),this.addInput(null,"float"),this.addOutput(null,"float"),this.addProperty("A","float",0),this.addProperty("B","float",0)}onExecute(){var e=this.getInput(0)??this.properties[0].value,t=this.getInput(1)??this.properties[1].value;this.setOutput(0,e-t)}}nt.description="Substraction of 2 values (A-B).",Je.registerCustomNode("math/Substract",nt);class at extends et{onCreate(){this.addInput(null,"float"),this.addInput(null,"float"),this.addOutput(null,"float"),this.addProperty("A","float",0),this.addProperty("B","float",0)}onExecute(){var e=this.getInput(0)??this.properties[0].value,t=this.getInput(1)??this.properties[1].value;this.setOutput(0,e*t)}}at.description="Multiplication of 2 values (A*B).",Je.registerCustomNode("math/Multiply",at);class lt extends et{onCreate(){this.addInput(null,"float"),this.addInput(null,"float"),this.addOutput(null,"float"),this.addProperty("A","float",0),this.addProperty("B","float",0)}onExecute(){var e=this.getInput(0)??this.properties[0].value,t=this.getInput(1)??this.properties[1].value;this.setOutput(0,e/t)}}lt.description="Division of 2 values (A/B).",Je.registerCustomNode("math/Divide",lt);class rt extends et{onCreate(){this.addInput(null,"float"),this.addOutput(null,"float"),this.addProperty("Value","float",0)}onExecute(){var e=this.getInput(0)??this.properties[0].value;this.setOutput(0,Math.sqrt(e))}}rt.description="Square root of a scalar.",Je.registerCustomNode("math/SQRT",rt);Je.registerCustomNode("logic/And",class extends et{onCreate(){this.addInput(null,"bool"),this.addInput(null,"bool"),this.addOutput(null,"bool")}onExecute(){var e=this.getInput(0),t=this.getInput(1);null!=e&&null!=t&&this.setOutput(0,!!e&&!!t)}});Je.registerCustomNode("logic/Or",class extends et{onCreate(){this.addInput(null,"bool"),this.addInput(null,"bool"),this.addOutput(null,"bool")}onExecute(){var e=this.getInput(0),t=this.getInput(1);null!=e&&null!=t&&this.setOutput(0,!!e||!!t)}});class ct extends et{onCreate(){this.addInput(null,"float"),this.addInput(null,"float"),this.addOutput(null,"bool")}logicOp(e,t){return e==t}onExecute(){var e=this.getInput(0),t=this.getInput(1);null!=e&&null!=t&&this.setOutput(0,this.logicOp(e,t))}}Je.registerCustomNode("logic/Equal",ct);Je.registerCustomNode("logic/NotEqual",class extends ct{logicOp(e,t){return e!=t}});Je.registerCustomNode("logic/Less",class extends ct{logicOp(e,t){return e<t}});Je.registerCustomNode("logic/LessEqual",class extends ct{logicOp(e,t){return e<=t}});Je.registerCustomNode("logic/Greater",class extends ct{logicOp(e,t){return e>t}});Je.registerCustomNode("logic/GreaterEqual",class extends ct{logicOp(e,t){return e>=t}});Je.registerCustomNode("logic/Select",class extends et{onCreate(){this.addInput("True","any"),this.addInput("False","any"),this.addInput("Condition","bool"),this.addOutput(null,"any")}onExecute(){var e=this.getInput(0),t=this.getInput(1),s=this.getInput(2);null!=e&&null!=t&&null!=s&&this.setOutput(0,s?e:t)}});class ht extends et{onCreate(){this.addInput("A","any"),this.addInput("B","any"),this.addInput("True","any"),this.addInput("False","any"),this.addProperty("Condition","select","Equal",["Equal","Not Equal","Less","Less Equal","Greater","Greater Equal"]),this.addOutput(null,"any")}onExecute(){var e=this.getInput(0),t=this.getInput(1),s=this.getInput(2),i=this.getInput(3),o=this.properties[0].value;if(null!=e&&null!=t&&null!=s&&null!=i){var n;switch(o){case"Equal":n=e==t?s:i;break;case"Not Equal":n=e!=t?s:i;break;case"Less":n=e<t?s:i;break;case"Less Equal":n=e<=t?s:i;break;case"Greater":n=e>t?s:i;break;case"Greater Equal":n=e>=t?s:i}this.setOutput(0,n)}}}ht.description="Compare A to B given the selected operator. If true, return value of True else return value of False.",Je.registerCustomNode("logic/Compare",ht);Je.registerCustomNode("events/KeyDown",class extends et{onCreate(){this.addOutput(null,"bool"),this.addProperty("Key","string"," ")}onExecute(){this.setOutput(0,!!this.editor?.keys[this.properties[0].value])}});Je.registerCustomNode("inputs/String",class extends et{onCreate(){this.addOutput(null,"string"),this.addProperty(null,"string","text")}onExecute(){this.setOutput(0,this.properties[0].value)}});Je.registerCustomNode("inputs/Float",class extends et{onCreate(){this.addOutput(null,"float"),this.addProperty(null,"float",0)}onExecute(){this.setOutput(0,this.properties[0].value)}});Je.registerCustomNode("inputs/Vector2",class extends et{onCreate(){this.addOutput("Value","vec2"),this.addProperty("Value","vec2",[0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});Je.registerCustomNode("inputs/Vector3",class extends et{onCreate(){this.addOutput("Value","vec3"),this.addProperty("Value","vec3",[0,0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});Je.registerCustomNode("inputs/Vector4",class extends et{onCreate(){this.addOutput("Value","vec4"),this.addProperty("Value","vec4",[0,0,0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});class dt extends et{onCreate(){this.addInput("Value","any"),this.addOutput(null,"any"),this.addProperty("Name","string","")}onExecute(){var e=this.getInput(0);if(null!=e){var t=this.getInput(1);null!=t&&(this.editor?.setVariable(e,t),this.setOutput(0,t))}}}dt.title="Set Variable",Je.registerCustomNode("variables/SetVariable",dt);class ut extends et{onCreate(){this.addOutput(null,"any"),this.addProperty("Name","string","")}onExecute(){var e=this.getInput(0);if(null!=e){var t=this.editor?.getVariable(e);null!=t&&this.setOutput(0,t)}}}ut.title="Get Variable",Je.registerCustomNode("variables/GetVariable",ut);class pt extends et{onCreate(){this.addInput(null,"any")}onExecute(){var e=this.getInput(0);null!=e&&console.log(e)}}pt.title="Console Log",Je.registerCustomNode("system/ConsoleLog",pt);class mt extends et{onCreate(){this.addInput("a","float"),this.addInput("b","bool"),this.addInput("Color","vec4")}onExecute(){var e=this.getInput(2);null!=e&&console.log(e)}}if(mt.blockDelete=!0,Je.registerCustomNode("system/Main",mt),!t)throw"Missing LX namespace!";t.extensions.push("ImUI");const gt=t.vec2;class ft{root;canvas;components={};mouseDown=!1;mousePosition=new gt;usePointerCursor=!1;eventClick=void 0;constructor(e,t={}){console.assert(void 0!==e),e.tabIndex=-1,e.addEventListener("keydown",this._processKey.bind(this),!0),e.addEventListener("mousedown",this._processMouse.bind(this)),e.addEventListener("mouseup",this._processMouse.bind(this)),e.addEventListener("mousemove",this._processMouse.bind(this)),e.addEventListener("click",this._processMouse.bind(this)),this.root=this.canvas=e}_processKey(e){const t=e.detail,s=e.key??t.key;console.log(s)}_processMouse(e){"mousedown"==e.type?this.mouseDown=!0:"mouseup"==e.type?(this._processClick(e),this.mouseDown=!1):"mousemove"==e.type&&this.mousePosition.set(e.clientX,e.clientY)}_processClick(e){this.eventClick=e}Button(e,s,i,o){const n=this.canvas.getContext("2d");n.font="16px Arial";let a=new t.vec2(12,8),l=new t.vec2(s,i);const r=n.measureText(e);let c=new t.vec2(r.width,r.actualBoundingBoxAscent+r.actualBoundingBoxDescent);const h=this.mousePosition.x>=l.x&&this.mousePosition.x<=l.x+c.x+2*a.x&&this.mousePosition.y>=l.y&&this.mousePosition.y<=l.y+c.y+2*a.y,d=h&&this.mouseDown;return n.beginPath(),n.fillStyle=d?"#666":h?"#444":"#222",n.roundRect(l.x,l.y,c.x+2*a.x,c.y+2*a.y,[8,8,8,8]),n.fill(),n.fillStyle=h?"#fff":"#ddd",n.fillText(e,l.x+a.x,l.y+r.actualBoundingBoxAscent+a.y),this.usePointerCursor=this.usePointerCursor||h,!!this.eventClick&&(o&&o(),!0)}Slider(e,s,i,o=0,n){const a=this.canvas.getContext("2d");this.components[e]?o=this.components[e].value:this.components[e]={value:o};a.font="16px Arial";let l=new t.vec2(12,8),r=new t.vec2(s,i);const c=a.measureText(e);let h=new t.vec2(c.width,c.actualBoundingBoxAscent+c.actualBoundingBoxDescent),d=h.add(l.mul(2));const u=this.mousePosition.x>=r.x&&this.mousePosition.x<=r.x+d.x&&this.mousePosition.y>=r.y&&this.mousePosition.y<=r.y+d.y,p=u&&this.mouseDown;a.beginPath(),a.fillStyle=u?"#444":"#222",a.roundRect(r.x,r.y,d.x,d.y,[8,8,8,8]),a.fill();const m=r.x,g=r.x+d.x;p&&(o=t.clamp((this.mousePosition.x-m)/(g-m),0,1),this.components[e].value=o);let f=new t.vec2(d.x*o,h.y);a.beginPath(),a.fillStyle=u?"#6074e7":"#3e57e4",f.x>d.x-8?(a.roundRect(r.x,r.y,f.x,f.y+2*l.y,[8,8,8,8]),a.fill()):a.fillRect(r.x,r.y,f.x,f.y+2*l.y),a.fillStyle=u?"#fff":"#ddd",a.fillText(e,r.x+l.x,r.y+c.actualBoundingBoxAscent+l.y),this.usePointerCursor=this.usePointerCursor||u,p&&n&&n(o)}Checkbox(e,s,i,o=!1,n){const a=this.canvas.getContext("2d");this.components[e]?o=this.components[e].value:this.components[e]={value:o};a.font="16px Arial";let l=new t.vec2(12,8),r=new t.vec2(s,i);const c=a.measureText(e);let h=new t.vec2(c.width,c.actualBoundingBoxAscent+c.actualBoundingBoxDescent),d=new t.vec2(24,0);d.add(h,d);const u=r.x+h.x+l.x+12,p=r.y+l.y,m=this.mousePosition.x>=u&&this.mousePosition.x<=u+h.y&&this.mousePosition.y>=p&&this.mousePosition.y<=p+h.y,g=m&&this.mouseDown,f=m&&this.eventClick;a.fillStyle=g?"#666":m?"#444":"#222",a.fillRect(r.x,r.y,d.x+2*l.x,d.y+2*l.y),f&&(o=!o,this.components[e].value=o,n&&n(o)),a.fillStyle=o?g?"#ddd":m?"#6074e7":"#3e57e4":g?"#bbb":m?"#777":"#888",a.fillRect(r.x+h.x+l.x+12,r.y+l.y,h.y,h.y),a.fillStyle=m?"#fff":"#ddd",a.fillText(e,r.x+l.x,r.y+c.actualBoundingBoxAscent+l.y),this.usePointerCursor=this.usePointerCursor||m}endFrame(){delete this.eventClick,document.body.style.cursor=this.usePointerCursor?"pointer":"default",this.usePointerCursor=!1}}if(t.ImUI=ft,!t)throw"Missing LX namespace!";t.extensions.push("Timeline"),t.registerIcon("TimelineLock",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path fill="none" d="M7 11V7a4 4 0 0 1 9 0v4 M5,11h13 a2 2 0 0 1 2 2 v7 a2 2 0 0 1 -2 2 h-13 a2 2 0 0 1 -2 -2 v-7 a2 2 0 0 1 2 -2 M12 16 v2"/></svg>'),t.registerIcon("TimelineLockOpen",'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path fill="none" d="M14 11V7a4 4 0 0 1 9 0v2 M3,11h13 a2 2 0 0 1 2 2 v7 a2 2 0 0 1 -2 2 h-13 a2 2 0 0 1 -2 -2 v-7 a2 2 0 0 1 2 -2 M8 17 h3"/></svg>');const Ct=t.Area,vt=t.Panel,yt=t.Dialog;t.TreeEvent;class bt{static BACKGROUND_COLOR;static TRACK_COLOR_PRIMARY;static TRACK_COLOR_SECONDARY;static TRACK_COLOR_TERCIARY;static TRACK_COLOR_QUATERNARY;static TRACK_SELECTED;static TRACK_SELECTED_LIGHT;static FONT;static FONT_COLOR_PRIMARY;static FONT_COLOR_TERTIARY;static FONT_COLOR_QUATERNARY;static KEYFRAME_COLOR;static KEYFRAME_COLOR_HOVERED;static KEYFRAME_COLOR_SELECTED;static KEYFRAME_COLOR_LOCK;static KEYFRAME_COLOR_EDITED;static KEYFRAME_COLOR_INACTIVE;static TIME_MARKER_COLOR;static TIME_MARKER_COLOR_TEXT;static BOX_SELECTION_COLOR;uniqueID;timelineTitle;animationClip;duration=1;currentTime=0;visualTimeRange=[0,0];visualOriginTime=0;pixelsPerSecond=300;secondsPerPixel;clickTime=0;clickDiscardTimeout=200;lastMouse=[0,0];boxSelection=!1;boxSelectionStart=[0,0];boxSelectionEnd=[0,0];historyUndo=[];historyRedo=[];historySaveEnabler=!0;historyMaxSteps=100;clipboard=null;grabbing=!1;grabTime=0;grabbingTimeBar=!1;grabbingScroll=!1;movingKeys=!1;timeBeforeMove=0;currentScroll=0;currentScrollInPixels=0;trackHeight=32;timeSeparators=[.01,.1,.5,1,5];playing=!1;loop=!0;active=!0;skipVisibility;skipLock;disableNewTracks;optimizeThreshold=.01;selectedTracks=[];selectedItems=[];leftPanel;trackTreesPanel=null;trackTreesComponent=null;lastTrackTreesComponentOffset=0;mainArea;root;header;canvasArea;canvas;size=[1e-6,1e-6];topMargin=40;header_offset=48;updateTheme;onCreateBeforeTopBar=null;onCreateAfterTopBar=null;onCreateControlsButtons=null;onCreateSettingsButtons=null;onShowOptimizeMenu=null;onShowConfiguration=null;onMouse=null;onDblClick=null;onShowContextMenu=null;onAddNewTrackButton=null;onAddNewTrack=null;onTrackTreeEvent=null;onBeforeDrawContent=null;onStateStop=null;onStateChange=null;onChangeLoopMode=null;onSetDuration=null;onSetTime=null;onItemSelected=null;onSetTrackSelection=null;onSetTrackState=null;onSetTrackLock=null;onUpdateTrack=null;configurationDialog=null;constructor(e,s={}){this.uniqueID=e??"timeline"+Math.floor(4294967295*Math.random()),this.timelineTitle=s.title??null,this.onCreateBeforeTopBar=s.onCreateBeforeTopBar,this.onCreateAfterTopBar=s.onCreateAfterTopBar,this.onCreateControlsButtons=s.onCreateControlsButtons,this.onCreateSettingsButtons=s.onCreateSettingsButtons,this.onShowOptimizeMenu=s.onShowOptimizeMenu,this.onShowConfiguration=s.onShowConfiguration,this.canvas=document.createElement("canvas"),this.canvas.style.width="100%",this.canvas.style.height="100%",this.secondsPerPixel=1/this.pixelsPerSecond,this.animationClip=this.instantiateAnimationClip(),this.loop=s.loop??!0,this.skipVisibility=s.skipVisibility??!1,this.skipLock=s.skipLock??!1,this.disableNewTracks=s.disableNewTracks??!1,this.mainArea=new Ct({className:"lextimeline"}),this.root=this.mainArea.root,this.mainArea.split({type:"vertical",sizes:[this.header_offset,"auto"],resize:!1}),this.header=new vt({id:"lextimelineheader"}),this.mainArea.sections[0].attach(this.header),this.updateHeader();const i=this.mainArea.sections[1];i.root.id="bottom-timeline-area",i.split({type:"horizontal",sizes:["15%","85%"]});let[o,n]=i.sections;n.attach(this.canvas),this.canvasArea=n,this.canvasArea.root.classList.add("lextimelinearea"),this.leftPanel=o.addPanel({className:"lextimelinepanel",width:"100%",height:"100%"}),this.updateLeftPanel(),this.uniqueID.length&&(this.root.id=this.uniqueID,this.canvas.id=this.uniqueID+"-canvas"),this.canvas.addEventListener("mousedown",this.processMouse.bind(this)),this.canvas.addEventListener("mouseup",this.processMouse.bind(this)),this.canvas.addEventListener("mousemove",this.processMouse.bind(this)),this.canvas.addEventListener("wheel",this.processMouse.bind(this)),this.canvas.addEventListener("dblclick",this.processMouse.bind(this)),this.canvas.addEventListener("contextmenu",this.processMouse.bind(this)),this.canvas.tabIndex=1,this.canvasArea.root.addEventListener("keydown",e=>{this.processKeys(e)}),this.canvasArea.onresize=e=>{e.width&&e.height&&this.resizeCanvas()},this.resize(this.size),this.updateTheme=function(){bt.BACKGROUND_COLOR=t.getThemeColor("global-blur-background"),bt.TRACK_COLOR_PRIMARY=t.getThemeColor("global-color-primary"),bt.TRACK_COLOR_SECONDARY=t.getThemeColor("global-color-secondary"),bt.TRACK_COLOR_TERCIARY=t.getThemeColor("global-color-terciary"),bt.TRACK_COLOR_QUATERNARY=t.getThemeColor("global-color-quaternary"),bt.FONT=t.getThemeColor("global-font"),bt.FONT_COLOR_PRIMARY=t.getThemeColor("global-text-primary"),bt.FONT_COLOR_TERTIARY=t.getThemeColor("global-text-tertiary"),bt.FONT_COLOR_QUATERNARY=t.getThemeColor("global-text-quaternary"),bt.KEYFRAME_COLOR=t.getThemeColor("lxTimeline-keyframe"),bt.KEYFRAME_COLOR_SELECTED=bt.KEYFRAME_COLOR_HOVERED=t.getThemeColor("lxTimeline-keyframe-selected"),bt.KEYFRAME_COLOR_LOCK=t.getThemeColor("lxTimeline-keyframe-locked"),bt.KEYFRAME_COLOR_EDITED=t.getThemeColor("lxTimeline-keyframe-edited"),bt.KEYFRAME_COLOR_INACTIVE=t.getThemeColor("lxTimeline-keyframe-inactive")}.bind(this),t.addSignal("@on_new_color_scheme",this.updateTheme)}clear(){if(this.header&&this.header.clear(),this.leftPanel&&this.leftPanel.clear(),this.updateTheme){let e=t.signals["@on_new_color_scheme"]??[];for(let t=0;t<e.length;++t)e[t]==this.updateTheme&&e.splice(t,1)}}updateHeader(){this.header.clear();const e=this.header;e.sameLine(),this.timelineTitle&&e.addTitle(this.timelineTitle,{style:{background:"none",fontSize:"18px",fontStyle:"bold",alignItems:"center"}});const s=t.makeContainer(["auto","100%"],"flex flex-row gap-1");e.queue(s);e.addButton("playBtn","",(e,t)=>{this.changeState()},{buttonClass:"accept",title:"Play",hideName:!0,icon:"Play@solid",swap:"Pause@solid"}).setState(this.playing,!0),e.addButton("stopBtn","",(e,t)=>{this.setState(!1,!0),this.onStateStop&&this.onStateStop()},{buttonClass:"accept",title:"Stop",hideName:!0,icon:"Stop@solid"}),e.addButton("loopBtn","",(e,t)=>{this.setLoopMode(!this.loop)},{selectable:!0,selected:this.loop,title:"Loop",hideName:!0,icon:"RefreshCw"}),this.onCreateControlsButtons&&this.onCreateControlsButtons(e),e.clearQueue(s),e.addContent("header-buttons",s),this.onCreateBeforeTopBar&&this.onCreateBeforeTopBar(e),e.addNumber("Current Time",this.currentTime,(e,t)=>{this.setTime(e)},{units:"s",step:.01,min:0,precision:3,skipSlider:!0,skipReset:!0,nameWidth:"auto"}),e.addNumber("Duration",+this.duration.toFixed(3),(e,t)=>{this.setDuration(e,!1,!1)},{units:"s",step:.01,min:0,skipReset:!0,nameWidth:"auto"}),this.onCreateAfterTopBar&&this.onCreateAfterTopBar(e);const i=t.makeContainer(["auto","100%"],"flex flex-row gap-1");e.queue(i),this.onCreateSettingsButtons&&this.onCreateSettingsButtons(e),this.onShowOptimizeMenu&&e.addButton(null,"",(e,t)=>{this.onShowOptimizeMenu&&this.onShowOptimizeMenu(t)},{tooltip:!0,title:"Optimize",icon:"Filter"}),this.onShowConfiguration&&e.addButton(null,"",(e,t)=>{if(this.configurationDialog)return this.configurationDialog.close(),void(this.configurationDialog=null);this.configurationDialog=new yt("Configuration",e=>{this.onShowConfiguration&&this.onShowConfiguration(e)},{onBeforeClose:()=>{this.configurationDialog.panel.clear(),this.configurationDialog=null}})},{title:"Settings",icon:"Settings",tooltip:!0}),e.clearQueue(i),e.addContent("header-buttons-end",i),e.endLine("justify-between")}updateLeftPanel(){this.leftPanel.clear();const e=this.leftPanel;e.sameLine();let s=e.addTitle("Tracks",{style:{background:"none"},className:"fg-secondary text-lg px-4"}).root;this.disableNewTracks||e.addButton("addTrackBtn","",(e,t)=>{this.onAddNewTrackButton?this.onAddNewTrackButton():this.addNewTrack()},{hideName:!0,title:"Add Track",icon:"Plus"}),e.endLine();const i=window.getComputedStyle(s),o=s.clientHeight+parseFloat(i.marginTop)+parseFloat(i.marginBottom);let n=new t.Panel({height:"calc(100% - "+o+"px )"}),a=[];this.animationClip&&this.selectedItems.length&&(a=this.generateSelectedItemsTreeData()),this.trackTreesComponent=n.addTree(null,a,{filter:!1,rename:!1,draggable:!1,onevent:e=>{switch(e.type){case t.TreeEvent.NODE_SELECTED:if(e.event.shiftKey||this.deselectAllTracks(!1),e.node.trackData){const t=!e.event.shiftKey||!e.node.trackData.isSelected;this.setTrackSelection(e.node.trackData.trackIdx,t,!1,!1)}break;case t.TreeEvent.NODE_VISIBILITY:e.node.trackData&&this.setTrackState(e.node.trackData.trackIdx,e.value,!1,!1)}this.onTrackTreeEvent&&this.onTrackTreeEvent(e)}});const l=this;this.trackTreesComponent.innerTree._refresh=this.trackTreesComponent.innerTree.refresh,this.trackTreesComponent.innerTree.refresh=function(e,t){this._refresh(e,t),l.setTrackHeight(l.trackHeight)},this.selectedTracks.length&&this._updateTrackTreeSelection(),this.trackTreesComponent.name="tracksTrees",n.components[this.trackTreesComponent.name]=this.trackTreesComponent,this.trackTreesPanel=n,e.attach(n.root),n.root.addEventListener("scroll",e=>{e.currentTarget.scrollHeight>e.currentTarget.clientHeight?(this.currentScroll=e.currentTarget.scrollTop/(e.currentTarget.scrollHeight-e.currentTarget.clientHeight),this.currentScrollInPixels=e.currentTarget.scrollTop):(this.currentScroll=0,this.currentScrollInPixels=0)}),this.trackTreesPanel.root.scrollTop=this.currentScrollInPixels,this.setTrackHeight(this.trackHeight),!this.leftPanel.parent.root.classList.contains("hidden")&&this.root.parentElement&&(this.resizeCanvas(),this.setScroll(this.currentScroll))}setTrackHeight(e){const t=.25*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.trackHeight=e=Math.max(t,e),!this.trackTreesComponent)return;e-=t;const s=this.trackTreesComponent.root.querySelector("ul").children;for(let t=0;t<s.length;++t)s[t].style.height=e+"px"}addNewTrack(e={},t=!1){const s=this.instantiateTrack(e);return s.trackIdx=this.animationClip.tracks.length,this.animationClip.tracks.push(s),this.onAddNewTrack&&!t&&this.onAddNewTrack(s,e),s.trackIdx}getTracksInRange(e,t){let s=[];if(e>t){let s=e;e=t,t=s}const i=this.getVisibleItems();if(i.length<1)return[];const o=e-this.lastTrackTreesComponentOffset+this.currentScrollInPixels,n=t-this.lastTrackTreesComponentOffset+this.currentScrollInPixels,a=Math.max(0,Math.floor(o/this.trackHeight)),l=Math.min(i.length-1,Math.floor(n/this.trackHeight))+1;for(let e=a;e<l;++e){const t=i[e];t.treeData&&t.treeData.trackData&&s.push(t.treeData.trackData)}return s}setAnimationClip(e,t=!0){return this.deselectAllElements(),this.deselectAllTracks(!1),this.selectedItems=[],this.clearState(),e&&e.tracks&&!t?this.animationClip=e:this.animationClip=this.instantiateAnimationClip(e),this.setDuration(this.animationClip.duration,!0,!0),this.updateLeftPanel(),this.resize(),this.animationClip}drawTimeInfo(e,t=this.topMargin){let s=this.canvas.getContext("2d");s.font="11px "+bt.FONT,s.textAlign="center",s.save(),s.fillStyle=bt.BACKGROUND_COLOR,s.fillRect(0,0,this.canvas.width,t),s.strokeStyle=bt.FONT_COLOR_PRIMARY;let i=4;this.pixelsPerSecond>900?i=1:this.pixelsPerSecond>100?i=2:this.pixelsPerSecond>50&&(i=3);let o=this.timeSeparators[i-1];i=this.timeSeparators[i];const n=this.visualTimeRange[0],a=this.visualTimeRange[1];let l=this.timeToX(n+i)-this.timeToX(n),r=o*l/i,c=this.timeToX(Math.floor(n/i)*i);c+=1e-7;let h=this.timeToX(a);s.beginPath(),s.fillStyle=bt.FONT_COLOR_PRIMARY,s.globalAlpha=1;for(let e=c;e<=h;e+=l){s.moveTo(Math.round(e)+.5,.4*t+.3*t),s.lineTo(Math.round(e)+.5,.95*t);let o=e+l-.5*r;for(let i=e;i<o&&i<h;i+=r)s.moveTo(Math.round(i)+.5,.4*t+.45*t),s.lineTo(Math.round(i)+.5,.95*t);let n=this.xToTime(e);s.fillText(n.toFixed(i<1?1:0),e,.6*t)}s.stroke(),s.restore()}drawTracksBackground(e,t){let s=this.canvas,i=s.getContext("2d"),o=this.duration;i.globalAlpha=1;const n=this.topMargin,a=this.lastTrackTreesComponentOffset,l=this.trackHeight;e=e||s.width;let r=Math.ceil((t-n)/l)+1;i.save(),i.fillStyle=bt.TRACK_COLOR_SECONDARY;const c=this.currentScrollInPixels%l;for(let t=1-Math.floor(this.currentScrollInPixels/l)%2;t<=r;t+=2)i.fillRect(0,a-c+t*l,e,l);i.strokeStyle=bt.TRACK_COLOR_TERCIARY,i.beginPath();let h=this.timeToX(0);h<0&&(h=0),i.lineWidth=1,i.moveTo(h+.5,n),i.lineTo(h+.5,s.height),i.moveTo(Math.round(this.timeToX(o))+.5,n),i.lineTo(Math.round(this.timeToX(o))+.5,s.height),i.stroke(),i.restore()}draw(){let e=this.canvas.getContext("2d");e.textBaseline="bottom",e.font="11px "+bt.FONT,e.globalAlpha=1;const t=e.canvas.width,s=e.canvas.height,i=this.trackTreesComponent.root.scrollHeight,o=this.lastTrackTreesComponentOffset=this.trackTreesComponent.innerTree.domEl.offsetTop-this.canvas.offsetTop-2;let n=this.visualOriginTime;n=Math.min(this.duration,Math.max(0,n));let a=this.visualOriginTime+t*this.secondsPerPixel;if(a=Math.max(n,Math.min(this.duration,a)),this.visualTimeRange[0]=n,this.visualTimeRange[1]=a,e.globalAlpha=1,e.fillStyle=bt.TRACK_COLOR_SECONDARY,e.clearRect(0,0,this.canvas.width,this.canvas.height),this.drawTracksBackground(t,s),this.onBeforeDrawContent&&this.onBeforeDrawContent(e),this.animationClip&&(e.translate(0,o),this.drawContent(e),e.translate(0,-o)),s-this.topMargin<i){e.fillStyle="#222",e.fillRect(t-10,0,10,s),e.fillStyle=this.grabbingScroll?bt.FONT_COLOR_TERTIARY:bt.FONT_COLOR_QUATERNARY;let i=Math.max(10,(s-this.topMargin)*(s-this.topMargin)/this.trackTreesPanel.root.scrollHeight);Lt(e,t-10,this.currentScroll*(s-this.topMargin-i)+this.topMargin,10,i,5,!0)}this.drawTimeInfo(t);let l=Math.round(this.timeToX(this.currentTime)),r=.4*this.topMargin;l>=0&&(e.strokeStyle=e.fillStyle=bt.TIME_MARKER_COLOR,e.globalAlpha=1,e.beginPath(),e.moveTo(l,.6*r),e.lineTo(l,this.canvas.height),e.stroke(),e.closePath(),e.shadowBlur=8,e.shadowColor=bt.TIME_MARKER_COLOR,e.shadowOffsetX=1,e.shadowOffsetY=1,Lt(e,l-10,.6*r,20,r,5,!0),e.fill(),e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.font="11px "+bt.FONT,e.textAlign="center",e.fillStyle=bt.TIME_MARKER_COLOR_TEXT,e.fillText((.1*Math.floor(10*this.currentTime)).toFixed(1),l,.6*this.topMargin),e.strokeStyle=e.fillStyle=bt.FONT_COLOR_PRIMARY,this.boxSelection&&(e.globalAlpha=.15,e.fillStyle=bt.BOX_SELECTION_COLOR,e.strokeRect(this.boxSelectionStart[0],this.boxSelectionStart[1],this.boxSelectionEnd[0]-this.boxSelectionStart[0],this.boxSelectionEnd[1]-this.boxSelectionStart[1]),e.fillRect(this.boxSelectionStart[0],this.boxSelectionStart[1],this.boxSelectionEnd[0]-this.boxSelectionStart[0],this.boxSelectionEnd[1]-this.boxSelectionStart[1]),e.stroke(),e.globalAlpha=1)}clearState(){this.historyUndo=[],this.historyRedo=[]}setDuration(e,t=!1,s=!0){let i=Math.max(0,e);this.duration=this.animationClip.duration=i,s&&this.header.components.Duration.set(+this.duration.toFixed(2),!0),this.onSetDuration&&!t&&this.onSetDuration(this.duration)}setTime(e,t=!1){this.currentTime=Math.max(0,Math.min(e,this.duration)),this.header.components["Current Time"].set(+this.currentTime.toFixed(2),!0),this.onSetTime&&!t&&this.onSetTime(this.currentTime)}xToTime(e){return e*this.secondsPerPixel+this.visualOriginTime}timeToX(e){return(e-this.visualOriginTime)*this.pixelsPerSecond}setScale(e){const t=this.timeToX(this.currentTime);this.pixelsPerSecond=e,this.pixelsPerSecond=Math.max(1e-5,this.pixelsPerSecond),this.secondsPerPixel=1/this.pixelsPerSecond,this.visualOriginTime+=this.currentTime-this.xToTime(t)}setScroll(e,t=!0){if(!this.trackTreesPanel)return this.currentScroll=0,void(this.currentScrollInPixels=0);const s=this.trackTreesPanel.root;s.scrollHeight>s.clientHeight?t?(this.currentScroll=e,this.currentScrollInPixels=e*(s.scrollHeight-s.clientHeight)):(this.currentScroll=e/(s.scrollHeight-s.clientHeight),this.currentScrollInPixels=e):(this.currentScroll=0,this.currentScrollInPixels=0),this.trackTreesPanel.root.scrollTop=this.currentScrollInPixels}processMouse(e){if(!this.canvas)return;let s=this.canvas.height,i=this.canvas.width,o=e.offsetX,n=e.offsetY;e.deltax=o-this.lastMouse[0],e.deltay=n-this.lastMouse[1];let a=e.offsetX,l=e.offsetY,r=this.timeToX(this.currentTime),c=l<this.topMargin&&a>r-6&&a<r+6;const h=this.xToTime(o);if(c?this.canvas.style.cursor="col-resize":this.movingKeys?this.canvas.style.cursor="grabbing":e.shiftKey?this.canvas.style.cursor="crosshair":this.canvas.style.cursor="default","wheel"==e.type){if(e.shiftKey){if(e.wheelDelta){let t=this.xToTime(a);this.setScale(this.pixelsPerSecond*(e.wheelDelta<0?.95:1.05)),this.visualOriginTime=t-a*this.secondsPerPixel}}else s-this.topMargin<this.trackTreesComponent.root.scrollHeight&&(this.trackTreesPanel.root.scrollTop+=e.deltaY);return void(this.onMouse&&this.onMouse(e,h))}const d=o>=0&&o<=this.size[0]&&n>=0&&n<=this.size[1];let u=this.getTracksInRange(l,l);if(u=u.length?u[0]:null,e.track=u,e.localX=a,e.localY=l,"mouseup"==e.type){if(!this.active)return this.grabbing=!1,this.grabbingTimeBar=!1,this.grabbingScroll=!1,this.movingKeys=!1,this.timeBeforeMove=0,void(this.boxSelection=!1);const s=this.movingKeys||t.getTime()-this.clickTime>this.clickDiscardTimeout;e.discard=s,this.grabbingScroll||this.grabbingTimeBar||0!=e.button||!this.onMouseUp||this.onMouseUp(e,h),this.grabbing=!1,this.grabbingTimeBar=!1,this.grabbingScroll=!1,this.movingKeys=!1,this.timeBeforeMove=0,this.boxSelection=!1}if("mousedown"==e.type){if(window.getSelection()?.empty(),this.clickTime=t.getTime(),e.shiftKey&&this.active)return this.boxSelection=!0,this.boxSelectionEnd[0]=this.boxSelectionStart[0]=a,void(this.boxSelectionEnd[1]=this.boxSelectionStart[1]=l);e.localY<this.topMargin?(this.grabbing=!0,this.grabbingTimeBar=!0,this.setTime(h)):s-this.topMargin<this.trackTreesComponent.root.scrollHeight&&o>i-10?(this.grabbing=!0,this.grabbingScroll=!0):(this.grabbing=!0,this.grabTime=h,this.grabbingTimeBar=c,this.onMouseDown&&this.active&&this.onMouseDown(e,h))}else if("mousemove"==e.type){if(e.shiftKey&&this.active&&this.boxSelection)return this.boxSelectionEnd[0]=a,void(this.boxSelectionEnd[1]=l);if(this.grabbing&&2!=e.button&&!this.movingKeys)if(this.canvas.style.cursor="grabbing",this.grabbingTimeBar&&this.active)this.setTime(h);else if(this.grabbingScroll)n<this.topMargin?this.trackTreesPanel.root.scrollTop=0:this.trackTreesPanel.root.scrollTop+=this.trackTreesPanel.root.scrollHeight*e.deltay/(s-this.topMargin);else{var p=this.xToTime(this.lastMouse[0]),m=this.xToTime(e.offsetX);this.visualOriginTime+=p-m,this.trackTreesPanel.root.scrollTop-=e.deltay}this.onMouseMove&&this.onMouseMove(e,h)}else"dblclick"==e.type&&this.onDblClick?this.onDblClick(e):"contextmenu"==e.type&&this.onShowContextMenu&&this.active&&this.onShowContextMenu(e);return this.lastMouse[0]=o,this.lastMouse[1]=n,!(d||this.grabbing||e.metaKey||e.altKey)||(this.onMouse&&this.onMouse(e,h),!0)}processKeys(e){switch(e.key){case"Delete":case"Backspace":this.deleteSelectedContent(!1);break;case"c":case"C":e.ctrlKey&&this.copySelectedContent();break;case"v":case"V":e.ctrlKey&&this.pasteContent(this.currentTime);break;case" ":e.preventDefault(),e.stopImmediatePropagation(),this.changeState();break;case"Shift":this.canvas.style.cursor="crosshair"}}changeState(e=!1){this.setState(!this.playing,e)}setState(e,t=!1){this.playing=e,this.header.components.playBtn.setState(this.playing,!0),this.onStateChange&&!t&&this.onStateChange(this.playing)}setLoopMode(e,t=!1){this.loop=e,this.loop?this.header.components.loopBtn.root.children[0].classList.add("selected"):this.header.components.loopBtn.root.children[0].classList.remove("selected"),this.onChangeLoopMode&&!t&&this.onChangeLoopMode(this.loop)}getVisibleItems(){return this.trackTreesComponent.innerTree.domEl.children[0].children}setSelectedItems(e,t=!1){this.selectedItems=[],this.changeSelectedItems(e,null,t)}changeSelectedItems(e=null,t=null,s=!1){this.deselectAllElements(),this.deselectAllTracks(!1);const i=this.animationClip.tracks;if(t)for(let e=0;e<t.length;++e){const s=t[e];for(let e=0;e<this.selectedItems.length;++e)if(this.selectedItems[e]===s){this.selectedItems.splice(e,1);break}}if(e)for(let t=0;t<e.length;++t){const s=e[t];i[s]&&this.selectedItems.push(i[s])}this.updateLeftPanel(),this.onItemSelected&&!s&&this.onItemSelected(this.selectedItems,e,t)}getTrack(e){const t=this.animationClip.tracks;for(let s=0;s<t.length;++s)if(t[s].id==e)return t[s];return null}deselectAllTracks(e=!0){if(!this.animationClip)return;const t=this.animationClip.tracks;for(let e=0;e<t.length;e++)t[e].isSelected=!1;this.selectedTracks.length=0,e&&this._updateTrackTreeSelection()}setTrackSelection(e,t,s=!1,i=!0){const o=this.animationClip.tracks[e],n=o.isSelected;o.isSelected=t;const a=this.selectedTracks.indexOf(o);-1==a&&!t||a>-1&&t||(-1==a?this.selectedTracks.push(o):this.selectedTracks.splice(a,1),this.onSetTrackSelection&&!s&&this.onSetTrackSelection(o,n),i&&this._updateTrackTreeSelection())}_updateTrackTreeSelection(){const e=this.trackTreesComponent.innerTree.data,t=this.trackTreesComponent.innerTree.selected;t.length=0;const s=e=>{for(let i=0;i<e.length;++i)e[i].trackData&&e[i].trackData.isSelected&&t.push(e[i]),e[i].children&&s(e[i].children)};this.selectedTracks.length&&s(e),this.trackTreesComponent.innerTree.refresh()}deselectAllElements(){}setTrackState(e,t=!0,s=!1,i=!0){const o=this.animationClip.tracks[e],n=o.active;o.active=t,this.onSetTrackState&&!s&&this.onSetTrackState(o,n),i&&!this.skipVisibility&&this.updateLeftPanel()}setTrackLock(e,t=!1,s=!1,i=!0){const o=this.animationClip.tracks[e],n=o.locked;o.locked=t,this.onSetTrackLock&&!s&&this.onSetTrackLock(o,n),i&&!this.skipLock&&this.updateLeftPanel()}saveState(e,t=!1){if(!this.historySaveEnabler)return;const s=this.historyGenerateTrackStep(e);s.trackIdx=e,t&&this.historyUndo.length?this.historyUndo[this.historyUndo.length-1].push(s):this.historyUndo.push([s]),this.historyUndo.length>this.historyMaxSteps&&this.historyUndo.shift(),this.historyRedo=[]}#e(e=!0){let t=e?this.historyUndo:this.historyRedo,s=e?this.historyRedo:this.historyUndo;if(!t.length)return!1;this.deselectAllElements();const i=t.pop(),o=[];for(let t=0;t<i.length;++t){const s=i[t],n=s.trackIdx,a=this.historyApplyTrackStep(s,e);a.trackIdx=n,o.push(a),this.onUpdateTrack&&this.onUpdateTrack([s.trackIdx])}return s.push(o),!0}undo(){return this.#e(!0)}redo(){return this.#e(!1)}resize(e=null){e?(this.size[0]=e[0],this.size[1]=e[1]):this.root.parentElement&&(this.size[0]=this.root.parentElement.clientWidth,this.size[1]=this.root.parentElement.clientHeight),this.mainArea.sections[1].root.style.height="calc(100% - "+this.header_offset+"px )",this.size[0],this.leftPanel.root.clientWidth,this.mainArea.sections[1]._update(),this.resizeCanvas()}resizeCanvas(){this.canvas.width=this.canvasArea.root.clientWidth,this.canvas.height=this.canvasArea.root.clientHeight}hide(){this.mainArea.hide()}show(){this.mainArea.show(),this.resize(),this.updateLeftPanel()}generateSelectedItemsTreeData(){const e=[];for(let t=0;t<this.selectedItems.length;t++){const s=this.selectedItems[t];e.push({trackData:s,id:s.id,skipVisibility:this.skipVisibility,visible:s.active,children:[],actions:this.skipLock?null:[{name:"Lock edition",icon:s.locked?"TimelineLock":"TimelineLockOpen",swap:s.locked?"TimelineLockOpen":"TimelineLock",callback:(e,t,s)=>{this.setTrackLock(e.trackData.trackIdx,!e.trackData.locked,!1,!1)}}]})}return e}instantiateTrack(e={},t=!1){return{isTrack:!0,id:e.id??Math.floor(performance.now())+"_"+Math.floor(65535*Math.random()),active:e.active??!0,locked:e.locked??!1,isSelected:!1,trackIdx:-1,data:e.data??null}}instantiateAnimationClip(e={},t=!1){return{id:e.id??e.name??"animationClip",duration:e.duration??0,tracks:[],data:e.data??null}}}bt.BACKGROUND_COLOR=t.getThemeColor("global-blur-background"),bt.TRACK_COLOR_PRIMARY=t.getThemeColor("global-color-primary"),bt.TRACK_COLOR_SECONDARY=t.getThemeColor("global-color-secondary"),bt.TRACK_COLOR_TERCIARY=t.getThemeColor("global-color-terciary"),bt.TRACK_COLOR_QUATERNARY=t.getThemeColor("global-color-quaternary"),bt.TRACK_SELECTED=t.getThemeColor("global-color-accent"),bt.TRACK_SELECTED_LIGHT=t.getThemeColor("global-color-accent-light"),bt.FONT=t.getThemeColor("global-font"),bt.FONT_COLOR_PRIMARY=t.getThemeColor("global-text-primary"),bt.FONT_COLOR_TERTIARY=t.getThemeColor("global-text-tertiary"),bt.FONT_COLOR_QUATERNARY=t.getThemeColor("global-text-quaternary"),bt.TIME_MARKER_COLOR=t.getThemeColor("global-color-accent"),bt.TIME_MARKER_COLOR_TEXT="#ffffff",t.setThemeColor("lxTimeline-keyframe","light-dark(#2d69da,#2d69da )"),t.setThemeColor("lxTimeline-keyframe-selected","light-dark(#f5c700,#fafa14)"),t.setThemeColor("lxTimeline-keyframe-hovered","light-dark(#f5c700,#fafa14)"),t.setThemeColor("lxTimeline-keyframe-locked","light-dark(#c62e2e,#ff7d7d )"),t.setThemeColor("lxTimeline-keyframe-edited","light-dark(#00d000,#00d000 )"),t.setThemeColor("lxTimeline-keyframe-inactive","light-dark(#706b6b,#706b6b)"),bt.KEYFRAME_COLOR=t.getThemeColor("lxTimeline-keyframe"),bt.KEYFRAME_COLOR_SELECTED=bt.KEYFRAME_COLOR_HOVERED=t.getThemeColor("lxTimeline-keyframe-selected"),bt.KEYFRAME_COLOR_LOCK=t.getThemeColor("lxTimeline-keyframe-locked"),bt.KEYFRAME_COLOR_EDITED=t.getThemeColor("lxTimeline-keyframe-edited"),bt.KEYFRAME_COLOR_INACTIVE=t.getThemeColor("lxTimeline-keyframe-inactive"),bt.BOX_SELECTION_COLOR="#AAA",t.Timeline=bt;class _t extends bt{static ADDKEY_VALUESINARRAYS=1;lastKeyFramesSelected;keyValuePerPixel;defaultCurves;defaultCurvesRange;keyframeSize;keyframeSizeHovered;lastHovered=null;moveKeyMinTime=0;onContentMoved=null;onOptimizeTracks=null;onDeleteKeyFrames=null;onSelectKeyFrame=null;onDeselectKeyFrames=null;constructor(e,s={}){super(e,s),this.lastKeyFramesSelected=[],this.keyValuePerPixel=1/this.trackHeight,this.defaultCurves=!0,this.defaultCurvesRange=[0,1],this.keyframeSize=.5*this.trackHeight,this.keyframeSizeHovered=.5*this.trackHeight+5,s.onShowOptimizeMenu&&"boolean"==typeof s.onShowOptimizeMenu&&(this.onShowOptimizeMenu=e=>{0!=this.selectedItems.length&&t.addContextMenu("Optimize",e,e=>{this.selectedItems.forEach(t=>{if(t.isTrack)e.add((t.groupId?t.groupId:"")+"@"+t.id,()=>{this.optimizeTrack(t.trackIdx,!1)});else{const s=this.animationClip.tracksPerGroup[t];for(let t=0;t<s.length;++t){const i=s[t];e.add((i.groupId?i.groupId:"")+"@"+i.id,()=>{this.optimizeTrack(i.trackIdx,!1)})}}})})}),this.onShowContextMenu=e=>{e.preventDefault(),e.stopPropagation();let s=[];this.lastKeyFramesSelected&&this.lastKeyFramesSelected.length?(s.push({title:"Copy",callback:()=>{this.copySelectedContent()}}),s.push({title:"Delete",callback:()=>{this.deleteSelectedContent()}}),1==this.lastKeyFramesSelected.length&&this.clipboard&&this.clipboard.value&&s.push({title:"Paste Value",callback:()=>{this.pasteContentValue()}})):(s.push({title:"Add Here",callback:()=>{if(!e.track)return;const t=new Float32Array(e.track.dim);t.fill(0),this.addKeyFrames(e.track.trackIdx,t,[this.xToTime(e.localX)])}}),s.push({title:"Add",callback:()=>{if(!e.track)return;const t=new Float32Array(e.track.dim);t.fill(0),this.addKeyFrames(e.track.trackIdx,t,[this.currentTime])}})),this.clipboard&&this.clipboard.keyframes&&(s.push({title:"Paste Here",callback:()=>{this.pasteContent(this.xToTime(e.localX))}}),s.push({title:"Paste",callback:()=>{this.pasteContent(this.currentTime)}})),t.addContextMenu("Options",e,e=>{for(let t=0;t<s.length;t++)e.add(s[t].title,s[t].callback)})},this.animationClip&&this.setAnimationClip(this.animationClip)}generateSelectedItemsTreeData(){const e=[],t=this.animationClip.tracksPerGroup;for(let s=0;s<this.selectedItems.length;s++){const i=this.selectedItems[s],o=!i.isTrack,n=o?t[i]:[i],a=[];for(let e=0;e<n.length;e++){const t=n[e];a.push({trackData:t,id:t.id,skipVisibility:this.skipVisibility,visible:t.active,children:[],actions:this.skipLock?null:[{name:"Lock edition",icon:t.locked?"TimelineLock":"TimelineLockOpen",swap:t.locked?"TimelineLockOpen":"TimelineLock",callback:(e,t,s)=>{this.setTrackLock(e.trackData.trackIdx,!e.trackData.locked,!1,!1)}}]})}if(o){const t={id:i,skipVisibility:!0,children:a};e.push(t)}else e.push(a[0])}return e}instantiateTrack(e={},t=!1){const s=super.instantiateTrack(e);if(s.dim=Math.max(1,e.dim??1),s.groupId=null,s.groupTrackIdx=-1,s.values=new Float32Array(0),s.times=new Float32Array(0),s.selected=[],s.edited=[],s.hovered=[],e.values&&e.times){s.values=t?e.values.slice():e.values,s.times=t?e.times.slice():e.times;const i=s.times.length;e.selected&&e.selected.length==i?s.selected=t?e.selected.slice():e.selected:s.selected=new Array(i).fill(!1),e.edited&&e.edited.length==i?s.edited=t?e.edited.slice():e.edited:s.edited=new Array(i).fill(!1),e.hovered&&e.hovered.length==i?s.hovered=t?e.hovered.slice():e.hovered:s.hovered=new Array(i).fill(!1)}return s.curves=e.curves??this.defaultCurves,s.curvesRange=(e.curvesRange??this.defaultCurvesRange).slice(),s}instantiateAnimationClip(e,t=!1){const s=super.instantiateAnimationClip(e,t);if(s.tracksPerGroup={},e&&e.tracks){const i={};let o=0;for(let n=0;n<e.tracks.length;++n){let a=e.tracks[n],l=a.times??[],r=a.values??[],c=a.dim;(!c||c<0)&&(c=l.length&&r.length?Math.round(r.length/l.length):1);let h=a.id??a.name;const[d,u]=h?this._getValidTrackName(h):[null,null],p=Object.assign({},a);p.id=u,p.dim=c;const m=this.instantiateTrack(p,t);d&&(i[d]?i[d].push(m):i[d]=[m],m.groupId=d,m.groupTrackIdx=i[d].length-1),m.trackIdx=n,s.tracks.push(m),m.times.length&&(o=Math.max(o,m.times[m.times.length-1]))}if(s.tracksPerGroup=i,e&&e.duration||(s.duration=o),e.tracksPerGroup){s.tracks.forEach((e,t)=>{e.groupId=null,e.groupTrackIdx=-1}),s.tracksPerGroup={};let t=e.tracksPerGroup;for(let e in t){const i=t[e],o=[];for(let t=0;t<i.length;++t){const n=s.tracks[i[t].trackIdx];o[t]=n,n.groupId=e,n.groupTrackIdx=t}s.tracksPerGroup[e]=o}}}return s}deselectAllElements(){this.deselectAllKeyFrames(),this.unHoverAll()}changeSelectedItems(e=null,t=null,s=!1){this.deselectAllElements(),this.deselectAllTracks(!1);const i=this.animationClip.tracks,o=this.animationClip.tracksPerGroup;if(t)for(let e=0;e<t.length;++e){const s=!!t[e].substr;let n=s?t[e]:i[t[e]];for(let e=0;e<this.selectedItems.length;++e)if(this.selectedItems[e]===n){const t=s?o[n].length:1;this.selectedItems.splice(e,t);break}}if(e)for(let t=0;t<e.length;++t){const s=e[t];isNaN(s)?o[s]&&this.selectedItems.push(s):i[s]&&this.selectedItems.push(i[s])}this.updateLeftPanel(),this.onItemSelected&&!s&&this.onItemSelected(this.selectedItems,e,t)}setTracksGroup(e,t=null){const s=this.animationClip.tracks,i=this.animationClip.tracksPerGroup,o=[];let n=-1;if(i[e]){i[e].forEach(e=>{e.groupId=null,e.groupTrackIdx=-1});for(let t=0;t<this.selectedItems.length;++t)if(this.selectedItems[t]===e){n=t;break}}if(!t)return delete i.groupId,void(n>-1&&this.selectedItems.splice(n,1));for(let i=0;i<t.length;++i){const n=t[i];let a=null;if("string"==typeof n){for(let e=0;e<s.length;++e)if(s[e].id==n){a=s[e];break}}else s[n]&&(a=s[n]);a&&(a.groupId=e,a.groupTrackIdx=o.length,o.push(a))}i[e]=o,n>-1&&this.updateLeftPanel()}getTracksGroup(e){return this.animationClip.tracksPerGroup[e]??null}getTrack(e,t=null){let s=this.animationClip.tracks;t&&(s=this.animationClip.tracksPerGroup[t]??[]);for(let t=0;t<s.length;++t)if(s[t].id==e)return s[t];return null}setKeyframeSize(e,t=null){this.keyframeSizeHovered=t??e,this.keyframeSize=e}onMouseUp(e,t){let s=e.track,i=e.localX,o=e.discard;if(e.shiftKey){if(!o&&s){const e=.5*this.keyframeSize,t=this.getCurrentKeyFrame(s,this.xToTime(i),this.secondsPerPixel*e);t>-1&&(s.selected[t]?this.deselectKeyFrame(s.trackIdx,t):this.processSelectionKeyFrame(s.trackIdx,t,!0))}else if(this.boxSelection){let e=this.getTracksInRange(this.boxSelectionStart[1],this.boxSelectionEnd[1]);for(let t of e){let e=this.getKeyFramesInRange(t,this.xToTime(this.boxSelectionStart[0]),this.xToTime(this.boxSelectionEnd[0]),5*this.secondsPerPixel);if(e)for(let s=e[0];s<=e[1];++s)this.processSelectionKeyFrame(t.trackIdx,s,!0)}}}else if(!this.movingKeys&&!o&&(this.lastKeyFramesSelected.length&&(this.onDeselectKeyFrames&&this.onDeselectKeyFrames(this.lastKeyFramesSelected),this.deselectAllKeyFrames()),s)){const e=.5*this.keyframeSize,t=this.getCurrentKeyFrame(s,this.xToTime(i),this.secondsPerPixel*e);t>-1&&this.processSelectionKeyFrame(s.trackIdx,t,!1)}this.canvas.classList.remove("grabbing")}onMouseDown(e,t){let s=e.localX;if(e.localY,e.track,(e.ctrlKey||e.altKey)&&this.lastKeyFramesSelected.length){this.movingKeys=!0,this.canvas.style.cursor="grab",this.canvas.classList.add("grabbing"),this.moveKeyMinTime=1/0;const e=this.animationClip.tracks;let t=-1;for(let s of this.lastKeyFramesSelected){let[i,o,n]=s;const a=e[i];s[2]=a.times[o],t!=i&&(this.moveKeyMinTime<1/0?this.saveState(a.trackIdx,!0):this.saveState(a.trackIdx,!1),this.moveKeyMinTime=Math.min(this.moveKeyMinTime,s[2]),t=i)}this.timeBeforeMove=this.xToTime(s),this.grabbing=!1,this.grabbingTimeBar=!1}}onMouseMove(e,t){let s=e.localX;e.localY;let i=e.track;if(this.movingKeys){let t=this.xToTime(s)-this.timeBeforeMove;if(t+this.moveKeyMinTime<0&&(t=-this.moveKeyMinTime),this.timeBeforeMove=this.timeBeforeMove+t,e.ctrlKey){this.moveKeyMinTime+=t;const e=this.animationClip.tracks;for(let s=0;s<this.lastKeyFramesSelected.length;++s){let o=s;t>0&&(o=this.lastKeyFramesSelected.length-1-s);const[n,a,l]=this.lastKeyFramesSelected[o];if(i=e[n],i&&i.locked)continue;this.canvas.style.cursor="grabbing";const r=this.animationClip.tracks[i.trackIdx].times;r[a]=Math.max(0,r[a]+t),r[a]>this.duration&&this.setDuration(r[a]);let c=a;if(t>0)for(;c<r.length-1&&!(r[c]<r[c+1]);++c)this.swapKeyFrames(i,c+1,c);else for(;c>0&&!(r[c-1]<r[c]);--c)this.swapKeyFrames(i,c-1,c);this.lastKeyFramesSelected[o][1]=c,this.lastKeyFramesSelected[o][2]=r[c]}if(this.onContentMoved)for(let e=0;e<this.lastKeyFramesSelected.length;++e){const[t,s,o]=this.lastKeyFramesSelected[e];i=this.animationClip.tracks[t],i&&i.locked||this.onContentMoved(t,s)}}if(e.altKey&&1&e.buttons){const t=this.animationClip.tracks;let s=-1;for(let o=0;o<this.lastKeyFramesSelected.length;++o){const[n,a,l]=this.lastKeyFramesSelected[o];if(i=t[n],i.locked||1!=i.dim||!i.curves)continue;let r=i.values[a],c=e.deltay*this.keyValuePerPixel*(i.curvesRange[1]-i.curvesRange[0]);i.values[a]=Math.max(i.curvesRange[0],Math.min(i.curvesRange[1],r-c)),i.edited[a]=!0,this.onUpdateTrack&&i.trackIdx!=s&&s>-1&&this.onUpdateTrack([i.trackIdx]),s=i.trackIdx}return void(this.onUpdateTrack&&s>-1&&this.onUpdateTrack([i.trackIdx]))}}if(this.grabbing&&2!=e.button);else if(i){this.unHoverAll();const e=.5*this.keyframeSize;let t=this.getCurrentKeyFrame(i,this.xToTime(s),this.secondsPerPixel*e);if(t>-1){if(i&&i.locked)return;this.lastHovered=[i.trackIdx,t],i.hovered[t]=!0}}else this.unHoverAll()}drawContent(e){if(!this.animationClip)return;e.save();const t=this.trackHeight,s=-this.currentScrollInPixels,i=this.getVisibleItems();let o=s,n=0;o<-this.lastTrackTreesComponentOffset&&(n=Math.floor(-(o+this.lastTrackTreesComponentOffset)/this.trackHeight),o+=n*this.trackHeight),e.translate(0,o);let a=n+Math.ceil((e.canvas.height-this.lastTrackTreesComponentOffset-o)/this.trackHeight);a=a>i.length?i.length:a;for(let s=n;s<a;s++){const o=i[s].treeData.trackData;o&&(1==o.dim&&o.curves?this.drawTrackWithCurves(e,t,o):this.drawTrackWithKeyframes(e,t,o)),e.translate(0,t)}e.restore()}drawTrackWithKeyframes(e,t,s){s.isSelected&&(e.globalAlpha=.2,e.fillStyle=bt.TRACK_SELECTED,e.fillRect(0,0,e.canvas.width,t)),e.fillStyle=bt.KEYFRAME_COLOR,e.globalAlpha=1;const i=s.times,o=this.visualTimeRange[0],n=this.visualTimeRange[1]+1e-7,a=this.keyframeSize/Math.SQRT2,l=this.keyframeSizeHovered/Math.SQRT2;for(let r=0;r<i.length;++r){let c=i[r];if(c<o||c>n)continue;let h=this.timeToX(c),d=a;this.active&&0!=s.active?s.locked?e.fillStyle=bt.KEYFRAME_COLOR_LOCK:s.hovered[r]?(d=l,e.fillStyle=bt.KEYFRAME_COLOR_HOVERED):s.selected[r]?e.fillStyle=bt.KEYFRAME_COLOR_SELECTED:s.edited[r]?e.fillStyle=bt.KEYFRAME_COLOR_EDITED:e.fillStyle=bt.KEYFRAME_COLOR:e.fillStyle=bt.KEYFRAME_COLOR_INACTIVE,e.save(),e.translate(h,.5*t),e.rotate(45*Math.PI/180),e.fillRect(.5*-d,.5*-d,d,d),e.restore()}e.globalAlpha=1}drawTrackWithCurves(e,s,i){i.isSelected&&(e.globalAlpha=.2,e.fillStyle=bt.TRACK_SELECTED_LIGHT,e.fillRect(0,0,e.canvas.width,s)),e.globalAlpha=1;const o=i.times,n=i.values,a=.5*this.keyframeSize,l=.5*this.keyframeSizeHovered,r=i.curvesRange,c=s-2*a,h=this.visualTimeRange[0],d=this.visualTimeRange[1]+1e-7;if(e.strokeStyle=_t.FONT_COLOR_PRIMARY,e.beginPath(),o.length>1){let i=this.timeToX(o[0]),l=n[0];l=t.clamp((l-r[0])/(r[1]-r[0]),0,1)*-c+(s-a),e.moveTo(i,l);for(let i=1;i<o.length;++i){let l=o[i],u=this.timeToX(l),p=n[i];if(p=t.clamp((p-r[0])/(r[1]-r[0]),0,1)*-c+(s-a),l<h)e.moveTo(u,p);else{if(l>d){let l=this.timeToX(o[i-1]),h=u-l;if(h>0){let o=n[i-1];o=t.clamp((o-r[0])/(r[1]-r[0]),0,1)*-c+(s-a);let u=(this.timeToX(d)-l)/h;e.lineTo(l+h*u,o*(1-u)+p*u)}break}e.lineTo(u,p)}}e.stroke()}e.fillStyle=bt.KEYFRAME_COLOR;for(let u=0;u<o.length;++u){let p=o[u];if(p<h||p>d)continue;let m=a,g=this.timeToX(p);this.active&&i.active?i.locked?e.fillStyle=bt.KEYFRAME_COLOR_LOCK:i.hovered[u]?(m=l,e.fillStyle=bt.KEYFRAME_COLOR_HOVERED):i.selected[u]?e.fillStyle=bt.KEYFRAME_COLOR_SELECTED:i.edited[u]?e.fillStyle=bt.KEYFRAME_COLOR_EDITED:e.fillStyle=bt.KEYFRAME_COLOR:e.fillStyle=bt.KEYFRAME_COLOR_INACTIVE;let f=n[u];f=t.clamp((f-r[0])/(r[1]-r[0]),0,1)*-c+(s-a),e.beginPath(),e.arc(g,f,m,0,2*Math.PI),e.fill(),e.closePath()}}_getValidTrackName(e){let t,s=null,i=null;if(e.includes("[")){const s=e.indexOf("[");t=e.substring(s+1).split("].")}else t=e.split(".");return t.length>1?(s=t[0],i=t[1]):i=t[0],[s,i]}updateTrack(e,t){if(!this.animationClip)return!1;const s=this.animationClip.tracks[e];return s.values=t.values,s.times=t.times,s.selected=t.selected??new Array(s.times.length).fill(!1),s.hovered=t.hovered??new Array(s.times.length).fill(!1),s.edited=t.edited??new Array(s.times.length).fill(!1),!0}optimizeTrack(e,t=!1,s=!1){if(!this.animationClip)return;const i=this.animationClip.tracks[e],o=i.times,n=i.values,a=i.dim,l=this.optimizeThreshold;if(i.locked)return;let r=(e,t,s,i)=>Math.abs(e-t)>=i||Math.abs(e-s)>=i,c=0;const h=o.length-1;this.saveState(i.trackIdx);for(let e=1;e<h;++e){let s=!1;if(o[e]!==o[c])if(t)s=!0;else{const t=e*a,i=c*a,o=t+a;for(let e=0;e!==a;++e)if(r(n[t+e],n[i+e],n[o+e],l)){s=!0;break}}if(s&&(++c,e!==c)){o[c]=o[e];const t=e*a,s=c*a;for(let e=0;e!==a;++e)n[s+e]=n[t+e]}}if(o.length>1){++c,o[c]=o[o.length-1];const e=n.length-a,t=c*a;for(let s=0;s!==a;++s)n[t+s]=n[e+s]}c<o.length-1&&(i.times=o.slice(0,c+1),i.values=n.slice(0,(c+1)*a),this.updateTrack(i.trackIdx,i)),this.onOptimizeTracks&&!s&&this.onOptimizeTracks(e)}optimizeTracks(e=!1){if(!this.animationClip)return;if(this.historySaveEnabler)for(let e=0;e<this.animationClip.tracks.length;++e)this.saveState(e,0!=e);const t=this.historySaveEnabler;this.historySaveEnabler=!1;for(let t=0;t<this.animationClip.tracks.length;++t){const s=this.animationClip.tracks[t];this.optimizeTrack(s.trackIdx,e,!0)}this.historySaveEnabler=t,this.onOptimizeTracks&&this.onOptimizeTracks(-1)}historyGenerateTrackStep(e){const t=this.animationClip.tracks[e];return{trackIdx:e,t:t.times.slice(),v:t.values.slice(),edited:t.edited.slice(0,t.times.length)}}historyApplyTrackStep(e,t){const s=this.animationClip.tracks[e.trackIdx],i={trackIdx:e.trackIdx,t:s.times,v:s.values,edited:s.edited};return s.times=e.t,s.values=e.v,s.edited=e.edited,s.selected.length!=s.times.length&&(s.selected.length=s.times.length),s.hovered.length!=s.times.length&&(s.hovered.length=s.times.length),s.selected.fill(!1),s.hovered.fill(!1),i}swapKeyFrames(e,t,s){const i=e.times,o=e.values;let n=i[t];i[t]=i[s],i[s]=n,n=e.hovered[t],e.hovered[t]=e.hovered[s],e.hovered[s]=n,n=e.edited[t],e.edited[t]=e.edited[s],e.edited[s]=n,n=e.selected[t],e.selected[t]=e.selected[s],e.selected[s]=n;let a=t*e.dim,l=a+e.dim,r=s*e.dim;for(;a<l;++a)n=o[a],o[a]=o[r],o[r]=n,++r}copySelectedContent(){if(!this.lastKeyFramesSelected.length)return;this.clipboard=this.clipboard??{},this.clipboard.keyframes={};let e={};const t=this.animationClip.tracks;for(let s=0;s<this.lastKeyFramesSelected.length;s++){let[i,o]=this.lastKeyFramesSelected[s];const n=t[i];e[i]?e[i].idxs.push(o):e[i]={track:n,idxs:[o]},0==s&&this.copyKeyFrameValue(n,o)}for(let t in e)this.copyKeyFrames(e[t].track,e[t].idxs)}copyKeyFrameValue(e,t){const s=t*e.dim,i=this.animationClip.tracks[e.trackIdx].values.slice(s,s+e.dim);this.clipboard=this.clipboard??{},this.clipboard.value={type:e.type,values:i}}copyKeyFrames(e,t){let s=e.trackIdx;this.clipboard=this.clipboard??{},t.sort((e,t)=>e<t?-1:1);let i={track:e,values:[],times:[]};for(let s=0;s<t.length;s++){let o=t[s],n=o*e.dim,a=e.values.slice(n,n+e.dim);i.values.push(a),i.times.push(e.times[o])}this.clipboard.keyframes[s]=i}canPasteKeyFrame(){return null!=this.clipboard}#t(e,t,s){const i=t*e.dim;let o=0;for(let t=i;t<i+e.dim;++t)e.values[t]=s[o],++o;e.edited[t]=!0}pasteContentValue(){if(!this.clipboard)return!1;if(this.clipboard.value&&1==this.lastKeyFramesSelected.length){let[e,t]=this.lastKeyFramesSelected[0];return this.pasteKeyFrameValue(this.animationClip.tracks[e],t),!0}return!1}pasteContent(e=this.currentTime){if(!this.clipboard)return!1;if(this.clipboard.keyframes){for(let e in this.clipboard.keyframes){const t=this.animationClip.tracks[e];if(-1==this.selectedItems.findIndex(e=>e.isTrack?e===t:e===t.groupId))return!1}this.pasteKeyFrames(e)}return!0}pasteKeyFrameValue(e,t){e.locked||this.clipboard.value.type!=e.type||(this.saveState(e.trackIdx),this.#t(e,t,this.clipboard.value.values),this.onUpdateTrack&&this.onUpdateTrack([e.trackIdx]))}pasteKeyFrames(e=this.currentTime){if(!this.clipboard.keyframes)return!1;this.unHoverAll(),this.deselectAllKeyFrames();let t=this.clipboard.keyframes,s=1/0;for(let e in t)s>t[e].times[0]&&(s=t[e].times[0]);if(s==1/0)return!1;const i=this.onUpdateTrack;this.onUpdateTrack=null;const o=this.historySaveEnabler;let n=0;for(let i in t){const t=this.clipboard.keyframes[i],a=t.times,l=t.values,r=this.animationClip.tracks[i];r.locked||(this.saveState(r.trackIdx,Boolean(n++)),this.historySaveEnabler=!1,this.addKeyFrames(r.trackIdx,l,a,-s+e,_t.ADDKEY_VALUESINARRAYS),this.historySaveEnabler=o)}return i&&(this.onUpdateTrack=i,this.onUpdateTrack(Object.keys(t))),!0}addKeyFrames(e,t,s,i=0,o=0){const n=this.animationClip.tracks[e];if(!s.length||n.locked)return null;const a=n.dim,l=n.times,r=n.values,c=new Float32Array(l.length+s.length),h=new Float32Array(r.length+s.length*a);this.saveState(e);let d=s.length-1,u=l.length-1,p=[];if(_t.ADDKEY_VALUESINARRAYS&o)for(let e=c.length-1;e>-1;--e){if(u<0||d>-1&&l[u]<s[d]+i){const o=t[d];for(let t=0;t<a;++t)h[e*a+t]=o[t];c[e]=s[d--]+i,n.hovered.splice(u+1,0,!1),n.selected.splice(u+1,0,!1),n.edited.splice(u+1,0,!0),p.push(e);continue}for(let t=0;t<a;++t)h[e*a+t]=r[u*a+t];c[e]=l[u--]}else for(let e=c.length-1;e>-1;--e)if(u<0||d>-1&&l[u]<s[d]+i){for(let s=0;s<a;++s)h[e*a+s]=t[d*a+s];c[e]=s[d--]+i,n.hovered.splice(u+1,0,!1),n.selected.splice(u+1,0,!1),n.edited.splice(u+1,0,!0),p.push(e)}else{for(let t=0;t<a;++t)h[e*a+t]=r[u*a+t];c[e]=l[u--]}return n.times=c,n.values=h,s[s.length-1]+i>this.duration&&this.setDuration(s[s.length-1]+i),this.onUpdateTrack&&this.onUpdateTrack([e]),p}deleteSelectedContent(e=!1){if(!this.lastKeyFramesSelected.length)return;const t=this.animationClip.tracks,s=this.lastKeyFramesSelected[0][0];let i=s,o=[];const n=this.historySaveEnabler,a=this.lastKeyFramesSelected.length;for(let l=0;l<a;++l){const[a,r]=this.lastKeyFramesSelected[l];t[a].locked?t[a].selected[r]=!1:(i!=a&&(this.saveState(i,i!=s),this.historySaveEnabler=!1,this.deleteKeyFrames(i,o,e),this.historySaveEnabler=n,i=a,o.length=0),o.push(r))}this.saveState(i,i!=s),this.historySaveEnabler=!1,this.deleteKeyFrames(i,o,e),this.historySaveEnabler=n,this.lastKeyFramesSelected=[]}deleteKeyFrames(e,t,s=!1){const i=this.animationClip.tracks[e];if(!t.length||i.locked)return!1;this.saveState(e);const o=i.times.length,n=i.times.length-t.length,a=i.times.slice(0,n),l=i.values.slice(0,n*i.dim);let r=t[0],c=t[0]*i.dim;for(let e=0;e<t.length;++e){i.edited.splice(r,1),i.selected.splice(r,1),i.hovered.splice(r,1);const s=t[e],n=e<t.length-1?t[e+1]:o,h=n*i.dim;for(let e=(s+1)*i.dim;e<h;++e)l[c++]=i.values[e];for(let e=s+1;e<n;++e)a[r++]=i.times[e]}return i.times=a,i.values=l,this.onDeleteKeyFrames&&!s&&this.onDeleteKeyFrames(e,t),a[a.length-1]>this.duration&&this.setDuration(a[a.length-1]),!0}getNearestKeyFrame(e,t,s=0){if(!e||!e.times||!e.times.length)return-1;const i=e.times;let o=0,n=i.length-1;if(i[o]>t)return-1==s?-1:0;if(i[n]<t)return 1==s?-1:n;let a=Math.floor((o+n)/2);for(;o<a&&a<n;)t<i[a]?n=a:o=a,a=Math.floor((o+n)/2);return 0==s?Math.abs(t-i[o])<Math.abs(t-i[n])?o:n:-1==s?i[n]==t?n:o:i[o]==t?o:n}getCurrentKeyFrame(e,t,s=0){if(!e||!e.times.length)return-1;let i=this.getNearestKeyFrame(e,t);return i>-1&&(i=Math.abs(e.times[i]-t)>s?-1:i),i}getKeyFramesInRange(e,t,s,i=0){if(!e||!e.times.length)return null;if(t>s){let e=t;t=s,s=e}const o=this.getNearestKeyFrame(e,t-i,1),n=this.getNearestKeyFrame(e,s+i,-1);return-1==n||-1==o?null:[o,n]}unHoverAll(){this.lastHovered&&(this.animationClip.tracks[this.lastHovered[0]].hovered[this.lastHovered[1]]=!1);let e=this.lastHovered;return this.lastHovered=null,e}deselectAllKeyFrames(){for(let[e,t]of this.lastKeyFramesSelected)this.animationClip.tracks[e].selected[t]=!1;const e=this.lastKeyFramesSelected.length>0;return this.lastKeyFramesSelected.length=0,e}isKeyFrameSelected(e,t){return e.selected[t]}selectKeyFrame(e,t,s=!1){const i=this.animationClip.tracks[e];if(i.locked||!i.active||i.selected[t])return null;const o=[i.trackIdx,t,i.times[t]];let n=0;for(;n<this.lastKeyFramesSelected.length;++n){let s=this.lastKeyFramesSelected[n];if(s[0]>e||s[0]==e&&s[1]>t)break}return this.lastKeyFramesSelected.splice(n,0,o),i.selected[t]=!0,this.onSelectKeyFrame&&!s&&this.onSelectKeyFrame(o),o}deselectKeyFrame(e,t){const s=this.animationClip.tracks[e];if(s.locked||!s.active||!s.selected[t])return!1;s.selected[t]=!1;for(let s=0;s<this.lastKeyFramesSelected.length;++s){const i=this.lastKeyFramesSelected[s];if(i[0]===e&&i[1]===t){this.lastKeyFramesSelected.splice(s,1);break}}return!0}getNumKeyFramesSelected(){return this.lastKeyFramesSelected.length}processSelectionKeyFrame(e,t,s=!1){const i=this.animationClip.tracks[e];i.locked||(s||this.deselectAllKeyFrames(),this.selectKeyFrame(e,t),s||this.setTime(i.times[t]))}clearTrack(e){const t=this.animationClip.tracks[e];if(this.unHoverAll(),this.deselectAllKeyFrames(),!t.locked)return this.saveState(t.trackIdx),t.times=t.times.slice(0,0),t.values=t.values.slice(0,0),t.edited.length=0,t.hovered.length=0,t.selected.length=0,e}}t.KeyFramesTimeline=_t;class xt extends bt{static CLONEREASON_COPY=1;static CLONEREASON_PASTE=2;static CLONEREASON_HISTORY=3;static CLONEREASON_TRACKCLONE=4;lastClipsSelected=[];lastTrackClipsMove=0;dragClipMode="";lastHovered=null;onSelectClip=null;onContentMoved=null;onDeleteSelectedClips=null;onDeleteClip=null;constructor(e,s={}){super(e,s),this.lastClipsSelected=[],this.lastTrackClipsMove=0,this.dragClipMode="",this.setAnimationClip(this.animationClip),this.onDblClick=e=>{const t=e.track,s=e.localX;if(t){const e=this.getClipOnTime(t,this.xToTime(s),.001);this.selectClip(t.trackIdx,e)}},this.onShowContextMenu=e=>{e.preventDefault(),e.stopPropagation();let s=[];this.lastClipsSelected.length?(s.push({title:"Copy",callback:()=>{this.copySelectedContent()}}),s.push({title:"Delete",callback:()=>{this.deleteSelectedContent()}})):this.clipboard&&(s.push({title:"Paste",callback:()=>{this.pasteContent()}}),s.push({title:"Paste Here",callback:()=>{this.pasteContent(this.xToTime(e.localX))}})),t.addContextMenu("Options",e,e=>{for(let t=0;t<s.length;t++)e.add(s[t].title,s[t].callback)})}}instantiateAnimationClip(e,t=!1){const s=super.instantiateAnimationClip(e);if(e&&e.tracks)for(let i=0;i<e.tracks.length;++i){const o=this.instantiateTrack(e.tracks[i],t);o.trackIdx=s.tracks.length,s.tracks.push(o)}return s}instantiateTrack(e={},t=!1){const s=super.instantiateTrack(e);s.trackIdx=this.animationClip.tracks.length,s.selected=[],s.edited=[],s.hovered=[],e.clips?s.clips=t?this.cloneClips(e.clips,0,xt.CLONEREASON_TRACKCLONE):e.clips:s.clips=[];const i=s.clips.length;e.selected&&e.selected.length==i?s.selected=t?e.selected.slice():e.selected:s.selected=new Array(i).fill(!1),e.edited&&e.edited.length==i?s.edited=t?e.edited.slice():e.edited:s.edited=new Array(i).fill(!1),e.hovered&&e.hovered.length==i?s.hovered=t?e.hovered.slice():e.hovered:s.hovered=new Array(i).fill(!1);for(let e=0;e<s.clips.length;++e)s.clips[e].active=s.clips[e].active??!0;return s}instantiateClip(e={}){return{id:e.id??e.name??"clip",start:e.start??0,duration:e.duration??1,fadein:e.fadein??void 0,fadeout:e.fadeout??void 0,clipColor:e.clipColor??t.getThemeColor("global-color-accent"),fadeColor:e.fadeColor??null,active:e.active??!0,trackIdx:-1}}addNewTrack(e={},t=!0,s=!1){const i=this.instantiateTrack(e??{});return i.trackIdx=this.animationClip.tracks.length,this.animationClip.tracks.push(i),this.onAddNewTrack&&!s&&this.onAddNewTrack(i,e),this.selectedItems.push(i),t&&this.updateLeftPanel(),i.trackIdx}setAnimationClip(e,t=!0){return super.setAnimationClip(e,t),this.changeSelectedItems(),this.animationClip}deselectAllElements(){this.deselectAllClips(),this.unHoverAll()}changeSelectedItems(){this.deselectAllElements(),this.deselectAllTracks(!1),this.selectedItems=this.animationClip.tracks.slice(),this.updateLeftPanel()}unHoverAll(){this.lastHovered&&(this.animationClip.tracks[this.lastHovered[0]].hovered[this.lastHovered[1]]=!1);let e=this.lastHovered;return this.lastHovered=null,e}onMouseUp(e){let t=e.track,s=e.localX,i=e.discard;if(e.shiftKey){if(i){if(this.boxSelection){let e=this.getTracksInRange(this.boxSelectionStart[1],this.boxSelectionEnd[1]);for(let t of e){let e=this.getClipsInRange(t,this.xToTime(this.boxSelectionStart[0]),this.xToTime(this.boxSelectionEnd[0]),1e-6);if(e)for(let s of e)this.selectClip(t.trackIdx,s,!1)}}}else if(t){let e=this.getClipOnTime(t,this.xToTime(s),5*this.secondsPerPixel);e>-1&&(t.selected[e]?this.deselectClip(t.trackIdx,e):this.selectClip(t.trackIdx,e,!1))}}else{let o=this.canvas.getBoundingClientRect();if(e.y<o.top||e.y>o.bottom)return;if(!i&&t&&2!=e.button){const e=this.getClipOnTime(t,this.xToTime(s),.001);this.selectClip(t.trackIdx,e)}}this.movingKeys=!1}onMouseDown(e,t){let s=e.localX;e.localY;let i=e.track;if(!(e.button>0))if(e.ctrlKey&&i){let t=e.offsetX;const s=this.lastClipsSelected;this.canvas.style.cursor="grab";let i=-1;this.lastTrackClipsMove=Math.floor((e.localY-this.topMargin+this.trackTreesPanel.root.scrollTop)/this.trackHeight);for(let e=0;e<s.length;e++){let[o,n]=s[e];const a=this.animationClip.tracks[o].clips[n];let l=this.timeToX(a.start+a.duration);Math.abs(l-t)<5?(this.dragClipMode="duration",this.canvas.style.cursor="column-resize"):this.dragClipMode="move",i!=o&&(this.saveState(o,-1!=i),i=o)}this.movingKeys=!0}else if(!i||i&&-1==this.getClipOnTime(i,t,.001))this.lastClipsSelected.length&&(this.deselectAllClips(),this.onSelectClip&&this.onSelectClip(null));else if(i&&("duration"==this.dragClipMode||"fadein"==this.dragClipMode||"fadeout"==this.dragClipMode)){const e=this.getClipOnTime(i,this.xToTime(s),.001);this.selectClip(i.trackIdx,e),this.lastClipsSelected.length&&this.saveState(i.trackIdx),this.movingKeys=!0}}onMouseMove(e,t){if(!this.grabbingTimeBar&&!this.grabbingScroll){if(this.grabbing&&2!=e.buttons){this.unHoverAll();let s=t-this.grabTime;if(this.grabTime=t,t<0&&s>0&&(s=0),"move"!=this.dragClipMode&&1==this.lastClipsSelected.length){const e=this.animationClip.tracks[this.lastClipsSelected[0][0]];let t=e.clips[this.lastClipsSelected[0][1]];if("fadein"==this.dragClipMode)t.fadein=Math.min(Math.max(t.fadein+s,t.start),t.fadeout??t.start+t.duration);else if("fadeout"==this.dragClipMode)t.fadeout=Math.max(Math.min(t.fadeout+s,t.start+t.duration),t.fadein??t.start);else if("duration"==this.dragClipMode){let i=Math.max(0,t.duration+s);this.lastClipsSelected[0][1]<e.clips.length-1&&(i=Math.min(e.clips[this.lastClipsSelected[0][1]+1].start-t.start-1e-4,i)),t.duration=i,null!=t.fadeout&&(t.fadeout=Math.max(Math.min((t.fadeout??t.start+t.duration)+s,t.start+t.duration),t.start)),null!=t.fadein&&(t.fadein=Math.max(Math.min(t.fadein??t.start+t.duration,t.fadeout??t.start+t.duration),t.start)),this.duration<t.start+t.duration&&this.setDuration(t.start+t.duration)}this.onContentMoved&&this.onContentMoved(t,0)}else if("move"==this.dragClipMode&&this.lastClipsSelected.length){const i=this.lastTrackTreesComponentOffset;let o=Math.floor((e.localY-i)/this.trackHeight);if(e.altKey){let e=o-this.lastTrackClipsMove;if(this.lastClipsSelected[0][0]+e<0&&(e=-this.lastClipsSelected[0][0]),0!=e){for(let t=0;t<this.lastClipsSelected.length;++t){const s=this.animationClip.tracks[this.lastClipsSelected[t][0]],i=this.animationClip.tracks[this.lastClipsSelected[t][0]+e],n=s.clips[this.lastClipsSelected[t][1]],a=this.getClipsInRange(i,n.start,n.start+n.duration,1e-4);if(a)for(let s=0;s<a.length;++s)i.selected[a[s]]||(s=a.length,t=this.lastClipsSelected.length,e=0,o=this.lastTrackClipsMove)}if(0!=e){let t=this.historySaveEnabler;this.historySaveEnabler=!1;const s=this.lastClipsSelected;this.lastClipsSelected=[];for(let t=s[s.length-1][0]+e-this.animationClip.tracks.length+1;t>0;--t)this.addNewTrack(null,1==t),1==t&&this.updateLeftPanel();let i=e>0?s.length-1:0,o=i,n=s[i][0];for(let t=1;t<=s.length;++t){let a=e>0?s.length-1-t:t;if(t==s.length||s[a][0]!=n){const l=n+e,r=this.animationClip.tracks[l],c=this.animationClip.tracks[n],h=this.historyUndo[this.historyUndo.length-1];let d=0;for(;d<h.length&&l!=h[d].trackIdx;++d);d==h.length&&(this.historySaveEnabler=!0,this.saveState(l,!0),this.historySaveEnabler=!1);for(let e=i;e<=o;++e){let t=this.addClip(c.clips[s[e][1]],l,0);s[e][0]=t,r.selected[t]=!0}for(let e=o;e>=i;--e)this.#s(n,s[e][1]),s[e][1]=s[e][0],s[e][0]=l;n=t<s.length?s[a][0]:-1,i=a,o=a;continue}e>0?i=a:o=a}this.lastClipsSelected=s,this.historySaveEnabler=t}}}this.lastTrackClipsMove=o;let n=s,a=!0;for(let e=0;e<this.lastClipsSelected.length;++e){let t=this.lastClipsSelected[e][0],i=this.lastClipsSelected[e][1];const o=this.animationClip.tracks[t],l=o.clips,r=o.clips[i];if(s>=0){if(l.length-1==i)continue;if(!o.selected[i+1]){if(l[i+1].start>=r.start+r.duration+s)continue;const e=l[i+1];n=Math.max(0,Math.min(n,e.start-r.start-r.duration))}}else if(s<0){if(i>0&&l[i-1].start+l[i-1].duration<=r.start+s)continue;if(i>0){const e=l[i-1];n=Math.min(0,Math.max(n,e.start+e.duration-r.start))}r.start+s<0&&(n=Math.max(n,-r.start),a=!1)}if(!a)continue;let c=this.getClipsInRange(o,r.start+s,r.start+r.duration+s,.01);if(c&&(c[0]!=i||c[c.length-1]!=i))for(let e=0;e<c.length;++e)if(!o.selected[c[e]]){a=!1;break}}a&&(n=s),this.grabTime=t-s+n;for(let e=0;e<this.lastClipsSelected.length;++e){const t=this.lastClipsSelected[s>0?this.lastClipsSelected.length-1-e:e],i=this.animationClip.tracks[t[0]],o=i.clips;let a=t[1];const l=i.clips[a];l.start+=n,null!=l.fadein&&(l.fadein+=n),null!=l.fadeout&&(l.fadeout+=n);const r=i.edited[a],c=i.selected[a],h=i.hovered[a];if(s>0)for(;a<o.length-1&&!(o[a+1].start>=l.start);)o[a]=o[a+1],i.selected[a]=i.selected[a+1],i.edited[a]=i.edited[a+1],i.hovered[a]=i.hovered[a+1],a++;else for(;a>0&&!(o[a-1].start<=l.start);)o[a]=o[a-1],i.selected[a]=i.selected[a-1],i.edited[a]=i.edited[a-1],i.hovered[a]=i.hovered[a-1],a--;o[a]=l,i.edited[a]=r,i.selected[a]=c,i.hovered[a]=h,t[1]=a,l.start+l.duration>this.duration&&this.setDuration(l.start+l.duration),this.onContentMoved&&this.onContentMoved(l,n)}}return!0}if(e.track&&0==e.buttons){this.unHoverAll();let s=this.getClipsInRange(e.track,t,t,1e-5);if(!e.track.locked&&s){this.lastHovered=[e.track.trackIdx,s[0]],e.track.hovered[s[0]]=!0;let t=e.track.clips[s[0]];if(!t)return;Math.abs(e.localX-this.timeToX(t.start+t.duration))<8?(this.canvas.style.cursor="col-resize",this.dragClipMode="duration"):null!=t.fadein&&Math.abs(e.localX-this.timeToX(t.fadein))<8?(this.canvas.style.cursor="e-resize",this.dragClipMode="fadein"):null!=t.fadeout&&Math.abs(e.localX-this.timeToX(t.fadeout))<8?(this.canvas.style.cursor="e-resize",this.dragClipMode="fadeout"):this.dragClipMode=""}}else this.unHoverAll()}}drawContent(e){if(!this.animationClip)return;const t=this.animationClip.tracks,s=this.trackHeight,i=-this.currentScrollInPixels;e.save();for(let o=0;o<t.length;o++){let n=t[o];this.drawTrackWithBoxes(e,o*s+i,s,n)}e.restore()}drawTrackWithBoxes(e,t,s,i){e.globalAlpha=.2,e.fillStyle=bt.TRACK_SELECTED_LIGHT,i.isSelected&&e.fillRect(0,t,e.canvas.width,s);const o=i.clips,n=.4*s*.5;s*=.6;let a=null;e.font=Math.floor(.8*s)+"px"+bt.FONT,e.textAlign="left",e.textBaseline="middle";for(var l=0;l<o.length;++l){a=null;const d=o[l];var r=Math.floor(this.timeToX(d.start))+.5,c=Math.floor(this.timeToX(d.start+d.duration))+.5,h=c-r;if(c<0||r>this.canvas.width)continue;if(e.globalAlpha=1,e.fillStyle=d.clipColor||(i.hovered[l]?bt.KEYFRAME_COLOR_HOVERED:i.selected[l]?bt.TRACK_SELECTED:bt.KEYFRAME_COLOR),this.active&&i.active&&d.active||(e.fillStyle=bt.KEYFRAME_COLOR_INACTIVE),Lt(e,r,t+n,h,s,5,!0),this.active&&i.active&&d.active){if(e.fillStyle=d.fadeColor??"#0004",null!=d.fadein){Lt(e,r,t+n,this.pixelsPerSecond*(d.fadein-d.start),s,{tl:5,bl:5,tr:0,br:0},!0)}if(null!=d.fadeout){const i=this.pixelsPerSecond*(d.start+d.duration-d.fadeout);Lt(e,r+h-i,t+n,i,s,{tl:0,bl:0,tr:5,br:5},!0)}}e.fillStyle=bt.TRACK_COLOR_PRIMARY,(i.selected[l]||i.hovered[l])&&(e.strokeStyle=e.shadowColor=d.clipColor||bt.TRACK_SELECTED,e.shadowBlur=10,e.shadowOffsetX=1.5,e.shadowOffsetY=1.5,a=[r-1,t+n-1,c-r+2,s+2],Lt(e,a[0],a[1],a[2],a[3],5,!1,!0),e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.font="bold"+Math.floor(s)+"px "+bt.FONT,e.fillStyle=bt.FONT_COLOR_PRIMARY);let u=d.id??"";let p=e.measureText(u).width;if(p>h&&p>0){let e=Math.floor(h*u.length/p);u=u.substr(0,e),p=h}e.fillText(u,r+.5*(h-p),t+n+.5*s),e.fillStyle=i.hovered[l]?"white":"#f5f5f5",e.strokeStyle="rgba(125,125,125,0.4)",Lt(e,r+h-8,t+n,8,s,{tl:4,bl:4,tr:4,br:4},!0,!0)}e.font="12px"+bt.FONT}optimizeTrack(e){}optimizeTracks(){}addClip(e,s=-1,i=0,o=0){if(!this.animationClip)return-1;this.deselectAllElements();let n=e.start+i;if(null!=e.fadein&&(e.fadein+=n-e.start),null!=e.fadeout&&(e.fadeout+=n-e.start),e.start=n,e.active=e.active??!0,s>=this.animationClip.tracks.length)s=this.addNewTrack();else if(s<0){for(let i=o;i<this.animationClip.tracks.length;i++){if(!this.animationClip.tracks[i].clips.find(s=>t.compareThresholdRange(n,e.start+e.duration,s.start,s.start+s.duration))){s=i;break}}s<0&&(s=this.addNewTrack())}e.trackIdx=s;const a=this.animationClip.tracks[s];let l=a.clips.findIndex(e=>e.start>n);return l<0&&(l=a.clips.length),this.saveState(s),a.clips.splice(l,0,e),a.hovered.splice(l,0,!1),a.selected.splice(l,0,!1),a.edited.splice(l,0,!1),(!this.animationClip||e.start+e.duration>this.duration)&&this.setDuration(e.start+e.duration),this.onUpdateTrack&&this.onUpdateTrack([s]),l}addClips(e,s=0,i=0){if(!this.animationClip||!e.length)return!1;let o=new Int16Array(e.length),n=i-1,a=-1;const l=this.animationClip.tracks,r=l.length;let c=0;for(;c<e.length;++c){const i=e[c],r=i.start+s,h=r+i.duration;if(0==c){for(++n,a=n;a>=l.length;)this.addNewTrack(null,!1);if(l[n].clips.find(e=>t.compareThresholdRange(r,h,e.start,e.start+e.duration))){c=-1;continue}o[c]=n}else{let i=l[a].clips.find(e=>t.compareThresholdRange(r,h,e.start,e.start+e.duration));for(let n=c-1;n>-1&&(o[n]==a&&!i);--n)i=t.compareThresholdRange(r,h,e[n].start+s,e[n].start+s+e[n].duration);if(i&&(++a,a>=l.length&&this.addNewTrack(null,!1),i=l[a].clips.find(e=>t.compareThresholdRange(r,h,e.start,e.start+e.duration))),i){c=-1;continue}o[c]=a}}r!=l.length&&this.updateLeftPanel();for(let e=n;e<=a;++e)this.saveState(e,e!=n);let h=this.historySaveEnabler;for(this.historySaveEnabler=!1,c=0;c<e.length;++c)this.addClip(e[c],o[c],s);return this.historySaveEnabler=h,!0}deleteSelectedContent(e=!1){if(!this.lastClipsSelected.length)return;const t=this.lastClipsSelected;this.lastClipsSelected=[];let s=-1;for(let e=t.length-1;e>-1;--e){let i=t[e];i[0]!=s&&(this.saveState(i[0],-1!=s),s=i[0]),this.#s(i[0],i[1])}this.onDeleteSelectedClips&&!e&&this.onDeleteSelectedClips(t)}deleteClip(e,t,s=!1){this.saveState(e);const i=this.#s(e,t);this.onDeleteClip&&!s&&this.onDeleteClip(e,t,i)}#s(e,t){const s=this.animationClip.tracks[e];for(let s=0;s<this.lastClipsSelected.length;s++){const[i,o]=this.lastClipsSelected[s];if(i==e)o==t?this.lastClipsSelected.splice(s--,1):o>t&&this.lastClipsSelected[s][1]--;else if(e<i)break}this.lastHovered&&this.lastHovered[0]==e&&(this.lastHovered[1]==t?this.unHoverAll():this.lastHovered[1]>t&&this.lastHovered[1]--);const i=s[t];return s.hovered.splice(t,1),s.selected.splice(t,1),s.edited.splice(t,1),s.clips.splice(t,1),i}cloneClips(e,t,s=0){let i=JSON.parse(JSON.stringify(e));for(let e=0;e<i.length;++e){let s=i[e];s.start+=t,null==s.fadein||null==s.fadein?s.fadein=void 0:s.fadein+=t,null==s.fadeout||null==s.fadeout?s.fadeout=void 0:s.fadeout+=t}return i}copySelectedContent(){if(0==this.lastClipsSelected.length)return;let e=[];const t=this.lastClipsSelected,s=this.animationClip.tracks;let i=1/0;for(let o=0;o<t.length;++o){let n=s[t[o][0]].clips[t[o][1]];e.push(n),i>n.start&&(i=n.start)}i=Math.max(0,i),this.clipboard=this.cloneClips(e,-i,xt.CLONEREASON_COPY)}pasteContent(e=this.currentTime){if(this.deselectAllClips(),!this.clipboard)return;e=Math.max(0,e);let t=this.cloneClips(this.clipboard,e,xt.CLONEREASON_PASTE);this.addClips(t,0)}clearTrack(e){if(!this.animationClip)return void(this.animationClip={tracks:[]});if(this.saveState(e),this.animationClip.tracks[e].locked)return;const t=this.animationClip.tracks[e];t.selected=[],t.edited=[],t.hovered=[],t.clips=[];for(let t=0;t<this.lastClipsSelected.length;t++){const[s,i]=this.lastClipsSelected[t];if(s==e)this.lastClipsSelected.splice(t--,1);else if(e<s)break}this.lastHovered&&this.lastHovered[0]==e&&this.unHoverAll()}historyGenerateTrackStep(e){const t=this.animationClip.tracks[e],s=this.cloneClips(t.clips,0,xt.CLONEREASON_HISTORY);for(let t=0;t<s.length;++t)s[t].trackIdx=e;return{trackIdx:e,clips:s,edited:t.edited.slice(0,t.clips.length)}}historyApplyTrackStep(e,t){const s=this.animationClip.tracks[e.trackIdx],i={trackIdx:e.trackIdx,clips:s.clips,edited:s.edited};s.clips=e.clips,s.edited=e.edited,s.selected.length<s.clips.length&&(s.selected.length=s.clips.length),s.hovered.length<s.clips.length&&(s.hovered.length=s.clips.length),s.selected.fill(!1),s.hovered.fill(!1);for(let e=0;e<s.clips.length;++e)s.clips[e].active=s.clips[e].active??!0;return i}getClipOnTime(e,t,s){if(!e||!e.clips.length)return-1;if(t+s<e.clips[0].start)return-1;for(let i=0;i<e.clips.length;++i){let o=e.clips[i];if(o.start+o.duration>=t-s&&o.start<=t+s)return i}return-1}deselectAllClips(){for(let[e,t]of this.lastClipsSelected)this.animationClip.tracks[e].selected[t]=!1;const e=this.lastClipsSelected.length>0;return this.lastClipsSelected.length=0,e}selectAll(e=!1){this.deselectAllClips();for(let e=0;e<this.animationClip.tracks.length;e++)for(let t=0;t<this.animationClip.tracks[e].clips.length;t++)this.animationClip.tracks[e].selected[t]=!0,this.lastClipsSelected.push([e,t]);this.onSelectClip&&!e&&this.onSelectClip(null)}selectClip(e,t,s=!0,i=!1){if(s&&this.deselectAllClips(),t<0)return-1;const o=this.animationClip.tracks[e];if(o.selected[t])return t;let n=0;for(;n<this.lastClipsSelected.length;++n){let e=this.lastClipsSelected[n];if(!(e[0]<o.trackIdx)&&(e[0]>o.trackIdx||e[1]>t))break}return this.lastClipsSelected.splice(n,0,[o.trackIdx,t,o.clips[t]]),o.selected[t]=!0,!i&&this.onSelectClip&&this.onSelectClip(o.clips[t]),t}deselectClip(e,t){if(-1==t)return-1;const s=this.animationClip.tracks[e];if(!s.selected[t])return-1;s.selected[t]=!1;for(let s=0;s<this.lastClipsSelected.length;++s){let i=this.lastClipsSelected[s];if(i[0]==e&&i[1]==t){this.lastClipsSelected.splice(s,1);break}}return t}getClipsInRange(e,t,s,i=0){if(!e||!e.clips.length)return null;if(t>s){let e=t;t=s,s=e}t-=i,s+=i,t-=i,s+=i;const o=e.clips;if(s<o[0].start||t>o[o.length-1].start+o[o.length-1].duration)return null;let n=[];for(let e=0;e<o.length;++e){const i=o[e];if(!(i.start+i.duration<t)){if(i.start>s)break;n.push(e)}}return n.length?n:null}validateDuration(e){for(let t=0;t<this.animationClip.tracks.length;t++){const s=this.animationClip.tracks[t];if(s.clips.length){const t=s.clips[s.clips.length-1];e=Math.max(e,t.start+t.duration)}}return e}setDuration(e,t=!1,s=!0){const i=e,o=this.validateDuration(e);super.setDuration(o,t,i!=o||s)}}function Lt(e,t,s,i,o,n=5,a=!1,l=!1){if("number"==typeof n)n={tl:n,tr:n,br:n,bl:n};else{var r={tl:0,tr:0,br:0,bl:0};for(var c in r)n[c]=n[c]??r[c]}e.beginPath(),e.moveTo(t+n.tl,s),e.lineTo(t+i-n.tr,s),e.quadraticCurveTo(t+i,s,t+i,s+n.tr),e.lineTo(t+i,s+o-n.br),e.quadraticCurveTo(t+i,s+o,t+i-n.br,s+o),e.lineTo(t+n.bl,s+o),e.quadraticCurveTo(t,s+o,t,s+o-n.bl),e.lineTo(t,s+n.tl),e.quadraticCurveTo(t,s,t+n.tl,s),e.closePath(),a&&e.fill(),l&&e.stroke()}if(t.ClipsTimeline=xt,!t)throw"Missing LX namespace!";t.extensions.push("VideoEditor");const St=t.vec2;t.Area,t.Panel;class kt{static TIMEBAR_PLAY=1;static TIMEBAR_TRIM=2;static BACKGROUND_COLOR=t.getThemeColor("global-branch-darker");static COLOR=t.getThemeColor("global-button-color");static ACTIVE_COLOR="#668ee4";type=kt.TIMEBAR_PLAY;duration=1;canvas;ctx;markerWidth=8;markerHeight;offset;lineWidth;lineHeight;position;startX;endX;currentX;hovering;dragging;onChangeCurrent;onChangeStart;onChangeEnd;onDraw;onMouse;constructor(e,s,i={}){this.type=s??kt.TIMEBAR_PLAY,this.duration=i.duration??this.duration,this.canvas=document.createElement("canvas"),this.canvas.width=e.size[0],this.canvas.height=e.size[1],e.attach(this.canvas),this.ctx=this.canvas.getContext("2d"),this.markerWidth=i.markerWidth??this.markerWidth,this.markerHeight=i.markerHeight??.5*this.canvas.height,this.offset=i.offset||.5*this.markerWidth+5,this.lineWidth=this.canvas.width-2*this.offset,this.lineHeight=i.barHeight??5,this.position=new St(this.offset,.5*this.canvas.height-.5*this.lineHeight),this.startX=this.position.x,this.endX=this.position.x+this.lineWidth,this.currentX=this.startX,this._draw(),this.updateTheme(),t.addSignal("@on_new_color_scheme",()=>{this.updateTheme()}),this.canvas.onmousedown=e=>this.onMouseDown(e),this.canvas.onmousemove=e=>this.onMouseMove(e),this.canvas.onmouseup=e=>this.onMouseUp(e)}updateTheme(){kt.BACKGROUND_COLOR=t.getThemeColor("global-color-secondary"),kt.COLOR=t.getThemeColor("global-color-quaternary"),kt.ACTIVE_COLOR="#668ee4"}setDuration(e){this.duration=e}xToTime(e){return(e-this.offset)/this.lineWidth*this.duration}timeToX(e){return e/this.duration*this.lineWidth+this.offset}setCurrentTime(e){this.currentX=this.timeToX(e),this.onSetCurrentValue(this.currentX)}setStartTime(e){this.startX=this.timeToX(e),this.onSetStartValue(this.startX)}setEndTime(e){this.endX=this.timeToX(e),this.onSetEndValue(this.endX)}onSetCurrentValue(e){this.update(e);const t=this.xToTime(e);this.onChangeCurrent&&this.onChangeCurrent(t)}onSetStartValue(e){this.update(e);const t=this.xToTime(e);this.onChangeStart&&this.onChangeStart(t)}onSetEndValue(e){this.update(e);const t=this.xToTime(e);this.onChangeEnd&&this.onChangeEnd(t)}_draw(){const e=this.ctx;e&&(e.save(),e.fillStyle=kt.BACKGROUND_COLOR,e.clearRect(0,0,this.canvas.width,this.canvas.height),e.fillRect(0,0,this.canvas.width,this.canvas.height),e.fillStyle=kt.COLOR,e.fillRect(this.position.x,this.position.y,this.lineWidth,this.lineHeight),e.fillStyle=kt.ACTIVE_COLOR,e.fillRect(this.startX,this.position.y,this.endX-this.startX,this.lineHeight),e.restore(),this._drawTrimMarker("start",this.startX,{color:null,fillColor:kt.ACTIVE_COLOR||"#5f88c9"}),this._drawTrimMarker("end",this.endX,{color:null,fillColor:kt.ACTIVE_COLOR||"#5f88c9"}),this._drawTimeMarker("current",this.currentX,{color:"#e5e5e5",fillColor:kt.ACTIVE_COLOR||"#5f88c9",width:this.markerWidth}),this.onDraw&&this.onDraw())}_drawTrimMarker(e,t,s={}){const i=this.markerWidth,o=this.markerHeight,n=.5*this.canvas.height-.5*o,a=this.ctx;a&&(this.hovering==e&&(a.shadowColor="white",a.shadowBlur=2),a.globalAlpha=1,a.fillStyle=a.strokeStyle=s.fillColor||"#111",a.beginPath(),a.roundRect(t-.5*i,n,i,o,2),a.fill(),a.fillStyle=a.strokeStyle=s.fillColor||"#111",a.strokeStyle="white",a.beginPath(),a.lineWidth=2,a.moveTo(t,n+4),a.lineTo(t,n+o-4),a.stroke(),a.shadowBlur=0)}_drawTimeMarker(e,t,s={}){let i=this.offset;const o=s.width?s.width:this.dragging==e?6:4,n=this.canvas.height-2*this.offset;let a=this.ctx;a&&(a.globalAlpha=1,a.fillStyle=a.strokeStyle=s.fillColor||"#111",this.hovering==e&&(a.shadowColor="white",a.shadowBlur=2),a.fillStyle=a.strokeStyle="white",a.beginPath(),a.moveTo(t,i),a.lineTo(t,i+.5*n),a.stroke(),a.closePath(),a.fillStyle=a.strokeStyle=s.fillColor||"#111",i-=this.offset+8,a.fillStyle=s.fillColor||"#e5e5e5",a.beginPath(),a.roundRect(t-.5*o,i+this.offset,o,o,5),a.fill(),a.shadowBlur=0)}update(e){this.currentX=Math.min(Math.max(this.startX,e),this.endX),this._draw()}onMouseDown(e){if(this.onMouse&&this.onMouse(e),e.preventDefault(),!this.canvas||e.target!=this.canvas||e.cancelBubble)return;const t=this.canvas,s=e.offsetX,i=e.offsetY,o=this.markerWidth;Math.abs(this.startX-s)<o&&this.position.y<i?(this.dragging="start",t.style.cursor="grabbing"):Math.abs(this.endX-s)<o&&this.position.y<i?(this.dragging="end",t.style.cursor="grabbing"):(this.dragging="current",t.style.cursor="grabbing",s<this.startX?this.currentX=this.startX:s>this.endX?this.currentX=this.endX:this.currentX=s,this.onSetCurrentValue(this.currentX)),this._draw()}onMouseUp(e){if(this.onMouse&&this.onMouse(e),e.preventDefault(),delete this.dragging,delete this.hovering,!this.canvas||e.cancelBubble)return;this.canvas.style.cursor="default"}onMouseMove(e){if(this.onMouse&&this.onMouse(e),!this.canvas||e.cancelBubble)return;e.preventDefault();const t=this.canvas,s=e.target==t?e.offsetX:e.clientX-t.offsetLeft;if(e.target==t?e.offsetY:(e.clientY,t.offsetTop),this.dragging){switch(this.dragging){case"start":this.startX=Math.max(this.position.x,Math.min(this.endX,s)),this.currentX=this.startX,this.onSetStartValue(this.startX);break;case"end":this.endX=Math.max(this.startX,Math.min(this.position.x+this.lineWidth,s)),this.currentX=this.endX,this.onSetEndValue(this.endX);break;default:this.currentX=Math.max(this.startX,Math.min(this.endX,s))}this.onSetCurrentValue(this.currentX)}else{const e=.5*this.markerWidth;Math.abs(this.startX-s)<e?(this.hovering="start",t.style.cursor="grab"):Math.abs(this.endX-s)<e?(this.hovering="end",t.style.cursor="grab"):Math.abs(this.currentX-s)<e?(this.hovering="current",t.style.cursor="grab"):(delete this.hovering,t.style.cursor="default")}this._draw()}resize(e){this.canvas.width=Math.max(0,e[0]),this.canvas.height=Math.max(0,e[1]);let t=e[0]-2*this.offset;t=t<1e-5?1e-5:t;const s=(this.startX-this.offset)/this.lineWidth,i=(this.currentX-this.offset)/this.lineWidth,o=(this.endX-this.offset)/this.lineWidth;this.lineWidth=t,this.startX=Math.min(Math.max(t*s,0),t)+this.offset,this.currentX=Math.min(Math.max(t*i,0),t)+this.offset,this.endX=Math.min(Math.max(t*o,0),t)+this.offset,this._draw()}}t.TimeBar=kt;class Et{static CROP_HANDLE_L=1;static CROP_HANDLE_R=2;static CROP_HANDLE_T=4;static CROP_HANDLE_B=8;static CROP_HANDLE_TL=Et.CROP_HANDLE_L|Et.CROP_HANDLE_T;static CROP_HANDLE_BL=Et.CROP_HANDLE_L|Et.CROP_HANDLE_B;static CROP_HANDLE_TR=Et.CROP_HANDLE_R|Et.CROP_HANDLE_T;static CROP_HANDLE_BR=Et.CROP_HANDLE_R|Et.CROP_HANDLE_B;options={};playing=!1;videoReady=!1;controls=!0;startTimeString="0:0";endTimeString="0:0";speed=1;currentTime=0;startTime=0;endTime=0;requestId;video;loop=!1;isDragging=!1;isResizing=null;crop=!1;dragOffsetX=0;dragOffsetY=0;currentTimeString="";timebar;mainArea;cropArea;controlsArea;controlsPanelLeft;controlsPanelRight;controlsCurrentPanel;onChangeCurrent;onChangeStart;onChangeEnd;onKeyUp;onSetTime;onVideoLoaded;onCropArea;onResize;onChangeSpeed;_updateTime=!0;_onCropMouseUp;_onCropMouseMove;resize;constructor(e,s={}){this.options=s??{},this.speed=s.speed??this.speed,this.mainArea=e;let i=null,o=null;s.controlsArea?(i=e,o=s.controlsArea):[i,o]=e.split({type:"vertical",sizes:["85%",null],minimizable:!1,resize:!1}),o.root.classList.add("lexconstrolsarea"),this.cropArea=document.createElement("div"),this.cropArea.id="cropArea",this.cropArea.className="resize-area hidden",this.cropArea.normCoords={x:0,y:0,w:1,h:1};this.setCropAreaHandles(15),this.crop=s.crop,this.dragOffsetX=0,this.dragOffsetY=0;let n=this.video=s.video??document.createElement("video");this.loop=s.loop??this.loop,s.src&&(this.video.src=s.src,this.loadVideo(s)),s.videoArea?(s.videoArea.root.classList.add("lexvideoeditor"),s.videoArea.attach(this.cropArea),i.attach(s.videoArea)):(i.attach(n),i.attach(this.cropArea),i.root.classList.add("lexvideoeditor")),this.controlsArea=o;let[a,l]=o.split({type:"vertical",sizes:["50%",null],minimizable:!1,resize:!1});l.setSize([l.size[0],40]);let[r,c]=l.split({type:"horizontal",sizes:["92%",null],minimizable:!1,resize:!1}),[h,d]=r.split({type:"horizontal",sizes:["10%",null],minimizable:!1,resize:!1});a.root.classList.add("lexbar"),l.root.classList.add("lexbar"),this.controlsCurrentPanel=new t.Panel({className:"lexcontrolspanel lextime"}),this.controlsCurrentPanel.refresh=()=>{this.controlsCurrentPanel.clear(),this.controlsCurrentPanel.addLabel(this.currentTimeString,{float:"center"})},a.root.classList.add("lexflexarea"),a.attach(this.controlsCurrentPanel),this.controlsCurrentPanel.refresh();const u=getComputedStyle(l.root);let p=Number(u.getPropertyValue("padding").replace("px",""));this.timebar=new kt(d,kt.TIMEBAR_TRIM,{offset:p}),this.controlsPanelLeft=new t.Panel({className:"lexcontrolspanel"}),this.controlsPanelLeft.refresh=()=>{this.controlsPanelLeft.clear(),this.controlsPanelLeft.sameLine(),this.controlsPanelLeft.addButton("Play","",e=>{this.playing=e,this.playing?(this.video.currentTime+1e-6>=this.endTime&&(this.video.currentTime=this.startTime),this.video.play()):this.video.pause()},{width:"40px",icon:"Play@solid",swap:"Pause@solid",hideName:!0,className:"justify-center"}).setState(this.playing,!0),this.controlsPanelLeft.addButton("","",(e,s)=>{const i=new t.Panel;i.addRange("Speed",this.speed,e=>{this.speed=e,this.video.playbackRate=e,this.onChangeSpeed&&this.onChangeSpeed(e)},{min:0,max:2.5,step:.01,hideName:!0}),new t.Popover(s.target,[i],{align:"start",side:"top",sideOffset:12})},{width:"40px",title:"speed",icon:"Timer@solid",className:"justify-center"}),this.controlsPanelLeft.addButton("","Loop",e=>{this.loop=e},{width:"40px",title:"loop",icon:"Repeat@solid",className:"justify-center",selectable:!0,selected:this.loop}),this.controlsPanelLeft.addLabel(this.startTimeString,{width:"100px"}),this.controlsPanelLeft.endLine();let e=r.root.clientWidth-h.root.clientWidth;this.timebar.resize([e,d.root.clientHeight])},this.controlsPanelLeft.refresh(),h.root.style.minWidth="fit-content",h.attach(this.controlsPanelLeft),this.controlsPanelRight=new t.Panel({className:"lexcontrolspanel"}),this.controlsPanelRight.refresh=()=>{this.controlsPanelRight.clear(),this.controlsPanelRight.addLabel(this.endTimeString,{width:100})},this.controlsPanelRight.refresh(),c.root.style.minWidth="fit-content",c.attach(this.controlsPanelRight),this.timebar.onChangeCurrent=this._setCurrentTime.bind(this),this.timebar.onChangeStart=this._setStartTime.bind(this),this.timebar.onChangeEnd=this._setEndTime.bind(this),this.resize=()=>{l.setSize([this.controlsArea.root.clientWidth,40]);let e=this.controlsArea.root.clientWidth-h.root.clientWidth-c.root.clientWidth;this.timebar.resize([e,d.root.clientHeight]),this.moveCropArea(this.cropArea.normCoords.x,this.cropArea.normCoords.y,!0),this.resizeCropArea(this.cropArea.normCoords.w,this.cropArea.normCoords.h,!0),this.onResize&&this.onResize([i.root.clientWidth,i.root.clientHeight])},e.onresize=this.resize.bind(this),window.addEventListener("resize",e.onresize),this.onKeyUp=e=>{this.controls&&" "==e.key&&(e.preventDefault(),e.stopPropagation(),this.playing=!this.playing,this.playing?(this.video.currentTime+1e-6>=this.endTime&&(this.video.currentTime=this.startTime),this.video.play()):this.video.pause(),this.controlsPanelLeft.refresh())},window.addEventListener("keyup",this.onKeyUp);(o.parentElement?o.parentElement:o.root.parentElement).addEventListener("mousedown",e=>{}),this._onCropMouseUp=e=>{e.preventDefault(),e.stopPropagation(),(this.isDragging||this.isResizing)&&this.onCropArea&&this.onCropArea(this.getCroppedArea()),this.isDragging=!1,this.isResizing=!1,document.removeEventListener("mouseup",this._onCropMouseUp),document.removeEventListener("mousemove",this._onCropMouseMove)},this._onCropMouseMove=e=>{if(window.getSelection()?.removeAllRanges(),e.preventDefault(),e.stopPropagation(),this.isResizing){const t=this.cropArea.getBoundingClientRect(),s=this.video.getBoundingClientRect(),i=this.isResizing.movement;let o=t.left,n=t.top,a=t.width,l=t.height;if(i&Et.CROP_HANDLE_L){let i=Math.min(t.right-4,Math.max(s.left,e.clientX));a=t.left+t.width-i,o=i,i<t.left?(this.moveCropArea(o,n,!1),this.resizeCropArea(a,l,!1)):(this.resizeCropArea(a,l,!1),this.moveCropArea(o,n,!1))}if(i&Et.CROP_HANDLE_R&&(a=e.clientX-t.left,this.resizeCropArea(a,l,!1)),i&Et.CROP_HANDLE_T){const i=Math.min(t.bottom-4,Math.max(s.top,e.clientY));l=t.top+t.height-i,n=i,i<t.top?(this.moveCropArea(o,n,!1),this.resizeCropArea(a,l,!1)):(this.resizeCropArea(a,l,!1),this.moveCropArea(o,n,!1))}i&Et.CROP_HANDLE_B&&(l=e.clientY-t.top,this.resizeCropArea(a,l,!1))}this.isDragging&&this.moveCropArea(e.clientX-this.dragOffsetX,e.clientY-this.dragOffsetY,!1)},this.cropArea.addEventListener("mousedown",e=>{if(e.target===this.cropArea){const t=this.cropArea.getBoundingClientRect();this.isDragging=!0,this.dragOffsetX=e.clientX-t.left,this.dragOffsetY=e.clientY-t.top,document.addEventListener("mouseup",this._onCropMouseUp),document.addEventListener("mousemove",this._onCropMouseMove)}}),this.onChangeStart=null,this.onChangeEnd=null}setCropAreaHandles(e){const t=this.cropArea.getElementsByClassName("resize-handle");for(let e=t.length-1;e>-1;--e)t[e].remove();const s=(e,t)=>{const s=document.createElement("div");s.className=" resize-handle "+e,s.movement=t,this.options.handleStyle&&Object.assign(s.style,this.options.handleStyle),this.cropArea.append(s),s.addEventListener("mousedown",e=>{e.stopPropagation(),e.preventDefault(),this.isResizing=s,document.addEventListener("mouseup",this._onCropMouseUp),document.addEventListener("mousemove",this._onCropMouseMove)})};e&Et.CROP_HANDLE_L&&s("l",Et.CROP_HANDLE_L),e&Et.CROP_HANDLE_R&&s("r",Et.CROP_HANDLE_R),e&Et.CROP_HANDLE_T&&s("t",Et.CROP_HANDLE_T),e&Et.CROP_HANDLE_B&&s("b",Et.CROP_HANDLE_B),(e&Et.CROP_HANDLE_TL)==Et.CROP_HANDLE_TL&&s("tl",Et.CROP_HANDLE_TL),(e&Et.CROP_HANDLE_BL)==Et.CROP_HANDLE_BL&&s("bl",Et.CROP_HANDLE_BL),(e&Et.CROP_HANDLE_TR)==Et.CROP_HANDLE_TR&&s("tr",Et.CROP_HANDLE_TR),(e&Et.CROP_HANDLE_BR)==Et.CROP_HANDLE_BR&&s("br",Et.CROP_HANDLE_BR)}resizeCropArea(e,t,s=!0){const i=this.video.getBoundingClientRect();s||(e=i.width?e/i.width:1,t=i.height?t/i.height:1),e=Math.min(1-this.cropArea.normCoords.x,Math.max(0,e)),t=Math.min(1-this.cropArea.normCoords.y,Math.max(0,t)),this.cropArea.normCoords.w=e,this.cropArea.normCoords.h=t;const o=i.width*e,n=i.height*t,a=i.width*this.cropArea.normCoords.x+i.left,l=i.height*this.cropArea.normCoords.y+i.top;if(!this.cropArea.classList.contains("hidden")){const e=this.cropArea.parentElement.childNodes;for(let t=0;t<e.length;t++)if(e[t]!=this.cropArea){const s=e[t].getBoundingClientRect();e[t].style.webkitMask=`linear-gradient(#000 0 0) ${a-s.left}px ${l-s.top}px / ${o}px ${n}px, linear-gradient(rgba(0, 0, 0, 0.3) 0 0)`,e[t].style.webkitMaskRepeat="no-repeat"}}this.cropArea.style.width=o+"px",this.cropArea.style.height=n+"px"}moveCropArea(e,t,s=!0){const i=this.video.getBoundingClientRect();s||(e=i.width?(e-i.left)/i.width:0,t=i.height?(t-i.top)/i.height:0),e=Math.max(0,Math.min(1-this.cropArea.normCoords.w,e)),t=Math.max(0,Math.min(1-this.cropArea.normCoords.h,t)),this.cropArea.normCoords.x=e,this.cropArea.normCoords.y=t;const o=i.width*e+i.left,n=i.height*t+i.top,a=i.width*this.cropArea.normCoords.w,l=i.height*this.cropArea.normCoords.h;if(!this.cropArea.classList.contains("hidden")){const e=this.cropArea.parentElement.childNodes;for(let t=0;t<e.length;t++)if(e[t]!=this.cropArea){const s=e[t].getBoundingClientRect();e[t].style.webkitMask=`linear-gradient(#000 0 0) ${o-s.left}px ${n-s.top}px / ${a}px ${l}px, linear-gradient(rgba(0, 0, 0, 0.3) 0 0)`,e[t].style.webkitMaskRepeat="no-repeat"}}const r=this.cropArea.parentElement.getBoundingClientRect();this.cropArea.style.left=o-r.left+"px",this.cropArea.style.top=n-r.top+"px"}async loadVideo(e={}){for(this.videoReady=!1;this.video.duration===1/0||isNaN(this.video.duration)||!this.timebar;)await new Promise(e=>setTimeout(e,1e3)),this.video.currentTime=1e7*Math.random();this.video.currentTime=.01;this.video.addEventListener("canplaythrough",()=>{const e=this.videoReady;this.video.readyState>3&&(this.videoReady=!0),e||(this.video.currentTime=this.video.duration)},{passive:!0}),this.video.ondurationchange=e=>{this.video.duration!=this.endTime&&(this.video.currentTime=this.startTime,console.log("duration changed from",this.endTime," to ",this.video.duration),this.endTime=this.video.duration,this.timebar.setDuration(this.endTime),this.timebar.setEndTime(this.endTime)),this.video.currentTime=this.startTime,this.timebar.setCurrentTime(this.video.currentTime)},this.timebar.startX=this.timebar.position.x,this.timebar.endX=this.timebar.position.x+this.timebar.lineWidth,this.startTime=0,this.endTime=this.video.duration,this.timebar.setDuration(this.endTime),this.timebar.setEndTime(this.video.duration),this.timebar.setStartTime(this.startTime),this.timebar.setCurrentTime(this.startTime),this.requestId||this._update(),this.controls=e.controls??!0,this.controls||this.hideControls(),this.cropArea.style.height=this.video.clientHeight+"px",this.cropArea.style.width=this.video.clientWidth+"px",this.moveCropArea(0,0,!0),this.resizeCropArea(1,1,!0),this.crop?this.showCropArea():this.hideCropArea(),window.addEventListener("keyup",this.onKeyUp),this.onVideoLoaded&&this.onVideoLoaded(this.video)}_update(){this.playing&&(this.video.currentTime+1e-6>=this.endTime&&(this.video.pause(),this.loop?(this.video.currentTime=this.startTime,this.video.play()):(this.playing=!1,this.controlsPanelLeft.refresh())),this._updateTime=!1,this.timebar.setCurrentTime(this.video.currentTime),this._updateTime=!0),this.requestId=requestAnimationFrame(this._update.bind(this))}timeToString(e){let t=Math.floor(e/60),s=Math.floor(e-60*t),i=Math.floor(100*(e-s)),o=i<10?"0"+i:i.toString(),n=s<10?"0"+s:s.toString();return`${t<10?"0"+t:t.toString()}:${n}.${o}`}_setCurrentTime(e){this.video.currentTime!=e&&this._updateTime&&(this.video.currentTime=e),this.currentTimeString=this.timeToString(e),this.controlsCurrentPanel.refresh(),this.onSetTime&&this.onSetTime(e),this.onChangeCurrent&&this.onChangeCurrent(e)}_setStartTime(e){this.startTime=this.video.currentTime=e,this.startTimeString=this.timeToString(e),this.controlsPanelLeft.refresh(),this.onSetTime&&this.onSetTime(e),this.onChangeStart&&this.onChangeStart(e)}_setEndTime(e){this.endTime=this.video.currentTime=e,this.endTimeString=this.timeToString(e),this.controlsPanelRight.refresh(),this.onSetTime&&this.onSetTime(e),this.onChangeEnd&&this.onChangeEnd(e)}getStartTime(){return this.startTime}getEndTime(){return this.endTime}getTrimedTimes(){return{start:this.startTime,end:this.endTime}}getCroppedArea(){return this.cropArea.getBoundingClientRect()}showCropArea(){this.cropArea.classList.remove("hidden");const e=this.cropArea.parentElement?.childNodes??[],t=this.cropArea.getBoundingClientRect();for(let s=0;s<e.length;s++){const i=e[s];if(i==this.cropArea)continue;const o=i.getBoundingClientRect();i.style.webkitMask=`linear-gradient(#000 0 0) ${t.left-o.left}px ${t.top-o.top}px / ${t.width}px ${t.height}px, linear-gradient(rgba(0, 0, 0, 0.3) 0 0)`,i.style.webkitMaskRepeat="no-repeat"}}hideCropArea(){this.cropArea.classList.add("hidden");const e=this.cropArea.parentElement?.childNodes??[];for(let t=0;t<e.length;t++){const s=e[t];s!=this.cropArea&&(s.style.webkitMask="",s.style.webkitMaskRepeat="no-repeat")}}showControls(){this.controls=!0,this.controlsArea.show()}hideControls(){this.controls=!1,this.controlsArea.hide()}stopUpdates(){this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=null)}unbind(){this.stopUpdates(),this.video.pause(),this.playing=!1,this.controlsPanelLeft.refresh(),this.video.src="",window.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("mouseup",this._onCropMouseUp),document.removeEventListener("mousemove",this._onCropMouseMove)}}t.VideoEditor=Et;export{ce as AlertDialog,se as Area,te as AreaOverlayButtons,p as ArrayInput,be as AssetView,a as BaseComponent,Ze as BoundingBox,Q as Branch,l as Button,g as Checkbox,xt as ClipsTimeline,Be as CodeEditor,y as ColorInput,b as ComboButtons,n as ComponentType,he as ContextMenu,_ as Counter,L as Curve,E as DatePicker,w as Dial,re as Dialog,We as DocMaker,de as DropdownMenu,M as FileInput,pe as Footer,A as Form,Je as GraphEditor,et as GraphNode,i as IEvent,ft as ImUI,_t as KeyFramesTimeline,ke as Knob,t as LX,N as Layers,P as List,R as Map2D,D as NodeTree,h as NumberInput,B as OTPInput,H as Pad,G as Pagination,ee as Panel,me as PocketDialog,v as Popover,F as Progress,$ as RadioGroup,V as RangeInput,K as Rate,u as Select,ge as Sheet,fe as Sidebar,U as SizeInput,Ce as Skeleton,le as Spinner,q as TabSections,W as Table,c as Tabs,Y as Tags,X as TextArea,d as TextInput,kt as TimeBar,bt as Timeline,j as Title,Z as Toggle,ve as Tour,z as Tree,o as TreeEvent,J as Vector,Et as VideoEditor,ue as addDropdownMenu,O as vec2};
|