lexgui 8.3.0 → 8.3.2
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/core/Namespace.js +34 -34
- package/build/core/Namespace.js.map +1 -1
- package/build/extensions/CodeEditor.d.ts +521 -466
- package/build/extensions/CodeEditor.js +4895 -4218
- package/build/extensions/CodeEditor.js.map +1 -1
- package/build/extensions/Timeline.js.map +1 -1
- package/build/extensions/VideoEditor.js +1 -2
- package/build/extensions/VideoEditor.js.map +1 -1
- package/build/lexgui.all.js +28972 -28262
- package/build/lexgui.all.js.map +1 -1
- package/build/lexgui.all.min.js +1 -1
- package/build/lexgui.all.module.js +28897 -28187
- package/build/lexgui.all.module.js.map +1 -1
- package/build/lexgui.all.module.min.js +1 -1
- package/build/lexgui.css +7598 -7541
- package/build/lexgui.js +19071 -18360
- package/build/lexgui.js.map +1 -1
- package/build/lexgui.min.css +1 -1
- package/build/lexgui.min.js +1 -1
- package/build/lexgui.module.js +19010 -18299
- package/build/lexgui.module.js.map +1 -1
- package/build/lexgui.module.min.js +1 -1
- package/changelog.md +28 -1
- package/demo.js +5 -2
- package/examples/code-editor.html +9 -0
- package/package.json +1 -1
package/build/lexgui.all.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("https://cdn.jsdelivr.net/npm/tailwind-merge@3.4.0/+esm")):"function"==typeof define&&define.amd?define(["exports","https://cdn.jsdelivr.net/npm/tailwind-merge@3.4.0/+esm"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).lexgui={},e.twMerge)}(this,function(e,t){"use strict";const s=globalThis;e.LX=s.LX,e.LX||(e.LX={version:"8.3.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},s.LX=e.LX);const i={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"]};e.LX.LucideIconAlias={Stop:"Square",Refresh:"RefreshCw",Left:"ChevronLeft",Right:"ChevronRight",Up:"ChevronUp",Down:"ChevronDown",MenuArrows:"ChevronsUpDown",RotateForward:"RotateCw",RotateRight:"RotateCw",RotateBack:"RotateCcw",RotateLeft:"RotateCcw"},e.LX.ICONS=(()=>{const e={};for(let t in i){i[t][2].forEach(s=>e[s]=t)}return{...i,...e}})();let o=class{name;value;domEvent;constructor(e,t,s){this.name=e,this.value=t,this.domEvent=s}};e.LX.IEvent=o,e.ComponentType=void 0,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"}(e.ComponentType||(e.ComponentType={})),e.LX.ComponentType=e.ComponentType;let n=class t{type;name;customName;options;root;customIdx=-1;disabled=!1;onSetValue;onGetValue;onAllowPaste;onResize;onSetDisabled;_initialValue;static NO_CONTEXT_TYPES=[e.ComponentType.BUTTON,e.ComponentType.LIST,e.ComponentType.FILE,e.ComponentType.PROGRESS];constructor(t,s,i,o={}){this.type=t,this.name=s,this.options=o,this._initialValue=i;const n=e.LX.makeElement("div",e.LX.mergeClass("lexcomponent flex flex-row outline-none items-center text-foreground text-sm overflow-hidden min-h-8 pad-sm",o.className));if(this.onResize=()=>{},o.id&&(n.id=o.id),o.title&&(n.title=o.title),t!=e.ComponentType.TITLE&&(o.width&&(n.style.width=n.style.minWidth=o.width),o.maxWidth&&(n.style.maxWidth=o.maxWidth),o.minWidth&&(n.style.minWidth=o.minWidth),o.height&&(n.style.height=n.style.minHeight=o.height),e.LX.componentResizeObserver.observe(n)),null!=s){if(!o.hideName){let t=e.LX.makeElement("div","lexcomponentname flex text-sm text-secondary-foreground justify-between whitespace-nowrap overflow-hidden",s);o.justifyName&&t.classList.add("float-"+o.justifyName),t.title=o.title??t.innerHTML,t.style.width=o.nameWidth||e.LX.DEFAULT_NAME_WIDTH,t.style.minWidth=t.style.width,n.appendChild(t),n.domName=t;const a=this;t.addEventListener("contextmenu",function(e){e.preventDefault(),a.oncontextmenu(e)}),o.skipReset||null==i||this._addResetProperty(t,function(e,t){a.set(a._initialValue,!1,t),e.style.display="none"})}}else o.hideName=!0;o.signal&&e.LX.addSignal(o.signal,this),this.root=n,this.root.jsInstance=this,this.disabled=o.disabled??!1,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(t,s){const i=e.LX.makeIcon("Undo2",{iconClass:"ml-0 mr-1 px-1",title:"Reset"});return i.style.display="none",i.addEventListener("click",s.bind(i,i)),t.appendChild(i),i}_canPaste(){const t=navigator.clipboard;let s=this.type===e.ComponentType.CUSTOM?void 0!==t.customIdx&&this.customIdx==t.customIdx:t.type===this.type;return s=s&&!0!==this.disabled,this.onAllowPaste&&(s=this.onAllowPaste(s)),s}_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){t.NO_CONTEXT_TYPES.includes(this.type)||e.LX.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 e.ComponentType.TEXT:return"Text";case e.ComponentType.TEXTAREA:return"TextArea";case e.ComponentType.BUTTON:return"Button";case e.ComponentType.SELECT:return"Select";case e.ComponentType.CHECKBOX:return"Checkbox";case e.ComponentType.TOGGLE:return"Toggle";case e.ComponentType.RADIO:return"Radio";case e.ComponentType.COLOR:return"Color";case e.ComponentType.RANGE:return"Range";case e.ComponentType.NUMBER:return"Number";case e.ComponentType.VECTOR:return"Vector";case e.ComponentType.TREE:return"Tree";case e.ComponentType.PROGRESS:return"Progress";case e.ComponentType.FILE:return"File";case e.ComponentType.LAYERS:return"Layers";case e.ComponentType.ARRAY:return"Array";case e.ComponentType.LIST:return"List";case e.ComponentType.TAGS:return"Tags";case e.ComponentType.CURVE:return"Curve";case e.ComponentType.KNOB:return"Knob";case e.ComponentType.SIZE:return"Size";case e.ComponentType.PAD:return"Pad";case e.ComponentType.FORM:return"Form";case e.ComponentType.DIAL:return"Dial";case e.ComponentType.COUNTER:return"Counter";case e.ComponentType.TABLE:return"Table";case e.ComponentType.TABS:return"Tabs";case e.ComponentType.DATE:return"Date";case e.ComponentType.MAP2D:return"Map2D";case e.ComponentType.RATE:return"Rate";case e.ComponentType.LABEL:return"Label";case e.ComponentType.BLANK:return"Blank";case e.ComponentType.CUSTOM:return this.customName}console.error(`Unknown Component type: ${this.type}`)}setDisabled(e){this.disabled=e,this.onSetDisabled&&this.onSetDisabled(e)}refresh(e){}};e.LX.BaseComponent=n;class a extends n{selectable=!1;callback;setState;swap;constructor(t,s,i,n={}){super(e.ComponentType.BUTTON,t,null,n),this.callback=i,this.selectable=n.selectable??this.selectable,this.onGetValue=()=>{const t=e.LX.hasClass(a,"selected"),i=a.querySelector("input");return i?i.checked:this.selectable?t:s},this.onSetValue=(t,s,i)=>{if(n.swap)this.setState(t,s);else if(a.innerHTML="",n.icon){const t=e.LX.makeIcon(n.icon);a.prepend(t)}else if(n.img){let e=document.createElement("img");e.src=n.img,a.prepend(e)}else a.innerHTML=`${t??""}`},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=`calc( 100% - ${t})`},this.setState=function(e,r){const l=a.querySelector("input");l?l.checked=e:this.selectable&&(n.parent&&n.parent.querySelectorAll(".lexbutton.selected").forEach(e=>{e!=a&&e.classList.remove("selected")}),a.classList.toggle("selected",e)),r||this._trigger(new o(t,l?l.checked:this.selectable?e:s,null),i)};var a=e.LX.makeElement("button",e.LX.mergeClass(["lexbutton","inline-flex","items-center","justify-center","whitespace-nowrap","transition-all","disabled:pointer-events-none","disabled:opacity-50","[&_svg]:pointer-events-none","shrink-0","[&_svg]:shrink-0","outline-none","select-none","cursor-pointer","font-medium","text-sm","border-1","h-9","px-2","overflow-hidden","bg-clip-padding"].join(" "),n.buttonClass??"outline"));if(a.disabled=this.disabled,a.title=n.tooltip?"":n.title??"",this.root.appendChild(a),n.selected&&a.classList.add("selected"),n.img){let e=document.createElement("img");e.src=n.img,a.prepend(e)}else if(n.icon){const t=e.LX.makeIcon(n.icon,{iconClass:n.iconClass,svgClass:n.svgClass}),i=n.iconPosition??"cover";"cover"==i||void 0!==n.swap?a.prepend(t):(a.innerHTML=`${s||""}`,"start"==i?a.prepend(t):a.appendChild(t)),a.classList.add("justify-center")}else a.innerHTML=`${s||""}`;if(n.fileInput){const e=document.createElement("input");e.type="file",e.className="file-input",e.style.display="none",a.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"===n.fileInputType?s.readAsText(t[0]):"buffer"===n.fileInputType?s.readAsArrayBuffer(t[0]):"bin"===n.fileInputType?s.readAsBinaryString(t[0]):"url"===n.fileInputType&&s.readAsDataURL(t[0]),s.onload=e=>{i.call(this,e.target?.result,t[0])}})}let r=a;if(n.swap){a.classList.add("swap"),a.querySelector("a").classList.add("swap-off");const t=document.createElement("input");t.className="p-0 border-0",t.type="checkbox",a.prepend(t);const s=e.LX.makeIcon(n.swap,{iconClass:"swap-on"});a.appendChild(s),this.swap=function(e){const t=a.querySelector("input");t.checked=!t.checked,e||r.click()}}r.addEventListener("click",r=>{let l;if(this.selectable&&(n.parent&&n.parent.querySelectorAll(".lexbutton.selected").forEach(e=>{e!=a&&e.classList.remove("selected")}),l=a.classList.toggle("selected")),n.fileInput)a.querySelector(".file-input").click();else if(n.mustConfirm){const l=a.querySelector("input");new e.LX.PopConfirm(a,{onConfirm:()=>{n.swap&&(l.checked=!0),this._trigger(new o(t,s,r),i)},side:n.confirmSide,align:n.confirmAlign,confirmText:n.confirmText,cancelText:n.confirmCancelText,title:n.confirmTitle,content:n.confirmContent}),n.swap&&(l.checked=!1)}else{const e=a.querySelector("input");this._trigger(new o(t,e?.checked??(this.selectable?l:s),r),i)}}),n.tooltip&&e.LX.asTooltip(a,n.title??t),e.LX.doAsync(this.onResize.bind(this))}click(){this.root.querySelector("button").click()}setSwapIcon(t){const s=this.root.querySelector(".swap-on");if(!s)return;const i=e.LX.makeIcon(t,{iconClass:"swap-on"});s.replaceWith(i)}}e.LX.Button=a;class r{root;siblingArea;buttonContainer;items=[];buttons={};icons={};shorts={};focused=!1;_currentDropdown;constructor(t,s={}){this.root=e.LX.makeElement("div","lexmenubar size-full bg-background text-foreground inline-flex gap-1 overflow-hidden text-sm font-medium"),s.float&&(this.root.className=e.LX.mergeClass(this.root.className,`justify-${s.float}`)),this.items=t??[],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 t of this.items){let s=t.name,i=e.LX.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=e.LX.addDropdownMenu(o,t.submenu??[],{side:"bottom",align:"start",onBlur:()=>{this._resetMenubar()}})};o.addEventListener("mousedown",e=>{e.preventDefault()}),o.addEventListener("mouseup",e=>{e.preventDefault();const i=t.callback;if(!i)return n(),this.focused=!0,!1;i.call(this,s,o,e)}),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(t,s,i,o={}){if(!t)throw"Set Button Name!";let n=this.buttons[t];n&&(delete this.buttons[t],e.LX.deleteElement(n.root)),n=new a(t,void 0,i,{title:t,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[t]=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 a(e,t.label,t.callback,{title:e,buttonClass:"ghost",disabled:t.disabled,icon:t.icon,hideName:!0,swap:t.swap,iconPosition:"start"});this.buttonContainer.appendChild(s.root),e&&(this.buttons[e]=s)}}}class l{static TAB_ID=0;root;area;tabs={};tabDOMs={};thumb;selected=null;folding=!1;folded=!1;onclose;constructor(t,s={}){this.onclose=s.onclose;let i=document.createElement("div");i.className="lexareatabs flex flex-row w-fit "+(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 r=document.getElementById(t+"_content");n.area.attach(r),this.classList.remove("dockingtab"),s.instance=n,s._forceSelect=!0,s.click(),n.tabs[s.dataset.name]=r}),t.root.classList.add("lexareatabscontainer");const[a,r]=t.split({type:"vertical",sizes:s.sizes??"auto",resize:!1,top:2});if(a.attach(i),s.parentClass&&i.parentElement&&(i.parentElement.className=e.LX.mergeClass(i.parentElement.className,s.parentClass)),this.area=r,this.area.root.className+=" lexareatabscontent",s.contentClass&&(this.area.root.className=e.LX.mergeClass(this.area.root.className,s.contentClass)),this.selected=null,this.root=i,s.fit){let t=document.createElement("span");t.className="lexareatab thumb",this.thumb=t,this.root.appendChild(t);new ResizeObserver(t=>{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",e.LX.flushCss(this.thumb),this.thumb.style.transition=i}}).observe(this.area.root)}if(o){this.folded=!0,this.folding=o,"up"==o&&e.LX.insertChildAtIndex(t.root,t.sections[1].root,0);new ResizeObserver(e=>{for(const s of e){const e=s.contentRect,i=t.parentArea?.sections[0].root;i.style.height="calc(100% - "+(42+e.height)+"px )"}}).observe(this.area.root),this.area.root.classList.add("folded")}}add(t,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 t=i.icon.split(" ");i.icon=e.LX.makeIcon(t[0],{svgClass:"sm "+t.slice(0).join(" ")}).innerHTML}let a=document.createElement("span");if(a.dataset.name=t,a.className="lexareatab flex flex-row gap-1"+(o?" selected":""),a.innerHTML=(i.icon??"")+t,a.id=t.replace(/\s/g,"")+l.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 t={};(i.badge.asChild??!1)&&(t.parent=a),a.innerHTML+=e.LX.badge(i.badge.content??"",i.badge.className,t)}a.selected&&(this.selected=t),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=!t.folding||!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",t=>{t.button==e.LX.MOUSE_MIDDLE_CLICK&&t.preventDefault()}),a.addEventListener("mouseup",t=>{t.preventDefault(),t.stopPropagation(),t.button==e.LX.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 r=i.indexOffset??-1;a.childIndex=this.root.childElementCount+r,e.LX.insertChildAtIndex(this.root,a,a.childIndex+1),this.area.attach(n),this.tabDOMs[t]=a,this.tabs[t]=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()}setIcon(t,s){const i=this.tabDOMs[t];if(!i)return;const o=s.split(" "),n=e.LX.makeIcon(o[0],{svgClass:"sm "+o.slice(0).join(" ")});i.innerHTML=n.innerHTML+t}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()}}e.LX.Tabs=l;class c extends n{setLimits;constructor(t,s,i,n={}){super(e.ComponentType.NUMBER,t,s,n),this.onGetValue=()=>s,this.onSetValue=(a,l,h)=>{if(isNaN(a))return;s=e.LX.clamp(+a,+c.min,+c.max),c.value=s=e.LX.round(s,n.precision);const d=r.querySelector(".lexinputslider");d&&(d.value=s),l||this._trigger(new o(t,s,h),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=n.inputWidth??`calc( 100% - ${t})`},this.setLimits=(e,t,s)=>{};var a=document.createElement("div");a.className="lexnumber",this.root.appendChild(a);let r=e.LX.makeElement("div","numberbox relative flex flex-col w-full bg-secondary rounded-lg scrollbar-hidden overflow-x-hidden","",a),l=e.LX.makeContainer(["auto","100%"],"relative flex flex-row cursor-text","",r),c=document.createElement("input");c.id="number_"+e.LX.guidGenerator(),c.className="vecinput",c.min=n.min??-1e24,c.max=n.max??1e24,c.step=n.step??"any",c.type="number",c.disabled=this.disabled,s.constructor==Number&&(s=e.LX.clamp(s,+c.min,+c.max),s=e.LX.round(s,n.precision)),c.value=c.iValue=s,l.appendChild(c);const h=e.LX.makeIcon("MoveVertical",{iconClass:"drag-icon hidden-opacity",svgClass:"sm"});if(l.appendChild(h),n.units){let t=e.LX.makeContainer(["auto","auto"],"px-2 bg-card content-center break-keep",n.units,l);c.unitBox=t}if(!n.skipSlider&&void 0!==n.min&&void 0!==n.max){let t=e.LX.makeContainer(["100%","auto"],"z-1 input-box","",r),i=document.createElement("input");i.className="lexinputslider",i.min=n.min,i.max=n.max,i.step=n.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){n.onPress&&n.onPress.bind(i)(e,i)},!1),i.addEventListener("mouseup",function(e){n.onRelease&&n.onRelease.bind(i)(e,i)},!1),t.appendChild(i),this.setLimits=(e,t,o)=>{c.min=i.min=e??c.min,c.max=i.max=t??c.max,c.step=o??c.step,i.step=o??i.step,this.set(s,!0)}}c.addEventListener("input",function(t){s=+c.valueAsNumber,s=e.LX.round(s,n.precision)},!1),c.addEventListener("wheel",e=>{if(e.preventDefault(),c!==document.activeElement)return;let t=n.step??1;e.shiftKey?t*=10:e.altKey&&(t*=.1),s=+c.valueAsNumber-t*(e.deltaY>0?1:-1),this.set(s,!1,e)},{passive:!1}),c.addEventListener("change",e=>{this.set(c.valueAsNumber,!1,e)},{passive:!1});var d=this;let u=e=>{let t=-e.movementY;if(0!=t){let i=n.step??1;e.shiftKey?i*=10:e.altKey&&(i*=.1),s=+c.valueAsNumber+i*t,this.set(s,!1,e)}e.stopPropagation(),e.preventDefault()},p=e=>{var t=d.root.ownerDocument;t.removeEventListener("mousemove",u),t.removeEventListener("mouseup",p),document.body.classList.remove("noevents"),h.classList.add("hidden-opacity"),document.pointerLockElement&&document.exitPointerLock(),n.onRelease&&n.onRelease.bind(c)(e,c)};l.addEventListener("mousedown",t=>{if(document.activeElement!=c&&t.button==e.LX.MOUSE_LEFT_CLICK){var s=d.root.ownerDocument;s.addEventListener("mousemove",u),s.addEventListener("mouseup",p),document.body.classList.add("noevents"),h.classList.remove("hidden-opacity"),t.stopImmediatePropagation(),t.stopPropagation(),document.pointerLockElement||l.requestPointerLock(),n.onPress&&n.onPress.bind(c)(t,c)}}),e.LX.doAsync(this.onResize.bind(this))}}e.LX.NumberInput=c;class h extends n{valid;input;_triggerEvent;_lastValueTriggered;constructor(t,s,i,n={}){super(e.ComponentType.TEXT,t,String(s),n),this.onGetValue=()=>s,this.onSetValue=(e,a,l)=>{let c=this._lastValueTriggered==e;n.ignoreValidation||(c=c||!this.valid(e)),c||(this._lastValueTriggered=s=e,r.value=e,delete this._triggerEvent,a||this._trigger(new o(t,e,l),i))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=n.inputWidth??`calc( 100% - ${t})`},this.valid=(t,s)=>{if(t=t??this.value(),!n.pattern)return!0;return 0==e.LX.validateValueAtPattern(t,n.pattern,s).length};let a=document.createElement("div");a.className=n.warning?" lexwarning":"",a.style.display="flex",a.style.position="relative",this.root.appendChild(a),this.disabled=(this.disabled||n.warning)??!!n.url;let r=null;if(this.disabled)n.url?(r=document.createElement("a"),r.href=n.url,r.target="_blank",r.innerHTML=s??"",r.style.textAlign=n.float??"",r.className="lextext ellipsis-overflow"):(r=document.createElement("input"),r.disabled=!0,r.className=e.LX.mergeClass("lextext ellipsis-overflow",n.inputClass));else{r=e.LX.makeElement("input",e.LX.mergeClass("lextext text-sm",n.inputClass)),r.type=n.type||"",r.setAttribute("placeholder",n.placeholder??""),n.required&&r.setAttribute("required",n.required),n.pattern&&r.setAttribute("pattern",e.LX.buildTextPattern(n.pattern));const t=n.trigger??"default";if("default"==t?(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"==t&&r.addEventListener("input",e=>{this.set(e.target.value,!1,e)}),r.addEventListener("mousedown",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),n.icon){r.style.paddingLeft="1.75rem";const t=e.LX.makeIcon(n.icon,{iconClass:"absolute z-1 ml-2",svgClass:"sm"});a.appendChild(t)}}n.fit&&r.classList.add("field-sizing-content"),r instanceof HTMLInputElement&&(r.name=n.name,r.value=s??"",n.autocomplete?r.autocomplete=n.autocomplete:"password"===r.type?r.autocomplete="current-password":"username"===n.name||"email"===n.name?r.autocomplete=n.name:r.autocomplete="on",r.style.textAlign=n.float??"",r.addEventListener("transitionstart",e=>{"background-color"===e.propertyName&&r.matches(":-webkit-autofill")&&this.syncFromDOM()})),Object.assign(r.style,n.style??{}),a.appendChild(r),this.input=r,e.LX.doAsync(this.onResize.bind(this))}syncFromDOM(e=!0){this.input instanceof HTMLInputElement&&this.set(this.input.value,e)}}e.LX.TextInput=h;class d extends n{_lastPlacement=[!1,!1];constructor(t,s,i,n,r={}){super(e.ComponentType.SELECT,t,i,r),this.onGetValue=()=>i,this.onSetValue=(a,l,c)=>{i=a;let h=null;if(m.childNodes.forEach(e=>{e.classList.remove("selected"),e.getAttribute("value")==a&&(h=e)}),console.assert(h,`Item ${a} does not exist in the Select.`),h.classList.add("selected"),u.refresh(i),g){g.root.querySelector("input").value="";const e=this._filterOptions(s,"");m.refresh(e)}const d=this.root.querySelector(".lexcustomcontainer"),p=r[`on_${i}`];if(d.toggleAttribute("hidden",!p),p){d.innerHTML="";const t=new e.LX.Panel;t.queue(d),p.call(this,t),t.clearQueue()}this.root.dataset.opened=!!p,m.style.height="",l||this._trigger(new o(t,i,c),n)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=r.inputWidth??`calc( 100% - ${t})`};let l=document.createElement("div");l.className="lexselect",this.root.appendChild(l);let c=document.createElement("div");c.className="lexselect lexoption",c.name=t,c.iValue=i,void 0!==r.overflowContainer&&(r.overflowContainerX=r.overflowContainerY=r.overflowContainer);const d=(t,s)=>{const i=u.root,o=i.getBoundingClientRect(),n=t.parentElement.closest("dialog")??t.parentElement.closest(".lexcolorpicker");{const a=void 0!==r.overflowContainerY?r.overflowContainerY:e.LX.getParentArea(t),l=t.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}t.style.top=c+i.offsetHeight+"px",m.style.height="";const d=s?this._lastPlacement[0]:c-l<0,u=s?this._lastPlacement[1]:c+l>h;u&&!d?(t.style.top=c-l+"px",t.classList.add("place-above")):u&&d&&(m.style.height=h-c-32+"px"),this._lastPlacement=[d,u]}{const s=void 0!==r.overflowContainerX?r.overflowContainerX:e.LX.getParentArea(t),i=t.offsetWidth;let a=o.x;if(t.style.minWidth=o.width+"px",n){a-=n.getBoundingClientRect().x}t.style.left=a+"px";let l=window.innerWidth;if(s){const e=s.getBoundingClientRect();l=e.x+e.width}!("end"===r.align||a+i>l)||r.align&&"start"===r.align||(t.style.left=a-(i-o.width)+"px")}};let u=new a(null,i,(e,t)=>{if(m.unfocus_event)return void delete m.unfocus_event;p.classList.remove("place-above");p.hasAttribute("open")?p.close():(p.show(),d(p)),g&&g.root.querySelector("input").focus()},{buttonClass:"outline [&_a]:ml-auto",skipInlineCount:!0,disabled:this.disabled});u.root.style.width="100%",u.root.querySelector("button").appendChild(e.LX.makeIcon("Down",{svgClass:"sm"})),l.appendChild(u.root),u.refresh=e=>{const t=u.root.querySelector("button");""==t.innerText?t.innerText=e:t.innerHTML=t.innerHTML.replaceAll(t.innerText,e)};const p=document.createElement("dialog");p.className="lexselectoptions";let m=document.createElement("ul");m.tabIndex=-1,m.className="lexoptions",p.appendChild(m),m.addEventListener("focusout",function(e){if(e.stopPropagation(),e.stopImmediatePropagation(),e.relatedTarget===u.root.querySelector("button"))m.unfocus_event=!0,setTimeout(()=>delete m.unfocus_event,200);else{if(e.relatedTarget&&p.contains(e.relatedTarget))return;if("lexinput-filter"==e.target.className)return}p.close()});let g=null;if(r.filter){const t=e.LX.deepCopy(r);t.placeholder=t.placeholder??"Search...",t.skipComponent=t.skipComponent??!0,t.trigger="input",t.icon="Search",t.className="lexfilter",t.inputClass="outline",g=new h(null,r.filterValue??"",e=>{const t=this._filterOptions(s,e);m.refresh(t),d(p,!0)},t),g.root.querySelector(".lextext").style.border="1px solid transparent";g.root.querySelector("input").addEventListener("focusout",function(e){e.relatedTarget&&"UL"==e.relatedTarget.tagName&&e.relatedTarget.classList.contains("lexoptions")||p.close()}),m.appendChild(g.root)}m.refresh=t=>{for(;m.childElementCount>(r.filter?1:0);)m.removeChild(m.lastChild);if(!t.length){let t=r.emptyMsg??"No options found.",s=document.createElement("div");s.className="option",s.innerHTML=e.LX.makeIcon("Inbox",{svgClass:"mr-2"}).innerHTML+t;let i=document.createElement("li");return i.className="lexselectitem empty",i.appendChild(s),void m.appendChild(i)}for(let s=0;s<t.length;s++){let o=t[s],n=document.createElement("li"),a=document.createElement("div");a.className="option",n.appendChild(a);const r=e=>{this.set(e.currentTarget?.getAttribute("value"),!1,e),p.close()};if(n.addEventListener("click",r),o.constructor!=Object){const t="@"===o[0];t?(a.innerHTML="<span>"+o.substr(1)+"</span>",n.removeEventListener("click",r)):(a.innerHTML=`<span class="flex flex-row justify-between">${o}</span>`,a.appendChild(e.LX.makeIcon("Check")),a.value=o,n.setAttribute("value",o),o==i&&(n.classList.add("selected"),c.innerHTML=o)),n.classList.add(t?"lexselectlabel":"lexselectitem")}else{let e=document.createElement("img");e.src=o.src,n.setAttribute("value",o.value),n.className="lexlistitem",a.innerText=o.value,a.className+=" media",a.prepend(e),a.setAttribute("value",o.value),a.setAttribute("data-index",s),a.setAttribute("data-src",o.src),a.setAttribute("title",o.value),i==o.value&&n.classList.add("selected")}m.appendChild(n)}},m.refresh(s),l.appendChild(p);let f=e.LX.makeElement("div","lexcustomcontainer w-full");const C=r[`on_${i}`];if(f.toggleAttribute("hidden",!C),C){f.innerHTML="";const t=new e.LX.Panel;t.queue(f),C.call(this,t),t.clearQueue()}this.root.appendChild(f),this.root.dataset.opened=!!C,e.LX.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}}e.LX.Select=d;class u extends n{_updateItems;constructor(t,s=[],i,n={}){n.nameWidth="auto",super(e.ComponentType.ARRAY,t,null,n),this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{s=e,this._updateItems(),n||this._trigger(new o(t,s,a),i)};let r=document.createElement("div");r.className="lexarray shrink-1 grow-1 ml-4",r.style.width="auto",this.root.appendChild(r),this.root.dataset.opened=!1;let l=`Array (size ${s.length})`;const u=new a(null,l,()=>{this.root.dataset.opened="true"!=this.root.dataset.opened,this.root.querySelector(".lexarrayitems").toggleAttribute("hidden")},{buttonClass:"outline [&_a]:ml-auto"});u.root.querySelector("button").appendChild(e.LX.makeIcon("Down",{svgClass:"sm"})),r.appendChild(u.root);let p=document.createElement("div");p.className="lexarrayitems",p.toggleAttribute("hidden",!0),this.root.appendChild(p),this._updateItems=()=>{let r=this.root.querySelector("button");for(let e of r.childNodes)if(e.nodeType===Node.TEXT_NODE){e.textContent=`Array (size ${s.length})`;break}p.innerHTML="";for(let e=0;e<s.length;++e){const r=s[e];let l=n.innerValues?"select":r.constructor,u=null;switch(l){case String:u=new h(e+"",r,function(t){s[e]=t,i(s)},{nameWidth:"12px",className:"p-0",disabled:this.disabled,skipReset:!0});break;case Number:u=new c(e+"",r,function(t){s[e]=t,i(s)},{nameWidth:"12px",className:"p-0",disabled:this.disabled,skipReset:!0});break;case"select":u=new d(e+"",n.innerValues,r,function(t){s[e]=t,i(s)},{nameWidth:"12px",className:"p-0",disabled:this.disabled,skipReset:!0})}if(console.assert(u,`Value of type ${l} cannot be modified in ArrayInput`),p.appendChild(u.root),!this.disabled){const e=new a(null,"",(e,n)=>{s.splice(s.indexOf(r),1),this._updateItems(),this._trigger(new o(t,s,n),i)},{buttonClass:"ghost sm p-0",title:"Remove item",icon:"Trash2"});u.root.appendChild(e.root)}}if(!this.disabled){const r=new a(null,e.LX.makeIcon("Plus",{svgClass:"sm"}).innerHTML+"Add item",(e,a)=>{s.push(n.innerValues?n.innerValues[0]:""),this._updateItems(),this._trigger(new o(t,s,a),i)},{buttonClass:"ghost"});p.appendChild(r.root)}},this._updateItems()}}e.LX.ArrayInput=u;class p extends n{constructor(t,s={}){s.hideName=!0,super(e.ComponentType.CARD,t,null,s),this.root.classList.add("place-content-center");const i=e.LX.makeContainer(["100%","auto"],"lexcard max-w-sm flex flex-col gap-4 bg-card border-color rounded-xl py-6","",this.root);if(s.header){const t=void 0!==s.header.action;let o=e.LX.makeContainer(["100%","auto"],`flex ${t?"flex-row gap-4":"flex-col gap-1"} px-6`,"",i);if(t){const t=new a(null,s.header.action.name,s.header.action.callback,{buttonClass:"secondary"});o.appendChild(t.root);const i=e.LX.makeContainer(["75%","auto"],"flex flex-col gap-1","");o.prepend(i),o=i}s.header.title&&e.LX.makeElement("div","text-sm text-foreground leading-none font-semibold",s.header.title,o),s.header.description&&e.LX.makeElement("div","text-xs text-muted-foreground",s.header.description,o)}if(s.content){const t=e.LX.makeContainer(["100%","auto"],"flex flex-col gap-2 px-6","",i),o=[].concat(s.content);for(let e of o)t.appendChild(e.root?e.root:e)}if(s.footer){const t=e.LX.makeContainer(["100%","auto"],"flex flex-col gap-1 px-6","",i),o=[].concat(s.footer);for(let e of o)t.appendChild(e.root?e.root:e)}s.callback&&(i.classList.add("selectable"),i.style.cursor="pointer",i.addEventListener("click",e=>{this._trigger(new o(t,null,e),s.callback)}))}}e.LX.Card=p;class m extends n{constructor(t,s,i,n={}){if(!t&&!n.label)throw"Set Component Name or at least a label!";super(e.ComponentType.CHECKBOX,t,s,n),this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{e!=s&&(r.checked=s=e,this.root.querySelector(".lexcheckboxsubmenu")?.toggleAttribute("hidden",!e),n||this._trigger(new o(t,e,a),i))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=n.inputWidth??`calc( 100% - ${t})`};let a=document.createElement("div");a.className="flex items-center gap-2 my-0 mx-auto [&_span]:truncate [&_span]:flex-auto-fill",this.root.appendChild(a);let r=e.LX.makeElement("input",e.LX.mergeClass("lexcheckbox rounded-xl disabled:pointer-events-none disabled:opacity-50",n.className??"primary"));if(r.type="checkbox",r.checked=s,r.disabled=this.disabled,a.appendChild(r),e.LX.makeElement("span","text-sm",n.label??"On",a),r.addEventListener("change",e=>{this.set(r.checked,!1,e)}),n.suboptions){let t=e.LX.makeElement("div","lexcheckboxsubmenu");t.toggleAttribute("hidden",!r.checked);const s=new e.LX.Panel;s.queue(t),n.suboptions.call(this,s),s.clearQueue(),this.root.appendChild(t)}e.LX.doAsync(this.onResize.bind(this))}}e.LX.Checkbox=m;class g{_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(t){this._fromRGB(e.LX.hexToRgb(t))}_fromRGB(t){this._rgb=t,this._hsv=e.LX.rgbToHsv(t),this._hex=e.LX.rgbToHex(t),this.css=e.LX.rgbToCss(this._rgb)}_fromHSV(t){this._hsv=t,this._rgb=e.LX.hsvToRgb(t),this._hex=e.LX.rgbToHex(this._rgb),this.css=e.LX.rgbToCss(this._rgb)}}e.LX.Color=g;class f{static currentPicker=!1;root;colorModel;useAlpha;callback;markerHalfSize;markerSize;currentColor;labelComponent;colorPickerBackground;intSatMarker;colorPickerTracker;alphaTracker;hueMarker;alphaMarker;onPopover;constructor(t,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=e.LX.makeElement("div","lexcolorpicker flex flex-col text-sm w-3xs gap-2 p-1"),this.markerHalfSize=8,this.markerSize=2*this.markerHalfSize,this.currentColor=new g(t);const i=new g({h:this.currentColor.hsv.h,s:1,v:1}),o="size-4 rounded-lg bg-transparent absolute pointer-events-none border-3 border-solid border-white";this.colorPickerBackground=e.LX.makeElement("div","lexcolorpickerbg w-full aspect-square relative rounded-md cursor-pointer"),this.colorPickerBackground.style.backgroundColor=`rgb(${i.css.r}, ${i.css.g}, ${i.css.b})`,this.root.appendChild(this.colorPickerBackground),this.intSatMarker=e.LX.makeElement("div",o),this.intSatMarker.style.backgroundColor=this.currentColor.hex,this.colorPickerBackground.appendChild(this.intSatMarker);let n=null,r=t=>{const s=t.movementX,i=t.movementY,o=t.x-n.x,a=t.y-n.y;0!=s&&(o>=0||s<0)&&(o<this.colorPickerBackground.offsetWidth||s>0)&&(this.intSatMarker.style.left=e.LX.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=e.LX.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(),t.stopPropagation(),t.preventDefault()},l=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",r),t.removeEventListener("mouseup",l),document.body.classList.remove("noevents")};this.colorPickerBackground.addEventListener("mousedown",e=>{var t=this.root.ownerDocument;t.addEventListener("mousemove",r),t.addEventListener("mouseup",l),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(),n=this.colorPickerBackground.getBoundingClientRect()});const c=e.LX.makeContainer(["100%","auto"],"flex flex-row gap-1 items-center","",this.root),u=window.EyeDropper;u&&c.appendChild(new a(null,"eyedrop",async()=>{const e=new u;try{const t=await e.open();this.fromHexColor(t.sRGBHex)}catch(e){}},{icon:"Pipette",buttonClass:"bg-none",title:"Sample Color"}).root);const p=e.LX.makeContainer(["100%","100%"],"flex flex-col gap-2","",c);this.colorPickerTracker=e.LX.makeElement("div","lexhuetracker w-full h-4 rounded-lg relative cursor-pointer"),p.appendChild(this.colorPickerTracker),this.hueMarker=e.LX.makeElement("div",o),this.hueMarker.style.backgroundColor=`rgb(${i.css.r}, ${i.css.g}, ${i.css.b})`,this.colorPickerTracker.appendChild(this.hueMarker);const m=t=>{this.hueMarker.style.left=t+"px",this.currentColor.hsv.h=e.LX.remapRange(t,0,this.colorPickerTracker.offsetWidth-this.markerSize,0,360);const s=new g({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 f=null,C=t=>{const s=t.movementX,i=t.x-f.x;if(0!=s&&(i>=this.markerHalfSize||s<0)&&(i<this.colorPickerTracker.offsetWidth-this.markerHalfSize||s>0)){const t=e.LX.clamp(parseInt(this.hueMarker.style.left)+s,0,this.colorPickerTracker.offsetWidth-this.markerSize);m(t)}t.stopPropagation(),t.preventDefault()},y=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",C),t.removeEventListener("mouseup",y),document.body.classList.remove("noevents")};if(this.colorPickerTracker.addEventListener("mousedown",t=>{const s=this.root.ownerDocument;s.addEventListener("mousemove",C),s.addEventListener("mouseup",y),document.body.classList.add("noevents"),t.stopImmediatePropagation(),t.stopPropagation();const i=e.LX.clamp(t.offsetX-this.markerHalfSize,0,this.colorPickerTracker.offsetWidth-this.markerSize);m(i),f=this.colorPickerTracker.getBoundingClientRect()}),this.useAlpha){this.alphaTracker=e.LX.makeElement("div","lexalphatracker w-full h-4 rounded-lg relative cursor-pointer"),this.alphaTracker.style.color=`rgb(${this.currentColor.css.r}, ${this.currentColor.css.g}, ${this.currentColor.css.b})`,p.appendChild(this.alphaTracker),this.alphaMarker=e.LX.makeElement("div",o),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 t=t=>{this.alphaMarker.style.left=t+"px",this.currentColor.hsv.a=e.LX.remapRange(t,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 o=this.root.ownerDocument;o.addEventListener("mousemove",n),o.addEventListener("mouseup",a),document.body.classList.add("noevents"),i.stopImmediatePropagation(),i.stopPropagation();const r=e.LX.clamp(i.offsetX-this.markerHalfSize,0,this.alphaTracker.offsetWidth-this.markerSize);t(r),s=this.alphaTracker.getBoundingClientRect()},n=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=e.LX.clamp(parseInt(this.alphaMarker.style.left)+o,0,this.alphaTracker.offsetWidth-this.markerSize);t(s)}i.stopPropagation(),i.preventDefault()},a=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",n),t.removeEventListener("mouseup",a),document.body.classList.remove("noevents")};this.alphaTracker.addEventListener("mousedown",i)}const v=e.LX.makeContainer(["100%","auto"],"flex flex-row gap-1","",this.root);v.appendChild(new d(null,["CSS","Hex","HSV","RGB"],this.colorModel,e=>{this.colorModel=e,this._updateColorValue(null,!0)}).root),this.labelComponent=new h(null,"",null,{inputClass:"bg-none",fit:!0,disabled:!0}),v.appendChild(this.labelComponent.root);{const t=new a(null,"copy",async()=>{navigator.clipboard.writeText(this.labelComponent.value()),t.root.querySelector("input[type='checkbox']").style.pointerEvents="none",e.LX.doAsync(()=>{t.swap&&t.swap(!0),t.root.querySelector("input[type='checkbox']").style.pointerEvents="auto"},3e3)},{swap:"Check",icon:"Copy",buttonClass:"bg-none",className:"ml-auto",title:"Copy"});t.root.querySelector(".swap-on svg").classList.add("text-success"),v.appendChild(t.root)}this._updateColorValue(t,!0),e.LX.doAsync(this._placeMarkers.bind(this)),this.onPopover=this._placeMarkers.bind(this)}_placeMarkers(){this._svToPosition(this.currentColor.hsv.s,this.currentColor.hsv.v);const t=e.LX.remapRange(this.currentColor.hsv.h,0,360,0,this.colorPickerTracker.offsetWidth-this.markerSize);if(this.hueMarker.style.left=t+"px",this.useAlpha){const t=e.LX.remapRange(this.currentColor.hsv.a,0,1,0,this.alphaTracker.offsetWidth-this.markerSize);this.alphaMarker.style.left=t+"px"}}_svToPosition(t,s){this.intSatMarker.style.left=`${e.LX.remapRange(t,0,1,-this.markerHalfSize,this.colorPickerBackground.offsetWidth-this.markerHalfSize)}px`,this.intSatMarker.style.top=`${e.LX.remapRange(1-s,0,1,-this.markerHalfSize,this.colorPickerBackground.offsetHeight-this.markerHalfSize)}px`}_positionToSv(t,s){this.currentColor.hsv.s=e.LX.remapRange(t,-this.markerHalfSize,this.colorPickerBackground.offsetWidth-this.markerHalfSize,0,1),this.currentColor.hsv.v=1-e.LX.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(t){this.currentColor.setHex(t);const{h:s,s:i,v:o}=this.currentColor.hsv;this._svToPosition(i,o);const n=new g({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=e.LX.remapRange(s,0,360,-this.markerHalfSize,this.colorPickerTracker.offsetWidth-this.markerHalfSize)+"px",this._updateColorValue(t)}}e.LX.ColorPicker=f;class C{static activeElement=null;root;side="bottom";align="center";sideOffset=0;alignOffset=0;avoidCollisions=!0;reference;_windowPadding=4;_trigger;_parent;_onClick;constructor(t,s,i={}){if(C.activeElement)return void C.activeElement.destroy();this._trigger=t,t&&(t.classList.add("triggered"),t.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=e.LX.makeElement("div","lexpopover fixed bg-background rounded-lg border-color p-1 left-0 top-0"),this.root.dataset.side=this.side,this.root.tabIndex="1";const o=(t??this.reference).closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=e.LX.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()}),C.activeElement=this,e.LX.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(),C.activeElement=null}_adjustPosition(){const t=[0,0];{const e=this.reference??this._trigger;console.assert(e,"Popover needs a trigger or reference element!");const s=e.getBoundingClientRect();let i=!0;switch(this.side){case"left":t[0]+=s.x-this.root.offsetWidth-this.sideOffset,i=!1;break;case"right":t[0]+=s.x+s.width+this.sideOffset,i=!1;break;case"top":t[1]+=s.y-this.root.offsetHeight-this.sideOffset,i=!0;break;case"bottom":t[1]+=s.y+s.height+this.sideOffset,i=!0}switch(this.align){case"start":i?t[0]+=s.x:t[1]+=s.y;break;case"center":i?t[0]+=s.x+.5*s.width-.5*this.root.offsetWidth:t[1]+=s.y+.5*s.height-.5*this.root.offsetHeight;break;case"end":i?t[0]+=s.x-this.root.offsetWidth+s.width:t[1]+=s.y-this.root.offsetHeight+s.height}i?t[0]+=this.alignOffset:t[1]+=this.alignOffset}if(this.avoidCollisions&&(t[0]=e.LX.clamp(t[0],0,window.innerWidth-this.root.offsetWidth-this._windowPadding),t[1]=e.LX.clamp(t[1],0,window.innerHeight-this.root.offsetHeight-this._windowPadding)),this._parent instanceof HTMLDialogElement){let e=this._parent.getBoundingClientRect();t[0]-=e.x,t[1]-=e.y}this.root.style.left=`${t[0]}px`,this.root.style.top=`${t[1]}px`}}e.LX.Popover=C;e.LX.PopConfirm=class{_popover=null;constructor(t,s={}){const i=s.confirmText??"Yes",o=s.cancelText??"No",n=s.title??"Confirm",a=s.content??"Are you sure you want to proceed?",r=s.onConfirm,l=s.onCancel,c=e.LX.makeContainer(["auto","auto"],"tour-step-container");{const t=e.LX.makeContainer(["100%","auto"],"flex flex-row","",c);e.LX.makeContainer(["100%","auto"],"p-1 font-medium text-base",n,t)}e.LX.makeContainer(["100%","auto"],"p-1 text-base",a,c,{maxWidth:"400px"});const h=e.LX.makeContainer(["100%","auto"],"flex flex-row text-base","",c),d=e.LX.makeContainer(["100%","auto"],"text-base","",h),u=new e.LX.Panel;d.appendChild(u.root),u.sameLine(2,"justify-end"),u.addButton(null,o,()=>{l&&l(),this._popover?.destroy()}),u.addButton(null,i,()=>{r&&r(),this._popover?.destroy()},{buttonClass:"accent"}),this._popover?.destroy(),this._popover=new e.LX.Popover(null,[c],{reference:t,side:s.side??"top",align:s.align,sideOffset:s.sideOffset,alignOffset:s.alignOffset})}};class y extends n{picker;_skipTextUpdate=!1;_popover=void 0;constructor(t,s,i,n={}){(s=s??"#000000").constructor===String&&s.includes("oklch")&&(s=e.LX.oklchToHex(s));const a=n.useAlpha??(s.constructor===Object&&"a"in s||s.constructor===String&&[5,9].includes(s.length)),r=new g(s);s=a?r.hex:r.hex.substring(0,7),super(e.ComponentType.COLOR,t,s,n),this.onGetValue=()=>{const e=new g(s);return n.useRGB?e.rgb:s},this.onSetValue=(e,r,l)=>{const c=new g(e);if(d.style.color=s=c.hex.substring(0,7),a&&(u.style.color=s=c.hex),this._skipTextUpdate||p.set(s,!0,l),!r){let e=s;n.useRGB&&(e=c.rgb,a||delete e.a),this._trigger(new o(t,e,l),i)}},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};var l=document.createElement("span");l.className="lexcolor",this.root.appendChild(l),this.picker=new f(s,{colorModel:n.useRGB?"RGB":"Hex",useAlpha:a,onChange:e=>{this.set(e.hex)}});let c=e.LX.makeContainer(["18px","18px"],"flex flex-row rounded overflow-hidden","",l);c.tabIndex="1",c.addEventListener("click",e=>{this.disabled||(this._popover=new C(c,[this.picker]))});let d=document.createElement("div");d.className="lexcolorsample",d.style.color=s,c.appendChild(d);let u=null;a?(u=document.createElement("div"),u.className="lexcolorsample",u.style.color=s,c.appendChild(u)):d.style.width="18px";const p=new h(null,s,e=>{this._skipTextUpdate=!0,this.set(e),delete this._skipTextUpdate,this.picker.fromHexColor(e)},{width:"calc( 100% - 24px )",disabled:this.disabled});p.root.style.marginLeft="6px",l.appendChild(p.root),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Color=g,e.LX.ColorPicker=f,e.LX.ColorInput=y;class v extends n{constructor(t,s,i={}){const n=!i.noSelection;let r=n&&(i.toggle??!1),l=document.createElement("div");l.className="lexcombobuttons flex justify-center",i.skipReset=!0,i.float&&(l.className=e.LX.mergeClass(l.className,`justify-${i.float}`));let c=[],h=e.LX.makeElement("div","flex w-max bg-secondary pad-sm rounded-lg gap-1","",l);for(let t of s){if(!t.value)throw"Set 'value' for each button!";const s=e=>{c=[],n&&(r?o.classList.toggle("selected"):(l.querySelectorAll("button").forEach(e=>e.classList.remove("selected")),o.classList.add("selected"))),l.querySelectorAll("button").forEach(e=>{e.classList.contains("selected")&&c.push(e.dataset.value)}),!r&&c.length>1?console.error("Enable _options.toggle_ to allow selecting multiple options in ComboButtons."):(c=c[0],this.set(t.value,!1,o.classList.contains("selected")))};let o=new a(t.name??null,t.value,s,{title:t.icon?t.value:"",icon:t.icon,disabled:t.disabled,buttonClass:e.LX.mergeClass("combo w-auto",i.buttonClass)}).root.querySelector("button");o.id=t.id??"",o.dataset.value=t.value,n&&(t.selected||i.selected?.includes(t.value))&&(o.classList.add("selected"),c=c.concat([t.value])),h.appendChild(o)}c.length>1?r||(i.toggle=!0,r=n,console.warn(`Multiple options selected in '${t}' ComboButtons. Enabling _toggle_ mode.`)):c=c[0],super(e.ComponentType.BUTTONS,t,null,i),this.onGetValue=()=>c,this.onSetValue=(e,i,a)=>{if(n&&null==a&&(l.querySelectorAll("button").forEach(e=>e.classList.remove("selected")),l.querySelectorAll("button").forEach(e=>{c&&c.indexOf(e.dataset.value)>-1&&e.classList.add("selected")})),!i&&e.constructor!=Array){const i=a,n=s.filter(t=>t.value==e)[0]?.callback;this._trigger(new o(t,r?[e,i]:e,null),n)}},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`},this.root.appendChild(l),e.LX.doAsync(this.onResize.bind(this))}}e.LX.ComboButtons=v;class L extends n{count;constructor(t,s,i,n={}){super(e.ComponentType.COUNTER,t,s,n),this.onGetValue=()=>this.count,this.onSetValue=(s,n,a)=>{this.count=e.LX.clamp(s,r,l),d.value=this.count,n||this._trigger(new o(t,s,a),i)},this.count=s;const r=n.min??0,l=n.max??100,c=n.step??1,h=document.createElement("div");h.className="flex flex-row border-color bg-card rounded-lg shadow",this.root.appendChild(h);const d=e.LX.makeElement("input","lexcounter w-12 bg-card px-2 text-foreground","",h);d.type="number",d.value=s,d.disabled=this.disabled;const u=new a(null,"",(e,t)=>{let s=c??1;t.shiftKey&&(s*=10),this.set(this.count-s,!1,t)},{disabled:this.disabled,className:`p-0 ${this.disabled?"":"hover:bg-secondary"} border-l-color border-r-color`,buttonClass:"px-0 bg-none h-7",icon:"Minus"});h.appendChild(u.root);const p=new a(null,"",(e,t)=>{let s=c??1;t.shiftKey&&(s*=10),this.set(this.count+s,!1,t)},{disabled:this.disabled,className:`p-0 ${this.disabled?"":"hover:bg-secondary"} rounded-r-lg`,buttonClass:"px-0 bg-none h-7",icon:"Plus"});h.appendChild(p.root)}}e.LX.Counter=L;class b{element;canvas;constructor(t,s={}){let i=document.createElement("div");i.className=e.LX.mergeClass("curve [&_canvas]:rounded",s.className),i.style.minHeight="50px",i.style.width=s.width||"100%",i.style.minWidth="50px",i.style.minHeight="20px",i.bgcolor=s.bgColor||e.LX.getCSSVariable("background"),i.pointscolor=s.pointsColor||e.LX.getCSSVariable("primary"),i.activepointscolor=s.activePointsColor||e.LX.getCSSVariable("primary/50"),i.linecolor=s.lineColor||"#555",i.value=t||[],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??e.LX.CURVE_MOVEOUT_DELETE,e.LX.addSignal("@on_new_color_scheme",(t,o)=>{i.bgcolor=s.bgColor||e.LX.getCSSVariable("background"),i.pointscolor=s.pointsColor||e.LX.getCSSVariable("primary"),i.activepointscolor=s.activePointsColor||e.LX.getCSSVariable("primary/50"),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(t){document.addEventListener("mousemove",c),document.addEventListener("mouseup",h);var s=o.getBoundingClientRect(),d=t.clientX-s.left,m=t.clientY-s.top;if(r=function(e,t){for(var s=1e5,o=-1,a=0;a<i.value.length;a++){var r=u([e,t],n(i.value[a]));r<s&&r<8&&(s=r,o=a)}return o}(d,o.height-m),t.button==e.LX.MOUSE_LEFT_CLICK&&-1==r&&i.allow_add_values){var g=a([d,o.height-m]);i.value.push(g),p(),r=i.value.indexOf(g)}l=[d,m],i.redraw(),t.preventDefault(),t.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 r=-1;i.redraw=function(t={}){t.value&&(i.value=t.value),t.xrange&&(i.xrange=t.xrange),t.yrange&&(i.yrange=t.yrange),t.smooth&&(i.smooth=t.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 l=[a[0],a[1]];for(var c in i.value){a=n(i.value[c]),l.push(a[0]),l.push(a[1]),i.smooth||s.lineTo(a[0],a[1])}a=n([i.xrange[1],i.defaulty]),l.push(a[0]),l.push(a[1]),i.smooth?e.LX.drawSpline(s,l,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==r;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 l=[0,0];function c(t){var s=o.getBoundingClientRect(),n=t.clientX-s.left,c=t.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=[t.clientX-s.left,t.clientY-s.top];if(-1!=r&&u(m,[n,c])>.5*o.height){if(i.move_out==e.LX.CURVE_MOVEOUT_DELETE)i.value.splice(r,1);else{const e=[m[0]-n,m[1]-c];let t=i.value[r];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(t)}else{var g=a([-(i.draggable_x?l[0]-n:0),i.draggable_y?l[1]-c:0]);if(-1!=r){var f=i.xrange[0],C=i.xrange[1];i.no_overlap&&(r>0&&(f=i.value[r-1][0]),r<i.value.length-1&&(C=i.value[r+1][0]));var y=i.value[r];y[0]+=g[0],y[1]+=g[1],y[0]<f?y[0]=f:[0]>C&&(y[0]=C),y[1]<i.yrange[0]?y[1]=i.yrange[0]:y[1]>i.yrange[1]&&(y[1]=i.yrange[1])}p(),i.redraw(),l[0]=n,l[1]=c,d(t),t.preventDefault(),t.stopPropagation()}}function h(e){r=-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!=r&&(e=i.value[r]),i.value.sort(function(e,t){return e[0]-t[0]}),e&&(r=i.value.indexOf(e))}return i.redraw(),this}redraw(e={}){this.element.redraw(e)}}class x extends n{curveInstance;constructor(t,s,i,n={}){let a=JSON.parse(JSON.stringify(s));super(e.ComponentType.CURVE,t,a,n),this.onGetValue=()=>JSON.parse(JSON.stringify(l.element.value)),this.onSetValue=(e,s,n)=>{l.element.value=JSON.parse(JSON.stringify(e)),l.redraw(),s||this._trigger(new o(t,l.element.value,n),i)},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),n.callback=(e,s)=>{this._trigger(new o(t,e,s),i)},n.name=t;let l=new b(s,n);r.appendChild(l.element),this.curveInstance=l;new ResizeObserver(e=>{for(const t of e)l.canvas.width=t.contentRect.width,l.redraw()}).observe(r),e.LX.doAsync(this.onResize.bind(this))}}e.LX.CanvasCurve=b,e.LX.Curve=x;class _{root;day=-1;month=-1;year=-1;monthName="";firstDay=-1;daysInMonth=-1;calendarDays=[];currentDate;range;untilToday;fromToday;skipPrevMonth;skipNextMonth;onChange;onPreviousMonth;onNextMonth;constructor(t,s={}){if(this.root=e.LX.makeContainer(["256px","auto"],"p-1 flex flex-col gap-2 text-sm"),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,t)this.fromDateString(t);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 t=e.LX.makeContainer(["100%","auto"],"flex flex-row p-1","",this.root);if(!this.skipPrevMonth){const s=e.LX.makeIcon("Left",{title:"Previous Month",iconClass:"border-color p-1 rounded hover:bg-secondary",svgClass:"sm"});t.appendChild(s),s.addEventListener("click",()=>{this._previousMonth()})}if(e.LX.makeContainer(["100%","auto"],"text-center font-medium select-none",`${this.monthName} ${this.year}`,t),!this.skipNextMonth){const s=e.LX.makeIcon("Right",{title:"Next Month",iconClass:"border-color p-1 rounded hover:bg-secondary",svgClass:"sm"});t.appendChild(s),s.addEventListener("click",()=>{this._nextMonth()})}}{const t=document.createElement("table");t.className="w-full",this.root.appendChild(t);{const e=document.createElement("thead");t.appendChild(e);const s=document.createElement("tr");for(const e of["Mo","Tu","We","Th","Fr","Sa","Su"]){const t=document.createElement("th");t.className="text-muted-foreground text-xs font-normal w-10 select-none",t.innerHTML=`<span>${e}</span>`,s.appendChild(t)}e.appendChild(s)}{const s=document.createElement("tbody");t.appendChild(s);let i=this.range?e.LX.dateFromDateString(this.range[0]):null,o=this.range?e.LX.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-8 text-xs font-normal rounded select-none cursor-pointer shrink-0 grow-0";const n=new Date(`${this.month}/${e.day}/${this.year}`),a=new Date,r=!this.untilToday||n.getTime()<a.getTime(),l=!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&&r&&l,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-primary text-primary-foreground":this.range&&c&&n>i&&n<o?s.className+=" bg-accent text-accent-foreground":s.className+=` ${c?"text-secondary-foreground":"text-muted-foreground"} 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 r=42-a.length;for(let e=1;e<=r;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"}}}e.LX.Calendar=_;class k{root;fromCalendar;toCalendar;from;to;_selectingRange=!1;constructor(t,s={}){this.root=e.LX.makeContainer(["auto","auto"],"flex flex-row"),console.assert(t&&t.constructor===Array,"Range cannot be empty and has to be an Array!");let i=null,o=!1;{const s=e.LX.dateFromDateString(t[0]),n=e.LX.dateFromDateString(t[1]);if(s>n){const e=t[0];t[0]=t[1],t[1]=e,o=!0}i=(o?n.getMonth():s.getMonth())+2}this.from=t[0],this.to=t[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 _(this.from,{skipNextMonth:!0,onChange:n,onPreviousMonth:()=>{this.toCalendar._previousMonth()},range:t}),this.toCalendar=new _(this.to,{skipPrevMonth:!0,onChange:n,onNextMonth:()=>{this.fromCalendar._nextMonth()},range:t}),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 t=e.LX.dateFromDateString(this.from),s=this.fromCalendar.getMonthName(t.getMonth()),i=e.LX.dateFromDateString(this.to),o=this.toCalendar.getMonthName(i.getMonth());return`${this.fromCalendar.getFullDate(s,t.getDate(),t.getFullYear())} to ${this.toCalendar.getFullDate(o,i.getDate(),i.getFullYear())}`}}e.LX.CalendarRange=k;class S extends n{calendar;_popover=void 0;constructor(t,s,i,n={}){super(e.ComponentType.DATE,t,null,n);const r=s?.constructor===Array;if(!r&&n.today){const e=new Date;s=`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()}`}this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{r||this.calendar.fromDateString(e),s=e,c(this.calendar.getFullDate()),n||this._trigger(new o(t,e,a),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};const l=e.LX.makeContainer(["auto","auto"],"lexdate flex flex-row");this.root.appendChild(l),this.calendar=r?new k(s,{onChange:e=>{this.set(e)},...n}):new _(s,{onChange:e=>{const t=`${e.day}/${e.month}/${e.year}`;this.set(t)},...n});const c=t=>{const s=!!t;l.innerHTML="";const i=(t=t??"Pick a date").split(" to "),o=r?i[0]:t,n=e.LX.makeIcon("Calendar"),c=new a(null,o,()=>{this._popover=new C(c.root,[this.calendar])},{disabled:this.disabled,buttonClass:`outline flex flex-row px-3 ${s?"":"text-muted-foreground"} justify-between`});if(c.root.querySelector("button").appendChild(n),c.root.style.width="100%",l.appendChild(c.root),r){const t=e.LX.makeIcon("ArrowRight");e.LX.makeContainer(["32px","auto"],"content-center",t.innerHTML,l);const o=i[1],n=e.LX.makeIcon("Calendar"),r=new a(null,o,()=>{this._popover=new C(r.root,[this.calendar])},{disabled:this.disabled,buttonClass:`outline flex flex-row px-3 ${s?"":"text-muted-foreground"} justify-between`});r.root.querySelector("button").appendChild(n),r.root.style.width="100%",l.appendChild(r.root)}};s?c(this.calendar.getFullDate()):c(),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Calendar=_,e.LX.CalendarRange=k,e.LX.DatePicker=S;class w{element;canvas;constructor(t,s={}){let i=document.createElement("div");i.className=e.LX.mergeClass("dial",s.className),i.style.width=i.style.height=s.size||"100%",i.style.minWidth=i.style.minHeight="50px",i.bgcolor=s.bgColor||e.LX.getCSSVariable("background"),i.pointscolor=s.pointsColor||e.LX.getCSSVariable("primary/50"),i.linecolor=s.lineColor||"#555",i.value=t||[],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??e.LX.CURVE_MOVEOUT_DELETE,e.LX.addSignal("@on_new_color_scheme",(t,o)=>{i.bgcolor=s.bgColor||e.LX.getCSSVariable("background"),i.pointscolor=s.pointsColor||e.LX.getCSSVariable("primary/50"),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(t){document.addEventListener("mousemove",c),document.addEventListener("mouseup",h);var s=o.getBoundingClientRect(),d=t.clientX-s.left,m=t.clientY-s.top;if(r=function(e,t){for(var s=1e5,o=-1,a=0;a<i.value.length;a++){var r=u([e,t],n(i.value[a]));r<s&&r<8&&(s=r,o=a)}return o}(d,o.height-m),t.button==e.LX.MOUSE_LEFT_CLICK&&-1==r&&i.allow_add_values){var g=a([d,o.height-m]);i.value.push(g),p(),r=i.value.indexOf(g)}l=[d,m],i.redraw(),t.preventDefault(),t.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 r=-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 l in i.value){s=n(i.value[l]),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==r;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 l=[0,0];function c(t){var s=o.getBoundingClientRect(),n=t.clientX-s.left,c=t.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=[t.clientX-s.left,t.clientY-s.top];if(-1!=r&&u(m,[n,c])>.5*o.height){if(i.move_out==e.LX.CURVE_MOVEOUT_DELETE)i.value.splice(r,1);else{const e=[m[0]-n,m[1]-c];let t=i.value[r];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(t)}else{var g=a([-(i.draggable_x?l[0]-n:0),i.draggable_y?l[1]-c:0]);if(-1!=r){var f=i.xrange[0],C=i.xrange[1];i.no_overlap&&(r>0&&(f=i.value[r-1][0]),r<i.value.length-1&&(C=i.value[r+1][0]));var y=i.value[r];y[0]+=g[0],y[1]+=g[1],y[0]<f?y[0]=f:y[0]>C&&(y[0]=C),y[1]<i.yrange[0]?y[1]=i.yrange[0]:y[1]>i.yrange[1]&&(y[1]=i.yrange[1])}p(),i.redraw(),l[0]=n,l[1]=c,d(t),t.preventDefault(),t.stopPropagation()}}function h(e){r=-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!=r&&(e=i.value[r]),i.value.sort(function(e,t){return e[0]-t[0]}),e&&(r=i.value.indexOf(e))}return i.redraw(),this}redraw(e={}){this.element.redraw(e)}}e.LX.CanvasDial=w;class T extends n{dialInstance;constructor(t,s,i,n={}){let a=JSON.parse(JSON.stringify(s));super(e.ComponentType.DIAL,t,a,n),this.onGetValue=()=>JSON.parse(JSON.stringify(l.element.value)),this.onSetValue=(e,s,n)=>{l.element.value=JSON.parse(JSON.stringify(e)),l.redraw(),s||this._trigger(new o(t,l.element.value,n),i)},this.onResize=t=>{const s=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${s})`,e.LX.flushCss(r),l.element.style.height=l.element.offsetWidth+"px",l.canvas.width=l.element.offsetWidth,r.style.width=l.element.offsetWidth+"px",l.canvas.height=l.canvas.width,l.redraw()};var r=document.createElement("div");r.className="lexcurve",this.root.appendChild(r),n.callback=(e,s)=>{this._trigger(new o(t,e,s),i)},n.name=t;let l=new w(s,n);r.appendChild(l.element),this.dialInstance=l,e.LX.doAsync(this.onResize.bind(this))}}e.LX.CanvasDial=w,e.LX.Dial=T;class E extends n{constructor(t,s,i={}){super(e.ComponentType.FILE,t,null,i);let o=i.local??!0,n=i.type??"text",r=i.read??!0;this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};let l=document.createElement("input");if(l.className="lexfileinput",l.type="file",l.disabled=this.disabled,this.root.appendChild(l),i.placeholder&&(l.placeholder=i.placeholder),l.addEventListener("change",function(e){const t=e.target.files;if(t.length)if(r){i.onBeforeRead&&i.onBeforeRead();const e=new FileReader;"text"===n?e.readAsText(t[0]):"buffer"===n?e.readAsArrayBuffer(t[0]):"bin"===n?e.readAsBinaryString(t[0]):"url"===n&&e.readAsDataURL(t[0]),e.onload=e=>{s.call(this,e.target?.result,t[0])}}else s(t[0])}),l.addEventListener("cancel",function(e){s(null)}),o){let t=null;const s=new a(null,"",()=>{t||(t=new e.LX.Dialog("Load Settings",e=>{e.addSelect("Type",["text","buffer","bin","url"],n,e=>{n=e}),e.addButton(null,"Reload",()=>{l.dispatchEvent(new Event("change"))})},{onclose:e=>{e.remove(),t=null}}))},{skipInlineCount:!0,title:"Settings",disabled:this.disabled,icon:"Settings"});this.root.appendChild(s.root)}e.LX.doAsync(this.onResize.bind(this))}}e.LX.FileInput=E;class M extends n{data;formData={};primaryButton;constructor(t,s,i,o={}){if(s.constructor!=Object)return void console.error("Form data must be an Object");o.hideName=!0,super(e.ComponentType.FORM,t,null,o),this.onGetValue=()=>this.formData,this.onSetValue=(t,s,i)=>{this.formData=t;const o=r.querySelectorAll(".lexcomponent");for(let i=0;i<o.length;++i){if(o[i].jsInstance.type!=e.ComponentType.TEXT)continue;let a=o[i].querySelector(".lexcomponentname").innerText,r=o[i].querySelector(".lextext input");r.value=t[a]??"",n._dispatchEvent(r,"focusout",s)}};let r=document.createElement("div");r.className="flex flex-col gap-1",r.style.width="100%",this.root.appendChild(r);for(let t in s){let i=s[t];if(i.constructor!=Object){const o=e.LX.deepCopy(i);i={value:o},s[t]=i}if(i.width="100%",i.placeholder=i.placeholder??i.label??`Enter ${t}`,i.ignoreValidation=!0,!o.skipLabels){const e=new h(null,i.label??t,null,{disabled:!0,inputClass:"formlabel text-xs bg-none text-muted-foreground"});r.appendChild(e.root)}i.textComponent=new h(null,i.constructor==Object?i.value:i,(e,s)=>{this.formData[t]=e,i.submit&&s?.constructor===KeyboardEvent&&this.submit()},i),r.appendChild(i.textComponent.root),this.formData[t]=i.constructor==Object?i.value:i}const l=e.LX.makeContainer(["100%","auto"],"flex flex-row mt-2","",r);if(o.secondaryActionName||o.secondaryActionCallback){const e=new a(null,o.secondaryActionName??"Cancel",(e,t)=>{o.secondaryActionCallback&&o.secondaryActionCallback(this.formData,t)},{width:"100%",minWidth:"0",buttonClass:o.secondaryButtonClass??"secondary"});l.appendChild(e.root)}this.primaryButton=new a(null,o.primaryActionName??"Submit",(t,o)=>{this.syncInputs();const n=[];for(let t in s){let i=s[t];const o=i.pattern,a=o?.fieldMatchName?this.formData[o.fieldMatchName]:void 0;if(!i.textComponent.valid(void 0,a)){const s={entry:t,type:"input_not_valid",messages:[]};o&&(s.messages=e.LX.validateValueAtPattern(this.formData[t],o,a)),n.push(s)}}i&&i(this.formData,n,o)},{width:"100%",minWidth:"0",buttonClass:o.primaryButtonClass??"primary"}),l.appendChild(this.primaryButton.root),o.skipEnterSubmit||this.root.addEventListener("keydown",e=>{if("Enter"!==e.key||e.shiftKey)return;"TEXTAREA"!==e.target.tagName&&(e.preventDefault(),this.submit())}),this.data=s}submit(){this.syncInputs(),this.primaryButton?.click()}syncInputs(){for(const e in this.data){const t=this.data[e].textComponent;t instanceof h&&(t.syncFromDOM(),this.formData[e]=t.value())}}}e.LX.Form=M;class A extends n{setLayers;constructor(t,s,i,n={}){super(e.ComponentType.LAYERS,t,s,n),this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{s=e,this.setLayers(s),n||this._trigger(new o(t,s,a),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=`calc( 100% - ${t})`};const a=e.LX.makeElement("div","lexlayers grid","",this.root),r=n.maxBits??16;this.setLayers=e=>{a.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("button");if(i.className="lexlayer size-6 text-secondary-foreground text-center content-center place-self-center cursor-pointer font-semibold text-xs rounded-lg select-none \n disabled:pointer-events-none disabled:opacity-50",i.disabled=this.disabled,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),a.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),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Layers=A;class X extends n{_updateValues;constructor(t,s,i,n,a={}){super(e.ComponentType.LIST,t,i,a),this.onGetValue=()=>i,this.onSetValue=(e,a,l)=>{r.querySelectorAll(".lexlistitem").forEach(e=>e.classList.remove("selected"));let c=null;for(let t=0;t<s.length;++t){const i=s[t];if(i==e||i.constructor==Array&&i[0]==e){c=t;break}}c?(r.children[c].classList.toggle("selected"),i=e,a||this._trigger(new o(t,e,l),n)):console.error(`Cannot find item ${e} in List.`)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${t})`},this._updateValues=a=>{s=a,r.innerHTML="";for(let a=0;a<s.length;++a){let l=null,c=s[a];c.constructor===Array&&(l=c[1],c=c[0]);let h=document.createElement("button");h.className="lexlistitem disabled:pointer-events-none disabled:opacity-50 "+(i==c?"selected":""),h.disabled=this.disabled,l&&h.appendChild(e.LX.makeIcon(l)),h.innerHTML+=`<span>${c}</span>`,h.addEventListener("click",e=>{r.querySelectorAll(".lexlistitem").forEach(e=>e.classList.remove("selected")),h.classList.toggle("selected"),i=c,this._trigger(new o(t,c,e),n)}),r.appendChild(h)}};let r=document.createElement("div");r.className="bg-background flex flex-col gap-1 rounded-xl border-color p-2",this.root.appendChild(r),this._updateValues(s),e.LX.doAsync(this.onResize.bind(this))}}e.LX.List=X;let P=class t{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(e,s=new t){return s.set(this.x+e.x,this.y+e.y),s}sub(e,s=new t){return s.set(this.x-e.x,this.y-e.y),s}mul(e,s=new t){return e.constructor==Number&&(e=new t(e)),s.set(this.x*e.x,this.y*e.y),s}div(e,s=new t){return e.constructor==Number&&(e=new t(e)),s.set(this.x/e.x,this.y/e.y),s}abs(e=new t){return e.set(Math.abs(this.x),Math.abs(this.y)),e}dot(e){return this.x*e.x+this.y*e.y}len2(){return this.dot(this)}len(){return Math.sqrt(this.len2())}nrm(e=new t){return e.set(this.x,this.y),e.mul(1/this.len(),e)}dst(e){return e.sub(this).len()}clp(s,i,o=new t){return o.set(e.LX.clamp(this.x,s,i),e.LX.clamp(this.y,s,i)),o}fromArray(e){this.x=e[0],this.y=e[1]}toArray(){return this.xy}};e.LX.vec2=P;class N{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 P(0,0);circleCenter=[0,0];circleRadius=1;margin=8;dragging=!1;_valuesChanged=!0;_selectedPoint=null;_precomputedWeightsGridSize=0;_precomputedWeights=null;constructor(t,s,i={}){this.circular=i.circular??!1,this.showNames=i.showNames??!0,this.size=i.size??[200,200],this.points=t??[],this.callback=s,this._valuesChanged=!0,this._selectedPoint=null,this.root=e.LX.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(t){if(!o.dragging)return;const s=o.margin,i=o.root.getBoundingClientRect();let n=new P;n.set(t.x-i.x-.5*o.size[0],t.y-i.y-.5*o.size[1]);var a=o.currentPosition;if(a.set(e.LX.clamp(n.x/(.5*o.size[0]-s),-1,1),e.LX.clamp(n.y/(.5*o.size[1]-s),-1,1)),o.circular){const e=new P(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 r=this.canvas.getContext("2d",{willReadFrequently:!0});this.renderToCanvas(r)}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=N.GRID_SIZE;let n=0,a=new P;for(var r=0;r<o;++r)for(var l=0;l<o;++l){a.set(l/o*2-1,r/o*2-1);var c=2*l+r*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=N.GRID_SIZE,s=2*t*t;let i=new P;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,r=1e5;for(let o=0;o<e;++o){i.set(n/t*2-1,s/t*2-1);let e=new P;e.fromArray(this.points[o].pos);let l=i.dst(e);l>r||(a=o,r=l)}o[2*n+2*s*t]=a,o[2*n+2*s*t+1]=r}return o}precomputeWeightsToImage(e){if(!this.points.length)return null;const t=N.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 r=0,l=o.getImageData(0,0,t,t),c=new P;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=N.COLORS[a%N.COLORS.length];var u=e.dst(c)<s[o+1]+.001;u&&(n[a]+=1,r++),l.data[i]=p[0]+(u?128:0),l.data[i+1]=p[1]+(u?128:0),l.data[i+2]=p[2]+(u?128:0),l.data[i+3]=255}for(let e=0;e<n.length;++e)n[e]/=r;return o.putImageData(l,0,0),i}addPoint(t,s=null){if(this.findPoint(t))return void console.warn("CanvasMap2D.addPoint: There is already a point with that name");s||(s=[this.currentPosition.x,this.currentPosition.y]),s[0]=e.LX.clamp(s[0],-1,1),s[1]=e.LX.clamp(s[1],-1,1);const i={name:t,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(t){if(!t)return;const s=this.margin,i=this.size[0],o=this.size[1];t.fillStyle="black",t.strokeStyle="#BBB",t.clearRect(0,0,i,o),this.circular?(this.circleCenter[0]=.5*i,this.circleCenter[1]=.5*o,this.circleRadius=.5*o-s,t.lineWidth=1,t.beginPath(),t.arc(this.circleCenter[0],this.circleCenter[1],this.circleRadius,0,2*Math.PI),t.fill(),t.stroke(),t.beginPath(),t.moveTo(this.circleCenter[0]+.5,this.circleCenter[1]-this.circleRadius),t.lineTo(this.circleCenter[0]+.5,this.circleCenter[1]+this.circleRadius),t.moveTo(this.circleCenter[0]-this.circleRadius,this.circleCenter[1]),t.lineTo(this.circleCenter[0]+this.circleRadius,this.circleCenter[1]),t.stroke()):(t.fillRect(s,s,i-2*s,o-2*s),t.strokeRect(s,s,i-2*s,o-2*s));var n=this.precomputeWeightsToImage(this.currentPosition);n&&(t.globalAlpha=.5,t.imageSmoothingEnabled=!1,this.circular?(t.save(),t.beginPath(),t.arc(this.circleCenter[0],this.circleCenter[1],this.circleRadius,0,2*Math.PI),t.clip(),t.drawImage(n,this.circleCenter[0]-this.circleRadius,this.circleCenter[1]-this.circleRadius,2*this.circleRadius,2*this.circleRadius),t.restore()):t.drawImage(n,s,s,i-2*s,o-2*s),t.imageSmoothingEnabled=!0,t.globalAlpha=1);for(let n=0;n<this.points.length;++n){const a=this.points[n];let r=.5*a.pos[0]+.5,l=.5*a.pos[1]+.5;r=r*(i-2*s)+s,l=l*(o-2*s)+s,r=e.LX.clamp(r,s,i-s),l=e.LX.clamp(l,s,o-s),t.fillStyle=a==this._selectedPoint?"#CDF":"#BCD",t.beginPath(),t.arc(r,l,3,0,2*Math.PI),t.fill(),this.showNames&&t.fillText(a.name,r+5,l+5)}t.fillStyle="white",t.beginPath();var a=.5*this.currentPosition.x+.5,r=.5*this.currentPosition.y+.5;a=a*(i-2*s)+s,r=r*(o-2*s)+s,a=e.LX.clamp(a,s,i-s),r=e.LX.clamp(r,s,o-s),t.arc(a,r,4,0,2*Math.PI),t.fill()}}e.LX.CanvasMap2D=N;class I extends n{map2d;_popover=null;constructor(t,s,i,o={}){super(e.ComponentType.MAP2D,t,null,o),this.onGetValue=()=>this.map2d.weightsObj,this.onSetValue=(e,t,s)=>{},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";n.style.width=`calc( 100% - ${t})`};var n=document.createElement("div");n.className="lexmap2d",this.root.appendChild(n),this.map2d=new N(s,i,o);const r=e.LX.makeIcon(o.mapIcon??"SquareMousePointer"),l=new a(null,"Open Map",()=>{this._popover=new C(l.root,[this.map2d])},{buttonClass:"outline justify-between",disabled:this.disabled});l.root.querySelector("button").appendChild(r),n.appendChild(l.root),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Map2D=I;class O{domEl;data;options;selected=[];_forceClose=!1;_callbacks={};constructor(e,t,s={}){if(this.domEl=e,this.data=t,this.options=s,t.constructor===Object)this._createItem(null,t);else for(let e of t)this._createItem(null,e)}_createItem(t,s,i=0,o){const n=this,r=this.domEl.querySelector(".lexnodetreefilter");if(s.children=s.children??[],r&&""!=r.value&&!s.id.includes(r.value)){for(var l=0;l<s.children.length;++l)this._createItem(s,s.children[l],i+1,o);return}const c=this.domEl.querySelector("ul");s.visible=s.visible??!0,s.parent=t;let h=s.children.length>0,d=this.selected.indexOf(s)>-1||s.selected;if(this.options.onlyFolders){let e=!1;s.children.forEach(t=>{e=e||"folder"==t.type}),h=!!e}let u=document.createElement("li");u.className=`lextreeitem inline-flex outline-none text-sm items-center h-7 cursor-pointer truncate rounded-lg select-none datalevel${i} ${h?"parent":""} ${d?" selected":""}`,u.id=e.LX.getSupportedDOMName(s.id),u.tabIndex="0",u.treeData=s,s.treeEl=u;let p=this.options.skipDefaultIcon??1?null:"Dot";if(h&&(p=s.closed?"Right":"Down"),p&&u.appendChild(e.LX.makeIcon(p,{iconClass:"hierarchy",svgClass:"sm"})),p=s.icon,p)if(s.icon.includes(".")){const e="https://raw.githubusercontent.com/jxarco/lexgui.js/master/";u.innerHTML+=`<img src="${e+s.icon}">`}else{const t=s.icon.split(" "),i=e.LX.makeIcon(t[0],{iconClass:"tree-item-icon mr-2",svgClass:"md"+(t.length>1?` ${t.slice(0).join(" ")}`:"")});u.appendChild(i)}u.innerHTML+=s.rename?"":s.id,u.style.paddingLeft=3+15*(i+1)+"px",c.appendChild(u);const m=t&&(s.metadata?.draggable??this.options.defaultDraggable??!0);m&&u.setAttribute("draggable","true"),u.addEventListener("click",e=>{if(f)return void(f=!1);e.shiftKey||(c.querySelectorAll("li").forEach(e=>{e.classList.remove("selected")}),this.selected.length=0);const t=this.selected.indexOf(s);if(u.classList.toggle("selected",-1==t),t>-1?this.selected.splice(t,1):this.selected.push(s),h&&s.id.length>1){s.closed=!1;const t=n._callbacks.caretChanged;if(void 0!==t){t({type:"caret",items:[s],domEvent:e,userInitiated:!0})}n.frefresh(s.id)}const i=n._callbacks.select;if(void 0!==i){i({type:"select",items:[s],result:this.selected,domEvent:e,userInitiated:!0})}}),u.addEventListener("dblclick",function(e){(n.options.rename??1)&&(s.rename=!0,n.refresh());const t=n._callbacks.dblClick;if(void 0!==t){t({type:"dbl_click",items:[s],domEvent:e,userInitiated:!0})}}),u.addEventListener("contextmenu",async t=>{t.preventDefault();const i=n._callbacks.contextMenu;if(!i)return;const o={type:"context_menu",items:this.selected,from:s,domEvent:t,userInitiated:!0},a=await i(o),r=this.selected.length>1,l=this.options.useDefaultContextMenuItems??!0;e.LX.addContextMenu(this.options.contextMenuTitle??(r?"Selected Nodes":s.id),t,e=>{if(a?.length){for(const t of a)e.add(t.name,{callback:t.callback});l&&e.add("")}l&&(e.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);const i=this._callbacks.select;if(void 0!==i){i({type:"select",items:[s],result:this.selected,domEvent:t,userInitiated:!0})}}),e.add("Delete",{callback:()=>{const e=this._callbacks.beforeDelete,t=this._callbacks.delete,i=(...e)=>{let i=[];this.selected.length?i.push(...n.deleteNodes(this.selected)):n.deleteNode(s)&&i.push(s),this.refresh();t&&t({type:"delete",items:i,userInitiated:!0},...e)};if(e){e({type:"delete",items:this.selected.length?this.selected:[s],userInitiated:!0},i)}else i()}}))})}),u.addEventListener("keydown",t=>{if(!s.rename)if(t.preventDefault(),"Delete"==t.key){const e=this._callbacks.beforeDelete,s=this._callbacks.delete,i=(...e)=>{const i=[];for(let e of this.selected)n.deleteNode(e)&&i.push(e);if(this.selected.length=0,this.refresh(),i.length){s&&s({type:"delete",items:i,domEvent:t,userInitiated:!0},...e)}};if(e){e({type:"delete",items:this.selected,domEvent:t,userInitiated:!0},i)}else i()}else if("ArrowUp"==t.key||"ArrowDown"==t.key){var i=this.selected.length>1?"ArrowUp"==t.key?this.selected.shift():this.selected.pop():this.selected[0],o=this.domEl.querySelector("#"+e.LX.getSupportedDOMName(i.id)),a="ArrowUp"==t.key?o.previousSibling:o.nextSibling;a&&a.click()}});const g=document.createElement("input");g.toggleAttribute("hidden",!s.rename),g.className="text-foreground bg-none text-sm border-none outline-none",g.value=s.id,u.appendChild(g),s.rename&&(u.classList.add("selected"),g.focus()),g.addEventListener("keyup",function(t){if("Enter"==t.key){const t=n._callbacks.beforeRename,i=n._callbacks.rename,o=s.id;this.value=this.value.replace(/\s/g,"_");const a=(...t)=>{s.id=e.LX.getSupportedDOMName(this.value),delete s.rename,n.frefresh(s.id),c.querySelector(`#${s.id}`).classList.add("selected");const a={type:"rename",items:[s],oldName:o,newName:this.value,userInitiated:!0};i&&i(a,...t)};if(t){t({type:"rename",items:[s],oldName:o,newName:this.value,userInitiated:!0},a)}else a()}else"Escape"==t.key&&(delete s.rename,n.frefresh(s.id))}),g.addEventListener("blur",function(e){delete s.rename,n.refresh()}),m&&u.addEventListener("dragstart",e=>{window.__tree_node_dragged=s}),u.addEventListener("dragover",e=>{e.preventDefault()},!1),u.addEventListener("dragenter",e=>{e.target.classList.add("draggingover")}),u.addEventListener("dragend",e=>{e.target.classList.remove("draggingover")}),u.addEventListener("dragleave",e=>{e.target.classList.remove("draggingover")}),u.addEventListener("drop",e=>{e.preventDefault();let t=window.__tree_node_dragged;if(!t)return t=window.__av_item_dragged,void(t&&(t._nodeTarget=s));e.target.classList.remove("draggingover");let i=s;if(t.id==i.id)return void console.warn("Cannot parent node to itself!");const o=function(e,t){var s=!1;for(var i of t.children){if(i.id==e.id)return!0;s=s||o(e,i)}return s};if(o(i,t))return void console.warn("Cannot parent node to a current child!");const a=this._callbacks.beforeMove,r=this._callbacks.move,l=(...s)=>{const o=t.parent.children.findIndex(e=>e.id==t.id),a=t.parent.children.splice(o,1);i.children.push(a[0]),n.refresh(),delete window.__tree_node_dragged;r&&r({type:"move",items:[t],to:i,domEvent:e,userInitiated:!0},...s)};if(a){a({type:"move",items:[t],to:i,domEvent:e,userInitiated:!0},l)}else l()});let f=!1;h&&u.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;const t=n._callbacks.caretChanged;if(void 0!==t){t({type:"caret",items:[s],domEvent:e,userInitiated:!0})}n.frefresh(s.id)});const C=e.LX.makeElement("div","flex flex-row ml-auto mr-2");if(u.appendChild(C),s.actions)for(let e=0;e<s.actions.length;++e){const t=s.actions[e],i=new a(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 min-h-fit",buttonClass:"px-0 h-full bg-none"});C.appendChild(i.root)}if(!s.skipVisibility){const e=new a(null,"",(e,t)=>{t.stopPropagation(),s.visible=void 0!==s.visible&&!s.visible;const i=this._callbacks.visibleChanged;if(void 0!==i){i({type:"visibility",items:[s],domEvent:t,userInitiated:!0})}},{icon:s.visible?"Eye":"EyeOff",swap:s.visible?"EyeOff":"Eye",title:"Toggle visible",className:"p-0 min-h-fit",buttonClass:"px-0 h-full bg-none"});C.appendChild(e.root)}const y=function(e,t){if(e.id==t)return!0;let s=!1;for(var i of e?.children??[])s=s||y(i,t);return s},v=y(s,o);if(!s.closed||v)for(l=0;l<s.children.length;++l){let e=s.children[l];this.options.onlyFolders&&"folder"!=e.type||this._createItem(s,e,i+1,o)}}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(t,s){const i=this.domEl.querySelector(".lexnodetreefilter");if(i&&(i.value=""),this.refresh(null,t),this.domEl.querySelectorAll(".selected").forEach(e=>e.classList.remove("selected")),void 0===t){if(void 0===s)return void(this.selected.length=0);t=s.at(-1)}let o=null;if(void 0!==s){let e=this.data;for(const t of s){const s=e.children.find(e=>e.id===t);if(!s)break;e=s}o=e.treeEl,console.assert(o,"NodeTree: No domEl in item "+t)}else void 0!==t&&(o=this.domEl.querySelector("#"+e.LX.getSupportedDOMName(t)),console.assert(o,"NodeTree: Can't select node "+t));o||console.assert(o,"NodeTree: Can't select node "+t),o.classList.add("selected"),this.selected=[o.treeData],o.focus()}deleteNodes(e){const t=[];for(const s of e)this.deleteNode(s)&&t.push(s);return t}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}}e.LX.NodeTree=O;class R extends n{innerTree;constructor(t,s,i={}){i.hideName=!0,super(e.ComponentType.TREE,t,null,i);let o=e.LX.makeElement("div","lextree p-1 rounded-lg w-full my-0 mx-auto font-medium text-sm min-h-3","",this.root);t&&e.LX.makeElement("span","block p-1 select-none text-base font-medium whitespace-nowrap",t,o);let n=e.LX.makeElement("div","lextreetools flex items-center bg-secondary px-2 rounded-lg gap-2 my-1");if(t||(n.className+=" notitle"),i.icons)for(let t of i.icons){const s=e.LX.makeIcon(t.icon,{title:t.name});s.addEventListener("click",t.callback),n.appendChild(s)}i.filter=i.filter??!0;let a=null;if(i.filter){a=document.createElement("input"),a.className="lexnodetreefilter",a.setAttribute("placeholder","Filter.."),a.style.width="100%",a.addEventListener("input",()=>{this.innerTree.refresh()});let t=e.LX.makeIcon("Search");n.appendChild(a),n.appendChild(t)}(i.icons||i.filter)&&o.appendChild(n);let r=e.LX.makeElement("ul","flex flex-col gap-1 ps-0");r.addEventListener("contextmenu",function(e){e.preventDefault()}),o.appendChild(r),this.innerTree=new O(o,s,i)}on(e,t){this.innerTree._callbacks[e]=t}}e.LX.Tree=R;class z extends n{constructor(t,s,i,n={}){const a=n.pattern??"xxx-xxx",r=(a.match(/x/g)||[]).length;(s=String(s)).length||(s="x".repeat(r)),super(e.ComponentType.OTP,t,s,n),this.onGetValue=()=>+s,this.onSetValue=(e,n,a)=>{h(s=e),n||this._trigger(new o(t,e,a),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};const l=document.createElement("div");l.className="lexotp flex flex-row items-center",this.root.appendChild(l);const c=a.split("-"),h=t=>{l.innerHTML="";let s=0,i=0;for(let o=0;o<c.length;++o){const n=c[o];for(let o=0;o<n.length;++o){let a=t[s++];a="x"==a?"":a;const r=e.LX.makeContainer(["36px","30px"],"lexotpslot border-t-color border-b-color border-l-color px-3 cursor-text select-none font-medium outline-none",a,l);r.tabIndex="1",this.disabled&&r.classList.add("disabled");const c=s;0==o?r.className+=" rounded-l":o==n.length-1&&(r.className+=" rounded-r border-r-color"),r.addEventListener("click",()=>{if(this.disabled)return;l.querySelectorAll(".lexotpslot").forEach(e=>e.classList.remove("active"));const e=l.querySelectorAll(".lexotpslot")[i];e.classList.add("active"),e.focus()}),r.addEventListener("blur",()=>{this.disabled||e.LX.doAsync(()=>{l.contains(document.activeElement)||l.querySelectorAll(".lexotpslot").forEach(e=>e.classList.remove("active"))},10)}),r.addEventListener("keyup",e=>{if(!this.disabled)if(/[^0-9]+/g.test(e.key))if("ArrowLeft"==e.key||"ArrowRight"==e.key){const t="ArrowLeft"==e.key?-1:1,s=l.querySelectorAll(".lexotpslot")[i+t];s&&(l.querySelectorAll(".lexotpslot")[i].classList.remove("active"),s.classList.add("active"),s.focus(),i+=t)}else"Enter"!=e.key||t.includes("x")||this.set(t);else{const s=e.key;console.assert(!Number.isNaN(parseInt(s))),r.innerHTML=s,t=t.substring(0,c-1)+s+t.substring(c);const o=l.querySelectorAll(".lexotpslot")[i+1];o?(l.querySelectorAll(".lexotpslot")[i].classList.remove("active"),o.classList.add("active"),o.focus(),i++):this.set(t)}})}o<c.length-1&&e.LX.makeContainer(["auto","auto"],"mx-2","-",l)}console.assert(s==t.length,"OTP Value/Pattern Mismatch!")};h(s)}}e.LX.OTPInput=z;class D extends n{constructor(t,s,i,n={}){super(e.ComponentType.PAD,t,null,n),this.onGetValue=()=>l.value.xy,this.onSetValue=(e,s,n)=>{l.value.set(e[0],e[1]),c(l.value),s||this._trigger(new o(t,l.value.xy,n),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=`calc( 100% - ${t})`};let a=document.createElement("div");a.className="lexpad",this.root.appendChild(a);let r=document.createElement("div");r.id="lexpad-"+t,r.className="lexinnerpad data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 border-color",r.style.width=n.padSize??"96px",r.style.height=n.padSize??"96px",r.dataset.disabled=this.disabled.toString(),a.appendChild(r);let l=document.createElement("div");l.className="lexpadthumb opacity-inherit",l.value=new P(s[0],s[1]),l.min=n.min??0,l.max=n.max??1,r.appendChild(l);let c=t=>{const[s,i]=[r.offsetWidth,r.offsetHeight],o=new P(e.LX.remapRange(t.x,l.min,l.max,0,1),e.LX.remapRange(t.y,l.min,l.max,0,1));l.style.transform=`translate(calc( ${s*o.x}px - 50% ), calc( ${i*o.y}px - 50%)`};r.addEventListener("mousedown",function(e){if(document.activeElement==l)return;var t=h.root.ownerDocument;t.addEventListener("mousemove",d),t.addEventListener("mouseup",u),document.body.classList.add("nocursor"),document.body.classList.add("noevents"),e.stopImmediatePropagation(),e.stopPropagation(),l.classList.add("active"),n.onPress&&n.onPress.bind(l)(e,l)});let h=this;function d(s){const n=r.getBoundingClientRect(),a=new P(s.x-n.x,s.y-n.y);a.clp(0,r.offsetWidth,a);const[c,d]=[r.offsetWidth,r.offsetHeight],u=a.div(new P(r.offsetWidth,r.offsetHeight));l.style.transform=`translate(calc( ${c*u.x}px - 50% ), calc( ${d*u.y}px - 50%)`,l.value=new P(e.LX.remapRange(u.x,0,1,l.min,l.max),e.LX.remapRange(u.y,0,1,l.min,l.max)),h._trigger(new o(t,l.value.xy,s),i),s.stopPropagation(),s.preventDefault()}function u(e){var t=h.root.ownerDocument;t.removeEventListener("mousemove",d),t.removeEventListener("mouseup",u),document.body.classList.remove("nocursor"),document.body.classList.remove("noevents"),l.classList.remove("active"),n.onRelease&&n.onRelease.bind(l)(e,l)}e.LX.doAsync(()=>{this.onResize(),c(l.value)})}}e.LX.Pad=D;class B extends n{constructor(t,s,i={}){super(e.ComponentType.PROGRESS,t,s,i),this.onGetValue=()=>a.value,this.onSetValue=(s,n,l)=>{s=e.LX.clamp(s,a.min,a.max),this.root.querySelector("meter").value=s,r(),this.root.querySelector("span")&&(this.root.querySelector("span").innerText=s),n||this._trigger(new o(t,s,l),i.callback)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";n.style.width=`calc( 100% - ${t})`};const n=e.LX.makeElement("div","flex justify-center items-center gap-2","",this.root);let a=e.LX.makeElement("meter","lexprogressbar outline-none rounded-lg select-none");a.id="lexprogressbar-"+t,a.step="any",a.min=i.min??0,a.max=i.max??1,a.low=i.low??a.low,a.high=i.high??a.high,a.optimum=i.optimum??a.optimum,a.value=s,n.appendChild(a);const r=()=>{let t=e.LX.getCSSVariable("color-blue-500");null!=a.low&&a.value<a.low?t=e.LX.getCSSVariable("destructive"):null!=a.high&&a.value<a.high&&(t=e.LX.getCSSVariable("warning")),a.style.background=`color-mix(in srgb, ${t} 20%, transparent)`};if(i.showValue){const i=document.getElementById("progressvalue-"+t);i&&i.remove(),e.LX.makeElement("span","w-12 flex-auto-keep text-center",s,n).id="progressvalue-"+t}if(i.editable){a.classList.add("editable");let t=t=>{var o=this.root.ownerDocument;o.addEventListener("mousemove",s),o.addEventListener("mouseup",i),document.body.classList.add("noevents"),a.classList.add("grabbing"),t.stopImmediatePropagation(),t.stopPropagation();const n=a.getBoundingClientRect(),r=e.LX.round(e.LX.remapRange(t.offsetX,0,n.width,a.min,a.max));this.set(r,!1,t)},s=t=>{if(0!=t.movementX){const s=a.getBoundingClientRect(),i=e.LX.round(e.LX.remapRange(t.offsetX-s.x,0,s.width,a.min,a.max));this.set(i,!1,t)}t.stopPropagation(),t.preventDefault()},i=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",s),t.removeEventListener("mouseup",i),document.body.classList.remove("noevents"),a.classList.remove("grabbing")};a.addEventListener("mousedown",t)}r(),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Progress=B;class H extends n{constructor(t,s,i,n,a={}){super(e.ComponentType.RADIO,t,null,a);let r=null;this.onGetValue=()=>{const e=l.querySelectorAll("button");return r?[r,e[r]]:void 0},this.onSetValue=(e,t,s)=>{e=e[0]??e,console.assert(e.constructor==Number,"RadioGroup _value_ must be an Array index!");const a=l.querySelectorAll("button");a.forEach(e=>{e.checked=!1,e.classList.remove("checked")});const r=a[e];r.checked=!r.checked,r.classList.toggle("checked"),t||this._trigger(new o(null,[e,i[e]],s),n)};var l=document.createElement("div");l.className=e.LX.mergeClass("lexradiogroup flex flex-col",a.className),this.root.appendChild(l),e.LX.makeElement("span","font-medium mb-2",s,l);for(let e=0;e<i.length;++e){const t=document.createElement("div");t.className="lexradiogroupitem flex items-center gap-2 px-6 py-1",l.appendChild(t);const s=document.createElement("button");s.className="flex p-0 rounded-lg cursor-pointer",s.disabled=this.disabled,t.appendChild(s),s.addEventListener("click",t=>{this.set(e,!1,t)});const o=document.createElement("span");s.appendChild(o);const n=document.createElement("span");n.innerHTML=i[e],t.appendChild(n)}a.selected&&(console.assert(a.selected.constructor==Number,"RadioGroup _selected_ must be an Array index!"),r=a.selected,this.set(r,!0))}}e.LX.RadioGroup=H;class F extends n{_maxSlider=null;_labelTooltip=null;setLimits;constructor(t,s,i,a={}){const r=e.LX.deepCopy(s);super(e.ComponentType.RANGE,t,e.LX.deepCopy(r),a);const l=s.constructor==Array&&2==s.length;l&&(s=r[0],a.fill=!1),this.onGetValue=()=>{let e=s;return l?e=[s,r[1]]:a.left&&(e=+h.max-s+ +h.min),e},this.onSetValue=(n,d,u)=>{let p="";const m=a.max-a.min;if(l&&this._maxSlider){h.value=s=e.LX.clamp(+n[0],+h.min,+h.max),this._maxSlider.value=r[1]=e.LX.clamp(+n[1],+h.min,+h.max);const t=s/m-.5,i=r[1]/m-.5,o=e.LX.remapRange(s,a.min,a.max,0,1),l=e.LX.remapRange(r[1],a.min,a.max,0,1);h.style.setProperty("--range-min-value",100*o+"%"),h.style.setProperty("--range-max-value",100*l+"%"),h.style.setProperty("--range-fix-min-offset",-t+"rem"),h.style.setProperty("--range-fix-max-offset",`${i}rem`),c.dataset.tooltipOffsetX=""+(c.offsetWidth*o+c.offsetWidth*(l-o)*.5-.5*c.offsetWidth),p=`${s} - ${r[1]}`}else{if(isNaN(n))return;h.value=s=e.LX.clamp(+n,+h.min,+h.max);const t=.5*e.LX.remapRange(s,a.min,a.max,0,1);c.dataset.tooltipOffsetX=""+(c.offsetWidth*t-.5*c.offsetWidth),p=`${s}`}if(c.dataset.tooltipContent=p,this._labelTooltip&&(this._labelTooltip.innerHTML=p),!d){let e=s;l?e=[s,r[1]]:a.left&&(e=+h.max-s+ +h.min),this._trigger(new o(t,e,u),i)}},this.onResize=t=>{const i=this.root.domName?.style.width??"0px";if(c.style.width=a.inputWidth??`calc( 100% - ${i})`,l){const t=a.max-a.min,i=s/t-.5,o=r[1]/t-.5;h.style.setProperty("--range-min-value",100*e.LX.remapRange(s,a.min,a.max,0,1)+"%"),h.style.setProperty("--range-max-value",100*e.LX.remapRange(r[1],a.min,a.max,0,1)+"%"),h.style.setProperty("--range-fix-min-offset",-i+"rem"),h.style.setProperty("--range-fix-max-offset",`${o}rem`)}};const c=document.createElement("div");c.className="lexrange relative py-3",this.root.appendChild(c);let h=document.createElement("input");if(h.className=e.LX.mergeClass("lexrangeslider"+(l?" range pointer-events-none":""),a.className),h.min=a.min??0,h.max=a.max??100,h.step=a.step??1,h.type="range",h.disabled=this.disabled,s.constructor==Number&&(s=e.LX.clamp(s,+h.min,+h.max)),a.left&&(s=+h.max-s+ +h.min,h.classList.add("left")),(a.fill??1)||h.classList.add("no-fill"),h.value=s,c.appendChild(h),h.addEventListener("input",e=>{this.set(l?[Math.min(e.target.valueAsNumber,r[1]),r[1]]:e.target.valueAsNumber,!1,e)},{passive:!1}),l||(h.addEventListener("mousedown",function(e){a.onPress&&a.onPress.bind(h)(e,h)},!1),h.addEventListener("mouseup",function(e){a.onRelease&&a.onRelease.bind(h)(e,h)},!1)),this.setLimits=(e,t,s)=>{h.min=e??h.min,h.max=t??h.max,h.step=s??h.step,n._dispatchEvent(h,"input",!0)},e.LX.doAsync(()=>{this.onResize();let t=0;if(l){const i=e.LX.remapRange(s,a.min,a.max,0,1),o=e.LX.remapRange(r[1],a.min,a.max,0,1);t=c.offsetWidth*i+c.offsetWidth*(o-i)*.5-.5*c.offsetWidth}else{const i=.5*e.LX.remapRange(s,a.min,a.max,0,1);t=c.offsetWidth*i-.5*c.offsetWidth}e.LX.asTooltip(c,`${s}${l?`- ${r[1]}`:""}`,{offsetX:t,callback:e=>{this._labelTooltip=e}})}),r.constructor==Array){let t=e.LX.makeElement("input",e.LX.mergeClass("lexrangeslider no-fill pointer-events-none overlap absolute left-0",a.className));t.min=a.min??0,t.max=a.max??100,t.step=a.step??1,t.type="range",t.disabled=this.disabled,this._maxSlider=t;let i=r[1];t.value=i=e.LX.clamp(i,+t.min,+t.max),c.appendChild(t),t.addEventListener("input",e=>{r[1]=Math.max(s,+e.target.valueAsNumber),this.set([s,r[1]],!1,e)},{passive:!1})}}}e.LX.RangeInput=F;class V extends n{constructor(t,s,i,n={}){const a=n.allowHalf??!1;a||(s=Math.floor(s)),super(e.ComponentType.RATE,t,s,n),this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{d(s=e),n||this._trigger(new o(t,e,a),i)},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 data-[disabled=true]:pointer-events-none",r.dataset.disabled=this.disabled.toString(),this.root.appendChild(r);const l=e.LX.makeContainer(["fit-content","auto"],"flex flex-row gap-1","",r),c=e.LX.makeContainer(["fit-content","auto"],"absolute top-0 flex flex-row gap-1 pointer-events-none","",r),h=e.LX.makeContainer(["fit-content","auto"],"absolute top-0 flex flex-row gap-1 pointer-events-none","",r);l.addEventListener("mousemove",e=>{const t=e.target,s=t.dataset.idx;if(void 0!==s){const i=t.getBoundingClientRect(),o=a&&e.offsetX<.5*i.width;d(s-(o?.5:0))}},!1),l.addEventListener("mouseleave",e=>{d(s)},!1);for(let t=0;t<5;++t){const s=e.LX.makeIcon("Star",{svgClass:"lg fill-current text-accent"});s.dataset.idx=t+1,l.appendChild(s),s.addEventListener("click",e=>{const t=e.target,s=t.getBoundingClientRect(),i=a&&e.offsetX<.5*s.width;this.set(parseFloat(t.dataset.idx)-(i?.5:0))},!1);const i=e.LX.makeIcon("Star",{svgClass:"lg fill-current text-yellow-400"});c.appendChild(i);const o=e.LX.makeIcon("StarHalf",{svgClass:"lg fill-current text-yellow-400"});h.appendChild(o)}const d=e=>{for(let t=0;t<5;++t){const s=e>t+.5,i=c.childNodes[t],o=h.childNodes[t];if(s)i.style.opacity=1;else{i.style.opacity=0;const s=a&&e>t;o.style.opacity=s?1:0}}};d(s),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Rate=V;class $ extends n{constructor(t,s,i,o={}){super(e.ComponentType.SIZE,t,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.onResize=e=>{const t=this.root.domName?.style.width??"0px";n.style.width=`calc( 100% - ${t})`},this.root.aspectRatio=2==s.length?s[0]/s[1]:null,this.root.dimensions=[];const n=e.LX.makeElement("div","flex","",this.root);for(let t=0;t<s.length;++t){const a=new e.LX.Panel;if(this.root.dimensions[t]=a.addNumber(null,s[t],e=>{const s=this.value();if(this.root.locked){const i=0==t?1/this.root.aspectRatio:this.root.aspectRatio,o=(1+t)%2;s[o]=e*i,this.root.dimensions[o].set(s[o],!0)}i&&i(s)},{min:0,disabled:this.disabled,precision:o.precision,className:"flex-auto-fill"}),n.appendChild(this.root.dimensions[t].root),t+1!=s.length){const t=e.LX.makeIcon("X",{svgClass:"text-foreground font-bold"});n.appendChild(t)}}if(o.units&&e.LX.makeElement("span","text-muted-foreground align-center content-center font-medium flex-auto-keep select-none",o.units,n),this.root.aspectRatio){const e=new a(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",className:"flex-auto-keep",buttonClass:"h-auto bg-none p-0"});n.appendChild(e.root)}e.LX.doAsync(this.onResize.bind(this))}}e.LX.SizeInput=$;class q{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=q.ITEMS_PER_PAGE_VALUES;onChange=()=>{};onItemsPerPageChange=()=>{};constructor(t={}){if(this.pages=t.pages??1,this.page=e.LX.clamp(t.page??1,1,this.pages),this._alwaysShowEdges=t.alwaysShowEdges??this._alwaysShowEdges,this._useEllipsis=t.useEllipsis??this._useEllipsis,this._maxButtons=t.maxButtons??this._maxButtons,this._itemsPerPage=t.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 t.onChange&&(this.onChange=t.onChange),"function"==typeof t.onItemsPerPageChange&&(this.onItemsPerPageChange=t.onItemsPerPageChange),this.root=e.LX.makeContainer(["auto","auto"],e.LX.mergeClass("flex flex-row gap-2",t.className)),t.allowChangeItemsPerPage){const t=e.LX.makeContainer(["auto","auto"],"flex flex-row items-center","",this.root),s=new d(null,q.ITEMS_PER_PAGE_VALUES,this._itemsPerPage,e=>{this._itemsPerPage=e,this.onItemsPerPageChange?.(this._itemsPerPage)},{overflowContainer:null});t.appendChild(s.root)}this.pagesRoot=e.LX.makeContainer(["auto","auto"],"flex flex-row overflow-scroll","",this.root),this.refresh()}setPage(t){const s=e.LX.clamp(t,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(e.LX.makeIcon("ChevronLeft").innerHTML,1===this.page,()=>this.prev(),"bg-none "+(1===this.page?"":"hover:bg-secondary"));const t=e.LX.makeContainer(["auto","auto"],"flex flex-row items-center","",this.pagesRoot),s=this._maxButtons+2;if(this.pages<=s)for(let e=1;e<=this.pages;e++)this._makePageButton(t,e);else{const i=this.page,o=this.pages,n=1,a=o,r=this._alwaysShowEdges?1:0,l=s-2,c=Math.floor(l/2);let h=Math.max(1+r,i-c),d=Math.min(o-r,i+c);h<=2&&(h=1+r,d=h+l-1),d>=o-1&&(d=o-r,h=d-l+1),this._alwaysShowEdges&&this._makePageButton(t,n),this._useEllipsis&&h>2&&e.LX.makeElement("span","h-6 px-2 text-lg font-semibold whitespace-nowrap","...",t);for(let e=h;e<=d;e++)this._makePageButton(t,e);this._useEllipsis&&d<o-1&&e.LX.makeElement("span","h-6 px-2 text-lg font-semibold whitespace-nowrap","...",t),this._alwaysShowEdges&&this._makePageButton(t,a)}this._makeButton(e.LX.makeIcon("ChevronRight").innerHTML,this.page===this.pages,()=>this.next(),"bg-none "+(this.page===this.pages?"":"hover:bg-secondary"))}_emitChange(){this.onChange?.(this.page),this.root.dispatchEvent(new CustomEvent("change",{detail:{page:this.page}}))}_makeButton(e,t,s,i,o){const n=new a(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="h-8 "+(t===this.page?"primary text-primary-foreground":"ghost");return this._makeButton(String(t),!1,()=>this.setPage(t),s,e)}}e.LX.Pagination=q;class G extends n{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(t,s,i={}){if(!s)throw"Data is needed to create a table!";super(e.ComponentType.TABLE,t,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 q({pages:this._getNumPages(),itemsPerPage:this._rowsPerPage,allowChangeItemsPerPage:i.allowChangeItemsPerPage??!0,onChange:this._onChangePage.bind(this),onItemsPerPageChange:e=>{this.rowsPerPage=e}}));const n=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],a=i[e],r=n(o),l=n(a);if(r&&l)return r.getTime()<l.getTime()?-t:r.getTime()>l.getTime()?t:0;const c=Number(o),h=Number(a);return isNaN(c)||isNaN(h)?o<a?-t:o>a?t:0:c<h?-t:c>h?t:0},l=(e,t)=>{s.body=s.body.sort(r.bind(this,e,t)),this.refresh()},c=this;if(this.filter||this.customFilters||this._toggleColumns){const t=e.LX.makeContainer(["100%","auto"],"flex flex-row mb-2");if(this.filter){const s=e.LX.deepCopy(i);s.placeholder=`Filter ${this.filter}...`,s.skipComponent=!0,s.trigger="input",s.inputClass="outline";let o=new h(null,this._currentFilter??"",e=>{this._currentFilter=e,this.refresh()},s);t.appendChild(o.root)}if(null!==this.customFilters){const s=e.LX.makeIcon("CirclePlus",{svgClass:"sm"}),i='<div class="lexcontainer border-r-color place-self-center mx-1" style="width: 1px; height: 70%;"></div>';for(let o of this.customFilters)o.component=new a(null,s.innerHTML+o.name,t=>{const n=o.component.root.querySelector("button");if(o.options){const t=o.options.map((t,a)=>{const r={name:t,checked:!!this.activeCustomFilters[t],callback:(t,a,r)=>{a?this.activeCustomFilters[t]=o.name:delete this.activeCustomFilters[t];const l=Object.keys(this.activeCustomFilters).filter(e=>this.activeCustomFilters[e]==o.name),c=l.reduce((t,s)=>t+e.LX.badge(s,"xs secondary"),"");n.innerHTML=s.innerHTML+o.name+(l.length?i:"")+c,this.refresh()}};return r});e.LX.addDropdownMenu(o.component.root,t,{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 t=e.LX.makeContainer(["240px","auto"],"text-base"),a=new e.LX.Panel({className:"flex flex-col gap-2"});e.LX.makeContainer(["100%","auto"],"px-3 p-2 pb-0 text-base font-medium",o.name,t),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,t=>{o.start=t;const a=o.start!=o.min||o.end!=o.max;n.innerHTML=s.innerHTML+o.name+(a?i+e.LX.badge(`${o.start} - ${o.end} ${o.units??""}`,"xs secondary"):""),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,t=>{o.end=t;const a=o.start!=o.min||o.end!=o.max;n.innerHTML=s.innerHTML+o.name+(a?i+e.LX.badge(`${o.start} - ${o.end} ${o.units??""}`,"xs secondary"):""),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:"ghost"})},a.refresh(),t.appendChild(a.root),new C(o.component.root,[t],{side:"bottom"})}else if("date"==o.type){const t=e.LX.makeContainer(["auto","auto"],"text-base"),a=new e.LX.Panel;e.LX.makeContainer(["100%","auto"],"px-3 p-2 pb-0 text-base font-medium",o.name,t),a.refresh=()=>{if(a.clear(),!o.default){const e=new Date,t=`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()}`;o.default=[t,t]}const t=new k(o.value??o.default,{onChange:a=>{o.value=a,n.innerHTML=s.innerHTML+o.name+(i+e.LX.badge(`${t.getFullDate()}`,"xs secondary")),this._resetCustomFiltersBtn?.root.classList.remove("hidden"),this.refresh()}});a.attach(t)},a.refresh(),t.appendChild(a.root),new C(o.component.root,[t],{side:"bottom"})}},{buttonClass:"sm outline dashed"}),t.appendChild(o.component.root);this._resetCustomFiltersBtn=new a(null,"resetButton",()=>{this.activeCustomFilters={},this._resetCustomFiltersBtn?.root.classList.add("hidden");for(let e of this.customFilters??[])e.component.root.querySelector("button").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",buttonClass:"ghost"}),t.appendChild(this._resetCustomFiltersBtn?.root),this._resetCustomFiltersBtn?.root.classList.add("hidden")}if(this._toggleColumns){const i=e.LX.makeIcon("Settings2"),o=new a("toggleColumnsBtn",i.innerHTML+"View",(t,i)=>{const o=s.head.map((e,t)=>{const i={name:e,icon:"Check",callback:()=>{s.colVisibilityMap[t]=!s.colVisibilityMap[t];d.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});e.LX.addDropdownMenu(i.target,o,{side:"bottom",align:"end"})},{hideName:!0,buttonClass:"outline"});t.appendChild(o.root),o.root.style.marginLeft="auto"}o.appendChild(t)}const d=e.LX.makeElement("table",i.tableClass,"",o);this.refresh=()=>{this._currentFilter=this._currentFilter??"",d.innerHTML="",this.rowOffsetCount=0;{const t=document.createElement("thead");t.className="lextablehead",d.appendChild(t);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 t=document.createElement("th");t.style.width="0px";const i=document.createElement("input");i.type="checkbox",i.className="lexcheckbox primary",i.checked=s.checkMap[":root"]??!1,t.appendChild(i),i.addEventListener("change",function(){s.checkMap[":root"]=this.checked;const t=d.querySelector("tbody");for(const e of t.childNodes){const t=e.getAttribute("rowId");t&&(s.checkMap[t]=this.checked,e.querySelector("input[type='checkbox']").checked=this.checked)}const i=c.getSelectedRows();e.LX.emitSignal("@rows_selected_changed",i.length)}),this.rowOffsetCount++,o.appendChild(t)}for(const t of s.head){const n=document.createElement("th");n.innerHTML=`<span>${t}</span>`,n.querySelector("span").appendChild(e.LX.makeIcon("MenuArrows",{svgClass:"sm"}));const a=s.head.indexOf(t);this._centered?.indexOf&&(this._centered.indexOf(a)>-1||this._centered.indexOf(t)>-1)&&n.classList.add("centered");const r=[];if(i.columnActions)for(let e of i.columnActions)e.name?r.push({name:e.name,icon:e.icon,className:e.className,callback:()=>{const t=this.data.body.map(e=>[e[a]]);e.callback(t,d)&&this.refresh()}}):console.warn("Invalid column action (missing name):",e);this._sortColumns&&(r.length>0&&r.push(null),r.push({name:"Asc",icon:"ArrowUpZA",callback:l.bind(this,a,1)},{name:"Desc",icon:"ArrowDownZA",callback:l.bind(this,a,-1)})),this._toggleColumns&&(r.length>0&&r.push(null),r.push({name:"Hide",icon:"EyeOff",callback:()=>{s.colVisibilityMap[a]=!1;d.querySelectorAll(`tr > *:nth-child(${a+this.rowOffsetCount+1})`).forEach(e=>{e.style.display="none"===e.style.display?"":"none"})}})),n.addEventListener("click",t=>{0!==r.length&&e.LX.addDropdownMenu(t.target,r,{side:"bottom",align:"start"})}),o.appendChild(n)}if(i.rowActions){const e=document.createElement("th");e.className="sm",o.appendChild(e)}t.appendChild(o)}{const t=document.createElement("tbody");t.className="lextablebody",d.appendChild(t);let o=null,n=!1,a=null;document.addEventListener("mouseup",t=>{if(null===o)return;document.removeEventListener("mousemove",r);const i=d.rows[o];if(i.dY=0,i.classList.remove("dragging"),Array.from(d.rows).forEach(e=>{e.style.transform="",e.style.transition="none"}),e.LX.flushCss(i),a){const t=this._paginator?(this._paginator.page-1)*this.rowsPerPage:0,i=o-1+t,n=a[1]-1+t;e.LX.emitSignal("@on_table_sort",{instance:this,fromIdx:i,targetIdx:n});const r=s.body[i];let l=0;if(i==n)return;if(i>n)for(let e=i;e>n;--e)s.body[e]=s.body[e-1];else{l=1;for(let e=i;e<n;++e)s.body[e]=s.body[e+1]}s.body[n]=r;const c=a[0].parentNode;e.LX.insertChildAtIndex(c,a[0],n+l-t),a=null}o=null,e.LX.doAsync(()=>{Array.from(d.rows).forEach(e=>{e.style.transition="transform 0.2s ease-in"})})});let r=e=>{if(!o)return;const t=d.rows[o];t.dY=t.dY??0,t.dY+=e.movementY,t.style.transform=`translateY(${t.dY}px)`};const l=[];for(let t=0;t<s.body.length;++t){const i=s.body[t];if(this.filter){const t=s.head.indexOf(this.filter);if(t>-1){if(!e.LX.stripHTML(i[t]).toLowerCase().includes(this._currentFilter.toLowerCase()))continue}}if(Object.keys(this.activeCustomFilters).length){let t={};this._resetCustomFiltersBtn?.root.classList.remove("hidden");for(let o in this.activeCustomFilters){const n=this.activeCustomFilters[o];t[n]=t[n]??!1;const a=s.head.indexOf(n);if(a>-1){const s=i[a],r=e.LX.stripTags(s)??s;t[n]=t[n]||r===o}}if(!Object.values(t).reduce((e,t)=>e&&t,!0))continue}if(this.customFilters){let t={};for(let o of this.customFilters){const n=o.name;if("range"==o.type){t[n]=t[n]??!1;const e=s.head.indexOf(n);if(e>-1){const s=parseFloat(i[e]),a=o.start??o.min,r=o.end??o.max;t[n]=t[n]||s>=a&&s<=r}}else if("date"==o.type){t[n]=t[n]??!1;const a=s.head.indexOf(n);if(a>-1){if(!o.value){t[n]=!0;continue}o.value=o.value??o.default;const s=i[a],r=e.LX.dateFromDateString(s),l=e.LX.dateFromDateString(o.value[0]),c=e.LX.dateFromDateString(o.value[1]);t[n]=t[n]||r>=l&&r<=c}}}if(!Object.values(t).reduce((e,t)=>e&&t,!0))continue}l.push(i)}this._paginator&&this._paginator.setPages(this._getNumPages(l.length));const h=this._paginator?(this._paginator.page-1)*this.rowsPerPage:0,u=this._paginator?Math.min(h+this.rowsPerPage,l.length):l.length;for(let p=h;p<u;++p){const h=l[p],u=this.data.body.indexOf(h),m=document.createElement("tr"),g=this._makeRowId(h);if(m.setAttribute("rowId",g),i.sortable){const t=document.createElement("td");t.style.width="0px";const s=e.LX.makeIcon("GripVertical");t.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",r)},!1),m.addEventListener("mouseenter",function(t){if(t.preventDefault(),null!=o&&this.rowIndex!=o&&n!=this.rowIndex){n=this.rowIndex;const t=d.rows[o],s=""!=this.style.transform;this.rowIndex>o?(a=[t,s?this.rowIndex-1:this.rowIndex],this.style.transform=s?"":`translateY(-${this.offsetHeight}px)`):(a=[t,s?this.rowIndex+1:this.rowIndex],this.style.transform=s?"":`translateY(${this.offsetHeight}px)`),e.LX.doAsync(()=>{n=!1})}}),m.appendChild(t)}if(i.selectable){const t=document.createElement("td"),i=document.createElement("input");i.type="checkbox",i.className="lexcheckbox primary",i.checked=s.checkMap[g],t.appendChild(i),i.addEventListener("change",function(){s.checkMap[g]=this.checked;const t=d.querySelector("thead input[type='checkbox']");if(console.assert(t,"Header checkbox not found!"),this.checked){Array.from(d.querySelectorAll("tbody input[type='checkbox']")).filter(e=>!e.checked).length||(t.checked=s.checkMap[":root"]=!0)}else t.checked=s.checkMap[":root"]=!1;const i=c.getSelectedRows();e.LX.emitSignal("@rows_selected_changed",i.length)}),m.appendChild(t)}for(let e=0;e<h.length;++e){const t=h[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 t=document.createElement("td");t.style.width="0px";const o=document.createElement("div");o.className="lextablebuttons",t.appendChild(o);for(const t of i.rowActions){let n=null;"delete"==t?(n=e.LX.makeIcon("Trash3",{title:"Delete Row"}),n.addEventListener("click",()=>{s.body.splice(u,1),this.refresh()})):"menu"==t?(n=e.LX.makeIcon("EllipsisVertical",{title:"Menu"}),n.addEventListener("click",function(t){if(!i.onMenuAction)return;const o=i.onMenuAction(u,s);console.assert(o.length,"Add items to the Menu Action Dropdown!"),e.LX.addDropdownMenu(t.target,o,{side:"bottom",align:"end"})})):(console.assert(t.constructor==Object),n=e.LX.makeIcon(t.icon,{title:t.title}),t.callback&&n.addEventListener("click",e=>{t.callback(u,h,d,e)&&this.refresh()})),console.assert(n),o.appendChild(n)}m.appendChild(t)}t.appendChild(m)}if(i.selectable){const t=this.getSelectedRows();e.LX.emitSignal("@rows_selected_changed",t.length)}if(0==t.childNodes.length){const e=document.createElement("tr"),i=document.createElement("td");i.setAttribute("colspan",s.head.length+this.rowOffsetCount+1),i.className="empty-row",i.innerHTML="No results.",e.appendChild(i),t.appendChild(e)}}for(const e in s.colVisibilityMap){const t=parseInt(e);if(!s.colVisibilityMap[t]){d.querySelectorAll(`tr > *:nth-child(${t+this.rowOffsetCount+1})`).forEach(e=>{e.style.display="none"===e.style.display?"":"none"})}}};const u=this._showSelectedNumber&&i.selectable;if(u||this._paginator){const t=e.LX.makeContainer(["100%","auto"],"flex flex-row px-3 my-1 align-center","",o);if(u){const s=e.LX.makeContainer(["100%","auto"],"flex justify-start items-center","0 row(s) selected.",t);e.LX.addSignal("@rows_selected_changed",(e,t)=>{this._showSelectedNumber&&(s.innerHTML=0===t?"":`${t??0} row(s) selected.`)})}if(this._paginator){e.LX.makeContainer(["100%","auto"],"flex justify-end","",t).appendChild(this._paginator.root)}}this.refresh(),e.LX.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(t){return e.LX.getSupportedDOMName(t.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()}}e.LX.Table=G;class K extends n{tabs;tabDOMs;constructor(t,s,i={}){if(i.hideName=!0,super(e.ComponentType.TABS,t,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,n=!o&&(i.showNames??!1);this.tabDOMs={};let a=document.createElement("div");a.className="lextabscontainer",o||(a.className+=" horizontal");let r=document.createElement("div");r.className="tabs",a.appendChild(r),this.root.appendChild(a),s.findIndex(e=>!0===e.selected)<0&&(s[0].selected=!0);for(let t of s){console.assert(t.name);let s=document.createElement("div");s.className="lextab "+(t.selected?"selected":""),s.innerHTML=n?t.name:"",s.appendChild(e.LX.makeIcon(t.icon??"Hash",{title:t.name,iconClass:t.iconClass,svgClass:"lg"+(t.svgClass?" "+t.svgClass:"")})),this.tabDOMs[t.name]=s;let i=document.createElement("div");if(i.id=t.name.replace(/\s/g,""),i.className="components",i.toggleAttribute("hidden",!t.selected),a.appendChild(i),s.addEventListener("click",e=>{r.querySelectorAll(".lextab").forEach(e=>{e.classList.remove("selected")}),s.classList.add("selected"),a.querySelectorAll(".components").forEach(e=>{e.toggleAttribute("hidden",!0)});const o=a.querySelector("#"+i.id);o?.toggleAttribute("hidden"),t.onSelect&&t.onSelect(this,i)}),r.appendChild(s),t.onCreate){const s=new e.LX.Panel;s.queue(i),t.onCreate.call(this,s,i),s.clearQueue()}}this.tabs=s}select(e){const t=this.tabDOMs[e];t&&t.click()}}e.LX.TabSections=K;class U extends n{generateTags;constructor(t,s,i,n={}){let a=s.replace(/\s/g,"").split(","),r=e.LX.deepCopy(a);super(e.ComponentType.TAGS,t,r,n),this.options.skipDuplicates=n.skipDuplicates??!0,this.onGetValue=()=>e.LX.deepCopy(s),this.onSetValue=(e,s,n)=>{a=[].concat(e),this.generateTags(a),s||this._trigger(new o(t,a,n),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};const l=document.createElement("div");l.className="inline-flex flex-wrap gap-1 bg-card/50 rounded-lg pad-xs [&_input]:w-2/3",this.root.appendChild(l),this.generateTags=t=>{l.innerHTML="";for(let s=0;s<t.length;++s){const i=t[s],o=e.LX.mergeClass("lextag bg-primary px-2 py-1 rounded-xl min-w-2 justify-center text-primary-foreground gap-1 text-sm select-none",n.tagClass),a=e.LX.makeElement("span",o,i);if(!this.disabled){const s=e.LX.makeIcon("X",{svgClass:"sm"});a.appendChild(s),s.addEventListener("click",e=>{a.remove(),t.splice(t.indexOf(i),1),this.set(t,!1,e)})}l.appendChild(a)}if(this.disabled)return;let s=document.createElement("input");s.value="",s.placeholder="Add tag...",l.appendChild(s),s.onkeydown=e=>{if(" "==e.key||"Enter"==e.key){const i=s.value.replace(/\s/g,"");if(e.preventDefault(),!i.length||n.skipDuplicates&&t.indexOf(i)>-1)return;t.push(i),this.set(t,!1,e),l.querySelector("input")?.focus()}}},this.generateTags(a),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Tags=U;class W extends n{constructor(t,s,i,n={}){super(e.ComponentType.TEXTAREA,t,s,n),this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{r.value=s=e,n||this._trigger(new o(t,e,a),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=n.inputWidth??`calc( 100% - ${t})`};let a=document.createElement("div");a.className="lextextarea",a.style.display="flex",this.root.appendChild(a);let r=e.LX.makeElement("textarea",e.LX.mergeClass("w-full text-sm text-foreground bg-card border-color disabled:pointer-events-none disabled:opacity-50 rounded-lg outline-none pad-md",n.inputClass??""));r.value=s??"",r.style.textAlign=n.float??"",r.disabled=this.disabled,Object.assign(r.style,n.style??{}),n.fitHeight&&r.classList.add("field-sizing-content"),(n.resize??1)||r.classList.add("resize-none"),a.appendChild(r),n.placeholder&&r.setAttribute("placeholder",n.placeholder);const l=n.trigger??"default",c=n.submitOnEnterKey??!0;if("default"==l?(r.addEventListener("keydown",function(e){if(c&&"Enter"==e.key&&!e.shiftKey)return e.preventDefault(),!1}),r.addEventListener("keyup",function(e){(c&&"Enter"==e.key&&!e.shiftKey||"Escape"==e.key)&&(e.preventDefault(),r.blur())}),r.addEventListener("focusout",e=>{this.set(e.target?.value,!1,e)})):"input"==l&&r.addEventListener("input",e=>{this.set(e.target?.value,!1,e)}),n.icon){const t=e.LX.makeIcon(n.icon,{iconClass:"absolute z-1 ml-2",svgClass:"sm"});a.appendChild(t)}e.LX.doAsync(()=>{a.style.height=n.height??"",this.onResize()},10)}}e.LX.TextArea=W;class Y extends n{constructor(t,s={}){console.assert(0!==t.length,"Can't create Title Component without text!"),super(e.ComponentType.TITLE,null,null,s);const i="lextitle !w-fit bg-muted text-foreground text-sm font-semibold leading-normal m-3 flex content-center rounded-xl select-none";if(this.root.className=e.LX.mergeClass(i,s.className),s.icon){let t=e.LX.makeIcon(s.icon,{iconClass:"mr-2"});t.querySelector("svg").style.color=s.iconColor||"",this.root.appendChild(t)}let o=document.createElement("span");if(o.innerText=t,this.root.appendChild(o),null!=s.link){let o=e.LX.makeElement("a",`${i} link`,t);o.href=s.link,o.target=s.target??"",this.root.replaceWith(o),this.root=o}Object.assign(this.root.style,s.style??{})}}e.LX.Title=Y;class j extends n{constructor(t,s,i,n={}){if(!t&&!n.label)throw"Set Component Name or at least a label!";super(e.ComponentType.TOGGLE,t,s,n),this.onGetValue=()=>r.checked,this.onSetValue=(e,n,a)=>{e!=s&&(r.checked=s=e,this.root.querySelector(".lextogglesubmenu")?.toggleAttribute("hidden",!e),n||this._trigger(new o(t,e,a),i))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=n.inputWidth??`calc( 100% - ${t})`};var a=document.createElement("div");a.className="flex flex-row gap-2 items-center",this.root.appendChild(a);let r=e.LX.makeElement("input",e.LX.mergeClass("lextoggle relative inline-grid place-content-center cursor-pointer shrink-0 select-none disabled:pointer-events-none disabled:opacity-50",n.className));r.type="checkbox",r.checked=s,r.iValue=s,r.disabled=this.disabled,a.appendChild(r);let l=document.createElement("span");if(l.className="font-medium w-full overflow-hidden truncate",l.innerHTML=n.label??"On",a.appendChild(l),r.addEventListener("change",e=>{this.set(r.checked,!1,e)}),n.suboptions){let t=e.LX.makeElement("div","lextogglesubmenu w-full p-2");t.toggleAttribute("hidden",!r.checked);const s=new e.LX.Panel;s.queue(t),n.suboptions.call(this,s),s.clearQueue(),this.root.appendChild(t)}e.LX.doAsync(this.onResize.bind(this))}}e.LX.Toggle=j;class Z extends n{locked=!1;setLimits;constructor(t,s,i,r,l={}){t=e.LX.clamp(t,2,4),i=i??new Array(t).fill(0),super(e.ComponentType.VECTOR,s,e.LX.deepCopy(i),l),this.onGetValue=()=>{let e=this.root.querySelectorAll("input[type='number']"),t=[];for(var s of e)t.push(+s.value);return t},this.onSetValue=(t,n,a)=>{if(c.length==t.length){for(let s=0;s<c.length;++s){let o=t[s];o=e.LX.clamp(o,+c[s].min,+c[s].max),o=e.LX.round(o,l.precision)??0,c[s].value=i[s]=o}n||this._trigger(new o(s,i,a),r)}else console.error("Input length does not match vector length.")},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";h.style.width=`calc( 100% - ${t})`},this.setLimits=(e,t,s)=>{};const c=[];var h=document.createElement("div");h.className="lexvector flex",this.root.appendChild(h);const d=this;for(let u=0;u<t;++u){let p=document.createElement("div");p.className="vecbox",p.innerHTML="<span class='"+e.LX.Panel.VECTOR_COMPONENTS[u]+"'></span>";let m=document.createElement("input");m.className="vecinput v"+t,m.min=l.min??-1e24,m.max=l.max??1e24,m.step=l.step??"any",m.type="number",m.id="vec"+t+"_"+e.LX.guidGenerator(),m.idx=u,m.disabled=this.disabled,c[u]=m,p.appendChild(m),i[u].constructor==Number&&(i[u]=e.LX.clamp(i[u],+m.min,+m.max),i[u]=e.LX.round(i[u],l.precision)),m.value=m.iValue=i[u];const g=e.LX.makeIcon("MoveVertical",{iconClass:"drag-icon hidden-opacity",svgClass:"sm"});function f(t){if(document.activeElement!=m&&t.button==e.LX.MOUSE_LEFT_CLICK){var s=d.root.ownerDocument;s.addEventListener("mousemove",C),s.addEventListener("mouseup",y),document.body.classList.add("noevents"),g.classList.remove("hidden-opacity"),t.stopImmediatePropagation(),t.stopPropagation(),document.pointerLockElement||p.requestPointerLock(),l.onPress&&l.onPress.bind(m)(t,m)}}function C(t){let s=-t.movementY;if(0!=s){let i=l.step??1;if(t.shiftKey?i=10:t.altKey&&(i=.1),d.locked)for(let t of c)t.value=e.LX.round(+t.valueAsNumber+i*s,l.precision),n._dispatchEvent(t,"change");else m.value=e.LX.round(+m.valueAsNumber+i*s,l.precision),n._dispatchEvent(m,"change")}t.stopPropagation(),t.preventDefault()}function y(e){var t=d.root.ownerDocument;t.removeEventListener("mousemove",C),t.removeEventListener("mouseup",y),document.body.classList.remove("noevents"),g.classList.add("hidden-opacity"),document.pointerLockElement&&document.exitPointerLock(),l.onRelease&&l.onRelease.bind(m)(e,m)}p.appendChild(g),m.addEventListener("wheel",function(t){if(t.preventDefault(),m!==document.activeElement)return;let s=l.step??1;if(t.shiftKey?s=10:t.altKey&&(s=.1),d.locked)for(let i of c)i.value=e.LX.round(+i.valueAsNumber-s*(t.deltaY>0?1:-1),l.precision),n._dispatchEvent(i,"change");else m.value=e.LX.round(+m.valueAsNumber-s*(t.deltaY>0?1:-1),l.precision),n._dispatchEvent(m,"change")},{passive:!1}),m.addEventListener("change",t=>{if(isNaN(t.target.value))return;let s=e.LX.clamp(t.target.value,+m.min,+m.max);if(s=e.LX.round(s,l.precision),this.locked)for(let e of c)e.value=s,i[e.idx]=s;else m.value=s,i[t.target.idx]=s;this.set(i,!1,t)},!1),p.addEventListener("mousedown",f),h.appendChild(p)}if(void 0===l.min&&void 0===l.max||(this.setLimits=(e,t,s)=>{for(let i of c)i.min=e??i.min,i.max=t??i.max,i.step=s??i.step;this.set(i,!0)}),!l.skipLock){const v=new a(null,"",e=>{this.locked=e},{title:"Lock",icon:"LockOpen",swap:"Lock",buttonClass:"h-auto bg-none p-0"});h.appendChild(v.root)}e.LX.doAsync(this.onResize.bind(this))}}e.LX.Vector=Z;class Q{name;components;closed;root;content;grabber;panel;onclick;oncontextmenu;constructor(t,s={}){this.name=t;var i=document.createElement("div");s.id&&(i.id=s.id),i.className=e.LX.mergeClass("lexbranch bg-secondary/50 dark:bg-card text-secondary-foreground dark:text-card-foreground w-full rounded-lg my-0 mx-auto",s.className);var o=this;this.closed=s.closed??!1,this.root=i,this.components=[],this.panel=null;const n=e.LX.makeElement("div","lexbranchtitle flex cursor-pointer select-none pad-lg text-lg","",i);if(s.icon){const t=e.LX.makeIcon(s.icon,{iconClass:"mr-2"});n.appendChild(t)}n.innerHTML+=t||"Branch";const a=e.LX.makeIcon("Right",{iconClass:"switch-branch-button",svgClass:"sm"});n.appendChild(a);var r=e.LX.makeElement("div","lexbranchcontent pad-xs","",i);r.id=t.replace(/\s/g,""),this.content=r,this._addBranchSeparator(),this.closed&&(n.classList.add("closed"),i.classList.add("closed"),this.grabber.setAttribute("hidden",!0),e.LX.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"),e.LX.emitSignal("@on_branch_closed",n.classList.contains("closed"))},this.oncontextmenu=function(t){t.preventDefault(),t.stopPropagation(),n.parentElement.classList.contains("dialog")||e.LX.addContextMenu("Dock",t,e=>{t.preventDefault(),e.add("Floating",o._onMakeFloating.bind(o))},{icon:"WindowRestore"})},n.addEventListener("click",this.onclick),n.addEventListener("contextmenu",this.oncontextmenu)}_onMakeFloating(){const t=new e.LX.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!"),t.branchData={name:this.name,components:this.components,closed:this.closed,panel:this.panel,childIndex:s},this.root.remove()}_addBranchSeparator(){const t=document.createElement("div");t.className="lexcomponentseparator",t.style.width="100%",t.style.background="none";const s=document.createElement("div");s.innerHTML="▾",t.appendChild(s),e.LX.doAsync(()=>{s.style.marginLeft=parseFloat(e.LX.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(t){let i=t.movementX;if(0!=i){const t=parseFloat(s.style.marginLeft);s.style.marginLeft=e.LX.clamp(t+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(t)}_updateComponents(){var t=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=t,n.style.minWidth=t,i.type){case e.LX.BaseComponent.CUSTOM:case e.LX.BaseComponent.ARRAY:continue}a.style.width="-moz-calc( 100% - "+t+" )",a.style.width="-webkit-calc( 100% - "+t+" )",a.style.width="calc( 100% - "+t+" )"}}}e.LX.Branch=Q;let J=class{root;branches;components;signals;queuedContainer;_branchOpen;_currentBranch;_queue;_inlineComponentsLeft;_inlineQueuedContainer;_inlineExtraClass;_inlineContainer;_inlineComponents;constructor(t={}){const s=e.LX.makeElement("div",e.LX.mergeClass("lexpanel m-0 pad-md overflow-hidden overflow-y-scroll text-foreground scrollbar-hidden",t.className));t.id&&(s.id=t.id),s.style.width=t.width||"100%",s.style.height=t.height||"100%",Object.assign(s.style,t.style??{}),this.root=s,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 t in this.components)if(this.components[t].options&&this.components[t].options.signal){const s=this.components[t].options.signal;for(let i=0;i<e.LX.signals[s].length;i++)e.LX.signals[s][i]==this.components[t]&&(e.LX.signals[s]=[...e.LX.signals[s].slice(0,i),...e.LX.signals[s].slice(i+1)])}if(this.signals)for(let t=0;t<this.signals.length;t++){let s=Object.values(this.signals[t])[0],i=s.options.signal;for(let t=0;t<e.LX.signals[i].length;t++)e.LX.signals[i][t]==s&&(e.LX.signals[i]=[...e.LX.signals[i].slice(0,t),...e.LX.signals[i].slice(t+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(t,s={}){s.placeholder=t.constructor==String?t:"Filter properties..",s.skipComponent=s.skipComponent??!0,s.skipInlineCount=!0;const i=new h(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=e.LX.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 t=document.createElement("div");t.className="lexseparator";let s=new n(e.ComponentType.SEPARATOR);s.root=t,this._currentBranch?(this._currentBranch.content.appendChild(t),this._currentBranch.components.push(s)):this.root.appendChild(t)}addTitle(e,t={}){const s=new Y(e,t);return this._attachComponent(s)}addText(e,t,s,i={}){const o=new h(e,t,s,i);return this._attachComponent(o)}addTextArea(e,t,s,i={}){const o=new W(e,t,s,i);return this._attachComponent(o)}addLabel(t,s={}){s.disabled=!0,s.inputClass=e.LX.mergeClass("bg-none",s.inputClass);const i=this.addText(null,t,null,s);return i.type=e.ComponentType.LABEL,i}addButton(e,t,s,i={}){const o=new a(e,t,s,i);return this._attachComponent(o)}addComboButtons(e,t,s={}){const i=new v(e,t,s);return this._attachComponent(i)}addCard(e,t={}){const s=new p(e,t);return this._attachComponent(s)}addForm(e,t,s,i={}){const o=new M(e,t,s,i);return this._attachComponent(o)}addContent(t,s,i={}){if(console.assert(s,"Empty content!"),s.constructor==String){const e=document.createElement("div");e.innerHTML=s,s=e.childElementCount>1?e:e.firstElementChild}i.hideName=!0;let o=new n(e.ComponentType.CONTENT,t,null,i);return o.root.appendChild(s),this._attachComponent(o)}async addImage(t,s,i={}){console.assert(0!==s.length,"Empty src/url for Image!");let o=document.createElement("div");o.className="leximage",o.style.width="100%";let a=document.createElement("img");a.src=s,Object.assign(a.style,i.style??{}),o.appendChild(a);let r=new n(e.ComponentType.IMAGE,t,null,i);return r.root.appendChild(o),a.decode(),this._attachComponent(r)}addSelect(e,t,s,i,o={}){const n=new d(e,t,s,i,o);return this._attachComponent(n)}addCurve(e,t,s,i={}){const o=new x(e,t,s,i);return this._attachComponent(o)}addDial(e,t,s,i={}){const o=new T(e,t,s,i);return this._attachComponent(o)}addLayers(e,t,s,i={}){const o=new A(e,t,s,i);return this._attachComponent(o)}addArray(e,t=[],s,i={}){const o=new u(e,t,s,i);return this._attachComponent(o)}addList(e,t,s,i,o={}){const n=new X(e,t,s,i,o);return this._attachComponent(n)}addTags(e,t,s,i={}){const o=new U(e,t,s,i);return this._attachComponent(o)}addCheckbox(e,t,s,i={}){const o=new m(e,t,s,i);return this._attachComponent(o)}addToggle(e,t,s,i={}){const o=new j(e,t,s,i);return this._attachComponent(o)}addRadioGroup(e,t,s,i,o={}){const n=new H(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 F(e,t,s,i);return this._attachComponent(o)}addNumber(e,t,s,i={}){const o=new c(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 Z(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 $(e,t,s,i);return this._attachComponent(o)}addOTP(e,t,s,i={}){const o=new z(e,t,s,i);return this._attachComponent(o)}addPad(e,t,s,i={}){const o=new D(e,t,s,i);return this._attachComponent(o)}addProgress(e,t,s={}){const i=new B(e,t,s);return this._attachComponent(i)}addFile(e,t,s={}){const i=new E(e,t,s);return this._attachComponent(i)}addTree(e,t,s={}){const i=new R(e,t,s);return this._attachComponent(i)}addTabSections(e,t,s={}){const i=new K(e,t,s);return this._attachComponent(i)}addCounter(e,t,s,i={}){const o=new L(e,t,s,i);return this._attachComponent(o)}addTable(e,t,s={}){const i=new G(e,t,s);return this._attachComponent(i)}addDate(e,t,s,i={}){const o=new S(e,t,s,i);return this._attachComponent(o)}addMap2D(e,t,s,i={}){const o=new I(e,t,s,i);return this._attachComponent(o)}addRate(e,t,s,i={}){const o=new V(e,t,s,i);return this._attachComponent(o)}};e.LX.Panel=J;class ee{area;options;buttons;constructor(e,t,s={}){this.area=e,this.options=s,this.buttons={},this._buildButtons(t,s)}_buildButtons(t,s={}){s.className="lexoverlaybuttons flex justify-start gap-2 bg-card m-2 p-1 rounded-2xl border-color";let i=this.area.addPanel(s),o=null;const n=e.LX.makeElement("div","lexoverlaybuttonscontainer absolute flex top-0 w-full pointer-events-none");n.appendChild(i.root),this.area.attach(n);const a=s.float;let r="";if(a){for(let e=0;e<a.length;e++){switch(a[e]){case"h":case"t":case"l":break;case"v":r+=" vertical";break;case"m":r+=" middle";break;case"b":r+=" bottom";break;case"c":r+=" center";break;case"r":r+=" right"}}n.className+=` ${r}`}const l=(e,t,s)=>{const n={width:"auto",selectable:e.selectable,selected:e.selected,icon:e.icon,img:e.img,className:e.class??"",buttonClass:e.buttonClass??"x",title:e.name,overflowContainerX:i.root,swap:e.swap};t&&(o||(o=document.createElement("div"),o.className="lexoverlaygroup flex flex-none bg-secondary rounded-xl",i.queuedContainer=o),n.parent=o);let a=e.callback,r=null;r=e.options?i.addSelect(null,e.options,e.value??e.name,a,n):i.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,r.root)},n),this.buttons[e.name]=r,o&&s&&(i.root.appendChild(o),o=null,i.clearQueue())};!function(){i.clear();for(let e of t){if(null===e){const e=document.createElement("div");e.className="lexoverlayseparator"+r,i.root.appendChild(e);continue}if(e.constructor===Array)for(let t=0;t<e.length;++t){let s=e[t];s.group=e,l(s,!0,t==e.length-1)}else l(e)}if(a){var e=0;i.root.childNodes.forEach(t=>{e+=t.offsetHeight}),n.className.includes("middle")&&(n.style.top="-moz-calc( 50% - "+.5*e+"px )",n.style.top="-webkit-calc( 50% - "+.5*e+"px )",n.style.top="calc( 50% - "+.5*e+"px )")}}()}}e.LX.AreaOverlayButtons=ee;let te=class t{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(t={}){var s=document.createElement("div");t.id&&(s.id=t.id),s.className=e.LX.mergeClass("lexarea m-0 bg-background text-foreground",t.className);var i=t.width||"100%",o=t.height||"100%";this.setLimitBox(t.minWidth,t.minHeight,t.maxWidth,t.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&&!t.skipAppend&&n.appendChild(this.root),t.layout&&this.setLayout(t.layout);let a=t.overlay;if(a){this.root.classList.add("overlay-"+a),t.left?this.root.style.left=t.left:t.right?this.root.style.right=t.right:t.top?this.root.style.top=t.top:t.bottom&&(this.root.style.bottom=t.bottom);if((t.draggable??!0)&&e.LX.makeDraggable(s,t),t.resizeable&&s.classList.add("resizeable"),t.resize){this.splitBar=document.createElement("div");let r="left"==a||"right"==a?"horizontal":"vertical";if(this.type=a,this.splitBar.className="lexsplitbar "+r,"right"==a)this.splitBar.style.width=e.LX.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.left=-e.LX.DEFAULT_SPLITBAR_SIZE/2+"px";else if("left"==a){let p=Math.min(document.body.clientWidth-e.LX.DEFAULT_SPLITBAR_SIZE,this.root.clientWidth);this.splitBar.style.width=e.LX.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.left=p+e.LX.DEFAULT_SPLITBAR_SIZE/2+"px"}else if("top"==a){let m=Math.min(document.body.clientHeight-e.LX.DEFAULT_SPLITBAR_SIZE,this.root.clientHeight);this.splitBar.style.height=e.LX.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.top=m+e.LX.DEFAULT_SPLITBAR_SIZE/2+"px"}else"bottom"==a&&(this.splitBar.style.height=e.LX.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.top=-e.LX.DEFAULT_SPLITBAR_SIZE/2+"px");this.splitBar.addEventListener("mousedown",h),this.root.appendChild(this.splitBar);const l=this;let c=[0,0];function h(e){const t=l.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"),l.splitBar.classList.add("nocursor")}function d(t){switch(l.type){case"right":var s=c[0]-t.x,i=l.root.offsetWidth+s;l.root.style.width=i+"px";break;case"left":s=c[0]-t.x,i=Math.min(document.body.clientWidth-e.LX.DEFAULT_SPLITBAR_SIZE,l.root.offsetWidth-s);l.root.style.width=i+"px",l.splitBar.style.left=i+e.LX.DEFAULT_SPLITBAR_SIZE/2+"px";break;case"top":s=c[1]-t.y,i=Math.min(document.body.clientHeight-e.LX.DEFAULT_SPLITBAR_SIZE,l.root.offsetHeight-s);l.root.style.height=i+"px",l.splitBar.style.top=i+e.LX.DEFAULT_SPLITBAR_SIZE/2+"px";break;case"bottom":s=c[1]-t.y,i=l.root.offsetHeight+s;l.root.style.height=i+"px"}c[0]=t.x,c[1]=t.y,t.stopPropagation(),t.preventDefault(),l.onresize&&l.onresize(l.root.getBoundingClientRect())}function u(e){const t=l.root.ownerDocument;t.removeEventListener("mousemove",d),t.removeEventListener("mouseup",u),document.body.classList.remove("nocursor"),l.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(t){if(this.layout=e.LX.deepCopy(t),!t.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,r]=e.split({type:i,resize:o,minimizable:n,sizes:[t.splits[0].size,t.splits[1].size]});s(a,t.splits[0]),s(r,t.splits[1])};s(this,t)}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 r=s.minimizable??!1,l=(s.resize??!0)||r,c=s.fixedSize??!l,h=0,d=[],u=[];if(this.offset=0,l&&(this.resize=l,this.splitBar=document.createElement("div"),this.splitBar.className="lexsplitbar "+i,"horizontal"==i?this.splitBar.style.width=e.LX.DEFAULT_SPLITBAR_SIZE+"px":this.splitBar.style.height=e.LX.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=e.LX.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 t=a.width,s=e.LX.parsePixelSize(o[0],t)/t*100,i=e.LX.parsePixelSize(o[1],t)/t*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 t=a.height,s=e.LX.parsePixelSize(o[0],t)/t*100,i=e.LX.parsePixelSize(o[1],t)/t*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 t({width:d[0],height:d[1],skipAppend:!0,className:"split"+(s.menubar||s.sidebar?"":" origin")}),m=new t({width:u[0],height:u[1],skipAppend:!0,className:"split"});if(!(c||a.width&&a.height)){const t=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 t=a.width,s=e.LX.parsePixelSize(o[0],t)/t*100,i=e.LX.parsePixelSize(o[1],t)/t*100;d[0]=`calc(${s}% - ${h}px)`,u[0]=`calc(${i}% - ${h}px)`}else{const t=a.height,s=e.LX.parsePixelSize(o[0],t)/t*100,i=e.LX.parsePixelSize(o[1],t)/t*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(),t.disconnect()}});e.LX.doAsync(()=>{t.observe(this.root)},100)}if(n&&"vertical"==i&&(this._autoVerticalResizeObserver=new ResizeObserver(t=>{for(const s of t){const t=e.LX.getComputedSize(s.target);m.root.style.height="calc(100% - "+t.height+"px )"}}),this._autoVerticalResizeObserver.observe(p.root)),l&&r&&(this.splitExtended=!1,m.root.addEventListener("animationend",t=>{const s=getComputedStyle(m.root).opacity;m.root.classList.remove(t.animationName+"-"+i),m.root.style.opacity=s,e.LX.flushCss(m.root)}),this.splitBar.addEventListener("contextmenu",t=>{t.preventDefault(),e.LX.addContextMenu(null,t,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),l&&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),!l)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(t){let[s,i]=t;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()),e.LX.doAsync(()=>{this.size=[this.root.clientWidth,this.root.clientHeight],this.propagateEvent("onresize")},150)}extend(){if(this.splitExtended)return;let[t,s]=this.sections;this.splitExtended=!0,t.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)),e.LX.doAsync(()=>{this.propagateEvent("onresize")},100)}reduce(){if(!this.splitExtended)return;this.splitExtended=!1;let[t,s]=this.sections;t.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),e.LX.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 J(e);return this.attach(t),this.panels.push(t),t}addMenubar(t,s={}){let i=new r(t,s);e.LX.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-100"),s.parentClass&&(o.root.className=e.LX.mergeClass(o.root.className,s.parentClass)),i}addSidebar(t,s={}){let i=new e.LX.Sidebar({callback:t,...s});t&&t(i),i.update(),e.LX.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",r=n?[a,null]:[null,a],[l,c]=this.split({type:"horizontal",sizes:r,resize:!1,sidebar:!0});i.siblingArea=n?c:l;let h=n?l:c;return h.attach(i),h.isSidebar=!0,s.parentClass&&(h.root.className=e.LX.mergeClass(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 ee(this,e,t),this.overlayButtons)}addTabs(e={}){const t=new l(this,e);return e.folding&&(this.parentArea?._disableSplitResize(),this.root.style.paddingTop="4px"),t}_moveSplit(t,s=!1,i=0){if(!this.type)throw"No split area";if(void 0===t)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],r=a.root,l="- "+e.LX.DEFAULT_SPLITBAR_SIZE+"px";let c=null;if(s||(c=n.style.transition,n.style.transition=r.style.transition="none"),"horizontal"==this.type){var h=Math.max(r.offsetWidth+t,parseInt(a.minWidth));i&&(h=i);const e=h/this.size[0]*100,s=Math.max(0,100-e);n.style.width=`-moz-calc(${s}% ${l})`,n.style.width=`-webkit-calc( ${s}% ${l})`,n.style.width=`calc( ${s}% ${l})`,r.style.width=`${e}%`,r.style.width=`${e}%`,r.style.width=`${e}%`,o.maxWidth!=1/0&&(r.style.minWidth=`calc( 100% - ${parseInt(o.maxWidth)}px )`)}else{const s=this.size[1];h=Math.max(r.offsetHeight+t+a.offset,parseInt(a.minHeight));h=Math.min(s-e.LX.DEFAULT_SPLITBAR_SIZE,h),i&&(h=i);const c=h/s*100,d=Math.max(0,100-c);n.style.height=`-moz-calc(${d}% ${l})`,n.style.height=`-webkit-calc( ${d}% ${l})`,n.style.height=`calc( ${d}% ${l})`,r.style.height=`${c}%`,r.style.height=`${c}%`,r.style.height=`${c}%`,o.maxHeight!=1/0&&(r.style.minHeight=`calc( 100% - ${parseInt(o.maxHeight)}px )`)}s||(n.style.transition=r.style.transition=c),e.LX.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 se(t,s=!0){t="light"==t?"light":"dark",document.documentElement.setAttribute("data-mode",t),document.documentElement.classList.toggle("dark","dark"==t),s&&localStorage.setItem("lxColorScheme",t),e.LX.emitSignal("@on_new_color_scheme",t)}function ie(){return document.documentElement.getAttribute("data-mode")??"dark"}function oe(e,t){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 s=parseInt(e,16),i=(s>>(8===e.length?24:16)&255)/255,o=(s>>(8===e.length?16:8)&255)/255,n=(s>>(8===e.length?8:0)&255)/255,a=(8===e.length?255&s:4===e.length?parseInt(e.slice(-2),16):255)/255;return{r:i,g:o,b:n,a:t?t/100:a}}function ne(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 r=0;0!==a&&(r=n===t?(s-i)/a%6:n===s?(i-t)/a+2:(t-s)/a+4,r*=60,r<0&&(r+=360));return{h:r,s:0===n?0:a/n,v:n,a:o}}e.LX.Area=te,e.LX.twMerge=t.extendTailwindMerge({extend:{classGroups:{pad:[{pad:["xs","sm","md","lg","xl","2xl"]}]}}}),e.LX.clamp=function(e,t,s){return Math.min(Math.max(e,t),s)},e.LX.round=function(e,t){return 0==t?Math.floor(e):+e.toFixed(t??2).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,"$1")},e.LX.remapRange=function(e,t,s,i,o){return(e-t)*(o-i)/(s-t)+i},"undefined"!=typeof performance?e.LX.getTime=performance.now.bind(performance):"undefined"!=typeof Date&&Date.now?e.LX.getTime=Date.now.bind(Date):e.LX.getTime=function(){return(new Date).getTime()},e.LX.doAsync=function(e,t){setTimeout(e,t??0)},e.LX.flushCss=function(e){e.offsetHeight},e.LX.deleteElement=function(e){e&&e.remove()},e.LX.toCamelCase=function(e){return e.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(e,t)=>t.toUpperCase())},e.LX.toTitleCase=function(e){return e.replace(/-/g," ").toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())},e.LX.toKebabCase=function(e){return e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())},e.LX.getSupportedDOMName=function(e){console.assert("string"==typeof e,"getSupportedDOMName: Text is not a string!");let t=e.trim();return t=t.replace(/\//g,"_slash_").replace(/@/g,"_at_").replace(/\+/g,"_plus_").replace(/\./g,"_dot_"),t=t.replace(/[^a-zA-Z0-9_-]/g,"_"),/^[0-9]/.test(t)&&(t="_"+t),t},e.LX.has=function(t){return e.LX.extensions.indexOf(t)>-1},e.LX.getExtension=function(e){return e.includes(".")?e.split(".").pop():null},e.LX.stripHTML=function(e){const t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||""},e.LX.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}},e.LX.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!"},e.LX.deepCopy=function(e){return JSON.parse(JSON.stringify(e))},e.LX.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},e.LX.setThemeColor=function(t){document.documentElement.className=`theme-${t}`;const s=e.LX.getMode();document.documentElement.classList.toggle("dark","dark"==s)},e.LX.setMode=se,e.LX.getMode=ie,e.LX.switchMode=function(){se("dark"==ie()?"light":"dark")},e.LX.setSystemMode=function(){se(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"),localStorage.removeItem("lxColorScheme"),e.LX._mqlPrefersDarkScheme&&(e.LX._mqlPrefersDarkScheme.removeEventListener("change",e.LX._onChangeSystemTheme),e.LX._mqlPrefersDarkScheme.addEventListener("change",e.LX._onChangeSystemTheme))},e.LX.setCSSVariable=function(e,t){document.querySelector(":root").style.setProperty("--"+e,t)},e.LX.getCSSVariable=function(t){const[s,i]=t.split("/"),o=document.querySelector(":root"),n=getComputedStyle(o);let a=n.getPropertyValue("--"+s);if(!a)return"";if(a.includes("light-dark")){a="light"==n.getPropertyValue("color-scheme")?a.substring(a.indexOf("(")+1,a.indexOf(",")).replace(/\s/g,""):a.substring(a.indexOf(",")+1,a.indexOf(")")).replace(/\s/g,"")}if(i){if(a.includes("/"))return a;if(a.startsWith("rgb(")||a.startsWith("hsl(")||a.startsWith("oklch(")||a.startsWith("lab(")||a.startsWith("lch("))return a.replace(/\)$/,` / ${parseFloat(i)/100})`);if(a.startsWith("#")){const t=e.LX.hexToRgb(a,i);return e.LX.rgbToHex(t)}}return a},e.LX.switchSpacing=function(){const t=document.documentElement.getAttribute("data-spacing")??"default";document.documentElement.setAttribute("data-spacing","default"==t?"compact":"default"),e.LX.emitSignal("@on_new_spacing_layout",t)},e.LX.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")},e.LX.hexToRgb=oe,e.LX.hexToHsv=function(e){return ne(oe(e))},e.LX.rgbToHex=function(t,s=255){const i=[t.r,t.g,t.b];return null!=t.a&&i.push(t.a),"#"+i.map(t=>{const i=(t=Math.floor(e.LX.clamp(t*s,0,s))).toString(16);return 1===i.length?"0"+i:i}).join("")},e.LX.oklchToHex=function(t){const s=t.match(/oklch\(\s*([\d.]+)%\s+([\d.]+)\s+([\d.]+)\s*\)/);if(!s)return console.error("Invalid OKLCH format"),"#000";let[,i,o,n]=s;const a=parseFloat(i)/100,r=parseFloat(n)*Math.PI/180,l=parseFloat(o)*Math.cos(r),c=parseFloat(o)*Math.sin(r),h=(a+.3963377774*l+.2158037573*c)**3,d=(a-.1055613458*l-.0638541728*c)**3,u=(a-.0894841775*l-1.291485548*c)**3;let p=4.0767416621*h-3.3077115913*d+.2309699292*u,m=-1.2684380046*h+2.6097574011*d-.3413193965*u,g=-.0041960863*h-.7034186147*d+1.707614701*u;const f=e=>e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055;return p=f(p),m=f(m),g=f(g),e.LX.rgbToHex({r:p,g:m,b:g})},e.LX.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}},e.LX.rgbToHsv=ne,e.LX.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)),r=i-n;let l=0,c=0,h=0;return t<60?(l=n,c=a,h=0):t<120?(l=a,c=n,h=0):t<180?(l=0,c=n,h=a):t<240?(l=0,c=a,h=n):t<300?(l=a,c=0,h=n):(l=n,c=0,h=a),{r:l+r,g:c+r,b:h+r,a:o}},e.LX.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}`)},e.LX.measureRealWidth=function(t,s=8){var i=document.createElement("span");i.className="lexinputmeasure",i.innerHTML=t,document.body.appendChild(i);var o=i.getBoundingClientRect();return e.LX.deleteElement(i),o.width+s},e.LX.guidGenerator=function(){var e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+"-"+e()+"-"+e()},e.LX.escapeRegExp=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},e.LX.wildcardToRegExp=function(e){const t=e.replace(/([.+^${}()|[\]\\])/g,"\\$1").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp("^"+t+"$","i")},e.LX.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},e.LX.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},e.LX.makeDraggable=function(t,s={}){let i=0,o=0,n=null,a=s.targetClass,r=s.dragMargin??3,l=(s,n,a)=>{const l=t.parentElement?t.parentElement.getBoundingClientRect():{x:0,y:0,width:0,height:0},c="fixed"==t.style.position?new P(l.x,l.y):new P;a=a??s.clientX-i-l.x,n=n??s.clientY-o-l.y,t.style.left=e.LX.clamp(a,r+c.x,c.x+l.width-t.offsetWidth-r)+"px",t.style.top=e.LX.clamp(n,r+c.y,c.y+l.height-t.offsetHeight-r)+"px",t.style.translate="none"};s.autoAdjust&&l(null,parseInt(t.style.left),parseInt(t.style.top));let c=e.LX.guidGenerator();t["draggable-id"]=c;let h=s.onMove?e=>{n&&s.onMove&&s.onMove(n)}:e=>{n&&l(e)},d=s.onDragStart;t.setAttribute("draggable","true"),t.addEventListener("mousedown",function(e){n=e.target.classList.contains(a)||!a?e.target:null}),t.addEventListener("dragstart",function(a){if(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation(),!n)return;var r=new Image;r.src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=",a.dataTransfer&&(a.dataTransfer.setDragImage(r,0,0),a.dataTransfer.effectAllowed="move");const l=a.target.getBoundingClientRect(),c=n.parentElement.getBoundingClientRect(),u="fixed"==n.style.position?new P(c.x,c.y):new P;i=a.clientX-l.x-u.x,o=a.clientY-l.y-u.y,document.addEventListener("mousemove",h),n.eventCatched=!0,(s.updateLayers??1)&&(e.LX.activeDraggable&&(e.LX.activeDraggable.style.zIndex=e.LX.DRAGGABLE_Z_INDEX),e.LX.activeDraggable=t,e.LX.activeDraggable.style.zIndex=e.LX.DRAGGABLE_Z_INDEX+1),d&&d(n,a)},!1),document.addEventListener("mouseup",e=>{n&&(n=null,document.removeEventListener("mousemove",h))})},e.LX.makeCollapsible=function(t,s,i,o={}){t.classList.add("collapsible");const n=o.collapsed??!0,a=e.LX.makeIcon("Right");a.classList.add("collapser"),n&&(a.dataset.collapsed="true",s.style.display="none"),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")}),t.appendChild(a),(i=i??t.parentElement).appendChild(s)},e.LX.makeCodeSnippet=function(t,s,i={}){if(!e.LX.has("CodeEditor"))return void console.error("Import the CodeEditor component to create snippets!");const o=document.createElement("div");o.className=e.LX.mergeClass("lexcodesnippet relative rounded-xl overflow-hidden",i.className),o.style.width=s?s[0]:"auto",o.style.height=s?s[1]:"auto";const n=new te({xskipAppend:!0});return new e.LX.CodeEditor(n,{skipInfo:!0,disableEdition:!0,allowAddScripts:!1,name:i.tabName,onReady:e=>{if(e.setText(t,i.language??"Plain Text"),i.linesAdded){const t=e.root.querySelector(".code");for(let e of i.linesAdded){const s=e;if(s.constructor==Number)t.childNodes[s-1].classList.add("added");else if(s.constructor==Array)for(let e=s[0]-1;e<=s[1]-1;e++)t.childNodes[e].classList.add("added")}}if(i.linesRemoved){const t=e.root.querySelector(".code");for(let e of i.linesRemoved){const s=e;if(s.constructor==Number)t.childNodes[s-1].classList.add("removed");else if(s.constructor==Array)for(let e=s[0]-1;e<=s[1]-1;e++)t.childNodes[e].classList.add("removed")}}if(i.windowMode){const t=document.createElement("div");t.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",t.appendChild(s),t.appendChild(i),t.appendChild(o);e.root.querySelector(".lexareatabs").prepend(t)}(i.lineNumbers??1)||e.root.classList.add("no-gutter")}}),o.appendChild(n.root),o},e.LX.makeKbd=function(t,s=!0,i=""){const o={Ctrl:"⌃",Enter:"↩",Shift:"⇧",CapsLock:"⇪",Meta:"⌘",Option:"⌥",Alt:"⌥",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Space:"␣"},n=e.LX.makeContainer(["auto","auto"],"text-muted-foreground font-sans text-xs inline-flex\n ml-auto pointer-events-none select-none items-center justify-center gap-1");for(const a of t)e.LX.makeContainer(["auto","auto"],"bg-muted px-1 rounded-sm "+i,s?o[a]??a:a,n);return n},e.LX.makeBreadcrumb=function(t,s={}){const i=e.LX.makeContainer(["auto","auto"],"flex flex-row gap-1"),o=s.separatorIcon??"ChevronRight",n=s.maxItems??4,a=t.length-n;if(a>0){const e={name:"...",ellipsis:t.splice(1,a+1).map(e=>e.name).join("/")};t.splice(1,0,e)}for(let s=0;s<t.length;++s){const n=t[s];if(console.assert(n.name,"Breadcrumb item must have a name!"),0!=s){const t=e.LX.makeIcon(o,{svgClass:"sm text-foreground separator"});i.appendChild(t)}const a=s==t.length-1,r=e.LX.makeContainer(["auto","auto"],"p-1 flex flex-row gap-1 items-center "+(a?"text-foreground":"text-muted-foreground"));i.appendChild(r);let l=e.LX.makeElement("p","",n.name);if(n.icon&&r.appendChild(e.LX.makeIcon(n.icon,{svgClass:"sm"})),void 0!==n.items){const t=e.LX.makeContainer(["auto","auto"],""+(a?"text-foreground":"text-muted-foreground"));e.LX.listen(t,"click",t=>{e.LX.addDropdownMenu(t.target,n.items,{side:"bottom",align:"start"})}),t.append(l),r.appendChild(t)}else if(void 0!==n.url){let t=e.LX.makeElement("a","decoration-none hover:underline underline-offset-4 "+(a?"text-foreground":"text-muted-foreground"),"",r);t.href=n.url,t.appendChild(l)}else r.appendChild(l);n.ellipsis&&e.LX.asTooltip(r,n.ellipsis,{side:"bottom",offset:4})}return i},e.LX.makeIcon=function(t,s={}){let i=null;const o=function(i){const o=s.svgClass;if(o&&o.length){const t=e.LX.twMerge(...i.classList,...o.split(" "));i.classList.remove(...i.classList),t.split(" ").forEach(e=>i.classList.add(e))}const n=e.LX.makeElement("a",e.LX.mergeClass("lexicon",s.iconClass));return n.title=s.title??"",n.appendChild(i),i.dataset.name=t,n};if(t.includes("@")){const e=t.split("@");t=e[0],s.variant=e[1]}let n=e.LX.ICONS[t];const a=window.lucide,r=a[t]??a[e.LX.LucideIconAlias[t]];if(n){n.constructor!=Array&&(n=e.LX.ICONS[n]);const a=s.variant??"regular";n=("solid"==a?e.LX.ICONS[`${t}@solid`]:n)??n;const l=n[3];if(a==l||!r||"regular"==l){if(i=document.createElementNS("http://www.w3.org/2000/svg","svg"),i.classList.add("text-inherit"),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.classList.add("text-inherit"),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(r,`No existing icon named _${t}_`),i=a.createElement(r,s),o(i)},e.LX.registerIcon=function(t,s,i="none",o=[]){const n=(new DOMParser).parseFromString(s,"image/svg+xml").documentElement,a=n.querySelector("path"),r=n.getAttribute("viewBox").split(" "),l=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(r[2]),parseInt(r[3]),o,i,l,{svgAttributes:c.length?c.join(" "):null,pathAttributes:h.length?h.join(" "):null}];e.LX.ICONS[t]&&console.warn(`${t} will be added/replaced in LX.ICONS`),e.LX.ICONS[t]=d},e.LX.registerCommandbarEntry=function(t,s){e.LX.extraCommandbarEntries.push({name:t,callback:s})},e.LX.message=function(t,s,i={}){if(!t)throw"No message to show";return i.modal=!0,new e.LX.Dialog(s,e=>{e.addTextArea(null,t,null,{disabled:!0,fitHeight:!0})},i)},e.LX.popup=function(t,s,i={}){if(!t)throw"No message to show";i.size=i.size??["max-content","auto"];const o=i.timeout||3e3,n=new e.LX.Dialog(s,e=>{e.addTextArea(null,t,null,{disabled:!0,fitHeight:!0})},i);return setTimeout(()=>{n.close()},Math.max(o,150)),n},e.LX.prompt=function t(s,i,o,n={}){n.modal=!0,n.className="prompt";let a="";const r=()=>{n.required&&""===a?(s+=s.includes("You must fill the input text.")?"":"\nYou must fill the input text.",l.close(),t(s,i,o,n)):(o&&o.call(e.LX,a),l.close())},l=new e.LX.Dialog(i,t=>{e.LX.makeElement("p","max-h-64 p-2 break-word overflow-scroll",s,t),(n.input??1)&&t.addText(null,n.input||a,(e,t)=>{a=e,t?.constructor===KeyboardEvent&&r()},{placeholder:"..."}),t.sameLine(2),t.addButton(null,"Cancel",()=>{n.on_cancel&&n.on_cancel(),l.close()},{width:"50%",buttonClass:"destructive"}),t.addButton(null,n.accept||"Continue",()=>{r()},{width:"50%",buttonClass:"primary"})},n);return(n.input??1)&&l.root.querySelector("input").focus(),l},e.LX.toast=function(t,s,i={}){if(!t)throw"The toast needs at least a title!";const o=e.LX.notifications;console.assert(o);const n=e.LX.makeElement("li","lextoast flex flex-row relative w-full border-color overflow-hidden select-none pointer-events-auto touch-none rounded-lg p-3","",o),[a,r]=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(r){case"left":o.style.left="1rem";break;case"center":o.style.placeSelf="center",o.style.justifySelf="anchor-center";break;case"right":o.style.right="1rem"}n.classList.add(a),n.classList.add(r),e.LX.doAsync(()=>{o.offsetWidth>o.iWidth&&(o.iWidth=Math.min(o.offsetWidth,480),o.style.width=o.iWidth+"px"),n.dataset.open=!0},10);const l=e.LX.makeElement("div","grid h-fit max-w-lg gap-1 items-center mr-6 [&_div]:truncate [&_svg]:shrink-0","",n);if(e.LX.makeElement("div","flex flex-row gap-2 text-sm text-foreground items-center min-w-0",t,l),s&&e.LX.makeElement("div","text-secondary-foreground text-xs",s,l),i.action){const t=new J;t.addButton(null,i.action.name??"Accept",i.action.callback.bind(e.LX,n),{width:"auto",maxWidth:"150px",className:"right",buttonClass:"outline sm"}),n.appendChild(t.root.childNodes[0])}if(n.close=function(){this.dataset.open="false",e.LX.doAsync(()=>{this.remove(),e.LX.notifications.childElementCount||(e.LX.notifications.style.width="unset",e.LX.notifications.iWidth=0)},500)},i.closable??1){const t=e.LX.makeIcon("X",{iconClass:"absolute top-2 right-2 text-sm"});t.addEventListener("click",()=>{n.close()}),n.appendChild(t)}const c=i.timeout??3e3;-1!=c&&e.LX.doAsync(()=>{n.close()},c)},e.LX.badge=function(t,s,i={}){const o=document.createElement("div");o.innerHTML=t;const n=["lexbadge","inline-flex","items-center","justify-center","rounded-full","border","px-2","py-0.5","text-xs","font-medium","w-fit","whitespace-nowrap","shrink-0","overflow-hidden","border-transparent","gap-1","min-w-5","bg-card text-foreground"];if(o.className=s?e.LX.twMerge(...n,...s.split(" ")):n.join(" "),Object.assign(o.style,i.style??{}),i.callback){const t=e.LX.makeIcon("ArrowUpRight",{svgClass:"xs"});t.querySelector("svg").style.marginLeft="-0.25rem",o.innerHTML+=t.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},e.LX.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},e.LX.makeContainer=function(t,s,i,o,n={}){const a=e.LX.makeElement("div","lexcontainer "+(s??""),i,o,n);return a.style.width=t&&t[0]?t[0]:"100%",a.style.height=t&&t[1]?t[1]:"100%",a},e.LX.asTooltip=function(t,s,i={}){console.assert(t,"You need a trigger to generate a tooltip!"),t.dataset.disableTooltip=!(i.active??1);let o=null;const n=i.offset,a=i.offsetX??n??0,r=i.offsetY??n??6;t.addEventListener("mouseenter",function(n){if("true"==t.dataset.disableTooltip)return;o=e.LX.makeElement("div","lextooltip fixed bg-secondary-foreground text-secondary text-xs px-2 py-1 rounded-lg pointer-events-none data-closed:opacity-0",t.dataset.tooltipContent??s);const l=t.closest("dialog"),c=l??e.LX.root;e.LX.root.querySelectorAll(".lextooltip").forEach(e=>e.remove()),c.appendChild(o),e.LX.doAsync(()=>{const s=[0,0],n=parseFloat(t.dataset.tooltipOffsetX??a),h=parseFloat(t.dataset.tooltipOffsetY??r),d=t.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]=e.LX.clamp(s[0],0,window.innerWidth-o.offsetWidth-4),s[1]=e.LX.clamp(s[1],0,window.innerHeight-o.offsetHeight-4),l){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,t)})}),t.addEventListener("mouseleave",function(e){o&&o.remove()})},e.LX.insertChildAtIndex=function(e,t,s=1/0){s>=e.children.length?e.appendChild(t):e.insertBefore(t,e.children[s])},e.LX.getComputedSize=function(e){return{width:e.offsetWidth,height:e.offsetHeight}},e.LX.listen=function(e,t,s,i){e[i=i??"_on"+t]=s,e.addEventListener(t,s)},e.LX.ignore=function(e,t,s){const i=e[s=s??"_on"+t];e.removeEventListener(t,i)},e.LX.getParentArea=function(e){let t=e.parentElement;for(;t;){if(t.classList.contains("lexarea"))return t;t=t.parentElement}},e.LX.hasClass=function(e,t){return!!(t=[].concat(t)).filter(t=>e.classList.contains(t)).length},e.LX.addClass=function(e,t){if(!t)return;const s=t.split(" ");e.classList.add(...s)},e.LX.removeClass=function(e,t){if(!t)return;const s=t.split(" ");e.classList.remove(...s)},e.LX.toggleClass=function(e,t,s){t&&e.classList.toggle(t,s)},e.LX.mergeClass=function(t,s){return s&&(t=[t,s].join(" ")),e.LX.twMerge(...t.split(" "))},e.LX.lastChar=function(e){return e[e.length-1]},Object.assign(e.LX,{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},requestFileAsync:async(e,t,s=!1)=>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}),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 r in e){var l=document.createElement("script");l.num=r,l.type="text/javascript",l.src=e[r]+(o?"?version="+o:""),l.original_src=e[r],l.async=!1,l.onload=function(e){n--,a.push(this),n?i&&i(this.original_src,this.num):t&&t(a)},s&&(l.onerror=function(e){s(e,this.original_src,this.num)}),document.getElementsByTagName("head")[0].appendChild(l)}},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(t,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)};t.includes("http")?e.LX.request({url:t,dataType:"blob",success:e=>{i.readAsDataURL(e),i.onload=e=>{o(e.currentTarget.result)}}}):o(t)},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")}}),e.LX.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]},e.LX.compareThreshold=function(e,t,s,i){return Math.abs(e-t)>=i||Math.abs(e-s)>=i},e.LX.compareThresholdRange=function(e,t,s,i){return e>=s&&e<=i||t>=s&&t<=i||e<=s&&t>=i},e.LX.getControlPoints=function(e,t,s,i,o,n,a){var r=Math.sqrt(Math.pow(s-e,2)+Math.pow(i-t,2)),l=a*r/(r+Math.sqrt(Math.pow(o-s,2)+Math.pow(n-i,2))),c=a-l;return[s+l*(e-o),i+l*(t-n),s-c*(e-o),i-c*(t-n)]},e.LX.drawSpline=function(t,s,i){t.save();for(var o=[],n=s.length,a=0;a<n-4;a+=2)o=o.concat(e.LX.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)t.beginPath(),t.moveTo(s[a],s[a+1]),t.bezierCurveTo(o[2*a-2],o[2*a-1],o[2*a],o[2*a+1],s[a+2],s[a+3]),t.stroke(),t.closePath();t.beginPath(),t.moveTo(s[0],s[1]),t.quadraticCurveTo(o[0],o[1],s[2],s[3]),t.stroke(),t.closePath(),t.beginPath(),t.moveTo(s[n-2],s[n-1]),t.quadraticCurveTo(o[2*n-10],o[2*n-9],s[n-4],s[n-3]),t.stroke(),t.closePath(),t.restore()};class ae{root;imageElement=void 0;fallbackElement=void 0;constructor(t){let s="lexavatar bg-card items-center flex flex-row relative size-8 shrink-0 overflow-hidden rounded-full";if(this.root=e.LX.makeElement("div"),t.imgSource){const s="aspect-square size-full object-cover",i=e.LX.makeElement("img",t.imgClass?e.LX.twMerge(...s.split(" "),...t.imgClass.split(" ")):s,"",this.root);i.src=t.imgSource,i.alt=t.imgAlt,this.imageElement=i}else if(t.fallback){const i="size-full text-sm font-semibold place-self-center text-center content-center",o=e.LX.makeElement("span",t.fallbackClass?e.LX.twMerge(...i.split(" "),...t.fallbackClass.split(" ")):i,t.fallback,this.root);this.fallbackElement=o,s+=" border-color"}this.root.className=t.className?e.LX.twMerge(...s.split(" "),...t.className.split(" ")):s}}e.LX.Avatar=ae;class re{root;constructor(t={}){const s=t.icon??"LoaderCircle",i=t.size??"md",o=e.LX.mergeClass("flex",t.iconClass),n=e.LX.mergeClass(`animate-spin ${i}`,t.svgClass);this.root=e.LX.makeIcon(s,{iconClass:o,svgClass:n})}html(){return this.root.innerHTML}destroy(){this.root.remove()}}e.LX.Spinner=re;let le=class t{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=e.LX.guidGenerator();const n=o.size??[],a=o.position??[],r=o.draggable??!0,l=o.dockable??!1,c=o.modal??!1;let h=document.createElement("dialog");h.className=e.LX.mergeClass("lexdialog absolute outline-none border-color m-0 p-0 min-w-3xs min-h-max overflow-hidden rounded-xl bg-background",o.className),h.id=o.id??"dialog"+t._last_id++,h.dataset.modal=c,e.LX.root.appendChild(h),e.LX.doAsync(()=>{c?h.showModal():h.show()},10);let d=this;const u=document.createElement("div");if(s&&(u.className="lexdialogtitle flex w-full outline-none items-center justify-between font-semibold text-xl text-secondary-foreground pad-xl select-none",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(),e.LX.doAsync(()=>{d.panel.clear(),h.remove()},150))};const t=e.LX.makeIcon("X",{title:"Close",iconClass:"lexdialogcloser text-lg text-secondary-foreground cursor-pointer z-1 select-none"});t.addEventListener("click",this.close);const i=e.LX.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?(l&&u.appendChild(i),u.appendChild(t)):(t.classList.add("notitle"),h.appendChild(t))}const p=new e.LX.Panel({className:"lexdialogcontent w-full p-1 text-secondary-foreground text-sm ml-0 break-all"});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,r&&e.LX.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)}};e.LX.Dialog=le;class ce extends le{constructor(t,s,i,o={}){o.closable=!1,o.draggable=!1,o.modal=!0,super(void 0,n=>{n.root.className=e.LX.mergeClass(n.root.className,"pad-2xl flex flex-col gap-2"),e.LX.makeContainer(["100%","100%"],"text-lg font-medium text-foreground px-2",t,n),n.addTextArea(null,s,null,{disabled:!0,fitHeight:!0,inputClass:"bg-none text-sm text-muted-foreground"}),n.sameLine(2,"justify-end"),n.addButton(null,o.cancelText??"Cancel",()=>{o.cancelCallback&&o.cancelCallback(),this.destroy()},{buttonClass:"outline"}),n.addButton(null,o.continueText??"Continue",()=>{this.destroy(),i&&i()},{buttonClass:"primary"})},o)}}e.LX.AlertDialog=ce;class he{root;items;colors;_parent;constructor(t,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=t.target.closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=e.LX.root,this._parent.appendChild(this.root);const n=[t.x-48,t.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(t,s,i,o){const n=t[s].length;let a=document.createElement("div");a.className="lexmenuboxentry"+(t.className?" "+t.className:""),a.id=t.id??"eId"+e.LX.getSupportedDOMName(s),a.innerHTML="";const r=t.icon;r&&a.appendChild(e.LX.makeIcon(r,{svgClass:"sm"}));const l=t.disabled;if(a.innerHTML+="<div class='lexentryname"+(l?" 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(),l)return;const r=t.callback;r&&(r.call(this,s,a),this.root.remove()),n&&"click"==e.LX.OPEN_CONTEXTMENU_ENTRY&&this._createSubmenu(t,s,a,++o)}),!n)return;const c=e.LX.makeIcon("Menu",{svgClass:"sm"});a.appendChild(c),"mouseover"==e.LX.OPEN_CONTEXTMENU_ENTRY&&a.addEventListener("mouseover",e=>{"true"!=a.dataset.built&&(a.dataset.built="true",this._createSubmenu(t,s,a,++o),e.stopPropagation())}),a.addEventListener("mouseleave",()=>{o=-1,i.querySelectorAll(".lexcontextmenu").forEach(e=>e.remove())})}onCreate(){e.LX.doAsync(()=>this._adjustPosition(this.root,6))}add(t,s={}){s.constructor==Function&&(s={callback:s});const i=(t+="").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 r=i[n++];r||(o.id=s.id,o.icon=s.icon,o.callback=s.callback,o.disabled=s.disabled??!1),t.push(o),a(r,o[e])}};a(i[n++],this.items);const r=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)r(s)}}};for(let e of this.items)r(e);for(let t of this.items){let s=Object.keys(t)[0],i="eId"+e.LX.getSupportedDOMName(s);const o="#"+(t.id??i);this.root.querySelector(o)||this._createEntry(t,s,this.root,-1)}}setColor(t,s){"#"!==s[0]&&(s=e.LX.rgbToHex(s)),this.colors[t]=s}}e.LX.ContextMenu=he,e.LX.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(t,s,i={}){if(console.assert(t,"DropdownMenu needs a DOM element as trigger!"),de.currentMenu||!s?.length)return de.currentMenu?.destroy(),void(this.invalid=!0);this._trigger=t,t.classList.add("triggered"),t.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=t.closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=e.LX.root,this._parent.appendChild(this.root),this._create(this._items),de.currentMenu=this,e.LX.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(t,s){if(s){const t=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,e.LX.doAsync(()=>{const s=[t.x+t.width,t.y];if(this._parent instanceof HTMLDialogElement){let e=this._parent.getBoundingClientRect();s[0]-=e.x,s[1]-=e.y}this.avoidCollisions&&(s[0]=e.LX.clamp(s[0],0,window.innerWidth-i.offsetWidth-this._windowPadding),s[1]=e.LX.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=t.filter(e=>null!=e?.icon||null!=e?.checked).length>0;for(let e of t)this._createItem(e,s,i)}_createItem(t,s,i){if(!t)return void this._addSeparator(s);const o=t.name??t,n=e.LX.getSupportedDOMName(o);if(s.querySelector("#"+n))return;const a=document.createElement("div");if(a.className=e.LX.mergeClass("lexdropdownmenuitem flex flex-row pad-md rounded-lg gap-2 truncate cursor-pointer select-none"+(t.name||t.options?"":" label")+(t.disabled?" disabled":""),t.className),a.dataset.id=n,a.innerHTML=`<span class="ellipsis-overflow">${o}</span>`,a.tabIndex="1",s.appendChild(a),t.constructor===String)return;if(t.submenu){const t=e.LX.makeIcon("Right",{svgClass:"sm"});a.appendChild(t)}else if(t.kbd){t.kbd=[].concat(t.kbd);const s=e.LX.makeKbd(t.kbd,t.useKbdSpecialKeys??!0);a.appendChild(s),document.addEventListener("keydown",e=>{if(!this._trigger.ddm)return;e.preventDefault();let s=t.kbd.join("");s=1==s.length?s.toLowerCase():s,s==e.key&&a.click()})}const r=t.disabled??!1;if(void 0!==this._radioGroup){if(t.name===this._radioGroup.selected){const t=e.LX.makeIcon("Circle",{svgClass:"2xs fill-current"});a.prepend(t)}a.setAttribute("data-radioname",this._radioGroup.name)}else if(t.icon){const s=t.icon.constructor===String?e.LX.makeIcon(t.icon,{svgClass:r?"text-muted-foreground":t.svgClass??t.className}):t.icon;a.prepend(s)}else null==t.checked&&i&&a.classList.add("pl-8");if(!r){if(null!=t.checked){const e=new m(n+"_entryChecked",t.checked,e=>{const s=t.callback;t.checked=e,s&&s.call(this,o,e,a)},{className:"primary"}),s=e.root.querySelector("input");s.classList.add("ml-auto"),a.appendChild(s),a.addEventListener("click",t=>{"checkbox"!=t.target.type&&(s.checked=!s.checked,e.set(s.checked))})}else a.addEventListener("click",e=>{const s=a.getAttribute("data-radioname");s&&(this._trigger[s]=o);const i=t.callback;i&&i.call(this,o,a,s),!t.options&&(t.closeOnClick??1)&&this.destroy(!0)});if(a.addEventListener("mouseover",e=>{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())}),t.submenu&&this.inPlace){if(a.built)return;a.built=!0,this._create(t.submenu,a)}e.stopPropagation()}),t.options){console.assert(this._trigger[t.name]&&"An item of the radio group must be selected!"),this._radioGroup={name:t.name,selected:this._trigger[t.name]};for(let e of t.options)this._createItem(e,s,i);delete this._radioGroup,this._addSeparator()}}}_adjustPosition(){const t=[0,0],s=this._trigger.getBoundingClientRect();if(this.event)t[0]=this.event.x,t[1]=this.event.y;else{let e=!0;switch(this.side){case"left":t[0]+=s.x-this.root.offsetWidth-this.sideOffset,e=!1;break;case"right":t[0]+=s.x+s.width+this.sideOffset,e=!1;break;case"top":t[1]+=s.y-this.root.offsetHeight-this.sideOffset,e=!0;break;case"bottom":t[1]+=s.y+s.height+this.sideOffset,e=!0}switch(this.align){case"start":e?t[0]+=s.x:t[1]+=s.y;break;case"center":e?t[0]+=s.x+.5*s.width-.5*this.root.offsetWidth:t[1]+=s.y+.5*s.height-.5*this.root.offsetHeight;break;case"end":e?t[0]+=s.x-this.root.offsetWidth+s.width:t[1]+=s.y-this.root.offsetHeight+s.height}e?t[0]+=this.alignOffset:t[1]+=this.alignOffset}if(this._parent instanceof HTMLDialogElement){let e=this._parent.getBoundingClientRect();t[0]-=e.x,t[1]-=e.y}this.avoidCollisions&&(t[0]=e.LX.clamp(t[0],0,window.innerWidth-this.root.offsetWidth-this._windowPadding),t[1]=e.LX.clamp(t[1],0,window.innerHeight-this.root.offsetHeight-this._windowPadding)),this.root.style.left=`${t[0]}px`,this.root.style.top=`${t[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}e.LX.DropdownMenu=de,e.LX.addDropdownMenu=ue;class pe{root;constructor(t={}){const s=document.createElement("footer");s.className=e.LX.mergeClass("lexfooter bg-background p-2 w-full leading-6 [&_p]:text-xs",t.className);const i=document.createElement("div");if(i.style.minHeight="48px",i.className="w-full",s.appendChild(i),t.columns&&t.columns.constructor==Array){const e=document.createElement("div");e.className="grid text-center",e.style.gridTemplateColumns="1fr ".repeat(t.columns.length),i.appendChild(e);for(let s of t.columns){const t=document.createElement("div");t.className="col",e.appendChild(t);const i=document.createElement("h2");if(i.innerHTML=s.title,t.appendChild(i),!s.items||!s.items.length)continue;const o=document.createElement("ul");t.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(t.credits||t.socials){const s=document.createElement("div");if(s.className="credits-and-socials",i.appendChild(s),t.credits){const e=document.createElement("p");e.innerHTML=t.credits,s.appendChild(e)}if(t.socials){const i=document.createElement("div");i.className="socials flex flex-row gap-1 my-2 justify-end";for(let s of t.socials){const t=e.LX.makeIcon(s.icon,{title:s.title,svgClass:"xl"});t.href=s.link,t.target="_blank",i.appendChild(t)}s.appendChild(i)}}(t.parent??document.body).appendChild(s),s.previousElementSibling&&(s.previousElementSibling.style.flexGrow="1"),this.root=s}}e.LX.Footer=pe;let me=class t extends le{static TOP=0;static BOTTOM=1;dockPosition=t.TOP;minimized=!1;constructor(s,i,o={}){o.draggable=o.draggable??!1,o.closable=o.closable??!1;super(s,i,o);let n=this;e.LX.addSignal("@on_branch_closed",this.panel,e=>{this.dockPosition==t.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",e=>{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==t.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 e=o.float;if(e)for(let t=0;t<e.length;t++){switch(e[t]){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(e){e.ctrlKey&&(n.root.style.right="unset","ArrowLeft"==e.key?n.root.style.left="0px":"ArrowRight"==e.key?n.root.style.left=`calc(100% - ${n.root.offsetWidth+3}px)`:"ArrowUp"==e.key?(n.root.style.top="0px",n.dockPosition=t.TOP):"ArrowDown"==e.key&&(n.root.style.top=`calc(100% - ${n.root.offsetHeight+3}px)`,n.dockPosition=t.BOTTOM))})}}};e.LX.PocketDialog=me;class ge{side="left";root;_onClick;constructor(t,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 overflow-hidden",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()}),e.LX.doAsync(()=>{switch(e.LX.modal.toggle(!1),this.side){case"left":this.root.style.left="0",this.root.style.width=t,this.root.style.height="100%";break;case"right":this.root.style.right="0",this.root.style.width=t,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=t;break;case"bottom":this.root.style.left="0",this.root.style.bottom="0",this.root.style.width="100%",this.root.style.height=t}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(),e.LX.modal.toggle(!0)}}e.LX.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(t={}){const s=navigator&&/Android|iPhone/i.test(navigator.userAgent);if(this.root=document.createElement("div"),this.root.className=e.LX.mergeClass("lexsidebar flex flex-col pad-xl size-full scrollbar-hidden",t.className),this.callback=t.callback??null,this.side=t.side??"left",this.collapsable=t.collapsable??!0,this.collapsed=t.collapsed??s,this._displaySelected=t.displaySelected??!1,this._collapseWidth=t.collapseToIcons??1?"58px":"0px",this.filterString="",e.LX.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),e.LX.doAsync(()=>{this.resizeObserver?.unobserve(this.root.parentElement),this.root.querySelectorAll(".lexsidebarentrycontent").forEach(e=>e.dataset.disableTooltip=`${!this.collapsed}`)},10)}},10),!t.skipHeader&&(this.header=t.header??this._generateDefaultHeader(t),console.assert(this.header.constructor===HTMLDivElement,"Use an HTMLDivElement to build your custom header"),this.header.className="lexsidebarheader w-full h-[48px] flex rounded-lg p-2 mb-2 text-sm cursor-pointer items-center select-none",this.root.appendChild(this.header),this.collapsable)){const i=e.LX.makeIcon("left"==this.side?"PanelLeft":"PanelRight",{title:"Toggle Sidebar",iconClass:"toggler"});if(this.header.appendChild(i),s){const s=new te({skipAppend:!0}),o=e.LX.deepCopy(t);o.collapsed=!1,o.collapsable=!1,s.addSidebar(this.callback,o),i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),new e.LX.Sheet("256px",[s],{side:this.side})})}else i.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.toggleCollapsed()})}if(t.filter){const e=new h(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 overflow-mask flex flex-col overflow-x-hidden overflow-y-scroll flex-auto-fill w-full",this.root.appendChild(this.content),t.skipFooter||(this.footer=t.footer??this._generateDefaultFooter(t),console.assert(this.footer.constructor===HTMLDivElement,"Use an HTMLDivElement to build your custom footer"),this.footer.className="lexsidebarfooter w-full h-[48px] flex rounded-lg p-2 mt-2 text-sm cursor-pointer items-center select-none",this.root.appendChild(this.footer))}_generateDefaultHeader(t={}){const s=document.createElement("div");s.addEventListener("click",e=>{this.collapsed?(e.preventDefault(),e.stopPropagation(),this.toggleCollapsed()):t.onHeaderPressed&&t.onHeaderPressed(e)});const i=new e.LX.Avatar({imgSource:t.headerImage,fallback:t.headerIcon?e.LX.makeIcon(t.headerIcon,{svgClass:"xl"}).innerHTML:void 0,className:"rounded-lg"});s.appendChild(i.root);{const i=document.createElement("div");i.className="infodefault",s.appendChild(i);const o=e.LX.makeElement("span","truncate text-sm font-semibold");o.innerHTML=t.headerTitle??"",i.appendChild(o);const n=e.LX.makeElement("span","truncate text-xs");n.innerHTML=t.headerSubtitle??"",i.appendChild(n)}if(t.onHeaderPressed&&!this.collapsable){const t=e.LX.makeIcon("MenuArrows");s.appendChild(t)}return s}_generateDefaultFooter(t={}){const s=document.createElement("div");s.addEventListener("click",e=>{t.onFooterPressed&&t.onFooterPressed(e,s)});const i=new e.LX.Avatar({imgSource:t.footerImage,fallback:t.footerIcon?e.LX.makeIcon(t.footerIcon,{svgClass:"xl"}).innerHTML:void 0,className:"rounded-lg"});s.appendChild(i.root);{const i=document.createElement("div");i.className="infodefault",s.appendChild(i);const o=e.LX.makeElement("span","truncate text-sm font-semibold");o.innerHTML=t.footerTitle??"",i.appendChild(o);const n=e.LX.makeElement("span","truncate text-xs");n.innerHTML=t.footerSubtitle??"",i.appendChild(n)}if(t.onFooterPressed){const t=e.LX.makeIcon("MenuArrows");s.appendChild(t)}return s}toggleCollapsed(t){if(this.collapsable){if(this.collapsed=t??!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),e.LX.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 r=s[o++];r||(a.callback=t.callback,a.group=this.currentGroup,a.options=t),i.push(a),n(r,a[e])}};n(s[o++],this.items)}select(t){let s=e.LX.getSupportedDOMName(t);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 t of this.items){const s=t.options??{};if(t.dom)continue;let i=t.name=Object.keys(t)[0];if(this.filterString.length&&!i.toLowerCase().includes(this.filterString.toLowerCase()))continue;let o=e.LX.getSupportedDOMName(i),n=null,a=e.LX.makeElement("div",e.LX.mergeClass("lexsidebarentry w-full rounded-lg cursor-pointer select-none",s.className));if(a.id=o,this.displaySelected&&s.selected&&a.classList.add("selected"),t.group){const s=t.group.replace(/\s/g,"").replaceAll(".","");if(n=this.content.querySelector("#"+s),n){if(!n.classList.contains("lexsidebargroup"))throw"Bad id: "+t.group}else{n=e.LX.makeElement("div","lexsidebargroup flex flex-col gap-0.5"),n.id=s,this.content.appendChild(n);let i=e.LX.makeElement("div","lexsidebargrouptitle");if(n.appendChild(i),e.LX.makeElement("div","",t.group,i),null!=this.groups[t.group]){const s=e.LX.makeIcon(this.groups[t.group].icon,{svgClass:"sm"});i.appendChild(s),s.addEventListener("click",e=>{this.groups[t.group].callback&&this.groups[t.group].callback(t.group,e)})}}}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 r=document.createElement("div");if(r.className="lexsidebarentrycontent",a.appendChild(r),t.dom=a,"checkbox"==s.type){t.value=s.value??!1;const e=new J;t.checkbox=e.addCheckbox(null,t.value,(e,o)=>{o.preventDefault(),o.stopPropagation();const n=s.callback;t.value=e,n&&n.call(this,i,e,o)},{className:"primary",label:i,signal:"@checkbox_"+i}),r.appendChild(e.root.childNodes[0])}else{if(s.icon){const t=e.LX.makeIcon(s.icon,{iconClass:"lexsidebarentryicon"});r.appendChild(t),e.LX.asTooltip(r,i,{side:"right",offset:16,active:!1})}if(e.LX.makeElement("a","grid-column-start-2",i,r),s.swap){r.classList.add("swap","inline-grid"),r.querySelector("a")?.classList.add("swap-off");const t=document.createElement("input");t.className="p-0 border-0",t.type="checkbox",r.prepend(t);const i=e.LX.makeIcon(s.swap,{iconClass:"lexsidebarentryicon swap-on"});r.appendChild(i)}s.content&&r.appendChild(s.content)}const l=null!=s.collapsable?s.collapsable:s.collapsable||t[i].length;if(a.addEventListener("click",e=>{if(e.target&&e.target.classList.contains("lexcheckbox"))return;let o;if(l)r.querySelector(".collapser")?.click();else if(t.checkbox)t.value=!t.value,t.checkbox.set(t.value,!0),o=t.value;else if(s.swap&&!(e.target instanceof HTMLInputElement)){const e=r.querySelector("input");e.checked=!e.checked,o=e.checked}const n=s.callback;n&&n.call(this,i,o??a,e),this.displaySelected&&!s.skipSelection&&(this.root.querySelectorAll(".lexsidebarentry").forEach(e=>e.classList.remove("selected")),a.classList.add("selected"))}),s.action){const t=e.LX.makeIcon(s.action.icon??"Ellipsis",{title:s.action.name});r.appendChild(t),t.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation();const t=s.action.callback;t&&t.call(this,i,e)})}else if(l){const t=document.createElement("div");t.className="collapsablecontainer",Object.assign(t.style,{width:"100%",display:"none"}),e.LX.makeCollapsible(r,t,n??this.content),this.collapseQueue=s.collapsable,this.collapseContainer=t}if(!t[i].length)continue;let c=e.LX.makeElement("div","lexsidebarsubentrycontainer flex flex-col self-center w-full ml-4 px-4 select-none");l?(this.collapseContainer.appendChild(c),delete this.collapseContainer):n?(c.classList.add("collapsablecontainer"),n.appendChild(c)):this.content.appendChild(c);for(let s=0;s<t[i].length;++s){const o=t[i][s],n=o.options??{},a=o.name=Object.keys(o)[0];if(this.filterString.length&&!a.toLowerCase().includes(this.filterString.toLowerCase()))continue;let r=document.createElement("div");if(r.innerHTML=`<span>${a}</span>`,n.action){const t=e.LX.makeIcon(n.action.icon??"Ellipsis",{title:n.action.name});r.appendChild(t),t.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation();const t=n.action.callback;t&&t.call(this,a,e)})}if(r.className="lexsidebarentry w-full rounded-lg cursor-pointer select-none",r.id=a,n.content){const t=e.LX.makeElement("div");t.appendChild(n.content),r.appendChild(t)}c.appendChild(r),r.addEventListener("click",e=>{const t=n.callback;t&&t.call(this,a,r,e),this.displaySelected&&!n.skipSelection&&(this.root.querySelectorAll(".lexsidebarentry").forEach(e=>e.classList.remove("selected")),r.classList.add("selected"))})}}}}e.LX.Sidebar=fe;class Ce{root;constructor(t){if(this.root=e.LX.makeContainer(["auto","auto"],"flex flex-row lexskeleton"),t.constructor===String)this.root.innerHTML=t;else{t=[].concat(t);for(let e of t)this.root.appendChild(e)}}destroy(){this.root.dataset.closed=!0,e.LX.doAsync(()=>{this.root.remove(),this.root=null},200)}}e.LX.Skeleton=Ce;class ye{static ACTIVE_TOURS=[];steps;currentStep=0;useModal;offset;horizontalOffset;verticalOffset;radius;tourContainer;tourMask=void 0;_popover=null;constructor(t,s={}){this.steps=t||[],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=e.LX.makeContainer(["100%","100%"],"tour-container"),this.tourContainer.style.display="none",document.body.appendChild(this.tourContainer),window.addEventListener("resize",()=>{for(const e of ye.ACTIVE_TOURS)e._showStep(0)}))}begin(){this.currentStep=0,this.tourContainer.style.display="block",ye.ACTIVE_TOURS.push(this),this._showStep(0)}stop(){this.useModal&&(this.tourMask?.remove(),this.tourMask=void 0),this._popover?.destroy();const e=ye.ACTIVE_TOURS.indexOf(this);-1!==e&&ye.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(t){this.tourContainer.innerHTML="",this.tourMask=e.LX.makeContainer(["100%","100%"],"tour-mask absolute inset-0"),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=t.getBoundingClientRect(),[a,r]=o(n.x,n.width),[l,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,r+2*d)}`),e.setAttribute("height",`${Math.max(0,l-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",`${l+c+h}`),e.setAttribute("width",`${Math.max(0,r+2*d)}`),e.setAttribute("height",`${Math.max(0,window.innerHeight-l-c-h)}`),e.setAttribute("stroke","none"),i.appendChild(e)}{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x",`${a+r+d}`),e.setAttribute("y","0"),e.setAttribute("width",`${Math.max(0,window.innerWidth-a-r)}`),e.setAttribute("height",`${Math.max(0,window.innerHeight)}`),e.setAttribute("stroke","none"),i.appendChild(e)}const u=e.LX.makeContainer(["0","0"],"tour-ref-mask absolute");u.style.left=a-d-1+"px",u.style.top=l-h-1+"px",u.style.width=`${r+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",`${r+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",`${r+2*d+2}`),t.setAttribute("height",`${c+2*h+2}`),t.setAttribute("stroke","none"),t.setAttribute("fill","black"),p.appendChild(t)}}_createHighlight(t,s,i){const o=e.LX.makeContainer(["auto","auto"],"tour-step-container");{const s=e.LX.makeContainer(["100%","auto"],"flex flex-row","",o);e.LX.makeContainer(["70%","auto"],"p-2 font-medium text-base",t.title,s);const i=e.LX.makeContainer(["30%","auto"],"flex flex-row p-2 justify-end","",s),n=e.LX.makeIcon("X");i.appendChild(n),e.LX.listen(n,"click",()=>{this.stop()})}e.LX.makeContainer(["100%","auto"],"p-2 text-sm",t.content,o,{maxWidth:"400px"});const n=e.LX.makeContainer(["100%","auto"],"flex flex-row","",o);{const t=e.LX.makeContainer(["50%","auto"],"p-2 gap-1 place-self-center flex flex-row","",n);for(let s=0;s<this.steps.length;s++){const i=e.LX.makeElement("span");i.className="size-3 rounded-full bg-accent inline-flex data-active:bg-primary",s===this.currentStep&&(i.dataset.active="true"),t.appendChild(i)}}const a=e.LX.makeContainer(["50%","auto"],"text-base","",n),r=new J;let l=1;s&&l++,l>1&&r.sameLine(2,"justify-end"),s&&r.addButton(null,"Previous",()=>{this._showStep(-1)},{buttonClass:"ghost"}),i?r.addButton(null,"Next",()=>{this._showStep(1)},{buttonClass:"accent"}):r.addButton(null,"Finish",()=>{this.stop()},{buttonClass:"primary"}),a.appendChild(r.root);const c=("left"===t.side||"right"===t.side?this.horizontalOffset:this.verticalOffset)??this.offset,h="start"===t.align||"end"===t.align?c:0;this._popover?.destroy(),this._popover=new C(null,[o],{reference:t.reference,side:t.side,align:t.align,sideOffset:c,alignOffset:"start"===t.align?-h:h})}}if(e.LX.Tour=ye,!e.LX)throw"Missing LX namespace!";function ve(e){return/[^\w\s]/.test(e)}function Le(e){return/\w/.test(e)}function be(e,t){if(!e?.icon)return"FileCode text-neutral-500";if("string"==typeof e.icon)return e.icon;if(t&&e.icon[t])return e.icon[t];return Object.values(e.icon)[0]||"FileCode text-neutral-500"}e.LX.extensions.push("CodeEditor");class xe{static languages=new Map;static extensionMap=new Map;static registerLanguage(e){xe.languages.set(e.name,e);for(const t of e.extensions)xe.extensionMap.set(t,e.name)}static getLanguage(e){return xe.languages.get(e)}static getLanguageByExtension(e){const t=xe.extensionMap.get(e);return t?xe.languages.get(t):void 0}static getRegisteredLanguages(){return Array.from(xe.languages.keys())}static initialState(){return{stack:["root"]}}static tokenizeLine(e,t,s){const i=[],o=[...s.stack];let n=0;for(;n<e.length;){const s=o[o.length-1],a=t.states[s];if(!a){i.push({type:"text",value:e.slice(n)}),n=e.length;break}let r=!1;for(const t of a){const s=new RegExp(t.match.source,"y"+t.match.flags.replace(/[gy]/g,""));s.lastIndex=n;const a=s.exec(e);if(a){if(0===a[0].length)continue;if(i.push({type:t.type,value:a[0]}),n+=a[0].length,t.next)o.push(t.next);else if(t.pop){const e="number"==typeof t.pop?t.pop:1;for(let t=0;t<e&&o.length>1;t++)o.pop()}r=!0;break}}if(!r){const t=i[i.length-1];t&&"text"===t.type?t.value+=e[n]:i.push({type:"text",value:e[n]}),n++}}return{tokens:xe._mergeTokens(i),state:{stack:o}}}static _mergeTokens(e){if(0===e.length)return e;const t=[e[0]];for(let s=1;s<e.length;s++){const i=t[t.length-1];e[s].type===i.type?i.value+=e[s].value:t.push(e[s])}return t}}function _e(e){return new RegExp("\\b(?:"+e.join("|")+")\\b")}e.LX.Tokenizer=xe;const ke={blockComment:[{match:/\*\//,type:"comment",pop:!0},{match:/[^*]+/,type:"comment"},{match:/\*/,type:"comment"}],doubleString:[{match:/\\./,type:"string"},{match:/"/,type:"string",pop:!0},{match:/[^"\\]+/,type:"string"}],singleString:[{match:/\\./,type:"string"},{match:/'/,type:"string",pop:!0},{match:/[^'\\]+/,type:"string"}]},Se=[{match:/0[bB][01]+(?:[uU][lL]{0,2}|[lL]{1,2}[uU]?)?\b/,type:"number"},{match:/0[xX][0-9a-fA-F]+(?:[uU][lL]{0,2}|[lL]{1,2}[uU]?)?\b/,type:"number"},{match:/0[oO][0-7]+(?:[uU][lL]{0,2}|[lL]{1,2}[uU]?)?\b/,type:"number"},{match:/\d+\.?\d*(?:[eE][+-]?\d+)?(?:[fFdDmMlLuUiI]|[uU][lL]{0,2}|[lL]{1,2}[uU]?)?\b/,type:"number"},{match:/\.\d+(?:[eE][+-]?\d+)?(?:[fFdDmM])?\b/,type:"number"}],we=[{match:/[a-zA-Z_$]\w*(?=\s*[<(])/,type:"method"},{match:/[a-zA-Z_$]\w*/,type:"text"},{match:/[{}()\[\];,.:?!&|<>=+\-*/%^~@#]/,type:"symbol"},{match:/\s+/,type:"text"}];function Te(e){return{templateString:[{match:/\\./,type:"string"},{match:/`/,type:"string",pop:!0},{match:/\$\{/,type:"symbol",next:"templateExpr"},{match:/[^`\\$]+/,type:"string"},{match:/\$/,type:"string"}],templateExpr:[{match:/\}/,type:"symbol",pop:!0},{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/`/,type:"string",next:"templateString"},...Se,{match:_e(e),type:"keyword"},...we]}}xe.registerLanguage({name:"Plain Text",extensions:["txt"],states:{root:[{match:/.+/,type:"text"}]},reservedWords:[],icon:"FileText text-neutral-500"});const Ee=["var","let","const","this","in","of","true","false","null","undefined","new","function","class","extends","super","import","export","from","default","async","typeof","instanceof","void","delete","debugger","NaN","static","constructor","Infinity","abstract"],Me=["for","if","else","switch","case","return","while","do","continue","break","await","yield","throw","try","catch","finally","with"],Ae=["document","console","window","navigator","performance","Math","JSON","Promise","Array","Object","String","Number","Boolean","RegExp","Error","Map","Set","WeakMap","WeakSet","Symbol","Proxy","Reflect"];xe.registerLanguage({name:"JavaScript",extensions:["js","mjs","cjs"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/`/,type:"string",next:"templateString"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(Ee),type:"keyword"},{match:_e(Ae),type:"builtin"},{match:_e(Me),type:"statement"},{match:/(?<=\b(?:class|enum)\s+)[A-Z][a-zA-Z0-9_]*/,type:"type"},...we],...ke,...Te(["var","let","const","this","true","false","null","undefined","new","typeof","instanceof","void"])},reservedWords:[...Ee,...Me,...Ae],icon:"Js text-yellow-500"});const Xe=[...Ee,"as","interface","type","enum","namespace","declare","private","protected","implements","readonly","keyof","infer","is","asserts","override","satisfies"],Pe=["string","number","boolean","any","unknown","never","void","null","undefined","object","symbol","bigint","Promise","Record","Partial","Required","Readonly","Pick","Omit","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","Awaited"];xe.registerLanguage({name:"TypeScript",extensions:["ts","tsx"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/`/,type:"string",next:"templateString"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(Xe),type:"keyword"},{match:_e(Pe),type:"type"},{match:_e(Ae),type:"builtin"},{match:_e(Me),type:"statement"},{match:/(?<=\b(?:class|enum|interface|type|extends|implements)\s+)[A-Z][a-zA-Z0-9_]*/,type:"type"},{match:/(?<=<\s*)[A-Z][a-zA-Z0-9_]*(?=\s*(?:[,>]|extends|=))/,type:"type"},{match:/(?<=,\s*)[A-Z][a-zA-Z0-9_]*(?=\s*(?:[,>]|extends|=))/,type:"type"},{match:/(?<=:\s*)[A-Z][a-zA-Z0-9_]*/,type:"type"},...we],...ke,...Te(["var","let","const","this","true","false","null","undefined","new","typeof","instanceof","void"])},reservedWords:[...Xe,...Pe,...Ae,...Me],icon:"Ts text-blue-600"});const Ne=["bool","i32","u32","f16","f32","vec2","vec3","vec4","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","vec2f","vec3f","vec4f","mat2x2f","mat2x3f","mat2x4f","mat3x2f","mat3x3f","mat3x4f","mat4x2f","mat4x3f","mat4x4f","array","struct","ptr","atomic","sampler","sampler_comparison","texture_1d","texture_2d","texture_2d_array","texture_3d","texture_cube","texture_cube_array","texture_multisampled_2d","texture_depth_2d","texture_depth_2d_array","texture_depth_cube","texture_depth_cube_array","texture_depth_multisampled_2d","texture_storage_1d","texture_storage_2d","texture_storage_2d_array","texture_storage_3d","texture_external","var","let","const","override","fn","type","alias","true","false"],Ie=["if","else","switch","case","default","for","loop","while","break","continue","discard","return","function","private","workgroup","uniform","storage","read","write","read_write","bitcast"],Oe=["position","vertex_index","instance_index","front_facing","frag_depth","local_invocation_id","local_invocation_index","global_invocation_id","workgroup_id","num_workgroups","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","cross","degrees","determinant","distance","dot","exp","exp2","floor","fma","fract","inverseSqrt","length","log","log2","max","min","mix","normalize","pow","radians","reflect","refract","round","saturate","sign","sin","sinh","smoothstep","sqrt","step","tan","tanh","transpose","trunc","textureSample","textureSampleBias","textureSampleLevel","textureSampleGrad","textureSampleCompare","textureSampleCompareLevel","textureSampleBaseClampToEdge","textureLoad","textureStore","textureGather","textureGatherCompare","textureDimensions","textureNumLayers","textureNumLevels","textureNumSamples","pack4x8snorm","pack4x8unorm","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack2x16snorm","unpack2x16unorm","unpack2x16float","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","select","arrayLength","countLeadingZeros","countOneBits","countTrailingZeros","extractBits","firstLeadingBit","firstTrailingBit","insertBits","reverseBits","storageBarrier","workgroupBarrier","workgroupUniformLoad"];xe.registerLanguage({name:"WGSL",extensions:["wgsl"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/#\w+/,type:"preprocessor"},...Se,{match:_e(Ne),type:"keyword"},{match:_e(Oe),type:"builtin"},{match:_e(Ie),type:"statement"},{match:/@\w+/,type:"text"},...we],...ke},reservedWords:[...Ne,...Oe,...Ie],icon:"AlignLeft text-orange-500"});const Re=["true","false","int","float","double","bool","void","uint","struct","mat2","mat3","mat4","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","vec2","vec3","vec4","ivec2","ivec3","ivec4","uvec2","uvec3","uvec4","dvec2","dvec3","dvec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler2DShadow","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","samplerCubeArray","samplerCubeArrayShadow","isampler2D","usampler2D","isampler3D","usampler3D","lowp","mediump","highp","precision","in","out","inout","uniform","varying","attribute","const","layout","centroid","flat","smooth","noperspective","patch","sample","buffer","shared","coherent","volatile","restrict","readonly","writeonly"],ze=["if","else","switch","case","default","for","while","do","break","continue","return","discard"],De=["radians","degrees","sin","cos","tan","asin","acos","atan","pow","exp","log","exp2","log2","sqrt","inversesqrt","abs","sign","floor","ceil","fract","mod","min","max","clamp","mix","step","smoothstep","length","distance","dot","cross","normalize","reflect","refract","matrixCompMult","lessThan","lessThanEqual","greaterThan","greaterThanEqual","equal","notEqual","any","all","not","texture","textureProj","textureLod","textureGrad","texelFetch"];xe.registerLanguage({name:"GLSL",extensions:["glsl"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/#\w+/,type:"preprocessor"},...Se,{match:_e(Re),type:"keyword"},{match:_e(De),type:"builtin"},{match:_e(ze),type:"statement"},...we],...ke},reservedWords:[...Re,...De,...ze],icon:"AlignLeft text-neutral-500"});const Be=["bool","int","uint","dword","half","float","double","min16float","min10float","min16int","min12int","min16uint","float1","float2","float3","float4","int1","int2","int3","int4","uint1","uint2","uint3","uint4","bool1","bool2","bool3","bool4","half1","half2","half3","half4","float1x1","float1x2","float1x3","float1x4","float2x1","float2x2","float2x3","float2x4","float3x1","float3x2","float3x3","float3x4","float4x1","float4x2","float4x3","float4x4","vector","matrix","string","void","struct","class","interface","true","false","sampler","sampler1D","sampler2D","sampler3D","samplerCUBE","sampler_state","Texture1D","Texture2D","Texture3D","TextureCube","Texture1DArray","Texture2DArray","TextureCubeArray","Buffer","AppendStructuredBuffer","ConsumeStructuredBuffer","StructuredBuffer","RWStructuredBuffer","ByteAddressBuffer","RWByteAddressBuffer","RWTexture1D","RWTexture2D","RWTexture3D","RWTexture1DArray","RWTexture2DArray","cbuffer","tbuffer","in","out","inout","uniform","extern","static","volatile","precise","shared","groupshared","linear","centroid","nointerpolation","noperspective","sample","const","row_major","column_major"],He=["if","else","for","while","do","switch","case","default","break","continue","discard","return","typedef","register","packoffset"],Fe=["SV_Position","SV_Target","SV_Depth","SV_VertexID","SV_InstanceID","SV_PrimitiveID","SV_DispatchThreadID","SV_GroupID","SV_GroupThreadID","SV_GroupIndex","SV_Coverage","SV_IsFrontFace","SV_RenderTargetArrayIndex","POSITION","NORMAL","TEXCOORD","COLOR","TANGENT","BINORMAL"];xe.registerLanguage({name:"HLSL",extensions:["hlsl","fx","fxh","vsh","psh"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/#\w+/,type:"preprocessor"},...Se,{match:_e(Be),type:"keyword"},{match:_e(Fe),type:"builtin"},{match:_e(He),type:"statement"},...we],...ke},reservedWords:[...Be,...Fe,...He],icon:"AlignLeft text-purple-500"});const Ve=["False","def","None","True","in","is","and","lambda","nonlocal","not","or"],$e=["if","elif","else","for","while","try","except","finally","with","match","case","break","continue","return","raise","pass","import","from","as","global","nonlocal","assert","del","yield"],qe=["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"],Ge=["int","float","complex","bool","str","bytes","bytearray","list","tuple","set","frozenset","dict","object","type","ArithmeticError","AssertionError","AttributeError","BaseException","BufferError","EOFError","Exception","FloatingPointError","GeneratorExit","ImportError","ModuleNotFoundError","IndentationError","IndexError","KeyError","KeyboardInterrupt","LookupError","MemoryError","NameError","NotImplementedError","OSError","OverflowError","RecursionError","ReferenceError","RuntimeError","StopAsyncIteration","StopIteration","SyntaxError","TabError","SystemError","SystemExit","TypeError","UnboundLocalError","UnicodeError","UnicodeEncodeError","UnicodeDecodeError","UnicodeTranslateError","ValueError","ZeroDivisionError"];xe.registerLanguage({name:"Python",extensions:["py"],lineComment:"#",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/#.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(Ve),type:"keyword"},{match:_e(Ge),type:"type"},{match:_e(qe),type:"builtin"},{match:_e($e),type:"statement"},...we],...ke},reservedWords:[...Ve,...Ge,...qe,...$e],icon:"Python text-cyan-600"});const Ke=["abstract","and","array","as","callable","class","clone","const","enum","extends","final","fn","function","global","implements","include","include_once","instanceof","insteadof","interface","namespace","new","null","or","private","protected","public","readonly","require","require_once","static","trait","use","var","xor","from","$this"],Ue=["if","else","elseif","endif","switch","case","default","endswitch","for","endfor","foreach","endforeach","while","endwhile","do","break","continue","return","try","catch","finally","throw","declare","enddeclare","goto","yield","match"],We=["int","float","string","bool","array","object","callable","iterable","void","never","mixed","static","self","parent","Exception","Error","Throwable","DateTime","DateTimeImmutable","Closure","Generator","JsonSerializable"],Ye=["echo","print","isset","empty","unset","eval","die","exit","count","sizeof","in_array","array_merge","array_push","array_pop","strlen","strpos","substr","str_replace","explode","implode","json_encode","json_decode","var_dump","print_r"];xe.registerLanguage({name:"PHP",extensions:["php"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(Ke),type:"keyword"},{match:_e(We),type:"type"},{match:_e(Ye),type:"builtin"},{match:_e(Ue),type:"statement"},...we],...ke},reservedWords:[...Ke,...We,...Ye,...Ue],icon:"Php text-purple-700"});const je=["int","float","double","bool","long","short","char","void","const","enum","extern","register","sizeof","static","struct","typedef","union","volatile","true","false"],Ze=["break","continue","do","else","for","goto","if","return","switch","while"];xe.registerLanguage({name:"C",extensions:["c","h"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/#\w+/,type:"preprocessor"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(je),type:"keyword"},{match:_e(Ze),type:"statement"},...we],...ke},reservedWords:[...je,...Ze],icon:{c:"C text-sky-400",h:"C text-fuchsia-500"}});const Qe=[...je,"wchar_t","static_cast","dynamic_cast","new","delete","auto","class","nullptr","NULL","signed","unsigned","namespace","static","private","public"],Je=[...Ze,"case","using","glm","spdlog","default"],et=["uint8_t","uint16_t","uint32_t","uint64_t","int8_t","int16_t","int32_t","int64_t","size_t","ptrdiff_t"],tt=["std","string","vector","map","set","unordered_map","unordered_set","array","tuple","optional","variant","cout","cin","cerr","clog"];xe.registerLanguage({name:"C++",extensions:["cpp","hpp"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/#\w+/,type:"preprocessor"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(Qe),type:"keyword"},{match:_e(et),type:"type"},{match:_e(tt),type:"builtin"},{match:_e(Je),type:"statement"},...we],...ke},reservedWords:[...Qe,...et,...tt,...Je],icon:{cpp:"CPlusPlus text-sky-400",hpp:"CPlusPlus text-fuchsia-500"}}),xe.registerLanguage({name:"JSON",extensions:["json","jsonc","bml"],states:{root:[{match:/"/,type:"string",next:"doubleString"},{match:/\btrue\b|\bfalse\b|\bnull\b/,type:"keyword"},{match:/-?\d+\.?\d*(?:[eE][+-]?\d+)?/,type:"number"},{match:/[{}[\]:,]/,type:"symbol"},{match:/\s+/,type:"text"}],...ke},reservedWords:[],icon:"Json text-yellow-600"}),xe.registerLanguage({name:"XML",extensions:["xml","xaml","xsd","xsl"],lineComment:"\x3c!--",states:{root:[{match:/<!--/,type:"comment",next:"xmlComment"},{match:/<\?/,type:"preprocessor",next:"processingInstruction"},{match:/<\/[a-zA-Z][\w:-]*>/,type:"keyword"},{match:/<[a-zA-Z][\w:-]*/,type:"keyword",next:"tag"},{match:/[^<]+/,type:"text"}],tag:[{match:/\/?>/,type:"keyword",pop:!0},{match:/[a-zA-Z][\w:-]*(?==)/,type:"type"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/[^"'>/]+/,type:"text"}],xmlComment:[{match:/-->/,type:"comment",pop:!0},{match:/[^-]+/,type:"comment"},{match:/-/,type:"comment"}],processingInstruction:[{match:/\?>/,type:"preprocessor",pop:!0},{match:/[^?]+/,type:"preprocessor"},{match:/\?/,type:"preprocessor"}],...ke},reservedWords:[],icon:"Rss text-orange-600"});xe.registerLanguage({name:"HTML",extensions:["html"],lineComment:"\x3c!--",states:{root:[{match:/<!--/,type:"comment",next:"xmlComment"},{match:/<!DOCTYPE/i,type:"preprocessor"},{match:/<\/[a-zA-Z][\w-]*>/,type:"keyword"},{match:/<script\b/i,type:"keyword",next:"scriptTag"},{match:/<style\b/i,type:"keyword",next:"styleTag"},{match:/<[a-zA-Z][\w-]*/,type:"keyword",next:"tag"},{match:/[^<]+/,type:"text"}],tag:[{match:/\/?>/,type:"keyword",pop:!0},{match:/[a-zA-Z][\w-]*(?==)/,type:"type"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/[^"'>/]+/,type:"text"}],scriptTag:[{match:/\/>/,type:"keyword",pop:!0},{match:/>/,type:"keyword",next:"scriptContent"},{match:/[a-zA-Z][\w-]*(?==)/,type:"type"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/[^"'>/]+/,type:"text"}],scriptContent:[{match:/<\/script>/i,type:"keyword",pop:2},{match:/[^<]+/,type:"text"},{match:/</,type:"text"}],styleTag:[{match:/\/>/,type:"keyword",pop:!0},{match:/>/,type:"keyword",next:"styleContent"},{match:/[a-zA-Z][\w-]*(?==)/,type:"type"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/[^"'>/]+/,type:"text"}],styleContent:[{match:/<\/style>/i,type:"keyword",pop:2},{match:/[^<]+/,type:"text"},{match:/</,type:"text"}],xmlComment:[{match:/-->/,type:"comment",pop:!0},{match:/[^-]+/,type:"comment"},{match:/-/,type:"comment"}],...ke},reservedWords:["html","head","body","title","meta","link","script","style","div","span","p","a","img","ul","ol","li","table","tr","td","th","form","input","button","select","option","textarea","label","h1","h2","h3","h4","h5","h6","header","footer","nav","section","article","aside","main","figure","figcaption","video","audio","source","canvas","svg"],icon:"Code text-orange-500"});const st=["inherit","initial","unset","revert","revert-layer","auto","none","hidden","visible","collapse","block","inline","inline-block","flex","inline-flex","grid","inline-grid","contents","list-item","static","relative","absolute","fixed","sticky","solid","dashed","dotted","double","groove","ridge","inset","outset","bold","bolder","lighter","normal","italic","oblique","uppercase","lowercase","capitalize","left","right","center","top","bottom","start","end","stretch","space-between","space-around","space-evenly","repeat","no-repeat","repeat-x","repeat-y","cover","contain","pointer","default","move","text","not-allowed","transparent","currentColor"];xe.registerLanguage({name:"CSS",extensions:["css","scss","sass","less"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/@[\w-]+/,type:"statement"},{match:/#[\w-]+/,type:"keyword"},{match:/\.[\w-]+/,type:"keyword"},{match:/::?[\w-]+(?:\([^)]*\))?/,type:"keyword"},{match:/\[[\w-]+(?:[~|^$*]?=(?:"[^"]*"|'[^']*'|[\w-]+))?\]/,type:"type"},{match:/{/,type:"symbol",next:"properties"},{match:/}/,type:"symbol"},{match:/[,>+~*]/,type:"symbol"},{match:/[\w-]+/,type:"keyword"},{match:/\s+/,type:"text"}],properties:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/}/,type:"symbol",pop:!0},{match:/[\w-]+(?=\s*:)/,type:"type"},{match:/:/,type:"symbol"},{match:_e(st),type:"string"},{match:/;/,type:"symbol"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/#[a-fA-F0-9]{3,8}\b/,type:"string"},{match:/-?\d+\.?\d*(?:px|em|rem|%|vh|vw|vmin|vmax|pt|cm|mm|in|pc|ex|ch|fr|deg|rad|grad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?/,type:"number"},{match:/!important\b/,type:"builtin"},{match:/[\w-]+\(/,type:"method"},{match:/--[\w-]+/,type:"type"},{match:/[(),]/,type:"symbol"},{match:/{/,type:"symbol",next:"properties"},{match:/[\w-]+/,type:"text"},{match:/\s+/,type:"text"}],...ke},reservedWords:["color","background","border","margin","padding","font","display","position","width","height","top","left","right","bottom","flex","grid","z-index","opacity","transform","transition","animation","content","visibility",...st,"hover","active","focus","visited","link","before","after","first-child","last-child","nth-child","not","root","disabled","checked"],icon:"Hash text-blue-500"}),xe.registerLanguage({name:"Markdown",extensions:["md","markdown"],states:{root:[{match:/^#{1,6}\s+.+/,type:"keyword"},{match:/^\*\*\*.+$/,type:"symbol"},{match:/\*\*[^*]+\*\*/,type:"keyword"},{match:/\*[^*]+\*/,type:"type"},{match:/__[^_]+__/,type:"keyword"},{match:/_[^_]+_/,type:"type"},{match:/`[^`]+`/,type:"string"},{match:/```/,type:"comment",next:"codeBlock"},{match:/^\s*[-*+]\s+/,type:"symbol"},{match:/^\s*\d+\.\s+/,type:"symbol"},{match:/\[([^\]]+)\]\(([^)]+)\)/,type:"builtin"},{match:/^>\s+/,type:"comment"},{match:/.+/,type:"text"}],codeBlock:[{match:/```/,type:"comment",pop:!0},{match:/.+/,type:"string"}]},reservedWords:[],icon:"Markdown text-red-500"});const it=["if","else","for","in","do","goto","call","exit","setlocal","endlocal","set","echo","rem","pause","cd","pushd","popd","shift","start"],ot=["dir","copy","move","del","ren","md","rd","type","find","findstr","tasklist","taskkill","ping","ipconfig","netstat","cls","title","color"];xe.registerLanguage({name:"Batch",extensions:["bat","cmd"],lineComment:"rem",states:{root:[{match:/^rem\s+.*/i,type:"comment"},{match:/^::.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/%[\w]+%/,type:"type"},{match:/\b\d+\b/,type:"number"},{match:_e([...it,...it.map(e=>e.toUpperCase())]),type:"keyword"},{match:_e(ot),type:"builtin"},{match:/@echo/,type:"statement"},{match:/[a-zA-Z_]\w*/,type:"text"},{match:/[<>|&()@]/,type:"symbol"},{match:/\s+/,type:"text"}],...ke},reservedWords:[...it,...ot],icon:"Terminal text-gray-300"});const nt=["project","cmake_minimum_required","add_executable","add_library","target_link_libraries","target_include_directories","set","option","if","else","elseif","endif","foreach","endforeach","while","endwhile","function","endfunction","macro","endmacro","find_package","include","message","install","add_subdirectory","configure_file"];xe.registerLanguage({name:"CMake",extensions:["cmake","txt","cmake-cache"],lineComment:"#",states:{root:[{match:/#.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/\$\{[^}]+\}/,type:"type"},{match:/\b\d+\.?\d*\b/,type:"number"},{match:_e([...nt,...nt.map(e=>e.toUpperCase())]),type:"keyword"},{match:/\b[A-Z_][A-Z0-9_]*\b/,type:"builtin"},{match:/[a-zA-Z_]\w*/,type:"text"},{match:/[(){}]/,type:"symbol"},{match:/\s+/,type:"text"}],...ke},reservedWords:[...nt],icon:"AlignLeft text-neutral-500"});const at=["as","break","const","continue","crate","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","unsafe","use","where","while","async","await","dyn","abstract","become","box","do","final","macro","override","priv","typeof","unsized","virtual","yield"],rt=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","bool","char","str","String","Vec","Option","Result","Box"],lt=["println","print","eprintln","eprint","format","panic","assert","assert_eq","assert_ne","debug_assert","vec","Some","None","Ok","Err"];xe.registerLanguage({name:"Rust",extensions:["rs"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/'(?:\\.|[^'])+'/,type:"string"},{match:/r#*"/,type:"string",next:"rawString"},...Se,{match:/#\[[\w:]+\]/,type:"preprocessor"},{match:_e(at),type:"keyword"},{match:_e(rt),type:"type"},{match:_e(lt),type:"builtin"},{match:/![a-zA-Z_]\w*/,type:"preprocessor"},...we],rawString:[{match:/"#*/,type:"string",pop:!0},{match:/[^"]+/,type:"string"},{match:/"/,type:"string"}],...ke},reservedWords:[...at,...rt,...lt],icon:"Rust text-orange-400"});class ct{onChange=void 0;_lines=[""];get lineCount(){return this._lines.length}constructor(e){this.onChange=e}getLine(e){return this._lines[e]??""}getText(e="\n"){return this._lines.join(e)}setText(e){this._lines=e.split(/\r?\n/),0===this._lines.length&&(this._lines=[""]),this.onChange&&this.onChange(this)}getCharAt(e,t){const s=this._lines[e];if(!(!s||t<0||t>=s.length))return s[t]}getWordAt(e,t){const s=this._lines[e];if(!s||t<0||t>s.length)return["",t,t];let i=t;for(;i>0&&Le(s[i-1]);)i--;let o=t;for(;o<s.length&&Le(s[o]);)o++;return[s.substring(i,o),i,o]}getIndent(e){const t=function(e){const t=e.search(/\S|$/);return t<e.length?t:-1}(this._lines[e]??"");return-1===t?this._lines[e]?.length??0:t}findNext(e,t,s){if(!e)return null;for(let i=t;i<this._lines.length;i++){const o=i===t?s:0,n=this._lines[i].indexOf(e,o);if(-1!==n)return{line:i,col:n}}for(let i=0;i<=t;i++){const o=i===t?s:this._lines[i].length,n=this._lines[i].indexOf(e);if(-1!==n&&n<o)return{line:i,col:n}}return null}insert(e,t,s){const i=s.split(/\r?\n/),o=this._lines[e]??"",n=o.substring(0,t),a=o.substring(t);if(1===i.length)this._lines[e]=n+i[0]+a;else{this._lines[e]=n+i[0];for(let t=1;t<i.length-1;t++)this._lines.splice(e+t,0,i[t]);this._lines.splice(e+i.length-1,0,i[i.length-1]+a)}return this.onChange&&this.onChange(this),{type:"insert",line:e,col:t,text:s}}delete(e,t,s){let i=s,o="",n=e,a=t;for(;i>0&&n<this._lines.length;){const e=this._lines[n],t=e.length-a;if(i<=t)o+=e.substring(a,a+i),this._lines[n]=e.substring(0,a)+e.substring(a+i),i=0;else{o+=e.substring(a)+"\n",i-=t+1;const s=this._lines[n+1]??"";this._lines[n]=e.substring(0,a)+s,this._lines.splice(n+1,1)}}return this.onChange&&this.onChange(this),{type:"delete",line:e,col:t,text:o}}insertLine(e,t=""){const s=e+1;return this._lines.splice(s,0,t),this.onChange&&this.onChange(this),{type:"insert",line:Math.max(e,0),col:e>=0?this._lines[e]?.length??0:0,text:"\n"+t}}removeLine(e){const t=this._lines[e];return this._lines.splice(e,1),0===this._lines.length&&(this._lines=[""]),this.onChange&&this.onChange(this),{type:"delete",line:Math.max(e-1,0),col:e>0?this._lines[e-1]?.length??0:0,text:"\n"+t}}replaceLine(e,t){const s=this._lines[e];return this._lines[e]=t,this.onChange&&this.onChange(this),{type:"replaceLine",line:e,col:0,text:t,oldText:s}}applyInverse(e){return"insert"===e.type?this.delete(e.line,e.col,e.text.length):"replaceLine"===e.type?this.replaceLine(e.line,e.oldText):this.insert(e.line,e.col,e.text)}}class ht{_undoStack=[];_redoStack=[];_pendingOps=[];_pendingCursorsBefore=[];_pendingCursorsAfter=[];_lastPushTime=0;_groupThresholdMs;_maxSteps;constructor(e=2e3,t=200){this._groupThresholdMs=e,this._maxSteps=t}record(e,t){const s=Date.now();s-this._lastPushTime>this._groupThresholdMs&&this._pendingOps.length>0&&this._flush(),0===this._pendingOps.length&&(this._pendingCursorsBefore=t.map(e=>({...e}))),this._pendingOps.push(e),this._pendingCursorsAfter=t.map(e=>({...e})),this._lastPushTime=s,this._redoStack.length=0}flush(e){e&&this._pendingOps.length>0&&(this._pendingCursorsAfter=e.map(e=>({...e}))),this._flush()}undo(e,t){this.flush(t);const s=this._undoStack.pop();if(!s)return null;const i=[];for(let t=s.operations.length-1;t>=0;t--){const o=e.applyInverse(s.operations[t]);i.unshift(o)}return this._redoStack.push({operations:i,cursorsBefore:s.cursorsBefore,cursorsAfter:s.cursorsAfter}),{cursors:s.cursorsBefore}}redo(e){const t=this._redoStack.pop();if(!t)return null;const s=[];for(let i=0;i<t.operations.length;i++){const o=e.applyInverse(t.operations[i]);s.push(o)}return this._undoStack.push({operations:s,cursorsBefore:t.cursorsBefore,cursorsAfter:t.cursorsAfter}),{cursors:t.cursorsAfter}}canUndo(){return this._undoStack.length>0||this._pendingOps.length>0}canRedo(){return this._redoStack.length>0}clear(){this._undoStack.length=0,this._redoStack.length=0,this._pendingOps.length=0,this._lastPushTime=0}_flush(){if(0!==this._pendingOps.length)for(this._undoStack.push({operations:[...this._pendingOps],cursorsBefore:[...this._pendingCursorsBefore],cursorsAfter:[...this._pendingCursorsAfter]}),this._pendingOps.length=0,this._pendingCursorsBefore=[],this._pendingCursorsAfter=[];this._undoStack.length>this._maxSteps;)this._undoStack.shift()}}function dt(e,t){return e.line===t.line&&e.col===t.col}function ut(e,t){return e.line<t.line||e.line===t.line&&e.col<t.col}function pt(e){return ut(e.anchor,e.head)?e.anchor:e.head}function mt(e){return ut(e.anchor,e.head)?e.head:e.anchor}function gt(e){return dt(e.anchor,e.head)}class ft{cursors=[];constructor(){this.cursors=[{anchor:{line:0,col:0},head:{line:0,col:0}}]}getPrimary(){return this.cursors[0]}set(e,t){this.cursors=[{anchor:{line:e,col:t},head:{line:e,col:t}}]}moveLeft(e,t=!1){for(const s of this.cursors)this._moveHead(s,e,-1,0,t);this._merge()}moveRight(e,t=!1){for(const s of this.cursors)this._moveHead(s,e,1,0,t);this._merge()}moveUp(e,t=!1){for(const s of this.cursors)this._moveVertical(s,e,-1,t);this._merge()}moveDown(e,t=!1){for(const s of this.cursors)this._moveVertical(s,e,1,t);this._merge()}moveToLineStart(e,t=!1,s=!1){for(const i of this.cursors){const o=i.head.line,n=e.getIndent(o),a=i.head.col===n||s?0:n;i.head={line:o,col:a},t||(i.anchor={...i.head})}this._merge()}moveToLineEnd(e,t=!1){for(const s of this.cursors){const i=s.head.line;s.head={line:i,col:e.getLine(i).length},t||(s.anchor={...s.head})}this._merge()}moveWordLeft(e,t=!1){for(const s of this.cursors){const{line:i,col:o}=s.head;if(0===o&&i>0)s.head={line:i-1,col:e.getLine(i-1).length};else{const t=e.getLine(i);let n=o;for(;n>0&&/\s/.test(t[n-1]);)n--;if(n>0&&Le(t[n-1]))for(;n>0&&Le(t[n-1]);)n--;else if(n>0)for(;n>0&&ve(t[n-1]);)n--;s.head={line:i,col:n}}t||(s.anchor={...s.head})}this._merge()}moveWordRight(e,t=!1){for(const s of this.cursors){const{line:i,col:o}=s.head,n=e.getLine(i);if(o>=n.length&&i<e.lineCount-1)s.head={line:i+1,col:0};else{let e=o;for(;e<n.length&&/\s/.test(n[e]);)e++;if(e<n.length&&Le(n[e]))for(;e<n.length&&Le(n[e]);)e++;else if(e<n.length&&ve(n[e]))for(;e<n.length&&ve(n[e]);)e++;s.head={line:i,col:e}}t||(s.anchor={...s.head})}this._merge()}selectAll(e){const t=e.lineCount-1;this.cursors=[{anchor:{line:0,col:0},head:{line:t,col:e.getLine(t).length}}]}addCursor(e,t){this.cursors.push({anchor:{line:e,col:t},head:{line:e,col:t}}),this._merge()}removeSecondaryCursors(){this.cursors=[this.cursors[0]]}sortedIndicesBottomUp(){return this.cursors.map((e,t)=>t).sort((e,t)=>{const s=this.cursors[e].head,i=this.cursors[t].head;return i.line!==s.line?i.line-s.line:i.col-s.col})}adjustOthers(e,t,s,i,o=0){for(let n=0;n<this.cursors.length;n++){if(n===e)continue;const a=this.cursors[n];0!==o&&a.head.line>t?a.head={line:a.head.line+o,col:a.head.col}:a.head.line===t&&a.head.col>=s&&(a.head={line:a.head.line+o,col:a.head.col+i}),0!==o&&a.anchor.line>t?a.anchor={line:a.anchor.line+o,col:a.anchor.col}:a.anchor.line===t&&a.anchor.col>=s&&(a.anchor={line:a.anchor.line+o,col:a.anchor.col+i})}}hasSelection(e=0){const t=this.cursors[e];return!!t&&!dt(t.anchor,t.head)}getSelectedText(e,t=0){const s=this.cursors[t];if(!s||gt(s))return"";const i=pt(s),o=mt(s);if(i.line===o.line)return e.getLine(i.line).substring(i.col,o.col);const n=[];n.push(e.getLine(i.line).substring(i.col));for(let t=i.line+1;t<o.line;t++)n.push(e.getLine(t));return n.push(e.getLine(o.line).substring(0,o.col)),n.join("\n")}getCursorPositions(){return this.cursors.map(e=>({...e.head}))}_moveHead(e,t,s,i,o){const{line:n,col:a}=e.head;if(!o&&!gt(e)){const t=s<0?pt(e):mt(e);return e.head={...t},void(e.anchor={...t})}if(s<0)a>0?e.head={line:n,col:a-1}:n>0&&(e.head={line:n-1,col:t.getLine(n-1).length});else if(s>0){a<t.getLine(n).length?e.head={line:n,col:a+1}:n<t.lineCount-1&&(e.head={line:n+1,col:0})}o||(e.anchor={...e.head})}_moveVertical(e,t,s,i){const{line:o,col:n}=e.head,a=o+s;if(a<0||a>=t.lineCount)return;const r=t.getLine(a).length;e.head={line:a,col:Math.min(n,r)},i||(e.anchor={...e.head})}_merge(){if(this.cursors.length<=1)return;this.cursors.sort((e,t)=>e.head.line!==t.head.line?e.head.line-t.head.line:e.head.col-t.head.col);const e=[this.cursors[0]];for(let t=1;t<this.cursors.length;t++){const s=e[e.length-1],i=this.cursors[t];dt(s.head,i.head)||e.push(i)}this.cursors=e}}class Ct{_symbols=new Map;_lineSymbols=[];_scopeStack=[{name:"global",type:"global",line:0}];_lineScopes=[];get currentScope(){return this._scopeStack[this._scopeStack.length-1]?.name??"global"}get currentScopeType(){return this._scopeStack[this._scopeStack.length-1]?.type??"global"}getScopeAtLine(e){return this._lineScopes[e]??[{name:"global",type:"global",line:0}]}getSymbols(e){return this._symbols.get(e)??[]}getAllSymbolNames(){return Array.from(this._symbols.keys())}getAllSymbols(){const e=[];for(const t of this._symbols.values())e.push(...t);return e}getLineSymbols(e){return this._lineSymbols[e]??[]}updateScopeForLine(e,t){const s=(t.match(/\{/g)||[]).length,i=(t.match(/\}/g)||[]).length;this._lineScopes[e]=[...this._scopeStack];for(let e=0;e<i;e++)this._scopeStack.length>1&&this._scopeStack.pop();for(let t=0;t<s;t++)this._scopeStack.push({name:"anonymous",type:"anonymous",line:e})}nameCurrentScope(e,t){if(this._scopeStack.length>0){const s=this._scopeStack[this._scopeStack.length-1];"anonymous"!==s.name&&"anonymous"!==s.type||(s.name=e,s.type=t)}}removeLineSymbols(e){const t=this._lineSymbols[e];if(t){for(const s of t){const t=this._symbols.get(s.name);if(!t)continue;const i=t.findIndex(t=>t.line===e&&t.kind===s.kind&&t.scope===s.scope);-1!==i&&t.splice(i,1),0===t.length&&this._symbols.delete(s.name)}this._lineSymbols[e]=[]}}addSymbol(e){this._symbols.has(e.name)||this._symbols.set(e.name,[]),this._symbols.get(e.name).push(e),this._lineSymbols[e.line]||(this._lineSymbols[e.line]=[]),this._lineSymbols[e.line].push(e)}resetScopes(){this._scopeStack=[{name:"global",type:"global",line:0}],this._lineScopes=[]}clear(){this._symbols.clear(),this._lineSymbols=[],this.resetScopes()}}const yt=globalThis,vt={keyword:"cm-kwd",statement:"cm-std",type:"cm-typ",builtin:"cm-bln",string:"cm-str",comment:"cm-com",number:"cm-dec",method:"cm-mtd",symbol:"cm-sym",enum:"cm-enu",preprocessor:"cm-ppc",variable:"cm-var"};e.LX.Area,e.LX.Panel,e.LX.Tabs,e.LX.NodeTree;class Lt{static SIZE=10;root;thumb;_vertical;_thumbPos=0;_thumbRatio=0;_lastMouse=0;_onDrag=null;get visible(){return!this.root.classList.contains("hidden")}get isVertical(){return this._vertical}constructor(t,s){this._vertical=t,this._onDrag=s,this.root=e.LX.makeElement("div","lexcodescrollbar hidden "+(t?"vertical":"horizontal")),this.thumb=e.LX.makeElement("div"),this.thumb.addEventListener("mousedown",e=>this._onMouseDown(e)),this.root.appendChild(this.thumb)}setThumbRatio(t){this._thumbRatio=e.LX.clamp(t,0,1);const s=this._thumbRatio<1;this.root.classList.toggle("hidden",!s),s&&(this._vertical?this.thumb.style.height=100*this._thumbRatio+"%":this.thumb.style.width=100*this._thumbRatio+"%")}syncToScroll(e,t){if(t<=0)return;const s=(this._vertical?this.root.offsetHeight:this.root.offsetWidth)-(this._vertical?this.thumb.offsetHeight:this.thumb.offsetWidth);s<=0||(this._thumbPos=e/t*s,this._applyPosition())}applyDragDelta(t,s){const i=(this._vertical?this.root.offsetHeight:this.root.offsetWidth)-(this._vertical?this.thumb.offsetHeight:this.thumb.offsetWidth);return i<=0?0:(this._thumbPos=e.LX.clamp(this._thumbPos+t,0,i),this._applyPosition(),this._thumbPos/i*s)}_applyPosition(){this._vertical?this.thumb.style.top=this._thumbPos+"px":this.thumb.style.left=this._thumbPos+"px"}_onMouseDown(e){const t=document;this._lastMouse=this._vertical?e.clientY:e.clientX;const s=e=>{const t=this._vertical?e.clientY:e.clientX,s=t-this._lastMouse;this._lastMouse=t,this._onDrag?.(s),e.stopPropagation(),e.preventDefault()},i=()=>{t.removeEventListener("mousemove",s),t.removeEventListener("mouseup",i)};t.addEventListener("mousemove",s),t.addEventListener("mouseup",i),e.stopPropagation(),e.preventDefault()}}class bt{static __instances=[];language;symbolTable;area;baseArea;codeArea;explorerArea;tabs;root;codeScroller;codeSizer;cursorsLayer;selectionsLayer;lineGutter;vScrollbar;hScrollbar;searchBox=null;searchLineBox=null;autocomplete=null;currentTab=null;statusPanel;leftStatusPanel;rightStatusPanel;explorer=null;charWidth=0;lineHeight=0;fontSize=0;xPadding=64;_cachedTabsHeight=0;_cachedStatusPanelHeight=0;skipInfo=!1;disableEdition=!1;skipTabs=!1;useFileExplorer=!1;useAutoComplete=!0;allowAddScripts=!0;allowClosingTabs=!0;allowLoadingFiles=!0;tabSize=4;highlight="Plain Text";newTabOptions=null;customSuggestions=[];explorerName="EXPLORER";onSave;onRun;onCtrlSpace;onCreateStatusPanel;onContextMenu;onNewTab;onSelectTab;onReady;onCreateFile;onCodeChange;_inputArea;_lineStates=[];_lineElements=[];_openedTabs={};_loadedTabs={};_storedTabs={};_focused=!1;_composing=!1;_keyChain=null;_wasPaired=!1;_lastAction="";_blinkerInterval=null;_cursorVisible=!0;_cursorBlinkRate=550;_clickCount=0;_lastClickTime=0;_lastClickLine=-1;_isSearchBoxActive=!1;_isSearchLineBoxActive=!1;_searchMatchCase=!1;_lastTextFound="";_lastSearchPos=null;_discardScroll=!1;_isReady=!1;_lastMaxLineLength=0;_lastLineCount=0;_isAutoCompleteActive=!1;_selectedAutocompleteIndex=0;_displayObservers;static CODE_MIN_FONT_SIZE=9;static CODE_MAX_FONT_SIZE=22;static PAIR_KEYS={'"':'"',"'":"'","`":"`","(":")","{":"}","[":"]"};get doc(){return this.currentTab.doc}get undoManager(){return this.currentTab.undoManager}get cursorSet(){return this.currentTab.cursorSet}get codeContainer(){return this.currentTab.dom}static getInstances(){return bt.__instances}constructor(t,s={}){if(yt.editor=this,bt.__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.allowAddScripts=s.allowAddScripts??this.allowAddScripts,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,this.onRun=s.onRun,this.onCtrlSpace=s.onCtrlSpace,this.onCreateStatusPanel=s.onCreateStatusPanel,this.onContextMenu=s.onContextMenu,this.onNewTab=s.onNewTab,this.onSelectTab=s.onSelectTab,this.onReady=s.onReady,this.onCodeChange=s.onCodeChange,this.language=xe.getLanguage(this.highlight)??xe.getLanguage("Plain Text"),this.symbolTable=new Ct,this.useFileExplorer){let[s,i]=t.split({sizes:["15%","85%"]});this.explorerArea=s;let o=new e.LX.Panel;o.addTitle(this.explorerName);let n=[];this.explorer=o.addTree(null,n,{filter:!1,rename:!1,skipDefaultIcon:!0}),this.explorer.on("dblClick",e=>{const t=e.items[0].id;this.loadTab(t)}),this.explorer.on("beforeDelete",(e,t)=>{}),s.attach(o),t=i}t.root.className=e.LX.mergeClass(t.root.className,"codebasearea overflow-hidden flex relative"),this.baseArea=t,this.area=new e.LX.Area({className:"lexcodeeditor flex flex-col outline-none overflow-hidden size-full select-none bg-inherit relative",skipAppend:!0});const i="lexcodearea scrollbar-hidden flex flex-row flex-auto-fill";if(this.skipTabs?(this.codeArea=new e.LX.Area({className:i,skipAppend:!0}),this.area.attach(this.codeArea)):(this.tabs=this.area.addTabs({contentClass:i,onclose:e=>{delete this._openedTabs[e]}}),e.LX.addClass(this.tabs.root.parentElement,"rounded-t-lg"),this.disableEdition||this.tabs.root.parentElement.addEventListener("dblclick",e=>{this.allowAddScripts&&(e.preventDefault(),this._onCreateNewFile())}),this.codeArea=this.tabs.area),this.root=this.area.root,t.attach(this.root),this.codeScroller=this.codeArea.root,this.lineGutter=e.LX.makeElement("div","w-16 overflow-hidden absolute top-0 bg-inherit z-10 "+(this.skipTabs?"":"mt-8"),null,this.codeScroller),this.codeSizer=e.LX.makeElement("div","pseudoparent-tabs w-full",null,this.codeScroller),this.cursorsLayer=e.LX.makeElement("div","cursors",null,this.codeSizer),this.selectionsLayer=e.LX.makeElement("div","selections",null,this.codeSizer),!this.disableEdition){this.vScrollbar=new Lt(!0,e=>{const t=this.codeScroller.scrollHeight-this.codeScroller.clientHeight;this.codeScroller.scrollTop=this.vScrollbar.applyDragDelta(e,t),this._discardScroll=!0}),this.root.appendChild(this.vScrollbar.root),this.hScrollbar=new Lt(!1,e=>{const t=this.codeScroller.scrollWidth-this.codeScroller.clientWidth;this.codeScroller.scrollLeft=this.hScrollbar.applyDragDelta(e,t),this._discardScroll=!0}),this.root.appendChild(this.hScrollbar.root),this.codeScroller.addEventListener("scroll",()=>{this._discardScroll?this._discardScroll=!1:this._syncScrollBars()});let e=0,t=0;this.codeScroller.addEventListener("touchstart",s=>{e=s.touches[0].clientX,t=s.touches[0].clientY},{passive:!0}),this.codeScroller.addEventListener("touchmove",s=>{const i=s.touches[0].clientX,o=s.touches[0].clientY,n=e-i,a=t-o;this.codeScroller.scrollLeft+=n,this.codeScroller.scrollTop+=a,e=i,t=o},{passive:!0}),this.codeScroller.addEventListener("wheel",e=>{if(e.ctrlKey)return e.preventDefault(),void this._applyFontSizeOffset(e.deltaY<0?1:-1);e.shiftKey&&(this.codeScroller.scrollLeft+=e.deltaY>0?10:-10)},{passive:!1})}if(new ResizeObserver(()=>{this.currentTab&&this.resize(!0)}).observe(this.codeArea.root),!this.disableEdition){this.useAutoComplete&&(this.autocomplete=e.LX.makeElement("div","autocomplete"),this.codeArea.attach(this.autocomplete));const t="searchbox bg-card min-w-96 absolute z-100 top-8 right-2 rounded-lg border-color overflow-y-scroll opacity-0";{const s=e.LX.makeElement("div",t,null,this.codeArea),i=new e.LX.Panel;s.appendChild(i.root),i.sameLine();const o=i.addText(null,"",null,{placeholder:"Find",inputClass:"bg-secondary"});i.addButton(null,"MatchCaseButton",e=>{this._searchMatchCase=e,this._doSearch()},{icon:"CaseSensitive",selectable:!0,buttonClass:"link",title:"Match Case",tooltip:!0}),i.addButton(null,"up",()=>this._doSearch(null,!0),{icon:"ArrowUp",buttonClass:"ghost",title:"Previous Match",tooltip:!0}),i.addButton(null,"down",()=>this._doSearch(),{icon:"ArrowDown",buttonClass:"ghost",title:"Next Match",tooltip:!0}),i.addButton(null,"x",this._doHideSearch.bind(this),{icon:"X",buttonClass:"ghost",title:"Close",tooltip:!0}),i.endLine();const n=o.root.querySelector("input");n?.addEventListener("keyup",e=>{"Escape"==e.key?this._doHideSearch():"Enter"==e.key&&this._doSearch(e.target.value,!!e.shiftKey)}),this.searchBox=s}{const s=e.LX.makeElement("div",t,null,this.codeArea),i=new e.LX.Panel;s.appendChild(i.root),i.sameLine();const o=i.addText(null,"",e=>{n.value=":"+e.replaceAll(":",""),this._doGotoLine(parseInt(n.value.slice(1)))},{className:"flex-auto-fill",placeholder:"Go to line",trigger:"input"});i.addButton(null,"x",this._doHideSearch.bind(this),{icon:"X",title:"Close",buttonClass:"ghost",tooltip:!0}),i.endLine();const n=o.root.querySelector("input");n.addEventListener("keyup",e=>{"Escape"==e.key&&this._doHideSearch()}),i.addText(null,"Type a line number to go to (from 0 to 0).",null,{disabled:!0,inputClass:"text-xs bg-none",signal:"@line-number-range"}),this.searchLineBox=s}}this._inputArea=e.LX.makeElement("textarea","absolute opacity-0 w-[1px] h-[1px] top-0 left-0 overflow-hidden resize-none","",this.root),this._inputArea.setAttribute("autocorrect","off"),this._inputArea.setAttribute("autocapitalize","off"),this._inputArea.setAttribute("spellcheck","false"),this._inputArea.tabIndex=0,this._inputArea.addEventListener("keydown",this._onKeyDown.bind(this)),this._inputArea.addEventListener("compositionstart",()=>this._composing=!0),this._inputArea.addEventListener("compositionend",e=>{this._composing=!1,this._inputArea.value="",e.data&&this._doInsertChar(e.data)}),this._inputArea.addEventListener("input",()=>{if(this._composing)return;const e=this._inputArea.value;e&&(this._inputArea.value="",this._doInsertChar(e))}),this._inputArea.addEventListener("focus",()=>this._setFocused(!0)),this._inputArea.addEventListener("blur",()=>this._setFocused(!1)),this.codeArea.root.addEventListener("mousedown",this._onMouseDown.bind(this)),this.codeArea.root.addEventListener("contextmenu",this._onMouseDown.bind(this)),this.statusPanel=this._createStatusPanel(s),this.statusPanel&&this.area.root.appendChild(this.statusPanel.root),this.allowAddScripts&&(this.onCreateFile=s.onCreateFile,this.addTab("+",{selected:!1,title:"Create file"})),(s.defaultTab??1)&&(this.addTab(s.name||"untitled",{language:this.highlight,title:s.title}),this._renderAllLines(),this._renderCursors()),this._init()}_init(){if(this._displayObservers)return;this._isReady=!1;const e=this.root,t=async()=>{this._isReady||null!==e.offsetParent&&e.clientWidth>0&&e.clientHeight>0&&(s.disconnect(),i.disconnect(),await this._setupEditorWhenVisible())},s=new IntersectionObserver(e=>{for(const s of e)s.isIntersecting&&t()});s.observe(e);const i=new ResizeObserver(()=>{t()});i.observe(e),this._displayObservers={intersectionObserver:s,resizeObserver:i}}clear(){console.assert(this.rightStatusPanel&&this.leftStatusPanel,"No panels to clear."),this.rightStatusPanel.clear(),this.leftStatusPanel.clear()}addExplorerItem(e){this.explorer&&(this.explorer.innerTree.data.find((t,s)=>t.id===e.id)||this.explorer.innerTree.data.push(e))}setText(e){this.currentTab&&(this.doc.setText(e),this.cursorSet.set(0,0),this.undoManager.clear(),this._lineStates=[],this._renderAllLines(),this._renderCursors(),this._renderSelections(),this.resize(!0))}appendText(e){const t=this.cursorSet.getPrimary(),{line:s,col:i}=t.head,o=this.doc.insert(s,i,e);this.undoManager.record(o,this.cursorSet.getCursorPositions());const n=e.split(/\r?\n/);1===n.length?t.head={line:s,col:i+e.length}:t.head={line:s+n.length-1,col:n[n.length-1].length},t.anchor={...t.head},this._rebuildLines(),this._renderCursors(),this._renderSelections(),this.resize(),this._scrollCursorIntoView()}getText(){return this.doc.getText()}setLanguage(t,s){const i=xe.getLanguage(t);i&&(this.language=i,this.currentTab&&(this.currentTab.language=t,this.skipTabs||this.tabs.setIcon(this.currentTab.name,be(i,s))),this._lineStates=[],this._renderAllLines(),e.LX.emitSignal("@highlight",t))}focus(){this._inputArea.focus()}addTab(t,s={}){const i="+"===t,o=e.LX.makeElement("div","code"),n=s.language??"Plain Text",a=xe.getLanguage(n),r=e.LX.getExtension(t),l=i?null:be(a,r),c=s.selected??!0,h={name:t,dom:o,doc:new ct(this.onCodeChange),cursorSet:new ft,undoManager:new ht,language:n,title:s.title??t};return this._openedTabs[t]=h,this._loadedTabs[t]=h,this.useFileExplorer&&!i&&(this.addExplorerItem({id:t,skipVisibility:!0,icon:l}),this.explorer.innerTree.frefresh(t)),this.skipTabs||this.tabs.add(t,o,{selected:c,icon:l,fixed:i,title:h.title,onSelect:this._onSelectTab.bind(this,i),onContextMenu:this._onContextMenuTab.bind(this,i),allowDelete:this.allowClosingTabs,indexOffset:s.indexOffset}),this.codeSizer.appendChild(o),s.text&&(h.doc.setText(s.text),h.cursorSet.set(0,0),h.undoManager.clear(),this._renderAllLines(),this._renderCursors(),this._renderSelections(),this._resetGutter()),c&&(this.currentTab=h,this._updateDataInfoPanel("@tab-name",t),this.setLanguage(n,r)),h}loadTab(e){if(this._openedTabs[e])return void this.tabs.select(e);const t=this._loadedTabs[e];if(t)return this._openedTabs[e]=t,this.tabs.add(e,t.dom,{selected:!0,title:t.title,onSelect:this._onSelectTab.bind(this),onContextMenu:this._onContextMenuTab.bind(this),allowDelete:this.allowClosingTabs}),this.codeSizer.appendChild(t.dom),this.currentTab=t,void this._updateDataInfoPanel("@tab-name",e);this.addTab(e,this._storedTabs[e]??null)}closeTab(e){if(!this.allowClosingTabs)return;this.tabs.delete(e);const t=this._openedTabs[e];if(t&&(t.dom.remove(),delete this._openedTabs[e]),this.currentTab?.name===e){const e=Object.keys(this._openedTabs).filter(e=>"+"!==e);e.length>0?this.tabs.select(e[0]):this.currentTab=null}}setCustomSuggestions(e){e&&e.constructor===Array?this.customSuggestions=e:console.warn("suggestions should be a string array!")}loadFile(t,s={}){const i=(t,i)=>{t=t.replaceAll("\r","").replaceAll(/\t|\\t/g," ".repeat(this.tabSize));const o=e.LX.getExtension(i),n=s.language??xe.getLanguage(s.language)??xe.getLanguageByExtension(o)??xe.getLanguage("Plain Text"),a=n.name;this.useFileExplorer||this.skipTabs?(this._storedTabs[i]={text:t,title:s.title??i,language:a,...s},this.useFileExplorer&&(this.addExplorerItem({id:i,skipVisibility:!0,icon:be(n,o)}),this.explorer.innerTree.frefresh(i))):(this.addTab(i,{selected:!0,title:s.title??i,language:a}),this.doc.setText(t),this.setLanguage(a,o),this.cursorSet.set(0,0),this.undoManager.clear(),this._renderCursors(),this._renderSelections(),this._resetGutter()),s.callback&&s.callback(i,t)};if("string"==typeof t){const o=t,n=s.filename??o.substring(o.lastIndexOf("/")+1);e.LX.request({url:o,success:e=>{i(e,n)}})}else{const e=new FileReader;e.readAsText(t),e.onload=e=>{const s=e.currentTarget.result;i(s,t.name)}}}async loadFiles(t,s,i=!1){if(!t||0===t.length)return void s?.(this,[],0);const o=[];for(const s of t)try{const t=await e.LX.requestFileAsync(s,"text"),i=s.substring(s.lastIndexOf("/")+1),n=t.replaceAll("\r","").replaceAll(/\t|\\t/g," ".repeat(this.tabSize)),a=e.LX.getExtension(i),r=xe.getLanguageByExtension(a)??xe.getLanguage("Plain Text"),l=r.name;this.useFileExplorer||this.skipTabs?(this._storedTabs[i]={text:n,title:i,language:l},this.useFileExplorer&&(this.addExplorerItem({id:i,skipVisibility:!0,icon:be(r,a)}),this.explorer.innerTree.frefresh(i))):(this.addTab(i,{selected:0===o.length,title:i,language:l}),0===o.length&&(this.doc.setText(n),this.setLanguage(l,a),this.cursorSet.set(0,0),this.undoManager.clear(),this._renderCursors(),this._renderSelections(),this._resetGutter())),o.push({filePath:s,name:i,success:!0})}catch(e){console.error(`[LX.CodeEditor] Failed to load file: ${s}`,e),o.push({filePath:s,success:!1,error:e})}s?.(this,o,o.length)}async _setupEditorWhenVisible(){const t=window.localStorage.getItem("lexcodeeditor-font-size");if(t)await this._setFontSize(parseInt(t),!1);else{const e=document.querySelector(":root"),t=getComputedStyle(e);this.fontSize=parseInt(t.getPropertyValue("--code-editor-font-size")),await this._measureChar()}e.LX.emitSignal("@font-size",this.fontSize),e.LX.doAsync(()=>{this._isReady||(this._isReady=!0,this.onReady&&this.onReady(this),console.log(`[LX.CodeEditor] Ready! (font size: ${this.fontSize}px, char size: ${this.charWidth}px)`))},20)}_onSelectTab(t,s,i){this.disableEdition||(t?this._onNewTab(s):(this.currentTab=this._openedTabs[i],this._updateDataInfoPanel("@tab-name",i),this.language=xe.getLanguage(this.currentTab.language)??xe.getLanguage("Plain Text"),e.LX.emitSignal("@highlight",this.currentTab.language),this._renderAllLines(),this._afterCursorMove(),!t&&this.onSelectTab&&this.onSelectTab(i,this)))}_onNewTab(t){if(this.onNewTab)return void this.onNewTab(t);const s=this.newTabOptions??[{name:"Create file",icon:"FilePlus",callback:this._onCreateNewFile.bind(this)},{name:"Load file",icon:"FileUp",disabled:!this.allowLoadingFiles,callback:this._doLoadFromFile.bind(this)}];e.LX.addDropdownMenu(t.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,{selected:!0,title:t,indexOffset:e.indexOffset,language:e.language??"JavaScript"}),this._renderAllLines(),this._renderCursors(),this._renderSelections(),this._resetGutter()}_onContextMenuTab(t=!1,s,i){t||e.LX.addDropdownMenu(s.target,[{name:"Close",kbd:"MWB",disabled:!this.allowClosingTabs,callback:()=>{this.closeTab(i)}},{name:"Close Others",disabled:!this.allowClosingTabs,callback:()=>{for(const e of Object.keys(this.tabs.tabs))"+"!==e&&e!==i&&this.closeTab(e)}},{name:"Close All",disabled:!this.allowClosingTabs,callback:()=>{for(const e of Object.keys(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})}async _measureChar(){const t=e.LX.makeContainer(null,"lexcodeeditor","",document.body),s=e.LX.makeContainer(null,"code","",t),i=document.createElement("pre");s.appendChild(i);const o=document.createElement("span");o.className="codechar",o.style.visibility="hidden",o.textContent="M",i.appendChild(o);const n=getComputedStyle(o),a=n.fontFamily,r=n.fontSize,l=n.fontWeight||"normal",c=`${n.fontStyle||"normal"} ${l} ${r} ${a}`;try{await document.fonts.load(c)}catch(e){console.warn("[LX.CodeEditor] Failed to load font:",c,e)}requestAnimationFrame(()=>{const s=o.getBoundingClientRect();this.charWidth=s.width||7,this.lineHeight=parseFloat(getComputedStyle(this.root).getPropertyValue("--code-editor-row-height"))||20,e.LX.deleteElement(t),this._renderCursors(),this._renderSelections(),this.resize(!0)})}_createStatusPanel(t={}){if(this.skipInfo)return;let s=new e.LX.Panel({className:"lexcodetabinfo bg-inherit flex flex-row flex-auto-keep",height:"auto"});this.onCreateStatusPanel&&this.onCreateStatusPanel(s,this);let i=this.leftStatusPanel=new e.LX.Panel({id:"FontSizeZoomStatusComponent",className:"pad-xs content-center items-center flex-auto-keep",width:"auto",height:"auto"});i.sameLine(),i.addButton(null,"ZoomOutButton",this._decreaseFontSize.bind(this),{icon:"ZoomOut",buttonClass:"ghost sm",title:"Zoom Out",tooltip:!0}),i.addLabel(this.fontSize,{fit:!0,signal:"@font-size"}),i.addButton(null,"ZoomInButton",this._increaseFontSize.bind(this),{icon:"ZoomIn",buttonClass:"ghost sm",title:"Zoom In",tooltip:!0}),i.endLine("justify-start"),s.attach(i.root);let o=this.rightStatusPanel=new e.LX.Panel({className:"pad-xs content-center items-center",height:"auto"});o.sameLine(),o.addLabel(this.currentTab?.title??"",{id:"EditorFilenameStatusComponent",fit:!0,inputClass:"text-xs",signal:"@tab-name"}),o.addButton(null,"Ln 1, Col 1",this._doOpenLineSearch.bind(this),{id:"EditorSelectionStatusComponent",buttonClass:"outline xs",fit:!0,signal:"@cursor-data"});const n=o.addButton(null,"Spaces: "+this.tabSize,(t,s)=>{const i=e=>{this.tabSize=parseInt(e),this._rebuildLines(),this._updateDataInfoPanel("@tab-spaces",`Spaces: ${this.tabSize}`)},o=e.LX.addDropdownMenu(n.root,["2","4","8"].map(e=>({name:e,className:"w-full place-content-center",callback:i})),{side:"top",align:"end"});e.LX.addClass(o.root,"min-w-16! items-center")},{id:"EditorIndentationStatusComponent",buttonClass:"outline xs",signal:"@tab-spaces"}),a=o.addButton("<b>{ }</b>",this.highlight,(t,s)=>{const i=e.LX.addDropdownMenu(a.root,xe.getRegisteredLanguages().map(e=>{const t=be(xe.getLanguage(e)),s=t?t.split(" "):[];return{name:e,icon:s[0],className:"w-full text-xs px-3",svgClass:s.slice(1).join(" "),callback:e=>this.setLanguage(e)}}),{side:"top",align:"end"});e.LX.addClass(i.root,"min-w-min! items-center")},{id:"EditorLanguageStatusComponent",nameWidth:"auto",buttonClass:"outline xs",signal:"@highlight",title:""});o.endLine("justify-end"),s.attach(o.root);const r={"Font Size Zoom":t.statusShowFontSizeZoom??!0,"Editor Filename":t.statusShowEditorFilename??!0,"Editor Selection":t.statusShowEditorSelection??!0,"Editor Indentation":t.statusShowEditorIndentation??!0,"Editor Language":t.statusShowEditorLanguage??!0},l=e=>{const t=s.root.querySelector(`#${e.replaceAll(" ","")}StatusComponent`);console.assert(t,`${e} has no status button!`),t.classList.toggle("hidden",!r[e])};for(const[e,t]of Object.entries(r))l(e);return s.root.addEventListener("contextmenu",t=>{if(t.target&&(t.target.classList.contains("lexpanel")||t.target.classList.contains("lexinlinecomponents")))return;const s=Object.keys(r).map((e,t)=>{const s={name:e,icon:"Check",callback:()=>{r[e]=!r[e],l(e)}};return r[e]||delete s.icon,s});e.LX.addDropdownMenu(t.target,s,{side:"top",align:"start"})}),s}_updateDataInfoPanel(t,s){this.skipInfo||(this.cursorSet.cursors.length>1&&(s=""),e.LX.emitSignal(t,s))}_tokenizeLine(e){const t=e>0?this._lineStates[e-1]??xe.initialState():xe.initialState(),s=this.doc.getLine(e),i=xe.tokenizeLine(s,this.language,t),o=this.language.name.toLowerCase().replace(/[^a-z]/g,"");let n="";for(const e of i.tokens){const t=vt[e.type],s=e.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");n+=t?`<span class="${t} ${o}">${s}</span>`:s}return{html:n||" ",endState:i.state,tokens:i.tokens}}_updateSymbolsForLine(e){const t=this.doc.getLine(e);this.symbolTable.updateScopeForLine(e,t),this.symbolTable.removeLineSymbols(e);const{tokens:s}=this._tokenizeLine(e),i=function(e,t,s,i){const o=[],n=i.currentScope,a=i.currentScopeType,r=new Set;for(const e of t)["keyword","statement","builtin","preprocessor"].includes(e.type)&&r.add(e.value);const l=new Set,c=(e,t,i=0)=>{if(!e||!e.match(/^[a-zA-Z_$][\w$]*$/))return;if(r.has(e))return;const a=`${e}@${5*Math.floor(i/5)}`;l.has(a)||(o.push({name:e,kind:t,scope:n,line:s,col:i}),l.add(a))},h=[{regex:/^\s*class\s+([A-Z_]\w*)/i,kind:"class"},{regex:/^\s*struct\s+([A-Z_]\w*)/i,kind:"struct"},{regex:/^\s*interface\s+([A-Z_]\w*)/i,kind:"interface"},{regex:/^\s*enum\s+([A-Z_]\w*)/i,kind:"enum"},{regex:/^\s*type\s+([A-Z_]\w*)\s*=/i,kind:"type"},{regex:/^\s*(?:export\s+)?(?:async\s+)?function\s+(\w+)/i,kind:"function"},{regex:/^\s*(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?\([^)]*\)\s*=>/i,kind:"function"},{regex:/^\s*(?:static\s+|const\s+|virtual\s+|inline\s+|extern\s+|pub\s+|async\s+)*(\w+[\w\s\*&:<>,]*?)\s+(\w+)\s*\([^)]*\)\s*[{;]/i,kind:"typed-function"},{regex:/^\s*(?:public|private|protected|static|readonly)*\s*(\w+)\s*\([^)]*\)\s*[:{]/i,kind:"class"===a?"method":"function"}],d=[{regex:/(?:const|let|var)\s+(\w+)/gi,kind:"variable"},{regex:/(\w+)\s*:\s*(?:function|[A-Z]\w*)/gi,kind:"variable"},{regex:/this\.(\w+)\s*=/gi,kind:"property"},{regex:/new\s+([A-Z]\w+)/gi,kind:"constructor-call"},{regex:/(\w+)\s*\(/gi,kind:"method-call"}];let u=!1;for(const t of h){const s=e.match(t.regex);if(s){let o,n=t.kind;if("typed-function"===t.kind&&s[2])o=s[2],n="class"===a?"method":"function";else{if(!s[1])continue;o=s[1]}c(o,n,e.indexOf(o)),["class","function","method","enum","struct","interface"].includes(n)&&i.nameCurrentScope(o,n),u=!0;break}}if(!u)for(const t of d){const s=e.matchAll(t.regex);for(const e of s)if(e[1]){const s=e[1],i=e.index??0;c(s,t.kind,i)}}if("enum"===a){const t=e.match(/^\s*(\w+)\s*[,=]?/);t&&t[1]&&!e.includes("enum")&&c(t[1],"enum-value",e.indexOf(t[1]))}return o}(t,s,e,this.symbolTable);for(const e of i)this.symbolTable.addSymbol(e)}_renderAllLines(){if(this.currentTab){this.codeContainer.innerHTML="",this._lineElements=[],this._lineStates=[],this.symbolTable.clear();for(let e=0;e<this.doc.lineCount;e++)this._appendLineElement(e)}}_getGutterHtml(e){return`<span class="line-gutter">${e+1}</span>`}_appendLineElement(e){const{html:t,endState:s}=this._tokenizeLine(e);this._lineStates[e]=s;const i=document.createElement("pre");i.innerHTML=this._getGutterHtml(e)+t,this.codeContainer.appendChild(i),this._lineElements[e]=i,this._updateSymbolsForLine(e)}_updateLine(e){const{html:t,endState:s}=this._tokenizeLine(e),i=this._lineStates[e];if(this._lineStates[e]=s,this._lineElements[e]&&(this._lineElements[e].innerHTML=this._getGutterHtml(e)+t),this._updateSymbolsForLine(e),!this._statesEqual(i,s))for(let t=e+1;t<this.doc.lineCount;t++){const{html:e,endState:s}=this._tokenizeLine(t),i=this._lineStates[t];if(this._lineStates[t]=s,this._lineElements[t]&&(this._lineElements[t].innerHTML=this._getGutterHtml(t)+e),this._updateSymbolsForLine(t),this._statesEqual(i,s))break}}_rebuildLines(){if(this._lineElements.length===this.doc.lineCount)for(let e=0;e<this.doc.lineCount;e++)this._updateLine(e);else this._renderAllLines();this.resize()}_statesEqual(e,t){if(!e)return!1;if(e.stack.length!==t.stack.length)return!1;for(let s=0;s<e.stack.length;s++)if(e.stack[s]!==t.stack[s])return!1;return!0}_updateActiveLine(){const e=this.cursorSet.hasSelection(),t=this.cursorSet.getPrimary().head.line,s=this.cursorSet.getPrimary().head.col;for(let s=0;s<this._lineElements.length;s++)this._lineElements[s].classList.toggle("active-line",!e&&s===t);this._updateDataInfoPanel("@cursor-data",`Ln ${t+1}, Col ${s+1}`)}_renderCursors(){if(this.currentTab){this.cursorsLayer.innerHTML="";for(const e of this.cursorSet.cursors){const t=document.createElement("div");t.className="cursor",t.innerHTML=" ",t.style.left=e.head.col*this.charWidth+this.xPadding+"px",t.style.top=e.head.line*this.lineHeight+"px",this.cursorsLayer.appendChild(t)}this._updateActiveLine()}}_renderSelections(){if(this.currentTab){this.selectionsLayer.innerHTML="";for(const e of this.cursorSet.cursors){if(gt(e))continue;const t=pt(e),s=mt(e);for(let e=t.line;e<=s.line;e++){const i=this.doc.getLine(e),o=e===t.line?t.col:0,n=e===s.line?s.col:i.length;if(o===n)continue;const a=document.createElement("div");a.className="lexcodeselection",a.style.top=e*this.lineHeight+"px",a.style.left=o*this.charWidth+this.xPadding+"px",a.style.width=(n-o)*this.charWidth+"px",this.selectionsLayer.appendChild(a)}}}}_setFocused(e){this._focused=e,e?(this.cursorsLayer.classList.add("show"),this.selectionsLayer.classList.add("show"),this.selectionsLayer.classList.remove("unfocused"),this._startBlinker()):(this.cursorsLayer.classList.remove("show"),this._isSearchBoxActive?this.selectionsLayer.classList.add("show"):this.selectionsLayer.classList.add("unfocused"),this._stopBlinker())}_startBlinker(){this._stopBlinker(),this._cursorVisible=!0,this._setCursorVisibility(!0),this._blinkerInterval=setInterval(()=>{this._cursorVisible=!this._cursorVisible,this._setCursorVisibility(this._cursorVisible)},this._cursorBlinkRate)}_stopBlinker(){null!==this._blinkerInterval&&(clearInterval(this._blinkerInterval),this._blinkerInterval=null)}_resetBlinker(){this._focused&&this._startBlinker()}_setCursorVisibility(e){const t=this.cursorsLayer.querySelectorAll(".cursor");for(const s of t)s.style.opacity=e?"0.6":"0"}_onKeyDown(e){if(!this.currentTab)return;if(this._composing||"Dead"===e.key)return;if(["Control","Shift","Alt","Meta"].includes(e.key))return;const t=e.ctrlKey||e.metaKey,s=e.shiftKey,i=e.altKey;if(this._keyChain){const s=this._keyChain;if(this._keyChain=null,e.preventDefault(),t&&"k"===s)switch(e.key.toLowerCase()){case"c":return void this._commentLines();case"u":return void this._uncommentLines()}return}if(t)switch(e.key.toLowerCase()){case"a":return e.preventDefault(),this.cursorSet.selectAll(this.doc),void this._afterCursorMove();case"d":return e.preventDefault(),void this._doFindNextOcurrence();case"f":return e.preventDefault(),void this._doOpenSearch();case"g":return e.preventDefault(),void this._doOpenLineSearch();case"k":return e.preventDefault(),void(this._keyChain="k");case"s":return e.preventDefault(),void(this.onSave&&this.onSave(this.getText(),this));case"z":return e.preventDefault(),void(s?this._doRedo():this._doUndo());case"y":return e.preventDefault(),void this._doRedo();case"c":return e.preventDefault(),void this._doCopy();case"x":return e.preventDefault(),void this._doCut();case"v":return e.preventDefault(),void this._doPaste();case" ":return e.preventDefault(),void(this.onCtrlSpace&&this.onCtrlSpace(this.getText(),this))}switch(e.key){case"ArrowLeft":return e.preventDefault(),this._wasPaired=!1,t?this.cursorSet.moveWordLeft(this.doc,s):this.cursorSet.moveLeft(this.doc,s),void this._afterCursorMove();case"ArrowRight":return e.preventDefault(),this._wasPaired=!1,t?this.cursorSet.moveWordRight(this.doc,s):this.cursorSet.moveRight(this.doc,s),void this._afterCursorMove();case"ArrowUp":if(e.preventDefault(),this._isAutoCompleteActive){const e=this.autocomplete.childNodes;return e[this._selectedAutocompleteIndex]?.classList.remove("selected"),this._selectedAutocompleteIndex=(this._selectedAutocompleteIndex-1+e.length)%e.length,e[this._selectedAutocompleteIndex]?.classList.add("selected"),void e[this._selectedAutocompleteIndex]?.scrollIntoView({block:"nearest"})}return this._wasPaired=!1,i&&s?void this._duplicateLine(-1):i?void this._swapLine(-1):(this.cursorSet.moveUp(this.doc,s),void this._afterCursorMove());case"ArrowDown":if(e.preventDefault(),this._isAutoCompleteActive){const e=this.autocomplete.childNodes;return e[this._selectedAutocompleteIndex]?.classList.remove("selected"),this._selectedAutocompleteIndex=(this._selectedAutocompleteIndex+1)%e.length,e[this._selectedAutocompleteIndex]?.classList.add("selected"),void e[this._selectedAutocompleteIndex]?.scrollIntoView({block:"nearest"})}return this._wasPaired=!1,i&&s?void this._duplicateLine(1):i?void this._swapLine(1):(this.cursorSet.moveDown(this.doc,s),void this._afterCursorMove());case"Home":return e.preventDefault(),this._wasPaired=!1,this.cursorSet.moveToLineStart(this.doc,s),void this._afterCursorMove();case"End":return e.preventDefault(),this._wasPaired=!1,this.cursorSet.moveToLineEnd(this.doc,s),void this._afterCursorMove();case"Escape":if(e.preventDefault(),this._isAutoCompleteActive)return void this._doHideAutocomplete();if(this._doHideSearch())return;this.cursorSet.removeSecondaryCursors();const o=this.cursorSet.getPrimary().head;return this.cursorSet.set(o.line,o.col),void this._afterCursorMove()}switch(e.key){case"Backspace":return e.preventDefault(),void this._doBackspace(t);case"Delete":return e.preventDefault(),void this._doDelete(t);case"Enter":return e.preventDefault(),void this._doEnter(t);case"Tab":return e.preventDefault(),void this._doTab(s)}1!==e.key.length||t||(e.preventDefault(),this._doInsertChar(e.key))}_flushIfActionChanged(e){this._lastAction!==e&&(this.undoManager.flush(this.cursorSet.getCursorPositions()),this._lastAction=e)}_flushAction(){this.undoManager.flush(this.cursorSet.getCursorPositions()),this._lastAction=""}_doInsertChar(e){if(e in bt.PAIR_KEYS&&this.cursorSet.hasSelection())return void this._encloseSelection(e,bt.PAIR_KEYS[e]);this._flushIfActionChanged("insert"),this._deleteSelectionIfAny();const t=new Set;let s=!1;for(const i of this.cursorSet.sortedIndicesBottomUp()){const o=this.cursorSet.cursors[i],{line:n,col:a}=o.head,r=this.doc.getCharAt(n,a);if(this._wasPaired&&r===e){o.head={line:n,col:a+1},o.anchor={...o.head};continue}const l=this.doc.insert(n,a,e);this.undoManager.record(l,this.cursorSet.getCursorPositions());const c=e in bt.PAIR_KEYS&&(!r||/\s/.test(r)),h=c?2:1;if(c){const t=this.doc.insert(n,a+1,bt.PAIR_KEYS[e]);this.undoManager.record(t,this.cursorSet.getCursorPositions()),s=!0}o.head={line:n,col:a+1},o.anchor={...o.head},this.cursorSet.adjustOthers(i,n,a,h),t.add(n)}this._wasPaired=s;for(const e of t)this._updateLine(e);this._afterCursorMove(),/[\w$]/.test(e)?this._doOpenAutocomplete():this._doHideAutocomplete()}_getAffectedLines(){const e=this.cursorSet.getPrimary(),t=e.anchor.line,s=e.head.line;return t<=s?[t,s]:[s,t]}_commentLines(){const e=this.language.lineComment;if(!e)return;const[t,s]=this._getAffectedLines(),i=e+" ";let o=1/0;for(let e=t;e<=s;e++){0!==this.doc.getLine(e).trim().length&&(o=Math.min(o,this.doc.getIndent(e)))}o===1/0&&(o=0),this._flushAction();for(let e=t;e<=s;e++){if(0===this.doc.getLine(e).trim().length)continue;const t=this.doc.insert(e,o,i);this.undoManager.record(t,this.cursorSet.getCursorPositions()),this._updateLine(e)}this._afterCursorMove()}_uncommentLines(){const e=this.language.lineComment;if(!e)return;const[t,s]=this._getAffectedLines();this._flushAction();for(let i=t;i<=s;i++){const t=this.doc.getLine(i),s=this.doc.getIndent(i),o=t.substring(s);if(o.startsWith(e+" ")){const t=this.doc.delete(i,s,e.length+1);this.undoManager.record(t,this.cursorSet.getCursorPositions())}else if(o.startsWith(e)){const t=this.doc.delete(i,s,e.length);this.undoManager.record(t,this.cursorSet.getCursorPositions())}}this._rebuildLines(),this._afterCursorMove()}_doFindNextOcurrence(){const e=this.cursorSet.getPrimary();let t=this.cursorSet.getSelectedText(this.doc);if(!t){const{line:t,col:s}=e.head,[i,o,n]=this.doc.getWordAt(t,s);if(!i)return;return e.anchor={line:t,col:o},e.head={line:t,col:n},this._renderCursors(),void this._renderSelections()}const s=this.cursorSet.cursors[this.cursorSet.cursors.length-1],i=ut(s.anchor,s.head)?s.head:s.anchor,o=this.doc.findNext(t,i.line,i.col);if(!o)return;this.cursorSet.cursors.some(e=>{const t=ut(e.anchor,e.head)?e.anchor:e.head;return t.line===o.line&&t.col===o.col})||(this.cursorSet.cursors.push({anchor:{line:o.line,col:o.col},head:{line:o.line,col:o.col+t.length}}),this._renderCursors(),this._renderSelections(),this._scrollCursorIntoView())}_doOpenSearch(t=!1){if(!this.searchBox)return;this._doHideSearch(),e.LX.addClass(this.searchBox,"opened"),this._isSearchBoxActive=!0;const s=this.searchBox.querySelector("input");s&&(t?s.value="":this.cursorSet.hasSelection()&&(s.value=this.cursorSet.getSelectedText(this.doc)),s.selectionStart=0,s.selectionEnd=s.value.length,s.focus())}_doOpenLineSearch(){if(!this.searchLineBox)return;this._doHideSearch(),e.LX.emitSignal("@line-number-range",`Type a line number to go to (from 1 to ${this.doc.lineCount}).`),e.LX.addClass(this.searchLineBox,"opened"),this._isSearchLineBoxActive=!0;const t=this.searchLineBox.querySelector("input");t&&(t.value=":",t.focus())}_doHideSearch(){if(!this.searchBox||!this.searchLineBox)return!1;const e=this._isSearchBoxActive,t=this._isSearchLineBoxActive;return e?(this.searchBox.classList.remove("opened"),this._isSearchBoxActive=!1,this._lastSearchPos=null):t&&(this.searchLineBox.classList.remove("opened"),this._isSearchLineBoxActive=!1),e!=this._isSearchBoxActive||t!=this._isSearchLineBoxActive}_doSearch(e,t=!1,s,i=!0,o=!0){if(!(e=e??this._lastTextFound))return;const n=this.doc;let a,r;if(this._lastSearchPos)a=this._lastSearchPos.line,r=this._lastSearchPos.col+(t?-e.length:e.length);else{const e=this.cursorSet.getPrimary();a=e.head.line,r=e.head.col}const l=(s,i)=>{let o=n.getLine(s),a=e;if(this._searchMatchCase||(o=o.toLowerCase(),a=a.toLowerCase()),t){return o.substring(0,i).lastIndexOf(a)}return o.indexOf(a,i)};let c=-1,h=-1;if(t){for(let e=a;e>=0;e--){const t=l(e,e===a?r:n.getLine(e).length);if(t>-1){c=e,h=t;break}}if(-1===c)for(let e=n.lineCount-1;e>a;e--){const t=l(e,n.getLine(e).length);if(t>-1){c=e,h=t;break}}}else{for(let e=a;e<n.lineCount;e++){const t=l(e,e===a?r:0);if(t>-1){c=e,h=t;break}}if(-1===c)for(let e=0;e<a;e++){const t=l(e,0);if(t>-1){c=e,h=t;break}}}if(-1===c)return i||alert("No results!"),void(this._lastSearchPos=null);if(this._lastTextFound=e,this._lastSearchPos={line:c,col:h},s)s(h,c);else{const t=this.cursorSet.getPrimary();t.anchor={line:c,col:h},t.head={line:c,col:h+e.length},this._renderCursors(),this._renderSelections()}if(this.codeScroller.scrollTop=Math.max((c-10)*this.lineHeight,0),this.codeScroller.scrollLeft=Math.max(h*this.charWidth-this.codeScroller.clientWidth/2,0),o){const e=this.searchBox?.querySelector("input");e?.focus()}}_doGotoLine(e){Number.isNaN(e)||e<1||e>this.doc.lineCount||(this.cursorSet.set(e-1,0),this._afterCursorMove())}_encloseSelection(e,t){const s=this.cursorSet.getPrimary(),i=s.anchor,o=s.head,n=i.line<o.line||i.line===o.line&&i.col<o.col?i:o,a=n===i?o:i;if(n.line!==a.line)return;const r=n.line,l=n.col,c=a.col;this._flushAction();const h=this.doc.insert(r,l,e);this.undoManager.record(h,this.cursorSet.getCursorPositions());const d=this.doc.insert(r,c+1,t);this.undoManager.record(d,this.cursorSet.getCursorPositions()),s.anchor={line:r,col:l+1},s.head={line:r,col:c+1},this._updateLine(r),this._afterCursorMove()}_doBackspace(e){if(this._flushIfActionChanged("backspace"),this.cursorSet.hasSelection())return this._deleteSelectionIfAny(),this._rebuildLines(),void this._afterCursorMove();for(const t of this.cursorSet.sortedIndicesBottomUp()){const s=this.cursorSet.cursors[t],{line:i,col:o}=s.head;if(0!==i||0!==o)if(0===o){const e=this.doc.getLine(i-1).length,o=this.doc.delete(i-1,e,1);this.undoManager.record(o,this.cursorSet.getCursorPositions()),s.head={line:i-1,col:e},s.anchor={...s.head},this.cursorSet.adjustOthers(t,i,0,e,-1)}else if(e){const[e,n]=this.doc.getWordAt(i,o-1),a=e.length>0?n:o-1,r=o-a,l=this.doc.delete(i,a,r);this.undoManager.record(l,this.cursorSet.getCursorPositions()),s.head={line:i,col:a},s.anchor={...s.head},this.cursorSet.adjustOthers(t,i,o,-r)}else{const e=this.doc.delete(i,o-1,1);this.undoManager.record(e,this.cursorSet.getCursorPositions()),s.head={line:i,col:o-1},s.anchor={...s.head},this.cursorSet.adjustOthers(t,i,o,-1)}}this._rebuildLines(),this._afterCursorMove(),this._doOpenAutocomplete()}_doDelete(e){if(this.cursorSet.hasSelection())return this._deleteSelectionIfAny(),this._rebuildLines(),void this._afterCursorMove();this._flushIfActionChanged("delete");for(const t of this.cursorSet.sortedIndicesBottomUp()){const s=this.cursorSet.cursors[t],{line:i,col:o}=s.head,n=this.doc.getLine(i);if(!(o>=n.length&&i>=this.doc.lineCount-1))if(o>=n.length){const e=this.doc.delete(i,o,1);this.undoManager.record(e,this.cursorSet.getCursorPositions()),this.cursorSet.adjustOthers(t,i,o,0,-1)}else if(e){const[e,,s]=this.doc.getWordAt(i,o),n=e.length>0?s-o:1,a=this.doc.delete(i,o,n);this.undoManager.record(a,this.cursorSet.getCursorPositions()),this.cursorSet.adjustOthers(t,i,o,-n)}else{const e=this.doc.delete(i,o,1);this.undoManager.record(e,this.cursorSet.getCursorPositions()),this.cursorSet.adjustOthers(t,i,o,-1)}}this._rebuildLines(),this._afterCursorMove()}_doEnter(e){if(this._isAutoCompleteActive)this._doAutocompleteWord();else if(e&&this.onRun)this.onRun(this.getText(),this);else{this._deleteSelectionIfAny(),this._flushAction();for(const e of this.cursorSet.sortedIndicesBottomUp()){const t=this.cursorSet.cursors[e],{line:s,col:i}=t.head,o=this.doc.getIndent(s),n=" ".repeat(o),a=this.doc.insert(s,i,"\n"+n);this.undoManager.record(a,this.cursorSet.getCursorPositions()),t.head={line:s+1,col:o},t.anchor={...t.head},this.cursorSet.adjustOthers(e,s,i,0,1)}this._rebuildLines(),this._afterCursorMove()}}_doTab(e){if(this._isAutoCompleteActive)this._doAutocompleteWord();else{this._flushAction();for(const t of this.cursorSet.sortedIndicesBottomUp()){const s=this.cursorSet.cursors[t],{line:i,col:o}=s.head;if(e){const e=this.doc.getLine(i);let n=0;for(;n<this.tabSize&&n<e.length&&" "===e[n];)n++;if(n>0){const e=this.doc.delete(i,0,n);this.undoManager.record(e,this.cursorSet.getCursorPositions()),s.head={line:i,col:Math.max(0,o-n)},s.anchor={...s.head},this.cursorSet.adjustOthers(t,i,0,-n)}}else{const e=this.tabSize-o%this.tabSize,n=" ".repeat(e),a=this.doc.insert(i,o,n);this.undoManager.record(a,this.cursorSet.getCursorPositions()),s.head={line:i,col:o+e},s.anchor={...s.head},this.cursorSet.adjustOthers(t,i,o,e)}}this._rebuildLines(),this._afterCursorMove()}}_deleteSelectionIfAny(){let e=!1;for(const t of this.cursorSet.sortedIndicesBottomUp()){const s=this.cursorSet.cursors[t];if(gt(s))continue;const i=pt(s),o=mt(s),n=this.cursorSet.getSelectedText(this.doc,t);if(!n)continue;const a=o.line-i.line,r=0===a?o.col-i.col:i.col,l=this.doc.delete(i.line,i.col,n.length);this.undoManager.record(l,this.cursorSet.getCursorPositions()),s.head={...i},s.anchor={...i},this.cursorSet.adjustOthers(t,i.line,i.col,-r,-a),e=!0}e&&this._rebuildLines()}_doCopy(){const e=this.cursorSet.getSelectedText(this.doc);e&&navigator.clipboard.writeText(e)}_doCut(){this._flushAction();const e=this.cursorSet.getSelectedText(this.doc);if(e)navigator.clipboard.writeText(e),this._deleteSelectionIfAny();else{const e=this.cursorSet.getPrimary(),t=e.head.line,s=this.doc.getLine(t),i=t===this.doc.lineCount-1;navigator.clipboard.writeText(s+(i?"":"\n"));const o=this.doc.removeLine(t);this.undoManager.record(o,this.cursorSet.getCursorPositions());const n=Math.min(t,this.doc.lineCount-1);e.head={line:n,col:0},e.anchor={...e.head}}this._rebuildLines(),this._afterCursorMove()}_swapLine(e){const t=this.cursorSet.getPrimary(),s=t.head.line,i=s+e;if(i<0||i>=this.doc.lineCount)return;const o=this.doc.getLine(s),n=this.doc.getLine(i);this._flushAction();const a=this.doc.replaceLine(s,n);this.undoManager.record(a,this.cursorSet.getCursorPositions());const r=this.doc.replaceLine(i,o);this.undoManager.record(r,this.cursorSet.getCursorPositions()),t.head={line:i,col:t.head.col},t.anchor={...t.head},this._rebuildLines(),this._afterCursorMove()}_duplicateLine(e){const t=this.cursorSet.getPrimary(),s=t.head.line,i=this.doc.getLine(s);this._flushAction();const o=this.doc.insertLine(s,i);this.undoManager.record(o,this.cursorSet.getCursorPositions());const n=1===e?s+1:s;t.head={line:n,col:t.head.col},t.anchor={...t.head},this._rebuildLines(),this._afterCursorMove()}async _doPaste(){const e=await navigator.clipboard.readText();if(!e)return;this._flushAction(),this._deleteSelectionIfAny();const t=this.cursorSet.getPrimary(),s=this.doc.insert(t.head.line,t.head.col,e);this.undoManager.record(s,this.cursorSet.getCursorPositions());const i=e.split("\n");1===i.length?this.cursorSet.set(t.head.line,t.head.col+e.length):this.cursorSet.set(t.head.line+i.length-1,i[i.length-1].length),this._rebuildLines(),this._afterCursorMove()}_doUndo(){const e=this.undoManager.undo(this.doc,this.cursorSet.getCursorPositions());if(e){if(e.cursors.length>0){const t=e.cursors[0];this.cursorSet.set(t.line,t.col)}this._rebuildLines(),this._afterCursorMove()}}_doRedo(){const e=this.undoManager.redo(this.doc);if(e){if(e.cursors.length>0){const t=e.cursors[0];this.cursorSet.set(t.line,t.col)}this._rebuildLines(),this._afterCursorMove()}}_onMouseDown(t){if(!this.currentTab)return;if(this.searchBox&&this.searchBox.contains(t.target))return;if(this.autocomplete&&this.autocomplete.contains(t.target))return;t.preventDefault(),this._wasPaired=!1;const s=this.codeContainer.getBoundingClientRect(),i=t.clientX-s.left-this.xPadding,o=t.clientY-s.top,n=e.LX.clamp(Math.floor(o/this.lineHeight),0,this.doc.lineCount-1),a=e.LX.clamp(Math.round(i/this.charWidth),0,this.doc.getLine(n).length);if("contextmenu"===t.type)return void this._onContextMenu(t,n,a);if(0!==t.button)return;const r=Date.now();if(r-this._lastClickTime<400&&n===this._lastClickLine?this._clickCount=Math.min(this._clickCount+1,3):this._clickCount=1,this._lastClickTime=r,this._lastClickLine=n,3===this._clickCount){const e=this.cursorSet.getPrimary();e.anchor={line:n,col:0},e.head={line:n,col:this.doc.getLine(n).length}}else if(2===this._clickCount){const[,e,t]=this.doc.getWordAt(n,a),s=this.cursorSet.getPrimary();s.anchor={line:n,col:e},s.head={line:n,col:t}}else if(t.shiftKey){this.cursorSet.getPrimary().head={line:n,col:a}}else this.cursorSet.set(n,a);this._afterCursorMove(),this._inputArea.focus();const l=e=>{const t=e.clientX-s.left-this.xPadding,i=e.clientY-s.top,o=Math.max(0,Math.min(Math.floor(i/this.lineHeight),this.doc.lineCount-1)),n=Math.max(0,Math.min(Math.round(t/this.charWidth),this.doc.getLine(o).length));this.cursorSet.getPrimary().head={line:o,col:n},this._renderCursors(),this._renderSelections()},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}_onContextMenu(t,s,i){t.preventDefault();const o=[{name:"Copy",icon:"Copy",callback:()=>this._doCopy(),kbd:["Ctrl","C"],useKbdSpecialKeys:!1}];if(this.disableEdition||(o.push({name:"Cut",icon:"Scissors",callback:()=>this._doCut(),kbd:["Ctrl","X"],useKbdSpecialKeys:!1}),o.push({name:"Paste",icon:"Paste",callback:()=>this._doPaste(),kbd:["Ctrl","V"],useKbdSpecialKeys:!1})),this.onContextMenu){const e=this.cursorSet.getSelectedText(this.doc),s=this.onContextMenu(this,e,t);if(s?.length){o.push(null);for(const e of s)o.push({name:e.path,disabled:e.disabled,callback:e.callback})}}e.LX.addDropdownMenu(t.target,o,{event:t,side:"bottom",align:"start"})}_getWordAtCursor(){const e=this.cursorSet.getPrimary().head,t=this.doc.getLine(e.line);let s=e.col,i=e.col;for(;s>0&&/[\w$]/.test(t[s-1]);)s--;for(;i<t.length&&/[\w$]/.test(t[i]);)i++;return{word:t.slice(s,i),start:s,end:i}}_doOpenAutocomplete(){if(!this.autocomplete||!this.useAutoComplete)return;this.autocomplete.innerHTML="";const{word:t}=this._getWordAtCursor();if(!t||0===t.length)return void this._doHideAutocomplete();const s=[],i=new Set,o=(e,t,o,n)=>{i.has(e)||(s.push({label:e,kind:t,scope:o,detail:n}),i.add(e))},n=this.symbolTable.getAllSymbols();for(const e of n)e.name.toLowerCase().startsWith(t.toLowerCase())&&o(e.name,e.kind,e.scope,`${e.kind} in ${e.scope}`);for(const e of this.language.reservedWords)e.toLowerCase().startsWith(t.toLowerCase())&&o(e);for(const e of this.customSuggestions){const s="string"==typeof e?e:e.label,i="object"==typeof e?e.kind:void 0,n="object"==typeof e?e.detail:void 0;s.toLowerCase().startsWith(t.toLowerCase())&&o(s,i,void 0,n)}if(0===s.length)return void this._doHideAutocomplete();s.sort((e,s)=>{const i=e.label.toLowerCase()===t.toLowerCase()?0:1,o=s.label.toLowerCase()===t.toLowerCase()?0:1;return i!==o?i-o:e.label.localeCompare(s.label)}),this._selectedAutocompleteIndex=0,s.forEach((s,i)=>{const o=document.createElement("pre");i===this._selectedAutocompleteIndex&&o.classList.add("selected");const n=s.label;let a="CaseLower",r="foo";switch(s.kind){case"class":a="CircleNodes",r="text-orange-500";break;case"struct":a="Form",r="text-orange-400";break;case"interface":a="FileType",r="text-cyan-500";break;case"enum":a="ListTree",r="text-yellow-500";break;case"enum-value":a="Dot",r="text-yellow-400";break;case"type":a="Type",r="text-teal-500";break;case"function":a="Function",r="text-purple-500";break;case"method":a="Box",r="text-fuchsia-500";break;case"variable":a="Cuboid",r="text-blue-400";break;case"property":a="Layers",r="text-blue-300";break;case"constructor-call":a="Hammer",r="text-green-500";break;case"method-call":a="PlayCircle",r="text-gray-400";break;default:a="CaseLower",r="text-gray-500"}o.appendChild(e.LX.makeIcon(a,{iconClass:"ml-1 mr-2",svgClass:"sm "+r}));const l=n.toLowerCase().indexOf(t.toLowerCase());var c=document.createElement("span");c.textContent=n.substring(0,l),o.appendChild(c);var h=document.createElement("span");h.textContent=n.substring(l,l+t.length),h.classList.add("word-highlight"),o.appendChild(h);var d=document.createElement("span");if(d.textContent=n.substring(l+t.length),o.appendChild(d),s.kind){const e=document.createElement("span");e.textContent=` (${s.kind})`,e.className="kind text-muted-foreground text-xs! ml-2",o.appendChild(e)}o.addEventListener("click",()=>{this._doAutocompleteWord()}),this.autocomplete.appendChild(o)}),this._isAutoCompleteActive=!0;const a=e=>{this.autocomplete?.contains(e.target)||this._doHideAutocomplete()};setTimeout(()=>document.addEventListener("click",a,{once:!0}),0),this.autocomplete._cleanup=()=>{document.removeEventListener("click",a)},this.autocomplete.classList.toggle("show",!0),this.autocomplete.classList.toggle("no-scrollbar",!(this.autocomplete.scrollHeight>this.autocomplete.offsetHeight));const r=this.cursorSet.getPrimary().head,l=r.col*this.charWidth+this.xPadding,c=(r.line+1)*this.lineHeight+this._cachedTabsHeight-this.codeScroller.scrollTop;this.autocomplete.style.left=l+"px",this.autocomplete.style.top=c+"px"}_doHideAutocomplete(){this.autocomplete&&this._isAutoCompleteActive&&(this.autocomplete.innerHTML="",this.autocomplete.classList.remove("show"),this._isAutoCompleteActive=!1,this.autocomplete._cleanup&&(this.autocomplete._cleanup(),delete this.autocomplete._cleanup))}_doAutocompleteWord(){const e=this._getSelectedAutoCompleteWord();if(!e)return;const t=this.cursorSet.getPrimary().head,{start:s,end:i}=this._getWordAtCursor(),o=t.line,n=this.cursorSet.getCursorPositions();if(i>s){const e=this.doc.delete(o,s,i-s);this.undoManager.record(e,n)}const a=this.doc.insert(o,s,e);this.cursorSet.set(o,s+e.length);const r=this.cursorSet.getCursorPositions();this.undoManager.record(a,r),this._rebuildLines(),this._afterCursorMove(),this._doHideAutocomplete()}_getSelectedAutoCompleteWord(){if(!this.autocomplete||!this._isAutoCompleteActive)return null;const e=this.autocomplete.childNodes[this._selectedAutocompleteIndex];var t="";for(let s of e.childNodes){const e=s;e.constructor!=HTMLSpanElement||e.classList.contains("kind")||(t+=e.textContent)}return t}_afterCursorMove(){this._renderCursors(),this._renderSelections(),this._resetBlinker(),this.resize(),this._scrollCursorIntoView()}_scrollCursorIntoView(){const e=this.cursorSet.getPrimary().head,t=e.line*this.lineHeight,s=e.col*this.charWidth;t<this.codeScroller.scrollTop?this.codeScroller.scrollTop=t:t+this.lineHeight>this.codeScroller.scrollTop+this.codeScroller.clientHeight&&(this.codeScroller.scrollTop=t+this.lineHeight-this.codeScroller.clientHeight);const i=2*Lt.SIZE;s<this.codeScroller.scrollLeft?this.codeScroller.scrollLeft=s:s+i>this.codeScroller.scrollLeft+this.codeScroller.clientWidth-this.xPadding&&(this.codeScroller.scrollLeft=s+i-this.codeScroller.clientWidth+this.xPadding)}_resetGutter(){const e=this._cachedTabsHeight||(this.tabs?.root.getBoundingClientRect().height??0);this.lineGutter.style.height=`calc(100% - ${e}px)`}getMaxLineLength(){if(!this.currentTab)return 0;let e=0;for(let t=0;t<this.doc.lineCount;t++){const s=this.doc.getLine(t).length;s>e&&(e=s)}return e}resize(e=!1){if(!this.charWidth)return;this._cachedTabsHeight=this.tabs?.root.getBoundingClientRect().height??0,this._cachedStatusPanelHeight=this.statusPanel?.root.getBoundingClientRect().height??0;const t=this.getMaxLineLength(),s=this.currentTab?this.doc.lineCount:0,i=Math.floor((this.codeScroller.clientWidth-this.xPadding)/this.charWidth),o=Math.floor(this.codeScroller.clientHeight/this.lineHeight);let n=t!==this._lastMaxLineLength&&(t>=i||this._lastMaxLineLength>=i),a=s!==this._lastLineCount&&(s>=o||this._lastLineCount>=o);n=n||t<i&&this.hScrollbar?.visible,a=a||s<o&&this.vScrollbar?.visible,(e||n||a)&&(this._lastMaxLineLength=t,this._lastLineCount=s,(e||n)&&(this.codeSizer.style.minWidth=t*this.charWidth+this.xPadding+2*Lt.SIZE+"px"),(e||a)&&(this.codeSizer.style.minHeight=s*this.lineHeight+2*Lt.SIZE+"px"),this._resetGutter(),setTimeout(()=>this._resizeScrollBars(),10))}_resizeScrollBars(){if(!this.vScrollbar)return;const e=this._cachedTabsHeight,t=this._cachedStatusPanelHeight,s=this.codeScroller.scrollHeight;this.vScrollbar.setThumbRatio(s>0?this.codeScroller.clientHeight/s:1),this.vScrollbar.root.style.top=e+"px",this.vScrollbar.root.style.height=`calc(100% - ${e+t}px)`;const i=this.codeScroller.scrollWidth;this.hScrollbar.setThumbRatio(i>0?this.codeScroller.clientWidth/i:1),this.hScrollbar.root.style.bottom=t+"px",this.hScrollbar.root.style.width=`calc(100% - ${this.xPadding+(this.vScrollbar.visible?Lt.SIZE:0)}px)`}_syncScrollBars(){this.vScrollbar&&(this.vScrollbar.syncToScroll(this.codeScroller.scrollTop,this.codeScroller.scrollHeight-this.codeScroller.clientHeight),this.hScrollbar.syncToScroll(this.codeScroller.scrollLeft,this.codeScroller.scrollWidth-this.codeScroller.clientWidth))}_doLoadFromFile(){const t=e.LX.makeElement("input","","",document.body);t.type="file",t.click(),t.addEventListener("change",e=>{const s=e.target;s.files&&s.files[0]&&this.loadFile(s.files[0]),t.remove()})}async _setFontSize(t,s=!0){this.fontSize=t;const i=document.querySelector(":root");i.style.setProperty("--code-editor-font-size",`${this.fontSize}px`),window.localStorage.setItem("lexcodeeditor-font-size",`${this.fontSize}`),await this._measureChar();const o=this.fontSize+6;i.style.setProperty("--code-editor-row-height",`${o}px`),this.lineHeight=o,s&&(this._rebuildLines(),this._afterCursorMove()),e.LX.emitSignal("@font-size",this.fontSize)}_applyFontSizeOffset(t=0){const s=e.LX.clamp(this.fontSize+t,bt.CODE_MIN_FONT_SIZE,bt.CODE_MAX_FONT_SIZE);this._setFontSize(s)}_increaseFontSize(){this._applyFontSizeOffset(1)}_decreaseFontSize(){this._applyFontSizeOffset(-1)}}if(e.LX.CodeEditor=bt,e.LX.init=async function(t={}){if(this.ready)return this.mainArea;await e.LX.loadScriptSync("https://unpkg.com/lucide@latest"),console.log(`LexGUI v${this.version}`);const s=e.LX.makeElement("div",e.LX.mergeClass("lexcontainer",t.rootClass));function i(e){e.preventDefault(),e.stopPropagation()}s.id="lexroot",s.tabIndex=-1,this.modal=e.LX.makeElement("div","inset-0 hidden-opacity bg-black/50 fixed z-100 transition-opacity duration-100 ease-in"),this.modal.id="modal",this.modal.toggle=function(e){this.classList.toggle("hidden-opacity",e)},this.modal.addEventListener("wheel",i,{passive:!1}),this.modal.addEventListener("touchmove",i,{passive:!1}),this.root=s,this.container=document.body,t.container&&(this.container=t.container.constructor===String?document.getElementById(t.container):t.container),this.layoutMode=t.layoutMode??"app",document.documentElement.setAttribute("data-layout",this.layoutMode),this.layoutMode,this.spacingMode=t.spacingMode??"default",document.documentElement.setAttribute("data-spacing",this.spacingMode),this.container.appendChild(this.modal),t.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="fixed flex flex-col-reverse m-0 p-0 gap-1 z-1000",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),t.skipRoot||t.skipDefaultArea||(this.mainArea=new te({id:t.id??"mainarea"})),this._onChangeSystemTheme=function(t){localStorage.getItem("lxColorScheme")||e.LX.setMode(t.matches?"dark":"light",!1)},this._mqlPrefersDarkScheme=window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)"):null;const o=localStorage.getItem("lxColorScheme");return o?e.LX.setMode(o):this._mqlPrefersDarkScheme&&(t.autoTheme??1)&&(window.matchMedia("(prefers-color-scheme: light)").matches&&e.LX.setMode("light",!1),this._mqlPrefersDarkScheme.addEventListener("change",this._onChangeSystemTheme)),this.mainArea},e.LX.setSpacingMode=function(e){this.spacingMode=e,document.documentElement.setAttribute("data-spacing",this.spacingMode)},e.LX.setLayoutMode=function(e){this.layoutMode=e,document.documentElement.setAttribute("data-layout",this.layoutMode)},e.LX.addSignal=function(t,s,i){s[t]=i,e.LX.signals[t]||(e.LX.signals[t]=[]),e.LX.signals[t].indexOf(s)>-1||e.LX.signals[t].push(s)},e.LX.removeSignal=function(t,s){const i=e.LX.signals[t];if(i)if(s){for(let e=0;e<i.length;++e)if(i[e]==s){i.splice(e,1);break}}else delete e.LX.signals[t]},e.LX.emitSignal=function(t,s,i={}){const o=e.LX.signals[t];if(!o)return;const a=i.target;if(a)a[t]&&a[t].call(a,s);else for(let e of o)if(e instanceof n)e.set(s,i.skipCallback??!0);else if(e.constructor===Function){e(null,s)}else{const i=e[t];console.assert(i,`No callback registered with _${t}_ signal`),i.bind(e)(s)}},e.LX._createCommandbar=function(t){let s=document.createElement("dialog");s.className="commandbar absolute border-color rounded-lg m-0",s.tabIndex=-1,t.appendChild(s);let i=[],o=null;s.addEventListener("keydown",function(e){if(e.stopPropagation(),e.stopImmediatePropagation(),o=o??-1,"Escape"==e.key)s.close(),d(!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)-l.offsetHeight;t>0&&l.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(t){t.relatedTarget!=t.currentTarget&&(t.stopPropagation(),t.stopImmediatePropagation(),e.LX.setCommandbarState(!1),d(!0))}),t.addEventListener("keydown",t=>{if(" "==t.key&&t.ctrlKey)t.stopImmediatePropagation(),t.stopPropagation(),e.LX.setCommandbarState(!0);else for(let s of e.LX.extensions){if(!e.LX[s]||!e.LX[s].prototype.onKeyPressed)continue;const i=e.LX.CodeEditor.getInstances();for(let e of i)e.onKeyPressed(t)}});const n=e.LX.makeContainer(["100%","auto"],"flex flex-row"),a=new h(null,"",e=>{s._addElements(e.toLowerCase())},{width:"100%",icon:"Search",trigger:"input",placeholder:"Search..."});n.appendChild(a.root);const r=new te({width:"100%",skipAppend:!0,className:"cb-tabs"});{const e=(e,t)=>{};r.addTabs({parentClass:"p-2"}).add("All",document.createElement("div"),{selected:!0,onSelect:e})}const l=e.LX.makeElement("div","searchitembox overflow-y-scroll basis-full scrollbar-hidden");let c=null;const d=e=>{l.innerHTML="",i.length=0,o=null,e&&a.set("",!0)},u=function(t,s){if(!s?.length)return!1;return e.LX.stripTags(t).toLowerCase().includes(s.toLowerCase())},p=(t,n,a)=>{if(!t||t.constructor!=Object)return;t.callback&&((t,n,a,r)=>{if(!t.length)return;c&&c.classList.remove("last");let h=document.createElement("div");if(h.className="searchitem last",void 0!==r?.checked){const s=r.checked?e.LX.makeIcon("Check").innerHTML:"";h.innerHTML=s+(a+t)}else h.innerHTML=a+t;h.callback=n,h.item=r,h.addEventListener("click",s=>{null!=r.checked&&(r.checked=!r.checked),n.call(window,t,r.checked),e.LX.setCommandbarState(!1),d(!0)}),h.addEventListener("mouseenter",function(e){s.querySelectorAll(".hovered").forEach(e=>e.classList.remove("hovered")),h.classList.add("hovered"),o=i.indexOf(h)}),h.addEventListener("mouseleave",function(e){h.classList.remove("hovered")}),i.push(h),l.appendChild(h),c=h})(t.name,t.callback,n,t);const r=t.submenu??t[t.name];if(!r)return;const h=e.LX.makeIcon("ChevronRight",{svgClass:"sm text-muted-foreground separator"});n+=t.name+h.innerHTML;for(let e of r)p(e,n)};return s._addElements=t=>{d();let s=function(t){const s=[];for(let i of e.LX.menubars)for(let e of i.items)u(e.name,t)&&s.push(e);for(let i of e.LX.sidebars)for(let e of i.items)u(e.name,t)&&s.push(e);for(let i of e.LX.extraCommandbarEntries)u(i.name,t)&&s.push(i);if(e.LX.has("CodeEditor")){const i=e.LX.CodeEditor.getInstances();if(!i.length||!i[0].area.root.offsetHeight)return s;for(let o of e.LX.Tokenizer.getRegisteredLanguages()){const n=xe.getLanguage(o);if(!n)continue;const a="Language: "+o,r=n?.icon,l=(e=>{const t=e.constructor===String?e:Object.values(e)[0];return e?t.split(" "):[]})(r);let c=e.LX.makeIcon(l[0],{svgClass:`${l.slice(1).join(" ")}`}).innerHTML;c+=a+" <span class='lang-ext'>("+n.extensions+")</span>",u(a,t)&&s.push({name:c,callback:()=>{for(let e of i)e.setLanguage(o)}})}}return s}(t);function i(e,t){return e.startsWith(t)?0:e.includes(t)?1:2}s=s.sort((s,o)=>{const n=e.LX.stripTags(s.name),a=e.LX.stripTags(o.name);return i(n,t)-i(a,t)||n.localeCompare(a)}),s=s.slice(0,48);for(let e of s)p(e,"")},s.appendChild(n),s.appendChild(r.root),s.appendChild(l),s},e.LX._registerIconsAndColors=function(t="./"){e.LX.requestJSON(t+"registry/colors.json",t=>{for(const s in t){const i=t[s];Array.isArray(i)&&i.forEach(t=>{const i=`${s}-${t.scale}`,o=`<span class="flex bg-${i} w-3 h-3 rounded-full mr-2"></span>${i}`;e.LX.registerCommandbarEntry(o,()=>{navigator.clipboard.writeText(i),e.LX.toast(`${e.LX.makeIcon("CircleCheck").innerHTML} Copied ${i} to clipboard.`,null,{position:"top-center",timeout:3e3})})})}});const s=window.lucide,i={...e.LX.ICONS,...s.icons};for(const t in i){const s="regular",i=`${e.LX.makeIcon(t,{svgClass:"mr-2 pointer-events-none",variant:s}).innerHTML}${t}`;e.LX.registerCommandbarEntry(i,()=>{navigator.clipboard.writeText(t),e.LX.toast(`${e.LX.makeIcon("CircleCheck").innerHTML} Copied ${t} to clipboard.`,null,{position:"top-center",timeout:3e3})})}},e.LX.setCommandbarState=function(t,s=!0){const i=this.commandbar;e.LX.modal.toggle(!t),t?(i.style.top=`calc(15% + ${document.scrollingElement?.scrollTop??0}px)`,i.show(),i.querySelector("input").focus(),s&&i._addElements(void 0),e.LX.modal.toggle(!1)):i.close()},e.LX.REGISTER_COMPONENT=function(t,s={}){let i=e.LX.guidGenerator();J.prototype["add"+t]=function(a,r,l){const c=Array.from(arguments).slice(3);let h=new n(e.ComponentType.CUSTOM,a,null,s);this._attachComponent(h),h.customName=t,h.customIdx=i,h.onGetValue=()=>r,h.onSetValue=(e,t,s)=>{r=e,g(),d.querySelector(".lexcustomitems").toggleAttribute("hidden",!1),t||h._trigger(new o(a,r,s),l)},h.onResize=()=>{const e=h.root.domName?.style.width??"0px";u.style.width=`calc( 100% - ${e})`};const d=h.root;let u,p,m=s.default??{};const g=()=>{u&&u.remove(),p&&p.remove(),u=document.createElement("div"),u.className="lexcustomcontainer w-full",d.appendChild(u),d.dataset.opened=!1;const i=e.LX.makeIcon(s.icon??"Box"),n=e.LX.makeIcon("Menu");let f=t+(r?"":" [empty]"),C=this.addButton(null,f,(s,i)=>{r?(d.querySelector(".lexcustomitems").toggleAttribute("hidden"),d.dataset.opened=!d.querySelector(".lexcustomitems").hasAttribute("hidden")):e.LX.addContextMenu(null,i,e=>{e.add("New "+t,()=>{r={},g(),d.querySelector(".lexcustomitems").toggleAttribute("hidden",!1),d.dataset.opened=!d.querySelector(".lexcustomitems").hasAttribute("hidden")})})},{buttonClass:"outline custom"});const y=C.root.querySelector("button");if(y.prepend(i),y.appendChild(n),u.appendChild(C.root),r&&n.addEventListener("click",t=>{t.stopImmediatePropagation(),t.stopPropagation(),e.LX.addContextMenu(null,t,e=>{e.add("Clear",()=>{r=null,g()})})}),p=document.createElement("div"),p.className="lexcustomitems",p.toggleAttribute("hidden",!0),d.appendChild(p),r){this.queue(p);const e=(e,t,i)=>{const n=s[`_set_${e}`];n?n.call(r,t):r[e]=t,h._trigger(new o(a,r,i),l)};for(let t in m){let i=null;const o=s[`_get_${t}`];if(i=o?r[t]?o.call(r):o.call(m):r[t]??m[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,...c),this.clearQueue()}};g()}},!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("AssetView");const xt=e.LX.Area;e.LX.Panel,e.LX.NodeTree,e.LX.Tree;class _t{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="";selectedItems=[];allowedTypes;searchValue="";filter="None";gridScale=1;layout=_t.LAYOUT_GRID;sortMode=_t.CONTENT_SORT_ASC;skipBrowser=!1;skipPreview=!1;useNativeTitle=!1;onlyFolders=!0;allowMultipleSelection=!0;allowItemCheck=!1;previewActions=[];contextMenu=[];itemContextMenuOptions=null;_assetsPerPage=24;get assetsPerPage(){return this._assetsPerPage}set assetsPerPage(e){this._setAssetsPerPage(e)}_callbacks={};_lastSortBy="";_paginator;_scriptCodeDialog;_moveItemDialog;_movingItem;constructor(t={}){this.rootPath="https://raw.githubusercontent.com/jxarco/lexgui.js/master/",this.layout=t.layout??this.layout,this.sortMode=t.sortMode??this.sortMode,t.rootPath&&(t.rootPath.constructor!==String?console.warn(`Asset Root Path must be a String (now is a ${t.rootPath.constructor.name})`):this.rootPath=t.rootPath);let s=document.createElement("div");s.className="lexassetbrowser",this.root=s;let i=new xt({width:"100%",height:"100%"});s.appendChild(i.root);let o,n,a=i;if(this.skipBrowser=t.skipBrowser??this.skipBrowser,this.skipPreview=t.skipPreview??this.skipPreview,this.useNativeTitle=t.useNativeTitle??this.useNativeTitle,this.onlyFolders=t.onlyFolders??this.onlyFolders,this.allowMultipleSelection=t.allowMultipleSelection??this.allowMultipleSelection,this.allowItemCheck=t.allowItemCheck??this.allowItemCheck,this.previewActions=t.previewActions??[],this.itemContextMenuOptions=t.itemContextMenuOptions,this.gridScale=t.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"},...t.allowedTypes??{}},this.path=["@"],this.rootItem={id:"/",children:this.data,type:"folder",metadata:{uid:e.LX.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(t){this.prevData.length=0,this.nextData.length=0,this.data=t,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:e.LX.guidGenerator()}}),this._refreshContent()}addItem(t,s,i=!0){const o=this.layout==_t.LAYOUT_LIST,n=this.layout==_t.LAYOUT_GRID,a=t.type.charAt(0).toUpperCase()+t.type.slice(1),r=e.LX.getExtension(t.id),l="Folder"===a,c=this;let h=document.createElement("li");h.className="lexassetitem "+t.type.toLowerCase(),h.tabIndex=-1,e.LX.insertChildAtIndex(this.content,h,s);const d=this.allowedTypes[a]?.color;d&&e.LX.makeElement("span",`rounded-full w-2 h-2 z-100 flex absolute ml-2 mt-2 bg-${d}`,"",h);const u=t.metadata;if(u.uid||(u.uid=e.LX.guidGenerator()),u.lastModified&&!u.lastModifiedDate&&(u.lastModifiedDate=this._lastModifiedToStringDate(u.lastModified)),this.useNativeTitle)h.title=a+": "+t.id;else{let i=document.createElement("span");i.className="lexitemdesc",i.id=e.LX.getSupportedDOMName(`floatingTitle_${u.uid}`),i.innerHTML=`File: ${t.id}<br>Type: ${a}`,e.LX.insertChildAtIndex(this.content,i,void 0!==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 r=o.x+e.offsetX,l=o.y+e.offsetY;if(s){const e=s.getBoundingClientRect();r-=e.x,l-=e.y}t.classList.contains("lexassettitle")&&(l+=a.y-o.y),i.style.left=r+"px",i.style.top=l-36+"px"})}if(this.allowItemCheck){let e=document.createElement("input");e.type="checkbox",e.className="lexcheckbox",e.checked=u.selected,e.addEventListener("change",e=>{u.selected=!u.selected;const s=c._callbacks.check;if(void 0!==s){s({type:"check",items:[t],userInitiated:!0})}e.stopPropagation(),e.stopImmediatePropagation()}),h.appendChild(e)}if(e.LX.makeElement("span","lexassettitle absolute w-full h-8 bottom-0 text-sm bg-card text-card-foreground cursor-pointer text-center content-center block px-3 py-0.5 truncate z-1 pointer-events-none",t.id,h),!this.skipPreview){if("video"===t.type){const s=e.LX.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=t.src,s.volume=u.volume??.4}let s=null;const i=u.preview??t.src;if(i&&((()=>{const t=e.LX.getExtension(i.split("?")[0].split("#")[0]);return!!t&&["png","jpg","jpeg","gif","bmp","avif"].includes(t.toLowerCase())})()||i.startsWith("data:image/"))||l||!n){const e=`${this.rootPath}images/file.png`,t=`${this.rootPath}images/folder.png`;s=document.createElement("img");let o=u.unknownExtension?e:l?t:i;s.src=n||l?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 e=document.createElement("text");e.innerText=r&&r!=t.id?`${r.toUpperCase()}`:t.type.toUpperCase(),s.appendChild(e);var p=2.5/e.innerText.length;if(p<1){var m=64*p;e.style.fontSize=m+"px",s.style.paddingTop=`calc(50% - ${.5*e.offsetHeight+10}px)`}}}let g=a;o&&(u.bytesize&&(g+=` | ${e.LX.formatBytes(u.bytesize)}`),u.lastModifiedDate&&(g+=` | ${u.lastModifiedDate}`)),e.LX.makeContainer(["auto","auto"],"lexassetinfo",g,h),h.addEventListener("click",function(s){s.stopImmediatePropagation(),s.stopPropagation();const i=s.detail==e.LX.MOUSE_DOUBLE_CLICK;if(i){if(l)return void c._enterFolder(t)}else s.shiftKey&&c.allowMultipleSelection||(c.content.querySelectorAll(".lexassetitem").forEach(e=>e.classList.remove("selected")),c.selectedItems.length=0),this.classList.add("selected"),c.selectedItems.push(t),c.skipPreview||c._previewAsset(t);const o=c._callbacks.select,n=c._callbacks.dblClick;if(i&&void 0!==n){n({type:"dbl_click",items:[t],userInitiated:!0})}else if(!i&&void 0!==o){o({type:"select",items:[t],userInitiated:!0})}}),h.addEventListener("contextmenu",function(s){s.preventDefault(),s.stopImmediatePropagation(),s.stopPropagation();const i=c.selectedItems.length>1,o=[{name:i?`${c.selectedItems.length} selected`:t.id,icon:e.LX.makeIcon("CircleSmall",{svgClass:`fill-current text-${d}`}),className:"text-sm",disabled:!0},null];if(i||o.push({name:"Rename",icon:"TextCursor",callback:c._renameItemPopover.bind(c,t)}),l||i||o.push({name:"Clone",icon:"Copy",callback:c._requestCloneItem.bind(c,t)}),i||o.push({name:"Move",icon:"FolderInput",callback:()=>c._moveItem(t)}),!i&&"Script"==a&&e.LX.has("CodeEditor")&&o.push({name:"Open in Editor",icon:"Code",callback:c._openScriptInEditor.bind(c,t)}),c.itemContextMenuOptions){o.length>2&&o.push(null);for(let e of c.itemContextMenuOptions)e.name&&e.callback&&o.push({name:e.name,icon:e.icon,callback:e.callback?.bind(c,i?c.selectedItems:[t])})}o.push(null,{name:"Delete",icon:"Trash2",className:"destructive",callback:c._requestDeleteItem.bind(c,i?c.selectedItems:[t])}),e.LX.addClass(c.contentPanel.root,"pointer-events-none"),e.LX.addDropdownMenu(s.target,o,{side:"right",align:"start",event:s,onBlur:()=>{e.LX.removeClass(c.contentPanel.root,"pointer-events-none")}})});const f=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",s=>{window.__av_item_dragged=t;var i=new Image;i.src="",s.dataTransfer&&(s.dataTransfer.setDragImage(i,0,0),s.dataTransfer.effectAllowed="move");const o=e.LX.getSupportedDOMName(`floatingTitle_${u.uid}`),n=c.content.querySelector(`#${o}`);n&&(n.style.display="none")},!1),h.addEventListener("dragend",e=>{e.preventDefault();let t=window.__av_item_dragged;t&&t._nodeTarget&&f(t,t._nodeTarget),delete window.__av_item_dragged},!1),h.addEventListener("dragenter",s=>{s.preventDefault();let i=window.__av_item_dragged;i&&l&&i.metadata.uid!=u.uid&&e.LX.addClass(t.domEl,"animate-pulse")}),h.addEventListener("dragleave",s=>{s.preventDefault(),window.__av_item_dragged&&e.LX.removeClass(t.domEl,"animate-pulse")}),h.addEventListener("drop",e=>{e.preventDefault();let s=window.__av_item_dragged;s&&f(s,t)}),h.addEventListener("mouseenter",s=>{if(!c.useNativeTitle&&n){const t=e.LX.getSupportedDOMName(`floatingTitle_${u.uid}`),s=c.content.querySelector(`#${t}`);s&&(s.style.display="unset")}if("video"!==t.type)return;s.preventDefault();const i=h.querySelector("video");i.style.opacity="1",i.play()}),h.addEventListener("mouseleave",s=>{if(!c.useNativeTitle&&n&&setTimeout(()=>{const t=e.LX.getSupportedDOMName(`floatingTitle_${u.uid}`),s=c.content.querySelector(`#${t}`);s&&(s.style.display="none")},100),"video"!==t.type)return;s.preventDefault();const i=h.querySelector("video");i.pause(),i.currentTime=0,u.preview&&(i.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("@");e.LX.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:"ghost",title:"Go Back",tooltip:!0,icon:"ArrowLeft"}),e.addButton(null,"GoForwardButton",()=>{this.nextData.length&&this.currentFolder&&this._enterFolder(this.nextData.pop())},{buttonClass:"ghost",title:"Go Forward",tooltip:!0,icon:"ArrowRight"}),e.addButton(null,"GoUpButton",()=>{const e=this.currentFolder?.parent;e&&this._enterFolder(e)},{buttonClass:"ghost",title:"Go Upper Folder",tooltip:!0,icon:"ArrowUp"}),e.addButton(null,"RefreshButton",()=>{this._refreshContent(void 0,void 0,!0)},{buttonClass:"ghost",title:"Refresh",tooltip:!0,icon:"Refresh"})}_createTreePanel(e){this.leftPanel?this.leftPanel.clear():this.leftPanel=e.addPanel({className:"lexassetbrowserpanel"}),this._createNavigationBar(this.leftPanel);const t={id:"/",children:this.data},s=this.leftPanel.addTree("Content Browser",t,{filter:!1,onlyFolders:this.onlyFolders});this._subscribeTreeEvents(s),this.tree=s.innerTree}_subscribeTreeEvents(e){e.on("select",(e,t)=>{if(e.items.length>1)return;const s=e.items[0];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.selectedItems=[s]}else this.currentFolder&&this.prevData.push(this.currentFolder),this.currentFolder=void 0,this.currentData=this.data,this._refreshContent(),this._updatePath()}),e.on("beforeMove",(e,t)=>{const s=this._callbacks.beforeNodeDragged,i=this._callbacks.nodeDragged,o=e.items[0],n=e.to,a=(...e)=>{if(o.parent){const e=o.parent.children.indexOf(o);o.parent.children.splice(e,1)}n.children||(n.children=[]),n.children.push(o),o.parent=n,o.dir=n.children,t(...e);i&&i({type:"node-drag",items:[o],to:n,userInitiated:!0},...e),this._refreshContent()};if(s){s({type:"node-drag",items:[o],to:n,userInitiated:!0},a)}else a()}),e.on("beforeDelete",(e,t)=>{const s=e.items[0];this._requestDeleteItem(s)}),e.on("beforeRename",(e,t)=>{const s=e.items[0];this._requestRenameItem(s,e.newName,!0)})}_setContentLayout(e){this.layout=e,this.toolsPanel.refresh(),this._refreshContent()}_createContentPanel(t){const s=this;t.root.classList.add("flex","flex-col"),this.toolsPanel?this.contentPanel.clear():(this.toolsPanel=t.addPanel({className:"flex-auto",height:"auto"}),this.contentPanel=t.addPanel({className:"lexassetcontentpanel flex flex-col flex-auto-fill content-center overflow-hidden"}),this._paginator=new e.LX.Pagination({className:"ml-auto",pages:Math.max(Math.ceil(this.data.length/this.assetsPerPage),1),onChange:()=>this._refreshContent()}),this.contentPanel.root.addEventListener("wheel",t=>{if(!t.ctrlKey)return;t.preventDefault(),this.gridScale*=t.deltaY<0?1.05:.95,this.gridScale=e.LX.clamp(this.gridScale,.5,2);document.querySelector(":root").style.setProperty("--av-grid-scale",this.gridScale)}));const i=(t,s)=>{e.LX.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,_t.CONTENT_SORT_ASC)},{name:"Descending",icon:"SortDesc",callback:()=>this._sortData(void 0,_t.CONTENT_SORT_DESC)}],{side:"bottom",align:"start"})},o=(t,s)=>{e.LX.addDropdownMenu(s.target,[{name:"Grid",icon:"LayoutGrid",callback:()=>this._setContentLayout(_t.LAYOUT_GRID)},{name:"Compact",icon:"LayoutList",callback:()=>this._setContentLayout(_t.LAYOUT_COMPACT)},{name:"List",icon:"List",callback:()=>this._setContentLayout(_t.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===_t.CONTENT_SORT_ASC?"SortAsc":"SortDesc"});if(this.toolsPanel.addButton(null,"",o.bind(this),{title:"View",tooltip:!0,icon:this.layout===_t.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 text-muted-foreground text-sm 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")),s.selectedItems.length=0}),this.content.addEventListener("contextmenu",function(t){t.preventDefault();const i=[{name:"New Folder",icon:e.LX.makeIcon("FolderPlus"),callback:()=>{s._requestCreateFolder()}}];e.LX.addClass(s.contentPanel.root,"pointer-events-none"),e.LX.addDropdownMenu(t.target,i,{side:"right",align:"start",event:t,onBlur:()=>{e.LX.removeClass(s.contentPanel.root,"pointer-events-none")}})}),this._refreshContent(),e.LX.doAsync(()=>this.toolsPanel.refresh(),100)}_makeNameFilterFn(t){const s=t.trim();if(s.includes("*")||s.includes("?")){const t=e.LX.wildcardToRegExp(s);return e=>t.test(e)}return e=>e.toLowerCase().includes(s.toLowerCase())}_refreshContent(t,s,i=!1){const o=this._callbacks.beforeRefreshContent,n=this._callbacks.refreshContent,a=(...o)=>{const a=this.layout==_t.LAYOUT_COMPACT,r=this.layout==_t.LAYOUT_LIST;if(this.filter=s??this.filter??"None",this.searchValue=t??this.searchValue??"",this.content.innerHTML="",this.content.className="lexassetscontent"+(a?" compact":r?" list":""),!this.currentData.length)return;const l=new FileReader,c=this._makeNameFilterFn(this.searchValue),h=this.currentData.filter(e=>{const t="None"===this.filter||e.type.toLowerCase()===this.filter.toLowerCase(),s=c(e.id);return t&&s});this._paginator?.setPages(Math.max(Math.ceil(h.length/this.assetsPerPage),1));const d=this._paginator?(this._paginator.page-1)*this.assetsPerPage:0,u=this._paginator?Math.min(d+this.assetsPerPage,h.length):h.length;for(let i=d;i<u;++i){let o=h[i];o.path?e.LX.request({url:o.path,dataType:"blob",success:e=>{o.metadata.bytesize=e.size,l.readAsDataURL(e),l.onload=e=>{const i=e.currentTarget;o.src=i.result,o.metadata.path=o.path,delete o.path,this._refreshContent(t,s)}}}):o.domEl=this.addItem(o,void 0,!1)}const p={type:"refresh-content",search:[this.searchValue,this.filter],items:h.slice(d,u),userInitiated:i};n&&n(p,...o)};if(o){o({type:"refresh-content",search:[this.searchValue,this.filter],userInitiated:i},a)}else a()}_previewAsset(t){if(this.skipPreview)return;const s=t.src&&t.src.includes("data:image/");if(t.metadata=t.metadata??{},this.previewPanel.clear(),this.previewPanel.branch("Asset"),"image"==t.type||t.src){(["png","jpg"].indexOf(e.LX.getExtension(t.src))>-1||s)&&this.previewPanel.addImage(null,t.src,{style:{width:"100%"}})}t.metadata.lastModified&&!t.metadata.lastModifiedDate&&(t.metadata.lastModifiedDate=this._lastModifiedToStringDate(t.metadata.lastModified));const i={disabled:!0};this.previewPanel.addText("Filename",t.id,null,i),t.metadata.lastModifiedDate&&this.previewPanel.addText("Last Modified",t.metadata.lastModifiedDate,null,i),(t.metadata.path||t.src)&&this.previewPanel.addText("URL",t.metadata.path?t.metadata.path:t.src,null,i),this.previewPanel.addText("Path",this.path.join("/"),null,i),this.previewPanel.addText("Type",t.type,null,i),t.metadata.bytesize&&this.previewPanel.addText("Size",e.LX.formatBytes(t.metadata.bytesize),null,i),"folder"==t.type&&this.previewPanel.addText("Files",t.children?t.children.length.toString():"0",null,i),this.previewPanel.addSeparator();const o=[...this.previewActions];o.length||"folder"===t.type||o.push({name:"Download",callback:()=>e.LX.downloadURL(t.src,t.id)});for(let e of o)e.type&&e.type!==t.type||e.path&&e.path!==this.path.join("/")||this.previewPanel.addButton(null,e.name,e.callback.bind(this,t));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)===_t.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?.metadata?.uid===e.metadata?.uid;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}if(this.currentFolder=e,this.currentData=this.currentFolder?.children??[],o){this._processData(this.data),this._refreshContent();let e=`${this.currentFolder.id}/`,t=this.currentFolder.parent;for(;t&&"/"!==t.id;)e+=`${t.id}/`,t=t.parent;const s=e.split("/").filter(Boolean).reverse();this.tree?.select(void 0,s)}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)=>{e.forEach(e=>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,this.previewPanel?.clear()):console.error("[AssetView Error] Cannot move. Item not found.")}_moveItem(t,s){this._moveItemDialog&&this._moveItemDialog.destroy(),this._movingItem=t;let i,o=null;const n=function(t,s,a=!0){s.innerHTML="",o=t;for(let t of o.children??o){const i=e.LX.makeContainer(["100%","auto"],"flex flex-row px-1 items-center","",s),a="folder"===t.type,r=e.LX.makeContainer(["100%","auto"],`move-item flex flex-row gap-1 py-1 px-3 cursor-pointer items-center ${a?"text-foreground font-medium":"text-muted-foreground"} rounded-2xl ${a?"hover:bg-accent":"hover:bg-muted"}`,`${a?e.LX.makeIcon("FolderOpen",{svgClass:""}).innerHTML:""}${t.id}`,i);if(a){r.addEventListener("click",()=>{s.querySelectorAll(".move-item").forEach(t=>e.LX.removeClass(t,"bg-primary text-primary-foreground")),e.LX.addClass(r,"bg-primary text-primary-foreground"),o=t});const a=new e.LX.Button(null,"FPathButton",()=>{n(t,s)},{icon:"ChevronRight",className:"ml-auto h-8",buttonClass:"ghost"});i.appendChild(a.root)}}if(!a)return;const r=[];if(o&&o.parent){r.push(o.id);const e=t=>{t&&(r.push(t.parent?t.id:"@"),e(t.parent))};e(o.parent)}else r.push("@");i.innerHTML="",i.appendChild(e.LX.makeBreadcrumb(r.reverse().map(e=>({name:e})),{maxItems:4,separatorIcon:"ChevronRight"}))};this._moveItemDialog=new e.LX.Dialog(`Moving: ${t.id}`,a=>{const r=new e.LX.Area({className:"flex flex-col rounded-lg"});a.attach(r);const l=e.LX.makeContainer(["auto","100%"],"flex flex-auto-fill flex-col overflow-scroll py-2 gap-1","");{const t=r.addPanel({className:"p-2 border-b-color flex flex-auto-keep",height:"auto"});t.sameLine(2,"w-full"),t.addButton(null,"BackButton",()=>{o&&o.parent&&n(o.parent,l)},{icon:"ArrowLeft",title:"Back",tooltip:!0,className:"flex-auto-keep",buttonClass:"ghost"}),i=e.LX.makeElement("div"),t.addContent("ITEM_MOVE_PATH",i,{signal:"@item_move_path",className:"flex-auto-fill"})}r.attach(l),n(s??this.data,l);{const e=r.addPanel({className:"p-2 border-t-color flex flex-auto-keep justify-between",height:"auto"});e.addButton(null,"NewFolderButton",()=>{this._requestCreateFolder(o)},{width:"auto",icon:"FolderPlus",title:"Create Folder",tooltip:!0,className:"ml-2",buttonClass:"ghost"}),e.sameLine(2,"mr-2"),e.addButton(null,"Cancel",()=>{this._moveItemDialog.close()},{buttonClass:"ghost text-destructive"}),e.addButton(null,"Move",()=>{this._requestMoveItemToFolder(t,o)},{className:"",buttonClass:"primary"})}},{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(t){const s=t.parent,i=t.dir??[],o=i.indexOf(t);delete t.domEl,delete t.dir,delete t.parent;const n=e.LX.deepCopy(t);return n.id=this._getClonedName(t.id,i),n.dir=t.dir=i,n.parent=t.parent=s,n.metadata.uid=e.LX.guidGenerator(),i.splice(o+1,0,n),this._refreshContent(this.searchValue,this.filter),n}_getClonedName(t,s){const i=t.lastIndexOf(".");let o=t,n="";i>0&&(o=t.substring(0,i),n=t.substring(i));const a=o.match(/^(.*)\s\((\d+)\)$/);a&&(o=a[1]);let r=-1;for(const t of s){if(!t.id)continue;let s=t.id,i="";const a=s.lastIndexOf(".");if(a>0&&(i=s.substring(a),s=s.substring(0,a)),i!==n)continue;const l=s.match(new RegExp("^"+e.LX.escapeRegExp(o)+"\\s\\((\\d+)\\)$"));if(l){const e=parseInt(l[1]);e>r&&(r=e)}else s===o&&(r=Math.max(r,0))}return-1===r?t:`${o} (${r+1})${n}`}_requestRenameItem(e,t,s=!1){const i=this._callbacks.beforeRename,o=this._callbacks.rename,n=e.id,a=(...i)=>{this._renameItem(e,t,s?e.dir:this.currentData);o&&o({type:"rename",items:[e],oldName:n,newName:t,userInitiated:!0},...i)};if(i){i({type:"rename",items:[e],oldName:n,newName:t,userInitiated:!0},a)}else a()}_renameItem(t,s,i){const o=(i=i??this.currentData).indexOf(t);if(!(o<0)){if(t.domEl){const i=e.LX.hasClass(t.domEl,"selected"),n=e.LX.getSupportedDOMName(`floatingTitle_${t.metadata.uid}`),a=this.content.querySelector(`#${n}`);a&&a.remove(),t.domEl?.remove(),t.id=s,t.domEl=this.addItem(t,2*o),i&&this._previewAsset(t)}else t.id=s;this.tree?.refresh(),this._processData(this.data)}}_renameItemPopover(t){if(this.currentData.indexOf(t)<0)return;const s=e=>{n.destroy(),this._requestRenameItem(t,e)};let i=t.id;const o=new e.LX.Panel;o.addText(null,t.id,(e,t)=>{i=e,t.constructor===KeyboardEvent&&s(e)}),o.addButton(null,"Save",()=>{s(i)},{buttonClass:"primary"});const n=new e.LX.Popover(t.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,...t);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,t){if(!(e=e??this.currentFolder))throw"_createFolder: Something went wrong!";const s=e.children??e,i={id:this._getClonedName(t??"New Folder",s),type:"folder",children:[],parent:this.currentFolder,metadata:{}};return s.push(i),this._refreshContent(),this.tree?.refresh(),this._moveItemDialog&&this._movingItem&&this._moveItem(this._movingItem,e),i}_openScriptInEditor(t){this._scriptCodeDialog&&this._scriptCodeDialog.destroy(),this._scriptCodeDialog=new e.LX.Dialog(null,s=>{const i=new e.LX.Area({className:"rounded-lg"});s.attach(i),new e.LX.CodeEditor(i,{allowAddScripts:!1,files:[t.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(e.LX.AssetView=_t,!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("Audio");const kt=e.LX.Panel,St=e.LX.BaseComponent,wt=e.LX.ComponentType,Tt=e.LX.IEvent;class Et extends St{constructor(t,s,i,o,n,a={}){s.constructor==Number&&(s=e.LX.clamp(s,i,o),s=a.precision?e.LX.round(s,a.precision):s),super(wt.KNOB,t,s,a),this.onGetValue=()=>d.value,this.onSetValue=(t,s,i)=>{m(t),e.LX.BaseComponent._dispatchEvent(d,"change",s)},this.onResize=()=>{const e=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${e})`};const r=a.snap&&a.snap.constructor==Number,l=[];if(r){const e=(o-i)/a.snap;for(let t=0;t<a.snap+1;++t)l.push(i+t*e)}var c=document.createElement("div");c.className="lexknob",e.LX.addClass(c,a.size),e.LX.addClass(c,r?"show-ticks":null);let h=document.createElement("div");h.className="knobcircle",r&&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(t){const s=e.LX.remapRange(t,d.min,d.max,-135,135);d.style.rotate=s+"deg",d.value=t};const g=e.LX.remapRange(s,i,o,-135,135);d.style.rotate=g+"deg",this.disabled&&e.LX.addClass(c,"disabled"),d.addEventListener("change",s=>{const i=s.target,o=s.detail;p&&(i.value=l.reduce((e,t)=>Math.abs(t-i.value)<Math.abs(e-i.value)?t:e));let c=i.value=e.LX.clamp(i.value,i.min,i.max);if(c=a.precision?e.LX.round(c,a.precision):c,m(c),!o){let e=this.root.querySelector(".lexcomponentname .lexicon");e&&(e.style.display=c!=d.iValue?"block":"none"),r&&!p||(this._trigger(new Tt(t,c,s),n),p=!1)}},{passive:!1}),d.addEventListener("mousedown",function(e){if(document.activeElement==d||f.disabled)return;var t=f.root.ownerDocument;t.addEventListener("mousemove",C),t.addEventListener("mouseup",y),document.body.classList.add("noevents"),document.pointerLockElement||c.requestPointerLock();e.stopImmediatePropagation(),e.stopPropagation()});var f=this;function C(t){let s=-t.movementY;if(0!=s){let i=a.step??1;t.shiftKey?i*=10:t.altKey&&(i*=.1);let o=d.value-i*s;d.value=o,e.LX.BaseComponent._dispatchEvent(d,"change")}t.stopPropagation(),t.preventDefault()}function y(t){var s=f.root.ownerDocument;s.removeEventListener("mousemove",C),s.removeEventListener("mouseup",y),document.body.classList.remove("noevents"),r&&(p=!0,e.LX.BaseComponent._dispatchEvent(d,"change")),document.pointerLockElement&&document.exitPointerLock()}c.appendChild(h),this.root.appendChild(c),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Knob=Et;if(kt.prototype.addKnob=function(e,t,s,i,o,n={}){const a=new Et(e,t,s,i,o,n);return this._attachComponent(a)},!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("DocMaker");const Mt=["uint32_t","uint64_t","uint8_t"],At=["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"],Xt=["var","let","const","static","function","null","undefined","new","delete","true","false","NaN","this"],Pt=["var","let","const","override","fn","struct","alias","true","false","bool","f16","f32","i32","u32","vec2","vec3","vec4","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4"],Nt=["for","if","else","return","continue","break","case","switch","while","import","from","await"],It=["html","charset","rel","src","href","crossorigin","type","lang"],Ot=["DOCTYPE","html","head","body","title","base","link","meta","style","main","section","nav","article","aside","header","footer","address","h1","h2","h3","h4","h5","h6","p","hr","pre","blockquote","ol","ul","li","dl","dt","dd","figure","figcaption","div","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rp","rt","ruby","s","samp","small","span","strong","sub","sup","time","u","var","wbr","img","audio","video","source","track","picture","map","area","canvas","iframe","embed","object","param","form","label","input","button","select","datalist","optgroup","option","textarea","output","progress","meter","fieldset","legend","table","caption","colgroup","col","tbody","thead","tfoot","tr","td","th","details","summary","dialog","script","noscript","template"];class Rt{root;_listQueued=void 0;_lastDomTarget=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(t,s,i,o={}){if(console.assert(void 0!==t&&void 0!==s),o.collapsable){const n=e.LX.makeElement("div",e.LX.mergeClass("my-4 px-6 cursor-pointer",o.className),`<${s} id="${i??""}">${t}</${s}>`,this.root),a=e.LX.makeContainer(["100%","auto"],"px-4","",this.root);return e.LX.listen(n,"click",()=>n.querySelector("a.collapser").click()),this._lastDomTarget=this.root,this.setDomTarget(a),o.collapsableContentCallback&&o.collapsableContentCallback(),e.LX.makeCollapsible(n,a,null,{collapsed:o.collapsed??!1}),this.setDomTarget(this._lastDomTarget),delete this._lastDomTarget,n}const n=document.createElement(s);return n.className=o.className??"",n.innerHTML=t,i&&(n.id=i),this.root.appendChild(n),n}paragraph(t,s=!1,i=""){console.assert(void 0!==t);let o=document.createElement(s?"sup":"p");return o.className=e.LX.mergeClass("leading-relaxed",i),o.innerHTML=t,this.root.appendChild(o),o}code(t,s="js"){console.assert(void 0!==t),t.replaceAll("<","<"),t.replaceAll(">",">");let i="",o="";const n=(e,t)=>`<span class="${e}">${t}</span>`;for(let e=0;e<t.length;++e){const a=t[e],r=t.substring(e),l=r.indexOf("\n"),c=r.substring(0,l>-1?l:void 0);if("@"==a){const a=c.substring(1);if(!(a.indexOf("@")>-1||a.indexOf("[")>-1))continue;let r=null;const l=a.indexOf("@"),h="|"==a[l-1];if("["==t[e+1])if(i=a.substring(1,4),o=a.substring(5,l),h){const e=a.substring(6+o.length),s=o,l=e.substring(0,e.indexOf("@"));r=n(i,s.substring(0,s.length-1)+"@"+l);const c=s+"@"+l;t=t.replace(`@[${i}]${c}@`,r)}else r=n(i,o),t=t.replace(`@[${i}]${o}@`,r);else{if(o=a.substring(0,l),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),t=t.substr(0,e)+"@"+o+"@"+t.substr(e+o.length+3)}"cpp"==s&&At.includes(o)||"js"==s&&Xt.includes(o)||"wgsl"==s&&Pt.includes(o)?i="kwd":Mt.includes(o)?i="cls":Nt.includes(o)?i="lit":Ot.includes(o)?i="tag":It.includes(o)?i="atn":'"'==o[0]&&'"'==o[o.length-1]||"'"==o[0]&&"'"==o[o.length-1]||"`"==o[0]&&"`"==o[o.length-1]?i="str":Number.isNaN(parseFloat(o))?(i="",console.error("WARNING[Code Parsing]: Unknown highlight type: "+o)):i="dec",r=n(i,o),t=t.replace(`@${o}@`,r)}e+=r.length-1}}let a=document.createElement("div");a.className="code-container";let r=document.createElement("pre"),l=document.createElement("code");l.innerHTML=t;let c=document.createElement("button");return c.title="Copy code sample",c.appendChild(e.LX.makeIcon("Copy")),c.addEventListener("click",this._copySnippet.bind(this,c)),a.appendChild(c),r.appendChild(l),a.appendChild(r),this.root.appendChild(a),a}list(e,t,s,i=""){console.assert(e&&e.length>0&&["bullet","numbered"].includes(t),"Invalid list type or empty list"+t);const o="bullet"==t?"ul":"ol";let n=document.createElement(o);for(var a of(n.className=i,(s=s??this.root).appendChild(n),e)){if(a.constructor===Array)return void this.list(a,t,n);let e=document.createElement("li");e.className="leading-loose",e.innerHTML=a,n.appendChild(e)}return n}bulletList(e){return this.list(e,"bullet")}numberedList(e){return this.list(e,"numbered")}startCodeBulletList(){let e=document.createElement("ul");return this._listQueued=e,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);return t?t.appendChild(s):this.root.appendChild(s),s}image(t,s="",i,o=""){let n=document.createElement("img");return n.src=t,n.alt=s,n.className=e.LX.mergeClass("my-1",o),(i=i??this.root).appendChild(n),n}images(e,t=[],s,i){const o=navigator&&/Android|iPhone/i.test(navigator.userAgent),n=document.createElement("div");o||(n.style.width=s??"auto",n.style.height=i??"256px",n.className="flex flex-row justify-center");for(let s=0;s<e.length;++s)this.image(e[s],t[s],n);return this.root.appendChild(n),n}video(e,t="",s=!0,i=!1,o=""){let n=document.createElement("video");return n.className=o,n.src=e,n.controls=s,n.autoplay=i,i&&(n.muted=!0),n.loop=!0,n.alt=t,this.root.appendChild(n),n}note(t,s=!1,i,o,n=""){console.assert(void 0!==t);const a=e.LX.makeContainer([],e.LX.mergeClass("border-color rounded-xl overflow-hidden text-sm text-secondary-foreground my-6",n),"",this.root),r=document.createElement("div");return r.className="flex bg-muted font-semibold px-3 py-2 gap-2 text-secondary-foreground",r.appendChild(e.LX.makeIcon(o??(s?"MessageSquareWarning":"NotepadText"))),r.innerHTML+=i??(s?"Important":"Note"),a.appendChild(r),e.LX.makeContainer([],"leading-6 p-3",t,a)}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");return n.innerHTML=this.iCode("<span class='constructor'>"+e+"("+i+")</span>"),this.root.appendChild(n),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 class="font-semibold underline-offset-4 hover:underline" 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(t){t.innerHTML="",t.appendChild(e.LX.makeIcon("Check")),t.classList.add("copied"),setTimeout(()=>{t.innerHTML="",t.appendChild(e.LX.makeIcon("Copy")),t.classList.remove("copied")},2e3),navigator.clipboard.writeText(t.dataset.snippet??t.parentElement.innerText),console.log("Copied!")}}if(e.LX.DocMaker=Rt,!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("GraphEditor");const zt=globalThis,Dt=e.LX.vec2,Bt=e.LX.Area;e.LX.Panel,e.LX.Sidebar,e.LX.ContextMenu;const Ht=e.LX.PocketDialog;class Ft{origin;size;constructor(e,t){this.origin=e??new Dt(0,0),this.size=t??new Dt(0,0)}merge(e){console.assert(e.constructor==Ft);const t=this.origin,s=this.origin.add(this.size),i=e.origin,o=e.origin.add(e.size),n=new Dt(Math.min(t.x,i.x),Math.min(t.y,i.y)),a=new Dt(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 Vt{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=Vt.STOPPED;isFocused=!1;_graphContainer;_sidebarDom;_sidebarActive=!0;_sidebar;_domLinks;_domNodes;_mousePosition=new Dt(0,0);_deltaMousePosition=new Dt(0,0);_snappedDeltaMousePosition=new Dt(0,0);_lastMousePosition=new Dt(0,0);_lastSnappedMousePosition=new Dt(0,0);_generatingLink;_snapToGrid=!1;_snapValue=1;_nodeBackgroundOpacity=.8;_patternSizeF=15;_patternSize=new Dt(this._patternSizeF);_circlePatternSize=.04*this._patternSizeF;_circlePatternColor="#71717a9c";_background;_undoSteps=[];_redoSteps=[];_clipboardData;_lastMouseDown=0;_boxSelecting;_boxSelectRemoving;_currentBoxSelectionSVG;constructor(t,s={}){Vt.__instances.push(this),this._sidebar=t.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 Bt({className:"lexgraph"}),t.root.classList.add("grapharea"),this.root=this.area.root,this.root.tabIndex=-1,t.attach(this.root),this._graphContainer=t.sections[1].root,this._sidebarDom=t.sections[0].root,this._sidebarActive=s.sidebar??this._sidebarActive,e.LX.doAsync(()=>{this._sidebar.toggleCollapsed(!this._sidebarActive)},50),t.onresize=e=>{},t.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 Ht("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),zt.ge=this}static getInstances(){return Vt.__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=Vt.NODE_TYPES[e];i&&console.warn(`Replacing node type [${e}]`),Vt.NODE_TYPES[e]=t,Vt.onCustomNodeRegistered&&Vt.onCustomNodeRegistered(e,t),i&&Vt.onNodeTypeReplaced&&Vt.onNodeTypeReplaced(e,t,i)}static addNode(e,t,s={}){var i=Vt.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 Dt(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(t){if(!this.currentGraph||t.id!=this.currentGraph.id)if(this.clear(),t.id=t.id??t.constructor.name+"-"+e.LX.guidGenerator(),this.graphs[t.id]=t,t.nodes){this.currentGraph=t,this._updatePattern();for(let e of t.nodes)this._createNodeDOM(e);for(let e of t.groups){const t=this._createGroup(e);t.querySelector(".lexgraphgrouptitle").value=e.name,this._domNodes.prepend(t)}for(let e in t.links){const s=t.links[e];for(let e of s)this._createLink(e)}this._updateGraphName(t.name),this._togglePropertiesDialog(!1)}else console.warn("Graph does not contain any node!")}loadGraph(t,s){e.LX.requestJSON(t,e=>{let t="Graph"==e.type?this.addGraph(e):this.addGraphFunction(e);s&&s(t)},e=>console.error(e))}addGraph(e){let t=new $t;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 Gt;if(t.editor=this,e){for(let t of e.functions??[])this.addGraphFunction(t);t.configure(e)}this.setGraph(t);class s extends qt{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,Vt.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(t){t.editor=this,t.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,t.position),t.type&&Vt.NODE_TYPES[t.type]){const e=t.constructor.category;i.classList.add(e)}else{const e=t.type.lastIndexOf("/"),s=t.type.substring(0,e);i.classList.add(s)}(s=t.color??s)&&(s.constructor==Array?s=s.join(","):(s=e.LX.hexToRgb(s)).forEach((e,t)=>s[t]=255*e),i.style.backgroundColor="rgba("+s+", "+this._nodeBackgroundOpacity+")"),i.addEventListener("mousedown",t=>{t.button==e.LX.MOUSE_LEFT_CLICK&&(t.altKey?this._unSelectNode(i):(this.selectedNodes.length>1&&!t.ctrlKey&&!t.shiftKey&&this.unSelectAll(!0),i.classList.contains("selected")||this._selectNode(i,t.ctrlKey||t.shiftKey)))}),i.addEventListener("contextmenu",s=>{s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),e.LX.addContextMenu(null,s,e=>{e.add("Copy",()=>{this._clipboardData={id:t.id,gid:this.currentGraph?.id}}),e.add(""),e.add("Delete",()=>{this._deleteNode(i.dataset.id)})})}),i.addEventListener("dblclick",s=>{s.button==e.LX.MOUSE_LEFT_CLICK&&t.constructor.func&&this._sidebar.select(t.constructor.func.name)});var o=document.createElement("div");o.classList.add("lexgraphnodeheader"),o.innerText=t.title,i.appendChild(o);var n=document.createElement("div");n.classList.add("lexgraphnodeios"),i.appendChild(n);const a=t.inputs&&t.inputs.length,r=t.outputs&&t.outputs.length;if(a){const s=document.createElement("div");s.classList.add("lexgraphnodeinputs"),n.appendChild(s);for(let i of t.inputs)if(i.type){var l=document.createElement("div");l.className="lexgraphnodeio ioinput",l.dataset.index=s.childElementCount.toString(),(c=document.createElement("span")).className="io__type input "+i.type,c.dataset.type=i.type,c.innerHTML="<span>"+i.type[0].toUpperCase()+"</span>",l.appendChild(c),(h=document.createElement("span")).className="io__typedesc input "+i.type,h.innerHTML=i.type,l.appendChild(h),i.name&&e.LX.makeElement("span","io__name",i.name,l),s.appendChild(l)}else console.warn(`Missing type for node [${t.title}], skipping...`)}if(r){const e=document.createElement("div");e.classList.add("lexgraphnodeoutputs"),n.appendChild(e);for(let s of t.outputs){s.type||console.warn(`Missing type for node [${t.title}], skipping...`);var c,h,d=document.createElement("div");if(d.className="lexgraphnodeio iooutput",d.dataset.index=e.childElementCount.toString(),s.name){var u=document.createElement("span");u.classList.add("io__name"),u.innerText=s.name,d.appendChild(u)}(c=document.createElement("span")).className="io__type output "+s.type,c.dataset.type=s.type,c.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",d.appendChild(c),(h=document.createElement("span")).className="io__typedesc output "+s.type,h.innerHTML=s.type,d.appendChild(h),e.appendChild(d)}}e.LX.makeDraggable(i,{onMove:this._onMoveNodes.bind(this),onDragStart:this._onDragNode.bind(this)}),this._addNodeIOEvents(i);const p=t.id??t.title.toLowerCase().replaceAll(/\s/g,"-")+"-"+e.LX.guidGenerator();return this.nodes[p]={data:t,dom:i},t.id=p,i.dataset.id=p,this._domNodes.appendChild(i),"Main"==t.title&&(this.main=p),t.size=new Dt(i.offsetWidth,i.offsetHeight),t.resizeObserver=new ResizeObserver(e=>{for(const s of e){const e=s.contentRect;e.width&&e.height&&(t.size=new Dt(i.offsetWidth,i.offsetHeight))}}),t.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(),(r=document.createElement("span")).className="io__type input "+s.type,r.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",n.appendChild(r),(l=document.createElement("span")).className="io__typedesc input "+s.type,l.innerHTML=s.type,n.appendChild(l),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,r,l,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);(r=document.createElement("span")).className="io__type output "+s.type,r.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",c.appendChild(r),(l=document.createElement("span")).className="io__typedesc output "+s.type,l.innerHTML=s.type,c.appendChild(l),e.appendChild(c)}}this._addNodeIOEvents(e)}_addNodeIOEvents(t){const s=t.querySelector(".lexgraphnodeios");s?.querySelectorAll(".lexgraphnodeio").forEach(s=>{s.addEventListener("mousedown",i=>{i.button==e.LX.MOUSE_LEFT_CLICK&&(this._lastMouseDown=e.LX.getTime(),this._generatingLink={index:parseInt(s.dataset.index),io:s,ioType:s.classList.contains("ioinput")?Vt.NODE_IO_INPUT:Vt.NODE_IO_OUTPUT,domEl:t},i.stopPropagation(),i.stopImmediatePropagation())}),s.addEventListener("mouseup",t=>{t.stopPropagation(),t.stopImmediatePropagation(),e.LX.getTime()-this._lastMouseDown<200?delete this._generatingLink:this._generatingLink&&(this._onLink(t)||e.LX.deleteElement(this._generatingLink.path?this._generatingLink.path.parentElement:null),delete this._generatingLink)}),s.addEventListener("click",e=>{if(!s.links)return;const i=t.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 Ft(new Dt(e,o),new Dt(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 Dt(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(t){if(!this.currentGraph)return;const s=this.nodes[t],i=s.data,o=s.dom;if(console.assert(o),i.constructor.blockDelete)return void console.warn("Can't delete node!");e.LX.deleteElement(o),delete this.nodes[t];const n=this.currentGraph.nodes.findIndex(e=>e.id===t);console.assert(n>=0),this.currentGraph.nodes.splice(n,1);for(let s in this.currentGraph.links){if(!s.includes(t))continue;const i=s.indexOf("@"),o=s.substring(i+1)!=t,n=this.currentGraph.links[s].length;for(var a=0;a<n;++a){var r=this.currentGraph.links[s][a];e.LX.deleteElement(r.path.parentElement);const i=o?r.inputNode:r.outputNode,n=this._getNodeDOMElement(i).querySelector(o?".lexgraphnodeinputs":".lexgraphnodeoutputs").childNodes[o?r.inputIdx:r.outputIdx],d=o?r.outputIdx:r.inputIdx,u=n.links[d].indexOf(t);if(n.links[d].splice(u,1),o)delete n.dataset.active;else{var l=!1;for(var c of n.links)if(c)for(var h of c)l=l||!!h;l||delete n.dataset.active}}delete this.currentGraph.links[s]}}_deleteGroup(t){if(!this.currentGraph)return;const s=this.groups[t];e.LX.deleteElement(s),delete this.groups[t];const i=this.currentGraph.groups.findIndex(e=>e.id===t);console.assert(i>=0),this.currentGraph.groups.splice(i,1)}_cloneNode(t,s,i){if(!this.currentGraph)return;const o=this.graphs[s??this.currentGraph.id].getNodeById(t);if(!o)return;const n=this._getNodeDOMElement(t),a=Vt.addNode(o.type);a.properties=e.LX.deepCopy(o.properties);const r=this._createNodeDOM(a);this._translateNode(r,i??this._getNodePosition(n)),this._selectNode(r,!0),this.currentGraph.nodes.push(a)}_cloneNodes(){const t=e.LX.deepCopy(this.selectedNodes);this.unSelectAll();for(let e of t)this._cloneNode(e)}_getNodePosition(e){return new Dt(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(t,s){const i=s.classList.contains("ioinput"),o=parseInt(s.dataset.index);if(i){let i=-1;const l=s.links.filter((e,t)=>(i=t,void 0!==e))[0][0];if(!l)return;var n=(r=this._getLinks(l,t)).findIndex(e=>e.inputIdx==o&&e.outputIdx==i);e.LX.deleteElement(r[n].path.parentElement),r.splice(n,1),delete s.links,delete s.dataset.active;const c=this._getNodeDOMElement(l).querySelector(".lexgraphnodeoutputs").childNodes[i],h=c.links[o].findIndex(e=>e==t);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 l=i.length-1;l>=0;--l){const c=i[l];var r;n=(r=this._getLinks(t,c)).findIndex(e=>e.inputIdx==a&&e.outputIdx==o);e.LX.deleteElement(r[n].path.parentElement),r.splice(n,1),s.links[a].splice(l,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(t){if(!this.currentGraph)return;const s=this.root.getBoundingClientRect();this._mousePosition=new Dt(t.clientX-s.x,t.clientY-s.y);const i=new Dt(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"==t.type)this._lastMouseDown=e.LX.getTime(),this._processMouseDown(t);else if("mouseup"==t.type)e.LX.getTime()-this._lastMouseDown<200&&this._processClick(t),this._processMouseUp(t);else if("mousemove"==t.type)this._processMouseMove(t);else if("click"==t.type)switch(t.detail){case e.LX.MOUSE_DOUBLE_CLICK:case e.LX.MOUSE_TRIPLE_CLICK:}else"mousewheel"==t.type?(t.preventDefault(),this._processWheel(t)):"contextmenu"==t.type?(t.preventDefault(),e.LX.getTime()-this._lastMouseDown<300&&this._processContextMenu(t)):"mouseleave"==t.type&&this._generatingLink&&this._processMouseUp(t);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(t){const s=t.target;s.classList.contains("lexgraphnode")||s.classList.contains("lexgraphgroup")||t.button!=e.LX.MOUSE_LEFT_CLICK||(this._boxSelecting=this._mousePosition,this._boxSelectRemoving=t.altKey)}_processMouseUp(t){if(this._generatingLink){const s=Object.assign({},this._generatingLink);e.LX.deleteElement(this._generatingLink.path?this._generatingLink.path.parentElement:null),delete this._generatingLink,this._processContextMenu(t,s)}else this._boxSelecting&&(t.ctrlKey||t.altKey||this.unSelectAll(),this._selectNodesInBox(this._boxSelecting,this._mousePosition,t.altKey),e.LX.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(t){if(this._boxSelecting||!this.currentGraph)return;const s=this.root.getBoundingClientRect(),i=this._mousePosition??new Dt(.5*s.width,.5*s.height),o=this._getPatternPosition(i),n=t.deltaY;this.currentGraph.scale*=n>0?.9:1/.9,this.currentGraph.scale=e.LX.clamp(this.currentGraph.scale,Vt.MIN_SCALE,Vt.MAX_SCALE);const a=this._getPatternPosition(i).sub(o);this.currentGraph.translation.add(a,this.currentGraph.translation),this._updatePattern()}_processContextMenu(t,s){this.currentGraph&&e.LX.addContextMenu(null,t,e=>{var i=null;if(t){const e=this.root.getBoundingClientRect(),s=new Dt(t.clientX-e.x,t.clientY-e.y);i=this._getPatternPosition(s)}this._clipboardData&&(e.add("Paste",()=>{const e=this._clipboardData.id,t=this._clipboardData.gid;this._cloneNode(e,t,i)}),e.add(""));for(let t in Vt.NODE_TYPES){Vt.NODE_TYPES[t].blockAdd||e.add(t,()=>{const e=Vt.addNode(t),o=this._createNodeDOM(e);if(this._snapToGrid&&(o.mustSnap=!0),i&&this._translateNode(o,i),this.currentGraph?.nodes.push(e),s&&e.inputs.length){const t=s.domEl.dataset.id,i=s.io.childNodes[s.index].dataset.type,o=s.ioType==Vt.NODE_IO_INPUT,n={inputNode:o?t:e.id,inputIdx:o?s.index:0,inputType:o?i:e.inputs[0].type,outputNode:o?e.id:t,outputIdx:o?0:s.index,outputType:o?e.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=Vt.RUNNING,this.propagateEventToAllNodes("onStart"),requestAnimationFrame(this._frame.bind(this))}stop(){this.mustStop=!0,this.state=Vt.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,r=n-n*this.currentGraph.scale,l=a-a*this.currentGraph.scale;this._domNodes.style.transform="\n translate("+(s.x-r)+"px, "+(s.y-l)+"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")?Vt.NODE_IO_INPUT:Vt.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,r=this.nodes[a].data,l=parseInt(e.target.parentElement.dataset.index),c=t.ioType==Vt.NODE_IO_INPUT,h=o[c?"inputs":"outputs"][n].type,d=r[s==Vt.NODE_IO_INPUT?"inputs":"outputs"][l].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==Vt.NODE_IO_INPUT&&e.target.parentElement.dataset.active?this._deleteLinks(a,e.target.parentElement):t.ioType==Vt.NODE_IO_INPUT&&t.io.dataset.active&&this._deleteLinks(i,t.io);var u=t.io;u.links=u.links??[],u.links[l]=u.links[l]??[],u.links[l].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:l,inputType:c?h:d,outputNode:c?a:i,outputIdx:c?l:n,outputType:c?d:h}),m.dataset.id=g,t.io.dataset.active=!0,e.target.parentElement.dataset.active=!0,!0}_updatePreviewLink(t,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,r=this._generatingLink.domEl,l=this.root.getBoundingClientRect().x,c=this.root.getBoundingClientRect().y,h=r.querySelector(a==Vt.NODE_IO_INPUT?".lexgraphnodeinputs":".lexgraphnodeoutputs").childNodes[n].querySelector(".io__type"),d=h.getBoundingClientRect();let u=new Dt(d.x-l,d.y-c),p=null,m=null;if(t){if(p=new Dt(t.offsetX,t.offsetY),e.LX.hasClass(t.target,["lexgraphnode","lexgraphgroup"]))p.add(this._getNodePosition(t.target),p),p.add(new Dt(3,3),p);else if(e.LX.hasClass(t.target,["io__type","lexgraphgroupresizer"])){var g=t.target.offsetParent;p.add(this._getNodePosition(g),p),p.add(new Dt(t.target.offsetLeft,t.target.offsetTop),p),p.add(new Dt(3,3),p)}p=this._getRenderPosition(p)}else{m=s.querySelector(".io__type");const e=m.getBoundingClientRect();p=new Dt(e.x-l,e.y-c)}if(a==Vt.NODE_IO_INPUT){var f=p;p=u,u=f}let C=getComputedStyle(h).backgroundColor;return a==Vt.NODE_IO_OUTPUT&&m&&(C=getComputedStyle(m).backgroundColor),this._createLinkPath(i,u,p,C,!!t),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,r=o.querySelector(".lexgraphnodeoutputs").childNodes[e.outputIdx],l=r.querySelector(".io__type").getBoundingClientRect();let c=new Dt(l.x-n,l.y-a+6);const h=i.querySelector(".lexgraphnodeinputs").childNodes[e.inputIdx],d=h.querySelector(".io__type").getBoundingClientRect();let u=new Dt(d.x-n,d.y-a+6);const p=getComputedStyle(h.querySelector(".io__type")).backgroundColor;this._createLinkPath(s,c,u,p),e.path=s,r.links=[],r.links[e.inputIdx]=r.links[e.inputIdx]??[],r.links[e.inputIdx].push(e.inputNode),h.links=[],h.links[e.outputIdx]=h.links[e.outputIdx]??[],h.links[e.outputIdx].push(e.outputNode),r.dataset.active=!0,h.dataset.active=!0}_createLinkPath(t,s,i,o,n=!1){if(!this.currentGraph)return;const a=6*this.currentGraph.scale;s.add(new Dt(a,a),s),n||i.add(new Dt(a,a),i),s=this._getPatternPosition(s),i=this._getPatternPosition(i);const r=e.LX.clamp(Math.abs(s.x-i.x),0,256),l=128*Math.pow(r/256,.5);let c=s.add(new Dt(l,0)),h=i.sub(new Dt(l,0));t.setAttribute("d",`\n M ${s.x},${s.y}\n C ${c.x},${c.y} ${h.x},${h.y} ${i.x},${i.y}\n `),t.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:Vt.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 r of a){s=this._getLinks(e,r).find(e=>e.inputIdx==n&&e.outputIdx==o);this._generatingLink={index:s.outputIdx,io:i,ioType:Vt.NODE_IO_OUTPUT,domEl:t,path:s.path};const a=this._getNodeDOMElement(r).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 Ft(new Dt(0,0),new Dt(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 Ft(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 Dt(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 Ft(new Dt(t,s),new Dt(e.offsetWidth-2,e.offsetHeight-2))}_getBoundingFromNodes(e){let t=null;for(let s of e){const e=this.nodes[s].data,i=new Ft(e.position,e.size);t?t.merge(i):t=i}if(t){const e=8;t.origin.sub(new Dt(e),t.origin),t.origin.sub(new Dt(e),t.origin),t.size.add(new Dt(2*e),t.size),t.size.add(new Dt(2*e),t.size)}return t}_createGroup(t){const s=t??this._getBoundingFromNodes(this.selectedNodes);if(!s)return;const i=s.id??`group-${e.LX.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",l),t.addEventListener("mouseup",c),r[0]=e.x,r[1]=e.y,e.stopPropagation(),e.preventDefault(),document.body.classList.add("nocursor"),n.classList.add("nocursor")}),this.groups[i]=o;var a=this,r=[0,0];function l(e){let t=new Dt(r[0]-e.x,r[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",r[0]=e.x,r[1]=e.y,e.stopPropagation(),e.preventDefault()}function c(e){var t=a.root.ownerDocument;t.removeEventListener("mousemove",l),t.removeEventListener("mouseup",c),document.body.classList.remove("nocursor"),n.classList.remove("nocursor")}let h=document.createElement("input"),d=`Group ${Vt.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",t=>{t.button==e.LX.MOUSE_LEFT_CLICK&&(h.disabled=!1,h.focus())}),o.addEventListener("contextmenu",t=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e.LX.addContextMenu(null,t,e=>{e.add("Delete",()=>{this._deleteGroup(i)})})}),o.appendChild(n),o.appendChild(h),this._domNodes.prepend(o),e.LX.makeDraggable(o,{onMove:this._onMoveGroup.bind(this),onDragStart:this._onDragGroup.bind(this),updateLayers:!1}),Vt.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(t){new e.LX.DropdownMenu(t.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 t=new e.LX.Dialog(this.currentGraph.constructor.name,e=>{e.addText("Name",this.currentGraph?.name,e=>{this._updateGraphName(e),t.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=Vt.NODE_TYPES[o];n&&(delete Vt.NODE_TYPES[o],n.title=e,Vt.registerCustomNode("function/"+e,n)),this.currentGraph.name=e}_addGlobalActions(){}}e.LX.GraphEditor=Vt;class $t{name="Unnamed Graph";type="Graph";id="";editor;nodes=[];groups=[];variables={};links={};scale=1;translation=new Dt(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=Vt.addNode(t.type);e.id=t.id,e.title=t.title,e.color=t.color,e.position=new Dt(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(t=!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 t in this.links){const i=e.LX.deepCopy(this.links[t]);i.forEach(e=>delete e.path),s.links[t]=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,t?2:void 0)}catch(e){s=null,console.error(`Can't export Graph [${this.name}] of type [${this.type}].`)}return s}export(){const t=this.serialize();e.LX.downloadFile(this.name+".json",t)}}e.LX.Graph=$t;class qt{static title;static blockDelete=!1;static blockAdd=!1;static description="";id="";type="";title="";inputs=[];outputs=[];properties=[];position=new Dt(0,0);size=new Dt(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(t,s){if(!this.outputs||!this.outputs.length||!this.outputs[t])return;const i=this.editor?.graphs[this.graphID];for(let a in i.links){if(a.indexOf(this.id+"@")<0)continue;const r=i.links[a];for(var o of r){if(o.outputIdx!=t)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(e.LX.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}}e.LX.GraphNode=qt;class Gt extends $t{constructor(e,t={}){super(),this.name=e??"GraphFunction"+Vt.LAST_FUNCTION_ID,this.type="GraphFunction",Vt.LAST_FUNCTION_ID++;const s=Vt.addNode("function/Input");s.position=new Dt(150,250);const i=Vt.addNode("function/Output");i.position=new Dt(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)}}e.LX.GraphFunction=Gt;class Kt extends qt{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})}}Kt.blockDelete=!0,Kt.blockAdd=!0,Vt.registerCustomNode("function/Input",Kt);class Ut extends qt{onCreate(){this.addInput(null,"any")}onExecute(){}}Ut.blockDelete=!0,Ut.blockAdd=!0,Vt.registerCustomNode("function/Output",Ut);class Wt extends qt{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)}}Wt.description="Addition of 2 values (A+B).",Vt.registerCustomNode("math/Add",Wt);class Yt extends qt{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)}}Yt.description="Substraction of 2 values (A-B).",Vt.registerCustomNode("math/Substract",Yt);class jt extends qt{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)}}jt.description="Multiplication of 2 values (A*B).",Vt.registerCustomNode("math/Multiply",jt);class Zt extends qt{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)}}Zt.description="Division of 2 values (A/B).",Vt.registerCustomNode("math/Divide",Zt);class Qt extends qt{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))}}Qt.description="Square root of a scalar.",Vt.registerCustomNode("math/SQRT",Qt);Vt.registerCustomNode("logic/And",class extends qt{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)}});Vt.registerCustomNode("logic/Or",class extends qt{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 Jt extends qt{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))}}Vt.registerCustomNode("logic/Equal",Jt);Vt.registerCustomNode("logic/NotEqual",class extends Jt{logicOp(e,t){return e!=t}});Vt.registerCustomNode("logic/Less",class extends Jt{logicOp(e,t){return e<t}});Vt.registerCustomNode("logic/LessEqual",class extends Jt{logicOp(e,t){return e<=t}});Vt.registerCustomNode("logic/Greater",class extends Jt{logicOp(e,t){return e>t}});Vt.registerCustomNode("logic/GreaterEqual",class extends Jt{logicOp(e,t){return e>=t}});Vt.registerCustomNode("logic/Select",class extends qt{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 es extends qt{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)}}}es.description="Compare A to B given the selected operator. If true, return value of True else return value of False.",Vt.registerCustomNode("logic/Compare",es);Vt.registerCustomNode("events/KeyDown",class extends qt{onCreate(){this.addOutput(null,"bool"),this.addProperty("Key","string"," ")}onExecute(){this.setOutput(0,!!this.editor?.keys[this.properties[0].value])}});Vt.registerCustomNode("inputs/String",class extends qt{onCreate(){this.addOutput(null,"string"),this.addProperty(null,"string","text")}onExecute(){this.setOutput(0,this.properties[0].value)}});Vt.registerCustomNode("inputs/Float",class extends qt{onCreate(){this.addOutput(null,"float"),this.addProperty(null,"float",0)}onExecute(){this.setOutput(0,this.properties[0].value)}});Vt.registerCustomNode("inputs/Vector2",class extends qt{onCreate(){this.addOutput("Value","vec2"),this.addProperty("Value","vec2",[0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});Vt.registerCustomNode("inputs/Vector3",class extends qt{onCreate(){this.addOutput("Value","vec3"),this.addProperty("Value","vec3",[0,0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});Vt.registerCustomNode("inputs/Vector4",class extends qt{onCreate(){this.addOutput("Value","vec4"),this.addProperty("Value","vec4",[0,0,0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});class ts extends qt{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))}}}ts.title="Set Variable",Vt.registerCustomNode("variables/SetVariable",ts);class ss extends qt{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)}}}ss.title="Get Variable",Vt.registerCustomNode("variables/GetVariable",ss);class is extends qt{onCreate(){this.addInput(null,"any")}onExecute(){var e=this.getInput(0);null!=e&&console.log(e)}}is.title="Console Log",Vt.registerCustomNode("system/ConsoleLog",is);class os extends qt{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(os.blockDelete=!0,Vt.registerCustomNode("system/Main",os),!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("ImUI");const ns=e.LX.vec2;class as{root;canvas;components={};mouseDown=!1;mousePosition=new ns;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(t,s,i,o){const n=this.canvas.getContext("2d");n.font="16px Arial";let a=new e.LX.vec2(12,8),r=new e.LX.vec2(s,i);const l=n.measureText(t);let c=new e.LX.vec2(l.width,l.actualBoundingBoxAscent+l.actualBoundingBoxDescent);const h=this.mousePosition.x>=r.x&&this.mousePosition.x<=r.x+c.x+2*a.x&&this.mousePosition.y>=r.y&&this.mousePosition.y<=r.y+c.y+2*a.y,d=h&&this.mouseDown;return n.beginPath(),n.fillStyle=d?"#666":h?"#444":"#222",n.roundRect(r.x,r.y,c.x+2*a.x,c.y+2*a.y,[8,8,8,8]),n.fill(),n.fillStyle=h?"#fff":"#ddd",n.fillText(t,r.x+a.x,r.y+l.actualBoundingBoxAscent+a.y),this.usePointerCursor=this.usePointerCursor||h,!!this.eventClick&&(o&&o(),!0)}Slider(t,s,i,o=0,n){const a=this.canvas.getContext("2d");this.components[t]?o=this.components[t].value:this.components[t]={value:o};a.font="16px Arial";let r=new e.LX.vec2(12,8),l=new e.LX.vec2(s,i);const c=a.measureText(t);let h=new e.LX.vec2(c.width,c.actualBoundingBoxAscent+c.actualBoundingBoxDescent),d=h.add(r.mul(2));const u=this.mousePosition.x>=l.x&&this.mousePosition.x<=l.x+d.x&&this.mousePosition.y>=l.y&&this.mousePosition.y<=l.y+d.y,p=u&&this.mouseDown;a.beginPath(),a.fillStyle=u?"#444":"#222",a.roundRect(l.x,l.y,d.x,d.y,[8,8,8,8]),a.fill();const m=l.x,g=l.x+d.x;p&&(o=e.LX.clamp((this.mousePosition.x-m)/(g-m),0,1),this.components[t].value=o);let f=new e.LX.vec2(d.x*o,h.y);a.beginPath(),a.fillStyle=u?"#6074e7":"#3e57e4",f.x>d.x-8?(a.roundRect(l.x,l.y,f.x,f.y+2*r.y,[8,8,8,8]),a.fill()):a.fillRect(l.x,l.y,f.x,f.y+2*r.y),a.fillStyle=u?"#fff":"#ddd",a.fillText(t,l.x+r.x,l.y+c.actualBoundingBoxAscent+r.y),this.usePointerCursor=this.usePointerCursor||u,p&&n&&n(o)}Checkbox(t,s,i,o=!1,n){const a=this.canvas.getContext("2d");this.components[t]?o=this.components[t].value:this.components[t]={value:o};a.font="16px Arial";let r=new e.LX.vec2(12,8),l=new e.LX.vec2(s,i);const c=a.measureText(t);let h=new e.LX.vec2(c.width,c.actualBoundingBoxAscent+c.actualBoundingBoxDescent),d=new e.LX.vec2(24,0);d.add(h,d);const u=l.x+h.x+r.x+12,p=l.y+r.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(l.x,l.y,d.x+2*r.x,d.y+2*r.y),f&&(o=!o,this.components[t].value=o,n&&n(o)),a.fillStyle=o?g?"#ddd":m?"#6074e7":"#3e57e4":g?"#bbb":m?"#777":"#888",a.fillRect(l.x+h.x+r.x+12,l.y+r.y,h.y,h.y),a.fillStyle=m?"#fff":"#ddd",a.fillText(t,l.x+r.x,l.y+c.actualBoundingBoxAscent+r.y),this.usePointerCursor=this.usePointerCursor||m}endFrame(){delete this.eventClick,document.body.style.cursor=this.usePointerCursor?"pointer":"default",this.usePointerCursor=!1}}if(e.LX.ImUI=as,!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("Timeline"),e.LX.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>'),e.LX.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 rs=e.LX.Area,ls=e.LX.Panel,cs=e.LX.Dialog;class hs{static BACKGROUND_COLOR;static TRACK_COLOR_PRIMARY;static TRACK_COLOR_SECONDARY;static TRACK_COLOR_TERTIARY;static TRACK_SELECTED;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;trackTreesEvents={};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;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(t,s={}){this.uniqueID=t??"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 rs({className:"lextimeline"}),this.root=this.mainArea.root,this.mainArea.split({type:"vertical",sizes:[this.header_offset,"auto"],resize:!1}),this.header=new ls({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(){hs.BACKGROUND_COLOR=e.LX.getCSSVariable("background-blur"),hs.TRACK_COLOR_PRIMARY=e.LX.getCSSVariable("card"),hs.TRACK_COLOR_SECONDARY=e.LX.getCSSVariable("secondary"),hs.TRACK_COLOR_TERTIARY=e.LX.getCSSVariable("accent"),hs.TRACK_SELECTED=e.LX.getCSSVariable("primary"),hs.FONT=e.LX.getCSSVariable("global-font"),hs.FONT_COLOR_PRIMARY=e.LX.getCSSVariable("foreground"),hs.FONT_COLOR_TERTIARY=e.LX.getCSSVariable("primary"),hs.FONT_COLOR_QUATERNARY=e.LX.getCSSVariable("muted-foreground"),hs.KEYFRAME_COLOR=e.LX.getCSSVariable("lxTimeline-keyframe"),hs.KEYFRAME_COLOR_SELECTED=hs.KEYFRAME_COLOR_HOVERED=e.LX.getCSSVariable("lxTimeline-keyframe-selected"),hs.KEYFRAME_COLOR_LOCK=e.LX.getCSSVariable("lxTimeline-keyframe-locked"),hs.KEYFRAME_COLOR_EDITED=e.LX.getCSSVariable("lxTimeline-keyframe-edited"),hs.KEYFRAME_COLOR_INACTIVE=e.LX.getCSSVariable("lxTimeline-keyframe-inactive"),hs.TIME_MARKER_COLOR=e.LX.getCSSVariable("primary"),hs.TIME_MARKER_COLOR_TEXT=e.LX.getCSSVariable("primary-foreground")}.bind(this),e.LX.addSignal("@on_new_color_scheme",this.updateTheme),this.updateTheme()}clear(){if(this.header&&this.header.clear(),this.leftPanel&&this.leftPanel.clear(),this.updateTheme){let t=e.LX.signals["@on_new_color_scheme"]??[];for(let e=0;e<t.length;++e)t[e]==this.updateTheme&&t.splice(e,1)}}updateHeader(){this.header.clear();const t=this.header;t.sameLine(),this.timelineTitle&&t.addTitle(this.timelineTitle,{style:{background:"none",fontSize:"18px",fontStyle:"bold",alignItems:"center"}});const s=e.LX.makeContainer(["auto","100%"],"flex flex-row gap-1");t.queue(s);t.addButton("playBtn","",(e,t)=>{this.changeState()},{buttonClass:"accept",title:"Play",hideName:!0,icon:"Play@solid",swap:"Pause@solid"}).setState(this.playing,!0),t.addButton("stopBtn","",(e,t)=>{this.setState(!1,!0),this.onStateStop&&this.onStateStop()},{buttonClass:"accept",title:"Stop",hideName:!0,icon:"Stop@solid"}),t.addButton("loopBtn","",(e,t)=>{this.setLoopMode(!this.loop)},{selectable:!0,selected:this.loop,title:"Loop",hideName:!0,icon:"RefreshCw",buttonClass:"h-8"}),this.onCreateControlsButtons&&this.onCreateControlsButtons(t),t.clearQueue(s),t.addContent("header-buttons",s),this.onCreateBeforeTopBar&&this.onCreateBeforeTopBar(t),t.addNumber("Current Time",this.currentTime,(e,t)=>{this.setTime(e)},{units:"s",step:.01,min:0,precision:3,skipSlider:!0,skipReset:!0,nameWidth:"auto"}),t.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(t);const i=e.LX.makeContainer(["auto","100%"],"flex flex-row gap-1");t.queue(i),this.onCreateSettingsButtons&&this.onCreateSettingsButtons(t),this.onShowOptimizeMenu&&t.addButton(null,"",(e,t)=>{this.onShowOptimizeMenu&&this.onShowOptimizeMenu(t)},{tooltip:!0,title:"Optimize",icon:"Filter"}),this.onShowConfiguration&&t.addButton(null,"",(e,t)=>{if(this.configurationDialog)return this.configurationDialog.close(),void(this.configurationDialog=null);this.configurationDialog=new cs("Configuration",e=>{this.onShowConfiguration&&this.onShowConfiguration(e)},{onBeforeClose:()=>{this.configurationDialog.panel.clear(),this.configurationDialog=null}})},{title:"Settings",icon:"Settings",tooltip:!0}),t.clearQueue(i),t.addContent("header-buttons-end",i),t.endLine("justify-between")}setTrackTreeEventListener(e,t){this.trackTreesEvents[e]=t,"select"!=e&&"visibleChanged"!=e&&this.trackTreesComponent.on(e,this.trackTreesEvents[e])}updateLeftPanel(){this.leftPanel.clear();const t=this.leftPanel;t.sameLine();let s=t.addTitle("Tracks",{style:{background:"none"},className:"text-lg px-4"}).root;this.disableNewTracks||t.addButton("addTrackBtn","",(e,t)=>{this.onAddNewTrackButton?this.onAddNewTrackButton():this.addNewTrack()},{hideName:!0,title:"Add Track",icon:"Plus"}),t.endLine();const i=window.getComputedStyle(s),o=s.clientHeight+parseFloat(i.marginTop)+parseFloat(i.marginBottom);let n=new e.LX.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}),this.trackTreesComponent.on("select",(e,t)=>{const s=e.items[0];if(e.domEvent.shiftKey||this.deselectAllTracks(!1),s.trackData){const t=!e.domEvent.shiftKey||!s.trackData.isSelected;this.setTrackSelection(s.trackData.trackIdx,t,!1,!1)}this.trackTreesEvents.select&&this.trackTreesEvents.select(e)}),this.trackTreesComponent.on("visibleChanged",(e,t)=>{const s=e.items[0];s.trackData&&this.setTrackState(s.trackData.trackIdx,s.visible,!1,!1),this.trackTreesEvents.visibleChanged&&this.trackTreesEvents.visibleChanged(e)});for(let e in this.trackTreesEvents)this.setTrackTreeEventListener(e,this.trackTreesEvents[e]);const r=this;this.trackTreesComponent.innerTree._refresh=this.trackTreesComponent.innerTree.refresh,this.trackTreesComponent.innerTree.refresh=function(e,t){this._refresh(e,t),r.setTrackHeight(r.trackHeight)},this.selectedTracks.length&&this._updateTrackTreeSelection(),this.trackTreesComponent.name="tracksTrees",n.components[this.trackTreesComponent.name]=this.trackTreesComponent,this.trackTreesPanel=n,t.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)),r=Math.min(i.length-1,Math.floor(n/this.trackHeight))+1;for(let e=a;e<r;++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 "+hs.FONT,s.textAlign="center",s.save(),s.fillStyle=hs.BACKGROUND_COLOR,s.fillRect(0,0,this.canvas.width,t),s.strokeStyle=hs.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 r=this.timeToX(n+i)-this.timeToX(n),l=o*r/i,c=this.timeToX(Math.floor(n/i)*i);c+=1e-7;let h=this.timeToX(a);s.beginPath(),s.fillStyle=hs.FONT_COLOR_PRIMARY,s.globalAlpha=1;for(let e=c;e<=h;e+=r){s.moveTo(Math.round(e)+.5,.4*t+.3*t),s.lineTo(Math.round(e)+.5,.95*t);let o=e+r-.5*l;for(let i=e;i<o&&i<h;i+=l)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,r=this.trackHeight;e=e||s.width;let l=Math.ceil((t-n)/r)+1;i.save(),i.fillStyle=hs.TRACK_COLOR_SECONDARY;const c=this.currentScrollInPixels%r;for(let t=Math.floor(this.currentScrollInPixels/r)%2;t<=l;t+=2)i.fillRect(0,a-c+t*r,e,r);i.strokeStyle=hs.TRACK_COLOR_TERTIARY,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 "+hs.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.children[0].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=hs.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?hs.FONT_COLOR_TERTIARY:hs.FONT_COLOR_QUATERNARY;let i=Math.max(10,(s-this.topMargin)*(s-this.topMargin)/this.trackTreesPanel.root.scrollHeight);ps(e,t-10,this.currentScroll*(s-this.topMargin-i)+this.topMargin,10,i,5,!0)}this.drawTimeInfo(t);let r=Math.round(this.timeToX(this.currentTime)),l=.4*this.topMargin;r>=0&&(e.strokeStyle=e.fillStyle=hs.TIME_MARKER_COLOR,e.globalAlpha=1,e.beginPath(),e.moveTo(r,.6*l),e.lineTo(r,this.canvas.height),e.stroke(),e.closePath(),e.shadowBlur=8,e.shadowColor=hs.TIME_MARKER_COLOR,e.shadowOffsetX=1,e.shadowOffsetY=1,ps(e,r-10,.6*l,20,l,5,!0),e.fill(),e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.font="11px "+hs.FONT,e.textAlign="center",e.fillStyle=hs.TIME_MARKER_COLOR_TEXT,e.fillText((.1*Math.floor(10*this.currentTime)).toFixed(1),r,.6*this.topMargin),e.strokeStyle=e.fillStyle=hs.FONT_COLOR_PRIMARY,this.boxSelection&&(e.globalAlpha=.15,e.fillStyle=hs.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(t){if(!this.canvas)return;let s=this.canvas.height,i=this.canvas.width,o=t.offsetX,n=t.offsetY;t.deltax=o-this.lastMouse[0],t.deltay=n-this.lastMouse[1];let a=t.offsetX,r=t.offsetY,l=this.timeToX(this.currentTime),c=r<this.topMargin&&a>l-6&&a<l+6;const h=this.xToTime(o);if(c?this.canvas.style.cursor="col-resize":this.movingKeys?this.canvas.style.cursor="grabbing":t.shiftKey?this.canvas.style.cursor="crosshair":this.canvas.style.cursor="default","wheel"==t.type){if(t.shiftKey){if(t.wheelDelta){let e=this.xToTime(a);this.setScale(this.pixelsPerSecond*(t.wheelDelta<0?.95:1.05)),this.visualOriginTime=e-a*this.secondsPerPixel}}else s-this.topMargin<this.trackTreesComponent.root.scrollHeight&&(this.trackTreesPanel.root.scrollTop+=t.deltaY);return void(this.onMouse&&this.onMouse(t,h))}const d=o>=0&&o<=this.size[0]&&n>=0&&n<=this.size[1];let u=this.getTracksInRange(r,r);if(u=u.length?u[0]:null,t.track=u,t.localX=a,t.localY=r,"mouseup"==t.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||e.LX.getTime()-this.clickTime>this.clickDiscardTimeout;t.discard=s,this.grabbingScroll||this.grabbingTimeBar||0!=t.button||!this.onMouseUp||this.onMouseUp(t,h),this.grabbing=!1,this.grabbingTimeBar=!1,this.grabbingScroll=!1,this.movingKeys=!1,this.timeBeforeMove=0,this.boxSelection=!1}if("mousedown"==t.type){if(window.getSelection()?.empty(),this.clickTime=e.LX.getTime(),t.shiftKey&&this.active)return this.boxSelection=!0,this.boxSelectionEnd[0]=this.boxSelectionStart[0]=a,void(this.boxSelectionEnd[1]=this.boxSelectionStart[1]=r);t.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(t,h))}else if("mousemove"==t.type){if(t.shiftKey&&this.active&&this.boxSelection)return this.boxSelectionEnd[0]=a,void(this.boxSelectionEnd[1]=r);if(this.grabbing&&2!=t.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*t.deltay/(s-this.topMargin);else{var p=this.xToTime(this.lastMouse[0]),m=this.xToTime(t.offsetX);this.visualOriginTime+=p-m,this.trackTreesPanel.root.scrollTop-=t.deltay}this.onMouseMove&&this.onMouseMove(t,h)}else"dblclick"==t.type&&this.onDblClick?this.onDblClick(t):"contextmenu"==t.type&&this.onShowContextMenu&&this.active&&this.onShowContextMenu(t);return this.lastMouse[0]=o,this.lastMouse[1]=n,!(d||this.grabbing||t.metaKey||t.altKey)||(this.onMouse&&this.onMouse(t,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}}}hs.BACKGROUND_COLOR=e.LX.getCSSVariable("background-blur"),hs.TRACK_COLOR_PRIMARY=e.LX.getCSSVariable("card"),hs.TRACK_COLOR_SECONDARY=e.LX.getCSSVariable("secondary"),hs.TRACK_COLOR_TERTIARY=e.LX.getCSSVariable("accent"),hs.TRACK_SELECTED=e.LX.getCSSVariable("primary"),hs.FONT=e.LX.getCSSVariable("global-font"),hs.FONT_COLOR_PRIMARY=e.LX.getCSSVariable("foreground"),hs.FONT_COLOR_TERTIARY=e.LX.getCSSVariable("primary"),hs.FONT_COLOR_QUATERNARY=e.LX.getCSSVariable("muted-foreground"),hs.TIME_MARKER_COLOR=e.LX.getCSSVariable("primary"),hs.TIME_MARKER_COLOR_TEXT=e.LX.getCSSVariable("primary-foreground"),e.LX.setCSSVariable("lxTimeline-keyframe","light-dark(#2d69da,#2d69da )"),e.LX.setCSSVariable("lxTimeline-keyframe-selected","light-dark(#f5c700,#fafa14)"),e.LX.setCSSVariable("lxTimeline-keyframe-hovered","light-dark(#f5c700,#fafa14)"),e.LX.setCSSVariable("lxTimeline-keyframe-locked","light-dark(#c62e2e,#ff7d7d )"),e.LX.setCSSVariable("lxTimeline-keyframe-edited","light-dark(#00d000,#00d000 )"),e.LX.setCSSVariable("lxTimeline-keyframe-inactive","light-dark(#706b6b,#706b6b)"),hs.KEYFRAME_COLOR=e.LX.getCSSVariable("lxTimeline-keyframe"),hs.KEYFRAME_COLOR_SELECTED=hs.KEYFRAME_COLOR_HOVERED=e.LX.getCSSVariable("lxTimeline-keyframe-selected"),hs.KEYFRAME_COLOR_LOCK=e.LX.getCSSVariable("lxTimeline-keyframe-locked"),hs.KEYFRAME_COLOR_EDITED=e.LX.getCSSVariable("lxTimeline-keyframe-edited"),hs.KEYFRAME_COLOR_INACTIVE=e.LX.getCSSVariable("lxTimeline-keyframe-inactive"),hs.BOX_SELECTION_COLOR="#AAA",e.LX.Timeline=hs;class ds extends hs{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(t,s={}){super(t,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=t=>{0!=this.selectedItems.length&&e.LX.addContextMenu("Optimize",t,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=t=>{t.preventDefault(),t.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(!t.track)return;const e=new Float32Array(t.track.dim);e.fill(0),this.addKeyFrames(t.track.trackIdx,e,[this.xToTime(t.localX)])}}),s.push({title:"Add",callback:()=>{if(!t.track)return;const e=new Float32Array(t.track.dim);e.fill(0),this.addKeyFrames(t.track.trackIdx,e,[this.currentTime])}})),this.clipboard&&this.clipboard.keyframes&&(s.push({title:"Paste Here",callback:()=>{this.pasteContent(this.xToTime(t.localX))}}),s.push({title:"Paste",callback:()=>{this.pasteContent(this.currentTime)}})),e.LX.addContextMenu("Options",t,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],r=a.times??[],l=a.values??[],c=a.dim;(!c||c<0)&&(c=r.length&&l.length?Math.round(l.length/r.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,r]=this.lastKeyFramesSelected[o];if(i=e[n],i&&i.locked)continue;this.canvas.style.cursor="grabbing";const l=this.animationClip.tracks[i.trackIdx].times;l[a]=Math.max(0,l[a]+t),l[a]>this.duration&&this.setDuration(l[a]);let c=a;if(t>0)for(;c<l.length-1&&!(l[c]<l[c+1]);++c)this.swapKeyFrames(i,c+1,c);else for(;c>0&&!(l[c-1]<l[c]);--c)this.swapKeyFrames(i,c-1,c);this.lastKeyFramesSelected[o][1]=c,this.lastKeyFramesSelected[o][2]=l[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,r]=this.lastKeyFramesSelected[o];if(i=t[n],i.locked||1!=i.dim||!i.curves)continue;let l=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],l-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=hs.TRACK_SELECTED,e.fillRect(0,0,e.canvas.width,t)),e.fillStyle=hs.KEYFRAME_COLOR,e.globalAlpha=1;const i=s.times,o=this.visualTimeRange[0],n=this.visualTimeRange[1]+1e-7,a=this.keyframeSize/Math.SQRT2,r=this.keyframeSizeHovered/Math.SQRT2;for(let l=0;l<i.length;++l){let c=i[l];if(c<o||c>n)continue;let h=this.timeToX(c),d=a;this.active&&0!=s.active?s.locked?e.fillStyle=hs.KEYFRAME_COLOR_LOCK:s.hovered[l]?(d=r,e.fillStyle=hs.KEYFRAME_COLOR_HOVERED):s.selected[l]?e.fillStyle=hs.KEYFRAME_COLOR_SELECTED:s.edited[l]?e.fillStyle=hs.KEYFRAME_COLOR_EDITED:e.fillStyle=hs.KEYFRAME_COLOR:e.fillStyle=hs.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(t,s,i){i.isSelected&&(t.globalAlpha=.2,t.fillStyle=hs.TRACK_SELECTED,t.fillRect(0,0,t.canvas.width,s)),t.globalAlpha=1;const o=i.times,n=i.values,a=.5*this.keyframeSize,r=.5*this.keyframeSizeHovered,l=i.curvesRange,c=s-2*a,h=this.visualTimeRange[0],d=this.visualTimeRange[1]+1e-7;if(t.strokeStyle=ds.FONT_COLOR_PRIMARY,t.beginPath(),o.length>1){let i=this.timeToX(o[0]),r=n[0];r=e.LX.clamp((r-l[0])/(l[1]-l[0]),0,1)*-c+(s-a),t.moveTo(i,r);for(let i=1;i<o.length;++i){let r=o[i],u=this.timeToX(r),p=n[i];if(p=e.LX.clamp((p-l[0])/(l[1]-l[0]),0,1)*-c+(s-a),r<h)t.moveTo(u,p);else{if(r>d){let r=this.timeToX(o[i-1]),h=u-r;if(h>0){let o=n[i-1];o=e.LX.clamp((o-l[0])/(l[1]-l[0]),0,1)*-c+(s-a);let u=(this.timeToX(d)-r)/h;t.lineTo(r+h*u,o*(1-u)+p*u)}break}t.lineTo(u,p)}}t.stroke()}t.fillStyle=hs.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?t.fillStyle=hs.KEYFRAME_COLOR_LOCK:i.hovered[u]?(m=r,t.fillStyle=hs.KEYFRAME_COLOR_HOVERED):i.selected[u]?t.fillStyle=hs.KEYFRAME_COLOR_SELECTED:i.edited[u]?t.fillStyle=hs.KEYFRAME_COLOR_EDITED:t.fillStyle=hs.KEYFRAME_COLOR:t.fillStyle=hs.KEYFRAME_COLOR_INACTIVE;let f=n[u];f=e.LX.clamp((f-l[0])/(l[1]-l[0]),0,1)*-c+(s-a),t.beginPath(),t.arc(g,f,m,0,2*Math.PI),t.fill(),t.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,r=this.optimizeThreshold;if(i.locked)return;let l=(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(l(n[t+e],n[i+e],n[o+e],r)){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,r=a+e.dim,l=s*e.dim;for(;a<r;++a)n=o[a],o[a]=o[l],o[l]=n,++l}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,r=t.values,l=this.animationClip.tracks[i];l.locked||(this.saveState(l.trackIdx,Boolean(n++)),this.historySaveEnabler=!1,this.addKeyFrames(l.trackIdx,r,a,-s+e,ds.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,r=n.times,l=n.values,c=new Float32Array(r.length+s.length),h=new Float32Array(l.length+s.length*a);this.saveState(e);let d=s.length-1,u=r.length-1,p=[];if(ds.ADDKEY_VALUESINARRAYS&o)for(let e=c.length-1;e>-1;--e){if(u<0||d>-1&&r[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]=l[u*a+t];c[e]=r[u--]}else for(let e=c.length-1;e>-1;--e)if(u<0||d>-1&&r[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]=l[u*a+t];c[e]=r[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 r=0;r<a;++r){const[a,l]=this.lastKeyFramesSelected[r];t[a].locked?t[a].selected[l]=!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(l))}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),r=i.values.slice(0,n*i.dim);let l=t[0],c=t[0]*i.dim;for(let e=0;e<t.length;++e){i.edited.splice(l,1),i.selected.splice(l,1),i.hovered.splice(l,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)r[c++]=i.values[e];for(let e=s+1;e<n;++e)a[l++]=i.times[e]}return i.times=a,i.values=r,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}}e.LX.KeyFramesTimeline=ds;class us extends hs{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(t,s={}){super(t,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=t=>{t.preventDefault(),t.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(t.localX))}})),e.LX.addContextMenu("Options",t,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,us.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(t={}){return{id:t.id??t.name??"clip",start:t.start??0,duration:t.duration??1,fadein:t.fadein??void 0,fadeout:t.fadeout??void 0,clipColor:t.clipColor??e.LX.getCSSVariable("color-blue-600"),fadeColor:t.fadeColor??null,active:t.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 r=this.timeToX(a.start+a.duration);Math.abs(r-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 r=n+e,l=this.animationClip.tracks[r],c=this.animationClip.tracks[n],h=this.historyUndo[this.historyUndo.length-1];let d=0;for(;d<h.length&&r!=h[d].trackIdx;++d);d==h.length&&(this.historySaveEnabler=!0,this.saveState(r,!0),this.historySaveEnabler=!1);for(let e=i;e<=o;++e){let t=this.addClip(c.clips[s[e][1]],r,0);s[e][0]=t,l.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]=r;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],r=o.clips,l=o.clips[i];if(s>=0){if(r.length-1==i)continue;if(!o.selected[i+1]){if(r[i+1].start>=l.start+l.duration+s)continue;const e=r[i+1];n=Math.max(0,Math.min(n,e.start-l.start-l.duration))}}else if(s<0){if(i>0&&r[i-1].start+r[i-1].duration<=l.start+s)continue;if(i>0){const e=r[i-1];n=Math.min(0,Math.max(n,e.start+e.duration-l.start))}l.start+s<0&&(n=Math.max(n,-l.start),a=!1)}if(!a)continue;let c=this.getClipsInRange(o,l.start+s,l.start+l.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 r=i.clips[a];r.start+=n,null!=r.fadein&&(r.fadein+=n),null!=r.fadeout&&(r.fadeout+=n);const l=i.edited[a],c=i.selected[a],h=i.hovered[a];if(s>0)for(;a<o.length-1&&!(o[a+1].start>=r.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<=r.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]=r,i.edited[a]=l,i.selected[a]=c,i.hovered[a]=h,t[1]=a,r.start+r.duration>this.duration&&this.setDuration(r.start+r.duration),this.onContentMoved&&this.onContentMoved(r,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=hs.TRACK_SELECTED,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"+hs.FONT,e.textAlign="left",e.textBaseline="middle";for(var r=0;r<o.length;++r){a=null;const d=o[r];var l=Math.floor(this.timeToX(d.start))+.5,c=Math.floor(this.timeToX(d.start+d.duration))+.5,h=c-l;if(c<0||l>this.canvas.width)continue;if(e.globalAlpha=1,e.fillStyle=d.clipColor||(i.hovered[r]?hs.KEYFRAME_COLOR_HOVERED:i.selected[r]?hs.TRACK_SELECTED:hs.KEYFRAME_COLOR),this.active&&i.active&&d.active||(e.fillStyle=hs.KEYFRAME_COLOR_INACTIVE),ps(e,l,t+n,h,s,5,!0),this.active&&i.active&&d.active){if(e.fillStyle=d.fadeColor??"#0004",null!=d.fadein){ps(e,l,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);ps(e,l+h-i,t+n,i,s,{tl:0,bl:0,tr:5,br:5},!0)}}e.fillStyle=hs.TRACK_COLOR_PRIMARY,(i.selected[r]||i.hovered[r])&&(e.strokeStyle=e.shadowColor=d.clipColor||hs.TRACK_SELECTED,e.shadowBlur=10,e.shadowOffsetX=1.5,e.shadowOffsetY=1.5,a=[l-1,t+n-1,c-l+2,s+2],ps(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 "+hs.FONT,e.fillStyle=hs.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,l+.5*(h-p),t+n+.5*s),e.fillStyle=i.hovered[r]?"white":"#f5f5f5",e.strokeStyle="rgba(125,125,125,0.4)",ps(e,l+h-8,t+n,8,s,{tl:4,bl:4,tr:4,br:4},!0,!0)}e.font="12px"+hs.FONT}optimizeTrack(e){}optimizeTracks(){}addClip(t,s=-1,i=0,o=0){if(!this.animationClip)return-1;this.deselectAllElements();let n=t.start+i;if(null!=t.fadein&&(t.fadein+=n-t.start),null!=t.fadeout&&(t.fadeout+=n-t.start),t.start=n,t.active=t.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=>e.LX.compareThresholdRange(n,t.start+t.duration,s.start,s.start+s.duration))){s=i;break}}s<0&&(s=this.addNewTrack())}t.trackIdx=s;const a=this.animationClip.tracks[s];let r=a.clips.findIndex(e=>e.start>n);return r<0&&(r=a.clips.length),this.saveState(s),a.clips.splice(r,0,t),a.hovered.splice(r,0,!1),a.selected.splice(r,0,!1),a.edited.splice(r,0,!1),(!this.animationClip||t.start+t.duration>this.duration)&&this.setDuration(t.start+t.duration),this.onUpdateTrack&&this.onUpdateTrack([s]),r}addClips(t,s=0,i=0){if(!this.animationClip||!t.length)return!1;let o=new Int16Array(t.length),n=i-1,a=-1;const r=this.animationClip.tracks,l=r.length;let c=0;for(;c<t.length;++c){const i=t[c],l=i.start+s,h=l+i.duration;if(0==c){for(++n,a=n;a>=r.length;)this.addNewTrack(null,!1);if(r[n].clips.find(t=>e.LX.compareThresholdRange(l,h,t.start,t.start+t.duration))){c=-1;continue}o[c]=n}else{let i=r[a].clips.find(t=>e.LX.compareThresholdRange(l,h,t.start,t.start+t.duration));for(let n=c-1;n>-1&&(o[n]==a&&!i);--n)i=e.LX.compareThresholdRange(l,h,t[n].start+s,t[n].start+s+t[n].duration);if(i&&(++a,a>=r.length&&this.addNewTrack(null,!1),i=r[a].clips.find(t=>e.LX.compareThresholdRange(l,h,t.start,t.start+t.duration))),i){c=-1;continue}o[c]=a}}l!=r.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<t.length;++c)this.addClip(t[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,us.CLONEREASON_COPY)}pasteContent(e=this.currentTime){if(this.deselectAllClips(),!this.clipboard)return;e=Math.max(0,e);let t=this.cloneClips(this.clipboard,e,us.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,us.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 ps(e,t,s,i,o,n=5,a=!1,r=!1){if("number"==typeof n)n={tl:n,tr:n,br:n,bl:n};else{var l={tl:0,tr:0,br:0,bl:0};for(var c in l)n[c]=n[c]??l[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(),r&&e.stroke()}if(e.LX.ClipsTimeline=us,!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("VideoEditor");const ms=e.LX.vec2;e.LX.Area,e.LX.Panel;class gs{static TIMEBAR_PLAY=1;static TIMEBAR_TRIM=2;static BACKGROUND_COLOR=e.LX.getCSSVariable("secondary");static COLOR=e.LX.getCSSVariable("accent");static ACTIVE_COLOR=e.LX.getCSSVariable("color-blue-400");type=gs.TIMEBAR_PLAY;duration=1;canvas;ctx;options;markerWidth=8;markerHeight;offset;lineWidth;lineHeight;linePosition;startX;endX;currentX;hovering;dragging;_onMouseUpListener;_onMouseMoveListener;_mouseDownCanvasRect=null;updateTheme;onChangeCurrent;onChangeStart;onChangeEnd;onDraw;onMouse;constructor(t,s,i={}){this.type=s??gs.TIMEBAR_PLAY,this.options=i??{},this.duration=i.duration??this.duration,this.canvas=document.createElement("canvas"),this.canvas.style.borderRadius="6px",this.canvas.width=t.size[0],this.canvas.height=t.size[1],t.attach(this.canvas),this.ctx=this.canvas.getContext("2d"),this.markerWidth=i.markerWidth??this.markerWidth,this.markerHeight=(i.markerHeight??.5)*this.canvas.height;const o=.5*this.markerWidth+5;"number"==typeof i.offset?this.offset=new ms(i.offset,i.offset):Array.isArray(i.offset)?this.offset=new ms(i.offset[0]??o,i.offset[1]??o):this.offset=new ms(o,o),this.lineWidth=this.canvas.width-2*this.offset.x,this.lineHeight=i.barHeight??5,this.linePosition=new ms(this.offset.x,.5*this.canvas.height-.5*this.lineHeight),this.startX=this.linePosition.x,this.endX=this.linePosition.x+this.lineWidth,this.currentX=this.startX,this._draw(),this.updateTheme=function(){gs.BACKGROUND_COLOR=e.LX.getCSSVariable("secondary"),gs.COLOR=e.LX.getCSSVariable("accent"),gs.ACTIVE_COLOR=e.LX.getCSSVariable("color-blue-400")}.bind(this),e.LX.addSignal("@on_new_color_scheme",this.updateTheme),this.updateTheme(),this._onMouseUpListener=this.onMouseUp.bind(this),this._onMouseMoveListener=this.onMouseMove.bind(this),this.canvas.onmousedown=e=>this.onMouseDown(e),this.canvas.onmousemove=e=>{this.dragging||this.onMouseMove(e)}}unbind(){removeEventListener("mousemove",this._onMouseMoveListener),removeEventListener("mouseup",this._onMouseUpListener)}setDuration(e){this.duration=e}xToTime(e){return(e-this.offset.x)/this.lineWidth*this.duration}timeToX(e){return e/this.duration*this.lineWidth+this.offset.x}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=gs.BACKGROUND_COLOR,e.clearRect(0,0,this.canvas.width,this.canvas.height),e.fillRect(0,0,this.canvas.width,this.canvas.height),e.fillStyle=gs.COLOR,e.fillRect(this.linePosition.x,this.linePosition.y,this.lineWidth,this.lineHeight),e.fillStyle=gs.ACTIVE_COLOR,e.fillRect(this.startX,this.linePosition.y,this.endX-this.startX,this.lineHeight),e.restore(),this._drawTrimMarker("start",this.startX,{color:null,fillColor:gs.ACTIVE_COLOR||"#5f88c9"}),this._drawTrimMarker("end",this.endX,{color:null,fillColor:gs.ACTIVE_COLOR||"#5f88c9"}),this._drawTimeMarker("current",this.currentX,{color:"#e5e5e5",fillColor:gs.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.y;const o=s.width?s.width:this.dragging==e?6:4;this.canvas.height,this.offset.y;let n=this.ctx;n&&(n.globalAlpha=1,n.fillStyle=n.strokeStyle=s.fillColor||"#111",this.hovering==e&&(n.shadowColor="white",n.shadowBlur=2),n.fillStyle=n.strokeStyle="white",n.beginPath(),n.moveTo(t,i),n.lineTo(t,this.linePosition.y+.5*this.lineHeight),n.stroke(),n.closePath(),n.fillStyle=n.strokeStyle=s.fillColor||"#111",n.fillStyle=s.fillColor||"#e5e5e5",n.beginPath(),n.roundRect(t-.5*o,i-.5*o,o,o,5),n.fill(),n.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,n=Math.abs(this.startX-s),a=Math.abs(this.endX-s);(n<o||a<o)&&this.linePosition.y<i?(this.dragging=n<a||s<this.startX?"start":"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._mouseDownCanvasRect=t.getBoundingClientRect(),window.addEventListener("mousemove",this._onMouseMoveListener),window.addEventListener("mouseup",this._onMouseUpListener),this._draw()}onMouseUp(e){if(window.removeEventListener("mousemove",this._onMouseMoveListener),window.removeEventListener("mouseup",this._onMouseUpListener),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-this._mouseDownCanvasRect.left;if(e.target==t?e.offsetY:(e.clientY,this._mouseDownCanvasRect.top),this.dragging){switch(this.dragging){case"start":this.startX=Math.max(this.linePosition.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.linePosition.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]),this.markerHeight=(this.options.markerHeight??.5)*this.canvas.height;let t=e[0]-2*this.offset.x;t=t<1e-5?1e-5:t;const s=(this.startX-this.offset.x)/this.lineWidth,i=(this.currentX-this.offset.x)/this.lineWidth,o=(this.endX-this.offset.x)/this.lineWidth;this.lineWidth=t,this.linePosition.x=this.offset.x,this.linePosition.y=.5*this.canvas.height-.5*this.lineHeight,this.startX=Math.min(Math.max(t*s,0),t)+this.offset.x,this.currentX=Math.min(Math.max(t*i,0),t)+this.offset.x,this.endX=Math.min(Math.max(t*o,0),t)+this.offset.x,this._draw()}}e.LX.TimeBar=gs;class fs{static CROP_HANDLE_L=1;static CROP_HANDLE_R=2;static CROP_HANDLE_T=4;static CROP_HANDLE_B=8;static CROP_HANDLE_TL=fs.CROP_HANDLE_L|fs.CROP_HANDLE_T;static CROP_HANDLE_BL=fs.CROP_HANDLE_L|fs.CROP_HANDLE_B;static CROP_HANDLE_TR=fs.CROP_HANDLE_R|fs.CROP_HANDLE_T;static CROP_HANDLE_BR=fs.CROP_HANDLE_R|fs.CROP_HANDLE_B;options={};playing=!1;videoReady=!1;controls=!0;speed=1;startTime=0;endTime=0;requestId;video;loop=!1;isDragging=!1;isResizing=null;crop=!1;dragOffsetX=0;dragOffsetY=0;timebar=null;mainArea;cropArea;videoArea;controlsArea;controlsComponents;onChangeCurrent;onChangeStart;onChangeEnd;onKeyUp;onSetTime;onVideoLoaded;onResize;onCropArea;onChangeSpeed;onChangeState;onChangeLoop;_updateTime=!0;_onCropMouseUp;_onCropMouseMove;resize=null;resizeControls=null;resizeVideo=null;constructor(e,t={}){this.options=t??{};const s=this.options.controlsLayout??{};this.speed=t.speed??this.speed,this.mainArea=e;let i=null,o=null;t.controlsArea?(i=e,o=t.controlsArea):[i,o]=e.split({type:"vertical",sizes:[s.height?`calc(100% - ${s.height})`:"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=t.crop,this.dragOffsetX=0,this.dragOffsetY=0;let n=this.video=t.video??document.createElement("video");this.loop=t.loop??this.loop,t.src&&(this.video.src=t.src,this.loadVideo(t)),t.videoArea?(t.videoArea.root.classList.add("lexvideoeditor"),t.videoArea.root.style.position="relative",t.videoArea.attach(this.cropArea),i.attach(t.videoArea)):(i.attach(n),i.attach(this.cropArea),i.root.classList.add("lexvideoeditor")),i.root.style.position="relative",this.videoArea=i,this.controlsArea=o,this.controlsComponents={timebar:null,playBtn:null,speedBtn:null,loopBtn:null,trimStartText:null,trimEndText:null,curTimeText:null,resetCropBtn:null},this.createControls(),this.resizeVideo=()=>{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])},this.resize=()=>{this.resizeVideo(),this.resizeControls()},e.onresize=this.resize.bind(this),window.addEventListener("resize",e.onresize),this.onKeyUp=e=>{this.controls&&" "==e.key&&(e.preventDefault(),e.stopPropagation(),this.controlsComponents.playBtn?.setState(!this.playing,!1))},window.addEventListener("keyup",this.onKeyUp),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,r=t.height;if(i&fs.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,r,!1)):(this.resizeCropArea(a,r,!1),this.moveCropArea(o,n,!1))}if(i&fs.CROP_HANDLE_R&&(a=e.clientX-t.left,this.resizeCropArea(a,r,!1)),i&fs.CROP_HANDLE_T){const i=Math.min(t.bottom-4,Math.max(s.top,e.clientY));r=t.top+t.height-i,n=i,i<t.top?(this.moveCropArea(o,n,!1),this.resizeCropArea(a,r,!1)):(this.resizeCropArea(a,r,!1),this.moveCropArea(o,n,!1))}i&fs.CROP_HANDLE_B&&(r=e.clientY-t.top,this.resizeCropArea(a,r,!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}createControls(t=null){const s=this.controlsArea;t&&(this.options.controlsLayout=t);const i=this.options.controlsLayout??{};for(;s.root.children.length;)s.root.children[0].remove();s.sections.length=0,this.controlsComponents.trimStartText=new e.LX.TextInput(null,this.timeToString(this.startTime),null,{width:"100px",title:"Trimmed Start Time",disabled:!0,inputClass:"bg-none"}),this.controlsComponents.trimEndText=new e.LX.TextInput(null,this.timeToString(this.endTime),null,{width:"100px",title:"Trimmed End Time",disabled:!0,inputClass:"bg-none"}),this.controlsComponents.curTimeText=new e.LX.TextInput(null,this.video.currentTime,null,{title:"Current Time",float:"center",disabled:!0,inputClass:"bg-none"}),this.controlsComponents.resetCropBtn=new e.LX.Button("ResetCrop",null,e=>{this.moveCropArea(0,0,!0),this.resizeCropArea(1,1,!0),this.onCropArea&&this.onCropArea(this.getCroppedArea())},{width:"40px",title:"Reset Crop Area",icon:"Crop@solid",hideName:!0,className:"justify-center"+(this.crop?"":" hidden")}),this.controlsComponents.playBtn=new e.LX.Button("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(),this.onChangeState&&this.onChangeState(e)},{width:"40px",title:"Play/Pause",icon:"Play@solid",swap:"Pause@solid",hideName:!0,className:"justify-center"}),this.controlsComponents.playBtn.setState(this.playing,!0),this.controlsComponents.speedBtn=new e.LX.Button("Speed","",(t,s)=>{const i=new e.LX.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 e.LX.Popover(s.target,[i],{align:"start",side:"top",sideOffset:12})},{width:"40px",title:"Speed",hideName:!0,icon:"Timer@solid",className:"justify-center"}),this.controlsComponents.loopBtn=new e.LX.Button("","Loop",e=>{this.loop=e,this.onChangeLoop&&this.onChangeLoop(e)},{width:"40px",hideName:!0,title:"Loop",icon:"Repeat@solid",className:"justify-center",selectable:!0,selected:this.loop});let o=null;o="function"==typeof i.type?i.type:1==i.type?this._createControlsLayout_1():this._createControlsLayout_0(),this.timebar&&this.timebar.unbind(),this.timebar=this.controlsComponents.timebar=new gs(o,gs.TIMEBAR_TRIM,{offset:[12,null]}),this.timebar.onChangeCurrent=this._setCurrentTime.bind(this),this.timebar.onChangeStart=this._setStartTime.bind(this),this.timebar.onChangeEnd=this._setEndTime.bind(this);let n=1;this.video.duration===1/0||isNaN(this.video.duration)||(n=this.video.duration),this.timebar.setDuration(n),this.timebar.setEndTime(this.endTime),this.timebar.setStartTime(this.startTime),this.timebar.setCurrentTime(this.startTime),this.resizeControls()}_createControlsLayout_1(){const t=this.controlsArea,s=this.options.controlsLayout??{};let[i,o]=t.split({type:"vertical",sizes:[s.l1TimelineHeight??"50%",null],minimizable:!1,resize:!1});o.root.classList.add("relative");let n=document.createElement("p");n.style.alignContent="center",n.innerText="/";let a=e.LX.makeContainer(["fit-content","100%"],"relative flex flex-row pb-2",null,o,{float:"right"});a.appendChild(this.controlsComponents.trimStartText.root),a.appendChild(n),a.appendChild(this.controlsComponents.trimEndText.root),this.controlsComponents.trimStartText.root.querySelector("input").classList.add("text-end"),this.controlsComponents.trimStartText.root.classList.add("top-0","bottom-0"),this.controlsComponents.trimEndText.root.classList.add("top-0","bottom-0"),e.LX.makeContainer(["100%","100%"],"absolute top-0 left-0 flex flex-row justify-center items-center pb-2",null,o,{}).appendChild(this.controlsComponents.curTimeText.root);const r=o.addPanel({className:"absolute top-0 left-0 flex flex-row pl-4 pr-4 pt-1 pb-2"});return r.root.classList.remove("pad-md"),r._attachComponent(this.controlsComponents.playBtn),r._attachComponent(this.controlsComponents.speedBtn),r._attachComponent(this.controlsComponents.loopBtn),r._attachComponent(this.controlsComponents.resetCropBtn),this.controlsComponents.playBtn.root.classList.add("pl-0"),this.controlsComponents.resetCropBtn.root.classList.add("pr-0"),i.root.classList.add("p-4","pb-0"),this.resizeControls=()=>{const e=getComputedStyle(i.root);let t=parseFloat(e.paddingLeft),s=parseFloat(e.paddingRight),o=parseFloat(e.paddingTop),n=parseFloat(e.paddingBottom);this.timebar.resize([i.root.clientWidth-t-s,i.root.clientHeight-o-n])},i}_createControlsLayout_0(){const e=this.controlsArea;let[t,s]=e.split({type:"vertical",sizes:["50%",null],minimizable:!1,resize:!1});s.setSize([s.size[0],40]);let[i,o]=s.split({type:"horizontal",sizes:["92%",null],minimizable:!1,resize:!1}),[n,a]=i.split({type:"horizontal",sizes:["10%",null],minimizable:!1,resize:!1});t.addPanel({className:"flex"})._attachComponent(this.controlsComponents.curTimeText),n.root.classList.add("min-w-fit");const r=n.addPanel({className:"lexcontrolspanel p-0 pl-2"});r.root.classList.remove("pad-md"),r.sameLine(),r._attachComponent(this.controlsComponents.playBtn),r._attachComponent(this.controlsComponents.speedBtn),r._attachComponent(this.controlsComponents.loopBtn),r._attachComponent(this.controlsComponents.trimStartText),r.endLine(),o.root.classList.add("min-w-fit");const l=o.addPanel({className:"lexcontrolspanel p-0"});return l.root.classList.remove("pad-md"),l._attachComponent(this.controlsComponents.trimEndText),this.resizeControls=()=>{s.setSize([this.controlsArea.root.clientWidth,40]);let e=this.controlsArea.root.clientWidth-n.root.clientWidth-o.root.clientWidth;this.timebar.resize([e,a.root.clientHeight])},a}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&fs.CROP_HANDLE_L&&s("l",fs.CROP_HANDLE_L),e&fs.CROP_HANDLE_R&&s("r",fs.CROP_HANDLE_R),e&fs.CROP_HANDLE_T&&s("t",fs.CROP_HANDLE_T),e&fs.CROP_HANDLE_B&&s("b",fs.CROP_HANDLE_B),(e&fs.CROP_HANDLE_TL)==fs.CROP_HANDLE_TL&&s("tl",fs.CROP_HANDLE_TL),(e&fs.CROP_HANDLE_BL)==fs.CROP_HANDLE_BL&&s("bl",fs.CROP_HANDLE_BL),(e&fs.CROP_HANDLE_TR)==fs.CROP_HANDLE_TR&&s("tr",fs.CROP_HANDLE_TR),(e&fs.CROP_HANDLE_BR)==fs.CROP_HANDLE_BR&&s("br",fs.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,r=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 ${r-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,r=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 ${r}px, linear-gradient(rgba(0, 0, 0, 0.3) 0 0)`,e[t].style.webkitMaskRepeat="no-repeat"}}const l=this.cropArea.parentElement.getBoundingClientRect();this.cropArea.style.left=o-l.left+"px",this.cropArea.style.top=n-l.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.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.controlsComponents.playBtn?.setState(!1,!0))),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.controlsComponents.curTimeText?.set(this.timeToString(e)),this.onSetTime&&this.onSetTime(e),this.onChangeCurrent&&this.onChangeCurrent(e)}_setStartTime(e){this.startTime=this.video.currentTime=e,this.controlsComponents.trimStartText?.set(this.timeToString(e)),this.onSetTime&&this.onSetTime(e),this.onChangeStart&&this.onChangeStart(e)}_setEndTime(e){this.endTime=this.video.currentTime=e,this.controlsComponents.trimEndText?.set(this.timeToString(e)),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.crop=!0,this.cropArea.classList.remove("hidden"),this.controlsComponents.resetCropBtn?.root.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.crop=!1,this.cropArea.classList.add("hidden"),this.controlsComponents.resetCropBtn?.root.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.controlsComponents.playBtn?.setState(!1,!0),this.video.src="",this.timebar&&this.timebar.unbind(),window.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("mouseup",this._onCropMouseUp),document.removeEventListener("mousemove",this._onCropMouseMove)}}e.LX.VideoEditor=fs,e.AlertDialog=ce,e.Area=te,e.AreaOverlayButtons=ee,e.ArrayInput=u,e.AssetView=_t,e.Avatar=ae,e.BaseComponent=n,e.BoundingBox=Ft,e.Branch=Q,e.Button=a,e.Checkbox=m,e.ClipsTimeline=us,e.CodeEditor=bt,e.ColorInput=y,e.ComboButtons=v,e.ContextMenu=he,e.Counter=L,e.Curve=x,e.DatePicker=S,e.Dial=T,e.Dialog=le,e.DocMaker=Rt,e.DropdownMenu=de,e.FileInput=E,e.Footer=pe,e.Form=M,e.GraphEditor=Vt,e.GraphNode=qt,e.IEvent=o,e.ImUI=as,e.KeyFramesTimeline=ds,e.Knob=Et,e.Layers=A,e.List=X,e.Map2D=I,e.NodeTree=O,e.NumberInput=c,e.OTPInput=z,e.Pad=D,e.Pagination=q,e.Panel=J,e.PocketDialog=me,e.Popover=C,e.Progress=B,e.RadioGroup=H,e.RangeInput=F,e.Rate=V,e.Select=d,e.Sheet=ge,e.Sidebar=fe,e.SizeInput=$,e.Skeleton=Ce,e.Spinner=re,e.TabSections=K,e.Table=G,e.Tabs=l,e.Tags=U,e.TextArea=W,e.TextInput=h,e.TimeBar=gs,e.Timeline=hs,e.Title=Y,e.Toggle=j,e.Tokenizer=xe,e.Tour=ye,e.Tree=R,e.Vector=Z,e.VideoEditor=fs,e.addDropdownMenu=ue,e.vec2=P});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("https://cdn.jsdelivr.net/npm/tailwind-merge@3.4.0/+esm")):"function"==typeof define&&define.amd?define(["exports","https://cdn.jsdelivr.net/npm/tailwind-merge@3.4.0/+esm"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).lexgui={},e.twMerge)}(this,function(e,t){"use strict";const s=globalThis;e.LX=s.LX,e.LX||(e.LX={version:"8.3.2",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},s.LX=e.LX);const i={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"]};e.LX.LucideIconAlias={Stop:"Square",Refresh:"RefreshCw",Left:"ChevronLeft",Right:"ChevronRight",Up:"ChevronUp",Down:"ChevronDown",MenuArrows:"ChevronsUpDown",RotateForward:"RotateCw",RotateRight:"RotateCw",RotateBack:"RotateCcw",RotateLeft:"RotateCcw"},e.LX.ICONS=(()=>{const e={};for(let t in i){i[t][2].forEach(s=>e[s]=t)}return{...i,...e}})();let o=class{name;value;domEvent;constructor(e,t,s){this.name=e,this.value=t,this.domEvent=s}};e.LX.IEvent=o,e.ComponentType=void 0,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"}(e.ComponentType||(e.ComponentType={})),e.LX.ComponentType=e.ComponentType;let n=class t{type;name;customName;options;root;customIdx=-1;disabled=!1;onSetValue;onGetValue;onAllowPaste;onResize;onSetDisabled;_initialValue;static NO_CONTEXT_TYPES=[e.ComponentType.BUTTON,e.ComponentType.LIST,e.ComponentType.FILE,e.ComponentType.PROGRESS];constructor(t,s,i,o={}){this.type=t,this.name=s,this.options=o,this._initialValue=i;const n=e.LX.makeElement("div",e.LX.mergeClass("lexcomponent flex flex-row outline-none items-center text-foreground text-sm overflow-hidden min-h-8 pad-sm",o.className));if(this.onResize=()=>{},o.id&&(n.id=o.id),o.title&&(n.title=o.title),t!=e.ComponentType.TITLE&&(o.width&&(n.style.width=n.style.minWidth=o.width),o.maxWidth&&(n.style.maxWidth=o.maxWidth),o.minWidth&&(n.style.minWidth=o.minWidth),o.height&&(n.style.height=n.style.minHeight=o.height),e.LX.componentResizeObserver.observe(n)),null!=s){if(!o.hideName){let t=e.LX.makeElement("div","lexcomponentname flex text-sm text-secondary-foreground justify-between whitespace-nowrap overflow-hidden",s);o.justifyName&&t.classList.add("float-"+o.justifyName),t.title=o.title??t.innerHTML,t.style.width=o.nameWidth||e.LX.DEFAULT_NAME_WIDTH,t.style.minWidth=t.style.width,n.appendChild(t),n.domName=t;const a=this;t.addEventListener("contextmenu",function(e){e.preventDefault(),a.oncontextmenu(e)}),o.skipReset||null==i||this._addResetProperty(t,function(e,t){a.set(a._initialValue,!1,t),e.style.display="none"})}}else o.hideName=!0;o.signal&&e.LX.addSignal(o.signal,this),this.root=n,this.root.jsInstance=this,this.disabled=o.disabled??!1,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(t,s){const i=e.LX.makeIcon("Undo2",{iconClass:"ml-0 mr-1 px-1",title:"Reset"});return i.style.display="none",i.addEventListener("click",s.bind(i,i)),t.appendChild(i),i}_canPaste(){const t=navigator.clipboard;let s=this.type===e.ComponentType.CUSTOM?void 0!==t.customIdx&&this.customIdx==t.customIdx:t.type===this.type;return s=s&&!0!==this.disabled,this.onAllowPaste&&(s=this.onAllowPaste(s)),s}_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){t.NO_CONTEXT_TYPES.includes(this.type)||e.LX.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 e.ComponentType.TEXT:return"Text";case e.ComponentType.TEXTAREA:return"TextArea";case e.ComponentType.BUTTON:return"Button";case e.ComponentType.SELECT:return"Select";case e.ComponentType.CHECKBOX:return"Checkbox";case e.ComponentType.TOGGLE:return"Toggle";case e.ComponentType.RADIO:return"Radio";case e.ComponentType.COLOR:return"Color";case e.ComponentType.RANGE:return"Range";case e.ComponentType.NUMBER:return"Number";case e.ComponentType.VECTOR:return"Vector";case e.ComponentType.TREE:return"Tree";case e.ComponentType.PROGRESS:return"Progress";case e.ComponentType.FILE:return"File";case e.ComponentType.LAYERS:return"Layers";case e.ComponentType.ARRAY:return"Array";case e.ComponentType.LIST:return"List";case e.ComponentType.TAGS:return"Tags";case e.ComponentType.CURVE:return"Curve";case e.ComponentType.KNOB:return"Knob";case e.ComponentType.SIZE:return"Size";case e.ComponentType.PAD:return"Pad";case e.ComponentType.FORM:return"Form";case e.ComponentType.DIAL:return"Dial";case e.ComponentType.COUNTER:return"Counter";case e.ComponentType.TABLE:return"Table";case e.ComponentType.TABS:return"Tabs";case e.ComponentType.DATE:return"Date";case e.ComponentType.MAP2D:return"Map2D";case e.ComponentType.RATE:return"Rate";case e.ComponentType.LABEL:return"Label";case e.ComponentType.BLANK:return"Blank";case e.ComponentType.CUSTOM:return this.customName}console.error(`Unknown Component type: ${this.type}`)}setDisabled(e){this.disabled=e,this.onSetDisabled&&this.onSetDisabled(e)}refresh(e){}};e.LX.BaseComponent=n;class a extends n{selectable=!1;callback;setState;swap;constructor(t,s,i,n={}){super(e.ComponentType.BUTTON,t,null,n),this.callback=i,this.selectable=n.selectable??this.selectable,this.onGetValue=()=>{const t=e.LX.hasClass(a,"selected"),i=a.querySelector("input");return i?i.checked:this.selectable?t:s},this.onSetValue=(t,s,i)=>{if(n.swap)this.setState(t,s);else if(a.innerHTML="",n.icon){const t=e.LX.makeIcon(n.icon);a.prepend(t)}else if(n.img){let e=document.createElement("img");e.src=n.img,a.prepend(e)}else a.innerHTML=`${t??""}`},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=`calc( 100% - ${t})`},this.setState=function(e,r){const l=a.querySelector("input");l?l.checked=e:this.selectable&&(n.parent&&n.parent.querySelectorAll(".lexbutton.selected").forEach(e=>{e!=a&&e.classList.remove("selected")}),a.classList.toggle("selected",e)),r||this._trigger(new o(t,l?l.checked:this.selectable?e:s,null),i)};var a=e.LX.makeElement("button",e.LX.mergeClass(["lexbutton","inline-flex","items-center","justify-center","whitespace-nowrap","transition-all","disabled:pointer-events-none","disabled:opacity-50","[&_svg]:pointer-events-none","shrink-0","[&_svg]:shrink-0","outline-none","select-none","cursor-pointer","font-medium","text-sm","border-1","h-9","px-2","overflow-hidden","bg-clip-padding"].join(" "),n.buttonClass??"outline"));if(a.disabled=this.disabled,a.title=n.tooltip?"":n.title??"",this.root.appendChild(a),n.selected&&a.classList.add("selected"),n.img){let e=document.createElement("img");e.src=n.img,a.prepend(e)}else if(n.icon){const t=e.LX.makeIcon(n.icon,{iconClass:n.iconClass,svgClass:n.svgClass}),i=n.iconPosition??"cover";"cover"==i||void 0!==n.swap?a.prepend(t):(a.innerHTML=`${s||""}`,"start"==i?a.prepend(t):a.appendChild(t)),a.classList.add("justify-center")}else a.innerHTML=`${s||""}`;if(n.fileInput){const e=document.createElement("input");e.type="file",e.className="file-input",e.style.display="none",a.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"===n.fileInputType?s.readAsText(t[0]):"buffer"===n.fileInputType?s.readAsArrayBuffer(t[0]):"bin"===n.fileInputType?s.readAsBinaryString(t[0]):"url"===n.fileInputType&&s.readAsDataURL(t[0]),s.onload=e=>{i.call(this,e.target?.result,t[0])}})}let r=a;if(n.swap){a.classList.add("swap"),a.querySelector("a").classList.add("swap-off");const t=document.createElement("input");t.className="p-0 border-0",t.type="checkbox",a.prepend(t);const s=e.LX.makeIcon(n.swap,{iconClass:"swap-on"});a.appendChild(s),this.swap=function(e){const t=a.querySelector("input");t.checked=!t.checked,e||r.click()}}r.addEventListener("click",r=>{let l;if(this.selectable&&(n.parent&&n.parent.querySelectorAll(".lexbutton.selected").forEach(e=>{e!=a&&e.classList.remove("selected")}),l=a.classList.toggle("selected")),n.fileInput)a.querySelector(".file-input").click();else if(n.mustConfirm){const l=a.querySelector("input");new e.LX.PopConfirm(a,{onConfirm:()=>{n.swap&&(l.checked=!0),this._trigger(new o(t,s,r),i)},side:n.confirmSide,align:n.confirmAlign,confirmText:n.confirmText,cancelText:n.confirmCancelText,title:n.confirmTitle,content:n.confirmContent}),n.swap&&(l.checked=!1)}else{const e=a.querySelector("input");this._trigger(new o(t,e?.checked??(this.selectable?l:s),r),i)}}),n.tooltip&&e.LX.asTooltip(a,n.title??t),e.LX.doAsync(this.onResize.bind(this))}click(){this.root.querySelector("button").click()}setSwapIcon(t){const s=this.root.querySelector(".swap-on");if(!s)return;const i=e.LX.makeIcon(t,{iconClass:"swap-on"});s.replaceWith(i)}}e.LX.Button=a;class r{root;siblingArea;buttonContainer;items=[];buttons={};icons={};shorts={};focused=!1;_currentDropdown;constructor(t,s={}){this.root=e.LX.makeElement("div","lexmenubar size-full bg-background text-foreground inline-flex gap-1 overflow-hidden text-sm font-medium"),s.float&&(this.root.className=e.LX.mergeClass(this.root.className,`justify-${s.float}`)),this.items=t??[],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 t of this.items){let s=t.name,i=e.LX.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=e.LX.addDropdownMenu(o,t.submenu??[],{side:"bottom",align:"start",onBlur:()=>{this._resetMenubar()}})};o.addEventListener("mousedown",e=>{e.preventDefault()}),o.addEventListener("mouseup",e=>{e.preventDefault();const i=t.callback;if(!i)return n(),this.focused=!0,!1;i.call(this,s,o,e)}),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(t,s,i,o={}){if(!t)throw"Set Button Name!";let n=this.buttons[t];n&&(delete this.buttons[t],e.LX.deleteElement(n.root)),n=new a(t,void 0,i,{title:t,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[t]=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 a(e,t.label,t.callback,{title:e,buttonClass:"ghost",disabled:t.disabled,icon:t.icon,hideName:!0,swap:t.swap,iconPosition:"start"});this.buttonContainer.appendChild(s.root),e&&(this.buttons[e]=s)}}}class l{static TAB_ID=0;root;area;tabs={};tabDOMs={};thumb;selected=null;folding=!1;folded=!1;onclose;constructor(t,s={}){this.onclose=s.onclose;let i=document.createElement("div");i.className="lexareatabs flex flex-row w-fit "+(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 r=document.getElementById(t+"_content");n.area.attach(r),this.classList.remove("dockingtab"),s.instance=n,s._forceSelect=!0,s.click(),n.tabs[s.dataset.name]=r}),t.root.classList.add("lexareatabscontainer");const[a,r]=t.split({type:"vertical",sizes:s.sizes??"auto",resize:!1,top:2});if(a.attach(i),s.parentClass&&i.parentElement&&(i.parentElement.className=e.LX.mergeClass(i.parentElement.className,s.parentClass)),this.area=r,this.area.root.className+=" lexareatabscontent",s.contentClass&&(this.area.root.className=e.LX.mergeClass(this.area.root.className,s.contentClass)),this.selected=null,this.root=i,s.fit){let t=document.createElement("span");t.className="lexareatab thumb",this.thumb=t,this.root.appendChild(t);new ResizeObserver(t=>{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",e.LX.flushCss(this.thumb),this.thumb.style.transition=i}}).observe(this.area.root)}if(o){this.folded=!0,this.folding=o,"up"==o&&e.LX.insertChildAtIndex(t.root,t.sections[1].root,0);new ResizeObserver(e=>{for(const s of e){const e=s.contentRect,i=t.parentArea?.sections[0].root;i.style.height="calc(100% - "+(42+e.height)+"px )"}}).observe(this.area.root),this.area.root.classList.add("folded")}}add(t,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 t=i.icon.split(" ");i.icon=e.LX.makeIcon(t[0],{svgClass:"sm "+t.slice(0).join(" ")}).innerHTML}let a=document.createElement("span");if(a.dataset.name=t,a.className="lexareatab flex flex-row gap-1"+(o?" selected":""),a.innerHTML=(i.icon??"")+t,a.id=t.replace(/\s/g,"")+l.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 t={};(i.badge.asChild??!1)&&(t.parent=a),a.innerHTML+=e.LX.badge(i.badge.content??"",i.badge.className,t)}a.selected&&(this.selected=t),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=!t.folding||!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",t=>{t.button==e.LX.MOUSE_MIDDLE_CLICK&&t.preventDefault()}),a.addEventListener("mouseup",t=>{t.preventDefault(),t.stopPropagation(),t.button==e.LX.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 r=i.indexOffset??-1;a.childIndex=this.root.childElementCount+r,e.LX.insertChildAtIndex(this.root,a,a.childIndex+1),this.area.attach(n),this.tabDOMs[t]=a,this.tabs[t]=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()}setIcon(t,s){const i=this.tabDOMs[t];if(!i)return;const o=s.split(" "),n=e.LX.makeIcon(o[0],{svgClass:"sm "+o.slice(0).join(" ")});i.innerHTML=n.innerHTML+t}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()}}e.LX.Tabs=l;class c extends n{setLimits;constructor(t,s,i,n={}){super(e.ComponentType.NUMBER,t,s,n),this.onGetValue=()=>s,this.onSetValue=(a,l,h)=>{if(isNaN(a))return;s=e.LX.clamp(+a,+c.min,+c.max),c.value=s=e.LX.round(s,n.precision);const d=r.querySelector(".lexinputslider");d&&(d.value=s),l||this._trigger(new o(t,s,h),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=n.inputWidth??`calc( 100% - ${t})`},this.setLimits=(e,t,s)=>{};var a=document.createElement("div");a.className="lexnumber",this.root.appendChild(a);let r=e.LX.makeElement("div","numberbox relative flex flex-col w-full bg-secondary rounded-lg scrollbar-hidden overflow-x-hidden","",a),l=e.LX.makeContainer(["auto","100%"],"relative flex flex-row cursor-text","",r),c=document.createElement("input");c.id="number_"+e.LX.guidGenerator(),c.className="vecinput",c.min=n.min??-1e24,c.max=n.max??1e24,c.step=n.step??"any",c.type="number",c.disabled=this.disabled,s.constructor==Number&&(s=e.LX.clamp(s,+c.min,+c.max),s=e.LX.round(s,n.precision)),c.value=c.iValue=s,l.appendChild(c);const h=e.LX.makeIcon("MoveVertical",{iconClass:"drag-icon hidden-opacity",svgClass:"sm"});if(l.appendChild(h),n.units){let t=e.LX.makeContainer(["auto","auto"],"px-2 bg-card content-center break-keep",n.units,l);c.unitBox=t}if(!n.skipSlider&&void 0!==n.min&&void 0!==n.max){let t=e.LX.makeContainer(["100%","auto"],"z-1 input-box","",r),i=document.createElement("input");i.className="lexinputslider",i.min=n.min,i.max=n.max,i.step=n.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){n.onPress&&n.onPress.bind(i)(e,i)},!1),i.addEventListener("mouseup",function(e){n.onRelease&&n.onRelease.bind(i)(e,i)},!1),t.appendChild(i),this.setLimits=(e,t,o)=>{c.min=i.min=e??c.min,c.max=i.max=t??c.max,c.step=o??c.step,i.step=o??i.step,this.set(s,!0)}}c.addEventListener("input",function(t){s=+c.valueAsNumber,s=e.LX.round(s,n.precision)},!1),c.addEventListener("wheel",e=>{if(e.preventDefault(),c!==document.activeElement)return;let t=n.step??1;e.shiftKey?t*=10:e.altKey&&(t*=.1),s=+c.valueAsNumber-t*(e.deltaY>0?1:-1),this.set(s,!1,e)},{passive:!1}),c.addEventListener("change",e=>{this.set(c.valueAsNumber,!1,e)},{passive:!1});var d=this;let u=e=>{let t=-e.movementY;if(0!=t){let i=n.step??1;e.shiftKey?i*=10:e.altKey&&(i*=.1),s=+c.valueAsNumber+i*t,this.set(s,!1,e)}e.stopPropagation(),e.preventDefault()},p=e=>{var t=d.root.ownerDocument;t.removeEventListener("mousemove",u),t.removeEventListener("mouseup",p),document.body.classList.remove("noevents"),h.classList.add("hidden-opacity"),document.pointerLockElement&&document.exitPointerLock(),n.onRelease&&n.onRelease.bind(c)(e,c)};l.addEventListener("mousedown",t=>{if(document.activeElement!=c&&t.button==e.LX.MOUSE_LEFT_CLICK){var s=d.root.ownerDocument;s.addEventListener("mousemove",u),s.addEventListener("mouseup",p),document.body.classList.add("noevents"),h.classList.remove("hidden-opacity"),t.stopImmediatePropagation(),t.stopPropagation(),document.pointerLockElement||l.requestPointerLock(),n.onPress&&n.onPress.bind(c)(t,c)}}),e.LX.doAsync(this.onResize.bind(this))}}e.LX.NumberInput=c;class h extends n{valid;input;_triggerEvent;_lastValueTriggered;constructor(t,s,i,n={}){super(e.ComponentType.TEXT,t,String(s),n),this.onGetValue=()=>s,this.onSetValue=(e,a,l)=>{let c=this._lastValueTriggered==e;n.ignoreValidation||(c=c||!this.valid(e)),c||(this._lastValueTriggered=s=e,r.value=e,delete this._triggerEvent,a||this._trigger(new o(t,e,l),i))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=n.inputWidth??`calc( 100% - ${t})`},this.valid=(t,s)=>{if(t=t??this.value(),!n.pattern)return!0;return 0==e.LX.validateValueAtPattern(t,n.pattern,s).length};let a=document.createElement("div");a.className=n.warning?" lexwarning":"",a.style.display="flex",a.style.position="relative",this.root.appendChild(a),this.disabled=(this.disabled||n.warning)??!!n.url;let r=null;if(this.disabled)n.url?(r=document.createElement("a"),r.href=n.url,r.target="_blank",r.innerHTML=s??"",r.style.textAlign=n.float??"",r.className="lextext ellipsis-overflow"):(r=document.createElement("input"),r.disabled=!0,r.className=e.LX.mergeClass("lextext ellipsis-overflow",n.inputClass));else{r=e.LX.makeElement("input",e.LX.mergeClass("lextext text-sm",n.inputClass)),r.type=n.type||"",r.setAttribute("placeholder",n.placeholder??""),n.required&&r.setAttribute("required",n.required),n.pattern&&r.setAttribute("pattern",e.LX.buildTextPattern(n.pattern));const t=n.trigger??"default";if("default"==t?(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"==t&&r.addEventListener("input",e=>{this.set(e.target.value,!1,e)}),r.addEventListener("mousedown",function(e){e.stopImmediatePropagation(),e.stopPropagation()}),n.icon){r.style.paddingLeft="1.75rem";const t=e.LX.makeIcon(n.icon,{iconClass:"absolute z-1 ml-2",svgClass:"sm"});a.appendChild(t)}}n.fit&&r.classList.add("field-sizing-content"),r instanceof HTMLInputElement&&(r.name=n.name,r.value=s??"",n.autocomplete?r.autocomplete=n.autocomplete:"password"===r.type?r.autocomplete="current-password":"username"===n.name||"email"===n.name?r.autocomplete=n.name:r.autocomplete="on",r.style.textAlign=n.float??"",r.addEventListener("transitionstart",e=>{"background-color"===e.propertyName&&r.matches(":-webkit-autofill")&&this.syncFromDOM()})),Object.assign(r.style,n.style??{}),a.appendChild(r),this.input=r,e.LX.doAsync(this.onResize.bind(this))}syncFromDOM(e=!0){this.input instanceof HTMLInputElement&&this.set(this.input.value,e)}}e.LX.TextInput=h;class d extends n{_lastPlacement=[!1,!1];constructor(t,s,i,n,r={}){super(e.ComponentType.SELECT,t,i,r),this.onGetValue=()=>i,this.onSetValue=(a,l,c)=>{i=a;let h=null;if(m.childNodes.forEach(e=>{e.classList.remove("selected"),e.getAttribute("value")==a&&(h=e)}),console.assert(h,`Item ${a} does not exist in the Select.`),h.classList.add("selected"),u.refresh(i),g){g.root.querySelector("input").value="";const e=this._filterOptions(s,"");m.refresh(e)}const d=this.root.querySelector(".lexcustomcontainer"),p=r[`on_${i}`];if(d.toggleAttribute("hidden",!p),p){d.innerHTML="";const t=new e.LX.Panel;t.queue(d),p.call(this,t),t.clearQueue()}this.root.dataset.opened=!!p,m.style.height="",l||this._trigger(new o(t,i,c),n)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=r.inputWidth??`calc( 100% - ${t})`};let l=document.createElement("div");l.className="lexselect",this.root.appendChild(l);let c=document.createElement("div");c.className="lexselect lexoption",c.name=t,c.iValue=i,void 0!==r.overflowContainer&&(r.overflowContainerX=r.overflowContainerY=r.overflowContainer);const d=(t,s)=>{const i=u.root,o=i.getBoundingClientRect(),n=t.parentElement.closest("dialog")??t.parentElement.closest(".lexcolorpicker");{const a=void 0!==r.overflowContainerY?r.overflowContainerY:e.LX.getParentArea(t),l=t.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}t.style.top=c+i.offsetHeight+"px",m.style.height="";const d=s?this._lastPlacement[0]:c-l<0,u=s?this._lastPlacement[1]:c+l>h;u&&!d?(t.style.top=c-l+"px",t.classList.add("place-above")):u&&d&&(m.style.height=h-c-32+"px"),this._lastPlacement=[d,u]}{const s=void 0!==r.overflowContainerX?r.overflowContainerX:e.LX.getParentArea(t),i=t.offsetWidth;let a=o.x;if(t.style.minWidth=o.width+"px",n){a-=n.getBoundingClientRect().x}t.style.left=a+"px";let l=window.innerWidth;if(s){const e=s.getBoundingClientRect();l=e.x+e.width}!("end"===r.align||a+i>l)||r.align&&"start"===r.align||(t.style.left=a-(i-o.width)+"px")}};let u=new a(null,i,(e,t)=>{if(m.unfocus_event)return void delete m.unfocus_event;p.classList.remove("place-above");p.hasAttribute("open")?p.close():(p.show(),d(p)),g&&g.root.querySelector("input").focus()},{buttonClass:"outline [&_a]:ml-auto",skipInlineCount:!0,disabled:this.disabled});u.root.style.width="100%",u.root.querySelector("button").appendChild(e.LX.makeIcon("Down",{svgClass:"sm"})),l.appendChild(u.root),u.refresh=e=>{const t=u.root.querySelector("button");""==t.innerText?t.innerText=e:t.innerHTML=t.innerHTML.replaceAll(t.innerText,e)};const p=document.createElement("dialog");p.className="lexselectoptions";let m=document.createElement("ul");m.tabIndex=-1,m.className="lexoptions",p.appendChild(m),m.addEventListener("focusout",function(e){if(e.stopPropagation(),e.stopImmediatePropagation(),e.relatedTarget===u.root.querySelector("button"))m.unfocus_event=!0,setTimeout(()=>delete m.unfocus_event,200);else{if(e.relatedTarget&&p.contains(e.relatedTarget))return;if("lexinput-filter"==e.target.className)return}p.close()});let g=null;if(r.filter){const t=e.LX.deepCopy(r);t.placeholder=t.placeholder??"Search...",t.skipComponent=t.skipComponent??!0,t.trigger="input",t.icon="Search",t.className="lexfilter",t.inputClass="outline",g=new h(null,r.filterValue??"",e=>{const t=this._filterOptions(s,e);m.refresh(t),d(p,!0)},t),g.root.querySelector(".lextext").style.border="1px solid transparent";g.root.querySelector("input").addEventListener("focusout",function(e){e.relatedTarget&&"UL"==e.relatedTarget.tagName&&e.relatedTarget.classList.contains("lexoptions")||p.close()}),m.appendChild(g.root)}m.refresh=t=>{for(;m.childElementCount>(r.filter?1:0);)m.removeChild(m.lastChild);if(!t.length){let t=r.emptyMsg??"No options found.",s=document.createElement("div");s.className="option",s.innerHTML=e.LX.makeIcon("Inbox",{svgClass:"mr-2"}).innerHTML+t;let i=document.createElement("li");return i.className="lexselectitem empty",i.appendChild(s),void m.appendChild(i)}for(let s=0;s<t.length;s++){let o=t[s],n=document.createElement("li"),a=document.createElement("div");a.className="option",n.appendChild(a);const r=e=>{this.set(e.currentTarget?.getAttribute("value"),!1,e),p.close()};if(n.addEventListener("click",r),o.constructor!=Object){const t="@"===o[0];t?(a.innerHTML="<span>"+o.substr(1)+"</span>",n.removeEventListener("click",r)):(a.innerHTML=`<span class="flex flex-row justify-between">${o}</span>`,a.appendChild(e.LX.makeIcon("Check")),a.value=o,n.setAttribute("value",o),o==i&&(n.classList.add("selected"),c.innerHTML=o)),n.classList.add(t?"lexselectlabel":"lexselectitem")}else{let e=document.createElement("img");e.src=o.src,n.setAttribute("value",o.value),n.className="lexlistitem",a.innerText=o.value,a.className+=" media",a.prepend(e),a.setAttribute("value",o.value),a.setAttribute("data-index",s),a.setAttribute("data-src",o.src),a.setAttribute("title",o.value),i==o.value&&n.classList.add("selected")}m.appendChild(n)}},m.refresh(s),l.appendChild(p);let f=e.LX.makeElement("div","lexcustomcontainer w-full");const C=r[`on_${i}`];if(f.toggleAttribute("hidden",!C),C){f.innerHTML="";const t=new e.LX.Panel;t.queue(f),C.call(this,t),t.clearQueue()}this.root.appendChild(f),this.root.dataset.opened=!!C,e.LX.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}}e.LX.Select=d;class u extends n{_updateItems;constructor(t,s=[],i,n={}){n.nameWidth="auto",super(e.ComponentType.ARRAY,t,null,n),this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{s=e,this._updateItems(),n||this._trigger(new o(t,s,a),i)};let r=document.createElement("div");r.className="lexarray shrink-1 grow-1 ml-4",r.style.width="auto",this.root.appendChild(r),this.root.dataset.opened=!1;let l=`Array (size ${s.length})`;const u=new a(null,l,()=>{this.root.dataset.opened="true"!=this.root.dataset.opened,this.root.querySelector(".lexarrayitems").toggleAttribute("hidden")},{buttonClass:"outline [&_a]:ml-auto"});u.root.querySelector("button").appendChild(e.LX.makeIcon("Down",{svgClass:"sm"})),r.appendChild(u.root);let p=document.createElement("div");p.className="lexarrayitems",p.toggleAttribute("hidden",!0),this.root.appendChild(p),this._updateItems=()=>{let r=this.root.querySelector("button");for(let e of r.childNodes)if(e.nodeType===Node.TEXT_NODE){e.textContent=`Array (size ${s.length})`;break}p.innerHTML="";for(let e=0;e<s.length;++e){const r=s[e];let l=n.innerValues?"select":r.constructor,u=null;switch(l){case String:u=new h(e+"",r,function(t){s[e]=t,i(s)},{nameWidth:"12px",className:"p-0",disabled:this.disabled,skipReset:!0});break;case Number:u=new c(e+"",r,function(t){s[e]=t,i(s)},{nameWidth:"12px",className:"p-0",disabled:this.disabled,skipReset:!0});break;case"select":u=new d(e+"",n.innerValues,r,function(t){s[e]=t,i(s)},{nameWidth:"12px",className:"p-0",disabled:this.disabled,skipReset:!0})}if(console.assert(u,`Value of type ${l} cannot be modified in ArrayInput`),p.appendChild(u.root),!this.disabled){const e=new a(null,"",(e,n)=>{s.splice(s.indexOf(r),1),this._updateItems(),this._trigger(new o(t,s,n),i)},{buttonClass:"ghost sm p-0",title:"Remove item",icon:"Trash2"});u.root.appendChild(e.root)}}if(!this.disabled){const r=new a(null,e.LX.makeIcon("Plus",{svgClass:"sm"}).innerHTML+"Add item",(e,a)=>{s.push(n.innerValues?n.innerValues[0]:""),this._updateItems(),this._trigger(new o(t,s,a),i)},{buttonClass:"ghost"});p.appendChild(r.root)}},this._updateItems()}}e.LX.ArrayInput=u;class p extends n{constructor(t,s={}){s.hideName=!0,super(e.ComponentType.CARD,t,null,s),this.root.classList.add("place-content-center");const i=e.LX.makeContainer(["100%","auto"],"lexcard max-w-sm flex flex-col gap-4 bg-card border-color rounded-xl py-6","",this.root);if(s.header){const t=void 0!==s.header.action;let o=e.LX.makeContainer(["100%","auto"],`flex ${t?"flex-row gap-4":"flex-col gap-1"} px-6`,"",i);if(t){const t=new a(null,s.header.action.name,s.header.action.callback,{buttonClass:"secondary"});o.appendChild(t.root);const i=e.LX.makeContainer(["75%","auto"],"flex flex-col gap-1","");o.prepend(i),o=i}s.header.title&&e.LX.makeElement("div","text-sm text-foreground leading-none font-semibold",s.header.title,o),s.header.description&&e.LX.makeElement("div","text-xs text-muted-foreground",s.header.description,o)}if(s.content){const t=e.LX.makeContainer(["100%","auto"],"flex flex-col gap-2 px-6","",i),o=[].concat(s.content);for(let e of o)t.appendChild(e.root?e.root:e)}if(s.footer){const t=e.LX.makeContainer(["100%","auto"],"flex flex-col gap-1 px-6","",i),o=[].concat(s.footer);for(let e of o)t.appendChild(e.root?e.root:e)}s.callback&&(i.classList.add("selectable"),i.style.cursor="pointer",i.addEventListener("click",e=>{this._trigger(new o(t,null,e),s.callback)}))}}e.LX.Card=p;class m extends n{constructor(t,s,i,n={}){if(!t&&!n.label)throw"Set Component Name or at least a label!";super(e.ComponentType.CHECKBOX,t,s,n),this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{e!=s&&(r.checked=s=e,this.root.querySelector(".lexcheckboxsubmenu")?.toggleAttribute("hidden",!e),n||this._trigger(new o(t,e,a),i))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=n.inputWidth??`calc( 100% - ${t})`};let a=document.createElement("div");a.className="flex items-center gap-2 my-0 mx-auto [&_span]:truncate [&_span]:flex-auto-fill",this.root.appendChild(a);let r=e.LX.makeElement("input",e.LX.mergeClass("lexcheckbox rounded-xl disabled:pointer-events-none disabled:opacity-50",n.className??"primary"));if(r.type="checkbox",r.checked=s,r.disabled=this.disabled,a.appendChild(r),e.LX.makeElement("span","text-sm",n.label??"On",a),r.addEventListener("change",e=>{this.set(r.checked,!1,e)}),n.suboptions){let t=e.LX.makeElement("div","lexcheckboxsubmenu");t.toggleAttribute("hidden",!r.checked);const s=new e.LX.Panel;s.queue(t),n.suboptions.call(this,s),s.clearQueue(),this.root.appendChild(t)}e.LX.doAsync(this.onResize.bind(this))}}e.LX.Checkbox=m;class g{_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(t){this._fromRGB(e.LX.hexToRgb(t))}_fromRGB(t){this._rgb=t,this._hsv=e.LX.rgbToHsv(t),this._hex=e.LX.rgbToHex(t),this.css=e.LX.rgbToCss(this._rgb)}_fromHSV(t){this._hsv=t,this._rgb=e.LX.hsvToRgb(t),this._hex=e.LX.rgbToHex(this._rgb),this.css=e.LX.rgbToCss(this._rgb)}}e.LX.Color=g;class f{static currentPicker=!1;root;colorModel;useAlpha;callback;markerHalfSize;markerSize;currentColor;labelComponent;colorPickerBackground;intSatMarker;colorPickerTracker;alphaTracker;hueMarker;alphaMarker;onPopover;constructor(t,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=e.LX.makeElement("div","lexcolorpicker flex flex-col text-sm w-3xs gap-2 p-1"),this.markerHalfSize=8,this.markerSize=2*this.markerHalfSize,this.currentColor=new g(t);const i=new g({h:this.currentColor.hsv.h,s:1,v:1}),o="size-4 rounded-lg bg-transparent absolute pointer-events-none border-3 border-solid border-white";this.colorPickerBackground=e.LX.makeElement("div","lexcolorpickerbg w-full aspect-square relative rounded-md cursor-pointer"),this.colorPickerBackground.style.backgroundColor=`rgb(${i.css.r}, ${i.css.g}, ${i.css.b})`,this.root.appendChild(this.colorPickerBackground),this.intSatMarker=e.LX.makeElement("div",o),this.intSatMarker.style.backgroundColor=this.currentColor.hex,this.colorPickerBackground.appendChild(this.intSatMarker);let n=null,r=t=>{const s=t.movementX,i=t.movementY,o=t.x-n.x,a=t.y-n.y;0!=s&&(o>=0||s<0)&&(o<this.colorPickerBackground.offsetWidth||s>0)&&(this.intSatMarker.style.left=e.LX.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=e.LX.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(),t.stopPropagation(),t.preventDefault()},l=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",r),t.removeEventListener("mouseup",l),document.body.classList.remove("noevents")};this.colorPickerBackground.addEventListener("mousedown",e=>{var t=this.root.ownerDocument;t.addEventListener("mousemove",r),t.addEventListener("mouseup",l),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(),n=this.colorPickerBackground.getBoundingClientRect()});const c=e.LX.makeContainer(["100%","auto"],"flex flex-row gap-1 items-center","",this.root),u=window.EyeDropper;u&&c.appendChild(new a(null,"eyedrop",async()=>{const e=new u;try{const t=await e.open();this.fromHexColor(t.sRGBHex)}catch(e){}},{icon:"Pipette",buttonClass:"bg-none",title:"Sample Color"}).root);const p=e.LX.makeContainer(["100%","100%"],"flex flex-col gap-2","",c);this.colorPickerTracker=e.LX.makeElement("div","lexhuetracker w-full h-4 rounded-lg relative cursor-pointer"),p.appendChild(this.colorPickerTracker),this.hueMarker=e.LX.makeElement("div",o),this.hueMarker.style.backgroundColor=`rgb(${i.css.r}, ${i.css.g}, ${i.css.b})`,this.colorPickerTracker.appendChild(this.hueMarker);const m=t=>{this.hueMarker.style.left=t+"px",this.currentColor.hsv.h=e.LX.remapRange(t,0,this.colorPickerTracker.offsetWidth-this.markerSize,0,360);const s=new g({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 f=null,C=t=>{const s=t.movementX,i=t.x-f.x;if(0!=s&&(i>=this.markerHalfSize||s<0)&&(i<this.colorPickerTracker.offsetWidth-this.markerHalfSize||s>0)){const t=e.LX.clamp(parseInt(this.hueMarker.style.left)+s,0,this.colorPickerTracker.offsetWidth-this.markerSize);m(t)}t.stopPropagation(),t.preventDefault()},v=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",C),t.removeEventListener("mouseup",v),document.body.classList.remove("noevents")};if(this.colorPickerTracker.addEventListener("mousedown",t=>{const s=this.root.ownerDocument;s.addEventListener("mousemove",C),s.addEventListener("mouseup",v),document.body.classList.add("noevents"),t.stopImmediatePropagation(),t.stopPropagation();const i=e.LX.clamp(t.offsetX-this.markerHalfSize,0,this.colorPickerTracker.offsetWidth-this.markerSize);m(i),f=this.colorPickerTracker.getBoundingClientRect()}),this.useAlpha){this.alphaTracker=e.LX.makeElement("div","lexalphatracker w-full h-4 rounded-lg relative cursor-pointer"),this.alphaTracker.style.color=`rgb(${this.currentColor.css.r}, ${this.currentColor.css.g}, ${this.currentColor.css.b})`,p.appendChild(this.alphaTracker),this.alphaMarker=e.LX.makeElement("div",o),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 t=t=>{this.alphaMarker.style.left=t+"px",this.currentColor.hsv.a=e.LX.remapRange(t,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 o=this.root.ownerDocument;o.addEventListener("mousemove",n),o.addEventListener("mouseup",a),document.body.classList.add("noevents"),i.stopImmediatePropagation(),i.stopPropagation();const r=e.LX.clamp(i.offsetX-this.markerHalfSize,0,this.alphaTracker.offsetWidth-this.markerSize);t(r),s=this.alphaTracker.getBoundingClientRect()},n=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=e.LX.clamp(parseInt(this.alphaMarker.style.left)+o,0,this.alphaTracker.offsetWidth-this.markerSize);t(s)}i.stopPropagation(),i.preventDefault()},a=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",n),t.removeEventListener("mouseup",a),document.body.classList.remove("noevents")};this.alphaTracker.addEventListener("mousedown",i)}const y=e.LX.makeContainer(["100%","auto"],"flex flex-row gap-1","",this.root);y.appendChild(new d(null,["CSS","Hex","HSV","RGB"],this.colorModel,e=>{this.colorModel=e,this._updateColorValue(null,!0)}).root),this.labelComponent=new h(null,"",null,{inputClass:"bg-none",fit:!0,disabled:!0}),y.appendChild(this.labelComponent.root);{const t=new a(null,"copy",async()=>{navigator.clipboard.writeText(this.labelComponent.value()),t.root.querySelector("input[type='checkbox']").style.pointerEvents="none",e.LX.doAsync(()=>{t.swap&&t.swap(!0),t.root.querySelector("input[type='checkbox']").style.pointerEvents="auto"},3e3)},{swap:"Check",icon:"Copy",buttonClass:"bg-none",className:"ml-auto",title:"Copy"});t.root.querySelector(".swap-on svg").classList.add("text-success"),y.appendChild(t.root)}this._updateColorValue(t,!0),e.LX.doAsync(this._placeMarkers.bind(this)),this.onPopover=this._placeMarkers.bind(this)}_placeMarkers(){this._svToPosition(this.currentColor.hsv.s,this.currentColor.hsv.v);const t=e.LX.remapRange(this.currentColor.hsv.h,0,360,0,this.colorPickerTracker.offsetWidth-this.markerSize);if(this.hueMarker.style.left=t+"px",this.useAlpha){const t=e.LX.remapRange(this.currentColor.hsv.a,0,1,0,this.alphaTracker.offsetWidth-this.markerSize);this.alphaMarker.style.left=t+"px"}}_svToPosition(t,s){this.intSatMarker.style.left=`${e.LX.remapRange(t,0,1,-this.markerHalfSize,this.colorPickerBackground.offsetWidth-this.markerHalfSize)}px`,this.intSatMarker.style.top=`${e.LX.remapRange(1-s,0,1,-this.markerHalfSize,this.colorPickerBackground.offsetHeight-this.markerHalfSize)}px`}_positionToSv(t,s){this.currentColor.hsv.s=e.LX.remapRange(t,-this.markerHalfSize,this.colorPickerBackground.offsetWidth-this.markerHalfSize,0,1),this.currentColor.hsv.v=1-e.LX.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(t){this.currentColor.setHex(t);const{h:s,s:i,v:o}=this.currentColor.hsv;this._svToPosition(i,o);const n=new g({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=e.LX.remapRange(s,0,360,-this.markerHalfSize,this.colorPickerTracker.offsetWidth-this.markerHalfSize)+"px",this._updateColorValue(t)}}e.LX.ColorPicker=f;class C{static activeElement=null;root;side="bottom";align="center";sideOffset=0;alignOffset=0;avoidCollisions=!0;reference;_windowPadding=4;_trigger;_parent;_onClick;constructor(t,s,i={}){if(C.activeElement)return void C.activeElement.destroy();this._trigger=t,t&&(t.classList.add("triggered"),t.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=e.LX.makeElement("div","lexpopover fixed bg-background rounded-lg border-color p-1 left-0 top-0"),this.root.dataset.side=this.side,this.root.tabIndex="1";const o=(t??this.reference).closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=e.LX.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()}),C.activeElement=this,e.LX.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(),C.activeElement=null}_adjustPosition(){const t=[0,0];{const e=this.reference??this._trigger;console.assert(e,"Popover needs a trigger or reference element!");const s=e.getBoundingClientRect();let i=!0;switch(this.side){case"left":t[0]+=s.x-this.root.offsetWidth-this.sideOffset,i=!1;break;case"right":t[0]+=s.x+s.width+this.sideOffset,i=!1;break;case"top":t[1]+=s.y-this.root.offsetHeight-this.sideOffset,i=!0;break;case"bottom":t[1]+=s.y+s.height+this.sideOffset,i=!0}switch(this.align){case"start":i?t[0]+=s.x:t[1]+=s.y;break;case"center":i?t[0]+=s.x+.5*s.width-.5*this.root.offsetWidth:t[1]+=s.y+.5*s.height-.5*this.root.offsetHeight;break;case"end":i?t[0]+=s.x-this.root.offsetWidth+s.width:t[1]+=s.y-this.root.offsetHeight+s.height}i?t[0]+=this.alignOffset:t[1]+=this.alignOffset}if(this.avoidCollisions&&(t[0]=e.LX.clamp(t[0],0,window.innerWidth-this.root.offsetWidth-this._windowPadding),t[1]=e.LX.clamp(t[1],0,window.innerHeight-this.root.offsetHeight-this._windowPadding)),this._parent instanceof HTMLDialogElement){let e=this._parent.getBoundingClientRect();t[0]-=e.x,t[1]-=e.y}this.root.style.left=`${t[0]}px`,this.root.style.top=`${t[1]}px`}}e.LX.Popover=C;e.LX.PopConfirm=class{_popover=null;constructor(t,s={}){const i=s.confirmText??"Yes",o=s.cancelText??"No",n=s.title??"Confirm",a=s.content??"Are you sure you want to proceed?",r=s.onConfirm,l=s.onCancel,c=e.LX.makeContainer(["auto","auto"],"tour-step-container");{const t=e.LX.makeContainer(["100%","auto"],"flex flex-row","",c);e.LX.makeContainer(["100%","auto"],"p-1 font-medium text-base",n,t)}e.LX.makeContainer(["100%","auto"],"p-1 text-base",a,c,{maxWidth:"400px"});const h=e.LX.makeContainer(["100%","auto"],"flex flex-row text-base","",c),d=e.LX.makeContainer(["100%","auto"],"text-base","",h),u=new e.LX.Panel;d.appendChild(u.root),u.sameLine(2,"justify-end"),u.addButton(null,o,()=>{l&&l(),this._popover?.destroy()}),u.addButton(null,i,()=>{r&&r(),this._popover?.destroy()},{buttonClass:"accent"}),this._popover?.destroy(),this._popover=new e.LX.Popover(null,[c],{reference:t,side:s.side??"top",align:s.align,sideOffset:s.sideOffset,alignOffset:s.alignOffset})}};class v extends n{picker;_skipTextUpdate=!1;_popover=void 0;constructor(t,s,i,n={}){(s=s??"#000000").constructor===String&&s.includes("oklch")&&(s=e.LX.oklchToHex(s));const a=n.useAlpha??(s.constructor===Object&&"a"in s||s.constructor===String&&[5,9].includes(s.length)),r=new g(s);s=a?r.hex:r.hex.substring(0,7),super(e.ComponentType.COLOR,t,s,n),this.onGetValue=()=>{const e=new g(s);return n.useRGB?e.rgb:s},this.onSetValue=(e,r,l)=>{const c=new g(e);if(d.style.color=s=c.hex.substring(0,7),a&&(u.style.color=s=c.hex),this._skipTextUpdate||p.set(s,!0,l),!r){let e=s;n.useRGB&&(e=c.rgb,a||delete e.a),this._trigger(new o(t,e,l),i)}},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};var l=document.createElement("span");l.className="lexcolor",this.root.appendChild(l),this.picker=new f(s,{colorModel:n.useRGB?"RGB":"Hex",useAlpha:a,onChange:e=>{this.set(e.hex)}});let c=e.LX.makeContainer(["18px","18px"],"flex flex-row rounded overflow-hidden","",l);c.tabIndex="1",c.addEventListener("click",e=>{this.disabled||(this._popover=new C(c,[this.picker]))});let d=document.createElement("div");d.className="lexcolorsample",d.style.color=s,c.appendChild(d);let u=null;a?(u=document.createElement("div"),u.className="lexcolorsample",u.style.color=s,c.appendChild(u)):d.style.width="18px";const p=new h(null,s,e=>{this._skipTextUpdate=!0,this.set(e),delete this._skipTextUpdate,this.picker.fromHexColor(e)},{width:"calc( 100% - 24px )",disabled:this.disabled});p.root.style.marginLeft="6px",l.appendChild(p.root),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Color=g,e.LX.ColorPicker=f,e.LX.ColorInput=v;class y extends n{constructor(t,s,i={}){const n=!i.noSelection;let r=n&&(i.toggle??!1),l=document.createElement("div");l.className="lexcombobuttons flex justify-center",i.skipReset=!0,i.float&&(l.className=e.LX.mergeClass(l.className,`justify-${i.float}`));let c=[],h=e.LX.makeElement("div","flex w-max bg-secondary pad-sm rounded-lg gap-1","",l);for(let t of s){if(!t.value)throw"Set 'value' for each button!";const s=e=>{c=[],n&&(r?o.classList.toggle("selected"):(l.querySelectorAll("button").forEach(e=>e.classList.remove("selected")),o.classList.add("selected"))),l.querySelectorAll("button").forEach(e=>{e.classList.contains("selected")&&c.push(e.dataset.value)}),!r&&c.length>1?console.error("Enable _options.toggle_ to allow selecting multiple options in ComboButtons."):(c=c[0],this.set(t.value,!1,o.classList.contains("selected")))};let o=new a(t.name??null,t.value,s,{title:t.icon?t.value:"",icon:t.icon,disabled:t.disabled,buttonClass:e.LX.mergeClass("combo w-auto",i.buttonClass)}).root.querySelector("button");o.id=t.id??"",o.dataset.value=t.value,n&&(t.selected||i.selected?.includes(t.value))&&(o.classList.add("selected"),c=c.concat([t.value])),h.appendChild(o)}c.length>1?r||(i.toggle=!0,r=n,console.warn(`Multiple options selected in '${t}' ComboButtons. Enabling _toggle_ mode.`)):c=c[0],super(e.ComponentType.BUTTONS,t,null,i),this.onGetValue=()=>c,this.onSetValue=(e,i,a)=>{if(n&&null==a&&(l.querySelectorAll("button").forEach(e=>e.classList.remove("selected")),l.querySelectorAll("button").forEach(e=>{c&&c.indexOf(e.dataset.value)>-1&&e.classList.add("selected")})),!i&&e.constructor!=Array){const i=a,n=s.filter(t=>t.value==e)[0]?.callback;this._trigger(new o(t,r?[e,i]:e,null),n)}},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`},this.root.appendChild(l),e.LX.doAsync(this.onResize.bind(this))}}e.LX.ComboButtons=y;class L extends n{count;constructor(t,s,i,n={}){super(e.ComponentType.COUNTER,t,s,n),this.onGetValue=()=>this.count,this.onSetValue=(s,n,a)=>{this.count=e.LX.clamp(s,r,l),d.value=this.count,n||this._trigger(new o(t,s,a),i)},this.count=s;const r=n.min??0,l=n.max??100,c=n.step??1,h=document.createElement("div");h.className="flex flex-row border-color bg-card rounded-lg shadow",this.root.appendChild(h);const d=e.LX.makeElement("input","lexcounter w-12 bg-card px-2 text-foreground","",h);d.type="number",d.value=s,d.disabled=this.disabled;const u=new a(null,"",(e,t)=>{let s=c??1;t.shiftKey&&(s*=10),this.set(this.count-s,!1,t)},{disabled:this.disabled,className:`p-0 ${this.disabled?"":"hover:bg-secondary"} border-l-color border-r-color`,buttonClass:"px-0 bg-none h-7",icon:"Minus"});h.appendChild(u.root);const p=new a(null,"",(e,t)=>{let s=c??1;t.shiftKey&&(s*=10),this.set(this.count+s,!1,t)},{disabled:this.disabled,className:`p-0 ${this.disabled?"":"hover:bg-secondary"} rounded-r-lg`,buttonClass:"px-0 bg-none h-7",icon:"Plus"});h.appendChild(p.root)}}e.LX.Counter=L;class b{element;canvas;constructor(t,s={}){let i=document.createElement("div");i.className=e.LX.mergeClass("curve [&_canvas]:rounded",s.className),i.style.minHeight="50px",i.style.width=s.width||"100%",i.style.minWidth="50px",i.style.minHeight="20px",i.bgcolor=s.bgColor||e.LX.getCSSVariable("background"),i.pointscolor=s.pointsColor||e.LX.getCSSVariable("primary"),i.activepointscolor=s.activePointsColor||e.LX.getCSSVariable("primary/50"),i.linecolor=s.lineColor||"#555",i.value=t||[],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??e.LX.CURVE_MOVEOUT_DELETE,e.LX.addSignal("@on_new_color_scheme",(t,o)=>{i.bgcolor=s.bgColor||e.LX.getCSSVariable("background"),i.pointscolor=s.pointsColor||e.LX.getCSSVariable("primary"),i.activepointscolor=s.activePointsColor||e.LX.getCSSVariable("primary/50"),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(t){document.addEventListener("mousemove",c),document.addEventListener("mouseup",h);var s=o.getBoundingClientRect(),d=t.clientX-s.left,m=t.clientY-s.top;if(r=function(e,t){for(var s=1e5,o=-1,a=0;a<i.value.length;a++){var r=u([e,t],n(i.value[a]));r<s&&r<8&&(s=r,o=a)}return o}(d,o.height-m),t.button==e.LX.MOUSE_LEFT_CLICK&&-1==r&&i.allow_add_values){var g=a([d,o.height-m]);i.value.push(g),p(),r=i.value.indexOf(g)}l=[d,m],i.redraw(),t.preventDefault(),t.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 r=-1;i.redraw=function(t={}){t.value&&(i.value=t.value),t.xrange&&(i.xrange=t.xrange),t.yrange&&(i.yrange=t.yrange),t.smooth&&(i.smooth=t.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 l=[a[0],a[1]];for(var c in i.value){a=n(i.value[c]),l.push(a[0]),l.push(a[1]),i.smooth||s.lineTo(a[0],a[1])}a=n([i.xrange[1],i.defaulty]),l.push(a[0]),l.push(a[1]),i.smooth?e.LX.drawSpline(s,l,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==r;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 l=[0,0];function c(t){var s=o.getBoundingClientRect(),n=t.clientX-s.left,c=t.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=[t.clientX-s.left,t.clientY-s.top];if(-1!=r&&u(m,[n,c])>.5*o.height){if(i.move_out==e.LX.CURVE_MOVEOUT_DELETE)i.value.splice(r,1);else{const e=[m[0]-n,m[1]-c];let t=i.value[r];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(t)}else{var g=a([-(i.draggable_x?l[0]-n:0),i.draggable_y?l[1]-c:0]);if(-1!=r){var f=i.xrange[0],C=i.xrange[1];i.no_overlap&&(r>0&&(f=i.value[r-1][0]),r<i.value.length-1&&(C=i.value[r+1][0]));var v=i.value[r];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(),l[0]=n,l[1]=c,d(t),t.preventDefault(),t.stopPropagation()}}function h(e){r=-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!=r&&(e=i.value[r]),i.value.sort(function(e,t){return e[0]-t[0]}),e&&(r=i.value.indexOf(e))}return i.redraw(),this}redraw(e={}){this.element.redraw(e)}}class x extends n{curveInstance;constructor(t,s,i,n={}){let a=JSON.parse(JSON.stringify(s));super(e.ComponentType.CURVE,t,a,n),this.onGetValue=()=>JSON.parse(JSON.stringify(l.element.value)),this.onSetValue=(e,s,n)=>{l.element.value=JSON.parse(JSON.stringify(e)),l.redraw(),s||this._trigger(new o(t,l.element.value,n),i)},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),n.callback=(e,s)=>{this._trigger(new o(t,e,s),i)},n.name=t;let l=new b(s,n);r.appendChild(l.element),this.curveInstance=l;new ResizeObserver(e=>{for(const t of e)l.canvas.width=t.contentRect.width,l.redraw()}).observe(r),e.LX.doAsync(this.onResize.bind(this))}}e.LX.CanvasCurve=b,e.LX.Curve=x;class _{root;day=-1;month=-1;year=-1;monthName="";firstDay=-1;daysInMonth=-1;calendarDays=[];currentDate;range;untilToday;fromToday;skipPrevMonth;skipNextMonth;onChange;onPreviousMonth;onNextMonth;constructor(t,s={}){if(this.root=e.LX.makeContainer(["256px","auto"],"p-1 flex flex-col gap-2 text-sm"),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,t)this.fromDateString(t);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 t=e.LX.makeContainer(["100%","auto"],"flex flex-row p-1","",this.root);if(!this.skipPrevMonth){const s=e.LX.makeIcon("Left",{title:"Previous Month",iconClass:"border-color p-1 rounded hover:bg-secondary",svgClass:"sm"});t.appendChild(s),s.addEventListener("click",()=>{this._previousMonth()})}if(e.LX.makeContainer(["100%","auto"],"text-center font-medium select-none",`${this.monthName} ${this.year}`,t),!this.skipNextMonth){const s=e.LX.makeIcon("Right",{title:"Next Month",iconClass:"border-color p-1 rounded hover:bg-secondary",svgClass:"sm"});t.appendChild(s),s.addEventListener("click",()=>{this._nextMonth()})}}{const t=document.createElement("table");t.className="w-full",this.root.appendChild(t);{const e=document.createElement("thead");t.appendChild(e);const s=document.createElement("tr");for(const e of["Mo","Tu","We","Th","Fr","Sa","Su"]){const t=document.createElement("th");t.className="text-muted-foreground text-xs font-normal w-10 select-none",t.innerHTML=`<span>${e}</span>`,s.appendChild(t)}e.appendChild(s)}{const s=document.createElement("tbody");t.appendChild(s);let i=this.range?e.LX.dateFromDateString(this.range[0]):null,o=this.range?e.LX.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-8 text-xs font-normal rounded select-none cursor-pointer shrink-0 grow-0";const n=new Date(`${this.month}/${e.day}/${this.year}`),a=new Date,r=!this.untilToday||n.getTime()<a.getTime(),l=!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&&r&&l,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-primary text-primary-foreground":this.range&&c&&n>i&&n<o?s.className+=" bg-accent text-accent-foreground":s.className+=` ${c?"text-secondary-foreground":"text-muted-foreground"} 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 r=42-a.length;for(let e=1;e<=r;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"}}}e.LX.Calendar=_;class k{root;fromCalendar;toCalendar;from;to;_selectingRange=!1;constructor(t,s={}){this.root=e.LX.makeContainer(["auto","auto"],"flex flex-row"),console.assert(t&&t.constructor===Array,"Range cannot be empty and has to be an Array!");let i=null,o=!1;{const s=e.LX.dateFromDateString(t[0]),n=e.LX.dateFromDateString(t[1]);if(s>n){const e=t[0];t[0]=t[1],t[1]=e,o=!0}i=(o?n.getMonth():s.getMonth())+2}this.from=t[0],this.to=t[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 _(this.from,{skipNextMonth:!0,onChange:n,onPreviousMonth:()=>{this.toCalendar._previousMonth()},range:t}),this.toCalendar=new _(this.to,{skipPrevMonth:!0,onChange:n,onNextMonth:()=>{this.fromCalendar._nextMonth()},range:t}),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 t=e.LX.dateFromDateString(this.from),s=this.fromCalendar.getMonthName(t.getMonth()),i=e.LX.dateFromDateString(this.to),o=this.toCalendar.getMonthName(i.getMonth());return`${this.fromCalendar.getFullDate(s,t.getDate(),t.getFullYear())} to ${this.toCalendar.getFullDate(o,i.getDate(),i.getFullYear())}`}}e.LX.CalendarRange=k;class S extends n{calendar;_popover=void 0;constructor(t,s,i,n={}){super(e.ComponentType.DATE,t,null,n);const r=s?.constructor===Array;if(!r&&n.today){const e=new Date;s=`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()}`}this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{r||this.calendar.fromDateString(e),s=e,c(this.calendar.getFullDate()),n||this._trigger(new o(t,e,a),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};const l=e.LX.makeContainer(["auto","auto"],"lexdate flex flex-row");this.root.appendChild(l),this.calendar=r?new k(s,{onChange:e=>{this.set(e)},...n}):new _(s,{onChange:e=>{const t=`${e.day}/${e.month}/${e.year}`;this.set(t)},...n});const c=t=>{const s=!!t;l.innerHTML="";const i=(t=t??"Pick a date").split(" to "),o=r?i[0]:t,n=e.LX.makeIcon("Calendar"),c=new a(null,o,()=>{this._popover=new C(c.root,[this.calendar])},{disabled:this.disabled,buttonClass:`outline flex flex-row px-3 ${s?"":"text-muted-foreground"} justify-between`});if(c.root.querySelector("button").appendChild(n),c.root.style.width="100%",l.appendChild(c.root),r){const t=e.LX.makeIcon("ArrowRight");e.LX.makeContainer(["32px","auto"],"content-center",t.innerHTML,l);const o=i[1],n=e.LX.makeIcon("Calendar"),r=new a(null,o,()=>{this._popover=new C(r.root,[this.calendar])},{disabled:this.disabled,buttonClass:`outline flex flex-row px-3 ${s?"":"text-muted-foreground"} justify-between`});r.root.querySelector("button").appendChild(n),r.root.style.width="100%",l.appendChild(r.root)}};s?c(this.calendar.getFullDate()):c(),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Calendar=_,e.LX.CalendarRange=k,e.LX.DatePicker=S;class w{element;canvas;constructor(t,s={}){let i=document.createElement("div");i.className=e.LX.mergeClass("dial",s.className),i.style.width=i.style.height=s.size||"100%",i.style.minWidth=i.style.minHeight="50px",i.bgcolor=s.bgColor||e.LX.getCSSVariable("background"),i.pointscolor=s.pointsColor||e.LX.getCSSVariable("primary/50"),i.linecolor=s.lineColor||"#555",i.value=t||[],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??e.LX.CURVE_MOVEOUT_DELETE,e.LX.addSignal("@on_new_color_scheme",(t,o)=>{i.bgcolor=s.bgColor||e.LX.getCSSVariable("background"),i.pointscolor=s.pointsColor||e.LX.getCSSVariable("primary/50"),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(t){document.addEventListener("mousemove",c),document.addEventListener("mouseup",h);var s=o.getBoundingClientRect(),d=t.clientX-s.left,m=t.clientY-s.top;if(r=function(e,t){for(var s=1e5,o=-1,a=0;a<i.value.length;a++){var r=u([e,t],n(i.value[a]));r<s&&r<8&&(s=r,o=a)}return o}(d,o.height-m),t.button==e.LX.MOUSE_LEFT_CLICK&&-1==r&&i.allow_add_values){var g=a([d,o.height-m]);i.value.push(g),p(),r=i.value.indexOf(g)}l=[d,m],i.redraw(),t.preventDefault(),t.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 r=-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 l in i.value){s=n(i.value[l]),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==r;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 l=[0,0];function c(t){var s=o.getBoundingClientRect(),n=t.clientX-s.left,c=t.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=[t.clientX-s.left,t.clientY-s.top];if(-1!=r&&u(m,[n,c])>.5*o.height){if(i.move_out==e.LX.CURVE_MOVEOUT_DELETE)i.value.splice(r,1);else{const e=[m[0]-n,m[1]-c];let t=i.value[r];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(t)}else{var g=a([-(i.draggable_x?l[0]-n:0),i.draggable_y?l[1]-c:0]);if(-1!=r){var f=i.xrange[0],C=i.xrange[1];i.no_overlap&&(r>0&&(f=i.value[r-1][0]),r<i.value.length-1&&(C=i.value[r+1][0]));var v=i.value[r];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(),l[0]=n,l[1]=c,d(t),t.preventDefault(),t.stopPropagation()}}function h(e){r=-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!=r&&(e=i.value[r]),i.value.sort(function(e,t){return e[0]-t[0]}),e&&(r=i.value.indexOf(e))}return i.redraw(),this}redraw(e={}){this.element.redraw(e)}}e.LX.CanvasDial=w;class T extends n{dialInstance;constructor(t,s,i,n={}){let a=JSON.parse(JSON.stringify(s));super(e.ComponentType.DIAL,t,a,n),this.onGetValue=()=>JSON.parse(JSON.stringify(l.element.value)),this.onSetValue=(e,s,n)=>{l.element.value=JSON.parse(JSON.stringify(e)),l.redraw(),s||this._trigger(new o(t,l.element.value,n),i)},this.onResize=t=>{const s=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${s})`,e.LX.flushCss(r),l.element.style.height=l.element.offsetWidth+"px",l.canvas.width=l.element.offsetWidth,r.style.width=l.element.offsetWidth+"px",l.canvas.height=l.canvas.width,l.redraw()};var r=document.createElement("div");r.className="lexcurve",this.root.appendChild(r),n.callback=(e,s)=>{this._trigger(new o(t,e,s),i)},n.name=t;let l=new w(s,n);r.appendChild(l.element),this.dialInstance=l,e.LX.doAsync(this.onResize.bind(this))}}e.LX.CanvasDial=w,e.LX.Dial=T;class E extends n{constructor(t,s,i={}){super(e.ComponentType.FILE,t,null,i);let o=i.local??!0,n=i.type??"text",r=i.read??!0;this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};let l=document.createElement("input");if(l.className="lexfileinput",l.type="file",l.disabled=this.disabled,this.root.appendChild(l),i.placeholder&&(l.placeholder=i.placeholder),l.addEventListener("change",function(e){const t=e.target.files;if(t.length)if(r){i.onBeforeRead&&i.onBeforeRead();const e=new FileReader;"text"===n?e.readAsText(t[0]):"buffer"===n?e.readAsArrayBuffer(t[0]):"bin"===n?e.readAsBinaryString(t[0]):"url"===n&&e.readAsDataURL(t[0]),e.onload=e=>{s.call(this,e.target?.result,t[0])}}else s(t[0])}),l.addEventListener("cancel",function(e){s(null)}),o){let t=null;const s=new a(null,"",()=>{t||(t=new e.LX.Dialog("Load Settings",e=>{e.addSelect("Type",["text","buffer","bin","url"],n,e=>{n=e}),e.addButton(null,"Reload",()=>{l.dispatchEvent(new Event("change"))})},{onclose:e=>{e.remove(),t=null}}))},{skipInlineCount:!0,title:"Settings",disabled:this.disabled,icon:"Settings"});this.root.appendChild(s.root)}e.LX.doAsync(this.onResize.bind(this))}}e.LX.FileInput=E;class M extends n{data;formData={};primaryButton;constructor(t,s,i,o={}){if(s.constructor!=Object)return void console.error("Form data must be an Object");o.hideName=!0,super(e.ComponentType.FORM,t,null,o),this.onGetValue=()=>this.formData,this.onSetValue=(t,s,i)=>{this.formData=t;const o=r.querySelectorAll(".lexcomponent");for(let i=0;i<o.length;++i){if(o[i].jsInstance.type!=e.ComponentType.TEXT)continue;let a=o[i].querySelector(".lexcomponentname").innerText,r=o[i].querySelector(".lextext input");r.value=t[a]??"",n._dispatchEvent(r,"focusout",s)}};let r=document.createElement("div");r.className="flex flex-col gap-1",r.style.width="100%",this.root.appendChild(r);for(let t in s){let i=s[t];if(i.constructor!=Object){const o=e.LX.deepCopy(i);i={value:o},s[t]=i}if(i.width="100%",i.placeholder=i.placeholder??i.label??`Enter ${t}`,i.ignoreValidation=!0,!o.skipLabels){const e=new h(null,i.label??t,null,{disabled:!0,inputClass:"formlabel text-xs bg-none text-muted-foreground"});r.appendChild(e.root)}i.textComponent=new h(null,i.constructor==Object?i.value:i,(e,s)=>{this.formData[t]=e,i.submit&&s?.constructor===KeyboardEvent&&this.submit()},i),r.appendChild(i.textComponent.root),this.formData[t]=i.constructor==Object?i.value:i}const l=e.LX.makeContainer(["100%","auto"],"flex flex-row mt-2","",r);if(o.secondaryActionName||o.secondaryActionCallback){const e=new a(null,o.secondaryActionName??"Cancel",(e,t)=>{o.secondaryActionCallback&&o.secondaryActionCallback(this.formData,t)},{width:"100%",minWidth:"0",buttonClass:o.secondaryButtonClass??"secondary"});l.appendChild(e.root)}this.primaryButton=new a(null,o.primaryActionName??"Submit",(t,o)=>{this.syncInputs();const n=[];for(let t in s){let i=s[t];const o=i.pattern,a=o?.fieldMatchName?this.formData[o.fieldMatchName]:void 0;if(!i.textComponent.valid(void 0,a)){const s={entry:t,type:"input_not_valid",messages:[]};o&&(s.messages=e.LX.validateValueAtPattern(this.formData[t],o,a)),n.push(s)}}i&&i(this.formData,n,o)},{width:"100%",minWidth:"0",buttonClass:o.primaryButtonClass??"primary"}),l.appendChild(this.primaryButton.root),o.skipEnterSubmit||this.root.addEventListener("keydown",e=>{if("Enter"!==e.key||e.shiftKey)return;"TEXTAREA"!==e.target.tagName&&(e.preventDefault(),this.submit())}),this.data=s}submit(){this.syncInputs(),this.primaryButton?.click()}syncInputs(){for(const e in this.data){const t=this.data[e].textComponent;t instanceof h&&(t.syncFromDOM(),this.formData[e]=t.value())}}}e.LX.Form=M;class A extends n{setLayers;constructor(t,s,i,n={}){super(e.ComponentType.LAYERS,t,s,n),this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{s=e,this.setLayers(s),n||this._trigger(new o(t,s,a),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=`calc( 100% - ${t})`};const a=e.LX.makeElement("div","lexlayers grid","",this.root),r=n.maxBits??16;this.setLayers=e=>{a.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("button");if(i.className="lexlayer size-6 text-secondary-foreground text-center content-center place-self-center cursor-pointer font-semibold text-xs rounded-lg select-none \n disabled:pointer-events-none disabled:opacity-50",i.disabled=this.disabled,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),a.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),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Layers=A;class X extends n{_updateValues;constructor(t,s,i,n,a={}){super(e.ComponentType.LIST,t,i,a),this.onGetValue=()=>i,this.onSetValue=(e,a,l)=>{r.querySelectorAll(".lexlistitem").forEach(e=>e.classList.remove("selected"));let c=null;for(let t=0;t<s.length;++t){const i=s[t];if(i==e||i.constructor==Array&&i[0]==e){c=t;break}}c?(r.children[c].classList.toggle("selected"),i=e,a||this._trigger(new o(t,e,l),n)):console.error(`Cannot find item ${e} in List.`)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";r.style.width=`calc( 100% - ${t})`},this._updateValues=a=>{s=a,r.innerHTML="";for(let a=0;a<s.length;++a){let l=null,c=s[a];c.constructor===Array&&(l=c[1],c=c[0]);let h=document.createElement("button");h.className="lexlistitem disabled:pointer-events-none disabled:opacity-50 "+(i==c?"selected":""),h.disabled=this.disabled,l&&h.appendChild(e.LX.makeIcon(l)),h.innerHTML+=`<span>${c}</span>`,h.addEventListener("click",e=>{r.querySelectorAll(".lexlistitem").forEach(e=>e.classList.remove("selected")),h.classList.toggle("selected"),i=c,this._trigger(new o(t,c,e),n)}),r.appendChild(h)}};let r=document.createElement("div");r.className="bg-background flex flex-col gap-1 rounded-xl border-color p-2",this.root.appendChild(r),this._updateValues(s),e.LX.doAsync(this.onResize.bind(this))}}e.LX.List=X;let P=class t{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(e,s=new t){return s.set(this.x+e.x,this.y+e.y),s}sub(e,s=new t){return s.set(this.x-e.x,this.y-e.y),s}mul(e,s=new t){return e.constructor==Number&&(e=new t(e)),s.set(this.x*e.x,this.y*e.y),s}div(e,s=new t){return e.constructor==Number&&(e=new t(e)),s.set(this.x/e.x,this.y/e.y),s}abs(e=new t){return e.set(Math.abs(this.x),Math.abs(this.y)),e}dot(e){return this.x*e.x+this.y*e.y}len2(){return this.dot(this)}len(){return Math.sqrt(this.len2())}nrm(e=new t){return e.set(this.x,this.y),e.mul(1/this.len(),e)}dst(e){return e.sub(this).len()}clp(s,i,o=new t){return o.set(e.LX.clamp(this.x,s,i),e.LX.clamp(this.y,s,i)),o}fromArray(e){this.x=e[0],this.y=e[1]}toArray(){return this.xy}};e.LX.vec2=P;class N{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 P(0,0);circleCenter=[0,0];circleRadius=1;margin=8;dragging=!1;_valuesChanged=!0;_selectedPoint=null;_precomputedWeightsGridSize=0;_precomputedWeights=null;constructor(t,s,i={}){this.circular=i.circular??!1,this.showNames=i.showNames??!0,this.size=i.size??[200,200],this.points=t??[],this.callback=s,this._valuesChanged=!0,this._selectedPoint=null,this.root=e.LX.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(t){if(!o.dragging)return;const s=o.margin,i=o.root.getBoundingClientRect();let n=new P;n.set(t.x-i.x-.5*o.size[0],t.y-i.y-.5*o.size[1]);var a=o.currentPosition;if(a.set(e.LX.clamp(n.x/(.5*o.size[0]-s),-1,1),e.LX.clamp(n.y/(.5*o.size[1]-s),-1,1)),o.circular){const e=new P(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 r=this.canvas.getContext("2d",{willReadFrequently:!0});this.renderToCanvas(r)}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=N.GRID_SIZE;let n=0,a=new P;for(var r=0;r<o;++r)for(var l=0;l<o;++l){a.set(l/o*2-1,r/o*2-1);var c=2*l+r*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=N.GRID_SIZE,s=2*t*t;let i=new P;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,r=1e5;for(let o=0;o<e;++o){i.set(n/t*2-1,s/t*2-1);let e=new P;e.fromArray(this.points[o].pos);let l=i.dst(e);l>r||(a=o,r=l)}o[2*n+2*s*t]=a,o[2*n+2*s*t+1]=r}return o}precomputeWeightsToImage(e){if(!this.points.length)return null;const t=N.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 r=0,l=o.getImageData(0,0,t,t),c=new P;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=N.COLORS[a%N.COLORS.length];var u=e.dst(c)<s[o+1]+.001;u&&(n[a]+=1,r++),l.data[i]=p[0]+(u?128:0),l.data[i+1]=p[1]+(u?128:0),l.data[i+2]=p[2]+(u?128:0),l.data[i+3]=255}for(let e=0;e<n.length;++e)n[e]/=r;return o.putImageData(l,0,0),i}addPoint(t,s=null){if(this.findPoint(t))return void console.warn("CanvasMap2D.addPoint: There is already a point with that name");s||(s=[this.currentPosition.x,this.currentPosition.y]),s[0]=e.LX.clamp(s[0],-1,1),s[1]=e.LX.clamp(s[1],-1,1);const i={name:t,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(t){if(!t)return;const s=this.margin,i=this.size[0],o=this.size[1];t.fillStyle="black",t.strokeStyle="#BBB",t.clearRect(0,0,i,o),this.circular?(this.circleCenter[0]=.5*i,this.circleCenter[1]=.5*o,this.circleRadius=.5*o-s,t.lineWidth=1,t.beginPath(),t.arc(this.circleCenter[0],this.circleCenter[1],this.circleRadius,0,2*Math.PI),t.fill(),t.stroke(),t.beginPath(),t.moveTo(this.circleCenter[0]+.5,this.circleCenter[1]-this.circleRadius),t.lineTo(this.circleCenter[0]+.5,this.circleCenter[1]+this.circleRadius),t.moveTo(this.circleCenter[0]-this.circleRadius,this.circleCenter[1]),t.lineTo(this.circleCenter[0]+this.circleRadius,this.circleCenter[1]),t.stroke()):(t.fillRect(s,s,i-2*s,o-2*s),t.strokeRect(s,s,i-2*s,o-2*s));var n=this.precomputeWeightsToImage(this.currentPosition);n&&(t.globalAlpha=.5,t.imageSmoothingEnabled=!1,this.circular?(t.save(),t.beginPath(),t.arc(this.circleCenter[0],this.circleCenter[1],this.circleRadius,0,2*Math.PI),t.clip(),t.drawImage(n,this.circleCenter[0]-this.circleRadius,this.circleCenter[1]-this.circleRadius,2*this.circleRadius,2*this.circleRadius),t.restore()):t.drawImage(n,s,s,i-2*s,o-2*s),t.imageSmoothingEnabled=!0,t.globalAlpha=1);for(let n=0;n<this.points.length;++n){const a=this.points[n];let r=.5*a.pos[0]+.5,l=.5*a.pos[1]+.5;r=r*(i-2*s)+s,l=l*(o-2*s)+s,r=e.LX.clamp(r,s,i-s),l=e.LX.clamp(l,s,o-s),t.fillStyle=a==this._selectedPoint?"#CDF":"#BCD",t.beginPath(),t.arc(r,l,3,0,2*Math.PI),t.fill(),this.showNames&&t.fillText(a.name,r+5,l+5)}t.fillStyle="white",t.beginPath();var a=.5*this.currentPosition.x+.5,r=.5*this.currentPosition.y+.5;a=a*(i-2*s)+s,r=r*(o-2*s)+s,a=e.LX.clamp(a,s,i-s),r=e.LX.clamp(r,s,o-s),t.arc(a,r,4,0,2*Math.PI),t.fill()}}e.LX.CanvasMap2D=N;class I extends n{map2d;_popover=null;constructor(t,s,i,o={}){super(e.ComponentType.MAP2D,t,null,o),this.onGetValue=()=>this.map2d.weightsObj,this.onSetValue=(e,t,s)=>{},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";n.style.width=`calc( 100% - ${t})`};var n=document.createElement("div");n.className="lexmap2d",this.root.appendChild(n),this.map2d=new N(s,i,o);const r=e.LX.makeIcon(o.mapIcon??"SquareMousePointer"),l=new a(null,"Open Map",()=>{this._popover=new C(l.root,[this.map2d])},{buttonClass:"outline justify-between",disabled:this.disabled});l.root.querySelector("button").appendChild(r),n.appendChild(l.root),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Map2D=I;class O{domEl;data;options;selected=[];_forceClose=!1;_callbacks={};constructor(e,t,s={}){if(this.domEl=e,this.data=t,this.options=s,t.constructor===Object)this._createItem(null,t);else for(let e of t)this._createItem(null,e)}_createItem(t,s,i=0,o){const n=this,r=this.domEl.querySelector(".lexnodetreefilter");if(s.children=s.children??[],r&&""!=r.value&&!s.id.includes(r.value)){for(var l=0;l<s.children.length;++l)this._createItem(s,s.children[l],i+1,o);return}const c=this.domEl.querySelector("ul");s.visible=s.visible??!0,s.parent=t;let h=s.children.length>0,d=this.selected.indexOf(s)>-1||s.selected;if(this.options.onlyFolders){let e=!1;s.children.forEach(t=>{e=e||"folder"==t.type}),h=!!e}let u=document.createElement("li");u.className=`lextreeitem inline-flex outline-none text-sm items-center h-7 cursor-pointer truncate rounded-lg select-none datalevel${i} ${h?"parent":""} ${d?" selected":""}`,u.id=e.LX.getSupportedDOMName(s.id),u.tabIndex="0",u.treeData=s,s.treeEl=u;let p=this.options.skipDefaultIcon??1?null:"Dot";if(h&&(p=s.closed?"Right":"Down"),p&&u.appendChild(e.LX.makeIcon(p,{iconClass:"hierarchy",svgClass:"sm"})),p=s.icon,p)if(s.icon.includes(".")){const e="https://raw.githubusercontent.com/jxarco/lexgui.js/master/";u.innerHTML+=`<img src="${e+s.icon}">`}else{const t=s.icon.split(" "),i=e.LX.makeIcon(t[0],{iconClass:"tree-item-icon mr-2",svgClass:"md"+(t.length>1?` ${t.slice(0).join(" ")}`:"")});u.appendChild(i)}u.innerHTML+=s.rename?"":s.id,u.style.paddingLeft=3+15*(i+1)+"px",c.appendChild(u);const m=t&&(s.metadata?.draggable??this.options.defaultDraggable??!0);m&&u.setAttribute("draggable","true"),u.addEventListener("click",e=>{if(f)return void(f=!1);e.shiftKey||(c.querySelectorAll("li").forEach(e=>{e.classList.remove("selected")}),this.selected.length=0);const t=this.selected.indexOf(s);if(u.classList.toggle("selected",-1==t),t>-1?this.selected.splice(t,1):this.selected.push(s),h&&s.id.length>1){s.closed=!1;const t=n._callbacks.caretChanged;if(void 0!==t){t({type:"caret",items:[s],domEvent:e,userInitiated:!0})}n.frefresh(s.id)}const i=n._callbacks.select;if(void 0!==i){i({type:"select",items:[s],result:this.selected,domEvent:e,userInitiated:!0})}}),u.addEventListener("dblclick",function(e){(n.options.rename??1)&&(s.rename=!0,n.refresh());const t=n._callbacks.dblClick;if(void 0!==t){t({type:"dbl_click",items:[s],domEvent:e,userInitiated:!0})}}),u.addEventListener("contextmenu",async t=>{t.preventDefault();const i=n._callbacks.contextMenu;if(!i)return;const o={type:"context_menu",items:this.selected,from:s,domEvent:t,userInitiated:!0},a=await i(o),r=this.selected.length>1,l=this.options.useDefaultContextMenuItems??!0;e.LX.addContextMenu(this.options.contextMenuTitle??(r?"Selected Nodes":s.id),t,e=>{if(a?.length){for(const t of a)e.add(t.name,{callback:t.callback});l&&e.add("")}l&&(e.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);const i=this._callbacks.select;if(void 0!==i){i({type:"select",items:[s],result:this.selected,domEvent:t,userInitiated:!0})}}),e.add("Delete",{callback:()=>{const e=this._callbacks.beforeDelete,t=this._callbacks.delete,i=(...e)=>{let i=[];this.selected.length?i.push(...n.deleteNodes(this.selected)):n.deleteNode(s)&&i.push(s),this.refresh();t&&t({type:"delete",items:i,userInitiated:!0},...e)};if(e){e({type:"delete",items:this.selected.length?this.selected:[s],userInitiated:!0},i)}else i()}}))})}),u.addEventListener("keydown",t=>{if(!s.rename)if(t.preventDefault(),"Delete"==t.key){const e=this._callbacks.beforeDelete,s=this._callbacks.delete,i=(...e)=>{const i=[];for(let e of this.selected)n.deleteNode(e)&&i.push(e);if(this.selected.length=0,this.refresh(),i.length){s&&s({type:"delete",items:i,domEvent:t,userInitiated:!0},...e)}};if(e){e({type:"delete",items:this.selected,domEvent:t,userInitiated:!0},i)}else i()}else if("ArrowUp"==t.key||"ArrowDown"==t.key){var i=this.selected.length>1?"ArrowUp"==t.key?this.selected.shift():this.selected.pop():this.selected[0],o=this.domEl.querySelector("#"+e.LX.getSupportedDOMName(i.id)),a="ArrowUp"==t.key?o.previousSibling:o.nextSibling;a&&a.click()}});const g=document.createElement("input");g.toggleAttribute("hidden",!s.rename),g.className="text-foreground bg-none text-sm border-none outline-none",g.value=s.id,u.appendChild(g),s.rename&&(u.classList.add("selected"),g.focus()),g.addEventListener("keyup",function(t){if("Enter"==t.key){const t=n._callbacks.beforeRename,i=n._callbacks.rename,o=s.id;this.value=this.value.replace(/\s/g,"_");const a=(...t)=>{s.id=e.LX.getSupportedDOMName(this.value),delete s.rename,n.frefresh(s.id),c.querySelector(`#${s.id}`).classList.add("selected");const a={type:"rename",items:[s],oldName:o,newName:this.value,userInitiated:!0};i&&i(a,...t)};if(t){t({type:"rename",items:[s],oldName:o,newName:this.value,userInitiated:!0},a)}else a()}else"Escape"==t.key&&(delete s.rename,n.frefresh(s.id))}),g.addEventListener("blur",function(e){delete s.rename,n.refresh()}),m&&u.addEventListener("dragstart",e=>{window.__tree_node_dragged=s}),u.addEventListener("dragover",e=>{e.preventDefault()},!1),u.addEventListener("dragenter",e=>{e.target.classList.add("draggingover")}),u.addEventListener("dragend",e=>{e.target.classList.remove("draggingover")}),u.addEventListener("dragleave",e=>{e.target.classList.remove("draggingover")}),u.addEventListener("drop",e=>{e.preventDefault();let t=window.__tree_node_dragged;if(!t)return t=window.__av_item_dragged,void(t&&(t._nodeTarget=s));e.target.classList.remove("draggingover");let i=s;if(t.id==i.id)return void console.warn("Cannot parent node to itself!");const o=function(e,t){var s=!1;for(var i of t.children){if(i.id==e.id)return!0;s=s||o(e,i)}return s};if(o(i,t))return void console.warn("Cannot parent node to a current child!");const a=this._callbacks.beforeMove,r=this._callbacks.move,l=(...s)=>{const o=t.parent.children.findIndex(e=>e.id==t.id),a=t.parent.children.splice(o,1);i.children.push(a[0]),n.refresh(),delete window.__tree_node_dragged;r&&r({type:"move",items:[t],to:i,domEvent:e,userInitiated:!0},...s)};if(a){a({type:"move",items:[t],to:i,domEvent:e,userInitiated:!0},l)}else l()});let f=!1;h&&u.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;const t=n._callbacks.caretChanged;if(void 0!==t){t({type:"caret",items:[s],domEvent:e,userInitiated:!0})}n.frefresh(s.id)});const C=e.LX.makeElement("div","flex flex-row ml-auto mr-2");if(u.appendChild(C),s.actions)for(let e=0;e<s.actions.length;++e){const t=s.actions[e],i=new a(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 min-h-fit",buttonClass:"px-0 h-full bg-none"});C.appendChild(i.root)}if(!s.skipVisibility){const e=new a(null,"",(e,t)=>{t.stopPropagation(),s.visible=void 0!==s.visible&&!s.visible;const i=this._callbacks.visibleChanged;if(void 0!==i){i({type:"visibility",items:[s],domEvent:t,userInitiated:!0})}},{icon:s.visible?"Eye":"EyeOff",swap:s.visible?"EyeOff":"Eye",title:"Toggle visible",className:"p-0 min-h-fit",buttonClass:"px-0 h-full 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,o);if(!s.closed||y)for(l=0;l<s.children.length;++l){let e=s.children[l];this.options.onlyFolders&&"folder"!=e.type||this._createItem(s,e,i+1,o)}}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(t,s){const i=this.domEl.querySelector(".lexnodetreefilter");if(i&&(i.value=""),this.refresh(null,t),this.domEl.querySelectorAll(".selected").forEach(e=>e.classList.remove("selected")),void 0===t){if(void 0===s)return void(this.selected.length=0);t=s.at(-1)}let o=null;if(void 0!==s){let e=this.data;for(const t of s){const s=e.children.find(e=>e.id===t);if(!s)break;e=s}o=e.treeEl,console.assert(o,"NodeTree: No domEl in item "+t)}else void 0!==t&&(o=this.domEl.querySelector("#"+e.LX.getSupportedDOMName(t)),console.assert(o,"NodeTree: Can't select node "+t));o||console.assert(o,"NodeTree: Can't select node "+t),o.classList.add("selected"),this.selected=[o.treeData],o.focus()}deleteNodes(e){const t=[];for(const s of e)this.deleteNode(s)&&t.push(s);return t}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}}e.LX.NodeTree=O;class R extends n{innerTree;constructor(t,s,i={}){i.hideName=!0,super(e.ComponentType.TREE,t,null,i);let o=e.LX.makeElement("div","lextree p-1 rounded-lg w-full my-0 mx-auto font-medium text-sm min-h-3","",this.root);t&&e.LX.makeElement("span","block p-1 select-none text-base font-medium whitespace-nowrap",t,o);let n=e.LX.makeElement("div","lextreetools flex items-center bg-secondary px-2 rounded-lg gap-2 my-1");if(t||(n.className+=" notitle"),i.icons)for(let t of i.icons){const s=e.LX.makeIcon(t.icon,{title:t.name});s.addEventListener("click",t.callback),n.appendChild(s)}i.filter=i.filter??!0;let a=null;if(i.filter){a=document.createElement("input"),a.className="lexnodetreefilter",a.setAttribute("placeholder","Filter.."),a.style.width="100%",a.addEventListener("input",()=>{this.innerTree.refresh()});let t=e.LX.makeIcon("Search");n.appendChild(a),n.appendChild(t)}(i.icons||i.filter)&&o.appendChild(n);let r=e.LX.makeElement("ul","flex flex-col gap-1 ps-0");r.addEventListener("contextmenu",function(e){e.preventDefault()}),o.appendChild(r),this.innerTree=new O(o,s,i)}on(e,t){this.innerTree._callbacks[e]=t}}e.LX.Tree=R;class z extends n{constructor(t,s,i,n={}){const a=n.pattern??"xxx-xxx",r=(a.match(/x/g)||[]).length;(s=String(s)).length||(s="x".repeat(r)),super(e.ComponentType.OTP,t,s,n),this.onGetValue=()=>+s,this.onSetValue=(e,n,a)=>{h(s=e),n||this._trigger(new o(t,e,a),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};const l=document.createElement("div");l.className="lexotp flex flex-row items-center",this.root.appendChild(l);const c=a.split("-"),h=t=>{l.innerHTML="";let s=0,i=0;for(let o=0;o<c.length;++o){const n=c[o];for(let o=0;o<n.length;++o){let a=t[s++];a="x"==a?"":a;const r=e.LX.makeContainer(["36px","30px"],"lexotpslot border-t-color border-b-color border-l-color px-3 cursor-text select-none font-medium outline-none",a,l);r.tabIndex="1",this.disabled&&r.classList.add("disabled");const c=s;0==o?r.className+=" rounded-l":o==n.length-1&&(r.className+=" rounded-r border-r-color"),r.addEventListener("click",()=>{if(this.disabled)return;l.querySelectorAll(".lexotpslot").forEach(e=>e.classList.remove("active"));const e=l.querySelectorAll(".lexotpslot")[i];e.classList.add("active"),e.focus()}),r.addEventListener("blur",()=>{this.disabled||e.LX.doAsync(()=>{l.contains(document.activeElement)||l.querySelectorAll(".lexotpslot").forEach(e=>e.classList.remove("active"))},10)}),r.addEventListener("keyup",e=>{if(!this.disabled)if(/[^0-9]+/g.test(e.key))if("ArrowLeft"==e.key||"ArrowRight"==e.key){const t="ArrowLeft"==e.key?-1:1,s=l.querySelectorAll(".lexotpslot")[i+t];s&&(l.querySelectorAll(".lexotpslot")[i].classList.remove("active"),s.classList.add("active"),s.focus(),i+=t)}else"Enter"!=e.key||t.includes("x")||this.set(t);else{const s=e.key;console.assert(!Number.isNaN(parseInt(s))),r.innerHTML=s,t=t.substring(0,c-1)+s+t.substring(c);const o=l.querySelectorAll(".lexotpslot")[i+1];o?(l.querySelectorAll(".lexotpslot")[i].classList.remove("active"),o.classList.add("active"),o.focus(),i++):this.set(t)}})}o<c.length-1&&e.LX.makeContainer(["auto","auto"],"mx-2","-",l)}console.assert(s==t.length,"OTP Value/Pattern Mismatch!")};h(s)}}e.LX.OTPInput=z;class D extends n{constructor(t,s,i,n={}){super(e.ComponentType.PAD,t,null,n),this.onGetValue=()=>l.value.xy,this.onSetValue=(e,s,n)=>{l.value.set(e[0],e[1]),c(l.value),s||this._trigger(new o(t,l.value.xy,n),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=`calc( 100% - ${t})`};let a=document.createElement("div");a.className="lexpad",this.root.appendChild(a);let r=document.createElement("div");r.id="lexpad-"+t,r.className="lexinnerpad data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 border-color",r.style.width=n.padSize??"96px",r.style.height=n.padSize??"96px",r.dataset.disabled=this.disabled.toString(),a.appendChild(r);let l=document.createElement("div");l.className="lexpadthumb opacity-inherit",l.value=new P(s[0],s[1]),l.min=n.min??0,l.max=n.max??1,r.appendChild(l);let c=t=>{const[s,i]=[r.offsetWidth,r.offsetHeight],o=new P(e.LX.remapRange(t.x,l.min,l.max,0,1),e.LX.remapRange(t.y,l.min,l.max,0,1));l.style.transform=`translate(calc( ${s*o.x}px - 50% ), calc( ${i*o.y}px - 50%)`};r.addEventListener("mousedown",function(e){if(document.activeElement==l)return;var t=h.root.ownerDocument;t.addEventListener("mousemove",d),t.addEventListener("mouseup",u),document.body.classList.add("nocursor"),document.body.classList.add("noevents"),e.stopImmediatePropagation(),e.stopPropagation(),l.classList.add("active"),n.onPress&&n.onPress.bind(l)(e,l)});let h=this;function d(s){const n=r.getBoundingClientRect(),a=new P(s.x-n.x,s.y-n.y);a.clp(0,r.offsetWidth,a);const[c,d]=[r.offsetWidth,r.offsetHeight],u=a.div(new P(r.offsetWidth,r.offsetHeight));l.style.transform=`translate(calc( ${c*u.x}px - 50% ), calc( ${d*u.y}px - 50%)`,l.value=new P(e.LX.remapRange(u.x,0,1,l.min,l.max),e.LX.remapRange(u.y,0,1,l.min,l.max)),h._trigger(new o(t,l.value.xy,s),i),s.stopPropagation(),s.preventDefault()}function u(e){var t=h.root.ownerDocument;t.removeEventListener("mousemove",d),t.removeEventListener("mouseup",u),document.body.classList.remove("nocursor"),document.body.classList.remove("noevents"),l.classList.remove("active"),n.onRelease&&n.onRelease.bind(l)(e,l)}e.LX.doAsync(()=>{this.onResize(),c(l.value)})}}e.LX.Pad=D;class B extends n{constructor(t,s,i={}){super(e.ComponentType.PROGRESS,t,s,i),this.onGetValue=()=>a.value,this.onSetValue=(s,n,l)=>{s=e.LX.clamp(s,a.min,a.max),this.root.querySelector("meter").value=s,r(),this.root.querySelector("span")&&(this.root.querySelector("span").innerText=s),n||this._trigger(new o(t,s,l),i.callback)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";n.style.width=`calc( 100% - ${t})`};const n=e.LX.makeElement("div","flex justify-center items-center gap-2","",this.root);let a=e.LX.makeElement("meter","lexprogressbar outline-none rounded-lg select-none");a.id="lexprogressbar-"+t,a.step="any",a.min=i.min??0,a.max=i.max??1,a.low=i.low??a.low,a.high=i.high??a.high,a.optimum=i.optimum??a.optimum,a.value=s,n.appendChild(a);const r=()=>{let t=e.LX.getCSSVariable("color-blue-500");null!=a.low&&a.value<a.low?t=e.LX.getCSSVariable("destructive"):null!=a.high&&a.value<a.high&&(t=e.LX.getCSSVariable("warning")),a.style.background=`color-mix(in srgb, ${t} 20%, transparent)`};if(i.showValue){const i=document.getElementById("progressvalue-"+t);i&&i.remove(),e.LX.makeElement("span","w-12 flex-auto-keep text-center",s,n).id="progressvalue-"+t}if(i.editable){a.classList.add("editable");let t=t=>{var o=this.root.ownerDocument;o.addEventListener("mousemove",s),o.addEventListener("mouseup",i),document.body.classList.add("noevents"),a.classList.add("grabbing"),t.stopImmediatePropagation(),t.stopPropagation();const n=a.getBoundingClientRect(),r=e.LX.round(e.LX.remapRange(t.offsetX,0,n.width,a.min,a.max));this.set(r,!1,t)},s=t=>{if(0!=t.movementX){const s=a.getBoundingClientRect(),i=e.LX.round(e.LX.remapRange(t.offsetX-s.x,0,s.width,a.min,a.max));this.set(i,!1,t)}t.stopPropagation(),t.preventDefault()},i=e=>{var t=this.root.ownerDocument;t.removeEventListener("mousemove",s),t.removeEventListener("mouseup",i),document.body.classList.remove("noevents"),a.classList.remove("grabbing")};a.addEventListener("mousedown",t)}r(),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Progress=B;class H extends n{constructor(t,s,i,n,a={}){super(e.ComponentType.RADIO,t,null,a);let r=null;this.onGetValue=()=>{const e=l.querySelectorAll("button");return r?[r,e[r]]:void 0},this.onSetValue=(e,t,s)=>{e=e[0]??e,console.assert(e.constructor==Number,"RadioGroup _value_ must be an Array index!");const a=l.querySelectorAll("button");a.forEach(e=>{e.checked=!1,e.classList.remove("checked")});const r=a[e];r.checked=!r.checked,r.classList.toggle("checked"),t||this._trigger(new o(null,[e,i[e]],s),n)};var l=document.createElement("div");l.className=e.LX.mergeClass("lexradiogroup flex flex-col",a.className),this.root.appendChild(l),e.LX.makeElement("span","font-medium mb-2",s,l);for(let e=0;e<i.length;++e){const t=document.createElement("div");t.className="lexradiogroupitem flex items-center gap-2 px-6 py-1",l.appendChild(t);const s=document.createElement("button");s.className="flex p-0 rounded-lg cursor-pointer",s.disabled=this.disabled,t.appendChild(s),s.addEventListener("click",t=>{this.set(e,!1,t)});const o=document.createElement("span");s.appendChild(o);const n=document.createElement("span");n.innerHTML=i[e],t.appendChild(n)}a.selected&&(console.assert(a.selected.constructor==Number,"RadioGroup _selected_ must be an Array index!"),r=a.selected,this.set(r,!0))}}e.LX.RadioGroup=H;class F extends n{_maxSlider=null;_labelTooltip=null;setLimits;constructor(t,s,i,a={}){const r=e.LX.deepCopy(s);super(e.ComponentType.RANGE,t,e.LX.deepCopy(r),a);const l=s.constructor==Array&&2==s.length;l&&(s=r[0],a.fill=!1),this.onGetValue=()=>{let e=s;return l?e=[s,r[1]]:a.left&&(e=+h.max-s+ +h.min),e},this.onSetValue=(n,d,u)=>{let p="";const m=a.max-a.min;if(l&&this._maxSlider){h.value=s=e.LX.clamp(+n[0],+h.min,+h.max),this._maxSlider.value=r[1]=e.LX.clamp(+n[1],+h.min,+h.max);const t=s/m-.5,i=r[1]/m-.5,o=e.LX.remapRange(s,a.min,a.max,0,1),l=e.LX.remapRange(r[1],a.min,a.max,0,1);h.style.setProperty("--range-min-value",100*o+"%"),h.style.setProperty("--range-max-value",100*l+"%"),h.style.setProperty("--range-fix-min-offset",-t+"rem"),h.style.setProperty("--range-fix-max-offset",`${i}rem`),c.dataset.tooltipOffsetX=""+(c.offsetWidth*o+c.offsetWidth*(l-o)*.5-.5*c.offsetWidth),p=`${s} - ${r[1]}`}else{if(isNaN(n))return;h.value=s=e.LX.clamp(+n,+h.min,+h.max);const t=.5*e.LX.remapRange(s,a.min,a.max,0,1);c.dataset.tooltipOffsetX=""+(c.offsetWidth*t-.5*c.offsetWidth),p=`${s}`}if(c.dataset.tooltipContent=p,this._labelTooltip&&(this._labelTooltip.innerHTML=p),!d){let e=s;l?e=[s,r[1]]:a.left&&(e=+h.max-s+ +h.min),this._trigger(new o(t,e,u),i)}},this.onResize=t=>{const i=this.root.domName?.style.width??"0px";if(c.style.width=a.inputWidth??`calc( 100% - ${i})`,l){const t=a.max-a.min,i=s/t-.5,o=r[1]/t-.5;h.style.setProperty("--range-min-value",100*e.LX.remapRange(s,a.min,a.max,0,1)+"%"),h.style.setProperty("--range-max-value",100*e.LX.remapRange(r[1],a.min,a.max,0,1)+"%"),h.style.setProperty("--range-fix-min-offset",-i+"rem"),h.style.setProperty("--range-fix-max-offset",`${o}rem`)}};const c=document.createElement("div");c.className="lexrange relative py-3",this.root.appendChild(c);let h=document.createElement("input");if(h.className=e.LX.mergeClass("lexrangeslider"+(l?" range pointer-events-none":""),a.className),h.min=a.min??0,h.max=a.max??100,h.step=a.step??1,h.type="range",h.disabled=this.disabled,s.constructor==Number&&(s=e.LX.clamp(s,+h.min,+h.max)),a.left&&(s=+h.max-s+ +h.min,h.classList.add("left")),(a.fill??1)||h.classList.add("no-fill"),h.value=s,c.appendChild(h),h.addEventListener("input",e=>{this.set(l?[Math.min(e.target.valueAsNumber,r[1]),r[1]]:e.target.valueAsNumber,!1,e)},{passive:!1}),l||(h.addEventListener("mousedown",function(e){a.onPress&&a.onPress.bind(h)(e,h)},!1),h.addEventListener("mouseup",function(e){a.onRelease&&a.onRelease.bind(h)(e,h)},!1)),this.setLimits=(e,t,s)=>{h.min=e??h.min,h.max=t??h.max,h.step=s??h.step,n._dispatchEvent(h,"input",!0)},e.LX.doAsync(()=>{this.onResize();let t=0;if(l){const i=e.LX.remapRange(s,a.min,a.max,0,1),o=e.LX.remapRange(r[1],a.min,a.max,0,1);t=c.offsetWidth*i+c.offsetWidth*(o-i)*.5-.5*c.offsetWidth}else{const i=.5*e.LX.remapRange(s,a.min,a.max,0,1);t=c.offsetWidth*i-.5*c.offsetWidth}e.LX.asTooltip(c,`${s}${l?`- ${r[1]}`:""}`,{offsetX:t,callback:e=>{this._labelTooltip=e}})}),r.constructor==Array){let t=e.LX.makeElement("input",e.LX.mergeClass("lexrangeslider no-fill pointer-events-none overlap absolute left-0",a.className));t.min=a.min??0,t.max=a.max??100,t.step=a.step??1,t.type="range",t.disabled=this.disabled,this._maxSlider=t;let i=r[1];t.value=i=e.LX.clamp(i,+t.min,+t.max),c.appendChild(t),t.addEventListener("input",e=>{r[1]=Math.max(s,+e.target.valueAsNumber),this.set([s,r[1]],!1,e)},{passive:!1})}}}e.LX.RangeInput=F;class $ extends n{constructor(t,s,i,n={}){const a=n.allowHalf??!1;a||(s=Math.floor(s)),super(e.ComponentType.RATE,t,s,n),this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{d(s=e),n||this._trigger(new o(t,e,a),i)},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 data-[disabled=true]:pointer-events-none",r.dataset.disabled=this.disabled.toString(),this.root.appendChild(r);const l=e.LX.makeContainer(["fit-content","auto"],"flex flex-row gap-1","",r),c=e.LX.makeContainer(["fit-content","auto"],"absolute top-0 flex flex-row gap-1 pointer-events-none","",r),h=e.LX.makeContainer(["fit-content","auto"],"absolute top-0 flex flex-row gap-1 pointer-events-none","",r);l.addEventListener("mousemove",e=>{const t=e.target,s=t.dataset.idx;if(void 0!==s){const i=t.getBoundingClientRect(),o=a&&e.offsetX<.5*i.width;d(s-(o?.5:0))}},!1),l.addEventListener("mouseleave",e=>{d(s)},!1);for(let t=0;t<5;++t){const s=e.LX.makeIcon("Star",{svgClass:"lg fill-current text-accent"});s.dataset.idx=t+1,l.appendChild(s),s.addEventListener("click",e=>{const t=e.target,s=t.getBoundingClientRect(),i=a&&e.offsetX<.5*s.width;this.set(parseFloat(t.dataset.idx)-(i?.5:0))},!1);const i=e.LX.makeIcon("Star",{svgClass:"lg fill-current text-yellow-400"});c.appendChild(i);const o=e.LX.makeIcon("StarHalf",{svgClass:"lg fill-current text-yellow-400"});h.appendChild(o)}const d=e=>{for(let t=0;t<5;++t){const s=e>t+.5,i=c.childNodes[t],o=h.childNodes[t];if(s)i.style.opacity=1;else{i.style.opacity=0;const s=a&&e>t;o.style.opacity=s?1:0}}};d(s),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Rate=$;class V extends n{constructor(t,s,i,o={}){super(e.ComponentType.SIZE,t,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.onResize=e=>{const t=this.root.domName?.style.width??"0px";n.style.width=`calc( 100% - ${t})`},this.root.aspectRatio=2==s.length?s[0]/s[1]:null,this.root.dimensions=[];const n=e.LX.makeElement("div","flex","",this.root);for(let t=0;t<s.length;++t){const a=new e.LX.Panel;if(this.root.dimensions[t]=a.addNumber(null,s[t],e=>{const s=this.value();if(this.root.locked){const i=0==t?1/this.root.aspectRatio:this.root.aspectRatio,o=(1+t)%2;s[o]=e*i,this.root.dimensions[o].set(s[o],!0)}i&&i(s)},{min:0,disabled:this.disabled,precision:o.precision,className:"flex-auto-fill"}),n.appendChild(this.root.dimensions[t].root),t+1!=s.length){const t=e.LX.makeIcon("X",{svgClass:"text-foreground font-bold"});n.appendChild(t)}}if(o.units&&e.LX.makeElement("span","text-muted-foreground align-center content-center font-medium flex-auto-keep select-none",o.units,n),this.root.aspectRatio){const e=new a(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",className:"flex-auto-keep",buttonClass:"h-auto bg-none p-0"});n.appendChild(e.root)}e.LX.doAsync(this.onResize.bind(this))}}e.LX.SizeInput=V;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(t={}){if(this.pages=t.pages??1,this.page=e.LX.clamp(t.page??1,1,this.pages),this._alwaysShowEdges=t.alwaysShowEdges??this._alwaysShowEdges,this._useEllipsis=t.useEllipsis??this._useEllipsis,this._maxButtons=t.maxButtons??this._maxButtons,this._itemsPerPage=t.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 t.onChange&&(this.onChange=t.onChange),"function"==typeof t.onItemsPerPageChange&&(this.onItemsPerPageChange=t.onItemsPerPageChange),this.root=e.LX.makeContainer(["auto","auto"],e.LX.mergeClass("flex flex-row gap-2",t.className)),t.allowChangeItemsPerPage){const t=e.LX.makeContainer(["auto","auto"],"flex flex-row items-center","",this.root),s=new d(null,G.ITEMS_PER_PAGE_VALUES,this._itemsPerPage,e=>{this._itemsPerPage=e,this.onItemsPerPageChange?.(this._itemsPerPage)},{overflowContainer:null});t.appendChild(s.root)}this.pagesRoot=e.LX.makeContainer(["auto","auto"],"flex flex-row overflow-scroll","",this.root),this.refresh()}setPage(t){const s=e.LX.clamp(t,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(e.LX.makeIcon("ChevronLeft").innerHTML,1===this.page,()=>this.prev(),"bg-none "+(1===this.page?"":"hover:bg-secondary"));const t=e.LX.makeContainer(["auto","auto"],"flex flex-row items-center","",this.pagesRoot),s=this._maxButtons+2;if(this.pages<=s)for(let e=1;e<=this.pages;e++)this._makePageButton(t,e);else{const i=this.page,o=this.pages,n=1,a=o,r=this._alwaysShowEdges?1:0,l=s-2,c=Math.floor(l/2);let h=Math.max(1+r,i-c),d=Math.min(o-r,i+c);h<=2&&(h=1+r,d=h+l-1),d>=o-1&&(d=o-r,h=d-l+1),this._alwaysShowEdges&&this._makePageButton(t,n),this._useEllipsis&&h>2&&e.LX.makeElement("span","h-6 px-2 text-lg font-semibold whitespace-nowrap","...",t);for(let e=h;e<=d;e++)this._makePageButton(t,e);this._useEllipsis&&d<o-1&&e.LX.makeElement("span","h-6 px-2 text-lg font-semibold whitespace-nowrap","...",t),this._alwaysShowEdges&&this._makePageButton(t,a)}this._makeButton(e.LX.makeIcon("ChevronRight").innerHTML,this.page===this.pages,()=>this.next(),"bg-none "+(this.page===this.pages?"":"hover:bg-secondary"))}_emitChange(){this.onChange?.(this.page),this.root.dispatchEvent(new CustomEvent("change",{detail:{page:this.page}}))}_makeButton(e,t,s,i,o){const n=new a(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="h-8 "+(t===this.page?"primary text-primary-foreground":"ghost");return this._makeButton(String(t),!1,()=>this.setPage(t),s,e)}}e.LX.Pagination=G;class q extends n{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(t,s,i={}){if(!s)throw"Data is needed to create a table!";super(e.ComponentType.TABLE,t,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 n=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],a=i[e],r=n(o),l=n(a);if(r&&l)return r.getTime()<l.getTime()?-t:r.getTime()>l.getTime()?t:0;const c=Number(o),h=Number(a);return isNaN(c)||isNaN(h)?o<a?-t:o>a?t:0:c<h?-t:c>h?t:0},l=(e,t)=>{s.body=s.body.sort(r.bind(this,e,t)),this.refresh()},c=this;if(this.filter||this.customFilters||this._toggleColumns){const t=e.LX.makeContainer(["100%","auto"],"flex flex-row mb-2");if(this.filter){const s=e.LX.deepCopy(i);s.placeholder=`Filter ${this.filter}...`,s.skipComponent=!0,s.trigger="input",s.inputClass="outline";let o=new h(null,this._currentFilter??"",e=>{this._currentFilter=e,this.refresh()},s);t.appendChild(o.root)}if(null!==this.customFilters){const s=e.LX.makeIcon("CirclePlus",{svgClass:"sm"}),i='<div class="lexcontainer border-r-color place-self-center mx-1" style="width: 1px; height: 70%;"></div>';for(let o of this.customFilters)o.component=new a(null,s.innerHTML+o.name,t=>{const n=o.component.root.querySelector("button");if(o.options){const t=o.options.map((t,a)=>{const r={name:t,checked:!!this.activeCustomFilters[t],callback:(t,a,r)=>{a?this.activeCustomFilters[t]=o.name:delete this.activeCustomFilters[t];const l=Object.keys(this.activeCustomFilters).filter(e=>this.activeCustomFilters[e]==o.name),c=l.reduce((t,s)=>t+e.LX.badge(s,"xs secondary"),"");n.innerHTML=s.innerHTML+o.name+(l.length?i:"")+c,this.refresh()}};return r});e.LX.addDropdownMenu(o.component.root,t,{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 t=e.LX.makeContainer(["240px","auto"],"text-base"),a=new e.LX.Panel({className:"flex flex-col gap-2"});e.LX.makeContainer(["100%","auto"],"px-3 p-2 pb-0 text-base font-medium",o.name,t),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,t=>{o.start=t;const a=o.start!=o.min||o.end!=o.max;n.innerHTML=s.innerHTML+o.name+(a?i+e.LX.badge(`${o.start} - ${o.end} ${o.units??""}`,"xs secondary"):""),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,t=>{o.end=t;const a=o.start!=o.min||o.end!=o.max;n.innerHTML=s.innerHTML+o.name+(a?i+e.LX.badge(`${o.start} - ${o.end} ${o.units??""}`,"xs secondary"):""),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:"ghost"})},a.refresh(),t.appendChild(a.root),new C(o.component.root,[t],{side:"bottom"})}else if("date"==o.type){const t=e.LX.makeContainer(["auto","auto"],"text-base"),a=new e.LX.Panel;e.LX.makeContainer(["100%","auto"],"px-3 p-2 pb-0 text-base font-medium",o.name,t),a.refresh=()=>{if(a.clear(),!o.default){const e=new Date,t=`${e.getDate()}/${e.getMonth()+1}/${e.getFullYear()}`;o.default=[t,t]}const t=new k(o.value??o.default,{onChange:a=>{o.value=a,n.innerHTML=s.innerHTML+o.name+(i+e.LX.badge(`${t.getFullDate()}`,"xs secondary")),this._resetCustomFiltersBtn?.root.classList.remove("hidden"),this.refresh()}});a.attach(t)},a.refresh(),t.appendChild(a.root),new C(o.component.root,[t],{side:"bottom"})}},{buttonClass:"sm outline dashed"}),t.appendChild(o.component.root);this._resetCustomFiltersBtn=new a(null,"resetButton",()=>{this.activeCustomFilters={},this._resetCustomFiltersBtn?.root.classList.add("hidden");for(let e of this.customFilters??[])e.component.root.querySelector("button").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",buttonClass:"ghost"}),t.appendChild(this._resetCustomFiltersBtn?.root),this._resetCustomFiltersBtn?.root.classList.add("hidden")}if(this._toggleColumns){const i=e.LX.makeIcon("Settings2"),o=new a("toggleColumnsBtn",i.innerHTML+"View",(t,i)=>{const o=s.head.map((e,t)=>{const i={name:e,icon:"Check",callback:()=>{s.colVisibilityMap[t]=!s.colVisibilityMap[t];d.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});e.LX.addDropdownMenu(i.target,o,{side:"bottom",align:"end"})},{hideName:!0,buttonClass:"outline"});t.appendChild(o.root),o.root.style.marginLeft="auto"}o.appendChild(t)}const d=e.LX.makeElement("table",i.tableClass,"",o);this.refresh=()=>{this._currentFilter=this._currentFilter??"",d.innerHTML="",this.rowOffsetCount=0;{const t=document.createElement("thead");t.className="lextablehead",d.appendChild(t);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 t=document.createElement("th");t.style.width="0px";const i=document.createElement("input");i.type="checkbox",i.className="lexcheckbox primary",i.checked=s.checkMap[":root"]??!1,t.appendChild(i),i.addEventListener("change",function(){s.checkMap[":root"]=this.checked;const t=d.querySelector("tbody");for(const e of t.childNodes){const t=e.getAttribute("rowId");t&&(s.checkMap[t]=this.checked,e.querySelector("input[type='checkbox']").checked=this.checked)}const i=c.getSelectedRows();e.LX.emitSignal("@rows_selected_changed",i.length)}),this.rowOffsetCount++,o.appendChild(t)}for(const t of s.head){const n=document.createElement("th");n.innerHTML=`<span>${t}</span>`,n.querySelector("span").appendChild(e.LX.makeIcon("MenuArrows",{svgClass:"sm"}));const a=s.head.indexOf(t);this._centered?.indexOf&&(this._centered.indexOf(a)>-1||this._centered.indexOf(t)>-1)&&n.classList.add("centered");const r=[];if(i.columnActions)for(let e of i.columnActions)e.name?r.push({name:e.name,icon:e.icon,className:e.className,callback:()=>{const t=this.data.body.map(e=>[e[a]]);e.callback(t,d)&&this.refresh()}}):console.warn("Invalid column action (missing name):",e);this._sortColumns&&(r.length>0&&r.push(null),r.push({name:"Asc",icon:"ArrowUpZA",callback:l.bind(this,a,1)},{name:"Desc",icon:"ArrowDownZA",callback:l.bind(this,a,-1)})),this._toggleColumns&&(r.length>0&&r.push(null),r.push({name:"Hide",icon:"EyeOff",callback:()=>{s.colVisibilityMap[a]=!1;d.querySelectorAll(`tr > *:nth-child(${a+this.rowOffsetCount+1})`).forEach(e=>{e.style.display="none"===e.style.display?"":"none"})}})),n.addEventListener("click",t=>{0!==r.length&&e.LX.addDropdownMenu(t.target,r,{side:"bottom",align:"start"})}),o.appendChild(n)}if(i.rowActions){const e=document.createElement("th");e.className="sm",o.appendChild(e)}t.appendChild(o)}{const t=document.createElement("tbody");t.className="lextablebody",d.appendChild(t);let o=null,n=!1,a=null;document.addEventListener("mouseup",t=>{if(null===o)return;document.removeEventListener("mousemove",r);const i=d.rows[o];if(i.dY=0,i.classList.remove("dragging"),Array.from(d.rows).forEach(e=>{e.style.transform="",e.style.transition="none"}),e.LX.flushCss(i),a){const t=this._paginator?(this._paginator.page-1)*this.rowsPerPage:0,i=o-1+t,n=a[1]-1+t;e.LX.emitSignal("@on_table_sort",{instance:this,fromIdx:i,targetIdx:n});const r=s.body[i];let l=0;if(i==n)return;if(i>n)for(let e=i;e>n;--e)s.body[e]=s.body[e-1];else{l=1;for(let e=i;e<n;++e)s.body[e]=s.body[e+1]}s.body[n]=r;const c=a[0].parentNode;e.LX.insertChildAtIndex(c,a[0],n+l-t),a=null}o=null,e.LX.doAsync(()=>{Array.from(d.rows).forEach(e=>{e.style.transition="transform 0.2s ease-in"})})});let r=e=>{if(!o)return;const t=d.rows[o];t.dY=t.dY??0,t.dY+=e.movementY,t.style.transform=`translateY(${t.dY}px)`};const l=[];for(let t=0;t<s.body.length;++t){const i=s.body[t];if(this.filter){const t=s.head.indexOf(this.filter);if(t>-1){if(!e.LX.stripHTML(i[t]).toLowerCase().includes(this._currentFilter.toLowerCase()))continue}}if(Object.keys(this.activeCustomFilters).length){let t={};this._resetCustomFiltersBtn?.root.classList.remove("hidden");for(let o in this.activeCustomFilters){const n=this.activeCustomFilters[o];t[n]=t[n]??!1;const a=s.head.indexOf(n);if(a>-1){const s=i[a],r=e.LX.stripTags(s)??s;t[n]=t[n]||r===o}}if(!Object.values(t).reduce((e,t)=>e&&t,!0))continue}if(this.customFilters){let t={};for(let o of this.customFilters){const n=o.name;if("range"==o.type){t[n]=t[n]??!1;const e=s.head.indexOf(n);if(e>-1){const s=parseFloat(i[e]),a=o.start??o.min,r=o.end??o.max;t[n]=t[n]||s>=a&&s<=r}}else if("date"==o.type){t[n]=t[n]??!1;const a=s.head.indexOf(n);if(a>-1){if(!o.value){t[n]=!0;continue}o.value=o.value??o.default;const s=i[a],r=e.LX.dateFromDateString(s),l=e.LX.dateFromDateString(o.value[0]),c=e.LX.dateFromDateString(o.value[1]);t[n]=t[n]||r>=l&&r<=c}}}if(!Object.values(t).reduce((e,t)=>e&&t,!0))continue}l.push(i)}this._paginator&&this._paginator.setPages(this._getNumPages(l.length));const h=this._paginator?(this._paginator.page-1)*this.rowsPerPage:0,u=this._paginator?Math.min(h+this.rowsPerPage,l.length):l.length;for(let p=h;p<u;++p){const h=l[p],u=this.data.body.indexOf(h),m=document.createElement("tr"),g=this._makeRowId(h);if(m.setAttribute("rowId",g),i.sortable){const t=document.createElement("td");t.style.width="0px";const s=e.LX.makeIcon("GripVertical");t.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",r)},!1),m.addEventListener("mouseenter",function(t){if(t.preventDefault(),null!=o&&this.rowIndex!=o&&n!=this.rowIndex){n=this.rowIndex;const t=d.rows[o],s=""!=this.style.transform;this.rowIndex>o?(a=[t,s?this.rowIndex-1:this.rowIndex],this.style.transform=s?"":`translateY(-${this.offsetHeight}px)`):(a=[t,s?this.rowIndex+1:this.rowIndex],this.style.transform=s?"":`translateY(${this.offsetHeight}px)`),e.LX.doAsync(()=>{n=!1})}}),m.appendChild(t)}if(i.selectable){const t=document.createElement("td"),i=document.createElement("input");i.type="checkbox",i.className="lexcheckbox primary",i.checked=s.checkMap[g],t.appendChild(i),i.addEventListener("change",function(){s.checkMap[g]=this.checked;const t=d.querySelector("thead input[type='checkbox']");if(console.assert(t,"Header checkbox not found!"),this.checked){Array.from(d.querySelectorAll("tbody input[type='checkbox']")).filter(e=>!e.checked).length||(t.checked=s.checkMap[":root"]=!0)}else t.checked=s.checkMap[":root"]=!1;const i=c.getSelectedRows();e.LX.emitSignal("@rows_selected_changed",i.length)}),m.appendChild(t)}for(let e=0;e<h.length;++e){const t=h[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 t=document.createElement("td");t.style.width="0px";const o=document.createElement("div");o.className="lextablebuttons",t.appendChild(o);for(const t of i.rowActions){let n=null;"delete"==t?(n=e.LX.makeIcon("Trash3",{title:"Delete Row"}),n.addEventListener("click",()=>{s.body.splice(u,1),this.refresh()})):"menu"==t?(n=e.LX.makeIcon("EllipsisVertical",{title:"Menu"}),n.addEventListener("click",function(t){if(!i.onMenuAction)return;const o=i.onMenuAction(u,s);console.assert(o.length,"Add items to the Menu Action Dropdown!"),e.LX.addDropdownMenu(t.target,o,{side:"bottom",align:"end"})})):(console.assert(t.constructor==Object),n=e.LX.makeIcon(t.icon,{title:t.title}),t.callback&&n.addEventListener("click",e=>{t.callback(u,h,d,e)&&this.refresh()})),console.assert(n),o.appendChild(n)}m.appendChild(t)}t.appendChild(m)}if(i.selectable){const t=this.getSelectedRows();e.LX.emitSignal("@rows_selected_changed",t.length)}if(0==t.childNodes.length){const e=document.createElement("tr"),i=document.createElement("td");i.setAttribute("colspan",s.head.length+this.rowOffsetCount+1),i.className="empty-row",i.innerHTML="No results.",e.appendChild(i),t.appendChild(e)}}for(const e in s.colVisibilityMap){const t=parseInt(e);if(!s.colVisibilityMap[t]){d.querySelectorAll(`tr > *:nth-child(${t+this.rowOffsetCount+1})`).forEach(e=>{e.style.display="none"===e.style.display?"":"none"})}}};const u=this._showSelectedNumber&&i.selectable;if(u||this._paginator){const t=e.LX.makeContainer(["100%","auto"],"flex flex-row px-3 my-1 align-center","",o);if(u){const s=e.LX.makeContainer(["100%","auto"],"flex justify-start items-center","0 row(s) selected.",t);e.LX.addSignal("@rows_selected_changed",(e,t)=>{this._showSelectedNumber&&(s.innerHTML=0===t?"":`${t??0} row(s) selected.`)})}if(this._paginator){e.LX.makeContainer(["100%","auto"],"flex justify-end","",t).appendChild(this._paginator.root)}}this.refresh(),e.LX.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(t){return e.LX.getSupportedDOMName(t.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()}}e.LX.Table=q;class K extends n{tabs;tabDOMs;constructor(t,s,i={}){if(i.hideName=!0,super(e.ComponentType.TABS,t,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,n=!o&&(i.showNames??!1);this.tabDOMs={};let a=document.createElement("div");a.className="lextabscontainer",o||(a.className+=" horizontal");let r=document.createElement("div");r.className="tabs",a.appendChild(r),this.root.appendChild(a),s.findIndex(e=>!0===e.selected)<0&&(s[0].selected=!0);for(let t of s){console.assert(t.name);let s=document.createElement("div");s.className="lextab "+(t.selected?"selected":""),s.innerHTML=n?t.name:"",s.appendChild(e.LX.makeIcon(t.icon??"Hash",{title:t.name,iconClass:t.iconClass,svgClass:"lg"+(t.svgClass?" "+t.svgClass:"")})),this.tabDOMs[t.name]=s;let i=document.createElement("div");if(i.id=t.name.replace(/\s/g,""),i.className="components",i.toggleAttribute("hidden",!t.selected),a.appendChild(i),s.addEventListener("click",e=>{r.querySelectorAll(".lextab").forEach(e=>{e.classList.remove("selected")}),s.classList.add("selected"),a.querySelectorAll(".components").forEach(e=>{e.toggleAttribute("hidden",!0)});const o=a.querySelector("#"+i.id);o?.toggleAttribute("hidden"),t.onSelect&&t.onSelect(this,i)}),r.appendChild(s),t.onCreate){const s=new e.LX.Panel;s.queue(i),t.onCreate.call(this,s,i),s.clearQueue()}}this.tabs=s}select(e){const t=this.tabDOMs[e];t&&t.click()}}e.LX.TabSections=K;class W extends n{generateTags;constructor(t,s,i,n={}){let a=s.replace(/\s/g,"").split(","),r=e.LX.deepCopy(a);super(e.ComponentType.TAGS,t,r,n),this.options.skipDuplicates=n.skipDuplicates??!0,this.onGetValue=()=>e.LX.deepCopy(s),this.onSetValue=(e,s,n)=>{a=[].concat(e),this.generateTags(a),s||this._trigger(new o(t,a,n),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";l.style.width=`calc( 100% - ${t})`};const l=document.createElement("div");l.className="inline-flex flex-wrap gap-1 bg-card/50 rounded-lg pad-xs [&_input]:w-2/3",this.root.appendChild(l),this.generateTags=t=>{l.innerHTML="";for(let s=0;s<t.length;++s){const i=t[s],o=e.LX.mergeClass("lextag bg-primary px-2 py-1 rounded-xl min-w-2 justify-center text-primary-foreground gap-1 text-sm select-none",n.tagClass),a=e.LX.makeElement("span",o,i);if(!this.disabled){const s=e.LX.makeIcon("X",{svgClass:"sm"});a.appendChild(s),s.addEventListener("click",e=>{a.remove(),t.splice(t.indexOf(i),1),this.set(t,!1,e)})}l.appendChild(a)}if(this.disabled)return;let s=document.createElement("input");s.value="",s.placeholder="Add tag...",l.appendChild(s),s.onkeydown=e=>{if(" "==e.key||"Enter"==e.key){const i=s.value.replace(/\s/g,"");if(e.preventDefault(),!i.length||n.skipDuplicates&&t.indexOf(i)>-1)return;t.push(i),this.set(t,!1,e),l.querySelector("input")?.focus()}}},this.generateTags(a),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Tags=W;class U extends n{constructor(t,s,i,n={}){super(e.ComponentType.TEXTAREA,t,s,n),this.onGetValue=()=>s,this.onSetValue=(e,n,a)=>{r.value=s=e,n||this._trigger(new o(t,e,a),i)},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=n.inputWidth??`calc( 100% - ${t})`};let a=document.createElement("div");a.className="lextextarea",a.style.display="flex",this.root.appendChild(a);let r=e.LX.makeElement("textarea",e.LX.mergeClass("w-full text-sm text-foreground bg-card border-color disabled:pointer-events-none disabled:opacity-50 rounded-lg outline-none pad-md",n.inputClass??""));r.value=s??"",r.style.textAlign=n.float??"",r.disabled=this.disabled,Object.assign(r.style,n.style??{}),n.fitHeight&&r.classList.add("field-sizing-content"),(n.resize??1)||r.classList.add("resize-none"),a.appendChild(r),n.placeholder&&r.setAttribute("placeholder",n.placeholder);const l=n.trigger??"default",c=n.submitOnEnterKey??!0;if("default"==l?(r.addEventListener("keydown",function(e){if(c&&"Enter"==e.key&&!e.shiftKey)return e.preventDefault(),!1}),r.addEventListener("keyup",function(e){(c&&"Enter"==e.key&&!e.shiftKey||"Escape"==e.key)&&(e.preventDefault(),r.blur())}),r.addEventListener("focusout",e=>{this.set(e.target?.value,!1,e)})):"input"==l&&r.addEventListener("input",e=>{this.set(e.target?.value,!1,e)}),n.icon){const t=e.LX.makeIcon(n.icon,{iconClass:"absolute z-1 ml-2",svgClass:"sm"});a.appendChild(t)}e.LX.doAsync(()=>{a.style.height=n.height??"",this.onResize()},10)}}e.LX.TextArea=U;class Y extends n{constructor(t,s={}){console.assert(0!==t.length,"Can't create Title Component without text!"),super(e.ComponentType.TITLE,null,null,s);const i="lextitle !w-fit bg-muted text-foreground text-sm font-semibold leading-normal m-3 flex content-center rounded-xl select-none";if(this.root.className=e.LX.mergeClass(i,s.className),s.icon){let t=e.LX.makeIcon(s.icon,{iconClass:"mr-2"});t.querySelector("svg").style.color=s.iconColor||"",this.root.appendChild(t)}let o=document.createElement("span");if(o.innerText=t,this.root.appendChild(o),null!=s.link){let o=e.LX.makeElement("a",`${i} link`,t);o.href=s.link,o.target=s.target??"",this.root.replaceWith(o),this.root=o}Object.assign(this.root.style,s.style??{})}}e.LX.Title=Y;class j extends n{constructor(t,s,i,n={}){if(!t&&!n.label)throw"Set Component Name or at least a label!";super(e.ComponentType.TOGGLE,t,s,n),this.onGetValue=()=>r.checked,this.onSetValue=(e,n,a)=>{e!=s&&(r.checked=s=e,this.root.querySelector(".lextogglesubmenu")?.toggleAttribute("hidden",!e),n||this._trigger(new o(t,e,a),i))},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";a.style.width=n.inputWidth??`calc( 100% - ${t})`};var a=document.createElement("div");a.className="flex flex-row gap-2 items-center",this.root.appendChild(a);let r=e.LX.makeElement("input",e.LX.mergeClass("lextoggle relative inline-grid place-content-center cursor-pointer shrink-0 select-none disabled:pointer-events-none disabled:opacity-50",n.className));r.type="checkbox",r.checked=s,r.iValue=s,r.disabled=this.disabled,a.appendChild(r);let l=document.createElement("span");if(l.className="font-medium w-full overflow-hidden truncate",l.innerHTML=n.label??"On",a.appendChild(l),r.addEventListener("change",e=>{this.set(r.checked,!1,e)}),n.suboptions){let t=e.LX.makeElement("div","lextogglesubmenu w-full p-2");t.toggleAttribute("hidden",!r.checked);const s=new e.LX.Panel;s.queue(t),n.suboptions.call(this,s),s.clearQueue(),this.root.appendChild(t)}e.LX.doAsync(this.onResize.bind(this))}}e.LX.Toggle=j;class Z extends n{locked=!1;setLimits;constructor(t,s,i,r,l={}){t=e.LX.clamp(t,2,4),i=i??new Array(t).fill(0),super(e.ComponentType.VECTOR,s,e.LX.deepCopy(i),l),this.onGetValue=()=>{let e=this.root.querySelectorAll("input[type='number']"),t=[];for(var s of e)t.push(+s.value);return t},this.onSetValue=(t,n,a)=>{if(c.length==t.length){for(let s=0;s<c.length;++s){let o=t[s];o=e.LX.clamp(o,+c[s].min,+c[s].max),o=e.LX.round(o,l.precision)??0,c[s].value=i[s]=o}n||this._trigger(new o(s,i,a),r)}else console.error("Input length does not match vector length.")},this.onResize=e=>{const t=this.root.domName?.style.width??"0px";h.style.width=`calc( 100% - ${t})`},this.setLimits=(e,t,s)=>{};const c=[];var h=document.createElement("div");h.className="lexvector flex",this.root.appendChild(h);const d=this;for(let u=0;u<t;++u){let p=document.createElement("div");p.className="vecbox",p.innerHTML="<span class='"+e.LX.Panel.VECTOR_COMPONENTS[u]+"'></span>";let m=document.createElement("input");m.className="vecinput v"+t,m.min=l.min??-1e24,m.max=l.max??1e24,m.step=l.step??"any",m.type="number",m.id="vec"+t+"_"+e.LX.guidGenerator(),m.idx=u,m.disabled=this.disabled,c[u]=m,p.appendChild(m),i[u].constructor==Number&&(i[u]=e.LX.clamp(i[u],+m.min,+m.max),i[u]=e.LX.round(i[u],l.precision)),m.value=m.iValue=i[u];const g=e.LX.makeIcon("MoveVertical",{iconClass:"drag-icon hidden-opacity",svgClass:"sm"});function f(t){if(document.activeElement!=m&&t.button==e.LX.MOUSE_LEFT_CLICK){var s=d.root.ownerDocument;s.addEventListener("mousemove",C),s.addEventListener("mouseup",v),document.body.classList.add("noevents"),g.classList.remove("hidden-opacity"),t.stopImmediatePropagation(),t.stopPropagation(),document.pointerLockElement||p.requestPointerLock(),l.onPress&&l.onPress.bind(m)(t,m)}}function C(t){let s=-t.movementY;if(0!=s){let i=l.step??1;if(t.shiftKey?i=10:t.altKey&&(i=.1),d.locked)for(let t of c)t.value=e.LX.round(+t.valueAsNumber+i*s,l.precision),n._dispatchEvent(t,"change");else m.value=e.LX.round(+m.valueAsNumber+i*s,l.precision),n._dispatchEvent(m,"change")}t.stopPropagation(),t.preventDefault()}function v(e){var t=d.root.ownerDocument;t.removeEventListener("mousemove",C),t.removeEventListener("mouseup",v),document.body.classList.remove("noevents"),g.classList.add("hidden-opacity"),document.pointerLockElement&&document.exitPointerLock(),l.onRelease&&l.onRelease.bind(m)(e,m)}p.appendChild(g),m.addEventListener("wheel",function(t){if(t.preventDefault(),m!==document.activeElement)return;let s=l.step??1;if(t.shiftKey?s=10:t.altKey&&(s=.1),d.locked)for(let i of c)i.value=e.LX.round(+i.valueAsNumber-s*(t.deltaY>0?1:-1),l.precision),n._dispatchEvent(i,"change");else m.value=e.LX.round(+m.valueAsNumber-s*(t.deltaY>0?1:-1),l.precision),n._dispatchEvent(m,"change")},{passive:!1}),m.addEventListener("change",t=>{if(isNaN(t.target.value))return;let s=e.LX.clamp(t.target.value,+m.min,+m.max);if(s=e.LX.round(s,l.precision),this.locked)for(let e of c)e.value=s,i[e.idx]=s;else m.value=s,i[t.target.idx]=s;this.set(i,!1,t)},!1),p.addEventListener("mousedown",f),h.appendChild(p)}if(void 0===l.min&&void 0===l.max||(this.setLimits=(e,t,s)=>{for(let i of c)i.min=e??i.min,i.max=t??i.max,i.step=s??i.step;this.set(i,!0)}),!l.skipLock){const y=new a(null,"",e=>{this.locked=e},{title:"Lock",icon:"LockOpen",swap:"Lock",buttonClass:"h-auto bg-none p-0"});h.appendChild(y.root)}e.LX.doAsync(this.onResize.bind(this))}}e.LX.Vector=Z;class Q{name;components;closed;root;content;grabber;panel;onclick;oncontextmenu;constructor(t,s={}){this.name=t;var i=document.createElement("div");s.id&&(i.id=s.id),i.className=e.LX.mergeClass("lexbranch bg-secondary/50 dark:bg-card text-secondary-foreground dark:text-card-foreground w-full rounded-lg my-0 mx-auto",s.className);var o=this;this.closed=s.closed??!1,this.root=i,this.components=[],this.panel=null;const n=e.LX.makeElement("div","lexbranchtitle flex cursor-pointer select-none pad-lg text-lg","",i);if(s.icon){const t=e.LX.makeIcon(s.icon,{iconClass:"mr-2"});n.appendChild(t)}n.innerHTML+=t||"Branch";const a=e.LX.makeIcon("Right",{iconClass:"switch-branch-button",svgClass:"sm"});n.appendChild(a);var r=e.LX.makeElement("div","lexbranchcontent pad-xs","",i);r.id=t.replace(/\s/g,""),this.content=r,this._addBranchSeparator(),this.closed&&(n.classList.add("closed"),i.classList.add("closed"),this.grabber.setAttribute("hidden",!0),e.LX.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"),e.LX.emitSignal("@on_branch_closed",n.classList.contains("closed"))},this.oncontextmenu=function(t){t.preventDefault(),t.stopPropagation(),n.parentElement.classList.contains("dialog")||e.LX.addContextMenu("Dock",t,e=>{t.preventDefault(),e.add("Floating",o._onMakeFloating.bind(o))},{icon:"WindowRestore"})},n.addEventListener("click",this.onclick),n.addEventListener("contextmenu",this.oncontextmenu)}_onMakeFloating(){const t=new e.LX.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!"),t.branchData={name:this.name,components:this.components,closed:this.closed,panel:this.panel,childIndex:s},this.root.remove()}_addBranchSeparator(){const t=document.createElement("div");t.className="lexcomponentseparator",t.style.width="100%",t.style.background="none";const s=document.createElement("div");s.innerHTML="▾",t.appendChild(s),e.LX.doAsync(()=>{s.style.marginLeft=parseFloat(e.LX.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(t){let i=t.movementX;if(0!=i){const t=parseFloat(s.style.marginLeft);s.style.marginLeft=e.LX.clamp(t+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(t)}_updateComponents(){var t=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=t,n.style.minWidth=t,i.type){case e.LX.BaseComponent.CUSTOM:case e.LX.BaseComponent.ARRAY:continue}a.style.width="-moz-calc( 100% - "+t+" )",a.style.width="-webkit-calc( 100% - "+t+" )",a.style.width="calc( 100% - "+t+" )"}}}e.LX.Branch=Q;let J=class{root;branches;components;signals;queuedContainer;_branchOpen;_currentBranch;_queue;_inlineComponentsLeft;_inlineQueuedContainer;_inlineExtraClass;_inlineContainer;_inlineComponents;constructor(t={}){const s=e.LX.makeElement("div",e.LX.mergeClass("lexpanel m-0 pad-md overflow-hidden overflow-y-scroll text-foreground scrollbar-hidden",t.className));t.id&&(s.id=t.id),s.style.width=t.width||"100%",s.style.height=t.height||"100%",Object.assign(s.style,t.style??{}),this.root=s,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 t in this.components)if(this.components[t].options&&this.components[t].options.signal){const s=this.components[t].options.signal;for(let i=0;i<e.LX.signals[s].length;i++)e.LX.signals[s][i]==this.components[t]&&(e.LX.signals[s]=[...e.LX.signals[s].slice(0,i),...e.LX.signals[s].slice(i+1)])}if(this.signals)for(let t=0;t<this.signals.length;t++){let s=Object.values(this.signals[t])[0],i=s.options.signal;for(let t=0;t<e.LX.signals[i].length;t++)e.LX.signals[i][t]==s&&(e.LX.signals[i]=[...e.LX.signals[i].slice(0,t),...e.LX.signals[i].slice(t+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(t,s={}){s.placeholder=t.constructor==String?t:"Filter properties..",s.skipComponent=s.skipComponent??!0,s.skipInlineCount=!0;const i=new h(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=e.LX.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 t=document.createElement("div");t.className="lexseparator";let s=new n(e.ComponentType.SEPARATOR);s.root=t,this._currentBranch?(this._currentBranch.content.appendChild(t),this._currentBranch.components.push(s)):this.root.appendChild(t)}addTitle(e,t={}){const s=new Y(e,t);return this._attachComponent(s)}addText(e,t,s,i={}){const o=new h(e,t,s,i);return this._attachComponent(o)}addTextArea(e,t,s,i={}){const o=new U(e,t,s,i);return this._attachComponent(o)}addLabel(t,s={}){s.disabled=!0,s.inputClass=e.LX.mergeClass("bg-none",s.inputClass);const i=this.addText(null,t,null,s);return i.type=e.ComponentType.LABEL,i}addButton(e,t,s,i={}){const o=new a(e,t,s,i);return this._attachComponent(o)}addComboButtons(e,t,s={}){const i=new y(e,t,s);return this._attachComponent(i)}addCard(e,t={}){const s=new p(e,t);return this._attachComponent(s)}addForm(e,t,s,i={}){const o=new M(e,t,s,i);return this._attachComponent(o)}addContent(t,s,i={}){if(console.assert(s,"Empty content!"),s.constructor==String){const e=document.createElement("div");e.innerHTML=s,s=e.childElementCount>1?e:e.firstElementChild}i.hideName=!0;let o=new n(e.ComponentType.CONTENT,t,null,i);return o.root.appendChild(s),this._attachComponent(o)}async addImage(t,s,i={}){console.assert(0!==s.length,"Empty src/url for Image!");let o=document.createElement("div");o.className="leximage",o.style.width="100%";let a=document.createElement("img");a.src=s,Object.assign(a.style,i.style??{}),o.appendChild(a);let r=new n(e.ComponentType.IMAGE,t,null,i);return r.root.appendChild(o),a.decode(),this._attachComponent(r)}addSelect(e,t,s,i,o={}){const n=new d(e,t,s,i,o);return this._attachComponent(n)}addCurve(e,t,s,i={}){const o=new x(e,t,s,i);return this._attachComponent(o)}addDial(e,t,s,i={}){const o=new T(e,t,s,i);return this._attachComponent(o)}addLayers(e,t,s,i={}){const o=new A(e,t,s,i);return this._attachComponent(o)}addArray(e,t=[],s,i={}){const o=new u(e,t,s,i);return this._attachComponent(o)}addList(e,t,s,i,o={}){const n=new X(e,t,s,i,o);return this._attachComponent(n)}addTags(e,t,s,i={}){const o=new W(e,t,s,i);return this._attachComponent(o)}addCheckbox(e,t,s,i={}){const o=new m(e,t,s,i);return this._attachComponent(o)}addToggle(e,t,s,i={}){const o=new j(e,t,s,i);return this._attachComponent(o)}addRadioGroup(e,t,s,i,o={}){const n=new H(e,t,s,i,o);return this._attachComponent(n)}addColor(e,t,s,i={}){const o=new v(e,t,s,i);return this._attachComponent(o)}addRange(e,t,s,i={}){const o=new F(e,t,s,i);return this._attachComponent(o)}addNumber(e,t,s,i={}){const o=new c(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 Z(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 V(e,t,s,i);return this._attachComponent(o)}addOTP(e,t,s,i={}){const o=new z(e,t,s,i);return this._attachComponent(o)}addPad(e,t,s,i={}){const o=new D(e,t,s,i);return this._attachComponent(o)}addProgress(e,t,s={}){const i=new B(e,t,s);return this._attachComponent(i)}addFile(e,t,s={}){const i=new E(e,t,s);return this._attachComponent(i)}addTree(e,t,s={}){const i=new R(e,t,s);return this._attachComponent(i)}addTabSections(e,t,s={}){const i=new K(e,t,s);return this._attachComponent(i)}addCounter(e,t,s,i={}){const o=new L(e,t,s,i);return this._attachComponent(o)}addTable(e,t,s={}){const i=new q(e,t,s);return this._attachComponent(i)}addDate(e,t,s,i={}){const o=new S(e,t,s,i);return this._attachComponent(o)}addMap2D(e,t,s,i={}){const o=new I(e,t,s,i);return this._attachComponent(o)}addRate(e,t,s,i={}){const o=new $(e,t,s,i);return this._attachComponent(o)}};e.LX.Panel=J;class ee{area;options;buttons;constructor(e,t,s={}){this.area=e,this.options=s,this.buttons={},this._buildButtons(t,s)}_buildButtons(t,s={}){s.className="lexoverlaybuttons flex justify-start gap-2 bg-card m-2 p-1 rounded-2xl border-color";let i=this.area.addPanel(s),o=null;const n=e.LX.makeElement("div","lexoverlaybuttonscontainer absolute flex top-0 w-full pointer-events-none");n.appendChild(i.root),this.area.attach(n);const a=s.float;let r="";if(a){for(let e=0;e<a.length;e++){switch(a[e]){case"h":case"t":case"l":break;case"v":r+=" vertical";break;case"m":r+=" middle";break;case"b":r+=" bottom";break;case"c":r+=" center";break;case"r":r+=" right"}}n.className+=` ${r}`}const l=(e,t,s)=>{const n={width:"auto",selectable:e.selectable,selected:e.selected,icon:e.icon,img:e.img,className:e.class??"",buttonClass:e.buttonClass??"x",title:e.name,overflowContainerX:i.root,swap:e.swap};t&&(o||(o=document.createElement("div"),o.className="lexoverlaygroup flex flex-none bg-secondary rounded-xl",i.queuedContainer=o),n.parent=o);let a=e.callback,r=null;r=e.options?i.addSelect(null,e.options,e.value??e.name,a,n):i.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,r.root)},n),this.buttons[e.name]=r,o&&s&&(i.root.appendChild(o),o=null,i.clearQueue())};!function(){i.clear();for(let e of t){if(null===e){const e=document.createElement("div");e.className="lexoverlayseparator"+r,i.root.appendChild(e);continue}if(e.constructor===Array)for(let t=0;t<e.length;++t){let s=e[t];s.group=e,l(s,!0,t==e.length-1)}else l(e)}if(a){var e=0;i.root.childNodes.forEach(t=>{e+=t.offsetHeight}),n.className.includes("middle")&&(n.style.top="-moz-calc( 50% - "+.5*e+"px )",n.style.top="-webkit-calc( 50% - "+.5*e+"px )",n.style.top="calc( 50% - "+.5*e+"px )")}}()}}e.LX.AreaOverlayButtons=ee;let te=class t{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(t={}){var s=document.createElement("div");t.id&&(s.id=t.id),s.className=e.LX.mergeClass("lexarea m-0 bg-background text-foreground",t.className);var i=t.width||"100%",o=t.height||"100%";this.setLimitBox(t.minWidth,t.minHeight,t.maxWidth,t.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&&!t.skipAppend&&n.appendChild(this.root),t.layout&&this.setLayout(t.layout);let a=t.overlay;if(a){this.root.classList.add("overlay-"+a),t.left?this.root.style.left=t.left:t.right?this.root.style.right=t.right:t.top?this.root.style.top=t.top:t.bottom&&(this.root.style.bottom=t.bottom);if((t.draggable??!0)&&e.LX.makeDraggable(s,t),t.resizeable&&s.classList.add("resizeable"),t.resize){this.splitBar=document.createElement("div");let r="left"==a||"right"==a?"horizontal":"vertical";if(this.type=a,this.splitBar.className="lexsplitbar "+r,"right"==a)this.splitBar.style.width=e.LX.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.left=-e.LX.DEFAULT_SPLITBAR_SIZE/2+"px";else if("left"==a){let p=Math.min(document.body.clientWidth-e.LX.DEFAULT_SPLITBAR_SIZE,this.root.clientWidth);this.splitBar.style.width=e.LX.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.left=p+e.LX.DEFAULT_SPLITBAR_SIZE/2+"px"}else if("top"==a){let m=Math.min(document.body.clientHeight-e.LX.DEFAULT_SPLITBAR_SIZE,this.root.clientHeight);this.splitBar.style.height=e.LX.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.top=m+e.LX.DEFAULT_SPLITBAR_SIZE/2+"px"}else"bottom"==a&&(this.splitBar.style.height=e.LX.DEFAULT_SPLITBAR_SIZE+"px",this.splitBar.style.top=-e.LX.DEFAULT_SPLITBAR_SIZE/2+"px");this.splitBar.addEventListener("mousedown",h),this.root.appendChild(this.splitBar);const l=this;let c=[0,0];function h(e){const t=l.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"),l.splitBar.classList.add("nocursor")}function d(t){switch(l.type){case"right":var s=c[0]-t.x,i=l.root.offsetWidth+s;l.root.style.width=i+"px";break;case"left":s=c[0]-t.x,i=Math.min(document.body.clientWidth-e.LX.DEFAULT_SPLITBAR_SIZE,l.root.offsetWidth-s);l.root.style.width=i+"px",l.splitBar.style.left=i+e.LX.DEFAULT_SPLITBAR_SIZE/2+"px";break;case"top":s=c[1]-t.y,i=Math.min(document.body.clientHeight-e.LX.DEFAULT_SPLITBAR_SIZE,l.root.offsetHeight-s);l.root.style.height=i+"px",l.splitBar.style.top=i+e.LX.DEFAULT_SPLITBAR_SIZE/2+"px";break;case"bottom":s=c[1]-t.y,i=l.root.offsetHeight+s;l.root.style.height=i+"px"}c[0]=t.x,c[1]=t.y,t.stopPropagation(),t.preventDefault(),l.onresize&&l.onresize(l.root.getBoundingClientRect())}function u(e){const t=l.root.ownerDocument;t.removeEventListener("mousemove",d),t.removeEventListener("mouseup",u),document.body.classList.remove("nocursor"),l.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(t){if(this.layout=e.LX.deepCopy(t),!t.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,r]=e.split({type:i,resize:o,minimizable:n,sizes:[t.splits[0].size,t.splits[1].size]});s(a,t.splits[0]),s(r,t.splits[1])};s(this,t)}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 r=s.minimizable??!1,l=(s.resize??!0)||r,c=s.fixedSize??!l,h=0,d=[],u=[];if(this.offset=0,l&&(this.resize=l,this.splitBar=document.createElement("div"),this.splitBar.className="lexsplitbar "+i,"horizontal"==i?this.splitBar.style.width=e.LX.DEFAULT_SPLITBAR_SIZE+"px":this.splitBar.style.height=e.LX.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=e.LX.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 t=a.width,s=e.LX.parsePixelSize(o[0],t)/t*100,i=e.LX.parsePixelSize(o[1],t)/t*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 t=a.height,s=e.LX.parsePixelSize(o[0],t)/t*100,i=e.LX.parsePixelSize(o[1],t)/t*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 t({width:d[0],height:d[1],skipAppend:!0,className:"split"+(s.menubar||s.sidebar?"":" origin")}),m=new t({width:u[0],height:u[1],skipAppend:!0,className:"split"});if(!(c||a.width&&a.height)){const t=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 t=a.width,s=e.LX.parsePixelSize(o[0],t)/t*100,i=e.LX.parsePixelSize(o[1],t)/t*100;d[0]=`calc(${s}% - ${h}px)`,u[0]=`calc(${i}% - ${h}px)`}else{const t=a.height,s=e.LX.parsePixelSize(o[0],t)/t*100,i=e.LX.parsePixelSize(o[1],t)/t*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(),t.disconnect()}});e.LX.doAsync(()=>{t.observe(this.root)},100)}if(n&&"vertical"==i&&(this._autoVerticalResizeObserver=new ResizeObserver(t=>{for(const s of t){const t=e.LX.getComputedSize(s.target);m.root.style.height="calc(100% - "+t.height+"px )"}}),this._autoVerticalResizeObserver.observe(p.root)),l&&r&&(this.splitExtended=!1,m.root.addEventListener("animationend",t=>{const s=getComputedStyle(m.root).opacity;m.root.classList.remove(t.animationName+"-"+i),m.root.style.opacity=s,e.LX.flushCss(m.root)}),this.splitBar.addEventListener("contextmenu",t=>{t.preventDefault(),e.LX.addContextMenu(null,t,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),l&&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),!l)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(t){let[s,i]=t;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()),e.LX.doAsync(()=>{this.size=[this.root.clientWidth,this.root.clientHeight],this.propagateEvent("onresize")},150)}extend(){if(this.splitExtended)return;let[t,s]=this.sections;this.splitExtended=!0,t.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)),e.LX.doAsync(()=>{this.propagateEvent("onresize")},100)}reduce(){if(!this.splitExtended)return;this.splitExtended=!1;let[t,s]=this.sections;t.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),e.LX.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 J(e);return this.attach(t),this.panels.push(t),t}addMenubar(t,s={}){let i=new r(t,s);e.LX.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-100"),s.parentClass&&(o.root.className=e.LX.mergeClass(o.root.className,s.parentClass)),i}addSidebar(t,s={}){let i=new e.LX.Sidebar({callback:t,...s});t&&t(i),i.update(),e.LX.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",r=n?[a,null]:[null,a],[l,c]=this.split({type:"horizontal",sizes:r,resize:!1,sidebar:!0});i.siblingArea=n?c:l;let h=n?l:c;return h.attach(i),h.isSidebar=!0,s.parentClass&&(h.root.className=e.LX.mergeClass(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 ee(this,e,t),this.overlayButtons)}addTabs(e={}){const t=new l(this,e);return e.folding&&(this.parentArea?._disableSplitResize(),this.root.style.paddingTop="4px"),t}_moveSplit(t,s=!1,i=0){if(!this.type)throw"No split area";if(void 0===t)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],r=a.root,l="- "+e.LX.DEFAULT_SPLITBAR_SIZE+"px";let c=null;if(s||(c=n.style.transition,n.style.transition=r.style.transition="none"),"horizontal"==this.type){var h=Math.max(r.offsetWidth+t,parseInt(a.minWidth));i&&(h=i);const e=h/this.size[0]*100,s=Math.max(0,100-e);n.style.width=`-moz-calc(${s}% ${l})`,n.style.width=`-webkit-calc( ${s}% ${l})`,n.style.width=`calc( ${s}% ${l})`,r.style.width=`${e}%`,r.style.width=`${e}%`,r.style.width=`${e}%`,o.maxWidth!=1/0&&(r.style.minWidth=`calc( 100% - ${parseInt(o.maxWidth)}px )`)}else{const s=this.size[1];h=Math.max(r.offsetHeight+t+a.offset,parseInt(a.minHeight));h=Math.min(s-e.LX.DEFAULT_SPLITBAR_SIZE,h),i&&(h=i);const c=h/s*100,d=Math.max(0,100-c);n.style.height=`-moz-calc(${d}% ${l})`,n.style.height=`-webkit-calc( ${d}% ${l})`,n.style.height=`calc( ${d}% ${l})`,r.style.height=`${c}%`,r.style.height=`${c}%`,r.style.height=`${c}%`,o.maxHeight!=1/0&&(r.style.minHeight=`calc( 100% - ${parseInt(o.maxHeight)}px )`)}s||(n.style.transition=r.style.transition=c),e.LX.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 se(t,s=!0){t="light"==t?"light":"dark",document.documentElement.setAttribute("data-mode",t),document.documentElement.classList.toggle("dark","dark"==t),s&&localStorage.setItem("lxColorScheme",t),e.LX.emitSignal("@on_new_color_scheme",t)}function ie(){return document.documentElement.getAttribute("data-mode")??"dark"}function oe(e,t){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 s=parseInt(e,16),i=(s>>(8===e.length?24:16)&255)/255,o=(s>>(8===e.length?16:8)&255)/255,n=(s>>(8===e.length?8:0)&255)/255,a=(8===e.length?255&s:4===e.length?parseInt(e.slice(-2),16):255)/255;return{r:i,g:o,b:n,a:t?t/100:a}}function ne(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 r=0;0!==a&&(r=n===t?(s-i)/a%6:n===s?(i-t)/a+2:(t-s)/a+4,r*=60,r<0&&(r+=360));return{h:r,s:0===n?0:a/n,v:n,a:o}}e.LX.Area=te,e.LX.twMerge=t.extendTailwindMerge({extend:{classGroups:{pad:[{pad:["xs","sm","md","lg","xl","2xl"]}]}}}),e.LX.clamp=function(e,t,s){return Math.min(Math.max(e,t),s)},e.LX.round=function(e,t){return 0==t?Math.floor(e):+e.toFixed(t??2).replace(/([0-9]+(\.[0-9]+[1-9])?)(\.?0+$)/,"$1")},e.LX.remapRange=function(e,t,s,i,o){return(e-t)*(o-i)/(s-t)+i},"undefined"!=typeof performance?e.LX.getTime=performance.now.bind(performance):"undefined"!=typeof Date&&Date.now?e.LX.getTime=Date.now.bind(Date):e.LX.getTime=function(){return(new Date).getTime()},e.LX.doAsync=function(e,t){setTimeout(e,t??0)},e.LX.flushCss=function(e){e.offsetHeight},e.LX.deleteElement=function(e){e&&e.remove()},e.LX.toCamelCase=function(e){return e.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(e,t)=>t.toUpperCase())},e.LX.toTitleCase=function(e){return e.replace(/-/g," ").toLowerCase().replace(/\b\w/g,e=>e.toUpperCase())},e.LX.toKebabCase=function(e){return e.replace(/([A-Z])/g,"-$1").replace(/[\s_]+/g,"-").replace(/^-/,"").toLowerCase()},e.LX.toSnakeCase=function(e){return e.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/[\s\-]+/g,"_").toLowerCase()},e.LX.getSupportedDOMName=function(e){console.assert("string"==typeof e,"getSupportedDOMName: Text is not a string!");let t=e.trim();return t=t.replace(/\//g,"_slash_").replace(/@/g,"_at_").replace(/\+/g,"_plus_").replace(/\./g,"_dot_"),t=t.replace(/[^a-zA-Z0-9_-]/g,"_"),/^[0-9]/.test(t)&&(t="_"+t),t},e.LX.has=function(t){return e.LX.extensions.indexOf(t)>-1},e.LX.getExtension=function(e){return e.includes(".")?e.split(".").pop():null},e.LX.stripHTML=function(e){const t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||""},e.LX.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}},e.LX.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!"},e.LX.deepCopy=function(e){return JSON.parse(JSON.stringify(e))},e.LX.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},e.LX.setThemeColor=function(t){document.documentElement.className=`theme-${t}`;const s=e.LX.getMode();document.documentElement.classList.toggle("dark","dark"==s)},e.LX.setMode=se,e.LX.getMode=ie,e.LX.switchMode=function(){se("dark"==ie()?"light":"dark")},e.LX.setSystemMode=function(){se(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark"),localStorage.removeItem("lxColorScheme"),e.LX._mqlPrefersDarkScheme&&(e.LX._mqlPrefersDarkScheme.removeEventListener("change",e.LX._onChangeSystemTheme),e.LX._mqlPrefersDarkScheme.addEventListener("change",e.LX._onChangeSystemTheme))},e.LX.setCSSVariable=function(e,t){document.querySelector(":root").style.setProperty("--"+e,t)},e.LX.getCSSVariable=function(t){const[s,i]=t.split("/"),o=document.querySelector(":root"),n=getComputedStyle(o);let a=n.getPropertyValue("--"+s);if(!a)return"";if(a.includes("light-dark")){a="light"==n.getPropertyValue("color-scheme")?a.substring(a.indexOf("(")+1,a.indexOf(",")).replace(/\s/g,""):a.substring(a.indexOf(",")+1,a.indexOf(")")).replace(/\s/g,"")}if(i){if(a.includes("/"))return a;if(a.startsWith("rgb(")||a.startsWith("hsl(")||a.startsWith("oklch(")||a.startsWith("lab(")||a.startsWith("lch("))return a.replace(/\)$/,` / ${parseFloat(i)/100})`);if(a.startsWith("#")){const t=e.LX.hexToRgb(a,i);return e.LX.rgbToHex(t)}}return a},e.LX.switchSpacing=function(){const t=document.documentElement.getAttribute("data-spacing")??"default";document.documentElement.setAttribute("data-spacing","default"==t?"compact":"default"),e.LX.emitSignal("@on_new_spacing_layout",t)},e.LX.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")},e.LX.hexToRgb=oe,e.LX.hexToHsv=function(e){return ne(oe(e))},e.LX.rgbToHex=function(t,s=255){const i=[t.r,t.g,t.b];return null!=t.a&&i.push(t.a),"#"+i.map(t=>{const i=(t=Math.floor(e.LX.clamp(t*s,0,s))).toString(16);return 1===i.length?"0"+i:i}).join("")},e.LX.oklchToHex=function(t){const s=t.match(/oklch\(\s*([\d.]+)%\s+([\d.]+)\s+([\d.]+)\s*\)/);if(!s)return console.error("Invalid OKLCH format"),"#000";let[,i,o,n]=s;const a=parseFloat(i)/100,r=parseFloat(n)*Math.PI/180,l=parseFloat(o)*Math.cos(r),c=parseFloat(o)*Math.sin(r),h=(a+.3963377774*l+.2158037573*c)**3,d=(a-.1055613458*l-.0638541728*c)**3,u=(a-.0894841775*l-1.291485548*c)**3;let p=4.0767416621*h-3.3077115913*d+.2309699292*u,m=-1.2684380046*h+2.6097574011*d-.3413193965*u,g=-.0041960863*h-.7034186147*d+1.707614701*u;const f=e=>e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055;return p=f(p),m=f(m),g=f(g),e.LX.rgbToHex({r:p,g:m,b:g})},e.LX.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}},e.LX.rgbToHsv=ne,e.LX.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)),r=i-n;let l=0,c=0,h=0;return t<60?(l=n,c=a,h=0):t<120?(l=a,c=n,h=0):t<180?(l=0,c=n,h=a):t<240?(l=0,c=a,h=n):t<300?(l=a,c=0,h=n):(l=n,c=0,h=a),{r:l+r,g:c+r,b:h+r,a:o}},e.LX.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}`)},e.LX.measureRealWidth=function(t,s=8){var i=document.createElement("span");i.className="lexinputmeasure",i.innerHTML=t,document.body.appendChild(i);var o=i.getBoundingClientRect();return e.LX.deleteElement(i),o.width+s},e.LX.guidGenerator=function(){var e=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return e()+"-"+e()+"-"+e()},e.LX.escapeRegExp=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},e.LX.wildcardToRegExp=function(e){const t=e.replace(/([.+^${}()|[\]\\])/g,"\\$1").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp("^"+t+"$","i")},e.LX.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},e.LX.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},e.LX.makeDraggable=function(t,s={}){let i=0,o=0,n=null,a=s.targetClass,r=s.dragMargin??3,l=(s,n,a)=>{const l=t.parentElement?t.parentElement.getBoundingClientRect():{x:0,y:0,width:0,height:0},c="fixed"==t.style.position?new P(l.x,l.y):new P;a=a??s.clientX-i-l.x,n=n??s.clientY-o-l.y,t.style.left=e.LX.clamp(a,r+c.x,c.x+l.width-t.offsetWidth-r)+"px",t.style.top=e.LX.clamp(n,r+c.y,c.y+l.height-t.offsetHeight-r)+"px",t.style.translate="none"};s.autoAdjust&&l(null,parseInt(t.style.left),parseInt(t.style.top));let c=e.LX.guidGenerator();t["draggable-id"]=c;let h=s.onMove?e=>{n&&s.onMove&&s.onMove(n)}:e=>{n&&l(e)},d=s.onDragStart;t.setAttribute("draggable","true"),t.addEventListener("mousedown",function(e){n=e.target.classList.contains(a)||!a?e.target:null}),t.addEventListener("dragstart",function(a){if(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation(),!n)return;var r=new Image;r.src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=",a.dataTransfer&&(a.dataTransfer.setDragImage(r,0,0),a.dataTransfer.effectAllowed="move");const l=a.target.getBoundingClientRect(),c=n.parentElement.getBoundingClientRect(),u="fixed"==n.style.position?new P(c.x,c.y):new P;i=a.clientX-l.x-u.x,o=a.clientY-l.y-u.y,document.addEventListener("mousemove",h),n.eventCatched=!0,(s.updateLayers??1)&&(e.LX.activeDraggable&&(e.LX.activeDraggable.style.zIndex=e.LX.DRAGGABLE_Z_INDEX),e.LX.activeDraggable=t,e.LX.activeDraggable.style.zIndex=e.LX.DRAGGABLE_Z_INDEX+1),d&&d(n,a)},!1),document.addEventListener("mouseup",e=>{n&&(n=null,document.removeEventListener("mousemove",h))})},e.LX.makeCollapsible=function(t,s,i,o={}){t.classList.add("collapsible");const n=o.collapsed??!0,a=e.LX.makeIcon("Right");a.classList.add("collapser"),n&&(a.dataset.collapsed="true",s.style.display="none"),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")}),t.appendChild(a),(i=i??t.parentElement).appendChild(s)},e.LX.makeCodeSnippet=function(t,s,i={}){if(!e.LX.has("CodeEditor"))return void console.error("Import the CodeEditor component to create snippets!");const o=document.createElement("div");o.className=e.LX.mergeClass("lexcodesnippet relative rounded-xl overflow-hidden",i.className),o.style.width=s?s[0]:"auto",o.style.height=s?s[1]:"auto";const n=new te({xskipAppend:!0});return new e.LX.CodeEditor(n,{skipInfo:!0,disableEdition:!0,allowAddScripts:!1,name:i.tabName,onReady:e=>{if(e.setText(t,i.language??"Plain Text"),i.linesAdded){const t=e.root.querySelector(".code");for(let e of i.linesAdded){const s=e;if(s.constructor==Number)t.childNodes[s-1].classList.add("added");else if(s.constructor==Array)for(let e=s[0]-1;e<=s[1]-1;e++)t.childNodes[e].classList.add("added")}}if(i.linesRemoved){const t=e.root.querySelector(".code");for(let e of i.linesRemoved){const s=e;if(s.constructor==Number)t.childNodes[s-1].classList.add("removed");else if(s.constructor==Array)for(let e=s[0]-1;e<=s[1]-1;e++)t.childNodes[e].classList.add("removed")}}if(i.windowMode){const t=document.createElement("div");t.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",t.appendChild(s),t.appendChild(i),t.appendChild(o);e.root.querySelector(".lexareatabs").prepend(t)}(i.lineNumbers??1)||e.root.classList.add("no-gutter")}}),o.appendChild(n.root),o},e.LX.makeKbd=function(t,s=!0,i=""){const o={Ctrl:"⌃",Enter:"↩",Shift:"⇧",CapsLock:"⇪",Meta:"⌘",Option:"⌥",Alt:"⌥",Tab:"⇥",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Space:"␣"},n=e.LX.makeContainer(["auto","auto"],"text-muted-foreground font-sans text-xs inline-flex\n ml-auto pointer-events-none select-none items-center justify-center gap-1");for(const a of t)e.LX.makeContainer(["auto","auto"],"bg-muted px-1 rounded-sm "+i,s?o[a]??a:a,n);return n},e.LX.makeBreadcrumb=function(t,s={}){const i=e.LX.makeContainer(["auto","auto"],"flex flex-row gap-1"),o=s.separatorIcon??"ChevronRight",n=s.maxItems??4,a=t.length-n;if(a>0){const e={name:"...",ellipsis:t.splice(1,a+1).map(e=>e.name).join("/")};t.splice(1,0,e)}for(let s=0;s<t.length;++s){const n=t[s];if(console.assert(n.name,"Breadcrumb item must have a name!"),0!=s){const t=e.LX.makeIcon(o,{svgClass:"sm text-foreground separator"});i.appendChild(t)}const a=s==t.length-1,r=e.LX.makeContainer(["auto","auto"],"p-1 flex flex-row gap-1 items-center "+(a?"text-foreground":"text-muted-foreground"));i.appendChild(r);let l=e.LX.makeElement("p","",n.name);if(n.icon&&r.appendChild(e.LX.makeIcon(n.icon,{svgClass:"sm"})),void 0!==n.items){const t=e.LX.makeContainer(["auto","auto"],""+(a?"text-foreground":"text-muted-foreground"));e.LX.listen(t,"click",t=>{e.LX.addDropdownMenu(t.target,n.items,{side:"bottom",align:"start"})}),t.append(l),r.appendChild(t)}else if(void 0!==n.url){let t=e.LX.makeElement("a","decoration-none hover:underline underline-offset-4 "+(a?"text-foreground":"text-muted-foreground"),"",r);t.href=n.url,t.appendChild(l)}else r.appendChild(l);n.ellipsis&&e.LX.asTooltip(r,n.ellipsis,{side:"bottom",offset:4})}return i},e.LX.makeIcon=function(t,s={}){let i=null;const o=function(i){const o=s.svgClass;if(o&&o.length){const t=e.LX.twMerge(...i.classList,...o.split(" "));i.classList.remove(...i.classList),t.split(" ").forEach(e=>i.classList.add(e))}const n=e.LX.makeElement("a",e.LX.mergeClass("lexicon",s.iconClass));return n.title=s.title??"",n.appendChild(i),i.dataset.name=t,n};if(t.includes("@")){const e=t.split("@");t=e[0],s.variant=e[1]}let n=e.LX.ICONS[t];const a=window.lucide,r=a[t]??a[e.LX.LucideIconAlias[t]];if(n){n.constructor!=Array&&(n=e.LX.ICONS[n]);const a=s.variant??"regular";n=("solid"==a?e.LX.ICONS[`${t}@solid`]:n)??n;const l=n[3];if(a==l||!r||"regular"==l){if(i=document.createElementNS("http://www.w3.org/2000/svg","svg"),i.classList.add("text-inherit"),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.classList.add("text-inherit"),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(r,`No existing icon named _${t}_`),i=a.createElement(r,s),o(i)},e.LX.registerIcon=function(t,s,i="none",o=[]){const n=(new DOMParser).parseFromString(s,"image/svg+xml").documentElement,a=n.querySelector("path"),r=n.getAttribute("viewBox").split(" "),l=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(r[2]),parseInt(r[3]),o,i,l,{svgAttributes:c.length?c.join(" "):null,pathAttributes:h.length?h.join(" "):null}];e.LX.ICONS[t]&&console.warn(`${t} will be added/replaced in LX.ICONS`),e.LX.ICONS[t]=d},e.LX.registerCommandbarEntry=function(t,s){e.LX.extraCommandbarEntries.push({name:t,callback:s})},e.LX.message=function(t,s,i={}){if(!t)throw"No message to show";return i.modal=!0,new e.LX.Dialog(s,e=>{e.addTextArea(null,t,null,{disabled:!0,fitHeight:!0})},i)},e.LX.popup=function(t,s,i={}){if(!t)throw"No message to show";i.size=i.size??["max-content","auto"];const o=i.timeout||3e3,n=new e.LX.Dialog(s,e=>{e.addTextArea(null,t,null,{disabled:!0,fitHeight:!0})},i);return setTimeout(()=>{n.close()},Math.max(o,150)),n},e.LX.prompt=function t(s,i,o,n={}){n.modal=!0,n.className="prompt";let a="";const r=()=>{n.required&&""===a?(s+=s.includes("You must fill the input text.")?"":"\nYou must fill the input text.",l.close(),t(s,i,o,n)):(o&&o.call(e.LX,a),l.close())},l=new e.LX.Dialog(i,t=>{e.LX.makeElement("p","max-h-64 p-2 break-word overflow-scroll",s,t),(n.input??1)&&t.addText(null,n.input||a,(e,t)=>{a=e,t?.constructor===KeyboardEvent&&r()},{placeholder:"..."}),t.sameLine(2),t.addButton(null,"Cancel",()=>{n.on_cancel&&n.on_cancel(),l.close()},{width:"50%",buttonClass:"destructive"}),t.addButton(null,n.accept||"Continue",()=>{r()},{width:"50%",buttonClass:"primary"})},n);return(n.input??1)&&l.root.querySelector("input").focus(),l},e.LX.toast=function(t,s,i={}){if(!t)throw"The toast needs at least a title!";const o=e.LX.notifications;console.assert(o);const n=e.LX.makeElement("li","lextoast flex flex-row relative w-full border-color overflow-hidden select-none pointer-events-auto touch-none rounded-lg p-3","",o),[a,r]=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(r){case"left":o.style.left="1rem";break;case"center":o.style.placeSelf="center",o.style.justifySelf="anchor-center";break;case"right":o.style.right="1rem"}n.classList.add(a),n.classList.add(r),e.LX.doAsync(()=>{o.offsetWidth>o.iWidth&&(o.iWidth=Math.min(o.offsetWidth,480),o.style.width=o.iWidth+"px"),n.dataset.open=!0},10);const l=e.LX.makeElement("div","grid h-fit max-w-lg gap-1 items-center mr-6 [&_div]:truncate [&_svg]:shrink-0","",n);if(e.LX.makeElement("div","flex flex-row gap-2 text-sm text-foreground items-center min-w-0",t,l),s&&e.LX.makeElement("div","text-secondary-foreground text-xs",s,l),i.action){const t=new J;t.addButton(null,i.action.name??"Accept",i.action.callback.bind(e.LX,n),{width:"auto",maxWidth:"150px",className:"right",buttonClass:"outline sm"}),n.appendChild(t.root.childNodes[0])}if(n.close=function(){this.dataset.open="false",e.LX.doAsync(()=>{this.remove(),e.LX.notifications.childElementCount||(e.LX.notifications.style.width="unset",e.LX.notifications.iWidth=0)},500)},i.closable??1){const t=e.LX.makeIcon("X",{iconClass:"absolute top-2 right-2 text-sm"});t.addEventListener("click",()=>{n.close()}),n.appendChild(t)}const c=i.timeout??3e3;-1!=c&&e.LX.doAsync(()=>{n.close()},c)},e.LX.badge=function(t,s,i={}){const o=document.createElement("div");o.innerHTML=t;const n=["lexbadge","inline-flex","items-center","justify-center","rounded-full","border","px-2","py-0.5","text-xs","font-medium","w-fit","whitespace-nowrap","shrink-0","overflow-hidden","border-transparent","gap-1","min-w-5","bg-card text-foreground"];if(o.className=s?e.LX.twMerge(...n,...s.split(" ")):n.join(" "),Object.assign(o.style,i.style??{}),i.callback){const t=e.LX.makeIcon("ArrowUpRight",{svgClass:"xs"});t.querySelector("svg").style.marginLeft="-0.25rem",o.innerHTML+=t.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},e.LX.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},e.LX.makeContainer=function(t,s,i,o,n={}){const a=e.LX.makeElement("div","lexcontainer "+(s??""),i,o,n);return a.style.width=t&&t[0]?t[0]:"100%",a.style.height=t&&t[1]?t[1]:"100%",a},e.LX.asTooltip=function(t,s,i={}){console.assert(t,"You need a trigger to generate a tooltip!"),t.dataset.disableTooltip=!(i.active??1);let o=null,n=null,a=null;const r=i.offset,l=i.offsetX??r??0,c=i.offsetY??r??6,h=i.delay??100,d=()=>{clearTimeout(n),null!==a&&(cancelAnimationFrame(a),a=null),o&&(o.remove(),o=null)},u=()=>{t.isConnected?o&&(a=requestAnimationFrame(u)):d()},p=()=>{o=e.LX.makeElement("div","lextooltip fixed bg-secondary-foreground text-secondary text-xs px-2 py-1 rounded-lg pointer-events-none data-closed:opacity-0",t.dataset.tooltipContent??s);const n=t.closest("dialog"),r=n??e.LX.root;e.LX.root.querySelectorAll(".lextooltip").forEach(e=>e.remove()),r.appendChild(o),a=requestAnimationFrame(u),e.LX.doAsync(()=>{const s=[0,0],a=parseFloat(t.dataset.tooltipOffsetX??l),h=parseFloat(t.dataset.tooltipOffsetY??c),d=t.getBoundingClientRect(),u=i.side??"top",p="top"===u||"bottom"===u;switch(u){case"left":s[0]+=d.x-o.offsetWidth-a;break;case"right":s[0]+=d.x+d.width+a;break;case"top":s[1]+=d.y-o.offsetHeight-h;break;case"bottom":s[1]+=d.y+d.height+h}if(p?s[0]+=d.x+.5*d.width-.5*o.offsetWidth+a:s[1]+=d.y+.5*d.height-.5*o.offsetHeight+h,s[0]=e.LX.clamp(s[0],0,window.innerWidth-o.offsetWidth-4),s[1]=e.LX.clamp(s[1],0,window.innerHeight-o.offsetHeight-4),n){const e=r.getBoundingClientRect();s[0]-=e.x,s[1]-=e.y}o.style.left=`${s[0]}px`,o.style.top=`${s[1]}px`,i.callback?.(o,t)})};t.addEventListener("mouseenter",function(){"true"!=t.dataset.disableTooltip&&(n=setTimeout(p,h))}),t.addEventListener("mouseleave",d)},e.LX.insertChildAtIndex=function(e,t,s=1/0){s>=e.children.length?e.appendChild(t):e.insertBefore(t,e.children[s])},e.LX.getComputedSize=function(e){return{width:e.offsetWidth,height:e.offsetHeight}},e.LX.listen=function(e,t,s,i){e[i=i??"_on"+t]=s,e.addEventListener(t,s)},e.LX.ignore=function(e,t,s){const i=e[s=s??"_on"+t];e.removeEventListener(t,i)},e.LX.getParentArea=function(e){let t=e.parentElement;for(;t;){if(t.classList.contains("lexarea"))return t;t=t.parentElement}},e.LX.hasClass=function(e,t){return!!(t=[].concat(t)).filter(t=>e.classList.contains(t)).length},e.LX.addClass=function(e,t){if(!t)return;const s=t.split(" ");e.classList.add(...s)},e.LX.removeClass=function(e,t){if(!t)return;const s=t.split(" ");e.classList.remove(...s)},e.LX.toggleClass=function(e,t,s){t&&e.classList.toggle(t,s)},e.LX.mergeClass=function(t,s){return s&&(t=[t,s].join(" ")),e.LX.twMerge(...t.split(" "))},e.LX.lastChar=function(e){return e[e.length-1]},Object.assign(e.LX,{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},requestFileAsync:async(e,t,s=!1)=>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}),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 r in e){var l=document.createElement("script");l.num=r,l.type="text/javascript",l.src=e[r]+(o?"?version="+o:""),l.original_src=e[r],l.async=!1,l.onload=function(e){n--,a.push(this),n?i&&i(this.original_src,this.num):t&&t(a)},s&&(l.onerror=function(e){s(e,this.original_src,this.num)}),document.getElementsByTagName("head")[0].appendChild(l)}},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(t,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)};t.includes("http")?e.LX.request({url:t,dataType:"blob",success:e=>{i.readAsDataURL(e),i.onload=e=>{o(e.currentTarget.result)}}}):o(t)},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")}}),e.LX.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]},e.LX.compareThreshold=function(e,t,s,i){return Math.abs(e-t)>=i||Math.abs(e-s)>=i},e.LX.compareThresholdRange=function(e,t,s,i){return e>=s&&e<=i||t>=s&&t<=i||e<=s&&t>=i},e.LX.getControlPoints=function(e,t,s,i,o,n,a){var r=Math.sqrt(Math.pow(s-e,2)+Math.pow(i-t,2)),l=a*r/(r+Math.sqrt(Math.pow(o-s,2)+Math.pow(n-i,2))),c=a-l;return[s+l*(e-o),i+l*(t-n),s-c*(e-o),i-c*(t-n)]},e.LX.drawSpline=function(t,s,i){t.save();for(var o=[],n=s.length,a=0;a<n-4;a+=2)o=o.concat(e.LX.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)t.beginPath(),t.moveTo(s[a],s[a+1]),t.bezierCurveTo(o[2*a-2],o[2*a-1],o[2*a],o[2*a+1],s[a+2],s[a+3]),t.stroke(),t.closePath();t.beginPath(),t.moveTo(s[0],s[1]),t.quadraticCurveTo(o[0],o[1],s[2],s[3]),t.stroke(),t.closePath(),t.beginPath(),t.moveTo(s[n-2],s[n-1]),t.quadraticCurveTo(o[2*n-10],o[2*n-9],s[n-4],s[n-3]),t.stroke(),t.closePath(),t.restore()};class ae{root;imageElement=void 0;fallbackElement=void 0;constructor(t){let s="lexavatar bg-card items-center flex flex-row relative size-8 shrink-0 overflow-hidden rounded-full";if(this.root=e.LX.makeElement("div"),t.imgSource){const s="aspect-square size-full object-cover",i=e.LX.makeElement("img",t.imgClass?e.LX.twMerge(...s.split(" "),...t.imgClass.split(" ")):s,"",this.root);i.src=t.imgSource,i.alt=t.imgAlt,this.imageElement=i}else if(t.fallback){const i="size-full text-sm font-semibold place-self-center text-center content-center",o=e.LX.makeElement("span",t.fallbackClass?e.LX.twMerge(...i.split(" "),...t.fallbackClass.split(" ")):i,t.fallback,this.root);this.fallbackElement=o,s+=" border-color"}this.root.className=t.className?e.LX.twMerge(...s.split(" "),...t.className.split(" ")):s}}e.LX.Avatar=ae;class re{root;constructor(t={}){const s=t.icon??"LoaderCircle",i=t.size??"md",o=e.LX.mergeClass("flex",t.iconClass),n=e.LX.mergeClass(`animate-spin ${i}`,t.svgClass);this.root=e.LX.makeIcon(s,{iconClass:o,svgClass:n})}html(){return this.root.innerHTML}destroy(){this.root.remove()}}e.LX.Spinner=re;let le=class t{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=e.LX.guidGenerator();const n=o.size??[],a=o.position??[],r=o.draggable??!0,l=o.dockable??!1,c=o.modal??!1;let h=document.createElement("dialog");h.className=e.LX.mergeClass("lexdialog absolute outline-none border-color m-0 p-0 min-w-3xs min-h-max overflow-hidden rounded-xl bg-background",o.className),h.id=o.id??"dialog"+t._last_id++,h.dataset.modal=c,e.LX.root.appendChild(h),e.LX.doAsync(()=>{c?h.showModal():h.show()},10);let d=this;const u=document.createElement("div");if(s&&(u.className="lexdialogtitle flex w-full outline-none items-center justify-between font-semibold text-xl text-secondary-foreground pad-xl select-none",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(),e.LX.doAsync(()=>{d.panel.clear(),h.remove()},150))};const t=e.LX.makeIcon("X",{title:"Close",iconClass:"lexdialogcloser text-lg text-secondary-foreground cursor-pointer z-1 select-none"});t.addEventListener("click",this.close);const i=e.LX.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?(l&&u.appendChild(i),u.appendChild(t)):(t.classList.add("notitle"),h.appendChild(t))}const p=new e.LX.Panel({className:"lexdialogcontent w-full p-1 text-secondary-foreground text-sm ml-0 break-all"});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,r&&e.LX.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)}};e.LX.Dialog=le;class ce extends le{constructor(t,s,i,o={}){o.closable=!1,o.draggable=!1,o.modal=!0,super(void 0,n=>{n.root.className=e.LX.mergeClass(n.root.className,"pad-2xl flex flex-col gap-2"),e.LX.makeContainer(["100%","100%"],"text-lg font-medium text-foreground px-2",t,n),n.addTextArea(null,s,null,{disabled:!0,fitHeight:!0,inputClass:"bg-none text-sm text-muted-foreground"}),n.sameLine(2,"justify-end"),n.addButton(null,o.cancelText??"Cancel",()=>{o.cancelCallback&&o.cancelCallback(),this.destroy()},{buttonClass:"outline"}),n.addButton(null,o.continueText??"Continue",()=>{this.destroy(),i&&i()},{buttonClass:"primary"})},o)}}e.LX.AlertDialog=ce;class he{root;items;colors;_parent;constructor(t,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=t.target.closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=e.LX.root,this._parent.appendChild(this.root);const n=[t.x-48,t.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(t,s,i,o){const n=t[s].length;let a=document.createElement("div");a.className="lexmenuboxentry"+(t.className?" "+t.className:""),a.id=t.id??"eId"+e.LX.getSupportedDOMName(s),a.innerHTML="";const r=t.icon;r&&a.appendChild(e.LX.makeIcon(r,{svgClass:"sm"}));const l=t.disabled;if(a.innerHTML+="<div class='lexentryname"+(l?" 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(),l)return;const r=t.callback;r&&(r.call(this,s,a),this.root.remove()),n&&"click"==e.LX.OPEN_CONTEXTMENU_ENTRY&&this._createSubmenu(t,s,a,++o)}),!n)return;const c=e.LX.makeIcon("Menu",{svgClass:"sm"});a.appendChild(c),"mouseover"==e.LX.OPEN_CONTEXTMENU_ENTRY&&a.addEventListener("mouseover",e=>{"true"!=a.dataset.built&&(a.dataset.built="true",this._createSubmenu(t,s,a,++o),e.stopPropagation())}),a.addEventListener("mouseleave",()=>{o=-1,i.querySelectorAll(".lexcontextmenu").forEach(e=>e.remove())})}onCreate(){e.LX.doAsync(()=>this._adjustPosition(this.root,6))}add(t,s={}){s.constructor==Function&&(s={callback:s});const i=(t+="").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 r=i[n++];r||(o.id=s.id,o.icon=s.icon,o.callback=s.callback,o.disabled=s.disabled??!1),t.push(o),a(r,o[e])}};a(i[n++],this.items);const r=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)r(s)}}};for(let e of this.items)r(e);for(let t of this.items){let s=Object.keys(t)[0],i="eId"+e.LX.getSupportedDOMName(s);const o="#"+(t.id??i);this.root.querySelector(o)||this._createEntry(t,s,this.root,-1)}}setColor(t,s){"#"!==s[0]&&(s=e.LX.rgbToHex(s)),this.colors[t]=s}}e.LX.ContextMenu=he,e.LX.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(t,s,i={}){if(console.assert(t,"DropdownMenu needs a DOM element as trigger!"),de.currentMenu||!s?.length)return de.currentMenu?.destroy(),void(this.invalid=!0);this._trigger=t,t.classList.add("triggered"),t.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=t.closest("dialog");o&&"true"==o.dataset.modal?this._parent=o:this._parent=e.LX.root,this._parent.appendChild(this.root),this._create(this._items),de.currentMenu=this,e.LX.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(t,s){if(s){const t=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,e.LX.doAsync(()=>{const s=[t.x+t.width,t.y];if(this._parent instanceof HTMLDialogElement){let e=this._parent.getBoundingClientRect();s[0]-=e.x,s[1]-=e.y}this.avoidCollisions&&(s[0]=e.LX.clamp(s[0],0,window.innerWidth-i.offsetWidth-this._windowPadding),s[1]=e.LX.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=t.filter(e=>null!=e?.icon||null!=e?.checked).length>0;for(let e of t)this._createItem(e,s,i)}_createItem(t,s,i){if(!t)return void this._addSeparator(s);const o=t.name??t,n=e.LX.getSupportedDOMName(o);if(s.querySelector("#"+n))return;const a=document.createElement("div");if(a.className=e.LX.mergeClass("lexdropdownmenuitem flex flex-row pad-md rounded-lg gap-2 truncate cursor-pointer select-none"+(t.name||t.options?"":" label")+(t.disabled?" disabled":""),t.className),a.dataset.id=n,a.innerHTML=`<span class="ellipsis-overflow">${o}</span>`,a.tabIndex="1",s.appendChild(a),t.constructor===String)return;if(t.submenu){const t=e.LX.makeIcon("Right",{svgClass:"sm"});a.appendChild(t)}else if(t.kbd){t.kbd=[].concat(t.kbd);const s=e.LX.makeKbd(t.kbd,t.useKbdSpecialKeys??!0);a.appendChild(s),document.addEventListener("keydown",e=>{if(!this._trigger.ddm)return;e.preventDefault();let s=t.kbd.join("");s=1==s.length?s.toLowerCase():s,s==e.key&&a.click()})}const r=t.disabled??!1;if(void 0!==this._radioGroup){if(t.name===this._radioGroup.selected){const t=e.LX.makeIcon("Circle",{svgClass:"2xs fill-current"});a.prepend(t)}a.setAttribute("data-radioname",this._radioGroup.name)}else if(t.icon){const s=t.icon.constructor===String?e.LX.makeIcon(t.icon,{svgClass:r?"text-muted-foreground":t.svgClass??t.className}):t.icon;a.prepend(s)}else null==t.checked&&i&&a.classList.add("pl-8");if(!r){if(null!=t.checked){const e=new m(n+"_entryChecked",t.checked,e=>{const s=t.callback;t.checked=e,s&&s.call(this,o,e,a)},{className:"primary"}),s=e.root.querySelector("input");s.classList.add("ml-auto"),a.appendChild(s),a.addEventListener("click",t=>{"checkbox"!=t.target.type&&(s.checked=!s.checked,e.set(s.checked))})}else a.addEventListener("click",e=>{const s=a.getAttribute("data-radioname");s&&(this._trigger[s]=o);const i=t.callback;i&&i.call(this,o,a,s),!t.options&&(t.closeOnClick??1)&&this.destroy(!0)});if(a.addEventListener("mouseover",e=>{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())}),t.submenu&&this.inPlace){if(a.built)return;a.built=!0,this._create(t.submenu,a)}e.stopPropagation()}),t.options){console.assert(this._trigger[t.name]&&"An item of the radio group must be selected!"),this._radioGroup={name:t.name,selected:this._trigger[t.name]};for(let e of t.options)this._createItem(e,s,i);delete this._radioGroup,this._addSeparator()}}}_adjustPosition(){const t=[0,0],s=this._trigger.getBoundingClientRect();if(this.event)t[0]=this.event.x,t[1]=this.event.y;else{let e=!0;switch(this.side){case"left":t[0]+=s.x-this.root.offsetWidth-this.sideOffset,e=!1;break;case"right":t[0]+=s.x+s.width+this.sideOffset,e=!1;break;case"top":t[1]+=s.y-this.root.offsetHeight-this.sideOffset,e=!0;break;case"bottom":t[1]+=s.y+s.height+this.sideOffset,e=!0}switch(this.align){case"start":e?t[0]+=s.x:t[1]+=s.y;break;case"center":e?t[0]+=s.x+.5*s.width-.5*this.root.offsetWidth:t[1]+=s.y+.5*s.height-.5*this.root.offsetHeight;break;case"end":e?t[0]+=s.x-this.root.offsetWidth+s.width:t[1]+=s.y-this.root.offsetHeight+s.height}e?t[0]+=this.alignOffset:t[1]+=this.alignOffset}if(this._parent instanceof HTMLDialogElement){let e=this._parent.getBoundingClientRect();t[0]-=e.x,t[1]-=e.y}this.avoidCollisions&&(t[0]=e.LX.clamp(t[0],0,window.innerWidth-this.root.offsetWidth-this._windowPadding),t[1]=e.LX.clamp(t[1],0,window.innerHeight-this.root.offsetHeight-this._windowPadding)),this.root.style.left=`${t[0]}px`,this.root.style.top=`${t[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}e.LX.DropdownMenu=de,e.LX.addDropdownMenu=ue;class pe{root;constructor(t={}){const s=document.createElement("footer");s.className=e.LX.mergeClass("lexfooter bg-background p-2 w-full leading-6 [&_p]:text-xs",t.className);const i=document.createElement("div");if(i.style.minHeight="48px",i.className="w-full",s.appendChild(i),t.columns&&t.columns.constructor==Array){const e=document.createElement("div");e.className="grid text-center",e.style.gridTemplateColumns="1fr ".repeat(t.columns.length),i.appendChild(e);for(let s of t.columns){const t=document.createElement("div");t.className="col",e.appendChild(t);const i=document.createElement("h2");if(i.innerHTML=s.title,t.appendChild(i),!s.items||!s.items.length)continue;const o=document.createElement("ul");t.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(t.credits||t.socials){const s=document.createElement("div");if(s.className="credits-and-socials",i.appendChild(s),t.credits){const e=document.createElement("p");e.innerHTML=t.credits,s.appendChild(e)}if(t.socials){const i=document.createElement("div");i.className="socials flex flex-row gap-1 my-2 justify-end";for(let s of t.socials){const t=e.LX.makeIcon(s.icon,{title:s.title,svgClass:"xl"});t.href=s.link,t.target="_blank",i.appendChild(t)}s.appendChild(i)}}(t.parent??document.body).appendChild(s),s.previousElementSibling&&(s.previousElementSibling.style.flexGrow="1"),this.root=s}}e.LX.Footer=pe;let me=class t extends le{static TOP=0;static BOTTOM=1;dockPosition=t.TOP;minimized=!1;constructor(s,i,o={}){o.draggable=o.draggable??!1,o.closable=o.closable??!1;super(s,i,o);let n=this;e.LX.addSignal("@on_branch_closed",this.panel,e=>{this.dockPosition==t.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",e=>{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==t.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 e=o.float;if(e)for(let t=0;t<e.length;t++){switch(e[t]){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(e){e.ctrlKey&&(n.root.style.right="unset","ArrowLeft"==e.key?n.root.style.left="0px":"ArrowRight"==e.key?n.root.style.left=`calc(100% - ${n.root.offsetWidth+3}px)`:"ArrowUp"==e.key?(n.root.style.top="0px",n.dockPosition=t.TOP):"ArrowDown"==e.key&&(n.root.style.top=`calc(100% - ${n.root.offsetHeight+3}px)`,n.dockPosition=t.BOTTOM))})}}};e.LX.PocketDialog=me;class ge{side="left";root;_onClick;constructor(t,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 overflow-hidden",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()}),e.LX.doAsync(()=>{switch(e.LX.modal.toggle(!1),this.side){case"left":this.root.style.left="0",this.root.style.width=t,this.root.style.height="100%";break;case"right":this.root.style.right="0",this.root.style.width=t,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=t;break;case"bottom":this.root.style.left="0",this.root.style.bottom="0",this.root.style.width="100%",this.root.style.height=t}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(),e.LX.modal.toggle(!0)}}e.LX.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(t={}){const s=navigator&&/Android|iPhone/i.test(navigator.userAgent);if(this.root=document.createElement("div"),this.root.className=e.LX.mergeClass("lexsidebar flex flex-col pad-xl size-full scrollbar-hidden",t.className),this.callback=t.callback??null,this.side=t.side??"left",this.collapsable=t.collapsable??!0,this.collapsed=t.collapsed??s,this._displaySelected=t.displaySelected??!1,this._collapseWidth=t.collapseToIcons??1?"58px":"0px",this.filterString="",e.LX.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),e.LX.doAsync(()=>{this.resizeObserver?.unobserve(this.root.parentElement),this.root.querySelectorAll(".lexsidebarentrycontent").forEach(e=>e.dataset.disableTooltip=`${!this.collapsed}`)},10)}},10),!t.skipHeader&&(this.header=t.header??this._generateDefaultHeader(t),console.assert(this.header.constructor===HTMLDivElement,"Use an HTMLDivElement to build your custom header"),this.header.className="lexsidebarheader w-full h-[48px] flex rounded-lg p-2 mb-2 text-sm cursor-pointer items-center select-none",this.root.appendChild(this.header),this.collapsable)){const i=e.LX.makeIcon("left"==this.side?"PanelLeft":"PanelRight",{title:"Toggle Sidebar",iconClass:"toggler"});if(this.header.appendChild(i),s){const s=new te({skipAppend:!0}),o=e.LX.deepCopy(t);o.collapsed=!1,o.collapsable=!1,s.addSidebar(this.callback,o),i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),new e.LX.Sheet("256px",[s],{side:this.side})})}else i.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.toggleCollapsed()})}if(t.filter){const e=new h(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 overflow-mask flex flex-col overflow-x-hidden overflow-y-scroll flex-auto-fill w-full",this.root.appendChild(this.content),t.skipFooter||(this.footer=t.footer??this._generateDefaultFooter(t),console.assert(this.footer.constructor===HTMLDivElement,"Use an HTMLDivElement to build your custom footer"),this.footer.className="lexsidebarfooter w-full h-[48px] flex rounded-lg p-2 mt-2 text-sm cursor-pointer items-center select-none",this.root.appendChild(this.footer))}_generateDefaultHeader(t={}){const s=document.createElement("div");s.addEventListener("click",e=>{this.collapsed?(e.preventDefault(),e.stopPropagation(),this.toggleCollapsed()):t.onHeaderPressed&&t.onHeaderPressed(e)});const i=new e.LX.Avatar({imgSource:t.headerImage,fallback:t.headerIcon?e.LX.makeIcon(t.headerIcon,{svgClass:"xl"}).innerHTML:void 0,className:"rounded-lg"});s.appendChild(i.root);{const i=document.createElement("div");i.className="infodefault",s.appendChild(i);const o=e.LX.makeElement("span","truncate text-sm font-semibold");o.innerHTML=t.headerTitle??"",i.appendChild(o);const n=e.LX.makeElement("span","truncate text-xs");n.innerHTML=t.headerSubtitle??"",i.appendChild(n)}if(t.onHeaderPressed&&!this.collapsable){const t=e.LX.makeIcon("MenuArrows");s.appendChild(t)}return s}_generateDefaultFooter(t={}){const s=document.createElement("div");s.addEventListener("click",e=>{t.onFooterPressed&&t.onFooterPressed(e,s)});const i=new e.LX.Avatar({imgSource:t.footerImage,fallback:t.footerIcon?e.LX.makeIcon(t.footerIcon,{svgClass:"xl"}).innerHTML:void 0,className:"rounded-lg"});s.appendChild(i.root);{const i=document.createElement("div");i.className="infodefault",s.appendChild(i);const o=e.LX.makeElement("span","truncate text-sm font-semibold");o.innerHTML=t.footerTitle??"",i.appendChild(o);const n=e.LX.makeElement("span","truncate text-xs");n.innerHTML=t.footerSubtitle??"",i.appendChild(n)}if(t.onFooterPressed){const t=e.LX.makeIcon("MenuArrows");s.appendChild(t)}return s}toggleCollapsed(t){if(this.collapsable){if(this.collapsed=t??!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),e.LX.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 r=s[o++];r||(a.callback=t.callback,a.group=this.currentGroup,a.options=t),i.push(a),n(r,a[e])}};n(s[o++],this.items)}select(t){let s=e.LX.getSupportedDOMName(t);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 t of this.items){const s=t.options??{};if(t.dom)continue;let i=t.name=Object.keys(t)[0];if(this.filterString.length&&!i.toLowerCase().includes(this.filterString.toLowerCase()))continue;let o=e.LX.getSupportedDOMName(i),n=null,a=e.LX.makeElement("div",e.LX.mergeClass("lexsidebarentry w-full rounded-lg cursor-pointer select-none",s.className));if(a.id=o,this.displaySelected&&s.selected&&a.classList.add("selected"),t.group){const s=t.group.replace(/\s/g,"").replaceAll(".","");if(n=this.content.querySelector("#"+s),n){if(!n.classList.contains("lexsidebargroup"))throw"Bad id: "+t.group}else{n=e.LX.makeElement("div","lexsidebargroup flex flex-col gap-0.5"),n.id=s,this.content.appendChild(n);let i=e.LX.makeElement("div","lexsidebargrouptitle");if(n.appendChild(i),e.LX.makeElement("div","",t.group,i),null!=this.groups[t.group]){const s=e.LX.makeIcon(this.groups[t.group].icon,{svgClass:"sm"});i.appendChild(s),s.addEventListener("click",e=>{this.groups[t.group].callback&&this.groups[t.group].callback(t.group,e)})}}}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 r=document.createElement("div");if(r.className="lexsidebarentrycontent",a.appendChild(r),t.dom=a,"checkbox"==s.type){t.value=s.value??!1;const e=new J;t.checkbox=e.addCheckbox(null,t.value,(e,o)=>{o.preventDefault(),o.stopPropagation();const n=s.callback;t.value=e,n&&n.call(this,i,e,o)},{className:"primary",label:i,signal:"@checkbox_"+i}),r.appendChild(e.root.childNodes[0])}else{if(s.icon){const t=e.LX.makeIcon(s.icon,{iconClass:"lexsidebarentryicon"});r.appendChild(t),e.LX.asTooltip(r,i,{side:"right",offset:16,active:!1})}if(e.LX.makeElement("a","grid-column-start-2",i,r),s.swap){r.classList.add("swap","inline-grid"),r.querySelector("a")?.classList.add("swap-off");const t=document.createElement("input");t.className="p-0 border-0",t.type="checkbox",r.prepend(t);const i=e.LX.makeIcon(s.swap,{iconClass:"lexsidebarentryicon swap-on"});r.appendChild(i)}s.content&&r.appendChild(s.content)}const l=null!=s.collapsable?s.collapsable:s.collapsable||t[i].length;if(a.addEventListener("click",e=>{if(e.target&&e.target.classList.contains("lexcheckbox"))return;let o;if(l)r.querySelector(".collapser")?.click();else if(t.checkbox)t.value=!t.value,t.checkbox.set(t.value,!0),o=t.value;else if(s.swap&&!(e.target instanceof HTMLInputElement)){const e=r.querySelector("input");e.checked=!e.checked,o=e.checked}const n=s.callback;n&&n.call(this,i,o??a,e),this.displaySelected&&!s.skipSelection&&(this.root.querySelectorAll(".lexsidebarentry").forEach(e=>e.classList.remove("selected")),a.classList.add("selected"))}),s.action){const t=e.LX.makeIcon(s.action.icon??"Ellipsis",{title:s.action.name});r.appendChild(t),t.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation();const t=s.action.callback;t&&t.call(this,i,e)})}else if(l){const t=document.createElement("div");t.className="collapsablecontainer",Object.assign(t.style,{width:"100%",display:"none"}),e.LX.makeCollapsible(r,t,n??this.content),this.collapseQueue=s.collapsable,this.collapseContainer=t}if(!t[i].length)continue;let c=e.LX.makeElement("div","lexsidebarsubentrycontainer flex flex-col self-center w-full ml-4 px-4 select-none");l?(this.collapseContainer.appendChild(c),delete this.collapseContainer):n?(c.classList.add("collapsablecontainer"),n.appendChild(c)):this.content.appendChild(c);for(let s=0;s<t[i].length;++s){const o=t[i][s],n=o.options??{},a=o.name=Object.keys(o)[0];if(this.filterString.length&&!a.toLowerCase().includes(this.filterString.toLowerCase()))continue;let r=document.createElement("div");if(r.innerHTML=`<span>${a}</span>`,n.action){const t=e.LX.makeIcon(n.action.icon??"Ellipsis",{title:n.action.name});r.appendChild(t),t.addEventListener("click",e=>{e.preventDefault(),e.stopImmediatePropagation();const t=n.action.callback;t&&t.call(this,a,e)})}if(r.className="lexsidebarentry w-full rounded-lg cursor-pointer select-none",r.id=a,n.content){const t=e.LX.makeElement("div");t.appendChild(n.content),r.appendChild(t)}c.appendChild(r),r.addEventListener("click",e=>{const t=n.callback;t&&t.call(this,a,r,e),this.displaySelected&&!n.skipSelection&&(this.root.querySelectorAll(".lexsidebarentry").forEach(e=>e.classList.remove("selected")),r.classList.add("selected"))})}}}}e.LX.Sidebar=fe;class Ce{root;constructor(t){if(this.root=e.LX.makeContainer(["auto","auto"],"flex flex-row lexskeleton"),t.constructor===String)this.root.innerHTML=t;else{t=[].concat(t);for(let e of t)this.root.appendChild(e)}}destroy(){this.root.dataset.closed=!0,e.LX.doAsync(()=>{this.root.remove(),this.root=null},200)}}e.LX.Skeleton=Ce;class ve{static ACTIVE_TOURS=[];steps;currentStep=0;useModal;offset;horizontalOffset;verticalOffset;radius;tourContainer;tourMask=void 0;_popover=null;constructor(t,s={}){this.steps=t||[],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=e.LX.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(t){this.tourContainer.innerHTML="",this.tourMask=e.LX.makeContainer(["100%","100%"],"tour-mask absolute inset-0"),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=t.getBoundingClientRect(),[a,r]=o(n.x,n.width),[l,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,r+2*d)}`),e.setAttribute("height",`${Math.max(0,l-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",`${l+c+h}`),e.setAttribute("width",`${Math.max(0,r+2*d)}`),e.setAttribute("height",`${Math.max(0,window.innerHeight-l-c-h)}`),e.setAttribute("stroke","none"),i.appendChild(e)}{const e=document.createElementNS("http://www.w3.org/2000/svg","rect");e.setAttribute("x",`${a+r+d}`),e.setAttribute("y","0"),e.setAttribute("width",`${Math.max(0,window.innerWidth-a-r)}`),e.setAttribute("height",`${Math.max(0,window.innerHeight)}`),e.setAttribute("stroke","none"),i.appendChild(e)}const u=e.LX.makeContainer(["0","0"],"tour-ref-mask absolute");u.style.left=a-d-1+"px",u.style.top=l-h-1+"px",u.style.width=`${r+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",`${r+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",`${r+2*d+2}`),t.setAttribute("height",`${c+2*h+2}`),t.setAttribute("stroke","none"),t.setAttribute("fill","black"),p.appendChild(t)}}_createHighlight(t,s,i){const o=e.LX.makeContainer(["auto","auto"],"tour-step-container");{const s=e.LX.makeContainer(["100%","auto"],"flex flex-row","",o);e.LX.makeContainer(["70%","auto"],"p-2 font-medium text-base",t.title,s);const i=e.LX.makeContainer(["30%","auto"],"flex flex-row p-2 justify-end","",s),n=e.LX.makeIcon("X");i.appendChild(n),e.LX.listen(n,"click",()=>{this.stop()})}e.LX.makeContainer(["100%","auto"],"p-2 text-sm",t.content,o,{maxWidth:"400px"});const n=e.LX.makeContainer(["100%","auto"],"flex flex-row","",o);{const t=e.LX.makeContainer(["50%","auto"],"p-2 gap-1 place-self-center flex flex-row","",n);for(let s=0;s<this.steps.length;s++){const i=e.LX.makeElement("span");i.className="size-3 rounded-full bg-accent inline-flex data-active:bg-primary",s===this.currentStep&&(i.dataset.active="true"),t.appendChild(i)}}const a=e.LX.makeContainer(["50%","auto"],"text-base","",n),r=new J;let l=1;s&&l++,l>1&&r.sameLine(2,"justify-end"),s&&r.addButton(null,"Previous",()=>{this._showStep(-1)},{buttonClass:"ghost"}),i?r.addButton(null,"Next",()=>{this._showStep(1)},{buttonClass:"accent"}):r.addButton(null,"Finish",()=>{this.stop()},{buttonClass:"primary"}),a.appendChild(r.root);const c=("left"===t.side||"right"===t.side?this.horizontalOffset:this.verticalOffset)??this.offset,h="start"===t.align||"end"===t.align?c:0;this._popover?.destroy(),this._popover=new C(null,[o],{reference:t.reference,side:t.side,align:t.align,sideOffset:c,alignOffset:"start"===t.align?-h:h})}}if(e.LX.Tour=ve,!e.LX)throw"Missing LX namespace!";function ye(e){return/[^\w\s]/.test(e)}function Le(e){return/\w/.test(e)}function be(e,t){if(!e?.icon)return"FileCode text-neutral-500";if("string"==typeof e.icon)return e.icon;if(t&&e.icon[t])return e.icon[t];return Object.values(e.icon)[0]||"FileCode text-neutral-500"}e.LX.extensions.push("CodeEditor");class xe{static languages=new Map;static extensionMap=new Map;static registerLanguage(e){xe.languages.set(e.name,e);for(const t of e.extensions)xe.extensionMap.set(t,e.name)}static getLanguage(e){return xe.languages.get(e)}static getLanguageByExtension(e){const t=xe.extensionMap.get(e);return t?xe.languages.get(t):void 0}static getRegisteredLanguages(){return Array.from(xe.languages.keys())}static initialState(){return{stack:["root"]}}static tokenizeLine(e,t,s){const i=[],o=[...s.stack];let n=0;for(;n<e.length;){const s=o[o.length-1],a=t.states[s];if(!a){i.push({type:"text",value:e.slice(n)}),n=e.length;break}let r=!1;for(const t of a){const s=new RegExp(t.match.source,"y"+t.match.flags.replace(/[gy]/g,""));s.lastIndex=n;const a=s.exec(e);if(a){if(0===a[0].length)continue;if(i.push({type:t.type,value:a[0]}),n+=a[0].length,t.next)o.push(t.next);else if(t.pop){const e="number"==typeof t.pop?t.pop:1;for(let t=0;t<e&&o.length>1;t++)o.pop()}r=!0;break}}if(!r){const t=i[i.length-1];t&&"text"===t.type?t.value+=e[n]:i.push({type:"text",value:e[n]}),n++}}return{tokens:xe._mergeTokens(i),state:{stack:o}}}static _mergeTokens(e){if(0===e.length)return e;const t=[e[0]];for(let s=1;s<e.length;s++){const i=t[t.length-1];e[s].type===i.type?i.value+=e[s].value:t.push(e[s])}return t}}function _e(e){return new RegExp("\\b(?:"+e.join("|")+")\\b")}e.LX.Tokenizer=xe;const ke={blockComment:[{match:/\*\//,type:"comment",pop:!0},{match:/[^*]+/,type:"comment"},{match:/\*/,type:"comment"}],doubleString:[{match:/\\./,type:"string"},{match:/"/,type:"string",pop:!0},{match:/[^"\\]+/,type:"string"}],singleString:[{match:/\\./,type:"string"},{match:/'/,type:"string",pop:!0},{match:/[^'\\]+/,type:"string"}]},Se=[{match:/0[bB][01]+(?:[uU][lL]{0,2}|[lL]{1,2}[uU]?)?\b/,type:"number"},{match:/0[xX][0-9a-fA-F]+(?:[uU][lL]{0,2}|[lL]{1,2}[uU]?)?\b/,type:"number"},{match:/0[oO][0-7]+(?:[uU][lL]{0,2}|[lL]{1,2}[uU]?)?\b/,type:"number"},{match:/\d+\.?\d*(?:[eE][+-]?\d+)?(?:[fFdDmMlLuUiI]|[uU][lL]{0,2}|[lL]{1,2}[uU]?)?\b/,type:"number"},{match:/\.\d+(?:[eE][+-]?\d+)?(?:[fFdDmM])?\b/,type:"number"}],we=[{match:/[a-zA-Z_$]\w*(?=\s*[<(])/,type:"method"},{match:/[a-zA-Z_$]\w*/,type:"text"},{match:/[{}()\[\];,.:?!&|<>=+\-*/%^~@#]/,type:"symbol"},{match:/\s+/,type:"text"}];function Te(e){return{templateString:[{match:/\\./,type:"string"},{match:/`/,type:"string",pop:!0},{match:/\$\{/,type:"symbol",next:"templateExpr"},{match:/[^`\\$]+/,type:"string"},{match:/\$/,type:"string"}],templateExpr:[{match:/\}/,type:"symbol",pop:!0},{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/`/,type:"string",next:"templateString"},...Se,{match:_e(e),type:"keyword"},...we]}}xe.registerLanguage({name:"Plain Text",extensions:["txt"],states:{root:[{match:/.+/,type:"text"}]},reservedWords:[],icon:"FileText text-neutral-500"});const Ee=["var","let","const","this","in","of","true","false","null","undefined","new","function","class","extends","super","import","export","from","default","async","typeof","instanceof","void","delete","debugger","NaN","static","constructor","Infinity","abstract"],Me=["for","if","else","switch","case","return","while","do","continue","break","await","yield","throw","try","catch","finally","with"],Ae=["document","console","window","navigator","performance","Math","JSON","Promise","Array","Object","String","Number","Boolean","RegExp","Error","Map","Set","WeakMap","WeakSet","Symbol","Proxy","Reflect"];xe.registerLanguage({name:"JavaScript",extensions:["js","mjs","cjs"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/`/,type:"string",next:"templateString"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(Ee),type:"keyword"},{match:_e(Ae),type:"builtin"},{match:_e(Me),type:"statement"},{match:/(?<=\b(?:class|enum)\s+)[A-Z][a-zA-Z0-9_]*/,type:"type"},...we],...ke,...Te(["var","let","const","this","true","false","null","undefined","new","typeof","instanceof","void"])},reservedWords:[...Ee,...Me,...Ae],icon:"Js text-yellow-500"});const Xe=[...Ee,"as","interface","type","enum","namespace","declare","private","protected","implements","readonly","keyof","infer","is","asserts","override","satisfies"],Pe=["string","number","boolean","any","unknown","never","void","null","undefined","object","symbol","bigint","Promise","Record","Partial","Required","Readonly","Pick","Omit","Exclude","Extract","NonNullable","ReturnType","Parameters","ConstructorParameters","InstanceType","Awaited"];xe.registerLanguage({name:"TypeScript",extensions:["ts","tsx"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/`/,type:"string",next:"templateString"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(Xe),type:"keyword"},{match:_e(Pe),type:"type"},{match:_e(Ae),type:"builtin"},{match:_e(Me),type:"statement"},{match:/(?<=\b(?:class|enum|interface|type|extends|implements)\s+)[A-Z][a-zA-Z0-9_]*/,type:"type"},{match:/(?<=<\s*)[A-Z][a-zA-Z0-9_]*(?=\s*(?:[,>]|extends|=))/,type:"type"},{match:/(?<=,\s*)[A-Z][a-zA-Z0-9_]*(?=\s*(?:[,>]|extends|=))/,type:"type"},{match:/(?<=:\s*)[A-Z][a-zA-Z0-9_]*/,type:"type"},...we],...ke,...Te(["var","let","const","this","true","false","null","undefined","new","typeof","instanceof","void"])},reservedWords:[...Xe,...Pe,...Ae,...Me],icon:"Ts text-blue-600"});const Ne=["bool","i32","u32","f16","f32","vec2","vec3","vec4","vec2i","vec3i","vec4i","vec2u","vec3u","vec4u","vec2f","vec3f","vec4f","mat2x2f","mat2x3f","mat2x4f","mat3x2f","mat3x3f","mat3x4f","mat4x2f","mat4x3f","mat4x4f","array","struct","ptr","atomic","sampler","sampler_comparison","texture_1d","texture_2d","texture_2d_array","texture_3d","texture_cube","texture_cube_array","texture_multisampled_2d","texture_depth_2d","texture_depth_2d_array","texture_depth_cube","texture_depth_cube_array","texture_depth_multisampled_2d","texture_storage_1d","texture_storage_2d","texture_storage_2d_array","texture_storage_3d","texture_external","var","let","const","override","fn","type","alias","true","false"],Ie=["if","else","switch","case","default","for","loop","while","break","continue","discard","return","function","private","workgroup","uniform","storage","read","write","read_write","bitcast"],Oe=["position","vertex_index","instance_index","front_facing","frag_depth","local_invocation_id","local_invocation_index","global_invocation_id","workgroup_id","num_workgroups","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","cross","degrees","determinant","distance","dot","exp","exp2","floor","fma","fract","inverseSqrt","length","log","log2","max","min","mix","normalize","pow","radians","reflect","refract","round","saturate","sign","sin","sinh","smoothstep","sqrt","step","tan","tanh","transpose","trunc","textureSample","textureSampleBias","textureSampleLevel","textureSampleGrad","textureSampleCompare","textureSampleCompareLevel","textureSampleBaseClampToEdge","textureLoad","textureStore","textureGather","textureGatherCompare","textureDimensions","textureNumLayers","textureNumLevels","textureNumSamples","pack4x8snorm","pack4x8unorm","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack2x16snorm","unpack2x16unorm","unpack2x16float","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","select","arrayLength","countLeadingZeros","countOneBits","countTrailingZeros","extractBits","firstLeadingBit","firstTrailingBit","insertBits","reverseBits","storageBarrier","workgroupBarrier","workgroupUniformLoad"];xe.registerLanguage({name:"WGSL",extensions:["wgsl"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/#\w+/,type:"preprocessor"},...Se,{match:_e(Ne),type:"keyword"},{match:_e(Oe),type:"builtin"},{match:_e(Ie),type:"statement"},{match:/@\w+/,type:"text"},...we],...ke},reservedWords:[...Ne,...Oe,...Ie],icon:"AlignLeft text-orange-500"});const Re=["true","false","int","float","double","bool","void","uint","struct","mat2","mat3","mat4","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","vec2","vec3","vec4","ivec2","ivec3","ivec4","uvec2","uvec3","uvec4","dvec2","dvec3","dvec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler2DShadow","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","samplerCubeArray","samplerCubeArrayShadow","isampler2D","usampler2D","isampler3D","usampler3D","lowp","mediump","highp","precision","in","out","inout","uniform","varying","attribute","const","layout","centroid","flat","smooth","noperspective","patch","sample","buffer","shared","coherent","volatile","restrict","readonly","writeonly"],ze=["if","else","switch","case","default","for","while","do","break","continue","return","discard"],De=["radians","degrees","sin","cos","tan","asin","acos","atan","pow","exp","log","exp2","log2","sqrt","inversesqrt","abs","sign","floor","ceil","fract","mod","min","max","clamp","mix","step","smoothstep","length","distance","dot","cross","normalize","reflect","refract","matrixCompMult","lessThan","lessThanEqual","greaterThan","greaterThanEqual","equal","notEqual","any","all","not","texture","textureProj","textureLod","textureGrad","texelFetch"];xe.registerLanguage({name:"GLSL",extensions:["glsl"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/#\w+/,type:"preprocessor"},...Se,{match:_e(Re),type:"keyword"},{match:_e(De),type:"builtin"},{match:_e(ze),type:"statement"},...we],...ke},reservedWords:[...Re,...De,...ze],icon:"AlignLeft text-neutral-500"});const Be=["bool","int","uint","dword","half","float","double","min16float","min10float","min16int","min12int","min16uint","float1","float2","float3","float4","int1","int2","int3","int4","uint1","uint2","uint3","uint4","bool1","bool2","bool3","bool4","half1","half2","half3","half4","float1x1","float1x2","float1x3","float1x4","float2x1","float2x2","float2x3","float2x4","float3x1","float3x2","float3x3","float3x4","float4x1","float4x2","float4x3","float4x4","vector","matrix","string","void","struct","class","interface","true","false","sampler","sampler1D","sampler2D","sampler3D","samplerCUBE","sampler_state","Texture1D","Texture2D","Texture3D","TextureCube","Texture1DArray","Texture2DArray","TextureCubeArray","Buffer","AppendStructuredBuffer","ConsumeStructuredBuffer","StructuredBuffer","RWStructuredBuffer","ByteAddressBuffer","RWByteAddressBuffer","RWTexture1D","RWTexture2D","RWTexture3D","RWTexture1DArray","RWTexture2DArray","cbuffer","tbuffer","in","out","inout","uniform","extern","static","volatile","precise","shared","groupshared","linear","centroid","nointerpolation","noperspective","sample","const","row_major","column_major"],He=["if","else","for","while","do","switch","case","default","break","continue","discard","return","typedef","register","packoffset"],Fe=["SV_Position","SV_Target","SV_Depth","SV_VertexID","SV_InstanceID","SV_PrimitiveID","SV_DispatchThreadID","SV_GroupID","SV_GroupThreadID","SV_GroupIndex","SV_Coverage","SV_IsFrontFace","SV_RenderTargetArrayIndex","POSITION","NORMAL","TEXCOORD","COLOR","TANGENT","BINORMAL"];xe.registerLanguage({name:"HLSL",extensions:["hlsl","fx","fxh","vsh","psh"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/#\w+/,type:"preprocessor"},...Se,{match:_e(Be),type:"keyword"},{match:_e(Fe),type:"builtin"},{match:_e(He),type:"statement"},...we],...ke},reservedWords:[...Be,...Fe,...He],icon:"AlignLeft text-purple-500"});const $e=["False","def","None","True","in","is","and","lambda","nonlocal","not","or"],Ve=["if","elif","else","for","while","try","except","finally","with","match","case","break","continue","return","raise","pass","import","from","as","global","nonlocal","assert","del","yield"],Ge=["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"],qe=["int","float","complex","bool","str","bytes","bytearray","list","tuple","set","frozenset","dict","object","type","ArithmeticError","AssertionError","AttributeError","BaseException","BufferError","EOFError","Exception","FloatingPointError","GeneratorExit","ImportError","ModuleNotFoundError","IndentationError","IndexError","KeyError","KeyboardInterrupt","LookupError","MemoryError","NameError","NotImplementedError","OSError","OverflowError","RecursionError","ReferenceError","RuntimeError","StopAsyncIteration","StopIteration","SyntaxError","TabError","SystemError","SystemExit","TypeError","UnboundLocalError","UnicodeError","UnicodeEncodeError","UnicodeDecodeError","UnicodeTranslateError","ValueError","ZeroDivisionError"];xe.registerLanguage({name:"Python",extensions:["py"],lineComment:"#",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/#.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e($e),type:"keyword"},{match:_e(qe),type:"type"},{match:_e(Ge),type:"builtin"},{match:_e(Ve),type:"statement"},...we],...ke},reservedWords:[...$e,...qe,...Ge,...Ve],icon:"Python text-cyan-600"});const Ke=["abstract","and","array","as","callable","class","clone","const","enum","extends","final","fn","function","global","implements","include","include_once","instanceof","insteadof","interface","namespace","new","null","or","private","protected","public","readonly","require","require_once","static","trait","use","var","xor","from","$this"],We=["if","else","elseif","endif","switch","case","default","endswitch","for","endfor","foreach","endforeach","while","endwhile","do","break","continue","return","try","catch","finally","throw","declare","enddeclare","goto","yield","match"],Ue=["int","float","string","bool","array","object","callable","iterable","void","never","mixed","static","self","parent","Exception","Error","Throwable","DateTime","DateTimeImmutable","Closure","Generator","JsonSerializable"],Ye=["echo","print","isset","empty","unset","eval","die","exit","count","sizeof","in_array","array_merge","array_push","array_pop","strlen","strpos","substr","str_replace","explode","implode","json_encode","json_decode","var_dump","print_r"];xe.registerLanguage({name:"PHP",extensions:["php"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(Ke),type:"keyword"},{match:_e(Ue),type:"type"},{match:_e(Ye),type:"builtin"},{match:_e(We),type:"statement"},...we],...ke},reservedWords:[...Ke,...Ue,...Ye,...We],icon:"Php text-purple-700"});const je=["int","float","double","bool","long","short","char","void","const","enum","extern","register","sizeof","static","struct","typedef","union","volatile","true","false"],Ze=["break","continue","do","else","for","goto","if","return","switch","while"];xe.registerLanguage({name:"C",extensions:["c","h"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/#\w+/,type:"preprocessor"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(je),type:"keyword"},{match:_e(Ze),type:"statement"},...we],...ke},reservedWords:[...je,...Ze],icon:{c:"C text-sky-400",h:"C text-fuchsia-500"}});const Qe=[...je,"wchar_t","static_cast","dynamic_cast","new","delete","auto","class","nullptr","NULL","signed","unsigned","namespace","static","private","public"],Je=[...Ze,"case","using","glm","spdlog","default"],et=["uint8_t","uint16_t","uint32_t","uint64_t","int8_t","int16_t","int32_t","int64_t","size_t","ptrdiff_t"],tt=["std","string","vector","map","set","unordered_map","unordered_set","array","tuple","optional","variant","cout","cin","cerr","clog"];xe.registerLanguage({name:"C++",extensions:["cpp","hpp"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/#\w+/,type:"preprocessor"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},...Se,{match:_e(Qe),type:"keyword"},{match:_e(et),type:"type"},{match:_e(tt),type:"builtin"},{match:_e(Je),type:"statement"},...we],...ke},reservedWords:[...Qe,...et,...tt,...Je],icon:{cpp:"CPlusPlus text-sky-400",hpp:"CPlusPlus text-fuchsia-500"}}),xe.registerLanguage({name:"JSON",extensions:["json","jsonc","bml"],states:{root:[{match:/"/,type:"string",next:"doubleString"},{match:/\btrue\b|\bfalse\b|\bnull\b/,type:"keyword"},{match:/-?\d+\.?\d*(?:[eE][+-]?\d+)?/,type:"number"},{match:/[{}[\]:,]/,type:"symbol"},{match:/\s+/,type:"text"}],...ke},reservedWords:[],icon:"Json text-yellow-600"}),xe.registerLanguage({name:"XML",extensions:["xml","xaml","xsd","xsl"],lineComment:"\x3c!--",states:{root:[{match:/<!--/,type:"comment",next:"xmlComment"},{match:/<\?/,type:"preprocessor",next:"processingInstruction"},{match:/<\/[a-zA-Z][\w:-]*>/,type:"keyword"},{match:/<[a-zA-Z][\w:-]*/,type:"keyword",next:"tag"},{match:/[^<]+/,type:"text"}],tag:[{match:/\/?>/,type:"keyword",pop:!0},{match:/[a-zA-Z][\w:-]*(?==)/,type:"type"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/[^"'>/]+/,type:"text"}],xmlComment:[{match:/-->/,type:"comment",pop:!0},{match:/[^-]+/,type:"comment"},{match:/-/,type:"comment"}],processingInstruction:[{match:/\?>/,type:"preprocessor",pop:!0},{match:/[^?]+/,type:"preprocessor"},{match:/\?/,type:"preprocessor"}],...ke},reservedWords:[],icon:"Rss text-orange-600"});xe.registerLanguage({name:"HTML",extensions:["html"],lineComment:"\x3c!--",states:{root:[{match:/<!--/,type:"comment",next:"xmlComment"},{match:/<!DOCTYPE/i,type:"preprocessor"},{match:/<\/[a-zA-Z][\w-]*>/,type:"keyword"},{match:/<script\b/i,type:"keyword",next:"scriptTag"},{match:/<style\b/i,type:"keyword",next:"styleTag"},{match:/<[a-zA-Z][\w-]*/,type:"keyword",next:"tag"},{match:/[^<]+/,type:"text"}],tag:[{match:/\/?>/,type:"keyword",pop:!0},{match:/[a-zA-Z][\w-]*(?==)/,type:"type"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/[^"'>/]+/,type:"text"}],scriptTag:[{match:/\/>/,type:"keyword",pop:!0},{match:/>/,type:"keyword",next:"scriptContent"},{match:/[a-zA-Z][\w-]*(?==)/,type:"type"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/[^"'>/]+/,type:"text"}],scriptContent:[{match:/<\/script>/i,type:"keyword",pop:2},{match:/[^<]+/,type:"text"},{match:/</,type:"text"}],styleTag:[{match:/\/>/,type:"keyword",pop:!0},{match:/>/,type:"keyword",next:"styleContent"},{match:/[a-zA-Z][\w-]*(?==)/,type:"type"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/[^"'>/]+/,type:"text"}],styleContent:[{match:/<\/style>/i,type:"keyword",pop:2},{match:/[^<]+/,type:"text"},{match:/</,type:"text"}],xmlComment:[{match:/-->/,type:"comment",pop:!0},{match:/[^-]+/,type:"comment"},{match:/-/,type:"comment"}],...ke},reservedWords:["html","head","body","title","meta","link","script","style","div","span","p","a","img","ul","ol","li","table","tr","td","th","form","input","button","select","option","textarea","label","h1","h2","h3","h4","h5","h6","header","footer","nav","section","article","aside","main","figure","figcaption","video","audio","source","canvas","svg"],icon:"Code text-orange-500"});const st=["inherit","initial","unset","revert","revert-layer","auto","none","hidden","visible","collapse","block","inline","inline-block","flex","inline-flex","grid","inline-grid","contents","list-item","static","relative","absolute","fixed","sticky","solid","dashed","dotted","double","groove","ridge","inset","outset","bold","bolder","lighter","normal","italic","oblique","uppercase","lowercase","capitalize","left","right","center","top","bottom","start","end","stretch","space-between","space-around","space-evenly","repeat","no-repeat","repeat-x","repeat-y","cover","contain","pointer","default","move","text","not-allowed","transparent","currentColor"];xe.registerLanguage({name:"CSS",extensions:["css","scss","sass","less"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/@[\w-]+/,type:"statement"},{match:/#[\w-]+/,type:"keyword"},{match:/\.[\w-]+/,type:"keyword"},{match:/::?[\w-]+(?:\([^)]*\))?/,type:"keyword"},{match:/\[[\w-]+(?:[~|^$*]?=(?:"[^"]*"|'[^']*'|[\w-]+))?\]/,type:"type"},{match:/{/,type:"symbol",next:"properties"},{match:/}/,type:"symbol"},{match:/[,>+~*]/,type:"symbol"},{match:/[\w-]+/,type:"keyword"},{match:/\s+/,type:"text"}],properties:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/}/,type:"symbol",pop:!0},{match:/[\w-]+(?=\s*:)/,type:"type"},{match:/:/,type:"symbol"},{match:_e(st),type:"string"},{match:/;/,type:"symbol"},{match:/"/,type:"string",next:"doubleString"},{match:/'/,type:"string",next:"singleString"},{match:/#[a-fA-F0-9]{3,8}\b/,type:"string"},{match:/-?\d+\.?\d*(?:px|em|rem|%|vh|vw|vmin|vmax|pt|cm|mm|in|pc|ex|ch|fr|deg|rad|grad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?/,type:"number"},{match:/!important\b/,type:"builtin"},{match:/[\w-]+\(/,type:"method"},{match:/--[\w-]+/,type:"type"},{match:/[(),]/,type:"symbol"},{match:/{/,type:"symbol",next:"properties"},{match:/[\w-]+/,type:"text"},{match:/\s+/,type:"text"}],...ke},reservedWords:["color","background","border","margin","padding","font","display","position","width","height","top","left","right","bottom","flex","grid","z-index","opacity","transform","transition","animation","content","visibility",...st,"hover","active","focus","visited","link","before","after","first-child","last-child","nth-child","not","root","disabled","checked"],icon:"Hash text-blue-500"}),xe.registerLanguage({name:"Markdown",extensions:["md","markdown"],states:{root:[{match:/^#{1,6}\s+.+/,type:"keyword"},{match:/^\*\*\*.+$/,type:"symbol"},{match:/\*\*[^*]+\*\*/,type:"keyword"},{match:/\*[^*]+\*/,type:"type"},{match:/__[^_]+__/,type:"keyword"},{match:/_[^_]+_/,type:"type"},{match:/`[^`]+`/,type:"string"},{match:/```/,type:"comment",next:"codeBlock"},{match:/^\s*[-*+]\s+/,type:"symbol"},{match:/^\s*\d+\.\s+/,type:"symbol"},{match:/\[([^\]]+)\]\(([^)]+)\)/,type:"builtin"},{match:/^>\s+/,type:"comment"},{match:/.+/,type:"text"}],codeBlock:[{match:/```/,type:"comment",pop:!0},{match:/.+/,type:"string"}]},reservedWords:[],icon:"Markdown text-red-500"});const it=["if","else","for","in","do","goto","call","exit","setlocal","endlocal","set","echo","rem","pause","cd","pushd","popd","shift","start"],ot=["dir","copy","move","del","ren","md","rd","type","find","findstr","tasklist","taskkill","ping","ipconfig","netstat","cls","title","color"];xe.registerLanguage({name:"Batch",extensions:["bat","cmd"],lineComment:"rem",states:{root:[{match:/^rem\s+.*/i,type:"comment"},{match:/^::.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/%[\w]+%/,type:"type"},{match:/\b\d+\b/,type:"number"},{match:_e([...it,...it.map(e=>e.toUpperCase())]),type:"keyword"},{match:_e(ot),type:"builtin"},{match:/@echo/,type:"statement"},{match:/[a-zA-Z_]\w*/,type:"text"},{match:/[<>|&()@]/,type:"symbol"},{match:/\s+/,type:"text"}],...ke},reservedWords:[...it,...ot],icon:"Terminal text-gray-300"});const nt=["project","cmake_minimum_required","add_executable","add_library","target_link_libraries","target_include_directories","set","option","if","else","elseif","endif","foreach","endforeach","while","endwhile","function","endfunction","macro","endmacro","find_package","include","message","install","add_subdirectory","configure_file"];xe.registerLanguage({name:"CMake",extensions:["cmake","txt","cmake-cache"],lineComment:"#",states:{root:[{match:/#.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/\$\{[^}]+\}/,type:"type"},{match:/\b\d+\.?\d*\b/,type:"number"},{match:_e([...nt,...nt.map(e=>e.toUpperCase())]),type:"keyword"},{match:/\b[A-Z_][A-Z0-9_]*\b/,type:"builtin"},{match:/[a-zA-Z_]\w*/,type:"text"},{match:/[(){}]/,type:"symbol"},{match:/\s+/,type:"text"}],...ke},reservedWords:[...nt],icon:"AlignLeft text-neutral-500"});const at=["as","break","const","continue","crate","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","unsafe","use","where","while","async","await","dyn","abstract","become","box","do","final","macro","override","priv","typeof","unsized","virtual","yield"],rt=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","bool","char","str","String","Vec","Option","Result","Box"],lt=["println","print","eprintln","eprint","format","panic","assert","assert_eq","assert_ne","debug_assert","vec","Some","None","Ok","Err"];xe.registerLanguage({name:"Rust",extensions:["rs"],lineComment:"//",states:{root:[{match:/\/\*/,type:"comment",next:"blockComment"},{match:/\/\/.*/,type:"comment"},{match:/"/,type:"string",next:"doubleString"},{match:/'(?:\\.|[^'])+'/,type:"string"},{match:/r#*"/,type:"string",next:"rawString"},...Se,{match:/#\[[\w:]+\]/,type:"preprocessor"},{match:_e(at),type:"keyword"},{match:_e(rt),type:"type"},{match:_e(lt),type:"builtin"},{match:/![a-zA-Z_]\w*/,type:"preprocessor"},...we],rawString:[{match:/"#*/,type:"string",pop:!0},{match:/[^"]+/,type:"string"},{match:/"/,type:"string"}],...ke},reservedWords:[...at,...rt,...lt],icon:"Rust text-orange-400"});class ct{onChange=void 0;_lines=[""];get lineCount(){return this._lines.length}constructor(e){this.onChange=e}getLine(e){return this._lines[e]??""}getText(e="\n"){return this._lines.join(e)}setText(e){this._lines=e.split(/\r?\n/),0===this._lines.length&&(this._lines=[""]),this.onChange&&this.onChange(this)}getCharAt(e,t){const s=this._lines[e];if(!(!s||t<0||t>=s.length))return s[t]}getWordAt(e,t){const s=this._lines[e];if(!s||t<0||t>s.length)return["",t,t];let i=t;for(;i>0&&Le(s[i-1]);)i--;let o=t;for(;o<s.length&&Le(s[o]);)o++;return[s.substring(i,o),i,o]}getIndent(e){const t=function(e){const t=e.search(/\S|$/);return t<e.length?t:-1}(this._lines[e]??"");return-1===t?this._lines[e]?.length??0:t}findNext(e,t,s){if(!e)return null;for(let i=t;i<this._lines.length;i++){const o=i===t?s:0,n=this._lines[i].indexOf(e,o);if(-1!==n)return{line:i,col:n}}for(let i=0;i<=t;i++){const o=i===t?s:this._lines[i].length,n=this._lines[i].indexOf(e);if(-1!==n&&n<o)return{line:i,col:n}}return null}insert(e,t,s){const i=s.split(/\r?\n/),o=this._lines[e]??"",n=o.substring(0,t),a=o.substring(t);if(1===i.length)this._lines[e]=n+i[0]+a;else{this._lines[e]=n+i[0];for(let t=1;t<i.length-1;t++)this._lines.splice(e+t,0,i[t]);this._lines.splice(e+i.length-1,0,i[i.length-1]+a)}return this.onChange&&this.onChange(this),{type:"insert",line:e,col:t,text:s}}delete(e,t,s){let i=s,o="",n=e,a=t;for(;i>0&&n<this._lines.length;){const e=this._lines[n],t=e.length-a;if(i<=t)o+=e.substring(a,a+i),this._lines[n]=e.substring(0,a)+e.substring(a+i),i=0;else{o+=e.substring(a)+"\n",i-=t+1;const s=this._lines[n+1]??"";this._lines[n]=e.substring(0,a)+s,this._lines.splice(n+1,1)}}return this.onChange&&this.onChange(this),{type:"delete",line:e,col:t,text:o}}insertLine(e,t=""){const s=e+1;return this._lines.splice(s,0,t),this.onChange&&this.onChange(this),{type:"insert",line:Math.max(e,0),col:e>=0?this._lines[e]?.length??0:0,text:"\n"+t}}removeLine(e){const t=this._lines[e];return this._lines.splice(e,1),0===this._lines.length&&(this._lines=[""]),this.onChange&&this.onChange(this),{type:"delete",line:Math.max(e-1,0),col:e>0?this._lines[e-1]?.length??0:0,text:"\n"+t}}replaceLine(e,t){const s=this._lines[e];return this._lines[e]=t,this.onChange&&this.onChange(this),{type:"replaceLine",line:e,col:0,text:t,oldText:s}}applyInverse(e){return"insert"===e.type?this.delete(e.line,e.col,e.text.length):"replaceLine"===e.type?this.replaceLine(e.line,e.oldText):this.insert(e.line,e.col,e.text)}}class ht{_undoStack=[];_redoStack=[];_pendingOps=[];_pendingCursorsBefore=[];_pendingCursorsAfter=[];_lastPushTime=0;_groupThresholdMs;_maxSteps;constructor(e=2e3,t=200){this._groupThresholdMs=e,this._maxSteps=t}record(e,t){const s=Date.now();s-this._lastPushTime>this._groupThresholdMs&&this._pendingOps.length>0&&this._flush(),0===this._pendingOps.length&&(this._pendingCursorsBefore=t.map(e=>({...e}))),this._pendingOps.push(e),this._pendingCursorsAfter=t.map(e=>({...e})),this._lastPushTime=s,this._redoStack.length=0}flush(e){e&&this._pendingOps.length>0&&(this._pendingCursorsAfter=e.map(e=>({...e}))),this._flush()}undo(e,t){this.flush(t);const s=this._undoStack.pop();if(!s)return null;const i=[];for(let t=s.operations.length-1;t>=0;t--){const o=e.applyInverse(s.operations[t]);i.unshift(o)}return this._redoStack.push({operations:i,cursorsBefore:s.cursorsBefore,cursorsAfter:s.cursorsAfter}),{cursors:s.cursorsBefore}}redo(e){const t=this._redoStack.pop();if(!t)return null;const s=[];for(let i=0;i<t.operations.length;i++){const o=e.applyInverse(t.operations[i]);s.push(o)}return this._undoStack.push({operations:s,cursorsBefore:t.cursorsBefore,cursorsAfter:t.cursorsAfter}),{cursors:t.cursorsAfter}}canUndo(){return this._undoStack.length>0||this._pendingOps.length>0}canRedo(){return this._redoStack.length>0}clear(){this._undoStack.length=0,this._redoStack.length=0,this._pendingOps.length=0,this._lastPushTime=0}_flush(){if(0!==this._pendingOps.length)for(this._undoStack.push({operations:[...this._pendingOps],cursorsBefore:[...this._pendingCursorsBefore],cursorsAfter:[...this._pendingCursorsAfter]}),this._pendingOps.length=0,this._pendingCursorsBefore=[],this._pendingCursorsAfter=[];this._undoStack.length>this._maxSteps;)this._undoStack.shift()}}function dt(e,t){return e.line===t.line&&e.col===t.col}function ut(e,t){return e.line<t.line||e.line===t.line&&e.col<t.col}function pt(e){return ut(e.anchor,e.head)?e.anchor:e.head}function mt(e){return ut(e.anchor,e.head)?e.head:e.anchor}function gt(e){return dt(e.anchor,e.head)}class ft{cursors=[];constructor(){this.cursors=[{anchor:{line:0,col:0},head:{line:0,col:0}}]}getPrimary(){return this.cursors[0]}set(e,t){this.cursors=[{anchor:{line:e,col:t},head:{line:e,col:t}}]}moveLeft(e,t=!1){for(const s of this.cursors)this._moveHead(s,e,-1,0,t);this._merge()}moveRight(e,t=!1){for(const s of this.cursors)this._moveHead(s,e,1,0,t);this._merge()}moveUp(e,t=!1){for(const s of this.cursors)this._moveVertical(s,e,-1,t);this._merge()}moveDown(e,t=!1){for(const s of this.cursors)this._moveVertical(s,e,1,t);this._merge()}moveToLineStart(e,t=!1,s=!1){for(const i of this.cursors){const o=i.head.line,n=e.getIndent(o),a=i.head.col===n||s?0:n;i.head={line:o,col:a},t||(i.anchor={...i.head})}this._merge()}moveToLineEnd(e,t=!1){for(const s of this.cursors){const i=s.head.line;s.head={line:i,col:e.getLine(i).length},t||(s.anchor={...s.head})}this._merge()}moveWordLeft(e,t=!1){for(const s of this.cursors){const{line:i,col:o}=s.head;if(0===o&&i>0)s.head={line:i-1,col:e.getLine(i-1).length};else{const t=e.getLine(i);let n=o;for(;n>0&&/\s/.test(t[n-1]);)n--;if(n>0&&Le(t[n-1]))for(;n>0&&Le(t[n-1]);)n--;else if(n>0)for(;n>0&&ye(t[n-1]);)n--;s.head={line:i,col:n}}t||(s.anchor={...s.head})}this._merge()}moveWordRight(e,t=!1){for(const s of this.cursors){const{line:i,col:o}=s.head,n=e.getLine(i);if(o>=n.length&&i<e.lineCount-1)s.head={line:i+1,col:0};else{let e=o;for(;e<n.length&&/\s/.test(n[e]);)e++;if(e<n.length&&Le(n[e]))for(;e<n.length&&Le(n[e]);)e++;else if(e<n.length&&ye(n[e]))for(;e<n.length&&ye(n[e]);)e++;s.head={line:i,col:e}}t||(s.anchor={...s.head})}this._merge()}selectAll(e){const t=e.lineCount-1;this.cursors=[{anchor:{line:0,col:0},head:{line:t,col:e.getLine(t).length}}]}addCursor(e,t){this.cursors.push({anchor:{line:e,col:t},head:{line:e,col:t}}),this._merge()}removeSecondaryCursors(){this.cursors=[this.cursors[0]]}sortedIndicesBottomUp(){return this.cursors.map((e,t)=>t).sort((e,t)=>{const s=this.cursors[e].head,i=this.cursors[t].head;return i.line!==s.line?i.line-s.line:i.col-s.col})}adjustOthers(e,t,s,i,o=0){for(let n=0;n<this.cursors.length;n++){if(n===e)continue;const a=this.cursors[n];0!==o&&a.head.line>t?a.head={line:a.head.line+o,col:a.head.col}:a.head.line===t&&a.head.col>=s&&(a.head={line:a.head.line+o,col:a.head.col+i}),0!==o&&a.anchor.line>t?a.anchor={line:a.anchor.line+o,col:a.anchor.col}:a.anchor.line===t&&a.anchor.col>=s&&(a.anchor={line:a.anchor.line+o,col:a.anchor.col+i})}}hasSelection(e=0){const t=this.cursors[e];return!!t&&!dt(t.anchor,t.head)}getSelectedText(e,t=0){const s=this.cursors[t];if(!s||gt(s))return"";const i=pt(s),o=mt(s);if(i.line===o.line)return e.getLine(i.line).substring(i.col,o.col);const n=[];n.push(e.getLine(i.line).substring(i.col));for(let t=i.line+1;t<o.line;t++)n.push(e.getLine(t));return n.push(e.getLine(o.line).substring(0,o.col)),n.join("\n")}getCursorPositions(){return this.cursors.map(e=>({...e.head}))}_moveHead(e,t,s,i,o){const{line:n,col:a}=e.head;if(!o&&!gt(e)){const t=s<0?pt(e):mt(e);return e.head={...t},void(e.anchor={...t})}if(s<0)a>0?e.head={line:n,col:a-1}:n>0&&(e.head={line:n-1,col:t.getLine(n-1).length});else if(s>0){a<t.getLine(n).length?e.head={line:n,col:a+1}:n<t.lineCount-1&&(e.head={line:n+1,col:0})}o||(e.anchor={...e.head})}_moveVertical(e,t,s,i){const{line:o,col:n}=e.head,a=o+s;if(a<0||a>=t.lineCount)return;const r=t.getLine(a).length;e.head={line:a,col:Math.min(n,r)},i||(e.anchor={...e.head})}_merge(){if(this.cursors.length<=1)return;this.cursors.sort((e,t)=>e.head.line!==t.head.line?e.head.line-t.head.line:e.head.col-t.head.col);const e=[this.cursors[0]];for(let t=1;t<this.cursors.length;t++){const s=e[e.length-1],i=this.cursors[t];dt(s.head,i.head)||e.push(i)}this.cursors=e}}class Ct{_symbols=new Map;_lineSymbols=[];_scopeStack=[{name:"global",type:"global",line:0}];_lineScopes=[];_lineScopesEnd=[];get currentScope(){return this._scopeStack[this._scopeStack.length-1]?.name??"global"}get currentScopeType(){return this._scopeStack[this._scopeStack.length-1]?.type??"global"}getScopeAtLine(e){return this._lineScopes[e]??[{name:"global",type:"global",line:0}]}getLineScopeEnd(e){return this._lineScopesEnd[e]??[{name:"global",type:"global",line:0}]}getSymbols(e){return this._symbols.get(e)??[]}getAllSymbolNames(){return Array.from(this._symbols.keys())}getAllSymbols(){const e=[];for(const t of this._symbols.values())e.push(...t);return e}getLineSymbols(e){return this._lineSymbols[e]??[]}updateScopeForLine(e,t){0===e?this._scopeStack=[{name:"global",type:"global",line:0}]:this._lineScopesEnd[e-1]&&(this._scopeStack=[...this._lineScopesEnd[e-1]]);const s=function(e){let t="",s=0;for(;s<e.length;){const i=e[s];if("/"===i&&"/"===e[s+1])break;if("/"!==i||"*"!==e[s+1]){if('"'===i||"'"===i||"`"===i){const t=i;for(s++;s<e.length;)if("\\"!==e[s]){if(e[s]===t){s++;break}s++}else s+=2;continue}t+=i,s++}else{for(s+=2;s<e.length&&("*"!==e[s]||"/"!==e[s+1]);)s++;s+=2}}return t}(t),i=(s.match(/\{/g)||[]).length,o=(s.match(/\}/g)||[]).length;this._lineScopes[e]=[...this._scopeStack];for(let e=0;e<o;e++)this._scopeStack.length>1&&this._scopeStack.pop();for(let t=0;t<i;t++)this._scopeStack.push({name:"anonymous",type:"anonymous",line:e});this._lineScopesEnd[e]=[...this._scopeStack]}nameCurrentScope(e,t){if(this._scopeStack.length>0){const s=this._scopeStack[this._scopeStack.length-1];"anonymous"!==s.name&&"anonymous"!==s.type||(s.name=e,s.type=t)}}removeLineSymbols(e){const t=this._lineSymbols[e];if(t){for(const s of t){const t=this._symbols.get(s.name);if(!t)continue;const i=t.findIndex(t=>t.line===e&&t.kind===s.kind&&t.scope===s.scope);-1!==i&&t.splice(i,1),0===t.length&&this._symbols.delete(s.name)}this._lineSymbols[e]=[]}}addSymbol(e){this._symbols.has(e.name)||this._symbols.set(e.name,[]),this._symbols.get(e.name).push(e),this._lineSymbols[e.line]||(this._lineSymbols[e.line]=[]),this._lineSymbols[e.line].push(e)}resetScopes(){this._scopeStack=[{name:"global",type:"global",line:0}],this._lineScopes=[],this._lineScopesEnd=[]}clear(){this._symbols.clear(),this._lineSymbols=[],this.resetScopes()}}const vt=globalThis,yt={keyword:"cm-kwd",statement:"cm-std",type:"cm-typ",builtin:"cm-bln",string:"cm-str",comment:"cm-com",number:"cm-dec",method:"cm-mtd",symbol:"cm-sym",enum:"cm-enu",preprocessor:"cm-ppc",variable:"cm-var"};e.LX.Area,e.LX.Panel,e.LX.Tabs,e.LX.NodeTree;const Lt=/#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b/g;function bt(e,t,s){Lt.lastIndex=0;let i,o="",n=0;const a=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");for(;null!==(i=Lt.exec(e));){o+=a(e.slice(n,i.index));const r=i[0];o+=`<span class="code-color" data-color="${r}" data-line="${t}" data-col="${s+i.index}" style="--code-color:${r}"><span class="code-color-swatch"></span>${a(r)}</span>`,n=i.index+r.length}return o+=a(e.slice(n)),o}class xt{static SIZE=10;root;thumb;_vertical;_thumbPos=0;_thumbRatio=0;_lastMouse=0;_onDrag=null;get visible(){return!this.root.classList.contains("hidden")}get isVertical(){return this._vertical}constructor(t,s){this._vertical=t,this._onDrag=s,this.root=e.LX.makeElement("div","lexcodescrollbar hidden "+(t?"vertical":"horizontal")),this.thumb=e.LX.makeElement("div"),this.thumb.addEventListener("mousedown",e=>this._onMouseDown(e)),this.root.appendChild(this.thumb)}setThumbRatio(t){this._thumbRatio=e.LX.clamp(t,0,1);const s=this._thumbRatio<1;this.root.classList.toggle("hidden",!s),s&&(this._vertical?this.thumb.style.height=100*this._thumbRatio+"%":this.thumb.style.width=100*this._thumbRatio+"%")}syncToScroll(e,t){if(t<=0)return;const s=(this._vertical?this.root.offsetHeight:this.root.offsetWidth)-(this._vertical?this.thumb.offsetHeight:this.thumb.offsetWidth);s<=0||(this._thumbPos=e/t*s,this._applyPosition())}applyDragDelta(t,s){const i=(this._vertical?this.root.offsetHeight:this.root.offsetWidth)-(this._vertical?this.thumb.offsetHeight:this.thumb.offsetWidth);return i<=0?0:(this._thumbPos=e.LX.clamp(this._thumbPos+t,0,i),this._applyPosition(),this._thumbPos/i*s)}_applyPosition(){this._vertical?this.thumb.style.top=this._thumbPos+"px":this.thumb.style.left=this._thumbPos+"px"}_onMouseDown(e){const t=document;this._lastMouse=this._vertical?e.clientY:e.clientX;const s=e=>{const t=this._vertical?e.clientY:e.clientX,s=t-this._lastMouse;this._lastMouse=t,this._onDrag?.(s),e.stopPropagation(),e.preventDefault()},i=()=>{t.removeEventListener("mousemove",s),t.removeEventListener("mouseup",i)};t.addEventListener("mousemove",s),t.addEventListener("mouseup",i),e.stopPropagation(),e.preventDefault()}}class _t{static __instances=[];language;symbolTable;area;baseArea;codeArea;explorerArea;tabs;root;codeScroller;codeSizer;cursorsLayer;selectionsLayer;lineGutter;vScrollbar;hScrollbar;searchBox=null;searchLineBox=null;autocomplete=null;currentTab=null;statusPanel;leftStatusPanel;rightStatusPanel;explorer=null;charWidth=0;lineHeight=0;fontSize=0;xPadding=64;_cachedTabsHeight=0;_cachedStatusPanelHeight=0;skipInfo=!1;disableEdition=!1;skipTabs=!1;useFileExplorer=!1;useAutoComplete=!0;allowAddScripts=!0;allowClosingTabs=!0;allowLoadingFiles=!0;tabSize=4;highlight="Plain Text";newTabOptions=null;customSuggestions=[];explorerName="EXPLORER";onSave;onRun;onCtrlSpace;onCreateStatusPanel;onContextMenu;onNewTab;onSelectTab;onReady;onCreateFile;onCodeChange;onHoverSymbol;_inputArea;_lineStates=[];_lineElements=[];_bracketOpenLine=-1;_bracketCloseLine=-1;_hoverTimer=null;_hoverPopup=null;_hoverWord="";_colorPopover=null;_openedTabs={};_loadedTabs={};_storedTabs={};_focused=!1;_composing=!1;_keyChain=null;_wasPaired=!1;_lastAction="";_blinkerInterval=null;_cursorVisible=!0;_cursorBlinkRate=550;_clickCount=0;_lastClickTime=0;_lastClickLine=-1;_isSearchBoxActive=!1;_isSearchLineBoxActive=!1;_searchMatchCase=!1;_lastTextFound="";_lastSearchPos=null;_discardScroll=!1;_isReady=!1;_lastMaxLineLength=0;_lastLineCount=0;_isAutoCompleteActive=!1;_selectedAutocompleteIndex=0;_displayObservers;static CODE_MIN_FONT_SIZE=9;static CODE_MAX_FONT_SIZE=22;static PAIR_KEYS={'"':'"',"'":"'","`":"`","(":")","{":"}","[":"]"};get doc(){return this.currentTab.doc}get undoManager(){return this.currentTab.undoManager}get cursorSet(){return this.currentTab.cursorSet}get codeContainer(){return this.currentTab.dom}static getInstances(){return _t.__instances}constructor(t,s={}){if(vt.editor=this,_t.__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.allowAddScripts=s.allowAddScripts??this.allowAddScripts,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,this.onRun=s.onRun,this.onCtrlSpace=s.onCtrlSpace,this.onCreateStatusPanel=s.onCreateStatusPanel,this.onContextMenu=s.onContextMenu,this.onNewTab=s.onNewTab,this.onSelectTab=s.onSelectTab,this.onReady=s.onReady,this.onCodeChange=s.onCodeChange,this.onHoverSymbol=s.onHoverSymbol,this.language=xe.getLanguage(this.highlight)??xe.getLanguage("Plain Text"),this.symbolTable=new Ct,this.useFileExplorer){let[s,i]=t.split({sizes:["15%","85%"]});this.explorerArea=s;let o=new e.LX.Panel;o.addTitle(this.explorerName);let n=[];this.explorer=o.addTree(null,n,{filter:!1,rename:!1,skipDefaultIcon:!0}),this.explorer.on("dblClick",e=>{const t=e.items[0].id;this.loadTab(t)}),this.explorer.on("beforeDelete",(e,t)=>{}),s.attach(o),t=i}t.root.className=e.LX.mergeClass(t.root.className,"codebasearea overflow-hidden flex relative"),this.baseArea=t,this.area=new e.LX.Area({className:"lexcodeeditor flex flex-col outline-none overflow-hidden size-full select-none bg-inherit relative",skipAppend:!0});const i="lexcodearea scrollbar-hidden flex flex-row flex-auto-fill";if(this.skipTabs?(this.codeArea=new e.LX.Area({className:i,skipAppend:!0}),this.area.attach(this.codeArea)):(this.tabs=this.area.addTabs({contentClass:i,onclose:e=>{delete this._openedTabs[e]}}),e.LX.addClass(this.tabs.root.parentElement,"rounded-t-lg"),this.disableEdition||this.tabs.root.parentElement.addEventListener("dblclick",e=>{this.allowAddScripts&&(e.preventDefault(),this._onCreateNewFile())}),this.codeArea=this.tabs.area),this.root=this.area.root,t.attach(this.root),this.codeScroller=this.codeArea.root,this.lineGutter=e.LX.makeElement("div","w-16 overflow-hidden absolute top-0 bg-inherit z-10 "+(this.skipTabs?"":"mt-8"),null,this.codeScroller),this.codeSizer=e.LX.makeElement("div","pseudoparent-tabs w-full",null,this.codeScroller),this.cursorsLayer=e.LX.makeElement("div","cursors",null,this.codeSizer),this.selectionsLayer=e.LX.makeElement("div","selections",null,this.codeSizer),!this.disableEdition){this.vScrollbar=new xt(!0,e=>{const t=this.codeScroller.scrollHeight-this.codeScroller.clientHeight;this.codeScroller.scrollTop=this.vScrollbar.applyDragDelta(e,t),this._discardScroll=!0}),this.root.appendChild(this.vScrollbar.root),this.hScrollbar=new xt(!1,e=>{const t=this.codeScroller.scrollWidth-this.codeScroller.clientWidth;this.codeScroller.scrollLeft=this.hScrollbar.applyDragDelta(e,t),this._discardScroll=!0}),this.root.appendChild(this.hScrollbar.root),this.codeScroller.addEventListener("scroll",()=>{this._discardScroll?this._discardScroll=!1:this._syncScrollBars()});let e=0,t=0;this.codeScroller.addEventListener("touchstart",s=>{e=s.touches[0].clientX,t=s.touches[0].clientY},{passive:!0}),this.codeScroller.addEventListener("touchmove",s=>{const i=s.touches[0].clientX,o=s.touches[0].clientY,n=e-i,a=t-o;this.codeScroller.scrollLeft+=n,this.codeScroller.scrollTop+=a,e=i,t=o},{passive:!0}),this.codeScroller.addEventListener("wheel",e=>{if(e.ctrlKey)return e.preventDefault(),void this._applyFontSizeOffset(e.deltaY<0?1:-1);e.shiftKey&&(this.codeScroller.scrollLeft+=e.deltaY>0?10:-10)},{passive:!1})}if(new ResizeObserver(()=>{this.currentTab&&this.resize(!0)}).observe(this.codeArea.root),!this.disableEdition){this.useAutoComplete&&(this.autocomplete=e.LX.makeElement("div","autocomplete"),this.codeArea.attach(this.autocomplete));const t="searchbox bg-card min-w-96 absolute z-100 top-8 right-2 rounded-lg border-color overflow-y-scroll opacity-0";{const s=e.LX.makeElement("div",t,null,this.codeArea),i=new e.LX.Panel;s.appendChild(i.root),i.sameLine();const o=i.addText(null,"",null,{placeholder:"Find",inputClass:"bg-secondary"});i.addButton(null,"MatchCaseButton",e=>{this._searchMatchCase=e,this._doSearch()},{icon:"CaseSensitive",selectable:!0,buttonClass:"link",title:"Match Case",tooltip:!0}),i.addButton(null,"up",()=>this._doSearch(null,!0),{icon:"ArrowUp",buttonClass:"ghost",title:"Previous Match",tooltip:!0}),i.addButton(null,"down",()=>this._doSearch(),{icon:"ArrowDown",buttonClass:"ghost",title:"Next Match",tooltip:!0}),i.addButton(null,"x",this._doHideSearch.bind(this),{icon:"X",buttonClass:"ghost",title:"Close",tooltip:!0}),i.endLine();const n=o.root.querySelector("input");n?.addEventListener("keyup",e=>{"Escape"==e.key?this._doHideSearch():"Enter"==e.key&&this._doSearch(e.target.value,!!e.shiftKey)}),this.searchBox=s}{const s=e.LX.makeElement("div",t,null,this.codeArea),i=new e.LX.Panel;s.appendChild(i.root),i.sameLine();const o=i.addText(null,"",e=>{n.value=":"+e.replaceAll(":",""),this._doGotoLine(parseInt(n.value.slice(1)))},{className:"flex-auto-fill",placeholder:"Go to line",trigger:"input"});i.addButton(null,"x",this._doHideSearch.bind(this),{icon:"X",title:"Close",buttonClass:"ghost",tooltip:!0}),i.endLine();const n=o.root.querySelector("input");n.addEventListener("keyup",e=>{"Escape"==e.key&&this._doHideSearch()}),i.addText(null,"Type a line number to go to (from 0 to 0).",null,{disabled:!0,inputClass:"text-xs bg-none",signal:"@line-number-range"}),this.searchLineBox=s}}this._inputArea=e.LX.makeElement("textarea","absolute opacity-0 w-[1px] h-[1px] top-0 left-0 overflow-hidden resize-none","",this.root),this._inputArea.setAttribute("autocorrect","off"),this._inputArea.setAttribute("autocapitalize","off"),this._inputArea.setAttribute("spellcheck","false"),this._inputArea.tabIndex=0,this._inputArea.addEventListener("keydown",this._onKeyDown.bind(this)),this._inputArea.addEventListener("compositionstart",()=>this._composing=!0),this._inputArea.addEventListener("compositionend",e=>{this._composing=!1,this._inputArea.value="",e.data&&this._doInsertChar(e.data)}),this._inputArea.addEventListener("input",()=>{if(this._composing)return;const e=this._inputArea.value;e&&(this._inputArea.value="",this._doInsertChar(e))}),this._inputArea.addEventListener("focus",()=>this._setFocused(!0)),this._inputArea.addEventListener("blur",()=>this._setFocused(!1)),this.codeArea.root.addEventListener("mousedown",this._onMouseDown.bind(this)),this.codeArea.root.addEventListener("contextmenu",this._onMouseDown.bind(this)),this.codeArea.root.addEventListener("mouseover",e=>{const t=e.target.closest(".code-link");t&&e.ctrlKey&&t.classList.add("hovered")}),this.codeArea.root.addEventListener("mouseout",e=>{const t=e.target.closest(".code-link");t&&t.classList.remove("hovered")}),this.codeArea.root.addEventListener("mousemove",e=>{const t=e.target.closest(".code-link");t&&t.classList.toggle("hovered",e.ctrlKey),this._onCodeAreaMouseMove(e)}),this.codeArea.root.addEventListener("mouseleave",()=>{this._clearHoverPopup()}),this.codeArea.root.addEventListener("click",e=>{this._onColorSwatchClick(e)}),this.statusPanel=this._createStatusPanel(s),this.statusPanel&&this.area.root.appendChild(this.statusPanel.root),this.allowAddScripts&&(this.onCreateFile=s.onCreateFile,this.addTab("+",{selected:!1,title:"Create file"})),(s.defaultTab??1)&&(this.addTab(s.name||"untitled",{language:this.highlight,title:s.title}),this._renderAllLines(),this._renderCursors()),this._init()}_init(){if(this._displayObservers)return;this._isReady=!1;const e=this.root,t=async()=>{this._isReady||null!==e.offsetParent&&e.clientWidth>0&&e.clientHeight>0&&(s.disconnect(),i.disconnect(),await this._setupEditorWhenVisible())},s=new IntersectionObserver(e=>{for(const s of e)s.isIntersecting&&t()});s.observe(e);const i=new ResizeObserver(()=>{t()});i.observe(e),this._displayObservers={intersectionObserver:s,resizeObserver:i}}clear(){console.assert(this.rightStatusPanel&&this.leftStatusPanel,"No panels to clear."),this.rightStatusPanel.clear(),this.leftStatusPanel.clear()}addExplorerItem(e){this.explorer&&(this.explorer.innerTree.data.find((t,s)=>t.id===e.id)||this.explorer.innerTree.data.push(e))}setText(e,t,s=!1){if(this.currentTab){if(this.doc.setText(this._normalizeText(e)),this.cursorSet.set(0,0),this.undoManager.clear(),this._lineStates=[],t)this.setLanguage(t);else if(s){const t=this._detectLanguage(e);t&&this.setLanguage(t)}this._renderAllLines(),this._renderCursors(),this._renderSelections(),this.resize(!0)}}_detectLanguage(e){const t={},s=(e,s)=>{t[e]=(t[e]??0)+s},i=new Set(e.match(/\b\w+\b/g)??[]),o=Math.max(i.size,1);for(const e of xe.getRegisteredLanguages()){const t=xe.getLanguage(e);if(!t?.reservedWords?.length)continue;let n=0;for(const e of t.reservedWords)i.has(e)&&n++;if(n>0){const i=n/t.reservedWords.length,a=n/o;s(e,Math.round(40*(i+a)))}}/<!DOCTYPE\s+html/i.test(e)&&s("HTML",20),/<html[\s>]/i.test(e)&&s("HTML",15),/<\/?(div|span|body|head|script|style|meta)\b/i.test(e)&&s("HTML",8),/^\s*[\[{]/.test(e)&&/"\s*:\s*/.test(e)&&!/function|=>|const|var|let/.test(e)&&s("JSON",15),/[\w-]+\s*:\s*[\w#\d"'(]+.*;/.test(e)&&/[{}]/.test(e)&&!/<\w+/.test(e)&&s("CSS",10),/@(media|keyframes|import|charset|font-face)\b/.test(e)&&s("CSS",15),/@(vertex|fragment|compute|group|binding|builtin)\b/.test(e)&&s("WGSL",20),/\bfn\s+\w+\s*\(/.test(e)&&/\bvar\b/.test(e)&&s("WGSL",10),/\b(vec2f|vec3f|vec4f|mat4x4f|f32|u32|i32)\b/.test(e)&&s("WGSL",12),/\b(gl_Position|gl_FragColor|gl_FragCoord)\b/.test(e)&&s("GLSL",20),/\b(uniform|varying|attribute)\s+\w/.test(e)&&s("GLSL",10),/\b(vec2|vec3|vec4|mat4|sampler2D)\b/.test(e)&&!/vec2f|vec3f/.test(e)&&s("GLSL",8),/\b(SV_Position|SV_Target|SV_Depth)\b/.test(e)&&s("HLSL",20),/\b(cbuffer|tbuffer|float4|float3|float2|Texture2D)\b/.test(e)&&s("HLSL",12),/^\s*def\s+\w+\s*\(/m.test(e)&&s("Python",15),/^\s*import\s+\w/m.test(e)&&!/\bfrom\s+['"]/.test(e)&&s("Python",8),/^\s*class\s+\w+(\s*\(.*\))?:/m.test(e)&&s("Python",10),/\bprint\s*\(/.test(e)&&/:\s*$/.test(e)&&s("Python",5),/elif\b|lambda\b|self\.\w/.test(e)&&s("Python",8),/\bfn\s+\w+\s*\(/.test(e)&&/\blet\s+mut\b/.test(e)&&s("Rust",15),/\b(impl|trait|enum|struct)\s+\w+/.test(e)&&/\bfn\b/.test(e)&&s("Rust",12),/use\s+std::|use\s+\w+::\w+/.test(e)&&s("Rust",10),/println!\s*\(/.test(e)&&s("Rust",8),/#include\s*<[\w./]+>/.test(e)&&s("C++",15),/\bstd::\w+/.test(e)&&s("C++",12),/\b(class|template|namespace|nullptr|new\s+\w)\b/.test(e)&&s("C++",8),/(::|->)\w+/.test(e)&&s("C++",6),/#include\s*<[\w.]+\.h>/.test(e)&&s("C",12),/\bint\s+main\s*\(/.test(e)&&s("C",15),/\b(printf|scanf|malloc|free|sizeof)\s*\(/.test(e)&&s("C",10),/:\s*(string|number|boolean|void|any|never|unknown)\b/.test(e)&&s("TypeScript",12),/\binterface\s+\w+/.test(e)&&s("TypeScript",12),/\btype\s+\w+\s*=/.test(e)&&s("TypeScript",10),/\bas\s+(string|number|any|unknown)\b/.test(e)&&s("TypeScript",8),/\benum\s+\w+\s*\{/.test(e)&&s("TypeScript",8),/\b(const|let|var)\s+\w+\s*=/.test(e)&&s("JavaScript",8),/=>\s*[\w{(]/.test(e)&&s("JavaScript",6),/\b(import|export)\s+(default|{|\*)/.test(e)&&s("JavaScript",8),/\bconsole\.(log|warn|error)\b/.test(e)&&s("JavaScript",6),/^#{1,6}\s+\S/m.test(e)&&s("Markdown",12),(/\*\*\w.*?\*\*/.test(e)||/\[.+\]\(.+\)/.test(e))&&s("Markdown",8),/^```\w*/m.test(e)&&s("Markdown",10);const n=Object.entries(t).sort((e,t)=>t[1]-e[1])[0];return n&&n[1]>=8?n[0]:null}appendText(e){const t=this.cursorSet.getPrimary(),{line:s,col:i}=t.head,o=this.doc.insert(s,i,e);this.undoManager.record(o,this.cursorSet.getCursorPositions());const n=e.split(/\r?\n/);1===n.length?t.head={line:s,col:i+e.length}:t.head={line:s+n.length-1,col:n[n.length-1].length},t.anchor={...t.head},this._rebuildLines(),this._renderCursors(),this._renderSelections(),this.resize(),this._scrollCursorIntoView()}getText(){return this.doc.getText()}setLanguage(t,s){const i=xe.getLanguage(t);i&&(this.language=i,this.currentTab&&(this.currentTab.language=t,this.skipTabs||this.tabs.setIcon(this.currentTab.name,be(i,s))),this._lineStates=[],this._renderAllLines(),e.LX.emitSignal("@highlight",t))}focus(){this._inputArea.focus()}addTab(t,s={}){const i="+"===t,o=e.LX.makeElement("div","code"),n=s.language??"Plain Text",a=xe.getLanguage(n),r=e.LX.getExtension(t),l=i?null:be(a,r),c=s.selected??!0,h={name:t,dom:o,doc:new ct(this.onCodeChange),cursorSet:new ft,undoManager:new ht,language:n,title:s.title??t};return this._openedTabs[t]=h,this._loadedTabs[t]=h,this.useFileExplorer&&!i&&(this.addExplorerItem({id:t,skipVisibility:!0,icon:l}),this.explorer.innerTree.frefresh(t)),this.skipTabs||this.tabs.add(t,o,{selected:c,icon:l,fixed:i,title:h.title,onSelect:this._onSelectTab.bind(this,i),onContextMenu:this._onContextMenuTab.bind(this,i),allowDelete:this.allowClosingTabs,indexOffset:s.indexOffset}),this.codeSizer.appendChild(o),s.text&&(h.doc.setText(s.text),h.cursorSet.set(0,0),h.undoManager.clear(),this._renderAllLines(),this._renderCursors(),this._renderSelections(),this._resetGutter()),c&&(this.currentTab=h,this._updateDataInfoPanel("@tab-name",t),this.setLanguage(n,r)),h}loadTab(e){if(this._openedTabs[e])return void this.tabs.select(e);const t=this._loadedTabs[e];if(t)return this._openedTabs[e]=t,this.tabs.add(e,t.dom,{selected:!0,title:t.title,onSelect:this._onSelectTab.bind(this),onContextMenu:this._onContextMenuTab.bind(this),allowDelete:this.allowClosingTabs}),this.codeSizer.appendChild(t.dom),this.currentTab=t,void this._updateDataInfoPanel("@tab-name",e);this.addTab(e,this._storedTabs[e]??null)}closeTab(e){if(!this.allowClosingTabs)return;this.tabs.delete(e);const t=this._openedTabs[e];if(t&&(t.dom.remove(),delete this._openedTabs[e]),this.currentTab?.name===e){const e=Object.keys(this._openedTabs).filter(e=>"+"!==e);e.length>0?this.tabs.select(e[0]):this.currentTab=null}}setCustomSuggestions(e){e&&e.constructor===Array?this.customSuggestions=e.map(e=>"string"==typeof e?{label:e}:e):console.warn("suggestions should be an array!")}loadFile(t,s={}){const i=(t,i)=>{t=this._normalizeText(t);const o=e.LX.getExtension(i),n=s.language??xe.getLanguage(s.language)??xe.getLanguageByExtension(o)??xe.getLanguage("Plain Text"),a=n.name;this.useFileExplorer||this.skipTabs?(this._storedTabs[i]={text:t,title:s.title??i,language:a,...s},this.useFileExplorer&&(this.addExplorerItem({id:i,skipVisibility:!0,icon:be(n,o)}),this.explorer.innerTree.frefresh(i))):(this.addTab(i,{selected:!0,title:s.title??i,language:a}),this.doc.setText(t),this.setLanguage(a,o),this.cursorSet.set(0,0),this.undoManager.clear(),this._renderCursors(),this._renderSelections(),this._resetGutter()),s.callback&&s.callback(i,t)};if("string"==typeof t){const o=t,n=s.filename??o.substring(o.lastIndexOf("/")+1);e.LX.request({url:o,success:e=>{i(e,n)}})}else{const e=new FileReader;e.readAsText(t),e.onload=e=>{const s=e.currentTarget.result;i(s,t.name)}}}async loadFiles(t,s,i=!1){if(!t||0===t.length)return void s?.(this,[],0);const o=[];for(const s of t)try{const t=await e.LX.requestFileAsync(s,"text"),i=s.substring(s.lastIndexOf("/")+1),n=t.replaceAll("\r","").replaceAll(/\t|\\t/g," ".repeat(this.tabSize)),a=e.LX.getExtension(i),r=xe.getLanguageByExtension(a)??xe.getLanguage("Plain Text"),l=r.name;this.useFileExplorer||this.skipTabs?(this._storedTabs[i]={text:n,title:i,language:l},this.useFileExplorer&&(this.addExplorerItem({id:i,skipVisibility:!0,icon:be(r,a)}),this.explorer.innerTree.frefresh(i))):(this.addTab(i,{selected:0===o.length,title:i,language:l}),0===o.length&&(this.doc.setText(n),this.setLanguage(l,a),this.cursorSet.set(0,0),this.undoManager.clear(),this._renderCursors(),this._renderSelections(),this._resetGutter())),o.push({filePath:s,name:i,success:!0})}catch(e){console.error(`[LX.CodeEditor] Failed to load file: ${s}`,e),o.push({filePath:s,success:!1,error:e})}s?.(this,o,o.length)}async _setupEditorWhenVisible(){const t=window.localStorage.getItem("lexcodeeditor-font-size");if(t)await this._setFontSize(parseInt(t),!1);else{const e=document.querySelector(":root"),t=getComputedStyle(e);this.fontSize=parseInt(t.getPropertyValue("--code-editor-font-size")),await this._measureChar()}e.LX.emitSignal("@font-size",this.fontSize),e.LX.doAsync(()=>{this._isReady||(this._isReady=!0,this.onReady&&this.onReady(this),console.log(`[LX.CodeEditor] Ready! (font size: ${this.fontSize}px, char size: ${this.charWidth}px)`))},20)}_onSelectTab(t,s,i){this.disableEdition||(t?this._onNewTab(s):(this.currentTab=this._openedTabs[i],this._updateDataInfoPanel("@tab-name",i),this.language=xe.getLanguage(this.currentTab.language)??xe.getLanguage("Plain Text"),e.LX.emitSignal("@highlight",this.currentTab.language),this._renderAllLines(),this._afterCursorMove(),!t&&this.onSelectTab&&this.onSelectTab(i,this)))}_onNewTab(t){if(this.onNewTab)return void this.onNewTab(t);const s=this.newTabOptions??[{name:"Create file",icon:"FilePlus",callback:this._onCreateNewFile.bind(this)},{name:"Load file",icon:"FileUp",disabled:!this.allowLoadingFiles,callback:this._doLoadFromFile.bind(this)}];e.LX.addDropdownMenu(t.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,{selected:!0,title:t,indexOffset:e.indexOffset,language:e.language??"JavaScript"}),this._renderAllLines(),this._renderCursors(),this._renderSelections(),this._resetGutter()}_onContextMenuTab(t=!1,s,i){t||e.LX.addDropdownMenu(s.target,[{name:"Close",kbd:"MWB",disabled:!this.allowClosingTabs,callback:()=>{this.closeTab(i)}},{name:"Close Others",disabled:!this.allowClosingTabs,callback:()=>{for(const e of Object.keys(this.tabs.tabs))"+"!==e&&e!==i&&this.closeTab(e)}},{name:"Close All",disabled:!this.allowClosingTabs,callback:()=>{for(const e of Object.keys(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})}async _measureChar(){const t=e.LX.makeContainer(null,"lexcodeeditor","",document.body),s=e.LX.makeContainer(null,"code","",t),i=document.createElement("pre");s.appendChild(i);const o=document.createElement("span");o.className="codechar",o.style.visibility="hidden",o.textContent="M",i.appendChild(o);const n=getComputedStyle(o),a=n.fontFamily,r=n.fontSize,l=n.fontWeight||"normal",c=`${n.fontStyle||"normal"} ${l} ${r} ${a}`;try{await document.fonts.load(c)}catch(e){console.warn("[LX.CodeEditor] Failed to load font:",c,e)}requestAnimationFrame(()=>{const s=o.getBoundingClientRect();this.charWidth=s.width||7,this.lineHeight=parseFloat(getComputedStyle(this.root).getPropertyValue("--code-editor-row-height"))||20,e.LX.deleteElement(t),this._renderCursors(),this._renderSelections(),this.resize(!0)})}_createStatusPanel(t={}){if(this.skipInfo)return;let s=new e.LX.Panel({className:"lexcodetabinfo bg-inherit flex flex-row flex-auto-keep",height:"auto"});this.onCreateStatusPanel&&this.onCreateStatusPanel(s,this);let i=this.leftStatusPanel=new e.LX.Panel({id:"FontSizeZoomStatusComponent",className:"pad-xs content-center items-center flex-auto-keep",width:"auto",height:"auto"});i.sameLine(),i.addButton(null,"ZoomOutButton",this._decreaseFontSize.bind(this),{icon:"ZoomOut",buttonClass:"ghost sm",title:"Zoom Out",tooltip:!0}),i.addLabel(this.fontSize,{fit:!0,signal:"@font-size"}),i.addButton(null,"ZoomInButton",this._increaseFontSize.bind(this),{icon:"ZoomIn",buttonClass:"ghost sm",title:"Zoom In",tooltip:!0}),i.endLine("justify-start"),s.attach(i.root);let o=this.rightStatusPanel=new e.LX.Panel({className:"pad-xs content-center items-center",height:"auto"});o.sameLine(),o.addLabel(this.currentTab?.title??"",{id:"EditorFilenameStatusComponent",fit:!0,inputClass:"text-xs",signal:"@tab-name"}),o.addButton(null,"Ln 1, Col 1",this._doOpenLineSearch.bind(this),{id:"EditorSelectionStatusComponent",buttonClass:"outline xs",fit:!0,signal:"@cursor-data"});const n=o.addButton(null,"Spaces: "+this.tabSize,(t,s)=>{const i=e=>{this.tabSize=parseInt(e),this._rebuildLines(),this._updateDataInfoPanel("@tab-spaces",`Spaces: ${this.tabSize}`)},o=e.LX.addDropdownMenu(n.root,["2","4","8"].map(e=>({name:e,className:"w-full place-content-center",callback:i})),{side:"top",align:"end"});e.LX.addClass(o.root,"min-w-16! items-center")},{id:"EditorIndentationStatusComponent",buttonClass:"outline xs",signal:"@tab-spaces"}),a=o.addButton("<b>{ }</b>",this.highlight,(t,s)=>{const i=e.LX.addDropdownMenu(a.root,xe.getRegisteredLanguages().map(e=>{const t=be(xe.getLanguage(e)),s=t?t.split(" "):[];return{name:e,icon:s[0],className:"w-full text-xs px-3",svgClass:s.slice(1).join(" "),callback:e=>this.setLanguage(e)}}),{side:"top",align:"end"});e.LX.addClass(i.root,"min-w-min! items-center")},{id:"EditorLanguageStatusComponent",nameWidth:"auto",buttonClass:"outline xs",signal:"@highlight",title:""});o.endLine("justify-end"),s.attach(o.root);const r={"Font Size Zoom":t.statusShowFontSizeZoom??!0,"Editor Filename":t.statusShowEditorFilename??!0,"Editor Selection":t.statusShowEditorSelection??!0,"Editor Indentation":t.statusShowEditorIndentation??!0,"Editor Language":t.statusShowEditorLanguage??!0},l=e=>{const t=s.root.querySelector(`#${e.replaceAll(" ","")}StatusComponent`);console.assert(t,`${e} has no status button!`),t.classList.toggle("hidden",!r[e])};for(const[e,t]of Object.entries(r))l(e);return s.root.addEventListener("contextmenu",t=>{if(t.target&&(t.target.classList.contains("lexpanel")||t.target.classList.contains("lexinlinecomponents")))return;const s=Object.keys(r).map((e,t)=>{const s={name:e,icon:"Check",callback:()=>{r[e]=!r[e],l(e)}};return r[e]||delete s.icon,s});e.LX.addDropdownMenu(t.target,s,{side:"top",align:"start"})}),s}_updateDataInfoPanel(t,s){this.skipInfo||(this.cursorSet.cursors.length>1&&(s=""),e.LX.emitSignal(t,s))}_tokenizeLine(e){const t=e>0?this._lineStates[e-1]??xe.initialState():xe.initialState(),s=this.doc.getLine(e),i=xe.tokenizeLine(s,this.language,t),o=this.language.name.toLowerCase().replace(/[^a-z]/g,""),n=/(https?:\/\/[^\s"'<>)\]]+)/g;let a=-1;if(e===this._bracketOpenLine){for(let e=i.tokens.length-1;e>=0;e--)if("symbol"===i.tokens[e].type&&"{"===i.tokens[e].value){a=e;break}}else if(e===this._bracketCloseLine)for(let e=0;e<i.tokens.length;e++)if("symbol"===i.tokens[e].type&&"}"===i.tokens[e].value){a=e;break}let r="",l=0;for(let t=0;t<i.tokens.length;t++){const s=i.tokens[t],c=yt[s.type],h=l;let d;if(l+=s.value.length,"comment"===s.type){d=s.value.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(n,'<span class="code-link" data-url="$1">$1</span>')}else d=bt(s.value,e,h);const u=t===a?" code-bracket-active":"";r+=c?`<span class="${c} ${o}${u}">${d}</span>`:u?`<span class="${u.trim()}">${d}</span>`:d}return{html:r||" ",endState:i.state,tokens:i.tokens}}_updateSymbolsForLine(e){const t=this.doc.getLine(e);this.symbolTable.updateScopeForLine(e,t),this.symbolTable.removeLineSymbols(e);const{tokens:s}=this._tokenizeLine(e),i=function(e,t,s,i){const o=[],n=i.getScopeAtLine(s),a=n[n.length-1],r=a?.name??"global",l=a?.type??"global",c=new Set;for(const e of t)["keyword","statement","builtin","preprocessor"].includes(e.type)&&c.add(e.value);const h=new Set,d=(e,t,i=0)=>{if(!e||!e.match(/^[a-zA-Z_$][\w$]*$/))return;if(c.has(e))return;const n=`${e}@${5*Math.floor(i/5)}`;h.has(n)||(o.push({name:e,kind:t,scope:r,line:s,col:i}),h.add(n))},u=[{regex:/^\s*class\s+([A-Z_]\w*)/i,kind:"class"},{regex:/^\s*struct\s+([A-Z_]\w*)/i,kind:"struct"},{regex:/^\s*interface\s+([A-Z_]\w*)/i,kind:"interface"},{regex:/^\s*enum\s+([A-Z_]\w*)/i,kind:"enum"},{regex:/^\s*type\s+([A-Z_]\w*)\s*=/i,kind:"type"},{regex:/^\s*(?:export\s+)?(?:async\s+)?function\s+(\w+)/i,kind:"function"},{regex:/^\s*(?:const|let|var)\s+(\w+)\s*=\s*(?:async\s+)?\([^)]*\)\s*=>/i,kind:"function"},{regex:/^\s*(?:static\s+|const\s+|virtual\s+|inline\s+|extern\s+|pub\s+|async\s+)*(?!\b(?:await|return|if|else|while|for|switch|case|throw|new|delete|typeof|yield)\b)(\w+[\w\s\*&:<>,]*?)\s+(\w+)\s*\([^)]*\)\s*[{;]/i,kind:"typed-function"},{regex:/^\s*(?:(?:public|private|protected|static|readonly|async|override)\s+)*(\w+)\s*\([^)]*\)\s*[:{]/i,kind:"class"===l?"method":"function"}],p=[{regex:/(?:const|let|var)\s+(\w+)/gi,kind:"variable"},{regex:/(\w+)\s*:\s*(?:function|[A-Z]\w*)/gi,kind:"variable"},{regex:/this\.(\w+)\s*=/gi,kind:"property"},{regex:/\b(?:private|protected|public)\s+(?:(?:static|readonly)\s+)*(\w+)\s*[=:;]/gi,kind:"property"},{regex:/new\s+([A-Z]\w+)/gi,kind:"constructor-call"},{regex:/(\w+)\s*\(/gi,kind:"method-call"}];let m=!1;for(const t of u){const s=e.match(t.regex);if(s){let o,n=t.kind;if("typed-function"===t.kind&&s[2])o=s[2],n="class"===l?"method":"function";else{if(!s[1])continue;o=s[1]}d(o,n,e.indexOf(o)),["class","function","method","enum","struct","interface"].includes(n)&&i.nameCurrentScope(o,n),m=!0;break}}if(!m)for(const t of p){const s=e.matchAll(t.regex);for(const e of s)if(e[1]){const s=e[1],i=e.index??0;d(s,t.kind,i)}}if("enum"===l){const t=e.match(/^\s*(\w+)\s*[,=]?/);t&&t[1]&&!e.includes("enum")&&d(t[1],"enum-value",e.indexOf(t[1]))}return o}(t,s,e,this.symbolTable);for(const e of i)this.symbolTable.addSymbol(e)}_renderAllLines(){if(this.currentTab){this.codeContainer.innerHTML="",this._lineElements=[],this._lineStates=[],this.symbolTable.clear();for(let e=0;e<this.doc.lineCount;e++)this._appendLineElement(e)}}_getGutterHtml(e){return`<span class="line-gutter">${e+1}</span>`}_appendLineElement(e){const{html:t,endState:s}=this._tokenizeLine(e);this._lineStates[e]=s;const i=document.createElement("pre");i.innerHTML=this._getGutterHtml(e)+t,this.codeContainer.appendChild(i),this._lineElements[e]=i,this._updateSymbolsForLine(e)}_updateLine(e){const{html:t,endState:s}=this._tokenizeLine(e),i=this._lineStates[e];if(this._lineStates[e]=s,this._lineElements[e]&&(this._lineElements[e].innerHTML=this._getGutterHtml(e)+t),this._updateSymbolsForLine(e),!this._statesEqual(i,s))for(let t=e+1;t<this.doc.lineCount;t++){const{html:e,endState:s}=this._tokenizeLine(t),i=this._lineStates[t];if(this._lineStates[t]=s,this._lineElements[t]&&(this._lineElements[t].innerHTML=this._getGutterHtml(t)+e),this._updateSymbolsForLine(t),this._statesEqual(i,s))break}for(let t=e+1;t<this.doc.lineCount;t++){const e=this.symbolTable.getScopeAtLine(t).length;if(this.symbolTable.updateScopeForLine(t,this.doc.getLine(t)),this.symbolTable.getScopeAtLine(t).length===e)break}}_rebuildLines(){if(this._lineElements.length===this.doc.lineCount)for(let e=0;e<this.doc.lineCount;e++)this._updateLine(e);else this._renderAllLines();this.resize()}_statesEqual(e,t){if(!e)return!1;if(e.stack.length!==t.stack.length)return!1;for(let s=0;s<e.stack.length;s++)if(e.stack[s]!==t.stack[s])return!1;return!0}_updateActiveLine(){const e=this.cursorSet.hasSelection(),t=this.cursorSet.getPrimary().head.line,s=this.cursorSet.getPrimary().head.col;for(let s=0;s<this._lineElements.length;s++)this._lineElements[s].classList.toggle("active-line",!e&&s===t);this._updateDataInfoPanel("@cursor-data",`Ln ${t+1}, Col ${s+1}`)}_renderCursors(){if(this.currentTab){this.cursorsLayer.innerHTML="";for(const t of this.cursorSet.cursors){const s=e.LX.makeElement("div","cursor"," ",this.cursorsLayer);s.style.left=t.head.col*this.charWidth+this.xPadding+"px",s.style.top=t.head.line*this.lineHeight+"px"}this._updateActiveLine()}}_renderSelections(){if(this.currentTab){this.selectionsLayer.innerHTML="";for(const t of this.cursorSet.cursors){if(gt(t))continue;const s=pt(t),i=mt(t);for(let t=s.line;t<=i.line;t++){const o=this.doc.getLine(t),n=t===s.line?s.col:0,a=t===i.line?i.col:o.length;if(n===a&&t===i.line)continue;const r=n===a?Math.ceil(.5*this.charWidth):(a-n)*this.charWidth,l=e.LX.makeElement("div","lexcodeselection","",this.selectionsLayer);l.style.top=t*this.lineHeight+"px",l.style.left=n*this.charWidth+this.xPadding+"px",l.style.width=r+"px"}}}}_setFocused(e){this._focused=e,e?(this.cursorsLayer.classList.add("show"),this.selectionsLayer.classList.add("show"),this.selectionsLayer.classList.remove("unfocused"),this._startBlinker()):(this.cursorsLayer.classList.remove("show"),this._isSearchBoxActive?this.selectionsLayer.classList.add("show"):this.selectionsLayer.classList.add("unfocused"),this._stopBlinker())}_startBlinker(){this._stopBlinker(),this._cursorVisible=!0,this._setCursorVisibility(!0),this._blinkerInterval=setInterval(()=>{this._cursorVisible=!this._cursorVisible,this._setCursorVisibility(this._cursorVisible)},this._cursorBlinkRate)}_stopBlinker(){null!==this._blinkerInterval&&(clearInterval(this._blinkerInterval),this._blinkerInterval=null)}_resetBlinker(){this._focused&&this._startBlinker()}_setCursorVisibility(e){const t=this.cursorsLayer.querySelectorAll(".cursor");for(const s of t)s.style.opacity=e?"0.6":"0"}_onKeyDown(e){if(!this.currentTab)return;if(this._composing||"Dead"===e.key)return;if(["Control","Shift","Alt","Meta"].includes(e.key))return;const t=e.ctrlKey||e.metaKey,s=e.shiftKey,i=e.altKey;if(this._keyChain){const s=this._keyChain;if(this._keyChain=null,e.preventDefault(),t&&"k"===s)switch(e.key.toLowerCase()){case"c":return void this._commentLines();case"u":return void this._uncommentLines()}return}if(t)switch(e.key.toLowerCase()){case"a":return e.preventDefault(),this.cursorSet.selectAll(this.doc),void this._afterCursorMove();case"d":return e.preventDefault(),void this._doFindNextOcurrence();case"f":return e.preventDefault(),void this._doOpenSearch();case"g":return e.preventDefault(),void this._doOpenLineSearch();case"k":return e.preventDefault(),void(this._keyChain="k");case"s":return e.preventDefault(),void(this.onSave&&this.onSave(this.getText(),this));case"z":return e.preventDefault(),void(s?this._doRedo():this._doUndo());case"y":return e.preventDefault(),void this._doRedo();case"c":return e.preventDefault(),void this._doCopy();case"x":return e.preventDefault(),void this._doCut();case"v":return e.preventDefault(),void this._doPaste();case" ":return e.preventDefault(),void(this.onCtrlSpace&&this.onCtrlSpace(this.getText(),this))}switch(e.key){case"ArrowLeft":return e.preventDefault(),this._wasPaired=!1,t?this.cursorSet.moveWordLeft(this.doc,s):this.cursorSet.moveLeft(this.doc,s),void this._afterCursorMove();case"ArrowRight":return e.preventDefault(),this._wasPaired=!1,t?this.cursorSet.moveWordRight(this.doc,s):this.cursorSet.moveRight(this.doc,s),void this._afterCursorMove();case"ArrowUp":if(e.preventDefault(),this._isAutoCompleteActive){const e=this.autocomplete.childNodes;return e[this._selectedAutocompleteIndex]?.classList.remove("selected"),this._selectedAutocompleteIndex=(this._selectedAutocompleteIndex-1+e.length)%e.length,e[this._selectedAutocompleteIndex]?.classList.add("selected"),void e[this._selectedAutocompleteIndex]?.scrollIntoView({block:"nearest"})}return this._wasPaired=!1,i&&s?void this._duplicateLine(-1):i?void this._swapLine(-1):(this.cursorSet.moveUp(this.doc,s),void this._afterCursorMove());case"ArrowDown":if(e.preventDefault(),this._isAutoCompleteActive){const e=this.autocomplete.childNodes;return e[this._selectedAutocompleteIndex]?.classList.remove("selected"),this._selectedAutocompleteIndex=(this._selectedAutocompleteIndex+1)%e.length,e[this._selectedAutocompleteIndex]?.classList.add("selected"),void e[this._selectedAutocompleteIndex]?.scrollIntoView({block:"nearest"})}return this._wasPaired=!1,i&&s?void this._duplicateLine(1):i?void this._swapLine(1):(this.cursorSet.moveDown(this.doc,s),void this._afterCursorMove());case"Home":return e.preventDefault(),this._wasPaired=!1,this.cursorSet.moveToLineStart(this.doc,s),void this._afterCursorMove();case"End":return e.preventDefault(),this._wasPaired=!1,this.cursorSet.moveToLineEnd(this.doc,s),void this._afterCursorMove();case"Escape":if(e.preventDefault(),this._isAutoCompleteActive)return void this._doHideAutocomplete();if(this._doHideSearch())return;this.cursorSet.removeSecondaryCursors();const o=this.cursorSet.getPrimary().head;return this.cursorSet.set(o.line,o.col),void this._afterCursorMove()}switch(e.key){case"Backspace":return e.preventDefault(),void this._doBackspace(t);case"Delete":return e.preventDefault(),void this._doDelete(t);case"Enter":return e.preventDefault(),void this._doEnter(t);case"Tab":return e.preventDefault(),void this._doTab(s)}1!==e.key.length||t||(e.preventDefault(),this._doInsertChar(e.key))}_flushIfActionChanged(e){this._lastAction!==e&&(this.undoManager.flush(this.cursorSet.getCursorPositions()),this._lastAction=e)}_flushAction(){this.undoManager.flush(this.cursorSet.getCursorPositions()),this._lastAction=""}_doInsertChar(e){if(e in _t.PAIR_KEYS&&this.cursorSet.hasSelection())return void this._encloseSelection(e,_t.PAIR_KEYS[e]);this._flushIfActionChanged("insert"),this._deleteSelectionIfAny();const t=new Set;let s=!1;for(const i of this.cursorSet.sortedIndicesBottomUp()){const o=this.cursorSet.cursors[i],{line:n,col:a}=o.head,r=this.doc.getCharAt(n,a);if(this._wasPaired&&r===e){o.head={line:n,col:a+1},o.anchor={...o.head};continue}const l=this.doc.insert(n,a,e);this.undoManager.record(l,this.cursorSet.getCursorPositions());const c=e in _t.PAIR_KEYS&&(!r||/\s/.test(r)),h=c?2:1;if(c){const t=this.doc.insert(n,a+1,_t.PAIR_KEYS[e]);this.undoManager.record(t,this.cursorSet.getCursorPositions()),s=!0}o.head={line:n,col:a+1},o.anchor={...o.head},this.cursorSet.adjustOthers(i,n,a,h),t.add(n)}this._wasPaired=s;for(const e of t)this._updateLine(e);this._afterCursorMove(),/[\w$]/.test(e)?this._doOpenAutocomplete():this._doHideAutocomplete()}_getAffectedLines(){const e=this.cursorSet.getPrimary(),t=e.anchor.line,s=e.head.line;return t<=s?[t,s]:[s,t]}_commentLines(){const e=this.language.lineComment;if(!e)return;const[t,s]=this._getAffectedLines(),i=e+" ";let o=1/0;for(let e=t;e<=s;e++){0!==this.doc.getLine(e).trim().length&&(o=Math.min(o,this.doc.getIndent(e)))}o===1/0&&(o=0),this._flushAction();for(let e=t;e<=s;e++){if(0===this.doc.getLine(e).trim().length)continue;const t=this.doc.insert(e,o,i);this.undoManager.record(t,this.cursorSet.getCursorPositions()),this._updateLine(e)}this._afterCursorMove()}_uncommentLines(){const e=this.language.lineComment;if(!e)return;const[t,s]=this._getAffectedLines();this._flushAction();for(let i=t;i<=s;i++){const t=this.doc.getLine(i),s=this.doc.getIndent(i),o=t.substring(s);if(o.startsWith(e+" ")){const t=this.doc.delete(i,s,e.length+1);this.undoManager.record(t,this.cursorSet.getCursorPositions())}else if(o.startsWith(e)){const t=this.doc.delete(i,s,e.length);this.undoManager.record(t,this.cursorSet.getCursorPositions())}}this._rebuildLines(),this._afterCursorMove()}_doFindNextOcurrence(){const e=this.cursorSet.getPrimary();let t=this.cursorSet.getSelectedText(this.doc);if(!t){const{line:t,col:s}=e.head,[i,o,n]=this.doc.getWordAt(t,s);if(!i)return;return e.anchor={line:t,col:o},e.head={line:t,col:n},this._renderCursors(),void this._renderSelections()}const s=this.cursorSet.cursors[this.cursorSet.cursors.length-1],i=ut(s.anchor,s.head)?s.head:s.anchor,o=this.doc.findNext(t,i.line,i.col);if(!o)return;this.cursorSet.cursors.some(e=>{const t=ut(e.anchor,e.head)?e.anchor:e.head;return t.line===o.line&&t.col===o.col})||(this.cursorSet.cursors.push({anchor:{line:o.line,col:o.col},head:{line:o.line,col:o.col+t.length}}),this._renderCursors(),this._renderSelections(),this._scrollCursorIntoView())}_doOpenSearch(t=!1){if(!this.searchBox)return;this._doHideSearch(),e.LX.addClass(this.searchBox,"opened"),this._isSearchBoxActive=!0;const s=this.searchBox.querySelector("input");s&&(t?s.value="":this.cursorSet.hasSelection()&&(s.value=this.cursorSet.getSelectedText(this.doc)),s.selectionStart=0,s.selectionEnd=s.value.length,s.focus())}_doOpenLineSearch(){if(!this.searchLineBox)return;this._doHideSearch(),e.LX.emitSignal("@line-number-range",`Type a line number to go to (from 1 to ${this.doc.lineCount}).`),e.LX.addClass(this.searchLineBox,"opened"),this._isSearchLineBoxActive=!0;const t=this.searchLineBox.querySelector("input");t&&(t.value=":",t.focus())}_doHideSearch(){if(!this.searchBox||!this.searchLineBox)return!1;const e=this._isSearchBoxActive,t=this._isSearchLineBoxActive;return e?(this.searchBox.classList.remove("opened"),this._isSearchBoxActive=!1,this._lastSearchPos=null):t&&(this.searchLineBox.classList.remove("opened"),this._isSearchLineBoxActive=!1),e!=this._isSearchBoxActive||t!=this._isSearchLineBoxActive}_doSearch(e,t=!1,s,i=!0,o=!0){if(!(e=e??this._lastTextFound))return;const n=this.doc;let a,r;if(this._lastSearchPos)a=this._lastSearchPos.line,r=this._lastSearchPos.col+(t?-e.length:e.length);else{const e=this.cursorSet.getPrimary();a=e.head.line,r=e.head.col}const l=(s,i)=>{let o=n.getLine(s),a=e;if(this._searchMatchCase||(o=o.toLowerCase(),a=a.toLowerCase()),t){return o.substring(0,i).lastIndexOf(a)}return o.indexOf(a,i)};let c=-1,h=-1;if(t){for(let e=a;e>=0;e--){const t=l(e,e===a?r:n.getLine(e).length);if(t>-1){c=e,h=t;break}}if(-1===c)for(let e=n.lineCount-1;e>a;e--){const t=l(e,n.getLine(e).length);if(t>-1){c=e,h=t;break}}}else{for(let e=a;e<n.lineCount;e++){const t=l(e,e===a?r:0);if(t>-1){c=e,h=t;break}}if(-1===c)for(let e=0;e<a;e++){const t=l(e,0);if(t>-1){c=e,h=t;break}}}if(-1===c)return i||alert("No results!"),void(this._lastSearchPos=null);if(this._lastTextFound=e,this._lastSearchPos={line:c,col:h},s)s(h,c);else{const t=this.cursorSet.getPrimary();t.anchor={line:c,col:h},t.head={line:c,col:h+e.length},this._renderCursors(),this._renderSelections()}if(this.codeScroller.scrollTop=Math.max((c-10)*this.lineHeight,0),this.codeScroller.scrollLeft=Math.max(h*this.charWidth-this.codeScroller.clientWidth/2,0),o){const e=this.searchBox?.querySelector("input");e?.focus()}}_doGotoLine(e){Number.isNaN(e)||e<1||e>this.doc.lineCount||(this.cursorSet.set(e-1,0),this._afterCursorMove())}_encloseSelection(e,t){const s=this.cursorSet.getPrimary(),i=s.anchor,o=s.head,n=i.line<o.line||i.line===o.line&&i.col<o.col?i:o,a=n===i?o:i;if(n.line!==a.line)return;const r=n.line,l=n.col,c=a.col;this._flushAction();const h=this.doc.insert(r,l,e);this.undoManager.record(h,this.cursorSet.getCursorPositions());const d=this.doc.insert(r,c+1,t);this.undoManager.record(d,this.cursorSet.getCursorPositions()),s.anchor={line:r,col:l+1},s.head={line:r,col:c+1},this._updateLine(r),this._afterCursorMove()}_doBackspace(e){if(this._flushIfActionChanged("backspace"),this.cursorSet.hasSelection())return this._deleteSelectionIfAny(),this._rebuildLines(),void this._afterCursorMove();for(const t of this.cursorSet.sortedIndicesBottomUp()){const s=this.cursorSet.cursors[t],{line:i,col:o}=s.head;if(0!==i||0!==o)if(0===o){const e=this.doc.getLine(i-1).length,o=this.doc.delete(i-1,e,1);this.undoManager.record(o,this.cursorSet.getCursorPositions()),s.head={line:i-1,col:e},s.anchor={...s.head},this.cursorSet.adjustOthers(t,i,0,e,-1)}else if(e){const[e,n]=this.doc.getWordAt(i,o-1),a=e.length>0?n:o-1,r=o-a,l=this.doc.delete(i,a,r);this.undoManager.record(l,this.cursorSet.getCursorPositions()),s.head={line:i,col:a},s.anchor={...s.head},this.cursorSet.adjustOthers(t,i,o,-r)}else{const e=this.doc.delete(i,o-1,1);this.undoManager.record(e,this.cursorSet.getCursorPositions()),s.head={line:i,col:o-1},s.anchor={...s.head},this.cursorSet.adjustOthers(t,i,o,-1)}}this._rebuildLines(),this._afterCursorMove(),this._doOpenAutocomplete()}_doDelete(e){if(this.cursorSet.hasSelection())return this._deleteSelectionIfAny(),this._rebuildLines(),void this._afterCursorMove();this._flushIfActionChanged("delete");for(const t of this.cursorSet.sortedIndicesBottomUp()){const s=this.cursorSet.cursors[t],{line:i,col:o}=s.head,n=this.doc.getLine(i);if(!(o>=n.length&&i>=this.doc.lineCount-1))if(o>=n.length){const e=this.doc.delete(i,o,1);this.undoManager.record(e,this.cursorSet.getCursorPositions()),this.cursorSet.adjustOthers(t,i,o,0,-1)}else if(e){const[e,,s]=this.doc.getWordAt(i,o),n=e.length>0?s-o:1,a=this.doc.delete(i,o,n);this.undoManager.record(a,this.cursorSet.getCursorPositions()),this.cursorSet.adjustOthers(t,i,o,-n)}else{const e=this.doc.delete(i,o,1);this.undoManager.record(e,this.cursorSet.getCursorPositions()),this.cursorSet.adjustOthers(t,i,o,-1)}}this._rebuildLines(),this._afterCursorMove()}_doEnter(e){if(this._isAutoCompleteActive)this._doAutocompleteWord();else if(e&&this.onRun)this.onRun(this.getText(),this);else{this._deleteSelectionIfAny(),this._flushAction();for(const e of this.cursorSet.sortedIndicesBottomUp()){const t=this.cursorSet.cursors[e],{line:s,col:i}=t.head,o=this.doc.getIndent(s),n=" ".repeat(o),a=this.doc.getCharAt(s,i-1),r=this.doc.getCharAt(s,i);if(a&&r&&{"{":"}","[":"]","(":")"}[a]===r){const a="\n"+" ".repeat(o+this.tabSize)+"\n"+n,r=this.doc.insert(s,i,a);this.undoManager.record(r,this.cursorSet.getCursorPositions()),t.head={line:s+1,col:o+this.tabSize},t.anchor={...t.head},this.cursorSet.adjustOthers(e,s,i,0,2)}else{const a=this.doc.insert(s,i,"\n"+n);this.undoManager.record(a,this.cursorSet.getCursorPositions()),t.head={line:s+1,col:o},t.anchor={...t.head},this.cursorSet.adjustOthers(e,s,i,0,1)}}this._rebuildLines(),this._afterCursorMove()}}_doTab(e){if(this._isAutoCompleteActive)this._doAutocompleteWord();else{this._flushAction();for(const t of this.cursorSet.sortedIndicesBottomUp()){const s=this.cursorSet.cursors[t],{line:i,col:o}=s.head,n=s.anchor.line,a=Math.min(i,n),r=Math.max(i,n);if(a!==r){for(let t=a;t<=r;t++)if(e){const e=this.doc.getLine(t);let s=0;for(;s<this.tabSize&&s<e.length&&" "===e[s];)s++;if(s>0){const e=this.doc.delete(t,0,s);this.undoManager.record(e,this.cursorSet.getCursorPositions())}}else{const e=" ".repeat(this.tabSize),s=this.doc.insert(t,0,e);this.undoManager.record(s,this.cursorSet.getCursorPositions())}const t=e?-this.tabSize:this.tabSize;s.head={line:i,col:Math.max(0,o+t)},s.anchor={line:n,col:Math.max(0,s.anchor.col+t)}}else if(e){const e=this.doc.getLine(i);let n=0;for(;n<this.tabSize&&n<e.length&&" "===e[n];)n++;if(n>0){const e=this.doc.delete(i,0,n);this.undoManager.record(e,this.cursorSet.getCursorPositions()),s.head={line:i,col:Math.max(0,o-n)},s.anchor={...s.head},this.cursorSet.adjustOthers(t,i,0,-n)}}else{const e=this.tabSize-o%this.tabSize,n=" ".repeat(e),a=this.doc.insert(i,o,n);this.undoManager.record(a,this.cursorSet.getCursorPositions()),s.head={line:i,col:o+e},s.anchor={...s.head},this.cursorSet.adjustOthers(t,i,o,e)}}this._rebuildLines(),this._afterCursorMove()}}_deleteSelectionIfAny(){let e=!1;for(const t of this.cursorSet.sortedIndicesBottomUp()){const s=this.cursorSet.cursors[t];if(gt(s))continue;const i=pt(s),o=mt(s),n=this.cursorSet.getSelectedText(this.doc,t);if(!n)continue;const a=o.line-i.line,r=0===a?o.col-i.col:i.col,l=this.doc.delete(i.line,i.col,n.length);this.undoManager.record(l,this.cursorSet.getCursorPositions()),s.head={...i},s.anchor={...i},this.cursorSet.adjustOthers(t,i.line,i.col,-r,-a),e=!0}e&&(this._rebuildLines(),this._doHideAutocomplete())}_doCopy(){const e=this.cursorSet.getSelectedText(this.doc);e&&navigator.clipboard.writeText(e)}_doCut(){this._flushAction();const e=this.cursorSet.getSelectedText(this.doc);if(e)navigator.clipboard.writeText(e),this._deleteSelectionIfAny();else{const e=this.cursorSet.getPrimary(),t=e.head.line,s=this.doc.getLine(t),i=t===this.doc.lineCount-1;navigator.clipboard.writeText(s+(i?"":"\n"));const o=this.doc.removeLine(t);this.undoManager.record(o,this.cursorSet.getCursorPositions());const n=Math.min(t,this.doc.lineCount-1);e.head={line:n,col:0},e.anchor={...e.head}}this._rebuildLines(),this._afterCursorMove()}_swapLine(e){const t=this.cursorSet.getPrimary(),s=t.head.line,i=s+e;if(i<0||i>=this.doc.lineCount)return;const o=this.doc.getLine(s),n=this.doc.getLine(i);this._flushAction();const a=this.doc.replaceLine(s,n);this.undoManager.record(a,this.cursorSet.getCursorPositions());const r=this.doc.replaceLine(i,o);this.undoManager.record(r,this.cursorSet.getCursorPositions()),t.head={line:i,col:t.head.col},t.anchor={...t.head},this._rebuildLines(),this._afterCursorMove()}_duplicateLine(e){const t=this.cursorSet.getPrimary(),s=t.head.line,i=this.doc.getLine(s);this._flushAction();const o=this.doc.insertLine(s,i);this.undoManager.record(o,this.cursorSet.getCursorPositions());const n=1===e?s+1:s;t.head={line:n,col:t.head.col},t.anchor={...t.head},this._rebuildLines(),this._afterCursorMove()}_normalizeText(e){return e.replace(/\r\n?/g,"\n").replace(/\t/g," ".repeat(this.tabSize))}async _doPaste(){const e=await navigator.clipboard.readText();if(!e)return;const t=this._normalizeText(e);this._flushAction(),this._deleteSelectionIfAny();const s=this.cursorSet.getPrimary(),i=this.doc.insert(s.head.line,s.head.col,t);this.undoManager.record(i,this.cursorSet.getCursorPositions());const o=t.split("\n");1===o.length?this.cursorSet.set(s.head.line,s.head.col+t.length):this.cursorSet.set(s.head.line+o.length-1,o[o.length-1].length),this._rebuildLines(),this._afterCursorMove()}_doUndo(){const e=this.undoManager.undo(this.doc,this.cursorSet.getCursorPositions());if(e){if(e.cursors.length>0){const t=e.cursors[0];this.cursorSet.set(t.line,t.col)}this._rebuildLines(),this._afterCursorMove()}}_doRedo(){const e=this.undoManager.redo(this.doc);if(e){if(e.cursors.length>0){const t=e.cursors[0];this.cursorSet.set(t.line,t.col)}this._rebuildLines(),this._afterCursorMove()}}_onMouseDown(t){if(!this.currentTab)return;if(this.searchBox&&this.searchBox.contains(t.target))return;if(this.autocomplete&&this.autocomplete.contains(t.target))return;if(t.ctrlKey&&0===t.button){const e=t.target.closest(".code-link");if(e?.dataset.url)return void window.open(e.dataset.url,"_blank")}t.preventDefault(),this._wasPaired=!1;const s=this.codeContainer.getBoundingClientRect(),i=t.clientX-s.left-this.xPadding,o=t.clientY-s.top,n=e.LX.clamp(Math.floor(o/this.lineHeight),0,this.doc.lineCount-1),a=e.LX.clamp(Math.round(i/this.charWidth),0,this.doc.getLine(n).length);if("contextmenu"===t.type)return void this._onContextMenu(t,n,a);if(0!==t.button)return;const r=Date.now();if(r-this._lastClickTime<400&&n===this._lastClickLine?this._clickCount=Math.min(this._clickCount+1,3):this._clickCount=1,this._lastClickTime=r,this._lastClickLine=n,3===this._clickCount){const e=this.cursorSet.getPrimary();e.anchor={line:n,col:0},e.head={line:n,col:this.doc.getLine(n).length}}else if(2===this._clickCount){const[,e,t]=this.doc.getWordAt(n,a),s=this.cursorSet.getPrimary();s.anchor={line:n,col:e},s.head={line:n,col:t}}else if(t.shiftKey){this.cursorSet.getPrimary().head={line:n,col:a}}else this.cursorSet.set(n,a);this._afterCursorMove(),this._inputArea.focus();const l=e=>{const t=e.clientX-s.left-this.xPadding,i=e.clientY-s.top,o=Math.max(0,Math.min(Math.floor(i/this.lineHeight),this.doc.lineCount-1)),n=Math.max(0,Math.min(Math.round(t/this.charWidth),this.doc.getLine(o).length));this.cursorSet.getPrimary().head={line:o,col:n},this._renderCursors(),this._renderSelections()},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}_onContextMenu(t,s,i){t.preventDefault();const o=[{name:"Copy",icon:"Copy",callback:()=>this._doCopy(),kbd:["Ctrl","C"],useKbdSpecialKeys:!1}];if(this.disableEdition||(o.push({name:"Cut",icon:"Scissors",callback:()=>this._doCut(),kbd:["Ctrl","X"],useKbdSpecialKeys:!1}),o.push({name:"Paste",icon:"Paste",callback:()=>this._doPaste(),kbd:["Ctrl","V"],useKbdSpecialKeys:!1})),this.onContextMenu){const e=this.cursorSet.getSelectedText(this.doc),s=this.onContextMenu(this,e,t);if(s?.length){o.push(null);for(const e of s)o.push({name:e.path,disabled:e.disabled,callback:e.callback})}}e.LX.addDropdownMenu(t.target,o,{event:t,side:"bottom",align:"start"})}_getWordAtCursor(){const e=this.cursorSet.getPrimary().head,t=this.doc.getLine(e.line);let s=e.col,i=e.col;for(;s>0&&/[\w$]/.test(t[s-1]);)s--;for(;i<t.length&&/[\w$]/.test(t[i]);)i++;return{word:t.slice(s,i),start:s,end:i}}_doOpenAutocomplete(){if(!this.autocomplete||!this.useAutoComplete)return;this.autocomplete.innerHTML="";const{word:t}=this._getWordAtCursor();if(!t||0===t.length)return void this._doHideAutocomplete();const s=[],i=new Set,o=e=>{i.has(e.label)||(s.push(e),i.add(e.label))},n=(e,t)=>{const s=t.toLowerCase();return e.filterText?e.filterText.split(" ").some(e=>e.toLowerCase().trim().startsWith(s)):e.label.toLowerCase().startsWith(s)},a=this.symbolTable.getAllSymbols();for(const e of a){const s={label:e.name,kind:e.kind,scope:e.scope,detail:`${e.kind} in ${e.scope}`};n(s,t)&&o(s)}for(const e of this.language.reservedWords){const s={label:e};n(s,t)&&o(s)}for(const e of this.customSuggestions)n(e,t)&&o(e);if(0===s.length)return void this._doHideAutocomplete();const r=t.toLowerCase();s.sort((e,t)=>{const s=(e.sortText??e.label).toLowerCase(),i=(t.sortText??t.label).toLowerCase(),o=s===r?0:1,n=i===r?0:1;return o!==n?o-n:s.localeCompare(i)}),this._selectedAutocompleteIndex=0,s.forEach((s,i)=>{const o=document.createElement("pre");o.insertText=s.insertText??s.label,i===this._selectedAutocompleteIndex&&o.classList.add("selected");const n=s.label;let a=s.icon??"CaseLower",r=s.iconClass??"text-gray-500";switch(s.kind){case"class":a="CircleNodes",r="text-orange-500";break;case"struct":a="Form",r="text-orange-400";break;case"interface":a="FileType",r="text-cyan-500";break;case"enum":a="ListTree",r="text-yellow-500";break;case"enum-value":a="Dot",r="text-yellow-400";break;case"type":a="Type",r="text-teal-500";break;case"function":a="Function",r="text-purple-500";break;case"method":a="Box",r="text-fuchsia-500";break;case"variable":a="Cuboid",r="text-blue-400";break;case"property":a="Layers",r="text-blue-300";break;case"constructor-call":a="Hammer",r="text-green-500";break;case"method-call":a="Parentheses",r="text-gray-400"}o.appendChild(e.LX.makeIcon(a,{iconClass:"ml-1 mr-2",svgClass:"sm "+r}));const l=n.toLowerCase().indexOf(t.toLowerCase());var c=document.createElement("span");c.textContent=n.substring(0,l),o.appendChild(c);var h=document.createElement("span");h.textContent=n.substring(l,l+t.length),h.classList.add("word-highlight"),o.appendChild(h);var d=document.createElement("span");if(d.textContent=n.substring(l+t.length),o.appendChild(d),s.kind){const e=document.createElement("span");e.textContent=` (${s.kind})`,e.className="kind text-muted-foreground text-xs! ml-2",o.appendChild(e)}o.addEventListener("click",()=>{this._doAutocompleteWord()}),this.autocomplete.appendChild(o)}),this._isAutoCompleteActive=!0;const l=e=>{this.autocomplete?.contains(e.target)||this._doHideAutocomplete()};setTimeout(()=>document.addEventListener("click",l,{once:!0}),0),this.autocomplete._cleanup=()=>{document.removeEventListener("click",l)},this.autocomplete.classList.toggle("show",!0),this.autocomplete.classList.toggle("no-scrollbar",!(this.autocomplete.scrollHeight>this.autocomplete.offsetHeight));const c=this.cursorSet.getPrimary().head,h=c.col*this.charWidth+this.xPadding,d=(c.line+1)*this.lineHeight+this._cachedTabsHeight-this.codeScroller.scrollTop;this.autocomplete.style.left=h+"px",this.autocomplete.style.top=d+"px"}_doHideAutocomplete(){this.autocomplete&&this._isAutoCompleteActive&&(this.autocomplete.innerHTML="",this.autocomplete.classList.remove("show"),this._isAutoCompleteActive=!1,this.autocomplete._cleanup&&(this.autocomplete._cleanup(),delete this.autocomplete._cleanup))}_doAutocompleteWord(){const e=this._getSelectedAutoCompleteWord();if(!e)return;const t=this.cursorSet.getPrimary().head,{start:s,end:i}=this._getWordAtCursor(),o=t.line,n=this.cursorSet.getCursorPositions();if(i>s){const e=this.doc.delete(o,s,i-s);this.undoManager.record(e,n)}const a=this.doc.insert(o,s,e),r=e.split(/\r?\n/);1===r.length?this.cursorSet.set(o,s+e.length):this.cursorSet.set(o+r.length-1,r[r.length-1].length);const l=this.cursorSet.getCursorPositions();this.undoManager.record(a,l),this._rebuildLines(),this._afterCursorMove(),this._doHideAutocomplete()}_getSelectedAutoCompleteWord(){if(!this.autocomplete||!this._isAutoCompleteActive)return null;return this.autocomplete.childNodes[this._selectedAutocompleteIndex].insertText}_afterCursorMove(){this._renderCursors(),this._renderSelections(),this._resetBlinker(),this.resize(),this._scrollCursorIntoView(),this._updateBracketHighlight()}_getScopeAtCursor(){const e=this.cursorSet.getPrimary().head,t=e.line,s=e.col,i=this.doc.getLine(t),o=[...this.symbolTable.getScopeAtLine(t)];let n=0,a=!1,r="";for(;n<s&&n<i.length;){const e=i[n];if(a){if("\\"===e){n+=2;continue}e===r&&(a=!1),n++}else{if("/"===e&&"/"===i[n+1])break;if("/"!==e||"*"!==i[n+1])'"'!==e&&"'"!==e&&"`"!==e?("{"===e?o.push({name:"anonymous",type:"anonymous",line:t}):"}"===e&&o.length>1&&o.pop(),n++):(a=!0,r=e,n++);else{for(n+=2;n<s&&("*"!==i[n]||"/"!==i[n+1]);)n++;n+=2}}}return o}_updateBracketHighlight(){const e=this._getScopeAtCursor();let t=null;for(let s=e.length-1;s>=0;s--)if("global"!==e[s].type){t=e[s];break}const s=this._bracketOpenLine,i=this._bracketCloseLine;if(t){const s=t.line,i=e.length;let o=s;for(let e=s+1;e<this.doc.lineCount&&this.symbolTable.getScopeAtLine(e).length>=i;e++)o=e;this._bracketOpenLine=s,this._bracketCloseLine=o}else this._bracketOpenLine=-1,this._bracketCloseLine=-1;const o=new Set;s!==this._bracketOpenLine&&(o.add(s),o.add(this._bracketOpenLine)),i!==this._bracketCloseLine&&(o.add(i),o.add(this._bracketCloseLine));for(const e of o)e>=0&&e<this.doc.lineCount&&this._updateLine(e)}_onColorSwatchClick(t){const s=t.target.closest(".code-color");if(!s)return;t.stopPropagation(),t.preventDefault();const i=s.dataset.color,o=parseInt(s.dataset.line),n=parseInt(s.dataset.col);let a=i.length;this._colorPopover&&(this._colorPopover.destroy(),this._colorPopover=null);const r=new e.LX.ColorPicker(i,{colorModel:"Hex",onChange:e=>{const t=e.hex.replace(/^#/,""),i=a-1,r="#"+(i<=4?t.slice(0,i).padEnd(i,"0"):t.slice(0,Math.min(i,8)).padEnd(i,"0"));if(this.doc.getLine(o).slice(n,n+a)!==s.dataset.color)return;const l=this.doc.delete(o,n,a);this.undoManager.record(l,this.cursorSet.getCursorPositions());const c=this.doc.insert(o,n,r);this.undoManager.record(c,this.cursorSet.getCursorPositions()),this._updateLine(o),a=r.length,s.dataset.color=r,s.dataset.col=String(n),s.style.setProperty("--code-color",r)}});this._colorPopover=new e.LX.Popover(s,[r],{side:"bottom",align:"start",sideOffset:4})}_getSymbolParams(e){if(e<0||e>=this.doc.lineCount)return"()";const t=this.doc.getLine(e).match(/\(([^)]*)\)/);return t?`(${t[1].trim()})`:"()"}_findConstructorParams(e){const t=this.symbolTable.getScopeAtLine(e).length,s=Math.min(e+50,this.doc.lineCount);for(let i=e+1;i<s&&!(this.symbolTable.getScopeAtLine(i).length<t+1);i++){const e=this.doc.getLine(i).match(/\bconstructor\s*\(([^)]*)\)/);if(e)return`(${e[1].trim()})`}return null}_pickBestSymbol(e,t,s,i,o){if(1===e.length)return e[0];const n=this.symbolTable.getScopeAtLine(o),a=[...n].reverse().find(e=>"global"!==e.type)?.name??"global",r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=new RegExp(`\\bnew\\s+${r}\\b`).test(i),c=new RegExp(`\\b${r}\\s*[(<]`).test(i),h=new RegExp(`(?::\\s*|<\\s*|[,>]\\s*)${r}\\b`).test(i),d=new Set(["class","interface","type","enum","struct"]),u=new Set(["function","method"]),p=e.map(e=>{let t=0;if(e.scope===a&&(t+=5),"method"===s&&u.has(e.kind)&&(t+=3),"type"===s&&d.has(e.kind)&&(t+=3),l&&"constructor-call"===e.kind&&(t+=20),l&&"class"===e.kind&&(t+=3),c&&u.has(e.kind)&&(t+=3),h&&d.has(e.kind)&&(t+=2),e.line>=0&&e.line<this.doc.lineCount){const s=this.doc.getLine(e.line);/\bfunction\b/.test(s)&&u.has(e.kind)&&(t+=4),/\bclass\b/.test(s)&&"class"===e.kind&&(t+=4),/\binterface\b/.test(s)&&"interface"===e.kind&&(t+=4),/\btype\b/.test(s)&&"type"===e.kind&&(t+=4),/\benum\b/.test(s)&&"enum"===e.kind&&(t+=4),/\b(?:const|let|var)\b/.test(s)&&"variable"===e.kind&&(t+=3)}const i=Math.abs(e.line-o);return t+=Math.max(0,4-Math.floor(i/20)),{sym:e,score:t}});return p.sort((e,t)=>t.score-e.score),p[0].sym}_clearHoverPopup(){this._hoverTimer&&(clearTimeout(this._hoverTimer),this._hoverTimer=null),this._hoverPopup&&(this._hoverPopup.remove(),this._hoverPopup=null),this._hoverWord=""}_onCodeAreaMouseMove(t){if(0!==t.buttons)return void this._clearHoverPopup();const s=this.codeContainer.getBoundingClientRect(),i=t.clientX-s.left-this.xPadding,o=t.clientY-s.top,n=e.LX.clamp(Math.floor(o/this.lineHeight),0,this.doc.lineCount-1),a=e.LX.clamp(Math.round(i/this.charWidth),0,this.doc.getLine(n).length),[r,l]=this.doc.getWordAt(n,a);r&&r!==this._hoverWord&&(this._clearHoverPopup(),r.trim()&&(this._hoverWord=r,this._hoverTimer=setTimeout(()=>{this._hoverTimer=null;const t=n>0?this._lineStates[n-1]??xe.initialState():xe.initialState(),{tokens:s}=xe.tokenizeLine(this.doc.getLine(n),this.language,t);let i="text",o=0;for(const e of s){if(l>=o&&l<o+e.value.length){i=e.type;break}o+=e.value.length}if("comment"===i||"string"===i||"number"===i)return;const c=this.symbolTable.getSymbols(r),h={word:r,tokenType:i,symbols:c};let d;if(this.onHoverSymbol&&(d=this.onHoverSymbol(h,this)),null===d)return;const u=c.length>0;if(!d&&!u)return;const p=this._hoverPopup=e.LX.makeElement("div","code-hover-popup [&_span]:text-sm");if(d)"string"==typeof d?p.innerHTML=d:p.appendChild(d);else{const e=this._pickBestSymbol(c,r,i,this.doc.getLine(n),n);let t=e.kind,s=`<span class="font-semibold">${r}</span>`;if("constructor-call"===e.kind){const e=this.symbolTable.getSymbols(r).find(e=>"class"===e.kind);t="constructor",s=`${s}<span class="text-muted-foreground">${null!=e?this._findConstructorParams(e.line)??"()":"()"}</span>`}else if("function"===e.kind){s=`${s}<span class="text-muted-foreground">${this._getSymbolParams(e.line)}</span>`}else if(e.scope&&"global"!==e.scope&&"anonymous"!==e.scope)if("property"===e.kind||"method"===e.kind){const t=`<span class="text-muted-foreground">${e.scope}.</span>`;if("method"===e.kind){s=`${t}${s}<span class="text-muted-foreground">${this._getSymbolParams(e.line)}</span>`}else s=`${t}${s}`}else if("variable"===e.kind){const t=this.symbolTable.getScopeAtLine(e.line).find(t=>t.name===e.scope),i=new Set(["class","interface","struct"]);t&&i.has(t.type)&&(s=`<span class="text-muted-foreground">${e.scope}.</span>${s}`)}p.innerHTML=`<span class="text-info">(${t})</span> ${s}`}document.body.appendChild(p);const m=this._lineElements[n];if(m){const e=m.getBoundingClientRect(),t=e.left+this.xPadding+a*this.charWidth,s=e.bottom+4;p.style.left=Math.min(t,window.innerWidth-p.offsetWidth-8)+"px",p.style.top=s+"px"}},500)))}_scrollCursorIntoView(){const e=this.cursorSet.getPrimary().head,t=e.line*this.lineHeight,s=e.col*this.charWidth;t<this.codeScroller.scrollTop?this.codeScroller.scrollTop=t:t+this.lineHeight>this.codeScroller.scrollTop+this.codeScroller.clientHeight&&(this.codeScroller.scrollTop=t+this.lineHeight-this.codeScroller.clientHeight);const i=2*xt.SIZE;s<this.codeScroller.scrollLeft?this.codeScroller.scrollLeft=s:s+i>this.codeScroller.scrollLeft+this.codeScroller.clientWidth-this.xPadding&&(this.codeScroller.scrollLeft=s+i-this.codeScroller.clientWidth+this.xPadding)}_resetGutter(){const e=this._cachedTabsHeight||(this.tabs?.root.getBoundingClientRect().height??0),t=this._cachedStatusPanelHeight||(this.statusPanel?.root.getBoundingClientRect().height??0);this.lineGutter.style.height=`calc(100% - ${e+t}px)`}getMaxLineLength(){if(!this.currentTab)return 0;let e=0;for(let t=0;t<this.doc.lineCount;t++){const s=this.doc.getLine(t).length;s>e&&(e=s)}return e}resize(e=!1){if(!this.charWidth)return;this._cachedTabsHeight=this.tabs?.root.getBoundingClientRect().height??0,this._cachedStatusPanelHeight=this.statusPanel?.root.getBoundingClientRect().height??0;const t=this.getMaxLineLength(),s=this.currentTab?this.doc.lineCount:0,i=Math.floor((this.codeScroller.clientWidth-this.xPadding)/this.charWidth),o=Math.floor(this.codeScroller.clientHeight/this.lineHeight);let n=t!==this._lastMaxLineLength&&(t>=i||this._lastMaxLineLength>=i),a=s!==this._lastLineCount&&(s>=o||this._lastLineCount>=o);n=n||t<i&&this.hScrollbar?.visible,a=a||s<o&&this.vScrollbar?.visible,(e||n||a)&&(this._lastMaxLineLength=t,this._lastLineCount=s,(e||n)&&(this.codeSizer.style.minWidth=t*this.charWidth+this.xPadding+2*xt.SIZE+"px"),(e||a)&&(this.codeSizer.style.minHeight=s*this.lineHeight+2*xt.SIZE+"px"),this._resetGutter(),setTimeout(()=>this._resizeScrollBars(),10))}_resizeScrollBars(){if(!this.vScrollbar)return;const e=this._cachedTabsHeight,t=this._cachedStatusPanelHeight,s=this.codeScroller.scrollHeight;this.vScrollbar.setThumbRatio(s>0?this.codeScroller.clientHeight/s:1),this.vScrollbar.root.style.top=e+"px",this.vScrollbar.root.style.height=`calc(100% - ${e+t}px)`;const i=this.codeScroller.scrollWidth;this.hScrollbar.setThumbRatio(i>0?this.codeScroller.clientWidth/i:1),this.hScrollbar.root.style.bottom=t+"px",this.hScrollbar.root.style.width=`calc(100% - ${this.xPadding+(this.vScrollbar.visible?xt.SIZE:0)}px)`}_syncScrollBars(){this.vScrollbar&&(this.vScrollbar.syncToScroll(this.codeScroller.scrollTop,this.codeScroller.scrollHeight-this.codeScroller.clientHeight),this.hScrollbar.syncToScroll(this.codeScroller.scrollLeft,this.codeScroller.scrollWidth-this.codeScroller.clientWidth))}_doLoadFromFile(){const t=e.LX.makeElement("input","","",document.body);t.type="file",t.click(),t.addEventListener("change",e=>{const s=e.target;s.files&&s.files[0]&&this.loadFile(s.files[0]),t.remove()})}async _setFontSize(t,s=!0){this.fontSize=t;const i=document.querySelector(":root");i.style.setProperty("--code-editor-font-size",`${this.fontSize}px`),window.localStorage.setItem("lexcodeeditor-font-size",`${this.fontSize}`),await this._measureChar();const o=this.fontSize+6;i.style.setProperty("--code-editor-row-height",`${o}px`),this.lineHeight=o,s&&(this._rebuildLines(),this._afterCursorMove()),e.LX.emitSignal("@font-size",this.fontSize)}_applyFontSizeOffset(t=0){const s=e.LX.clamp(this.fontSize+t,_t.CODE_MIN_FONT_SIZE,_t.CODE_MAX_FONT_SIZE);this._setFontSize(s)}_increaseFontSize(){this._applyFontSizeOffset(1)}_decreaseFontSize(){this._applyFontSizeOffset(-1)}}if(e.LX.CodeEditor=_t,e.LX.init=async function(t={}){if(this.ready)return this.mainArea;await e.LX.loadScriptSync("https://unpkg.com/lucide@latest"),console.log(`LexGUI v${this.version}`);const s=e.LX.makeElement("div",e.LX.mergeClass("lexcontainer",t.rootClass));function i(e){e.preventDefault(),e.stopPropagation()}s.id="lexroot",s.tabIndex=-1,this.modal=e.LX.makeElement("div","inset-0 hidden-opacity bg-black/50 fixed z-100 transition-opacity duration-100 ease-in"),this.modal.id="modal",this.modal.toggle=function(e){this.classList.toggle("hidden-opacity",e)},this.modal.addEventListener("wheel",i,{passive:!1}),this.modal.addEventListener("touchmove",i,{passive:!1}),this.root=s,this.container=document.body,t.container&&(this.container=t.container.constructor===String?document.getElementById(t.container):t.container),this.layoutMode=t.layoutMode??"app",document.documentElement.setAttribute("data-layout",this.layoutMode),this.layoutMode,this.spacingMode=t.spacingMode??"default",document.documentElement.setAttribute("data-spacing",this.spacingMode),this.container.appendChild(this.modal),t.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="fixed flex flex-col-reverse m-0 p-0 gap-1 z-1000",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),t.skipRoot||t.skipDefaultArea||(this.mainArea=new te({id:t.id??"mainarea"})),this._onChangeSystemTheme=function(t){localStorage.getItem("lxColorScheme")||e.LX.setMode(t.matches?"dark":"light",!1)},this._mqlPrefersDarkScheme=window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)"):null;const o=localStorage.getItem("lxColorScheme");return o?e.LX.setMode(o):this._mqlPrefersDarkScheme&&(t.autoTheme??1)&&(window.matchMedia("(prefers-color-scheme: light)").matches&&e.LX.setMode("light",!1),this._mqlPrefersDarkScheme.addEventListener("change",this._onChangeSystemTheme)),this.mainArea},e.LX.setSpacingMode=function(e){this.spacingMode=e,document.documentElement.setAttribute("data-spacing",this.spacingMode)},e.LX.setLayoutMode=function(e){this.layoutMode=e,document.documentElement.setAttribute("data-layout",this.layoutMode)},e.LX.addSignal=function(t,s,i){s[t]=i,e.LX.signals[t]||(e.LX.signals[t]=[]),e.LX.signals[t].indexOf(s)>-1||e.LX.signals[t].push(s)},e.LX.removeSignal=function(t,s){const i=e.LX.signals[t];if(i)if(s){for(let e=0;e<i.length;++e)if(i[e]==s){i.splice(e,1);break}}else delete e.LX.signals[t]},e.LX.emitSignal=function(t,s,i={}){const o=e.LX.signals[t];if(!o)return;const a=i.target;if(a)a[t]&&a[t].call(a,s);else for(let e of o)if(e instanceof n)e.set(s,i.skipCallback??!0);else if(e.constructor===Function){e(null,s)}else{const i=e[t];console.assert(i,`No callback registered with _${t}_ signal`),i.bind(e)(s)}},e.LX._createCommandbar=function(t){let s=document.createElement("dialog");s.className="commandbar absolute border-color rounded-lg m-0",s.tabIndex=-1,t.appendChild(s);let i=[],o=null;s.addEventListener("keydown",function(e){if(e.stopPropagation(),e.stopImmediatePropagation(),o=o??-1,"Escape"==e.key)s.close(),d(!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)-l.offsetHeight;t>0&&l.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(t){t.relatedTarget!=t.currentTarget&&(t.stopPropagation(),t.stopImmediatePropagation(),e.LX.setCommandbarState(!1),d(!0))}),t.addEventListener("keydown",t=>{if(" "==t.key&&t.ctrlKey)t.stopImmediatePropagation(),t.stopPropagation(),e.LX.setCommandbarState(!0);else for(let s of e.LX.extensions){if(!e.LX[s]||!e.LX[s].prototype.onKeyPressed)continue;const i=e.LX.CodeEditor.getInstances();for(let e of i)e.onKeyPressed(t)}});const n=e.LX.makeContainer(["100%","auto"],"flex flex-row"),a=new h(null,"",e=>{s._addElements(e.toLowerCase())},{width:"100%",icon:"Search",trigger:"input",placeholder:"Search..."});n.appendChild(a.root);const r=new te({width:"100%",skipAppend:!0,className:"cb-tabs"});{const e=(e,t)=>{};r.addTabs({parentClass:"p-2"}).add("All",document.createElement("div"),{selected:!0,onSelect:e})}const l=e.LX.makeElement("div","searchitembox overflow-y-scroll basis-full scrollbar-hidden");let c=null;const d=e=>{l.innerHTML="",i.length=0,o=null,e&&a.set("",!0)},u=function(t,s){if(!s?.length)return!1;return e.LX.stripTags(t).toLowerCase().includes(s.toLowerCase())},p=(t,n,a)=>{if(!t||t.constructor!=Object)return;t.callback&&((t,n,a,r)=>{if(!t.length)return;c&&c.classList.remove("last");let h=document.createElement("div");if(h.className="searchitem last",void 0!==r?.checked){const s=r.checked?e.LX.makeIcon("Check").innerHTML:"";h.innerHTML=s+(a+t)}else h.innerHTML=a+t;h.callback=n,h.item=r,h.addEventListener("click",s=>{null!=r.checked&&(r.checked=!r.checked),n.call(window,t,r.checked),e.LX.setCommandbarState(!1),d(!0)}),h.addEventListener("mouseenter",function(e){s.querySelectorAll(".hovered").forEach(e=>e.classList.remove("hovered")),h.classList.add("hovered"),o=i.indexOf(h)}),h.addEventListener("mouseleave",function(e){h.classList.remove("hovered")}),i.push(h),l.appendChild(h),c=h})(t.name,t.callback,n,t);const r=t.submenu??t[t.name];if(!r)return;const h=e.LX.makeIcon("ChevronRight",{svgClass:"sm text-muted-foreground separator"});n+=t.name+h.innerHTML;for(let e of r)p(e,n)};return s._addElements=t=>{d();let s=function(t){const s=[];for(let i of e.LX.menubars)for(let e of i.items)u(e.name,t)&&s.push(e);for(let i of e.LX.sidebars)for(let e of i.items)u(e.name,t)&&s.push(e);for(let i of e.LX.extraCommandbarEntries)u(i.name,t)&&s.push(i);if(e.LX.has("CodeEditor")){const i=e.LX.CodeEditor.getInstances();if(!i.length||!i[0].area.root.offsetHeight)return s;for(let o of e.LX.Tokenizer.getRegisteredLanguages()){const n=xe.getLanguage(o);if(!n)continue;const a="Language: "+o,r=n?.icon,l=(e=>{const t=e.constructor===String?e:Object.values(e)[0];return e?t.split(" "):[]})(r);let c=e.LX.makeIcon(l[0],{svgClass:`${l.slice(1).join(" ")}`}).innerHTML;c+=a+" <span class='lang-ext'>("+n.extensions+")</span>",u(a,t)&&s.push({name:c,callback:()=>{for(let e of i)e.setLanguage(o)}})}}return s}(t);function i(e,t){return e.startsWith(t)?0:e.includes(t)?1:2}s=s.sort((s,o)=>{const n=e.LX.stripTags(s.name),a=e.LX.stripTags(o.name);return i(n,t)-i(a,t)||n.localeCompare(a)}),s=s.slice(0,48);for(let e of s)p(e,"")},s.appendChild(n),s.appendChild(r.root),s.appendChild(l),s},e.LX._registerIconsAndColors=function(t="./"){e.LX.requestJSON(t+"registry/colors.json",t=>{for(const s in t){const i=t[s];Array.isArray(i)&&i.forEach(t=>{const i=`${s}-${t.scale}`,o=`<span class="flex bg-${i} w-3 h-3 rounded-full mr-2"></span>${i}`;e.LX.registerCommandbarEntry(o,()=>{navigator.clipboard.writeText(i),e.LX.toast(`${e.LX.makeIcon("CircleCheck").innerHTML} Copied ${i} to clipboard.`,null,{position:"top-center",timeout:3e3})})})}});const s=window.lucide,i={...e.LX.ICONS,...s.icons};for(const t in i){const s="regular",i=`${e.LX.makeIcon(t,{svgClass:"mr-2 pointer-events-none",variant:s}).innerHTML}${t}`;e.LX.registerCommandbarEntry(i,()=>{navigator.clipboard.writeText(t),e.LX.toast(`${e.LX.makeIcon("CircleCheck").innerHTML} Copied ${t} to clipboard.`,null,{position:"top-center",timeout:3e3})})}},e.LX.setCommandbarState=function(t,s=!0){const i=this.commandbar;e.LX.modal.toggle(!t),t?(i.style.top=`calc(15% + ${document.scrollingElement?.scrollTop??0}px)`,i.show(),i.querySelector("input").focus(),s&&i._addElements(void 0),e.LX.modal.toggle(!1)):i.close()},e.LX.REGISTER_COMPONENT=function(t,s={}){let i=e.LX.guidGenerator();J.prototype["add"+t]=function(a,r,l){const c=Array.from(arguments).slice(3);let h=new n(e.ComponentType.CUSTOM,a,null,s);this._attachComponent(h),h.customName=t,h.customIdx=i,h.onGetValue=()=>r,h.onSetValue=(e,t,s)=>{r=e,g(),d.querySelector(".lexcustomitems").toggleAttribute("hidden",!1),t||h._trigger(new o(a,r,s),l)},h.onResize=()=>{const e=h.root.domName?.style.width??"0px";u.style.width=`calc( 100% - ${e})`};const d=h.root;let u,p,m=s.default??{};const g=()=>{u&&u.remove(),p&&p.remove(),u=document.createElement("div"),u.className="lexcustomcontainer w-full",d.appendChild(u),d.dataset.opened=!1;const i=e.LX.makeIcon(s.icon??"Box"),n=e.LX.makeIcon("Menu");let f=t+(r?"":" [empty]"),C=this.addButton(null,f,(s,i)=>{r?(d.querySelector(".lexcustomitems").toggleAttribute("hidden"),d.dataset.opened=!d.querySelector(".lexcustomitems").hasAttribute("hidden")):e.LX.addContextMenu(null,i,e=>{e.add("New "+t,()=>{r={},g(),d.querySelector(".lexcustomitems").toggleAttribute("hidden",!1),d.dataset.opened=!d.querySelector(".lexcustomitems").hasAttribute("hidden")})})},{buttonClass:"outline custom"});const v=C.root.querySelector("button");if(v.prepend(i),v.appendChild(n),u.appendChild(C.root),r&&n.addEventListener("click",t=>{t.stopImmediatePropagation(),t.stopPropagation(),e.LX.addContextMenu(null,t,e=>{e.add("Clear",()=>{r=null,g()})})}),p=document.createElement("div"),p.className="lexcustomitems",p.toggleAttribute("hidden",!0),d.appendChild(p),r){this.queue(p);const e=(e,t,i)=>{const n=s[`_set_${e}`];n?n.call(r,t):r[e]=t,h._trigger(new o(a,r,i),l)};for(let t in m){let i=null;const o=s[`_get_${t}`];if(i=o?r[t]?o.call(r):o.call(m):r[t]??m[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,...c),this.clearQueue()}};g()}},!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("AssetView");const kt=e.LX.Area;e.LX.Panel,e.LX.NodeTree,e.LX.Tree;class St{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="";selectedItems=[];allowedTypes;searchValue="";filter="None";gridScale=1;layout=St.LAYOUT_GRID;sortMode=St.CONTENT_SORT_ASC;skipBrowser=!1;skipPreview=!1;useNativeTitle=!1;onlyFolders=!0;allowMultipleSelection=!0;allowItemCheck=!1;previewActions=[];contextMenu=[];itemContextMenuOptions=null;_assetsPerPage=24;get assetsPerPage(){return this._assetsPerPage}set assetsPerPage(e){this._setAssetsPerPage(e)}_callbacks={};_lastSortBy="";_paginator;_scriptCodeDialog;_moveItemDialog;_movingItem;constructor(t={}){this.rootPath="https://raw.githubusercontent.com/jxarco/lexgui.js/master/",this.layout=t.layout??this.layout,this.sortMode=t.sortMode??this.sortMode,t.rootPath&&(t.rootPath.constructor!==String?console.warn(`Asset Root Path must be a String (now is a ${t.rootPath.constructor.name})`):this.rootPath=t.rootPath);let s=document.createElement("div");s.className="lexassetbrowser",this.root=s;let i=new kt({width:"100%",height:"100%"});s.appendChild(i.root);let o,n,a=i;if(this.skipBrowser=t.skipBrowser??this.skipBrowser,this.skipPreview=t.skipPreview??this.skipPreview,this.useNativeTitle=t.useNativeTitle??this.useNativeTitle,this.onlyFolders=t.onlyFolders??this.onlyFolders,this.allowMultipleSelection=t.allowMultipleSelection??this.allowMultipleSelection,this.allowItemCheck=t.allowItemCheck??this.allowItemCheck,this.previewActions=t.previewActions??[],this.itemContextMenuOptions=t.itemContextMenuOptions,this.gridScale=t.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"},...t.allowedTypes??{}},this.path=["@"],this.rootItem={id:"/",children:this.data,type:"folder",metadata:{uid:e.LX.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(t){this.prevData.length=0,this.nextData.length=0,this.data=t,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:e.LX.guidGenerator()}}),this._refreshContent()}addItem(t,s,i=!0){const o=this.layout==St.LAYOUT_LIST,n=this.layout==St.LAYOUT_GRID,a=t.type.charAt(0).toUpperCase()+t.type.slice(1),r=e.LX.getExtension(t.id),l="Folder"===a,c=this;let h=document.createElement("li");h.className="lexassetitem "+t.type.toLowerCase(),h.tabIndex=-1,e.LX.insertChildAtIndex(this.content,h,s);const d=this.allowedTypes[a]?.color;d&&e.LX.makeElement("span",`rounded-full w-2 h-2 z-100 flex absolute ml-2 mt-2 bg-${d}`,"",h);const u=t.metadata;if(u.uid||(u.uid=e.LX.guidGenerator()),u.lastModified&&!u.lastModifiedDate&&(u.lastModifiedDate=this._lastModifiedToStringDate(u.lastModified)),this.useNativeTitle)h.title=a+": "+t.id;else{let i=document.createElement("span");i.className="lexitemdesc",i.id=e.LX.getSupportedDOMName(`floatingTitle_${u.uid}`),i.innerHTML=`File: ${t.id}<br>Type: ${a}`,e.LX.insertChildAtIndex(this.content,i,void 0!==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 r=o.x+e.offsetX,l=o.y+e.offsetY;if(s){const e=s.getBoundingClientRect();r-=e.x,l-=e.y}t.classList.contains("lexassettitle")&&(l+=a.y-o.y),i.style.left=r+"px",i.style.top=l-36+"px"})}if(this.allowItemCheck){let e=document.createElement("input");e.type="checkbox",e.className="lexcheckbox",e.checked=u.selected,e.addEventListener("change",e=>{u.selected=!u.selected;const s=c._callbacks.check;if(void 0!==s){s({type:"check",items:[t],userInitiated:!0})}e.stopPropagation(),e.stopImmediatePropagation()}),h.appendChild(e)}if(e.LX.makeElement("span","lexassettitle absolute w-full h-8 bottom-0 text-sm bg-card text-card-foreground cursor-pointer text-center content-center block px-3 py-0.5 truncate z-1 pointer-events-none",t.id,h),!this.skipPreview){if("video"===t.type){const s=e.LX.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=t.src,s.volume=u.volume??.4}let s=null;const i=u.preview??t.src;if(i&&((()=>{const t=e.LX.getExtension(i.split("?")[0].split("#")[0]);return!!t&&["png","jpg","jpeg","gif","bmp","avif"].includes(t.toLowerCase())})()||i.startsWith("data:image/"))||l||!n){const e=`${this.rootPath}images/file.png`,t=`${this.rootPath}images/folder.png`;s=document.createElement("img");let o=u.unknownExtension?e:l?t:i;s.src=n||l?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 e=document.createElement("text");e.innerText=r&&r!=t.id?`${r.toUpperCase()}`:t.type.toUpperCase(),s.appendChild(e);var p=2.5/e.innerText.length;if(p<1){var m=64*p;e.style.fontSize=m+"px",s.style.paddingTop=`calc(50% - ${.5*e.offsetHeight+10}px)`}}}let g=a;o&&(u.bytesize&&(g+=` | ${e.LX.formatBytes(u.bytesize)}`),u.lastModifiedDate&&(g+=` | ${u.lastModifiedDate}`)),e.LX.makeContainer(["auto","auto"],"lexassetinfo",g,h),h.addEventListener("click",function(s){s.stopImmediatePropagation(),s.stopPropagation();const i=s.detail==e.LX.MOUSE_DOUBLE_CLICK;if(i){if(l)return void c._enterFolder(t)}else s.shiftKey&&c.allowMultipleSelection||(c.content.querySelectorAll(".lexassetitem").forEach(e=>e.classList.remove("selected")),c.selectedItems.length=0),this.classList.add("selected"),c.selectedItems.push(t),c.skipPreview||c._previewAsset(t);const o=c._callbacks.select,n=c._callbacks.dblClick;if(i&&void 0!==n){n({type:"dbl_click",items:[t],userInitiated:!0})}else if(!i&&void 0!==o){o({type:"select",items:[t],userInitiated:!0})}}),h.addEventListener("contextmenu",function(s){s.preventDefault(),s.stopImmediatePropagation(),s.stopPropagation();const i=c.selectedItems.length>1,o=[{name:i?`${c.selectedItems.length} selected`:t.id,icon:e.LX.makeIcon("CircleSmall",{svgClass:`fill-current text-${d}`}),className:"text-sm",disabled:!0},null];if(i||o.push({name:"Rename",icon:"TextCursor",callback:c._renameItemPopover.bind(c,t)}),l||i||o.push({name:"Clone",icon:"Copy",callback:c._requestCloneItem.bind(c,t)}),i||o.push({name:"Move",icon:"FolderInput",callback:()=>c._moveItem(t)}),!i&&"Script"==a&&e.LX.has("CodeEditor")&&o.push({name:"Open in Editor",icon:"Code",callback:c._openScriptInEditor.bind(c,t)}),c.itemContextMenuOptions){o.length>2&&o.push(null);for(let e of c.itemContextMenuOptions)e.name&&e.callback&&o.push({name:e.name,icon:e.icon,callback:e.callback?.bind(c,i?c.selectedItems:[t])})}o.push(null,{name:"Delete",icon:"Trash2",className:"destructive",callback:c._requestDeleteItem.bind(c,i?c.selectedItems:[t])}),e.LX.addClass(c.contentPanel.root,"pointer-events-none"),e.LX.addDropdownMenu(s.target,o,{side:"right",align:"start",event:s,onBlur:()=>{e.LX.removeClass(c.contentPanel.root,"pointer-events-none")}})});const f=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",s=>{window.__av_item_dragged=t;var i=new Image;i.src="",s.dataTransfer&&(s.dataTransfer.setDragImage(i,0,0),s.dataTransfer.effectAllowed="move");const o=e.LX.getSupportedDOMName(`floatingTitle_${u.uid}`),n=c.content.querySelector(`#${o}`);n&&(n.style.display="none")},!1),h.addEventListener("dragend",e=>{e.preventDefault();let t=window.__av_item_dragged;t&&t._nodeTarget&&f(t,t._nodeTarget),delete window.__av_item_dragged},!1),h.addEventListener("dragenter",s=>{s.preventDefault();let i=window.__av_item_dragged;i&&l&&i.metadata.uid!=u.uid&&e.LX.addClass(t.domEl,"animate-pulse")}),h.addEventListener("dragleave",s=>{s.preventDefault(),window.__av_item_dragged&&e.LX.removeClass(t.domEl,"animate-pulse")}),h.addEventListener("drop",e=>{e.preventDefault();let s=window.__av_item_dragged;s&&f(s,t)}),h.addEventListener("mouseenter",s=>{if(!c.useNativeTitle&&n){const t=e.LX.getSupportedDOMName(`floatingTitle_${u.uid}`),s=c.content.querySelector(`#${t}`);s&&(s.style.display="unset")}if("video"!==t.type)return;s.preventDefault();const i=h.querySelector("video");i.style.opacity="1",i.play()}),h.addEventListener("mouseleave",s=>{if(!c.useNativeTitle&&n&&setTimeout(()=>{const t=e.LX.getSupportedDOMName(`floatingTitle_${u.uid}`),s=c.content.querySelector(`#${t}`);s&&(s.style.display="none")},100),"video"!==t.type)return;s.preventDefault();const i=h.querySelector("video");i.pause(),i.currentTime=0,u.preview&&(i.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("@");e.LX.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:"ghost",title:"Go Back",tooltip:!0,icon:"ArrowLeft"}),e.addButton(null,"GoForwardButton",()=>{this.nextData.length&&this.currentFolder&&this._enterFolder(this.nextData.pop())},{buttonClass:"ghost",title:"Go Forward",tooltip:!0,icon:"ArrowRight"}),e.addButton(null,"GoUpButton",()=>{const e=this.currentFolder?.parent;e&&this._enterFolder(e)},{buttonClass:"ghost",title:"Go Upper Folder",tooltip:!0,icon:"ArrowUp"}),e.addButton(null,"RefreshButton",()=>{this._refreshContent(void 0,void 0,!0)},{buttonClass:"ghost",title:"Refresh",tooltip:!0,icon:"Refresh"})}_createTreePanel(e){this.leftPanel?this.leftPanel.clear():this.leftPanel=e.addPanel({className:"lexassetbrowserpanel"}),this._createNavigationBar(this.leftPanel);const t={id:"/",children:this.data},s=this.leftPanel.addTree("Content Browser",t,{filter:!1,onlyFolders:this.onlyFolders});this._subscribeTreeEvents(s),this.tree=s.innerTree}_subscribeTreeEvents(e){e.on("select",(e,t)=>{if(e.items.length>1)return;const s=e.items[0];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.selectedItems=[s]}else this.currentFolder&&this.prevData.push(this.currentFolder),this.currentFolder=void 0,this.currentData=this.data,this._refreshContent(),this._updatePath()}),e.on("beforeMove",(e,t)=>{const s=this._callbacks.beforeNodeDragged,i=this._callbacks.nodeDragged,o=e.items[0],n=e.to,a=(...e)=>{if(o.parent){const e=o.parent.children.indexOf(o);o.parent.children.splice(e,1)}n.children||(n.children=[]),n.children.push(o),o.parent=n,o.dir=n.children,t(...e);i&&i({type:"node-drag",items:[o],to:n,userInitiated:!0},...e),this._refreshContent()};if(s){s({type:"node-drag",items:[o],to:n,userInitiated:!0},a)}else a()}),e.on("beforeDelete",(e,t)=>{const s=e.items[0];this._requestDeleteItem(s)}),e.on("beforeRename",(e,t)=>{const s=e.items[0];this._requestRenameItem(s,e.newName,!0)})}_setContentLayout(e){this.layout=e,this.toolsPanel.refresh(),this._refreshContent()}_createContentPanel(t){const s=this;t.root.classList.add("flex","flex-col"),this.toolsPanel?this.contentPanel.clear():(this.toolsPanel=t.addPanel({className:"flex-auto",height:"auto"}),this.contentPanel=t.addPanel({className:"lexassetcontentpanel flex flex-col flex-auto-fill content-center overflow-hidden"}),this._paginator=new e.LX.Pagination({className:"ml-auto",pages:Math.max(Math.ceil(this.data.length/this.assetsPerPage),1),onChange:()=>this._refreshContent()}),this.contentPanel.root.addEventListener("wheel",t=>{if(!t.ctrlKey)return;t.preventDefault(),this.gridScale*=t.deltaY<0?1.05:.95,this.gridScale=e.LX.clamp(this.gridScale,.5,2);document.querySelector(":root").style.setProperty("--av-grid-scale",this.gridScale)}));const i=(t,s)=>{e.LX.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,St.CONTENT_SORT_ASC)},{name:"Descending",icon:"SortDesc",callback:()=>this._sortData(void 0,St.CONTENT_SORT_DESC)}],{side:"bottom",align:"start"})},o=(t,s)=>{e.LX.addDropdownMenu(s.target,[{name:"Grid",icon:"LayoutGrid",callback:()=>this._setContentLayout(St.LAYOUT_GRID)},{name:"Compact",icon:"LayoutList",callback:()=>this._setContentLayout(St.LAYOUT_COMPACT)},{name:"List",icon:"List",callback:()=>this._setContentLayout(St.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===St.CONTENT_SORT_ASC?"SortAsc":"SortDesc"});if(this.toolsPanel.addButton(null,"",o.bind(this),{title:"View",tooltip:!0,icon:this.layout===St.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 text-muted-foreground text-sm 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")),s.selectedItems.length=0}),this.content.addEventListener("contextmenu",function(t){t.preventDefault();const i=[{name:"New Folder",icon:e.LX.makeIcon("FolderPlus"),callback:()=>{s._requestCreateFolder()}}];e.LX.addClass(s.contentPanel.root,"pointer-events-none"),e.LX.addDropdownMenu(t.target,i,{side:"right",align:"start",event:t,onBlur:()=>{e.LX.removeClass(s.contentPanel.root,"pointer-events-none")}})}),this._refreshContent(),e.LX.doAsync(()=>this.toolsPanel.refresh(),100)}_makeNameFilterFn(t){const s=t.trim();if(s.includes("*")||s.includes("?")){const t=e.LX.wildcardToRegExp(s);return e=>t.test(e)}return e=>e.toLowerCase().includes(s.toLowerCase())}_refreshContent(t,s,i=!1){const o=this._callbacks.beforeRefreshContent,n=this._callbacks.refreshContent,a=(...o)=>{const a=this.layout==St.LAYOUT_COMPACT,r=this.layout==St.LAYOUT_LIST;if(this.filter=s??this.filter??"None",this.searchValue=t??this.searchValue??"",this.content.innerHTML="",this.content.className="lexassetscontent"+(a?" compact":r?" list":""),!this.currentData.length)return;const l=new FileReader,c=this._makeNameFilterFn(this.searchValue),h=this.currentData.filter(e=>{const t="None"===this.filter||e.type.toLowerCase()===this.filter.toLowerCase(),s=c(e.id);return t&&s});this._paginator?.setPages(Math.max(Math.ceil(h.length/this.assetsPerPage),1));const d=this._paginator?(this._paginator.page-1)*this.assetsPerPage:0,u=this._paginator?Math.min(d+this.assetsPerPage,h.length):h.length;for(let i=d;i<u;++i){let o=h[i];o.path?e.LX.request({url:o.path,dataType:"blob",success:e=>{o.metadata.bytesize=e.size,l.readAsDataURL(e),l.onload=e=>{const i=e.currentTarget;o.src=i.result,o.metadata.path=o.path,delete o.path,this._refreshContent(t,s)}}}):o.domEl=this.addItem(o,void 0,!1)}const p={type:"refresh-content",search:[this.searchValue,this.filter],items:h.slice(d,u),userInitiated:i};n&&n(p,...o)};if(o){o({type:"refresh-content",search:[this.searchValue,this.filter],userInitiated:i},a)}else a()}_previewAsset(t){if(this.skipPreview)return;const s=t.src&&t.src.includes("data:image/");if(t.metadata=t.metadata??{},this.previewPanel.clear(),this.previewPanel.branch("Asset"),"image"==t.type||t.src){(["png","jpg"].indexOf(e.LX.getExtension(t.src))>-1||s)&&this.previewPanel.addImage(null,t.src,{style:{width:"100%"}})}t.metadata.lastModified&&!t.metadata.lastModifiedDate&&(t.metadata.lastModifiedDate=this._lastModifiedToStringDate(t.metadata.lastModified));const i={disabled:!0};this.previewPanel.addText("Filename",t.id,null,i),t.metadata.lastModifiedDate&&this.previewPanel.addText("Last Modified",t.metadata.lastModifiedDate,null,i),(t.metadata.path||t.src)&&this.previewPanel.addText("URL",t.metadata.path?t.metadata.path:t.src,null,i),this.previewPanel.addText("Path",this.path.join("/"),null,i),this.previewPanel.addText("Type",t.type,null,i),t.metadata.bytesize&&this.previewPanel.addText("Size",e.LX.formatBytes(t.metadata.bytesize),null,i),"folder"==t.type&&this.previewPanel.addText("Files",t.children?t.children.length.toString():"0",null,i),this.previewPanel.addSeparator();const o=[...this.previewActions];o.length||"folder"===t.type||o.push({name:"Download",callback:()=>e.LX.downloadURL(t.src,t.id)});for(let e of o)e.type&&e.type!==t.type||e.path&&e.path!==this.path.join("/")||this.previewPanel.addButton(null,e.name,e.callback.bind(this,t));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)===St.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?.metadata?.uid===e.metadata?.uid;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}if(this.currentFolder=e,this.currentData=this.currentFolder?.children??[],o){this._processData(this.data),this._refreshContent();let e=`${this.currentFolder.id}/`,t=this.currentFolder.parent;for(;t&&"/"!==t.id;)e+=`${t.id}/`,t=t.parent;const s=e.split("/").filter(Boolean).reverse();this.tree?.select(void 0,s)}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)=>{e.forEach(e=>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,this.previewPanel?.clear()):console.error("[AssetView Error] Cannot move. Item not found.")}_moveItem(t,s){this._moveItemDialog&&this._moveItemDialog.destroy(),this._movingItem=t;let i,o=null;const n=function(t,s,a=!0){s.innerHTML="",o=t;for(let t of o.children??o){const i=e.LX.makeContainer(["100%","auto"],"flex flex-row px-1 items-center","",s),a="folder"===t.type,r=e.LX.makeContainer(["100%","auto"],`move-item flex flex-row gap-1 py-1 px-3 cursor-pointer items-center ${a?"text-foreground font-medium":"text-muted-foreground"} rounded-2xl ${a?"hover:bg-accent":"hover:bg-muted"}`,`${a?e.LX.makeIcon("FolderOpen",{svgClass:""}).innerHTML:""}${t.id}`,i);if(a){r.addEventListener("click",()=>{s.querySelectorAll(".move-item").forEach(t=>e.LX.removeClass(t,"bg-primary text-primary-foreground")),e.LX.addClass(r,"bg-primary text-primary-foreground"),o=t});const a=new e.LX.Button(null,"FPathButton",()=>{n(t,s)},{icon:"ChevronRight",className:"ml-auto h-8",buttonClass:"ghost"});i.appendChild(a.root)}}if(!a)return;const r=[];if(o&&o.parent){r.push(o.id);const e=t=>{t&&(r.push(t.parent?t.id:"@"),e(t.parent))};e(o.parent)}else r.push("@");i.innerHTML="",i.appendChild(e.LX.makeBreadcrumb(r.reverse().map(e=>({name:e})),{maxItems:4,separatorIcon:"ChevronRight"}))};this._moveItemDialog=new e.LX.Dialog(`Moving: ${t.id}`,a=>{const r=new e.LX.Area({className:"flex flex-col rounded-lg"});a.attach(r);const l=e.LX.makeContainer(["auto","100%"],"flex flex-auto-fill flex-col overflow-scroll py-2 gap-1","");{const t=r.addPanel({className:"p-2 border-b-color flex flex-auto-keep",height:"auto"});t.sameLine(2,"w-full"),t.addButton(null,"BackButton",()=>{o&&o.parent&&n(o.parent,l)},{icon:"ArrowLeft",title:"Back",tooltip:!0,className:"flex-auto-keep",buttonClass:"ghost"}),i=e.LX.makeElement("div"),t.addContent("ITEM_MOVE_PATH",i,{signal:"@item_move_path",className:"flex-auto-fill"})}r.attach(l),n(s??this.data,l);{const e=r.addPanel({className:"p-2 border-t-color flex flex-auto-keep justify-between",height:"auto"});e.addButton(null,"NewFolderButton",()=>{this._requestCreateFolder(o)},{width:"auto",icon:"FolderPlus",title:"Create Folder",tooltip:!0,className:"ml-2",buttonClass:"ghost"}),e.sameLine(2,"mr-2"),e.addButton(null,"Cancel",()=>{this._moveItemDialog.close()},{buttonClass:"ghost text-destructive"}),e.addButton(null,"Move",()=>{this._requestMoveItemToFolder(t,o)},{className:"",buttonClass:"primary"})}},{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(t){const s=t.parent,i=t.dir??[],o=i.indexOf(t);delete t.domEl,delete t.dir,delete t.parent;const n=e.LX.deepCopy(t);return n.id=this._getClonedName(t.id,i),n.dir=t.dir=i,n.parent=t.parent=s,n.metadata.uid=e.LX.guidGenerator(),i.splice(o+1,0,n),this._refreshContent(this.searchValue,this.filter),n}_getClonedName(t,s){const i=t.lastIndexOf(".");let o=t,n="";i>0&&(o=t.substring(0,i),n=t.substring(i));const a=o.match(/^(.*)\s\((\d+)\)$/);a&&(o=a[1]);let r=-1;for(const t of s){if(!t.id)continue;let s=t.id,i="";const a=s.lastIndexOf(".");if(a>0&&(i=s.substring(a),s=s.substring(0,a)),i!==n)continue;const l=s.match(new RegExp("^"+e.LX.escapeRegExp(o)+"\\s\\((\\d+)\\)$"));if(l){const e=parseInt(l[1]);e>r&&(r=e)}else s===o&&(r=Math.max(r,0))}return-1===r?t:`${o} (${r+1})${n}`}_requestRenameItem(e,t,s=!1){const i=this._callbacks.beforeRename,o=this._callbacks.rename,n=e.id,a=(...i)=>{this._renameItem(e,t,s?e.dir:this.currentData);o&&o({type:"rename",items:[e],oldName:n,newName:t,userInitiated:!0},...i)};if(i){i({type:"rename",items:[e],oldName:n,newName:t,userInitiated:!0},a)}else a()}_renameItem(t,s,i){const o=(i=i??this.currentData).indexOf(t);if(!(o<0)){if(t.domEl){const i=e.LX.hasClass(t.domEl,"selected"),n=e.LX.getSupportedDOMName(`floatingTitle_${t.metadata.uid}`),a=this.content.querySelector(`#${n}`);a&&a.remove(),t.domEl?.remove(),t.id=s,t.domEl=this.addItem(t,2*o),i&&this._previewAsset(t)}else t.id=s;this.tree?.refresh(),this._processData(this.data)}}_renameItemPopover(t){if(this.currentData.indexOf(t)<0)return;const s=e=>{n.destroy(),this._requestRenameItem(t,e)};let i=t.id;const o=new e.LX.Panel;o.addText(null,t.id,(e,t)=>{i=e,t.constructor===KeyboardEvent&&s(e)}),o.addButton(null,"Save",()=>{s(i)},{buttonClass:"primary"});const n=new e.LX.Popover(t.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,...t);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,t){if(!(e=e??this.currentFolder))throw"_createFolder: Something went wrong!";const s=e.children??e,i={id:this._getClonedName(t??"New Folder",s),type:"folder",children:[],parent:this.currentFolder,metadata:{}};return s.push(i),this._refreshContent(),this.tree?.refresh(),this._moveItemDialog&&this._movingItem&&this._moveItem(this._movingItem,e),i}_openScriptInEditor(t){this._scriptCodeDialog&&this._scriptCodeDialog.destroy(),this._scriptCodeDialog=new e.LX.Dialog(null,s=>{const i=new e.LX.Area({className:"rounded-lg"});s.attach(i),new e.LX.CodeEditor(i,{allowAddScripts:!1,files:[t.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(e.LX.AssetView=St,!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("Audio");const wt=e.LX.Panel,Tt=e.LX.BaseComponent,Et=e.LX.ComponentType,Mt=e.LX.IEvent;class At extends Tt{constructor(t,s,i,o,n,a={}){s.constructor==Number&&(s=e.LX.clamp(s,i,o),s=a.precision?e.LX.round(s,a.precision):s),super(Et.KNOB,t,s,a),this.onGetValue=()=>d.value,this.onSetValue=(t,s,i)=>{m(t),e.LX.BaseComponent._dispatchEvent(d,"change",s)},this.onResize=()=>{const e=this.root.domName?.style.width??"0px";c.style.width=`calc( 100% - ${e})`};const r=a.snap&&a.snap.constructor==Number,l=[];if(r){const e=(o-i)/a.snap;for(let t=0;t<a.snap+1;++t)l.push(i+t*e)}var c=document.createElement("div");c.className="lexknob",e.LX.addClass(c,a.size),e.LX.addClass(c,r?"show-ticks":null);let h=document.createElement("div");h.className="knobcircle",r&&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(t){const s=e.LX.remapRange(t,d.min,d.max,-135,135);d.style.rotate=s+"deg",d.value=t};const g=e.LX.remapRange(s,i,o,-135,135);d.style.rotate=g+"deg",this.disabled&&e.LX.addClass(c,"disabled"),d.addEventListener("change",s=>{const i=s.target,o=s.detail;p&&(i.value=l.reduce((e,t)=>Math.abs(t-i.value)<Math.abs(e-i.value)?t:e));let c=i.value=e.LX.clamp(i.value,i.min,i.max);if(c=a.precision?e.LX.round(c,a.precision):c,m(c),!o){let e=this.root.querySelector(".lexcomponentname .lexicon");e&&(e.style.display=c!=d.iValue?"block":"none"),r&&!p||(this._trigger(new Mt(t,c,s),n),p=!1)}},{passive:!1}),d.addEventListener("mousedown",function(e){if(document.activeElement==d||f.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(t){let s=-t.movementY;if(0!=s){let i=a.step??1;t.shiftKey?i*=10:t.altKey&&(i*=.1);let o=d.value-i*s;d.value=o,e.LX.BaseComponent._dispatchEvent(d,"change")}t.stopPropagation(),t.preventDefault()}function v(t){var s=f.root.ownerDocument;s.removeEventListener("mousemove",C),s.removeEventListener("mouseup",v),document.body.classList.remove("noevents"),r&&(p=!0,e.LX.BaseComponent._dispatchEvent(d,"change")),document.pointerLockElement&&document.exitPointerLock()}c.appendChild(h),this.root.appendChild(c),e.LX.doAsync(this.onResize.bind(this))}}e.LX.Knob=At;if(wt.prototype.addKnob=function(e,t,s,i,o,n={}){const a=new At(e,t,s,i,o,n);return this._attachComponent(a)},!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("DocMaker");const Xt=["uint32_t","uint64_t","uint8_t"],Pt=["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"],Nt=["var","let","const","static","function","null","undefined","new","delete","true","false","NaN","this"],It=["var","let","const","override","fn","struct","alias","true","false","bool","f16","f32","i32","u32","vec2","vec3","vec4","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4"],Ot=["for","if","else","return","continue","break","case","switch","while","import","from","await"],Rt=["html","charset","rel","src","href","crossorigin","type","lang"],zt=["DOCTYPE","html","head","body","title","base","link","meta","style","main","section","nav","article","aside","header","footer","address","h1","h2","h3","h4","h5","h6","p","hr","pre","blockquote","ol","ul","li","dl","dt","dd","figure","figcaption","div","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rp","rt","ruby","s","samp","small","span","strong","sub","sup","time","u","var","wbr","img","audio","video","source","track","picture","map","area","canvas","iframe","embed","object","param","form","label","input","button","select","datalist","optgroup","option","textarea","output","progress","meter","fieldset","legend","table","caption","colgroup","col","tbody","thead","tfoot","tr","td","th","details","summary","dialog","script","noscript","template"];class Dt{root;_listQueued=void 0;_lastDomTarget=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(t,s,i,o={}){if(console.assert(void 0!==t&&void 0!==s),o.collapsable){const n=e.LX.makeElement("div",e.LX.mergeClass("my-4 px-6 cursor-pointer",o.className),`<${s} id="${i??""}">${t}</${s}>`,this.root),a=e.LX.makeContainer(["100%","auto"],"px-4","",this.root);return e.LX.listen(n,"click",()=>n.querySelector("a.collapser").click()),this._lastDomTarget=this.root,this.setDomTarget(a),o.collapsableContentCallback&&o.collapsableContentCallback(),e.LX.makeCollapsible(n,a,null,{collapsed:o.collapsed??!1}),this.setDomTarget(this._lastDomTarget),delete this._lastDomTarget,n}const n=document.createElement(s);return n.className=o.className??"",n.innerHTML=t,i&&(n.id=i),this.root.appendChild(n),n}paragraph(t,s=!1,i=""){console.assert(void 0!==t);let o=document.createElement(s?"sup":"p");return o.className=e.LX.mergeClass("leading-relaxed",i),o.innerHTML=t,this.root.appendChild(o),o}code(t,s="js"){console.assert(void 0!==t),t.replaceAll("<","<"),t.replaceAll(">",">");let i="",o="";const n=(e,t)=>`<span class="${e}">${t}</span>`;for(let e=0;e<t.length;++e){const a=t[e],r=t.substring(e),l=r.indexOf("\n"),c=r.substring(0,l>-1?l:void 0);if("@"==a){const a=c.substring(1);if(!(a.indexOf("@")>-1||a.indexOf("[")>-1))continue;let r=null;const l=a.indexOf("@"),h="|"==a[l-1];if("["==t[e+1])if(i=a.substring(1,4),o=a.substring(5,l),h){const e=a.substring(6+o.length),s=o,l=e.substring(0,e.indexOf("@"));r=n(i,s.substring(0,s.length-1)+"@"+l);const c=s+"@"+l;t=t.replace(`@[${i}]${c}@`,r)}else r=n(i,o),t=t.replace(`@[${i}]${o}@`,r);else{if(o=a.substring(0,l),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),t=t.substr(0,e)+"@"+o+"@"+t.substr(e+o.length+3)}"cpp"==s&&Pt.includes(o)||"js"==s&&Nt.includes(o)||"wgsl"==s&&It.includes(o)?i="kwd":Xt.includes(o)?i="cls":Ot.includes(o)?i="lit":zt.includes(o)?i="tag":Rt.includes(o)?i="atn":'"'==o[0]&&'"'==o[o.length-1]||"'"==o[0]&&"'"==o[o.length-1]||"`"==o[0]&&"`"==o[o.length-1]?i="str":Number.isNaN(parseFloat(o))?(i="",console.error("WARNING[Code Parsing]: Unknown highlight type: "+o)):i="dec",r=n(i,o),t=t.replace(`@${o}@`,r)}e+=r.length-1}}let a=document.createElement("div");a.className="code-container";let r=document.createElement("pre"),l=document.createElement("code");l.innerHTML=t;let c=document.createElement("button");return c.title="Copy code sample",c.appendChild(e.LX.makeIcon("Copy")),c.addEventListener("click",this._copySnippet.bind(this,c)),a.appendChild(c),r.appendChild(l),a.appendChild(r),this.root.appendChild(a),a}list(e,t,s,i=""){console.assert(e&&e.length>0&&["bullet","numbered"].includes(t),"Invalid list type or empty list"+t);const o="bullet"==t?"ul":"ol";let n=document.createElement(o);for(var a of(n.className=i,(s=s??this.root).appendChild(n),e)){if(a.constructor===Array)return void this.list(a,t,n);let e=document.createElement("li");e.className="leading-loose",e.innerHTML=a,n.appendChild(e)}return n}bulletList(e){return this.list(e,"bullet")}numberedList(e){return this.list(e,"numbered")}startCodeBulletList(){let e=document.createElement("ul");return this._listQueued=e,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);return t?t.appendChild(s):this.root.appendChild(s),s}image(t,s="",i,o=""){let n=document.createElement("img");return n.src=t,n.alt=s,n.className=e.LX.mergeClass("my-1",o),(i=i??this.root).appendChild(n),n}images(e,t=[],s,i){const o=navigator&&/Android|iPhone/i.test(navigator.userAgent),n=document.createElement("div");o||(n.style.width=s??"auto",n.style.height=i??"256px",n.className="flex flex-row justify-center");for(let s=0;s<e.length;++s)this.image(e[s],t[s],n);return this.root.appendChild(n),n}video(e,t="",s=!0,i=!1,o=""){let n=document.createElement("video");return n.className=o,n.src=e,n.controls=s,n.autoplay=i,i&&(n.muted=!0),n.loop=!0,n.alt=t,this.root.appendChild(n),n}note(t,s=!1,i,o,n=""){console.assert(void 0!==t);const a=e.LX.makeContainer([],e.LX.mergeClass("border-color rounded-xl overflow-hidden text-sm text-secondary-foreground my-6",n),"",this.root),r=document.createElement("div");return r.className="flex bg-muted font-semibold px-3 py-2 gap-2 text-secondary-foreground",r.appendChild(e.LX.makeIcon(o??(s?"MessageSquareWarning":"NotepadText"))),r.innerHTML+=i??(s?"Important":"Note"),a.appendChild(r),e.LX.makeContainer([],"leading-6 p-3",t,a)}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");return n.innerHTML=this.iCode("<span class='constructor'>"+e+"("+i+")</span>"),this.root.appendChild(n),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 class="font-semibold underline-offset-4 hover:underline" 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(t){t.innerHTML="",t.appendChild(e.LX.makeIcon("Check")),t.classList.add("copied"),setTimeout(()=>{t.innerHTML="",t.appendChild(e.LX.makeIcon("Copy")),t.classList.remove("copied")},2e3),navigator.clipboard.writeText(t.dataset.snippet??t.parentElement.innerText),console.log("Copied!")}}if(e.LX.DocMaker=Dt,!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("GraphEditor");const Bt=globalThis,Ht=e.LX.vec2,Ft=e.LX.Area;e.LX.Panel,e.LX.Sidebar,e.LX.ContextMenu;const $t=e.LX.PocketDialog;class Vt{origin;size;constructor(e,t){this.origin=e??new Ht(0,0),this.size=t??new Ht(0,0)}merge(e){console.assert(e.constructor==Vt);const t=this.origin,s=this.origin.add(this.size),i=e.origin,o=e.origin.add(e.size),n=new Ht(Math.min(t.x,i.x),Math.min(t.y,i.y)),a=new Ht(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 Gt{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=Gt.STOPPED;isFocused=!1;_graphContainer;_sidebarDom;_sidebarActive=!0;_sidebar;_domLinks;_domNodes;_mousePosition=new Ht(0,0);_deltaMousePosition=new Ht(0,0);_snappedDeltaMousePosition=new Ht(0,0);_lastMousePosition=new Ht(0,0);_lastSnappedMousePosition=new Ht(0,0);_generatingLink;_snapToGrid=!1;_snapValue=1;_nodeBackgroundOpacity=.8;_patternSizeF=15;_patternSize=new Ht(this._patternSizeF);_circlePatternSize=.04*this._patternSizeF;_circlePatternColor="#71717a9c";_background;_undoSteps=[];_redoSteps=[];_clipboardData;_lastMouseDown=0;_boxSelecting;_boxSelectRemoving;_currentBoxSelectionSVG;constructor(t,s={}){Gt.__instances.push(this),this._sidebar=t.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 Ft({className:"lexgraph"}),t.root.classList.add("grapharea"),this.root=this.area.root,this.root.tabIndex=-1,t.attach(this.root),this._graphContainer=t.sections[1].root,this._sidebarDom=t.sections[0].root,this._sidebarActive=s.sidebar??this._sidebarActive,e.LX.doAsync(()=>{this._sidebar.toggleCollapsed(!this._sidebarActive)},50),t.onresize=e=>{},t.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 $t("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),Bt.ge=this}static getInstances(){return Gt.__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=Gt.NODE_TYPES[e];i&&console.warn(`Replacing node type [${e}]`),Gt.NODE_TYPES[e]=t,Gt.onCustomNodeRegistered&&Gt.onCustomNodeRegistered(e,t),i&&Gt.onNodeTypeReplaced&&Gt.onNodeTypeReplaced(e,t,i)}static addNode(e,t,s={}){var i=Gt.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 Ht(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(t){if(!this.currentGraph||t.id!=this.currentGraph.id)if(this.clear(),t.id=t.id??t.constructor.name+"-"+e.LX.guidGenerator(),this.graphs[t.id]=t,t.nodes){this.currentGraph=t,this._updatePattern();for(let e of t.nodes)this._createNodeDOM(e);for(let e of t.groups){const t=this._createGroup(e);t.querySelector(".lexgraphgrouptitle").value=e.name,this._domNodes.prepend(t)}for(let e in t.links){const s=t.links[e];for(let e of s)this._createLink(e)}this._updateGraphName(t.name),this._togglePropertiesDialog(!1)}else console.warn("Graph does not contain any node!")}loadGraph(t,s){e.LX.requestJSON(t,e=>{let t="Graph"==e.type?this.addGraph(e):this.addGraphFunction(e);s&&s(t)},e=>console.error(e))}addGraph(e){let t=new qt;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 Wt;if(t.editor=this,e){for(let t of e.functions??[])this.addGraphFunction(t);t.configure(e)}this.setGraph(t);class s extends Kt{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,Gt.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(t){t.editor=this,t.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,t.position),t.type&&Gt.NODE_TYPES[t.type]){const e=t.constructor.category;i.classList.add(e)}else{const e=t.type.lastIndexOf("/"),s=t.type.substring(0,e);i.classList.add(s)}(s=t.color??s)&&(s.constructor==Array?s=s.join(","):(s=e.LX.hexToRgb(s)).forEach((e,t)=>s[t]=255*e),i.style.backgroundColor="rgba("+s+", "+this._nodeBackgroundOpacity+")"),i.addEventListener("mousedown",t=>{t.button==e.LX.MOUSE_LEFT_CLICK&&(t.altKey?this._unSelectNode(i):(this.selectedNodes.length>1&&!t.ctrlKey&&!t.shiftKey&&this.unSelectAll(!0),i.classList.contains("selected")||this._selectNode(i,t.ctrlKey||t.shiftKey)))}),i.addEventListener("contextmenu",s=>{s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),e.LX.addContextMenu(null,s,e=>{e.add("Copy",()=>{this._clipboardData={id:t.id,gid:this.currentGraph?.id}}),e.add(""),e.add("Delete",()=>{this._deleteNode(i.dataset.id)})})}),i.addEventListener("dblclick",s=>{s.button==e.LX.MOUSE_LEFT_CLICK&&t.constructor.func&&this._sidebar.select(t.constructor.func.name)});var o=document.createElement("div");o.classList.add("lexgraphnodeheader"),o.innerText=t.title,i.appendChild(o);var n=document.createElement("div");n.classList.add("lexgraphnodeios"),i.appendChild(n);const a=t.inputs&&t.inputs.length,r=t.outputs&&t.outputs.length;if(a){const s=document.createElement("div");s.classList.add("lexgraphnodeinputs"),n.appendChild(s);for(let i of t.inputs)if(i.type){var l=document.createElement("div");l.className="lexgraphnodeio ioinput",l.dataset.index=s.childElementCount.toString(),(c=document.createElement("span")).className="io__type input "+i.type,c.dataset.type=i.type,c.innerHTML="<span>"+i.type[0].toUpperCase()+"</span>",l.appendChild(c),(h=document.createElement("span")).className="io__typedesc input "+i.type,h.innerHTML=i.type,l.appendChild(h),i.name&&e.LX.makeElement("span","io__name",i.name,l),s.appendChild(l)}else console.warn(`Missing type for node [${t.title}], skipping...`)}if(r){const e=document.createElement("div");e.classList.add("lexgraphnodeoutputs"),n.appendChild(e);for(let s of t.outputs){s.type||console.warn(`Missing type for node [${t.title}], skipping...`);var c,h,d=document.createElement("div");if(d.className="lexgraphnodeio iooutput",d.dataset.index=e.childElementCount.toString(),s.name){var u=document.createElement("span");u.classList.add("io__name"),u.innerText=s.name,d.appendChild(u)}(c=document.createElement("span")).className="io__type output "+s.type,c.dataset.type=s.type,c.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",d.appendChild(c),(h=document.createElement("span")).className="io__typedesc output "+s.type,h.innerHTML=s.type,d.appendChild(h),e.appendChild(d)}}e.LX.makeDraggable(i,{onMove:this._onMoveNodes.bind(this),onDragStart:this._onDragNode.bind(this)}),this._addNodeIOEvents(i);const p=t.id??t.title.toLowerCase().replaceAll(/\s/g,"-")+"-"+e.LX.guidGenerator();return this.nodes[p]={data:t,dom:i},t.id=p,i.dataset.id=p,this._domNodes.appendChild(i),"Main"==t.title&&(this.main=p),t.size=new Ht(i.offsetWidth,i.offsetHeight),t.resizeObserver=new ResizeObserver(e=>{for(const s of e){const e=s.contentRect;e.width&&e.height&&(t.size=new Ht(i.offsetWidth,i.offsetHeight))}}),t.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(),(r=document.createElement("span")).className="io__type input "+s.type,r.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",n.appendChild(r),(l=document.createElement("span")).className="io__typedesc input "+s.type,l.innerHTML=s.type,n.appendChild(l),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,r,l,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);(r=document.createElement("span")).className="io__type output "+s.type,r.innerHTML="<span>"+s.type[0].toUpperCase()+"</span>",c.appendChild(r),(l=document.createElement("span")).className="io__typedesc output "+s.type,l.innerHTML=s.type,c.appendChild(l),e.appendChild(c)}}this._addNodeIOEvents(e)}_addNodeIOEvents(t){const s=t.querySelector(".lexgraphnodeios");s?.querySelectorAll(".lexgraphnodeio").forEach(s=>{s.addEventListener("mousedown",i=>{i.button==e.LX.MOUSE_LEFT_CLICK&&(this._lastMouseDown=e.LX.getTime(),this._generatingLink={index:parseInt(s.dataset.index),io:s,ioType:s.classList.contains("ioinput")?Gt.NODE_IO_INPUT:Gt.NODE_IO_OUTPUT,domEl:t},i.stopPropagation(),i.stopImmediatePropagation())}),s.addEventListener("mouseup",t=>{t.stopPropagation(),t.stopImmediatePropagation(),e.LX.getTime()-this._lastMouseDown<200?delete this._generatingLink:this._generatingLink&&(this._onLink(t)||e.LX.deleteElement(this._generatingLink.path?this._generatingLink.path.parentElement:null),delete this._generatingLink)}),s.addEventListener("click",e=>{if(!s.links)return;const i=t.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 Vt(new Ht(e,o),new Ht(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 Ht(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(t){if(!this.currentGraph)return;const s=this.nodes[t],i=s.data,o=s.dom;if(console.assert(o),i.constructor.blockDelete)return void console.warn("Can't delete node!");e.LX.deleteElement(o),delete this.nodes[t];const n=this.currentGraph.nodes.findIndex(e=>e.id===t);console.assert(n>=0),this.currentGraph.nodes.splice(n,1);for(let s in this.currentGraph.links){if(!s.includes(t))continue;const i=s.indexOf("@"),o=s.substring(i+1)!=t,n=this.currentGraph.links[s].length;for(var a=0;a<n;++a){var r=this.currentGraph.links[s][a];e.LX.deleteElement(r.path.parentElement);const i=o?r.inputNode:r.outputNode,n=this._getNodeDOMElement(i).querySelector(o?".lexgraphnodeinputs":".lexgraphnodeoutputs").childNodes[o?r.inputIdx:r.outputIdx],d=o?r.outputIdx:r.inputIdx,u=n.links[d].indexOf(t);if(n.links[d].splice(u,1),o)delete n.dataset.active;else{var l=!1;for(var c of n.links)if(c)for(var h of c)l=l||!!h;l||delete n.dataset.active}}delete this.currentGraph.links[s]}}_deleteGroup(t){if(!this.currentGraph)return;const s=this.groups[t];e.LX.deleteElement(s),delete this.groups[t];const i=this.currentGraph.groups.findIndex(e=>e.id===t);console.assert(i>=0),this.currentGraph.groups.splice(i,1)}_cloneNode(t,s,i){if(!this.currentGraph)return;const o=this.graphs[s??this.currentGraph.id].getNodeById(t);if(!o)return;const n=this._getNodeDOMElement(t),a=Gt.addNode(o.type);a.properties=e.LX.deepCopy(o.properties);const r=this._createNodeDOM(a);this._translateNode(r,i??this._getNodePosition(n)),this._selectNode(r,!0),this.currentGraph.nodes.push(a)}_cloneNodes(){const t=e.LX.deepCopy(this.selectedNodes);this.unSelectAll();for(let e of t)this._cloneNode(e)}_getNodePosition(e){return new Ht(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(t,s){const i=s.classList.contains("ioinput"),o=parseInt(s.dataset.index);if(i){let i=-1;const l=s.links.filter((e,t)=>(i=t,void 0!==e))[0][0];if(!l)return;var n=(r=this._getLinks(l,t)).findIndex(e=>e.inputIdx==o&&e.outputIdx==i);e.LX.deleteElement(r[n].path.parentElement),r.splice(n,1),delete s.links,delete s.dataset.active;const c=this._getNodeDOMElement(l).querySelector(".lexgraphnodeoutputs").childNodes[i],h=c.links[o].findIndex(e=>e==t);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 l=i.length-1;l>=0;--l){const c=i[l];var r;n=(r=this._getLinks(t,c)).findIndex(e=>e.inputIdx==a&&e.outputIdx==o);e.LX.deleteElement(r[n].path.parentElement),r.splice(n,1),s.links[a].splice(l,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(t){if(!this.currentGraph)return;const s=this.root.getBoundingClientRect();this._mousePosition=new Ht(t.clientX-s.x,t.clientY-s.y);const i=new Ht(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"==t.type)this._lastMouseDown=e.LX.getTime(),this._processMouseDown(t);else if("mouseup"==t.type)e.LX.getTime()-this._lastMouseDown<200&&this._processClick(t),this._processMouseUp(t);else if("mousemove"==t.type)this._processMouseMove(t);else if("click"==t.type)switch(t.detail){case e.LX.MOUSE_DOUBLE_CLICK:case e.LX.MOUSE_TRIPLE_CLICK:}else"mousewheel"==t.type?(t.preventDefault(),this._processWheel(t)):"contextmenu"==t.type?(t.preventDefault(),e.LX.getTime()-this._lastMouseDown<300&&this._processContextMenu(t)):"mouseleave"==t.type&&this._generatingLink&&this._processMouseUp(t);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(t){const s=t.target;s.classList.contains("lexgraphnode")||s.classList.contains("lexgraphgroup")||t.button!=e.LX.MOUSE_LEFT_CLICK||(this._boxSelecting=this._mousePosition,this._boxSelectRemoving=t.altKey)}_processMouseUp(t){if(this._generatingLink){const s=Object.assign({},this._generatingLink);e.LX.deleteElement(this._generatingLink.path?this._generatingLink.path.parentElement:null),delete this._generatingLink,this._processContextMenu(t,s)}else this._boxSelecting&&(t.ctrlKey||t.altKey||this.unSelectAll(),this._selectNodesInBox(this._boxSelecting,this._mousePosition,t.altKey),e.LX.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(t){if(this._boxSelecting||!this.currentGraph)return;const s=this.root.getBoundingClientRect(),i=this._mousePosition??new Ht(.5*s.width,.5*s.height),o=this._getPatternPosition(i),n=t.deltaY;this.currentGraph.scale*=n>0?.9:1/.9,this.currentGraph.scale=e.LX.clamp(this.currentGraph.scale,Gt.MIN_SCALE,Gt.MAX_SCALE);const a=this._getPatternPosition(i).sub(o);this.currentGraph.translation.add(a,this.currentGraph.translation),this._updatePattern()}_processContextMenu(t,s){this.currentGraph&&e.LX.addContextMenu(null,t,e=>{var i=null;if(t){const e=this.root.getBoundingClientRect(),s=new Ht(t.clientX-e.x,t.clientY-e.y);i=this._getPatternPosition(s)}this._clipboardData&&(e.add("Paste",()=>{const e=this._clipboardData.id,t=this._clipboardData.gid;this._cloneNode(e,t,i)}),e.add(""));for(let t in Gt.NODE_TYPES){Gt.NODE_TYPES[t].blockAdd||e.add(t,()=>{const e=Gt.addNode(t),o=this._createNodeDOM(e);if(this._snapToGrid&&(o.mustSnap=!0),i&&this._translateNode(o,i),this.currentGraph?.nodes.push(e),s&&e.inputs.length){const t=s.domEl.dataset.id,i=s.io.childNodes[s.index].dataset.type,o=s.ioType==Gt.NODE_IO_INPUT,n={inputNode:o?t:e.id,inputIdx:o?s.index:0,inputType:o?i:e.inputs[0].type,outputNode:o?e.id:t,outputIdx:o?0:s.index,outputType:o?e.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=Gt.RUNNING,this.propagateEventToAllNodes("onStart"),requestAnimationFrame(this._frame.bind(this))}stop(){this.mustStop=!0,this.state=Gt.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,r=n-n*this.currentGraph.scale,l=a-a*this.currentGraph.scale;this._domNodes.style.transform="\n translate("+(s.x-r)+"px, "+(s.y-l)+"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")?Gt.NODE_IO_INPUT:Gt.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,r=this.nodes[a].data,l=parseInt(e.target.parentElement.dataset.index),c=t.ioType==Gt.NODE_IO_INPUT,h=o[c?"inputs":"outputs"][n].type,d=r[s==Gt.NODE_IO_INPUT?"inputs":"outputs"][l].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==Gt.NODE_IO_INPUT&&e.target.parentElement.dataset.active?this._deleteLinks(a,e.target.parentElement):t.ioType==Gt.NODE_IO_INPUT&&t.io.dataset.active&&this._deleteLinks(i,t.io);var u=t.io;u.links=u.links??[],u.links[l]=u.links[l]??[],u.links[l].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:l,inputType:c?h:d,outputNode:c?a:i,outputIdx:c?l:n,outputType:c?d:h}),m.dataset.id=g,t.io.dataset.active=!0,e.target.parentElement.dataset.active=!0,!0}_updatePreviewLink(t,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,r=this._generatingLink.domEl,l=this.root.getBoundingClientRect().x,c=this.root.getBoundingClientRect().y,h=r.querySelector(a==Gt.NODE_IO_INPUT?".lexgraphnodeinputs":".lexgraphnodeoutputs").childNodes[n].querySelector(".io__type"),d=h.getBoundingClientRect();let u=new Ht(d.x-l,d.y-c),p=null,m=null;if(t){if(p=new Ht(t.offsetX,t.offsetY),e.LX.hasClass(t.target,["lexgraphnode","lexgraphgroup"]))p.add(this._getNodePosition(t.target),p),p.add(new Ht(3,3),p);else if(e.LX.hasClass(t.target,["io__type","lexgraphgroupresizer"])){var g=t.target.offsetParent;p.add(this._getNodePosition(g),p),p.add(new Ht(t.target.offsetLeft,t.target.offsetTop),p),p.add(new Ht(3,3),p)}p=this._getRenderPosition(p)}else{m=s.querySelector(".io__type");const e=m.getBoundingClientRect();p=new Ht(e.x-l,e.y-c)}if(a==Gt.NODE_IO_INPUT){var f=p;p=u,u=f}let C=getComputedStyle(h).backgroundColor;return a==Gt.NODE_IO_OUTPUT&&m&&(C=getComputedStyle(m).backgroundColor),this._createLinkPath(i,u,p,C,!!t),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,r=o.querySelector(".lexgraphnodeoutputs").childNodes[e.outputIdx],l=r.querySelector(".io__type").getBoundingClientRect();let c=new Ht(l.x-n,l.y-a+6);const h=i.querySelector(".lexgraphnodeinputs").childNodes[e.inputIdx],d=h.querySelector(".io__type").getBoundingClientRect();let u=new Ht(d.x-n,d.y-a+6);const p=getComputedStyle(h.querySelector(".io__type")).backgroundColor;this._createLinkPath(s,c,u,p),e.path=s,r.links=[],r.links[e.inputIdx]=r.links[e.inputIdx]??[],r.links[e.inputIdx].push(e.inputNode),h.links=[],h.links[e.outputIdx]=h.links[e.outputIdx]??[],h.links[e.outputIdx].push(e.outputNode),r.dataset.active=!0,h.dataset.active=!0}_createLinkPath(t,s,i,o,n=!1){if(!this.currentGraph)return;const a=6*this.currentGraph.scale;s.add(new Ht(a,a),s),n||i.add(new Ht(a,a),i),s=this._getPatternPosition(s),i=this._getPatternPosition(i);const r=e.LX.clamp(Math.abs(s.x-i.x),0,256),l=128*Math.pow(r/256,.5);let c=s.add(new Ht(l,0)),h=i.sub(new Ht(l,0));t.setAttribute("d",`\n M ${s.x},${s.y}\n C ${c.x},${c.y} ${h.x},${h.y} ${i.x},${i.y}\n `),t.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:Gt.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 r of a){s=this._getLinks(e,r).find(e=>e.inputIdx==n&&e.outputIdx==o);this._generatingLink={index:s.outputIdx,io:i,ioType:Gt.NODE_IO_OUTPUT,domEl:t,path:s.path};const a=this._getNodeDOMElement(r).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 Vt(new Ht(0,0),new Ht(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 Vt(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 Ht(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 Vt(new Ht(t,s),new Ht(e.offsetWidth-2,e.offsetHeight-2))}_getBoundingFromNodes(e){let t=null;for(let s of e){const e=this.nodes[s].data,i=new Vt(e.position,e.size);t?t.merge(i):t=i}if(t){const e=8;t.origin.sub(new Ht(e),t.origin),t.origin.sub(new Ht(e),t.origin),t.size.add(new Ht(2*e),t.size),t.size.add(new Ht(2*e),t.size)}return t}_createGroup(t){const s=t??this._getBoundingFromNodes(this.selectedNodes);if(!s)return;const i=s.id??`group-${e.LX.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",l),t.addEventListener("mouseup",c),r[0]=e.x,r[1]=e.y,e.stopPropagation(),e.preventDefault(),document.body.classList.add("nocursor"),n.classList.add("nocursor")}),this.groups[i]=o;var a=this,r=[0,0];function l(e){let t=new Ht(r[0]-e.x,r[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",r[0]=e.x,r[1]=e.y,e.stopPropagation(),e.preventDefault()}function c(e){var t=a.root.ownerDocument;t.removeEventListener("mousemove",l),t.removeEventListener("mouseup",c),document.body.classList.remove("nocursor"),n.classList.remove("nocursor")}let h=document.createElement("input"),d=`Group ${Gt.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",t=>{t.button==e.LX.MOUSE_LEFT_CLICK&&(h.disabled=!1,h.focus())}),o.addEventListener("contextmenu",t=>{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),e.LX.addContextMenu(null,t,e=>{e.add("Delete",()=>{this._deleteGroup(i)})})}),o.appendChild(n),o.appendChild(h),this._domNodes.prepend(o),e.LX.makeDraggable(o,{onMove:this._onMoveGroup.bind(this),onDragStart:this._onDragGroup.bind(this),updateLayers:!1}),Gt.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(t){new e.LX.DropdownMenu(t.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 t=new e.LX.Dialog(this.currentGraph.constructor.name,e=>{e.addText("Name",this.currentGraph?.name,e=>{this._updateGraphName(e),t.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=Gt.NODE_TYPES[o];n&&(delete Gt.NODE_TYPES[o],n.title=e,Gt.registerCustomNode("function/"+e,n)),this.currentGraph.name=e}_addGlobalActions(){}}e.LX.GraphEditor=Gt;class qt{name="Unnamed Graph";type="Graph";id="";editor;nodes=[];groups=[];variables={};links={};scale=1;translation=new Ht(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=Gt.addNode(t.type);e.id=t.id,e.title=t.title,e.color=t.color,e.position=new Ht(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(t=!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 t in this.links){const i=e.LX.deepCopy(this.links[t]);i.forEach(e=>delete e.path),s.links[t]=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,t?2:void 0)}catch(e){s=null,console.error(`Can't export Graph [${this.name}] of type [${this.type}].`)}return s}export(){const t=this.serialize();e.LX.downloadFile(this.name+".json",t)}}e.LX.Graph=qt;class Kt{static title;static blockDelete=!1;static blockAdd=!1;static description="";id="";type="";title="";inputs=[];outputs=[];properties=[];position=new Ht(0,0);size=new Ht(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(t,s){if(!this.outputs||!this.outputs.length||!this.outputs[t])return;const i=this.editor?.graphs[this.graphID];for(let a in i.links){if(a.indexOf(this.id+"@")<0)continue;const r=i.links[a];for(var o of r){if(o.outputIdx!=t)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(e.LX.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}}e.LX.GraphNode=Kt;class Wt extends qt{constructor(e,t={}){super(),this.name=e??"GraphFunction"+Gt.LAST_FUNCTION_ID,this.type="GraphFunction",Gt.LAST_FUNCTION_ID++;const s=Gt.addNode("function/Input");s.position=new Ht(150,250);const i=Gt.addNode("function/Output");i.position=new Ht(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)}}e.LX.GraphFunction=Wt;class Ut extends Kt{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})}}Ut.blockDelete=!0,Ut.blockAdd=!0,Gt.registerCustomNode("function/Input",Ut);class Yt extends Kt{onCreate(){this.addInput(null,"any")}onExecute(){}}Yt.blockDelete=!0,Yt.blockAdd=!0,Gt.registerCustomNode("function/Output",Yt);class jt extends Kt{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)}}jt.description="Addition of 2 values (A+B).",Gt.registerCustomNode("math/Add",jt);class Zt extends Kt{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)}}Zt.description="Substraction of 2 values (A-B).",Gt.registerCustomNode("math/Substract",Zt);class Qt extends Kt{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)}}Qt.description="Multiplication of 2 values (A*B).",Gt.registerCustomNode("math/Multiply",Qt);class Jt extends Kt{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)}}Jt.description="Division of 2 values (A/B).",Gt.registerCustomNode("math/Divide",Jt);class es extends Kt{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))}}es.description="Square root of a scalar.",Gt.registerCustomNode("math/SQRT",es);Gt.registerCustomNode("logic/And",class extends Kt{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)}});Gt.registerCustomNode("logic/Or",class extends Kt{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 ts extends Kt{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))}}Gt.registerCustomNode("logic/Equal",ts);Gt.registerCustomNode("logic/NotEqual",class extends ts{logicOp(e,t){return e!=t}});Gt.registerCustomNode("logic/Less",class extends ts{logicOp(e,t){return e<t}});Gt.registerCustomNode("logic/LessEqual",class extends ts{logicOp(e,t){return e<=t}});Gt.registerCustomNode("logic/Greater",class extends ts{logicOp(e,t){return e>t}});Gt.registerCustomNode("logic/GreaterEqual",class extends ts{logicOp(e,t){return e>=t}});Gt.registerCustomNode("logic/Select",class extends Kt{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 ss extends Kt{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)}}}ss.description="Compare A to B given the selected operator. If true, return value of True else return value of False.",Gt.registerCustomNode("logic/Compare",ss);Gt.registerCustomNode("events/KeyDown",class extends Kt{onCreate(){this.addOutput(null,"bool"),this.addProperty("Key","string"," ")}onExecute(){this.setOutput(0,!!this.editor?.keys[this.properties[0].value])}});Gt.registerCustomNode("inputs/String",class extends Kt{onCreate(){this.addOutput(null,"string"),this.addProperty(null,"string","text")}onExecute(){this.setOutput(0,this.properties[0].value)}});Gt.registerCustomNode("inputs/Float",class extends Kt{onCreate(){this.addOutput(null,"float"),this.addProperty(null,"float",0)}onExecute(){this.setOutput(0,this.properties[0].value)}});Gt.registerCustomNode("inputs/Vector2",class extends Kt{onCreate(){this.addOutput("Value","vec2"),this.addProperty("Value","vec2",[0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});Gt.registerCustomNode("inputs/Vector3",class extends Kt{onCreate(){this.addOutput("Value","vec3"),this.addProperty("Value","vec3",[0,0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});Gt.registerCustomNode("inputs/Vector4",class extends Kt{onCreate(){this.addOutput("Value","vec4"),this.addProperty("Value","vec4",[0,0,0,0])}onExecute(){this.setOutput(0,this.properties[0].value)}});class is extends Kt{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))}}}is.title="Set Variable",Gt.registerCustomNode("variables/SetVariable",is);class os extends Kt{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)}}}os.title="Get Variable",Gt.registerCustomNode("variables/GetVariable",os);class ns extends Kt{onCreate(){this.addInput(null,"any")}onExecute(){var e=this.getInput(0);null!=e&&console.log(e)}}ns.title="Console Log",Gt.registerCustomNode("system/ConsoleLog",ns);class as extends Kt{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(as.blockDelete=!0,Gt.registerCustomNode("system/Main",as),!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("ImUI");const rs=e.LX.vec2;class ls{root;canvas;components={};mouseDown=!1;mousePosition=new rs;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(t,s,i,o){const n=this.canvas.getContext("2d");n.font="16px Arial";let a=new e.LX.vec2(12,8),r=new e.LX.vec2(s,i);const l=n.measureText(t);let c=new e.LX.vec2(l.width,l.actualBoundingBoxAscent+l.actualBoundingBoxDescent);const h=this.mousePosition.x>=r.x&&this.mousePosition.x<=r.x+c.x+2*a.x&&this.mousePosition.y>=r.y&&this.mousePosition.y<=r.y+c.y+2*a.y,d=h&&this.mouseDown;return n.beginPath(),n.fillStyle=d?"#666":h?"#444":"#222",n.roundRect(r.x,r.y,c.x+2*a.x,c.y+2*a.y,[8,8,8,8]),n.fill(),n.fillStyle=h?"#fff":"#ddd",n.fillText(t,r.x+a.x,r.y+l.actualBoundingBoxAscent+a.y),this.usePointerCursor=this.usePointerCursor||h,!!this.eventClick&&(o&&o(),!0)}Slider(t,s,i,o=0,n){const a=this.canvas.getContext("2d");this.components[t]?o=this.components[t].value:this.components[t]={value:o};a.font="16px Arial";let r=new e.LX.vec2(12,8),l=new e.LX.vec2(s,i);const c=a.measureText(t);let h=new e.LX.vec2(c.width,c.actualBoundingBoxAscent+c.actualBoundingBoxDescent),d=h.add(r.mul(2));const u=this.mousePosition.x>=l.x&&this.mousePosition.x<=l.x+d.x&&this.mousePosition.y>=l.y&&this.mousePosition.y<=l.y+d.y,p=u&&this.mouseDown;a.beginPath(),a.fillStyle=u?"#444":"#222",a.roundRect(l.x,l.y,d.x,d.y,[8,8,8,8]),a.fill();const m=l.x,g=l.x+d.x;p&&(o=e.LX.clamp((this.mousePosition.x-m)/(g-m),0,1),this.components[t].value=o);let f=new e.LX.vec2(d.x*o,h.y);a.beginPath(),a.fillStyle=u?"#6074e7":"#3e57e4",f.x>d.x-8?(a.roundRect(l.x,l.y,f.x,f.y+2*r.y,[8,8,8,8]),a.fill()):a.fillRect(l.x,l.y,f.x,f.y+2*r.y),a.fillStyle=u?"#fff":"#ddd",a.fillText(t,l.x+r.x,l.y+c.actualBoundingBoxAscent+r.y),this.usePointerCursor=this.usePointerCursor||u,p&&n&&n(o)}Checkbox(t,s,i,o=!1,n){const a=this.canvas.getContext("2d");this.components[t]?o=this.components[t].value:this.components[t]={value:o};a.font="16px Arial";let r=new e.LX.vec2(12,8),l=new e.LX.vec2(s,i);const c=a.measureText(t);let h=new e.LX.vec2(c.width,c.actualBoundingBoxAscent+c.actualBoundingBoxDescent),d=new e.LX.vec2(24,0);d.add(h,d);const u=l.x+h.x+r.x+12,p=l.y+r.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(l.x,l.y,d.x+2*r.x,d.y+2*r.y),f&&(o=!o,this.components[t].value=o,n&&n(o)),a.fillStyle=o?g?"#ddd":m?"#6074e7":"#3e57e4":g?"#bbb":m?"#777":"#888",a.fillRect(l.x+h.x+r.x+12,l.y+r.y,h.y,h.y),a.fillStyle=m?"#fff":"#ddd",a.fillText(t,l.x+r.x,l.y+c.actualBoundingBoxAscent+r.y),this.usePointerCursor=this.usePointerCursor||m}endFrame(){delete this.eventClick,document.body.style.cursor=this.usePointerCursor?"pointer":"default",this.usePointerCursor=!1}}if(e.LX.ImUI=ls,!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("Timeline"),e.LX.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>'),e.LX.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 cs=e.LX.Area,hs=e.LX.Panel,ds=e.LX.Dialog;class us{static BACKGROUND_COLOR;static TRACK_COLOR_PRIMARY;static TRACK_COLOR_SECONDARY;static TRACK_COLOR_TERTIARY;static TRACK_SELECTED;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;trackTreesEvents={};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;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(t,s={}){this.uniqueID=t??"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 cs({className:"lextimeline"}),this.root=this.mainArea.root,this.mainArea.split({type:"vertical",sizes:[this.header_offset,"auto"],resize:!1}),this.header=new hs({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(){us.BACKGROUND_COLOR=e.LX.getCSSVariable("background-blur"),us.TRACK_COLOR_PRIMARY=e.LX.getCSSVariable("card"),us.TRACK_COLOR_SECONDARY=e.LX.getCSSVariable("secondary"),us.TRACK_COLOR_TERTIARY=e.LX.getCSSVariable("accent"),us.TRACK_SELECTED=e.LX.getCSSVariable("primary"),us.FONT=e.LX.getCSSVariable("global-font"),us.FONT_COLOR_PRIMARY=e.LX.getCSSVariable("foreground"),us.FONT_COLOR_TERTIARY=e.LX.getCSSVariable("primary"),us.FONT_COLOR_QUATERNARY=e.LX.getCSSVariable("muted-foreground"),us.KEYFRAME_COLOR=e.LX.getCSSVariable("lxTimeline-keyframe"),us.KEYFRAME_COLOR_SELECTED=us.KEYFRAME_COLOR_HOVERED=e.LX.getCSSVariable("lxTimeline-keyframe-selected"),us.KEYFRAME_COLOR_LOCK=e.LX.getCSSVariable("lxTimeline-keyframe-locked"),us.KEYFRAME_COLOR_EDITED=e.LX.getCSSVariable("lxTimeline-keyframe-edited"),us.KEYFRAME_COLOR_INACTIVE=e.LX.getCSSVariable("lxTimeline-keyframe-inactive"),us.TIME_MARKER_COLOR=e.LX.getCSSVariable("primary"),us.TIME_MARKER_COLOR_TEXT=e.LX.getCSSVariable("primary-foreground")}.bind(this),e.LX.addSignal("@on_new_color_scheme",this.updateTheme),this.updateTheme()}clear(){if(this.header&&this.header.clear(),this.leftPanel&&this.leftPanel.clear(),this.updateTheme){let t=e.LX.signals["@on_new_color_scheme"]??[];for(let e=0;e<t.length;++e)t[e]==this.updateTheme&&t.splice(e,1)}}updateHeader(){this.header.clear();const t=this.header;t.sameLine(),this.timelineTitle&&t.addTitle(this.timelineTitle,{style:{background:"none",fontSize:"18px",fontStyle:"bold",alignItems:"center"}});const s=e.LX.makeContainer(["auto","100%"],"flex flex-row gap-1");t.queue(s);t.addButton("playBtn","",(e,t)=>{this.changeState()},{buttonClass:"accept",title:"Play",hideName:!0,icon:"Play@solid",swap:"Pause@solid"}).setState(this.playing,!0),t.addButton("stopBtn","",(e,t)=>{this.setState(!1,!0),this.onStateStop&&this.onStateStop()},{buttonClass:"accept",title:"Stop",hideName:!0,icon:"Stop@solid"}),t.addButton("loopBtn","",(e,t)=>{this.setLoopMode(!this.loop)},{selectable:!0,selected:this.loop,title:"Loop",hideName:!0,icon:"RefreshCw",buttonClass:"h-8"}),this.onCreateControlsButtons&&this.onCreateControlsButtons(t),t.clearQueue(s),t.addContent("header-buttons",s),this.onCreateBeforeTopBar&&this.onCreateBeforeTopBar(t),t.addNumber("Current Time",this.currentTime,(e,t)=>{this.setTime(e)},{units:"s",step:.01,min:0,precision:3,skipSlider:!0,skipReset:!0,nameWidth:"auto"}),t.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(t);const i=e.LX.makeContainer(["auto","100%"],"flex flex-row gap-1");t.queue(i),this.onCreateSettingsButtons&&this.onCreateSettingsButtons(t),this.onShowOptimizeMenu&&t.addButton(null,"",(e,t)=>{this.onShowOptimizeMenu&&this.onShowOptimizeMenu(t)},{tooltip:!0,title:"Optimize",icon:"Filter"}),this.onShowConfiguration&&t.addButton(null,"",(e,t)=>{if(this.configurationDialog)return this.configurationDialog.close(),void(this.configurationDialog=null);this.configurationDialog=new ds("Configuration",e=>{this.onShowConfiguration&&this.onShowConfiguration(e)},{onBeforeClose:()=>{this.configurationDialog.panel.clear(),this.configurationDialog=null}})},{title:"Settings",icon:"Settings",tooltip:!0}),t.clearQueue(i),t.addContent("header-buttons-end",i),t.endLine("justify-between")}setTrackTreeEventListener(e,t){this.trackTreesEvents[e]=t,"select"!=e&&"visibleChanged"!=e&&this.trackTreesComponent.on(e,this.trackTreesEvents[e])}updateLeftPanel(){this.leftPanel.clear();const t=this.leftPanel;t.sameLine();let s=t.addTitle("Tracks",{style:{background:"none"},className:"text-lg px-4"}).root;this.disableNewTracks||t.addButton("addTrackBtn","",(e,t)=>{this.onAddNewTrackButton?this.onAddNewTrackButton():this.addNewTrack()},{hideName:!0,title:"Add Track",icon:"Plus"}),t.endLine();const i=window.getComputedStyle(s),o=s.clientHeight+parseFloat(i.marginTop)+parseFloat(i.marginBottom);let n=new e.LX.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}),this.trackTreesComponent.on("select",(e,t)=>{const s=e.items[0];if(e.domEvent.shiftKey||this.deselectAllTracks(!1),s.trackData){const t=!e.domEvent.shiftKey||!s.trackData.isSelected;this.setTrackSelection(s.trackData.trackIdx,t,!1,!1)}this.trackTreesEvents.select&&this.trackTreesEvents.select(e)}),this.trackTreesComponent.on("visibleChanged",(e,t)=>{const s=e.items[0];s.trackData&&this.setTrackState(s.trackData.trackIdx,s.visible,!1,!1),this.trackTreesEvents.visibleChanged&&this.trackTreesEvents.visibleChanged(e)});for(let e in this.trackTreesEvents)this.setTrackTreeEventListener(e,this.trackTreesEvents[e]);const r=this;this.trackTreesComponent.innerTree._refresh=this.trackTreesComponent.innerTree.refresh,this.trackTreesComponent.innerTree.refresh=function(e,t){this._refresh(e,t),r.setTrackHeight(r.trackHeight)},this.selectedTracks.length&&this._updateTrackTreeSelection(),this.trackTreesComponent.name="tracksTrees",n.components[this.trackTreesComponent.name]=this.trackTreesComponent,this.trackTreesPanel=n,t.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)),r=Math.min(i.length-1,Math.floor(n/this.trackHeight))+1;for(let e=a;e<r;++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 "+us.FONT,s.textAlign="center",s.save(),s.fillStyle=us.BACKGROUND_COLOR,s.fillRect(0,0,this.canvas.width,t),s.strokeStyle=us.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 r=this.timeToX(n+i)-this.timeToX(n),l=o*r/i,c=this.timeToX(Math.floor(n/i)*i);c+=1e-7;let h=this.timeToX(a);s.beginPath(),s.fillStyle=us.FONT_COLOR_PRIMARY,s.globalAlpha=1;for(let e=c;e<=h;e+=r){s.moveTo(Math.round(e)+.5,.4*t+.3*t),s.lineTo(Math.round(e)+.5,.95*t);let o=e+r-.5*l;for(let i=e;i<o&&i<h;i+=l)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,r=this.trackHeight;e=e||s.width;let l=Math.ceil((t-n)/r)+1;i.save(),i.fillStyle=us.TRACK_COLOR_SECONDARY;const c=this.currentScrollInPixels%r;for(let t=Math.floor(this.currentScrollInPixels/r)%2;t<=l;t+=2)i.fillRect(0,a-c+t*r,e,r);i.strokeStyle=us.TRACK_COLOR_TERTIARY,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 "+us.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.children[0].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=us.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?us.FONT_COLOR_TERTIARY:us.FONT_COLOR_QUATERNARY;let i=Math.max(10,(s-this.topMargin)*(s-this.topMargin)/this.trackTreesPanel.root.scrollHeight);gs(e,t-10,this.currentScroll*(s-this.topMargin-i)+this.topMargin,10,i,5,!0)}this.drawTimeInfo(t);let r=Math.round(this.timeToX(this.currentTime)),l=.4*this.topMargin;r>=0&&(e.strokeStyle=e.fillStyle=us.TIME_MARKER_COLOR,e.globalAlpha=1,e.beginPath(),e.moveTo(r,.6*l),e.lineTo(r,this.canvas.height),e.stroke(),e.closePath(),e.shadowBlur=8,e.shadowColor=us.TIME_MARKER_COLOR,e.shadowOffsetX=1,e.shadowOffsetY=1,gs(e,r-10,.6*l,20,l,5,!0),e.fill(),e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.font="11px "+us.FONT,e.textAlign="center",e.fillStyle=us.TIME_MARKER_COLOR_TEXT,e.fillText((.1*Math.floor(10*this.currentTime)).toFixed(1),r,.6*this.topMargin),e.strokeStyle=e.fillStyle=us.FONT_COLOR_PRIMARY,this.boxSelection&&(e.globalAlpha=.15,e.fillStyle=us.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(t){if(!this.canvas)return;let s=this.canvas.height,i=this.canvas.width,o=t.offsetX,n=t.offsetY;t.deltax=o-this.lastMouse[0],t.deltay=n-this.lastMouse[1];let a=t.offsetX,r=t.offsetY,l=this.timeToX(this.currentTime),c=r<this.topMargin&&a>l-6&&a<l+6;const h=this.xToTime(o);if(c?this.canvas.style.cursor="col-resize":this.movingKeys?this.canvas.style.cursor="grabbing":t.shiftKey?this.canvas.style.cursor="crosshair":this.canvas.style.cursor="default","wheel"==t.type){if(t.shiftKey){if(t.wheelDelta){let e=this.xToTime(a);this.setScale(this.pixelsPerSecond*(t.wheelDelta<0?.95:1.05)),this.visualOriginTime=e-a*this.secondsPerPixel}}else s-this.topMargin<this.trackTreesComponent.root.scrollHeight&&(this.trackTreesPanel.root.scrollTop+=t.deltaY);return void(this.onMouse&&this.onMouse(t,h))}const d=o>=0&&o<=this.size[0]&&n>=0&&n<=this.size[1];let u=this.getTracksInRange(r,r);if(u=u.length?u[0]:null,t.track=u,t.localX=a,t.localY=r,"mouseup"==t.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||e.LX.getTime()-this.clickTime>this.clickDiscardTimeout;t.discard=s,this.grabbingScroll||this.grabbingTimeBar||0!=t.button||!this.onMouseUp||this.onMouseUp(t,h),this.grabbing=!1,this.grabbingTimeBar=!1,this.grabbingScroll=!1,this.movingKeys=!1,this.timeBeforeMove=0,this.boxSelection=!1}if("mousedown"==t.type){if(window.getSelection()?.empty(),this.clickTime=e.LX.getTime(),t.shiftKey&&this.active)return this.boxSelection=!0,this.boxSelectionEnd[0]=this.boxSelectionStart[0]=a,void(this.boxSelectionEnd[1]=this.boxSelectionStart[1]=r);t.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(t,h))}else if("mousemove"==t.type){if(t.shiftKey&&this.active&&this.boxSelection)return this.boxSelectionEnd[0]=a,void(this.boxSelectionEnd[1]=r);if(this.grabbing&&2!=t.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*t.deltay/(s-this.topMargin);else{var p=this.xToTime(this.lastMouse[0]),m=this.xToTime(t.offsetX);this.visualOriginTime+=p-m,this.trackTreesPanel.root.scrollTop-=t.deltay}this.onMouseMove&&this.onMouseMove(t,h)}else"dblclick"==t.type&&this.onDblClick?this.onDblClick(t):"contextmenu"==t.type&&this.onShowContextMenu&&this.active&&this.onShowContextMenu(t);return this.lastMouse[0]=o,this.lastMouse[1]=n,!(d||this.grabbing||t.metaKey||t.altKey)||(this.onMouse&&this.onMouse(t,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}}}us.BACKGROUND_COLOR=e.LX.getCSSVariable("background-blur"),us.TRACK_COLOR_PRIMARY=e.LX.getCSSVariable("card"),us.TRACK_COLOR_SECONDARY=e.LX.getCSSVariable("secondary"),us.TRACK_COLOR_TERTIARY=e.LX.getCSSVariable("accent"),us.TRACK_SELECTED=e.LX.getCSSVariable("primary"),us.FONT=e.LX.getCSSVariable("global-font"),us.FONT_COLOR_PRIMARY=e.LX.getCSSVariable("foreground"),us.FONT_COLOR_TERTIARY=e.LX.getCSSVariable("primary"),us.FONT_COLOR_QUATERNARY=e.LX.getCSSVariable("muted-foreground"),us.TIME_MARKER_COLOR=e.LX.getCSSVariable("primary"),us.TIME_MARKER_COLOR_TEXT=e.LX.getCSSVariable("primary-foreground"),e.LX.setCSSVariable("lxTimeline-keyframe","light-dark(#2d69da,#2d69da )"),e.LX.setCSSVariable("lxTimeline-keyframe-selected","light-dark(#f5c700,#fafa14)"),e.LX.setCSSVariable("lxTimeline-keyframe-hovered","light-dark(#f5c700,#fafa14)"),e.LX.setCSSVariable("lxTimeline-keyframe-locked","light-dark(#c62e2e,#ff7d7d )"),e.LX.setCSSVariable("lxTimeline-keyframe-edited","light-dark(#00d000,#00d000 )"),e.LX.setCSSVariable("lxTimeline-keyframe-inactive","light-dark(#706b6b,#706b6b)"),us.KEYFRAME_COLOR=e.LX.getCSSVariable("lxTimeline-keyframe"),us.KEYFRAME_COLOR_SELECTED=us.KEYFRAME_COLOR_HOVERED=e.LX.getCSSVariable("lxTimeline-keyframe-selected"),us.KEYFRAME_COLOR_LOCK=e.LX.getCSSVariable("lxTimeline-keyframe-locked"),us.KEYFRAME_COLOR_EDITED=e.LX.getCSSVariable("lxTimeline-keyframe-edited"),us.KEYFRAME_COLOR_INACTIVE=e.LX.getCSSVariable("lxTimeline-keyframe-inactive"),us.BOX_SELECTION_COLOR="#AAA",e.LX.Timeline=us;class ps extends us{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(t,s={}){super(t,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=t=>{0!=this.selectedItems.length&&e.LX.addContextMenu("Optimize",t,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=t=>{t.preventDefault(),t.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(!t.track)return;const e=new Float32Array(t.track.dim);e.fill(0),this.addKeyFrames(t.track.trackIdx,e,[this.xToTime(t.localX)])}}),s.push({title:"Add",callback:()=>{if(!t.track)return;const e=new Float32Array(t.track.dim);e.fill(0),this.addKeyFrames(t.track.trackIdx,e,[this.currentTime])}})),this.clipboard&&this.clipboard.keyframes&&(s.push({title:"Paste Here",callback:()=>{this.pasteContent(this.xToTime(t.localX))}}),s.push({title:"Paste",callback:()=>{this.pasteContent(this.currentTime)}})),e.LX.addContextMenu("Options",t,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],r=a.times??[],l=a.values??[],c=a.dim;(!c||c<0)&&(c=r.length&&l.length?Math.round(l.length/r.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,r]=this.lastKeyFramesSelected[o];if(i=e[n],i&&i.locked)continue;this.canvas.style.cursor="grabbing";const l=this.animationClip.tracks[i.trackIdx].times;l[a]=Math.max(0,l[a]+t),l[a]>this.duration&&this.setDuration(l[a]);let c=a;if(t>0)for(;c<l.length-1&&!(l[c]<l[c+1]);++c)this.swapKeyFrames(i,c+1,c);else for(;c>0&&!(l[c-1]<l[c]);--c)this.swapKeyFrames(i,c-1,c);this.lastKeyFramesSelected[o][1]=c,this.lastKeyFramesSelected[o][2]=l[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,r]=this.lastKeyFramesSelected[o];if(i=t[n],i.locked||1!=i.dim||!i.curves)continue;let l=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],l-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=us.TRACK_SELECTED,e.fillRect(0,0,e.canvas.width,t)),e.fillStyle=us.KEYFRAME_COLOR,e.globalAlpha=1;const i=s.times,o=this.visualTimeRange[0],n=this.visualTimeRange[1]+1e-7,a=this.keyframeSize/Math.SQRT2,r=this.keyframeSizeHovered/Math.SQRT2;for(let l=0;l<i.length;++l){let c=i[l];if(c<o||c>n)continue;let h=this.timeToX(c),d=a;this.active&&0!=s.active?s.locked?e.fillStyle=us.KEYFRAME_COLOR_LOCK:s.hovered[l]?(d=r,e.fillStyle=us.KEYFRAME_COLOR_HOVERED):s.selected[l]?e.fillStyle=us.KEYFRAME_COLOR_SELECTED:s.edited[l]?e.fillStyle=us.KEYFRAME_COLOR_EDITED:e.fillStyle=us.KEYFRAME_COLOR:e.fillStyle=us.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(t,s,i){i.isSelected&&(t.globalAlpha=.2,t.fillStyle=us.TRACK_SELECTED,t.fillRect(0,0,t.canvas.width,s)),t.globalAlpha=1;const o=i.times,n=i.values,a=.5*this.keyframeSize,r=.5*this.keyframeSizeHovered,l=i.curvesRange,c=s-2*a,h=this.visualTimeRange[0],d=this.visualTimeRange[1]+1e-7;if(t.strokeStyle=ps.FONT_COLOR_PRIMARY,t.beginPath(),o.length>1){let i=this.timeToX(o[0]),r=n[0];r=e.LX.clamp((r-l[0])/(l[1]-l[0]),0,1)*-c+(s-a),t.moveTo(i,r);for(let i=1;i<o.length;++i){let r=o[i],u=this.timeToX(r),p=n[i];if(p=e.LX.clamp((p-l[0])/(l[1]-l[0]),0,1)*-c+(s-a),r<h)t.moveTo(u,p);else{if(r>d){let r=this.timeToX(o[i-1]),h=u-r;if(h>0){let o=n[i-1];o=e.LX.clamp((o-l[0])/(l[1]-l[0]),0,1)*-c+(s-a);let u=(this.timeToX(d)-r)/h;t.lineTo(r+h*u,o*(1-u)+p*u)}break}t.lineTo(u,p)}}t.stroke()}t.fillStyle=us.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?t.fillStyle=us.KEYFRAME_COLOR_LOCK:i.hovered[u]?(m=r,t.fillStyle=us.KEYFRAME_COLOR_HOVERED):i.selected[u]?t.fillStyle=us.KEYFRAME_COLOR_SELECTED:i.edited[u]?t.fillStyle=us.KEYFRAME_COLOR_EDITED:t.fillStyle=us.KEYFRAME_COLOR:t.fillStyle=us.KEYFRAME_COLOR_INACTIVE;let f=n[u];f=e.LX.clamp((f-l[0])/(l[1]-l[0]),0,1)*-c+(s-a),t.beginPath(),t.arc(g,f,m,0,2*Math.PI),t.fill(),t.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,r=this.optimizeThreshold;if(i.locked)return;let l=(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(l(n[t+e],n[i+e],n[o+e],r)){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,r=a+e.dim,l=s*e.dim;for(;a<r;++a)n=o[a],o[a]=o[l],o[l]=n,++l}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,r=t.values,l=this.animationClip.tracks[i];l.locked||(this.saveState(l.trackIdx,Boolean(n++)),this.historySaveEnabler=!1,this.addKeyFrames(l.trackIdx,r,a,-s+e,ps.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,r=n.times,l=n.values,c=new Float32Array(r.length+s.length),h=new Float32Array(l.length+s.length*a);this.saveState(e);let d=s.length-1,u=r.length-1,p=[];if(ps.ADDKEY_VALUESINARRAYS&o)for(let e=c.length-1;e>-1;--e){if(u<0||d>-1&&r[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]=l[u*a+t];c[e]=r[u--]}else for(let e=c.length-1;e>-1;--e)if(u<0||d>-1&&r[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]=l[u*a+t];c[e]=r[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 r=0;r<a;++r){const[a,l]=this.lastKeyFramesSelected[r];t[a].locked?t[a].selected[l]=!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(l))}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),r=i.values.slice(0,n*i.dim);let l=t[0],c=t[0]*i.dim;for(let e=0;e<t.length;++e){i.edited.splice(l,1),i.selected.splice(l,1),i.hovered.splice(l,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)r[c++]=i.values[e];for(let e=s+1;e<n;++e)a[l++]=i.times[e]}return i.times=a,i.values=r,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}}e.LX.KeyFramesTimeline=ps;class ms extends us{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(t,s={}){super(t,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=t=>{t.preventDefault(),t.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(t.localX))}})),e.LX.addContextMenu("Options",t,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,ms.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(t={}){return{id:t.id??t.name??"clip",start:t.start??0,duration:t.duration??1,fadein:t.fadein??void 0,fadeout:t.fadeout??void 0,clipColor:t.clipColor??e.LX.getCSSVariable("color-blue-600"),fadeColor:t.fadeColor??null,active:t.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 r=this.timeToX(a.start+a.duration);Math.abs(r-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 r=n+e,l=this.animationClip.tracks[r],c=this.animationClip.tracks[n],h=this.historyUndo[this.historyUndo.length-1];let d=0;for(;d<h.length&&r!=h[d].trackIdx;++d);d==h.length&&(this.historySaveEnabler=!0,this.saveState(r,!0),this.historySaveEnabler=!1);for(let e=i;e<=o;++e){let t=this.addClip(c.clips[s[e][1]],r,0);s[e][0]=t,l.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]=r;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],r=o.clips,l=o.clips[i];if(s>=0){if(r.length-1==i)continue;if(!o.selected[i+1]){if(r[i+1].start>=l.start+l.duration+s)continue;const e=r[i+1];n=Math.max(0,Math.min(n,e.start-l.start-l.duration))}}else if(s<0){if(i>0&&r[i-1].start+r[i-1].duration<=l.start+s)continue;if(i>0){const e=r[i-1];n=Math.min(0,Math.max(n,e.start+e.duration-l.start))}l.start+s<0&&(n=Math.max(n,-l.start),a=!1)}if(!a)continue;let c=this.getClipsInRange(o,l.start+s,l.start+l.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 r=i.clips[a];r.start+=n,null!=r.fadein&&(r.fadein+=n),null!=r.fadeout&&(r.fadeout+=n);const l=i.edited[a],c=i.selected[a],h=i.hovered[a];if(s>0)for(;a<o.length-1&&!(o[a+1].start>=r.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<=r.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]=r,i.edited[a]=l,i.selected[a]=c,i.hovered[a]=h,t[1]=a,r.start+r.duration>this.duration&&this.setDuration(r.start+r.duration),this.onContentMoved&&this.onContentMoved(r,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=us.TRACK_SELECTED,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"+us.FONT,e.textAlign="left",e.textBaseline="middle";for(var r=0;r<o.length;++r){a=null;const d=o[r];var l=Math.floor(this.timeToX(d.start))+.5,c=Math.floor(this.timeToX(d.start+d.duration))+.5,h=c-l;if(c<0||l>this.canvas.width)continue;if(e.globalAlpha=1,e.fillStyle=d.clipColor||(i.hovered[r]?us.KEYFRAME_COLOR_HOVERED:i.selected[r]?us.TRACK_SELECTED:us.KEYFRAME_COLOR),this.active&&i.active&&d.active||(e.fillStyle=us.KEYFRAME_COLOR_INACTIVE),gs(e,l,t+n,h,s,5,!0),this.active&&i.active&&d.active){if(e.fillStyle=d.fadeColor??"#0004",null!=d.fadein){gs(e,l,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);gs(e,l+h-i,t+n,i,s,{tl:0,bl:0,tr:5,br:5},!0)}}e.fillStyle=us.TRACK_COLOR_PRIMARY,(i.selected[r]||i.hovered[r])&&(e.strokeStyle=e.shadowColor=d.clipColor||us.TRACK_SELECTED,e.shadowBlur=10,e.shadowOffsetX=1.5,e.shadowOffsetY=1.5,a=[l-1,t+n-1,c-l+2,s+2],gs(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 "+us.FONT,e.fillStyle=us.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,l+.5*(h-p),t+n+.5*s),e.fillStyle=i.hovered[r]?"white":"#f5f5f5",e.strokeStyle="rgba(125,125,125,0.4)",gs(e,l+h-8,t+n,8,s,{tl:4,bl:4,tr:4,br:4},!0,!0)}e.font="12px"+us.FONT}optimizeTrack(e){}optimizeTracks(){}addClip(t,s=-1,i=0,o=0){if(!this.animationClip)return-1;this.deselectAllElements();let n=t.start+i;if(null!=t.fadein&&(t.fadein+=n-t.start),null!=t.fadeout&&(t.fadeout+=n-t.start),t.start=n,t.active=t.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=>e.LX.compareThresholdRange(n,t.start+t.duration,s.start,s.start+s.duration))){s=i;break}}s<0&&(s=this.addNewTrack())}t.trackIdx=s;const a=this.animationClip.tracks[s];let r=a.clips.findIndex(e=>e.start>n);return r<0&&(r=a.clips.length),this.saveState(s),a.clips.splice(r,0,t),a.hovered.splice(r,0,!1),a.selected.splice(r,0,!1),a.edited.splice(r,0,!1),(!this.animationClip||t.start+t.duration>this.duration)&&this.setDuration(t.start+t.duration),this.onUpdateTrack&&this.onUpdateTrack([s]),r}addClips(t,s=0,i=0){if(!this.animationClip||!t.length)return!1;let o=new Int16Array(t.length),n=i-1,a=-1;const r=this.animationClip.tracks,l=r.length;let c=0;for(;c<t.length;++c){const i=t[c],l=i.start+s,h=l+i.duration;if(0==c){for(++n,a=n;a>=r.length;)this.addNewTrack(null,!1);if(r[n].clips.find(t=>e.LX.compareThresholdRange(l,h,t.start,t.start+t.duration))){c=-1;continue}o[c]=n}else{let i=r[a].clips.find(t=>e.LX.compareThresholdRange(l,h,t.start,t.start+t.duration));for(let n=c-1;n>-1&&(o[n]==a&&!i);--n)i=e.LX.compareThresholdRange(l,h,t[n].start+s,t[n].start+s+t[n].duration);if(i&&(++a,a>=r.length&&this.addNewTrack(null,!1),i=r[a].clips.find(t=>e.LX.compareThresholdRange(l,h,t.start,t.start+t.duration))),i){c=-1;continue}o[c]=a}}l!=r.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<t.length;++c)this.addClip(t[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,ms.CLONEREASON_COPY)}pasteContent(e=this.currentTime){if(this.deselectAllClips(),!this.clipboard)return;e=Math.max(0,e);let t=this.cloneClips(this.clipboard,e,ms.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,ms.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 gs(e,t,s,i,o,n=5,a=!1,r=!1){if("number"==typeof n)n={tl:n,tr:n,br:n,bl:n};else{var l={tl:0,tr:0,br:0,bl:0};for(var c in l)n[c]=n[c]??l[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(),r&&e.stroke()}if(e.LX.ClipsTimeline=ms,!e.LX)throw"Missing LX namespace!";e.LX.extensions.push("VideoEditor");const fs=e.LX.vec2;e.LX.Area,e.LX.Panel;class Cs{static TIMEBAR_PLAY=1;static TIMEBAR_TRIM=2;static BACKGROUND_COLOR=e.LX.getCSSVariable("secondary");static COLOR=e.LX.getCSSVariable("accent");static ACTIVE_COLOR=e.LX.getCSSVariable("color-blue-400");type=Cs.TIMEBAR_PLAY;duration=1;canvas;ctx;options;markerWidth=8;markerHeight;offset;lineWidth;lineHeight;linePosition;startX;endX;currentX;hovering;dragging;_onMouseUpListener;_onMouseMoveListener;_mouseDownCanvasRect=null;updateTheme;onChangeCurrent;onChangeStart;onChangeEnd;onDraw;onMouse;constructor(t,s,i={}){this.type=s??Cs.TIMEBAR_PLAY,this.options=i??{},this.duration=i.duration??this.duration,this.canvas=document.createElement("canvas"),this.canvas.style.borderRadius="6px",this.canvas.width=t.size[0],this.canvas.height=t.size[1],t.attach(this.canvas),this.ctx=this.canvas.getContext("2d"),this.markerWidth=i.markerWidth??this.markerWidth,this.markerHeight=(i.markerHeight??.5)*this.canvas.height;const o=.5*this.markerWidth+5;"number"==typeof i.offset?this.offset=new fs(i.offset,i.offset):Array.isArray(i.offset)?this.offset=new fs(i.offset[0]??o,i.offset[1]??o):this.offset=new fs(o,o),this.lineWidth=this.canvas.width-2*this.offset.x,this.lineHeight=i.barHeight??5,this.linePosition=new fs(this.offset.x,.5*this.canvas.height-.5*this.lineHeight),this.startX=this.linePosition.x,this.endX=this.linePosition.x+this.lineWidth,this.currentX=this.startX,this._draw(),this.updateTheme=function(){Cs.BACKGROUND_COLOR=e.LX.getCSSVariable("secondary"),Cs.COLOR=e.LX.getCSSVariable("accent"),Cs.ACTIVE_COLOR=e.LX.getCSSVariable("color-blue-400")}.bind(this),e.LX.addSignal("@on_new_color_scheme",this.updateTheme),this.updateTheme(),this._onMouseUpListener=this.onMouseUp.bind(this),this._onMouseMoveListener=this.onMouseMove.bind(this),this.canvas.onmousedown=e=>this.onMouseDown(e),this.canvas.onmousemove=e=>{this.dragging||this.onMouseMove(e)}}unbind(){removeEventListener("mousemove",this._onMouseMoveListener),removeEventListener("mouseup",this._onMouseUpListener)}setDuration(e){this.duration=e}xToTime(e){return(e-this.offset.x)/this.lineWidth*this.duration}timeToX(e){return e/this.duration*this.lineWidth+this.offset.x}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=Cs.BACKGROUND_COLOR,e.clearRect(0,0,this.canvas.width,this.canvas.height),e.fillRect(0,0,this.canvas.width,this.canvas.height),e.fillStyle=Cs.COLOR,e.fillRect(this.linePosition.x,this.linePosition.y,this.lineWidth,this.lineHeight),e.fillStyle=Cs.ACTIVE_COLOR,e.fillRect(this.startX,this.linePosition.y,this.endX-this.startX,this.lineHeight),e.restore(),this._drawTrimMarker("start",this.startX,{color:null,fillColor:Cs.ACTIVE_COLOR||"#5f88c9"}),this._drawTrimMarker("end",this.endX,{color:null,fillColor:Cs.ACTIVE_COLOR||"#5f88c9"}),this._drawTimeMarker("current",this.currentX,{color:"#e5e5e5",fillColor:Cs.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.y;const o=s.width?s.width:this.dragging==e?6:4;this.canvas.height,this.offset.y;let n=this.ctx;n&&(n.globalAlpha=1,n.fillStyle=n.strokeStyle=s.fillColor||"#111",this.hovering==e&&(n.shadowColor="white",n.shadowBlur=2),n.fillStyle=n.strokeStyle="white",n.beginPath(),n.moveTo(t,i),n.lineTo(t,this.linePosition.y+.5*this.lineHeight),n.stroke(),n.closePath(),n.fillStyle=n.strokeStyle=s.fillColor||"#111",n.fillStyle=s.fillColor||"#e5e5e5",n.beginPath(),n.roundRect(t-.5*o,i-.5*o,o,o,5),n.fill(),n.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,n=Math.abs(this.startX-s),a=Math.abs(this.endX-s);(n<o||a<o)&&this.linePosition.y<i?(this.dragging=n<a||s<this.startX?"start":"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._mouseDownCanvasRect=t.getBoundingClientRect(),window.addEventListener("mousemove",this._onMouseMoveListener),window.addEventListener("mouseup",this._onMouseUpListener),this._draw()}onMouseUp(e){if(window.removeEventListener("mousemove",this._onMouseMoveListener),window.removeEventListener("mouseup",this._onMouseUpListener),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-this._mouseDownCanvasRect.left;if(e.target==t?e.offsetY:(e.clientY,this._mouseDownCanvasRect.top),this.dragging){switch(this.dragging){case"start":this.startX=Math.max(this.linePosition.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.linePosition.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]),this.markerHeight=(this.options.markerHeight??.5)*this.canvas.height;let t=e[0]-2*this.offset.x;t=t<1e-5?1e-5:t;const s=(this.startX-this.offset.x)/this.lineWidth,i=(this.currentX-this.offset.x)/this.lineWidth,o=(this.endX-this.offset.x)/this.lineWidth;this.lineWidth=t,this.linePosition.x=this.offset.x,this.linePosition.y=.5*this.canvas.height-.5*this.lineHeight,this.startX=Math.min(Math.max(t*s,0),t)+this.offset.x,this.currentX=Math.min(Math.max(t*i,0),t)+this.offset.x,this.endX=Math.min(Math.max(t*o,0),t)+this.offset.x,this._draw()}}e.LX.TimeBar=Cs;class vs{static CROP_HANDLE_L=1;static CROP_HANDLE_R=2;static CROP_HANDLE_T=4;static CROP_HANDLE_B=8;static CROP_HANDLE_TL=vs.CROP_HANDLE_L|vs.CROP_HANDLE_T;static CROP_HANDLE_BL=vs.CROP_HANDLE_L|vs.CROP_HANDLE_B;static CROP_HANDLE_TR=vs.CROP_HANDLE_R|vs.CROP_HANDLE_T;static CROP_HANDLE_BR=vs.CROP_HANDLE_R|vs.CROP_HANDLE_B;options={};playing=!1;videoReady=!1;controls=!0;speed=1;startTime=0;endTime=0;requestId;video;loop=!1;isDragging=!1;isResizing=null;crop=!1;dragOffsetX=0;dragOffsetY=0;timebar=null;mainArea;cropArea;videoArea;controlsArea;controlsComponents;onChangeCurrent;onChangeStart;onChangeEnd;onKeyUp;onSetTime;onVideoLoaded;onResize;onCropArea;onChangeSpeed;onChangeState;onChangeLoop;_updateTime=!0;_onCropMouseUp;_onCropMouseMove;resize=null;resizeControls=null;resizeVideo=null;constructor(e,t={}){this.options=t??{};const s=this.options.controlsLayout??{};this.speed=t.speed??this.speed,this.mainArea=e;let i=null,o=null;t.controlsArea?(i=e,o=t.controlsArea):[i,o]=e.split({type:"vertical",sizes:[s.height?`calc(100% - ${s.height})`:"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=t.crop,this.dragOffsetX=0,this.dragOffsetY=0;let n=this.video=t.video??document.createElement("video");this.loop=t.loop??this.loop,t.src&&(this.video.src=t.src,this.loadVideo(t)),t.videoArea?(t.videoArea.root.classList.add("lexvideoeditor"),t.videoArea.root.style.position="relative",t.videoArea.attach(this.cropArea),i.attach(t.videoArea)):(i.attach(n),i.attach(this.cropArea),i.root.classList.add("lexvideoeditor")),i.root.style.position="relative",this.videoArea=i,this.controlsArea=o,this.controlsComponents={timebar:null,playBtn:null,speedBtn:null,loopBtn:null,trimStartText:null,trimEndText:null,curTimeText:null,resetCropBtn:null},this.createControls(),this.resizeVideo=()=>{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])},this.resize=()=>{this.resizeVideo(),this.resizeControls()},e.onresize=this.resize.bind(this),window.addEventListener("resize",e.onresize),this.onKeyUp=e=>{this.controls&&" "==e.key&&(e.preventDefault(),e.stopPropagation(),this.controlsComponents.playBtn?.setState(!this.playing,!1))},window.addEventListener("keyup",this.onKeyUp),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,r=t.height;if(i&vs.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,r,!1)):(this.resizeCropArea(a,r,!1),this.moveCropArea(o,n,!1))}if(i&vs.CROP_HANDLE_R&&(a=e.clientX-t.left,this.resizeCropArea(a,r,!1)),i&vs.CROP_HANDLE_T){const i=Math.min(t.bottom-4,Math.max(s.top,e.clientY));r=t.top+t.height-i,n=i,i<t.top?(this.moveCropArea(o,n,!1),this.resizeCropArea(a,r,!1)):(this.resizeCropArea(a,r,!1),this.moveCropArea(o,n,!1))}i&vs.CROP_HANDLE_B&&(r=e.clientY-t.top,this.resizeCropArea(a,r,!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}createControls(t=null){const s=this.controlsArea;t&&(this.options.controlsLayout=t);const i=this.options.controlsLayout??{};for(;s.root.children.length;)s.root.children[0].remove();s.sections.length=0,this.controlsComponents.trimStartText=new e.LX.TextInput(null,this.timeToString(this.startTime),null,{width:"100px",title:"Trimmed Start Time",disabled:!0,inputClass:"bg-none"}),this.controlsComponents.trimEndText=new e.LX.TextInput(null,this.timeToString(this.endTime),null,{width:"100px",title:"Trimmed End Time",disabled:!0,inputClass:"bg-none"}),this.controlsComponents.curTimeText=new e.LX.TextInput(null,this.video.currentTime,null,{title:"Current Time",float:"center",disabled:!0,inputClass:"bg-none"}),this.controlsComponents.resetCropBtn=new e.LX.Button("ResetCrop",null,e=>{this.moveCropArea(0,0,!0),this.resizeCropArea(1,1,!0),this.onCropArea&&this.onCropArea(this.getCroppedArea())},{width:"40px",title:"Reset Crop Area",icon:"Crop@solid",hideName:!0,className:"justify-center"+(this.crop?"":" hidden")}),this.controlsComponents.playBtn=new e.LX.Button("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(),this.onChangeState&&this.onChangeState(e)},{width:"40px",title:"Play/Pause",icon:"Play@solid",swap:"Pause@solid",hideName:!0,className:"justify-center"}),this.controlsComponents.playBtn.setState(this.playing,!0),this.controlsComponents.speedBtn=new e.LX.Button("Speed","",(t,s)=>{const i=new e.LX.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 e.LX.Popover(s.target,[i],{align:"start",side:"top",sideOffset:12})},{width:"40px",title:"Speed",hideName:!0,icon:"Timer@solid",className:"justify-center"}),this.controlsComponents.loopBtn=new e.LX.Button("","Loop",e=>{this.loop=e,this.onChangeLoop&&this.onChangeLoop(e)},{width:"40px",hideName:!0,title:"Loop",icon:"Repeat@solid",className:"justify-center",selectable:!0,selected:this.loop});let o=null;o="function"==typeof i.type?i.type:1==i.type?this._createControlsLayout_1():this._createControlsLayout_0(),this.timebar&&this.timebar.unbind(),this.timebar=this.controlsComponents.timebar=new Cs(o,Cs.TIMEBAR_TRIM,{offset:[12,null]}),this.timebar.onChangeCurrent=this._setCurrentTime.bind(this),this.timebar.onChangeStart=this._setStartTime.bind(this),this.timebar.onChangeEnd=this._setEndTime.bind(this);let n=1;this.video.duration===1/0||isNaN(this.video.duration)||(n=this.video.duration),this.timebar.setDuration(n),this.timebar.setEndTime(this.endTime),this.timebar.setStartTime(this.startTime),this.timebar.setCurrentTime(this.startTime),this.resizeControls()}_createControlsLayout_1(){const t=this.controlsArea,s=this.options.controlsLayout??{};let[i,o]=t.split({type:"vertical",sizes:[s.l1TimelineHeight??"50%",null],minimizable:!1,resize:!1});o.root.classList.add("relative");let n=document.createElement("p");n.style.alignContent="center",n.innerText="/";let a=e.LX.makeContainer(["fit-content","100%"],"relative flex flex-row pb-2",null,o,{float:"right"});a.appendChild(this.controlsComponents.trimStartText.root),a.appendChild(n),a.appendChild(this.controlsComponents.trimEndText.root),this.controlsComponents.trimStartText.root.querySelector("input").classList.add("text-end"),this.controlsComponents.trimStartText.root.classList.add("top-0","bottom-0"),this.controlsComponents.trimEndText.root.classList.add("top-0","bottom-0"),e.LX.makeContainer(["100%","100%"],"absolute top-0 left-0 flex flex-row justify-center items-center pb-2",null,o,{}).appendChild(this.controlsComponents.curTimeText.root);const r=o.addPanel({className:"absolute top-0 left-0 flex flex-row pl-4 pr-4 pt-1 pb-2"});return r.root.classList.remove("pad-md"),r._attachComponent(this.controlsComponents.playBtn),r._attachComponent(this.controlsComponents.speedBtn),r._attachComponent(this.controlsComponents.loopBtn),r._attachComponent(this.controlsComponents.resetCropBtn),this.controlsComponents.playBtn.root.classList.add("pl-0"),this.controlsComponents.resetCropBtn.root.classList.add("pr-0"),i.root.classList.add("p-4","pb-0"),this.resizeControls=()=>{const e=getComputedStyle(i.root);let t=parseFloat(e.paddingLeft),s=parseFloat(e.paddingRight),o=parseFloat(e.paddingTop),n=parseFloat(e.paddingBottom);this.timebar.resize([i.root.clientWidth-t-s,i.root.clientHeight-o-n])},i}_createControlsLayout_0(){const e=this.controlsArea;let[t,s]=e.split({type:"vertical",sizes:["50%",null],minimizable:!1,resize:!1});s.setSize([s.size[0],40]);let[i,o]=s.split({type:"horizontal",sizes:["92%",null],minimizable:!1,resize:!1}),[n,a]=i.split({type:"horizontal",sizes:["10%",null],minimizable:!1,resize:!1});t.addPanel({className:"flex"})._attachComponent(this.controlsComponents.curTimeText),n.root.classList.add("min-w-fit");const r=n.addPanel({className:"lexcontrolspanel p-0 pl-2"});r.root.classList.remove("pad-md"),r.sameLine(),r._attachComponent(this.controlsComponents.playBtn),r._attachComponent(this.controlsComponents.speedBtn),r._attachComponent(this.controlsComponents.loopBtn),r._attachComponent(this.controlsComponents.trimStartText),r.endLine(),o.root.classList.add("min-w-fit");const l=o.addPanel({className:"lexcontrolspanel p-0"});return l.root.classList.remove("pad-md"),l._attachComponent(this.controlsComponents.trimEndText),this.resizeControls=()=>{s.setSize([this.controlsArea.root.clientWidth,40]);let e=this.controlsArea.root.clientWidth-n.root.clientWidth-o.root.clientWidth;this.timebar.resize([e,a.root.clientHeight])},a}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&vs.CROP_HANDLE_L&&s("l",vs.CROP_HANDLE_L),e&vs.CROP_HANDLE_R&&s("r",vs.CROP_HANDLE_R),e&vs.CROP_HANDLE_T&&s("t",vs.CROP_HANDLE_T),e&vs.CROP_HANDLE_B&&s("b",vs.CROP_HANDLE_B),(e&vs.CROP_HANDLE_TL)==vs.CROP_HANDLE_TL&&s("tl",vs.CROP_HANDLE_TL),(e&vs.CROP_HANDLE_BL)==vs.CROP_HANDLE_BL&&s("bl",vs.CROP_HANDLE_BL),(e&vs.CROP_HANDLE_TR)==vs.CROP_HANDLE_TR&&s("tr",vs.CROP_HANDLE_TR),(e&vs.CROP_HANDLE_BR)==vs.CROP_HANDLE_BR&&s("br",vs.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,r=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 ${r-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,r=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 ${r}px, linear-gradient(rgba(0, 0, 0, 0.3) 0 0)`,e[t].style.webkitMaskRepeat="no-repeat"}}const l=this.cropArea.parentElement.getBoundingClientRect();this.cropArea.style.left=o-l.left+"px",this.cropArea.style.top=n-l.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.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.controlsComponents.playBtn?.setState(!1,!0))),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.controlsComponents.curTimeText?.set(this.timeToString(e)),this.onSetTime&&this.onSetTime(e),this.onChangeCurrent&&this.onChangeCurrent(e)}_setStartTime(e){this.startTime=this.video.currentTime=e,this.controlsComponents.trimStartText?.set(this.timeToString(e)),this.onSetTime&&this.onSetTime(e),this.onChangeStart&&this.onChangeStart(e)}_setEndTime(e){this.endTime=this.video.currentTime=e,this.controlsComponents.trimEndText?.set(this.timeToString(e)),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.crop=!0,this.cropArea.classList.remove("hidden"),this.controlsComponents.resetCropBtn?.root.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.crop=!1,this.cropArea.classList.add("hidden"),this.controlsComponents.resetCropBtn?.root.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.controlsComponents.playBtn?.setState(!1,!0),this.video.src="",this.timebar&&this.timebar.unbind(),window.removeEventListener("keyup",this.onKeyUp),document.removeEventListener("mouseup",this._onCropMouseUp),document.removeEventListener("mousemove",this._onCropMouseMove)}}e.LX.VideoEditor=vs,e.AlertDialog=ce,e.Area=te,e.AreaOverlayButtons=ee,e.ArrayInput=u,e.AssetView=St,e.Avatar=ae,e.BaseComponent=n,e.BoundingBox=Vt,e.Branch=Q,e.Button=a,e.Checkbox=m,e.ClipsTimeline=ms,e.CodeEditor=_t,e.ColorInput=v,e.ComboButtons=y,e.ContextMenu=he,e.Counter=L,e.Curve=x,e.DatePicker=S,e.Dial=T,e.Dialog=le,e.DocMaker=Dt,e.DropdownMenu=de,e.FileInput=E,e.Footer=pe,e.Form=M,e.GraphEditor=Gt,e.GraphNode=Kt,e.IEvent=o,e.ImUI=ls,e.KeyFramesTimeline=ps,e.Knob=At,e.Layers=A,e.List=X,e.Map2D=I,e.NodeTree=O,e.NumberInput=c,e.OTPInput=z,e.Pad=D,e.Pagination=G,e.Panel=J,e.PocketDialog=me,e.Popover=C,e.Progress=B,e.RadioGroup=H,e.RangeInput=F,e.Rate=$,e.Select=d,e.Sheet=ge,e.Sidebar=fe,e.SizeInput=V,e.Skeleton=Ce,e.Spinner=re,e.TabSections=K,e.Table=q,e.Tabs=l,e.Tags=W,e.TextArea=U,e.TextInput=h,e.TimeBar=Cs,e.Timeline=us,e.Title=Y,e.Toggle=j,e.Tokenizer=xe,e.Tour=ve,e.Tree=R,e.Vector=Z,e.VideoEditor=vs,e.addDropdownMenu=ue,e.vec2=P});
|